
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
talk-to-code
Advanced tools
A lightweight library that lets developers interact with their code using natural language
A lightweight JavaScript library that lets developers interact with their code using natural language in the browser console.
Talk to Code provides a natural language interface for your JavaScript code. It hooks into the browser's console and lets you run commands like:
talk("what's in myAppState?");
// → { score: 42, level: 3 }
talk("call startGame with easy mode");
// → calls `startGame('easy')`
talk("log all DOM elements with class player");
// → logs all `.player` elements
npm install talk-to-code
// ES Modules
import { talk, setContext } from 'talk-to-code';
// CommonJS
const { talk, setContext } = require('talk-to-code');
// Browser (UMD)
<script src="dist/talkToCode.min.js"></script>
const { talk, setContext } = TalkToCode;
// Set up the context that Talk to Code can access
setContext({
startGame,
myAppState,
player
});
// Start using natural language commands
talk("what's in myAppState?");
talk("call startGame with easy mode");
Talk to Code interprets natural language commands and maps them to JavaScript code, functions, or data:
talk("what is counter?"); // Gets a variable's value
talk("show user profile"); // Displays nested objects
talk("call resetGame"); // Calls a function without arguments
talk("run saveScore with 42"); // Calls a function with arguments
Tell Talk to Code what variables and functions it can access:
// Set the initial context
setContext({
game: {
score: 100,
level: 3,
player: { health: 80 }
},
startGame: (difficulty) => { /* ... */ },
resetGame: () => { /* ... */ }
});
// Add more items to the context later
addToContext({
saveScore: (score) => { /* ... */ }
});
Find DOM elements using natural language:
talk("find elements with class player");
// → Returns array of elements with class "player"
talk("search for elements having id game-container");
// → Returns element with id "game-container"
Enable voice commands in supported browsers:
import { enableVoiceMode } from 'talk-to-code';
// Start voice recognition
const voice = enableVoiceMode();
// Now you can speak commands like "What is game score"
// Stop voice recognition when done
voice.stop();
talk(command: string): anyProcesses a natural language command and returns the result.
talk("what is user.name?");
talk("call greetUser with Alice");
setContext(context: object): booleanSets the context (variables and functions) that Talk to Code can access.
true if successful, false otherwisesetContext({
myApp: window.myApp,
startGame: window.startGame
});
addToContext(additionalContext: object): booleanAdds items to the existing context.
true if successful, false otherwiseaddToContext({
newVariable: 'new value',
newFunction: () => console.log('Hello')
});
enableVoiceMode(options?: object): object | falseEnables voice command mode in supported browsers.
stop() method, or false if not supportedconst voice = enableVoiceMode({
continuous: true,
lang: 'en-US'
});
// Stop listening
voice.stop();
talk("what is counter?");
talk("show me user");
talk("display user.profile");
talk("log the game.score");
talk("call startGame");
talk("run resetGame");
talk("execute calculateScore");
talk("call startGame with easy");
talk("run setVolume with 50");
talk("execute movePlayer with left, 10");
talk("find elements with class player");
talk("search for elements having id game-container");
import { talk, setContext } from 'talk-to-code';
const gameState = {
score: 0,
level: 1,
player: {
health: 100,
position: { x: 0, y: 0 }
}
};
function startGame(difficulty = 'normal') {
console.log(`Starting game in ${difficulty} mode`);
return `Game started in ${difficulty} mode`;
}
function movePlayer(direction, amount) {
const position = gameState.player.position;
switch(direction) {
case 'left': position.x -= amount; break;
case 'right': position.x += amount; break;
case 'up': position.y -= amount; break;
case 'down': position.y += amount; break;
}
return `Player moved ${direction} by ${amount}`;
}
setContext({
gameState,
startGame,
movePlayer
});
// Now you can use natural language commands
talk("what is gameState.player.health"); // 100
talk("call startGame with hard"); // "Game started in hard mode"
talk("call movePlayer with right, 5"); // "Player moved right by 5"
talk("what is gameState.player.position"); // { x: 5, y: 0 }
# Install dependencies
npm install
# Run tests
npm test
# Build the library
npm run build
MIT
FAQs
A lightweight library that lets developers interact with their code using natural language
We found that talk-to-code demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.