Quick Start
Quick Start
This guide walks you through creating and running your first mentu script.
Prerequisites
- mentu CLI installed (
mentu --versionprints output) - Node.js 20+ installed (
node --version)
Create your first script
Create a file at ~/.mentu/scripts/hello.ts:
const name = mentu.vars.NAME ?? 'world';
const stats = mentu.cir.stats();
console.log(`Hello, ${name}!`);
console.log(`CIR: ${stats.signals} signals, ${stats.contradictions} contradictions`);
return { greeting: `Hello, ${name}!`, stats };Run it
mentu script run hello --var NAME=developerExpected output
Hello, developer!
CIR: 1432 signals, 3 contradictions
{
"greeting": "Hello, developer!",
"stats": {
"signals": 1432,
"relations": 287,
"embeddings": 956,
"patterns": 41,
"contradictions": 3,
"database_size_bytes": 4218904
}
}Console output (console.log) prints first, followed by the return value serialized as JSON.
What happened
- The CLI resolved
helloto~/.mentu/scripts/hello.ts - Node.js spawned a V8 sandbox with the
mentuSDK injected as a global mentu.vars.NAMEread the--var NAME=developerargumentmentu.cir.stats()shelled out tomentu cir stats --format jsonand returned the parsed result- Console output and the return value were printed to stdout
List available scripts
mentu script listThis searches both {workspace}/.mentu/scripts/ and ~/.mentu/scripts/ and displays all discovered scripts.
Next steps
- Query CIR signals —
mentu.cir.query({ type: 'observation', limit: 10 }) - Read a secret —
mentu.vault.get('MY_API_KEY') - Check system health —
mentu.health.check() - Send a notification —
mentu.notify.send('Alert', 'Something happened')
See the SDK Reference for the complete API.