Minimal AI-powered CLI that can read/search files and, with explicit approval, create files and folders. Uses Google Generative AI via the ai SDK.
If the GIF does not load or you need audio, open the video directly: demo.mp4
- Minimal interactive or one-shot CLI
- Tools:
read_file: Read absolute path files (optional line range)grep: Regex search with optional include patternmkdir: Create directories (requires ALLOW_WRITE)write_file: Create/overwrite files (requires ALLOW_WRITE)
- Write-safety gate: Writing is blocked unless you include
ALLOW_WRITEin your query - Windows-friendly absolute paths (e.g.,
D:\path\to\file.ts)
- Node.js >= 20
- A Google Generative AI API key
npm i
npm run buildCreate a .env file in the project root (not committed) or set the env var in your shell:
GOOGLE_GENERATIVE_AI_API_KEY=your_key_here
See .env.example for reference. Never commit your real key.
- Interactive:
npm start
# or from anywhere
node D:\course\Learning_Coding_Projects\Projects\cli-agent\dist\index.jsAt the prompt Query>:
-
Read/search only:
search for TODO in D:\path\to\project include .*\.ts$read D:\path\to\project\src\index.ts
-
Allow writes (requires explicit token):
ALLOW_WRITE create minimal express app at D:\path\to\xyz
-
One-shot:
node dist/index.js --query "search for 'TODO' in D:\\path\\to\\xyz include .*\\.ts$"- Change directory first, or provide absolute paths in your queries. The agent respects absolute Windows paths and will operate there.
- Secrets:
.envis gitignored. Do not commit real API keys. Use.env.exampleto share the variable names. - If a secret was ever committed, rotate/revoke it immediately and force-push a history rewrite if necessary.
- Write-safety: The agent will not create or modify files unless the latest message contains the exact token
ALLOW_WRITE. - Recommended: run it in a sandbox folder and review planned writes before enabling them.
--query <text>: run a single query non-interactively
--cwdand--allow-writeflags- Better JSON extraction and loop guards
- Default grep ignore for node_modules/dist
MIT
