@praveencs/agent 0.3.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +42 -982
  2. package/dist/src/cli/commands/goal.d.ts.map +1 -1
  3. package/dist/src/cli/commands/goal.js +67 -0
  4. package/dist/src/cli/commands/goal.js.map +1 -1
  5. package/dist/src/cli/commands/report.d.ts +3 -0
  6. package/dist/src/cli/commands/report.d.ts.map +1 -0
  7. package/dist/src/cli/commands/report.js +34 -0
  8. package/dist/src/cli/commands/report.js.map +1 -0
  9. package/dist/src/cli/commands/skills.d.ts.map +1 -1
  10. package/dist/src/cli/commands/skills.js +100 -0
  11. package/dist/src/cli/commands/skills.js.map +1 -1
  12. package/dist/src/cli/index.d.ts.map +1 -1
  13. package/dist/src/cli/index.js +3 -1
  14. package/dist/src/cli/index.js.map +1 -1
  15. package/dist/src/goals/decomposer.d.ts +41 -0
  16. package/dist/src/goals/decomposer.d.ts.map +1 -0
  17. package/dist/src/goals/decomposer.js +167 -0
  18. package/dist/src/goals/decomposer.js.map +1 -0
  19. package/dist/src/goals/executor.d.ts +52 -0
  20. package/dist/src/goals/executor.d.ts.map +1 -0
  21. package/dist/src/goals/executor.js +198 -0
  22. package/dist/src/goals/executor.js.map +1 -0
  23. package/dist/src/goals/store.d.ts +4 -0
  24. package/dist/src/goals/store.d.ts.map +1 -1
  25. package/dist/src/goals/store.js +13 -0
  26. package/dist/src/goals/store.js.map +1 -1
  27. package/dist/src/memory/store.d.ts +12 -0
  28. package/dist/src/memory/store.d.ts.map +1 -1
  29. package/dist/src/memory/store.js +57 -1
  30. package/dist/src/memory/store.js.map +1 -1
  31. package/dist/src/reporting/generator.d.ts +14 -0
  32. package/dist/src/reporting/generator.d.ts.map +1 -0
  33. package/dist/src/reporting/generator.js +91 -0
  34. package/dist/src/reporting/generator.js.map +1 -0
  35. package/dist/src/skills/doctor.d.ts +30 -0
  36. package/dist/src/skills/doctor.d.ts.map +1 -0
  37. package/dist/src/skills/doctor.js +108 -0
  38. package/dist/src/skills/doctor.js.map +1 -0
  39. package/dist/src/skills/loader.d.ts +4 -0
  40. package/dist/src/skills/loader.d.ts.map +1 -1
  41. package/dist/src/skills/loader.js +13 -0
  42. package/dist/src/skills/loader.js.map +1 -1
  43. package/package.json +2 -2
package/README.md CHANGED
@@ -1,1007 +1,67 @@
1
- <p align="center">
2
- <h1 align="center">🤖 Agent Runtime</h1>
3
- <p align="center">
4
- A CLI agent runtime that executes goals safely with <b>Skills</b>, <b>Plan Files</b>, and <b>permissioned tools</b>.<br/>
5
- Multi-LLM • Policy-gated • Audit-logged • MCP-compatible
6
- </p>
7
- <p align="center">
8
- <a href="https://www.npmjs.com/package/@praveencs/agent"><img src="https://img.shields.io/npm/v/@praveencs/agent.svg" alt="npm version"></a>
9
- <a href="https://github.com/praveencs87/agent"><img src="https://img.shields.io/github/stars/praveencs87/agent.svg?style=social" alt="GitHub stars"></a>
10
- <a href="https://github.com/praveencs87/agent/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
11
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg" alt="Node.js"></a>
12
- </p>
13
- </p>
1
+ # Agent Runtime
14
2
 
15
- ---
3
+ An autonomous, goal-oriented AI agent runtime with persistent memory, skill execution, and self-improvement capabilities.
16
4
 
17
- ## Table of Contents
5
+ ## Features
18
6
 
