mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
feat: add NanoClaw agent REPL — persistent session-aware CLI for ECC
Implements a barebones agent loop that delegates to `claude -p` with markdown-as-database session persistence and ECC skill context loading. Zero external dependencies, ~264 lines of pure Node.js CommonJS. - scripts/claw.js: core module (storage, context, delegation, REPL) - commands/claw.md: slash command definition with usage docs - tests/scripts/claw.test.js: 14 unit tests covering all modules - package.json: add claw script and files entry - tests/run-all.js: register claw tests in test manifest
This commit is contained in:
79
commands/claw.md
Normal file
79
commands/claw.md
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
description: Start the NanoClaw agent REPL — a persistent, session-aware AI assistant powered by the claude CLI.
|
||||
---
|
||||
|
||||
# Claw Command
|
||||
|
||||
Start an interactive AI agent session that persists conversation history to disk and optionally loads ECC skill context.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
node scripts/claw.js
|
||||
```
|
||||
|
||||
Or via npm:
|
||||
|
||||
```bash
|
||||
npm run claw
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `CLAW_SESSION` | `default` | Session name (alphanumeric + hyphens) |
|
||||
| `CLAW_SKILLS` | *(empty)* | Comma-separated skill names to load as system context |
|
||||
|
||||
## REPL Commands
|
||||
|
||||
Inside the REPL, type these commands directly at the prompt:
|
||||
|
||||
```
|
||||
/clear Clear current session history
|
||||
/history Print full conversation history
|
||||
/sessions List all saved sessions
|
||||
/help Show available commands
|
||||
exit Quit the REPL
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Reads `CLAW_SESSION` env var to select a named session (default: `default`)
|
||||
2. Loads conversation history from `~/.claude/claw/{session}.md`
|
||||
3. Optionally loads ECC skill context from `CLAW_SKILLS` env var
|
||||
4. Enters a blocking prompt loop — each user message is sent to `claude -p` with full history
|
||||
5. Responses are appended to the session file for persistence across restarts
|
||||
|
||||
## Session Storage
|
||||
|
||||
Sessions are stored as Markdown files in `~/.claude/claw/`:
|
||||
|
||||
```
|
||||
~/.claude/claw/default.md
|
||||
~/.claude/claw/my-project.md
|
||||
```
|
||||
|
||||
Each turn is formatted as:
|
||||
|
||||
```markdown
|
||||
### [2025-01-15T10:30:00.000Z] User
|
||||
What does this function do?
|
||||
---
|
||||
### [2025-01-15T10:30:05.000Z] Assistant
|
||||
This function calculates...
|
||||
---
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
# Start default session
|
||||
node scripts/claw.js
|
||||
|
||||
# Named session
|
||||
CLAW_SESSION=my-project node scripts/claw.js
|
||||
|
||||
# With skill context
|
||||
CLAW_SKILLS=tdd-workflow,security-review node scripts/claw.js
|
||||
```
|
||||
Reference in New Issue
Block a user