19
- - [Overview](#overview)
20
- - [Installation](#installation)
21
- - [Quick Start](#quick-start)
22
- - [Project Structure](#project-structure)
23
- - [CLI Reference](#cli-reference)
24
- - [agent init](#agent-init)
25
- - [agent run](#agent-run)
26
- - [agent skills](#agent-skills)
27
- - [agent plan](#agent-plan)
28
- - [agent daemon](#agent-daemon)
29
- - [agent mcp](#agent-mcp)
30
- - [agent doctor](#agent-doctor)
31
- - [agent config](#agent-config)
32
- - [Configuration](#configuration)
33
- - [agent.config.json](#agentconfigjson)
34
- - [Models & Routing](#models--routing)
35
- - [Policy & Permissions](#policy--permissions)
36
- - [Environment Variables](#environment-variables)
37
- - [Skills](#skills)
38
- - [Skill Manifest (skill.json)](#skill-manifest-skilljson)
39
- - [Prompt-Based Skills](#prompt-based-skills)
40
- - [Workflow-Based Skills](#workflow-based-skills)
41
- - [Skill Lifecycle](#skill-lifecycle)
42
- - [Plan Files](#plan-files)
43
- - [Writing a Plan](#writing-a-plan)
44
- - [Triggers](#triggers)
45
- - [Propose Mode](#propose-mode)
46
- - [Built-in Tools](#built-in-tools)
47
- - [MCP Integration](#mcp-integration)
48
- - [Daemon & Scheduling](#daemon--scheduling)
49
- - [Audit Logs](#audit-logs)
50
- - [Development](#development)
51
- - [License](#license)
52
-
53
- ---
54
-
55
- ## Overview
56
-
57
- **Agent Runtime** is a command-line framework for building, running, and managing AI-powered automation safely. It provides:
58
-
59
- - **Skills** — reusable, versioned units of automation (prompt-based or workflow-based)
60
- - **Plan Files** — declarative YAML pipelines with step-by-step execution, dependencies, and verification
61
- - **Permissioned Tools** — a gated tool system (`fs.*`, `cmd.run`, `git.*`) with policy-based approval
62
- - **Multi-LLM Routing** — supports Azure OpenAI, OpenAI, Anthropic, and Ollama with fallback chains
63
- - **MCP Server** — expose tools and skills to any MCP-compatible editor (VS Code, Cursor, etc.)
64
- - **Background Daemon** — cron scheduling, filesystem watchers, and event-based triggers
65
- - **Audit Logging** — every run produces a detailed log with diffs, timing, and verification results
66
-
67
- ---
68
-
69
- ## Installation
70
-
71
- ### Prerequisites
72
-
73
- - **Node.js** ≥ 18.0.0
74
- - **npm** or **yarn**
75
- - An LLM API key (Azure OpenAI, OpenAI, Anthropic) or a running Ollama instance
76
-
77
- ### Install from npm
78
-
79
- ```bash
80
- npm install -g @praveencs/agent
81
- ```
82
-
83
- ### Install from source
84
-
85
- ```bash
86
- git clone https://github.com/praveencs87/agent.git
87
- cd agent
88
- npm install
89
- npm run build
90
-
91
- # Link globally
92
- npm link
93
- ```
94
-
95
- After installation, the `agent` command is available system-wide.
96
-
97
- ### Verify installation
98
-
99
- ```bash
100
- agent --version # 0.1.0
101
- agent --help # Show all commands
102
- agent doctor # Check system health
103
- ```
104
-
105
- ---
7
+ - **🧠 Goal Decomposition**: Breaks high-level objectives into actionable tasks using LLM reasoning.
8
+ - **⚡ Autonomous Execution**: Runs tasks in the background via a daemon process.
9
+ - **💾 Persistent Memory**: SQLite-based memory store with FTS5 search for context retention.
10
+ - **🛠️ Skill System**: Extensible toolset defined by simple markdown prompts.
11
+ - **📊 Reporting**: Generates daily activity reports and executive summaries.
12
+ - **❤️ Self-Improvement**: Tracks skill performance and automatically patches broken skills.
106
13
 
107
14
  ## Quick Start
108
15
 
109
- ### 1. Initialize a project
110
-
111
- ```bash
112
- cd your-project
113
- agent init
114
- ```
115
-
116
- This creates:
117
-
118
- ```
119
- .agent/
120
- ├── agent.config.json # Project configuration
121
- ├── skills/ # Installed skills
122
- ├── plans/ # Plan files (.plan.yaml)
123
- ├── runs/ # Execution audit logs
124
- ├── plugins/ # Tool plugins
125
- └── logs/ # Application logs
126
- ```
127
-
128
- ### 2. Run a goal
129
-
130
- ```bash
131
- # Ask the LLM to accomplish a task
132
- agent run "refactor the utils module to use async/await"
133
-
134
- # Run with a specific skill
135
- agent run "add input validation" --skill validate-inputs
136
-
137
- # Autonomous mode (auto-approve low-risk actions)
138
- agent run "fix all lint errors" --autonomous
139
- ```
140
-
141
- ### 3. Create and use a skill
142
-
143
- ```bash
144
- agent skills create my-formatter
145
- # Edit .agent/skills/my-formatter/prompt.md
146
- agent run "format the codebase" --skill my-formatter
147
- ```
148
-
149
- ### 4. Execute a plan
150
-
151
- ```bash
152
- # Create .agent/plans/deploy.plan.yaml (see Plan Files section)
153
- agent plan validate deploy
154
- agent plan run deploy
155
- ```
156
-
157
- ---
158
-
159
- ## Project Structure
160
-
161
- ```
162
- .agent/ # Agent workspace (per-project)
163
- ├── agent.config.json # Configuration
164
- ├── skills/ # Skill directories
165
- │ └── my-skill/
166
- │ ├── skill.json # Skill manifest
167
- │ └── prompt.md # or workflow.ts
168
- ├── plans/ # Plan files
169
- │ └── deploy.plan.yaml
170
- ├── runs/ # Audit logs per run
171
- │ └── run_20260212_143000/
172
- │ ├── run.json
173
- │ └── diffs.json
174
- ├── plugins/ # Tool plugins
175
- └── logs/ # Application logs
176
- ```
177
-
178
- ---
179
-
180
- ## CLI Reference
181
-
182
- ### Global Options
183
-
184
- ```
185
- -V, --version Output the version number
186
- --verbose Enable verbose output
187
- --no-color Disable colored output
188
- --config <path> Path to config file
189
- -h, --help Display help for command
190
- ```
191
-
192
- ---
193
-
194
- ### `agent init`
195
-
196
- Initialize agent configuration in the current project.
197
-
198
- ```bash
199
- agent init
200
- ```
201
-
202
- Creates the `.agent/` directory structure with a default `agent.config.json`, empty `skills/` and `plans/` directories, and registers all core tools.
203
-
204
- ---
205
-
206
- ### `agent run`
207
-
208
- Execute a goal or task using LLM reasoning or a specific skill.
209
-
210
- ```bash
211
- agent run <goal> [options]
212
- ```
213
-
214
- **Arguments:**
215
-
216
- | Argument | Description |
217
- |----------|-------------|
218
- | `<goal>` | Goal description or task to run |
219
-
220
- **Options:**
221
-
222
- | Option | Description |
223
- |--------|-------------|
224
- | `-s, --skill <name>` | Use a specific installed skill |
225
- | `-a, --autonomous` | Auto-approve low-risk actions |
226
- | `--dry-run` | Show what would be done without executing |
227
-
228
- **Examples:**
229
-
230
- ```bash
231
- # Free-form goal via LLM
232
- agent run "add error handling to the API routes"
233
-
234
- # Specific skill with inputs
235
- agent run "src/" --skill code-review
236
-
237
- # Preview without executing
238
- agent run "delete all temp files" --dry-run
239
- ```
240
-
241
- ---
242
-
243
- ### `agent skills`
244
-
245
- Manage installed skills.
246
-
247
- #### `agent skills list`
248
-
249
- List all installed skills with their name, version, state, and description.
250
-
251
- ```bash
252
- agent skills list
253
- ```
254
-
255
- #### `agent skills create <name>`
256
-
257
- Scaffold a new skill from the built-in template.
258
-
259
- ```bash
260
- agent skills create my-linter
261
- ```
262
-
263
- Creates:
264
- ```
265
- .agent/skills/my-linter/
266
- ├── skill.json # Manifest (edit this)
267
- └── prompt.md # Entrypoint prompt (edit this)
268
- ```
269
-
270
- #### `agent skills install <source>`
271
-
272
- Install a skill from a local path.
273
-
274
- ```bash
275
- agent skills install /path/to/skill-directory
276
- ```
277
-
278
- #### `agent skills remove <name>`
279
-
280
- Remove an installed skill.
281
-
282
- ```bash
283
- agent skills remove my-linter
284
- ```
285
-
286
- #### `agent skills info <name>`
287
-
288
- Display detailed information about a skill — manifest, tools, permissions, and validation status.
289
-
290
- ```bash
291
- agent skills info my-linter
292
- ```
293
-
294
- #### `agent skills update`
295
-
296
- Check for and apply skill updates (currently supports local skills).
297
-
298
- ```bash
299
- agent skills update
300
- ```
301
-
302
- ---
303
-
304
- ### `agent plan`
305
-
306
- Manage and execute plan files.
307
-
308
- #### `agent plan list`
309
-
310
- List all discovered `.plan.yaml` files.
311
-
312
- ```bash
313
- agent plan list
314
- ```
315
-
316
- #### `agent plan validate <name>`
317
-
318
- Parse and validate a plan file, showing goals, steps, mode, and trigger type.
319
-
320
- ```bash
321
- agent plan validate deploy
322
- ```
323
-
324
- #### `agent plan run <name>`
325
-
326
- Execute a plan with all its steps.
327
-
328
- ```bash
329
- agent plan run deploy
330
- agent plan run deploy --autonomous
331
- ```
332
-
333
- **Options:**
334
-
335
- | Option | Description |
336
- |--------|-------------|
337
- | `-a, --autonomous` | Auto-approve low-risk actions during execution |
338
-
339
- #### `agent plan propose <name>`
340
-
341
- Create a draft run for review before execution.
342
-
343
16
  ```bash
344
- agent plan propose deploy
345
- # Review, then:
346
- agent plan approve <runId>
347
- agent plan execute <runId>
348
- ```
349
-
350
- #### `agent plan runs`
351
-
352
- List the last 20 plan runs with status and plan name.
353
-
354
- ```bash
355
- agent plan runs
356
- ```
357
-
358
- #### `agent plan show <runId>`
359
-
360
- Display detailed information about a specific run — status, steps, timing, verification results.
361
-
362
- ```bash
363
- agent plan show run_20260212_143000
364
- ```
365
-
366
- #### `agent plan approve <runId>`
367
-
368
- Approve a proposed plan run (changes status from `proposed` → `pending`).
369
-
370
- ```bash
371
- agent plan approve run_20260212_143000
372
- ```
373
-
374
- #### `agent plan execute <runId>`
375
-
376
- Execute a previously approved plan run.
377
-
378
- ```bash
379
- agent plan execute run_20260212_143000
380
- ```
381
-
382
- ---
383
-
384
- ### `agent daemon`
385
-
386
- Manage the background daemon process for scheduled and event-triggered plans.
17
+ # 1. Install & Configure
18
+ npm install -g @praveencs/agent
19
+ agent config --init
387
20
 
388
- #### `agent daemon start`
21
+ # 2. Add a Goal
22
+ agent goal add "Create a personal blog with Next.js" --priority 1
389
23
 
390
- Start the daemon as a detached background process.
24
+ # 3. Decompose & Plan
25
+ agent goal decompose 1
391
26
 
392
- ```bash
27
+ # 4. Start Autonomous Mode
393
28
  agent daemon start
394
- ```
395
-
396
- The daemon:
397
- - Loads all plans with `cron` or `fs_change` triggers
398
- - Schedules cron jobs using the configured timezone
399
- - Watches filesystem paths for change-triggered plans
400
-
401
- #### `agent daemon stop`
402
-
403
- Stop the running daemon.
404
-
405
- ```bash
406
- agent daemon stop
407
- ```
408
-
409
- #### `agent daemon status`
410
-
411
- Check whether the daemon is running and show its PID.
412
29
 
413
- ```bash
30
+ # View status
414
31
  agent daemon status
32
+ agent goal list
415
33
  ```
416
34
 
417
- ---
418
-
419
- ### `agent mcp`
420
-
421
- Start the MCP (Model Context Protocol) server for editor integration.
422
-
423
- ```bash
424
- agent mcp [options]
425
- ```
426
-
427
- **Options:**
428
-
429
- | Option | Description |
430
- |--------|-------------|
431
- | `-t, --transport <type>` | Transport mode: `stdio` (default) or `http` |
432
-
433
- **Example editor configuration** (VS Code / Cursor):
434
-
435
- ```jsonc
436
- // .vscode/mcp.json
437
- {
438
- "servers": {
439
- "agent-runtime": {
440
- "command": "agent",
441
- "args": ["mcp"],
442
- "transport": "stdio"
443
- }
444
- }
445
- }
446
- ```
447
-
448
- Exposed tools via MCP:
449
- - `skills.list`, `skills.run` — list and run skills
450
- - `plans.list`, `plans.propose`, `plans.run` — manage plans
451
- - `fs.read`, `fs.search`, `git.diff`, `cmd.run` — gated tools (require approval)
452
-
453
- ---
454
-
455
- ### `agent doctor`
456
-
457
- Run system health checks and report configuration status.
458
-
459
- ```bash
460
- agent doctor
461
- ```
462
-
463
- **Checks performed:**
464
- - ✅ Agent directory exists
465
- - ✅ Configuration file is valid
466
- - ✅ LLM provider connectivity
467
- - ✅ Core tools registered
468
- - ✅ Skills loaded and valid
469
- - ✅ Node.js & Git versions
470
-
471
- ---
472
-
473
- ### `agent config`
474
-
475
- Manage configuration values.
476
-
477
- #### `agent config list`
478
-
479
- Show all current configuration values.
480
-
481
- ```bash
482
- agent config list
483
- ```
484
-
485
- #### `agent config get <key>`
486
-
487
- Get a specific value using dot-notation.
488
-
489
- ```bash
490
- agent config get models.routing.defaultProvider
491
- agent config get policy.defaultApproval
492
- ```
493
-
494
- #### `agent config set <key> <value>`
495
-
496
- Set a configuration value and save to `agent.config.json`.
497
-
498
- ```bash
499
- agent config set models.routing.defaultProvider anthropic
500
- agent config set policy.defaultApproval allow
501
- agent config set tools.timeoutMs 60000
502
- ```
503
-
504
- #### `agent config reset`
505
-
506
- Reset configuration to defaults.
507
-
508
- ```bash
509
- agent config reset
510
- ```
511
-
512
- ---
513
-
514
- ## Configuration
515
-
516
- ### agent.config.json
517
-
518
- The main configuration file lives at `.agent/agent.config.json`. A global config can also be placed at `~/.agent-runtime/agent.config.json`. Configs are merged in order: **defaults → global → project → environment variables**.
519
-
520
- ### Models & Routing
521
-
522
- ```jsonc
523
- {
524
- "models": {
525
- "providers": {
526
- "azure": {
527
- "type": "azure",
528
- "model": "gpt-5-mini",
529
- "deploymentName": "gpt-5-mini", // Azure deployment name
530
- "baseUrl": "https://your-resource.openai.azure.com",
531
- "apiVersion": "2024-02-15-preview" // Azure API version
532
- // "apiKey": "..." (prefer AZURE_API_KEY env var)
533
- },
534
- "openai": {
535
- "type": "openai",
536
- "model": "gpt-4o",
537
- "maxTokens": 4096,
538
- "temperature": 0.7
539
- // "apiKey": "sk-..." (prefer AGENT_OPENAI_API_KEY env var)
540
- },
541
- "anthropic": {
542
- "type": "anthropic",
543
- "model": "claude-sonnet-4-20250514",
544
- "maxTokens": 4096
545
- },
546
- "ollama": {
547
- "type": "ollama",
548
- "model": "llama3",
549
- "baseUrl": "http://localhost:11434"
550
- }
551
- },
552
- "routing": {
553
- "defaultProvider": "azure", // Azure is default
554
- "offlineFirst": false, // Prefer local models
555
- "fallbackChain": ["azure", "openai", "anthropic", "ollama"],
556
- "skillOverrides": { // Per-skill routing
557
- "code-review": "anthropic"
558
- }
559
- }
560
- }
561
- }
562
- ```
563
-
564
- ### Policy & Permissions
565
-
566
- The policy engine controls what tools can do without user approval.
567
-
568
- ```jsonc
569
- {
570
- "policy": {
571
- "defaultApproval": "confirm", // "allow" | "confirm" | "deny"
572
- "rules": [
573
- { "permission": "filesystem.read", "action": "allow" },
574
- { "permission": "filesystem.write", "action": "confirm" },
575
- { "permission": "exec", "action": "confirm" },
576
- { "permission": "network", "action": "confirm" },
577
- { "permission": "secrets", "action": "deny" }
578
- ],
579
- "filesystemAllowlist": ["**/*"], // Glob patterns
580
- "commandAllowlist": [], // Allowed shell commands
581
- "domainAllowlist": [] // Allowed network domains
582
- }
583
- }
584
- ```
585
-
586
- **Permission levels:**
587
-
588
- | Level | Behavior |
589
- |-------|----------|
590
- | `allow` | Tool executes without prompting |
591
- | `confirm` | User is prompted before execution |
592
- | `deny` | Tool call is rejected |
593
-
594
- ### Environment Variables
595
-
596
- Override config values via environment:
597
-
598
- | Variable | Config Path |
599
- |----------|-------------|
600
- | `AZURE_API_KEY` | `models.providers.azure.apiKey` |
601
- | `AZURE_API_BASE` | `models.providers.azure.baseUrl` |
602
- | `AZURE_DEPLOYMENT_NAME` | `models.providers.azure.deploymentName` |
603
- | `AZURE_API_VERSION` | `models.providers.azure.apiVersion` |
604
- | `AGENT_OPENAI_API_KEY` | `models.providers.openai.apiKey` |
605
- | `AGENT_ANTHROPIC_API_KEY` | `models.providers.anthropic.apiKey` |
606
- | `AGENT_DEFAULT_PROVIDER` | `models.routing.defaultProvider` |
607
- | `AGENT_OFFLINE_FIRST` | `models.routing.offlineFirst` |
608
-
609
- ---
610
-
611
- ## Skills
612
-
613
- Skills are reusable, versioned automation units. Each skill is a directory containing a `skill.json` manifest and an entrypoint file.
614
-
615
- ### Skill Manifest (skill.json)
616
-
617
- ```json
618
- {
619
- "name": "code-review",
620
- "version": "1.0.0",
621
- "description": "Review code for bugs, style issues, and improvements",
622
- "author": "your-name",
623
- "entrypoint": "prompt.md",
624
- "tools": ["fs.read", "fs.search", "git.diff"],
625
- "permissions": {
626
- "required": ["filesystem.read"],
627
- "optional": ["exec"]
628
- },
629
- "inputs": {
630
- "path": { "type": "string", "description": "Path to review" }
631
- },
632
- "validators": [
633
- {
634
- "name": "lint-check",
635
- "command": "npm run lint",
636
- "timeout": 30000
637
- }
638
- ],
639
- "constraints": {
640
- "binaries": ["git"]
641
- },
642
- "tags": ["review", "quality"],
643
- "state": "approved"
644
- }
645
- ```
646
-
647
- **Key fields:**
648
-
649
- | Field | Required | Description |
650
- |-------|----------|-------------|
651
- | `name` | ✅ | Lowercase alphanumeric with dots/hyphens |
652
- | `version` | ✅ | Semver (e.g. `1.0.0`) |
653
- | `description` | ✅ | Human-readable description |
654
- | `entrypoint` | ✅ | `prompt.md` (LLM-driven) or `workflow.ts` (programmatic) |
655
- | `tools` | ✅ | List of tools the skill is allowed to use |
656
- | `permissions` | ✅ | Required and optional permission categories |
657
- | `inputs` | | JSON Schema for skill inputs |
658
- | `validators` | | Post-execution validation commands |
659
- | `constraints` | | OS or binary requirements |
660
- | `state` | | `draft` → `approved` → `deprecated` |
661
-
662
- ### Prompt-Based Skills
663
-
664
- Create a `prompt.md` file that tells the LLM what to do:
665
-
666
- ```markdown
667
- # Code Review
668
-
669
- You are a senior code reviewer. Analyze the provided code for:
670
-
671
- 1. **Bugs** — logic errors, null pointer issues, race conditions
672
- 2. **Style** — naming conventions, code organization, readability
673
- 3. **Performance** — unnecessary allocations, O(n²) loops, missing caching
674
- 4. **Security** — injection vulnerabilities, hardcoded secrets
675
-
676
- Use `fs.read` to read files and `git.diff` to see recent changes.
677
- Provide your review as a structured report.
678
-
679
- Input path: {{path}}
680
- ```
681
-
682
- The `{{variable}}` placeholders are replaced with skill inputs at runtime. The LLM drives execution using allowed tools in an agentic loop.
683
-
684
- ### Workflow-Based Skills
685
-
686
- For deterministic automation, create a `workflow.ts`:
687
-
688
- ```typescript
689
- export default async function run({ inputs, tools, context }) {
690
- // Read source files
691
- const result = await tools('fs.search', {
692
- path: inputs.path,
693
- pattern: '**/*.ts'
694
- });
695
-
696
- // Process each file
697
- for (const file of result.data.matches) {
698
- const content = await tools('fs.read', { path: file });
699
- // ... transform content ...
700
- await tools('fs.write', { path: file, content: newContent });
701
- }
702
-
703
- return { filesProcessed: result.data.matches.length };
704
- }
705
- ```
706
-
707
- ### Skill Lifecycle
708
-
709
- Skills progress through three states:
710
-
711
- ```
712
- draft → approved → deprecated
713
- ↑ │
714
- └─────────┘ (can re-approve)
715
- ```
716
-
717
- - **draft** — newly created, can run interactively but not in daemon
718
- - **approved** — production-ready, can run in daemon/scheduled contexts
719
- - **deprecated** — archived, cannot be upgraded
720
-
721
- ---
722
-
723
- ## Plan Files
724
-
725
- Plans are declarative YAML pipelines stored as `.plan.yaml` files in `.agent/plans/`.
726
-
727
- ### Writing a Plan
728
-
729
- ```yaml
730
- # .agent/plans/deploy.plan.yaml
731
- name: deploy
732
- description: Build, test, and deploy the application
733
- mode: execute
734
-
735
- goals:
736
- - id: deploy-safely
737
- description: Deploy the application with zero downtime
738
- successCriteria:
739
- - All tests pass
740
- - Build succeeds
741
- - Deployment completes
742
- riskLevel: medium
743
-
744
- steps:
745
- - id: lint
746
- name: Run linter
747
- tool: cmd.run
748
- args:
749
- command: npm
750
- args: ["run", "lint"]
751
- verify:
752
- exitCode: 0
753
- onFailure: abort
754
-
755
- - id: test
756
- name: Run tests
757
- tool: cmd.run
758
- args:
759
- command: npm
760
- args: ["test"]
761
- verify:
762
- exitCode: 0
763
- onFailure: abort
764
- dependsOn: [lint]
765
-
766
- - id: build
767
- name: Build production bundle
768
- tool: cmd.run
769
- args:
770
- command: npm
771
- args: ["run", "build"]
772
- verify:
773
- fileExists: dist/index.js
774
- retries: 2
775
- onFailure: retry
776
- dependsOn: [test]
777
-
778
- - id: deploy
779
- name: Deploy to production
780
- skill: deploy-to-cloud
781
- args:
782
- environment: production
783
- dependsOn: [build]
784
-
785
- policy:
786
- approvals: per_step
787
- scope:
788
- commandAllowlist: ["npm", "node"]
789
-
790
- trigger:
791
- type: manual
792
-
793
- outputs:
794
- - name: build-output
795
- type: artifact
796
- path: dist/
797
- ```
798
-
799
- ### Step Fields
800
-
801
- | Field | Description |
802
- |-------|-------------|
803
- | `id` | Unique step identifier |
804
- | `name` | Human-readable step name |
805
- | `tool` | Built-in tool to execute (e.g. `cmd.run`) |
806
- | `skill` | Skill to run instead of a tool |
807
- | `args` | Arguments passed to the tool or skill |
808
- | `verify` | Post-step verification (`command`, `fileExists`, `exitCode`, `contains`) |
809
- | `dependsOn` | List of step IDs that must complete first |
810
- | `onFailure` | `abort` (default), `retry`, or `skip` |
811
- | `retries` | Number of retry attempts (used with `onFailure: retry`) |
812
-
813
- ### Triggers
814
-
815
- | Type | Description | Config |
816
- |------|-------------|--------|
817
- | `manual` | Run explicitly via CLI | — |
818
- | `cron` | Scheduled execution | `cron: "0 2 * * *"` |
819
- | `fs_change` | File system watcher | `paths: ["src/**/*.ts"]` |
820
- | `git_event` | Git hook events | `gitEvents: ["commit", "push"]` |
821
- | `webhook` | HTTP webhook trigger | `webhookPath: "/deploy"` |
822
-
823
- ### Propose Mode
824
-
825
- For high-risk plans, use propose mode to review before executing:
826
-
827
- ```bash
828
- # Create a draft run
829
- agent plan propose deploy
830
-
831
- # Review the proposal
832
- agent plan show <runId>
833
-
834
- # Approve and execute
835
- agent plan approve <runId>
836
- agent plan execute <runId>
837
- ```
838
-
839
- ---
840
-
841
- ## Built-in Tools
842
-
843
- | Tool | Category | Description |
844
- |------|----------|-------------|
845
- | `fs.read` | filesystem | Read file contents |
846
- | `fs.write` | filesystem | Write content to a file (auto-creates directories) |
847
- | `fs.list` | filesystem | List directory contents (recursive option) |
848
- | `fs.search` | filesystem | Search files matching a glob pattern |
849
- | `fs.patch` | filesystem | Find and replace content in a file |
850
- | `cmd.run` | exec | Execute a shell command |
851
- | `git.status` | git | Show working tree status |
852
- | `git.diff` | git | Show file differences |
853
- | `git.log` | git | Show commit log |
854
- | `git.commit` | git | Create a commit |
855
- | `project.detect` | project | Detect language, framework, and package manager |
856
-
857
- ---
858
-
859
- ## MCP Integration
860
-
861
- The MCP server allows editors like VS Code and Cursor to interact with the agent runtime.
862
-
863
- ### Start the server
864
-
865
- ```bash
866
- agent mcp # stdio transport (default)
867
- agent mcp --transport http # HTTP transport (future)
868
- ```
869
-
870
- ### Editor setup
871
-
872
- Add to your editor's MCP configuration:
873
-
874
- ```jsonc
875
- {
876
- "servers": {
877
- "agent-runtime": {
878
- "command": "agent",
879
- "args": ["mcp"],
880
- "transport": "stdio"
881
- }
882
- }
883
- }
884
- ```
885
-
886
- ### Exposed capabilities
887
-
888
- - **Skills**: List and execute installed skills from your editor
889
- - **Plans**: List, propose, and run plans
890
- - **Gated Tools**: Use `fs.read`, `fs.search`, `git.diff`, `cmd.run` with policy enforcement
891
-
892
- ---
893
-
894
- ## Daemon & Scheduling
895
-
896
- The daemon runs as a background process, executing plans on schedules or in response to events.
897
-
898
- ```bash
899
- agent daemon start # Start background daemon
900
- agent daemon status # Check if running
901
- agent daemon stop # Stop the daemon
902
- ```
903
-
904
- ### Cron scheduling
905
-
906
- Add a `cron` trigger to your plan:
907
-
908
- ```yaml
909
- trigger:
910
- type: cron
911
- cron: "0 2 * * *" # Daily at 2 AM
912
- ```
913
-
914
- The daemon respects the `daemon.timezone` config setting (default: `UTC`).
915
-
916
- ### File system triggers
35
+ ## Core Concepts
917
36
 
918
- ```yaml
919
- trigger:
920
- type: fs_change
921
- paths:
922
- - "src/**/*.ts"
923
- - "package.json"
924
- ```
37
+ ### Goals & Tasks
38
+ Goals are high-level objectives. The agent breaks them down into atomic **Tasks**.
39
+ Each task can be executed by a specific **Skill** or by general LLM reasoning.
925
40
 
926
- The daemon watches these paths and runs the plan when changes are detected (debounced by `daemon.watcherDebounceMs`).
41
+ ### Skills
42
+ Skills are the agent's tools. They are defined in `prompt.md` files.
43
+ - `agent skills list` - View installed skills
44
+ - `agent skills create <name>` - Create a new skill
45
+ - `agent skills doctor <name>` - Diagnose issues
46
+ - `agent skills fix <name>` - Auto-repair a broken skill
927
47
 
928
- ---
48
+ ### Memory
49
+ The agent remembers what it learns.
50
+ - `agent memory search "context"` - Search the knowledge base
51
+ - `agent report generate` - View daily activity
929
52
 
930
- ## Audit Logs
53
+ ## Architecture
931
54
 
932
- Every plan run produces an audit trail in `.agent/runs/<runId>/`:
933
-
934
- ```
935
- .agent/runs/run_20260212_143000/
936
- ├── run.json # Full run log with steps, events, timing
937
- └── diffs.json # File diffs captured during execution
938
- ```
939
-
940
- ### Run log contents
941
-
942
- - **Run metadata** — ID, plan name, status, timestamps
943
- - **Step logs** — per-step status, input/output, duration, errors
944
- - **Events** — audit events (tool calls, approvals, failures)
945
- - **Verification** — pass/fail results for each step verification
946
- - **Summary** — steps completed/failed/skipped, files changed, duration
947
-
948
- ### Browsing runs
949
-
950
- ```bash
951
- agent plan runs # List recent runs
952
- agent plan show <runId> # Detailed run view
953
- ```
954
-
955
- ---
55
+ - **`src/daemon`**: Background service manager.
56
+ - **`src/goals`**: Planning and execution engine.
57
+ - **`src/memory`**: SQLite storage layer.
58
+ - **`src/skills`**: Skill loader and auto-fixer.
59
+ - **`src/llm`**: Multi-provider LLM router.
956
60
 
957
61
  ## Development
958
62
 
959
- ### Building
960
-
961
63
  ```bash
962
- npm run build # Compile TypeScript
963
- npm run dev # Watch mode with tsx
964
- ```
965
-
966
- ### Testing
967
-
968
- ```bash
969
- npm test # Run unit tests
970
- npm run test:integration # Run integration tests
971
- ```
972
-
973
- ### Code quality
974
-
975
- ```bash
976
- npm run lint # ESLint
977
- npm run format # Prettier
978
- ```
979
-
980
- ### Project layout
981
-
982
- ```
983
- src/
984
- ├── cli/ # CLI commands and UI helpers
985
- │ ├── commands/ # init, run, skills, plan, daemon, mcp, doctor, config
986
- │ ├── ui/ # progress, prompt, report
987
- │ └── index.ts # CLI program factory
988
- ├── config/ # Configuration schema, defaults, loader, secrets
989
- ├── engine/ # Execution engine, verification, rollback
990
- ├── llm/ # LLM router, providers (OpenAI, Anthropic, Ollama), cache
991
- ├── logging/ # Structured logger, audit log, redactor
992
- ├── mcp/ # MCP server and handlers
993
- ├── daemon/ # Process manager, scheduler, file watcher
994
- ├── plans/ # Plan parser, runner, triggers, propose
995
- ├── policy/ # Permission engine, scope checker, audit emitter
996
- ├── skills/ # Skill loader, runner, validator, lifecycle
997
- ├── tools/ # Tool registry, core tools, plugin loader
998
- ├── self-extend/ # Skill generator, sandbox, publisher
999
- ├── utils/ # Paths, hashing, schema helpers
1000
- └── index.ts # Public API surface
64
+ npm install
65
+ npm run build
66
+ npm test
1001
67
  ```
1002
-
1003
- ---
1004
-
1005
- ## License
1006
-
1007
- MIT