agentpack-cli 0.1.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/SECURITY.md +44 -0
  4. package/assets/agentpack-logo.jpg +0 -0
  5. package/dist/src/agentpack.d.ts +2 -0
  6. package/dist/src/agentpack.js +8 -0
  7. package/dist/src/agentpack.js.map +1 -0
  8. package/dist/src/cli/index.d.ts +3 -0
  9. package/dist/src/cli/index.js +412 -0
  10. package/dist/src/cli/index.js.map +1 -0
  11. package/dist/src/core/budget.d.ts +14 -0
  12. package/dist/src/core/budget.js +56 -0
  13. package/dist/src/core/budget.js.map +1 -0
  14. package/dist/src/core/checkpoints.d.ts +24 -0
  15. package/dist/src/core/checkpoints.js +93 -0
  16. package/dist/src/core/checkpoints.js.map +1 -0
  17. package/dist/src/core/doctor.d.ts +4 -0
  18. package/dist/src/core/doctor.js +304 -0
  19. package/dist/src/core/doctor.js.map +1 -0
  20. package/dist/src/core/git.d.ts +2 -0
  21. package/dist/src/core/git.js +34 -0
  22. package/dist/src/core/git.js.map +1 -0
  23. package/dist/src/core/hash.d.ts +5 -0
  24. package/dist/src/core/hash.js +29 -0
  25. package/dist/src/core/hash.js.map +1 -0
  26. package/dist/src/core/ids.d.ts +1 -0
  27. package/dist/src/core/ids.js +7 -0
  28. package/dist/src/core/ids.js.map +1 -0
  29. package/dist/src/core/presets.d.ts +12 -0
  30. package/dist/src/core/presets.js +24 -0
  31. package/dist/src/core/presets.js.map +1 -0
  32. package/dist/src/core/redaction.d.ts +4 -0
  33. package/dist/src/core/redaction.js +18 -0
  34. package/dist/src/core/redaction.js.map +1 -0
  35. package/dist/src/core/resume.d.ts +13 -0
  36. package/dist/src/core/resume.js +398 -0
  37. package/dist/src/core/resume.js.map +1 -0
  38. package/dist/src/core/store.d.ts +20 -0
  39. package/dist/src/core/store.js +240 -0
  40. package/dist/src/core/store.js.map +1 -0
  41. package/dist/src/core/types.d.ts +43 -0
  42. package/dist/src/core/types.js +2 -0
  43. package/dist/src/core/types.js.map +1 -0
  44. package/dist/src/integrations/install.d.ts +5 -0
  45. package/dist/src/integrations/install.js +361 -0
  46. package/dist/src/integrations/install.js.map +1 -0
  47. package/dist/src/mcp/server.d.ts +9 -0
  48. package/dist/src/mcp/server.js +347 -0
  49. package/dist/src/mcp/server.js.map +1 -0
  50. package/dist/src/operations.d.ts +29 -0
  51. package/dist/src/operations.js +199 -0
  52. package/dist/src/operations.js.map +1 -0
  53. package/docs/DOGFOOD.md +72 -0
  54. package/docs/INTEGRATIONS.md +183 -0
  55. package/docs/MCP.md +83 -0
  56. package/docs/MVP.md +97 -0
  57. package/docs/ROADMAP.md +129 -0
  58. package/docs/SETUP.md +56 -0
  59. package/docs/agentpack-flow.md +63 -0
  60. package/package.json +55 -0
  61. package/scripts/mcp-smoke.mjs +197 -0
@@ -0,0 +1,72 @@
1
+ # Dogfood Workflow
2
+
3
+ Dogfooding means using Agentpack to develop Agentpack itself. The goal is to prove the workflow in real coding sessions before adding more features.
4
+
5
+ ## Start A Session
6
+
7
+ Load a small context first:
8
+
9
+ ```text
10
+ load_context(preset: "quick")
11
+ source_status()
12
+ ```
13
+
14
+ Use `agent` instead of `quick` when the task needs more history.
15
+
16
+ ## During Work
17
+
18
+ Record only durable context. Agentpack is not an activity logger, and it should not log every thought, file read, or edit.
19
+
20
+ Default cadence:
21
+
22
+ - At task start, load Agentpack context and source status.
23
+ - During normal coding, keep working locally; record only durable decisions, dead ends, source conclusions, and evidence.
24
+ - At the end of a coherent step, record the useful sources/evidence, update status and next actions, then checkpoint.
25
+ - Use full safe mode for risky or release-like changes: record important findings as they happen and run the full verification loop.
26
+
27
+ This keeps Agentpack useful without turning every micro-step into ledger traffic. The intended default cost is one context load near the start and one durable save near the end.
28
+
29
+ ```text
30
+ record_source(path, summary)
31
+ record_decision(text, files, evidence)
32
+ record_dead_end(text, reason, files)
33
+ attach_evidence(kind, content, command, exitCode)
34
+ ```
35
+
36
+ Good source summaries are conclusions, not file descriptions:
37
+
38
+ ```text
39
+ src/integrations/install.ts: install uses a dry-run plan by default and writes only project-local files with --write.
40
+ ```
41
+
42
+ Good dead ends prevent repeated work:
43
+
44
+ ```text
45
+ Do not put a project-specific --root or cwd in the global ~/.codex/config.toml Agentpack entry; use repo-local .codex/config.toml so each repo resolves its own .agentpack state.
46
+ ```
47
+
48
+ ## End A Meaningful Step
49
+
50
+ Checkpoint when the repo reaches a coherent state:
51
+
52
+ ```text
53
+ checkpoint(
54
+ summary: "Safe MCP install flow is implemented and tested.",
55
+ status: "Codex MCP setup can be dogfooded in this repo.",
56
+ nextActions: ["Run through the handoff demo with a fresh session."]
57
+ )
58
+ ```
59
+
60
+ Git still owns code history. Agentpack owns task memory.
61
+
62
+ ## What To Watch
63
+
64
+ While dogfooding, look for friction:
65
+
66
+ - Did the agent call `load_context` and `source_status` early enough?
67
+ - Were unchanged sources avoided when recorded conclusions were enough?
68
+ - Were decisions and dead ends recorded at useful moments?
69
+ - Was evidence too noisy or too thin?
70
+ - Was the checkpoint useful to the next session?
71
+
72
+ If the answer is no, improve the tool contract or the project instructions before adding larger features.
@@ -0,0 +1,183 @@
1
+ # Integrations
2
+
3
+ Agentpack integrates through local project files, CLI, and MCP. It does not write hidden global configuration by default.
4
+
5
+ ## Client Matrix
6
+
7
+ | Client | Instruction file | MCP config surface | Status |
8
+ | --- | --- | --- | --- |
9
+ | Codex | `AGENTS.md` | Project-local `.codex/config.toml`, plus a generated `.agentpack/instructions/codex-mcp.example.toml` review snippet | Tested |
10
+ | Claude Code | `CLAUDE.md` | Project-local `.mcp.json` in the repo root | Tested |
11
+ | Claude Desktop | None automatically read from the repo | User-local Claude Desktop config, copied from generated `.agentpack/instructions/claude-desktop-mcp.example.json` | Generated, not tested yet |
12
+ | Cursor | `.cursor/rules/agentpack.mdc` | Project-local `.cursor/mcp.json` | Generated, not tested yet |
13
+ | Web chats | Markdown handoff | No local stdio MCP support in v0; use `agentpack export` | Manual fallback |
14
+
15
+ Coding-agent clients use the same `agentpack mcp` server. The difference is where each client expects instructions and MCP configuration to live. Web chats are fallback targets for pasted markdown handoffs; they are not the primary v0 integration surface.
16
+
17
+ Generated integration files are local developer setup by default. Until Agentpack has an explicit shared/team mode, keep `.agentpack/`, `.codex/`, `.claude/`, `.mcp.json`, `AGENTS.md`, `CLAUDE.md`, and similar client config files out of origin unless a repo deliberately chooses to version its own agent policy.
18
+
19
+ Generated files under `.agentpack/instructions/` are local helper snippets. They are created only when you run the matching installer, and `agentpack init` adds the Agentpack local-only patterns to `.gitignore` without replacing existing project rules.
20
+
21
+ ## Where Files Live
22
+
23
+ In a local project setup:
24
+
25
+ - `CLAUDE.md`: repo-root project instructions for Claude Code.
26
+ - `.mcp.json`: repo-root project MCP config for Claude Code.
27
+ - `AGENTS.md`: repo-root project instructions for Codex.
28
+ - `.codex/config.toml`: repo-local Codex MCP config created by `agentpack install codex --write`.
29
+ - `.agentpack/instructions/codex-mcp.example.toml`: local Codex config snippet, created by `agentpack install codex --write`.
30
+ - `.agentpack/instructions/claude-desktop-mcp.example.json`: local Claude Desktop config snippet, created by `agentpack install claude-desktop --write`.
31
+
32
+ If a snippet is missing, run the matching `agentpack install <target> --write`. Running `agentpack install claude --write` does not create Codex or Claude Desktop snippets.
33
+
34
+ ## Safe Install Flow
35
+
36
+ Preview first:
37
+
38
+ ```bash
39
+ agentpack install codex
40
+ agentpack install claude
41
+ agentpack install claude-desktop
42
+ agentpack install cursor
43
+ ```
44
+
45
+ `install` defaults to dry-run mode. It shows the files Agentpack would create or update and prints the command needed to apply the plan.
46
+
47
+ Apply explicitly:
48
+
49
+ ```bash
50
+ agentpack install codex --write
51
+ agentpack install claude --write
52
+ agentpack install claude-desktop --write
53
+ agentpack install cursor --write
54
+ ```
55
+
56
+ Force preview explicitly:
57
+
58
+ ```bash
59
+ agentpack install claude --dry-run
60
+ ```
61
+
62
+ Agentpack only writes project-local files and `.agentpack/instructions/*`. These files are intended to be ignored/local for v0. Agentpack does not silently edit global files such as `~/.codex/config.toml`, `~/.claude.json`, `~/Library/Application Support/Claude/claude_desktop_config.json`, or `~/.cursor/mcp.json`.
63
+
64
+ Generated MCP server names are repo-specific to avoid collisions when several repos are open in the same client. The Agentpack repo itself keeps the short name `agentpack`; other repos use `agentpack-<repo-name>`, such as `agentpack-example-app`.
65
+
66
+ ## Codex
67
+
68
+ ```bash
69
+ agentpack install codex --write
70
+ ```
71
+
72
+ This writes:
73
+
74
+ - `AGENTS.md`
75
+ - `.codex/config.toml`
76
+ - `.agentpack/instructions/codex.md`
77
+ - `.agentpack/instructions/codex-mcp.example.toml`
78
+
79
+ Agentpack does not edit `~/.codex/config.toml`. The project-local `.codex/config.toml` entry starts MCP with:
80
+
81
+ ```toml
82
+ [mcp_servers.agentpack-example-app]
83
+ command = "agentpack"
84
+ args = ["mcp"]
85
+ ```
86
+
87
+ Do not keep an older global `~/.codex/config.toml` entry with `args = ["mcp", "--root", "/some/project"]` or `cwd = "/some/project"`. That makes every Codex session reuse that old repo's `.agentpack/` state even after you run `agentpack init` in a new repo.
88
+
89
+ If Agentpack still reports the wrong Pack root in Codex, remove the stale global `mcp_servers.agentpack` block, keep the project-local `.codex/config.toml`, then restart or reconnect the MCP server.
90
+
91
+ Official reference: [Codex configuration reference](https://developers.openai.com/codex/config-reference).
92
+
93
+ ## Claude Code
94
+
95
+ ```bash
96
+ agentpack install claude --write
97
+ ```
98
+
99
+ This writes:
100
+
101
+ - `CLAUDE.md`
102
+ - `.mcp.json`
103
+ - `.agentpack/instructions/claude.md`
104
+
105
+ The `.mcp.json` file is project-local. Claude Code treats project-scoped MCP config as shareable project config and prompts before using project-scoped servers. Agentpack names the server after the repo, for example `agentpack-example-app`, so it does not shadow a global `agentpack` server.
106
+
107
+ Official reference: [Claude Code MCP docs](https://docs.claude.com/en/docs/claude-code/mcp).
108
+
109
+ ## Claude Desktop
110
+
111
+ ```bash
112
+ agentpack install claude-desktop --write
113
+ ```
114
+
115
+ This writes:
116
+
117
+ - `.agentpack/instructions/claude-desktop.md`
118
+ - `.agentpack/instructions/claude-desktop-mcp.example.json`
119
+
120
+ Claude Desktop does not read this repo's `.mcp.json` or `CLAUDE.md`. To enable Agentpack manually in Claude Desktop on macOS, review `.agentpack/instructions/claude-desktop-mcp.example.json` and merge the `agentpack` server into:
121
+
122
+ ```text
123
+ ~/Library/Application Support/Claude/claude_desktop_config.json
124
+ ```
125
+
126
+ Do not copy the generated snippet over the Desktop config file. That can delete existing Claude Desktop MCP servers. Merge only the `mcpServers.agentpack` entry.
127
+
128
+ Safe manual flow:
129
+
130
+ ```bash
131
+ agentpack install claude-desktop --write
132
+ cat .agentpack/instructions/claude-desktop-mcp.example.json
133
+ mkdir -p "$HOME/Library/Application Support/Claude"
134
+ open -e "$HOME/Library/Application Support/Claude/claude_desktop_config.json"
135
+ ```
136
+
137
+ If the config file does not exist yet, create it with the generated snippet content. If it already exists, add only this entry under its existing `mcpServers` object:
138
+
139
+ ```json
140
+ "agentpack-example-app": {
141
+ "command": "agentpack",
142
+ "args": ["mcp", "--root", "/absolute/path/to/your/project"],
143
+ "env": {
144
+ "AGENTPACK_ROOT": "/absolute/path/to/your/project"
145
+ }
146
+ }
147
+ ```
148
+
149
+ Then restart Claude Desktop. If the Desktop app cannot find `agentpack`, replace `"command": "agentpack"` in the snippet with an absolute executable path. Keep both the `--root` argument and the `AGENTPACK_ROOT` env value pointed at the project whose `.agentpack/` state you want Claude Desktop to use.
150
+
151
+ Claude Desktop has no project-local repo config. If you switch Claude Desktop from one repo to another, update both the relevant server's `--root` value and `AGENTPACK_ROOT`, then restart Claude Desktop.
152
+
153
+ One Claude Desktop server entry points to one Agentpack repo at a time. To expose multiple repos at once, add multiple `mcpServers` entries with different names and different `AGENTPACK_ROOT` values, but expect duplicated Agentpack tool names in the client UI.
154
+
155
+ For a future low-friction Desktop install, Agentpack should ship a Desktop Extension/MCP bundle instead of asking users to edit JSON manually.
156
+
157
+ Official references: [MCP local server guide](https://modelcontextprotocol.io/docs/develop/connect-local-servers) and [Anthropic Desktop Extensions](https://www.anthropic.com/engineering/desktop-extensions).
158
+
159
+ ## Cursor
160
+
161
+ ```bash
162
+ agentpack install cursor --write
163
+ ```
164
+
165
+ This writes:
166
+
167
+ - `.cursor/rules/agentpack.mdc`
168
+ - `.cursor/mcp.json`
169
+ - `.agentpack/instructions/cursor.md`
170
+
171
+ The Cursor MCP config uses `${workspaceFolder}` so it can point Agentpack at the current project root without hard-coding your local filesystem path.
172
+
173
+ Official reference: [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol).
174
+
175
+ ## Verify
176
+
177
+ Before connecting an agent client:
178
+
179
+ ```bash
180
+ npm run mcp:smoke
181
+ ```
182
+
183
+ After installing the integration, restart the client if it does not pick up new MCP config automatically.
package/docs/MCP.md ADDED
@@ -0,0 +1,83 @@
1
+ # MCP
2
+
3
+ `agentpack mcp` starts a local stdio MCP server.
4
+
5
+ The MCP stdio transport uses newline-delimited JSON-RPC messages over stdin/stdout. The client launches Agentpack as a subprocess, sends JSON-RPC messages to stdin, and reads JSON-RPC responses from stdout. Agentpack must not write non-MCP logs to stdout.
6
+
7
+ Reference: [Model Context Protocol transports](https://modelcontextprotocol.io/docs/concepts/transports).
8
+
9
+ ## Tools
10
+
11
+ - `load_context`
12
+ - `record_decision`
13
+ - `record_dead_end`
14
+ - `attach_evidence`
15
+ - `record_source`
16
+ - `source_status`
17
+ - `checkpoint`
18
+ - `resume`
19
+ - `diff`
20
+ - `replay`
21
+
22
+ `load_context` and `resume` accept `query`, `budget`, and `preset`. When `query` is present, Agentpack filters Source Cache locally: matched sources keep full summaries/snippets, changed or missing source records are always shown in full, and unrelated unchanged sources remain visible as compact path/status/topic/guidance stubs. If nothing matches, Agentpack keeps the full Source Cache to avoid false-negative filtering. This saves tokens without hiding which recorded files exist.
23
+
24
+ ## Manual Smoke
25
+
26
+ In normal use, a client such as Codex, Claude Code, or Cursor starts `agentpack mcp`. For development, run the local smoke command:
27
+
28
+ ```bash
29
+ npm run mcp:smoke
30
+ ```
31
+
32
+ It creates a temporary Agentpack workspace, starts `agentpack mcp`, sends JSON-RPC messages over stdio, and removes the temporary workspace after the check.
33
+
34
+ The test suite also exercises the same newline-delimited JSON-RPC flow in memory:
35
+
36
+ ```bash
37
+ npm test
38
+ ```
39
+
40
+ The smoke test verifies:
41
+
42
+ - `initialize`
43
+ - `tools/list`
44
+ - `tools/call record_decision`
45
+ - `tools/call record_source`
46
+ - `tools/call source_status`
47
+ - `tools/call resume`
48
+ - notification messages do not produce responses
49
+
50
+ ## Client Setup
51
+
52
+ Use dry-run install first:
53
+
54
+ ```bash
55
+ agentpack install codex
56
+ agentpack install claude
57
+ agentpack install claude-desktop
58
+ agentpack install cursor
59
+ ```
60
+
61
+ Apply only after reviewing the plan:
62
+
63
+ ```bash
64
+ agentpack install codex --write
65
+ agentpack install claude --write
66
+ agentpack install claude-desktop --write
67
+ agentpack install cursor --write
68
+ ```
69
+
70
+ See [INTEGRATIONS.md](INTEGRATIONS.md) for target-specific files and manual global config steps.
71
+
72
+ After changing Agentpack itself and running `npm run build`, reconnect or restart any already-running MCP client. Stdio MCP clients keep the server process alive, so they do not automatically load the newly built `dist/` files.
73
+
74
+ If `load_context` reports the wrong Pack root, check for a stale global client config that starts Agentpack with a hard-coded `--root` or `cwd`. Project-local configs should start Codex and Claude Code with `agentpack mcp` so the server resolves the repo-local `.agentpack/` root. Global clients such as Claude Desktop should set an explicit `--root` and matching `AGENTPACK_ROOT` because they do not have a project cwd.
75
+
76
+ Avoid reusing the same MCP server name across global and project-local configs. Agentpack installers use `agentpack` for the Agentpack repo itself and `agentpack-<repo-name>` for other repos, so a project-local server such as `agentpack-example-app` does not shadow a global `agentpack` server.
77
+
78
+ ## Security Notes
79
+
80
+ - The server operates only on the nearest `.agentpack/` root.
81
+ - It does not make network calls.
82
+ - It writes task state to local files only.
83
+ - It should treat stdout as protocol-only output.
package/docs/MVP.md ADDED
@@ -0,0 +1,97 @@
1
+ # Agentpack MVP
2
+
3
+ ## Positioning
4
+
5
+ Agentpack helps coding agents continue repo work without rediscovering context, re-reading unchanged sources, or repeating dead ends.
6
+
7
+ The project is local-first and open-source by default. Optional hosted sync can come later, but the core value must work fully on a developer machine.
8
+
9
+ ## Non-goals
10
+
11
+ - Do not store full chat transcripts by default.
12
+ - Do not pretend to access hidden agent memory.
13
+ - Do not upload code or task state anywhere.
14
+ - Do not require embeddings or hosted LLM calls in v0.
15
+ - Do not implement deterministic environment replay in v0.
16
+
17
+ ## v0 Commands
18
+
19
+ ```bash
20
+ agentpack init
21
+ agentpack source add <file> --summary <text>
22
+ agentpack source status
23
+ agentpack record decision <text>
24
+ agentpack record dead-end <text>
25
+ agentpack evidence add --kind test-output --file <path>
26
+ agentpack note <text>
27
+ agentpack run <command>
28
+ agentpack checkpoint -m <summary> --status <text> --next <item>
29
+ agentpack resume --preset agent --query <text>
30
+ agentpack export --to markdown --preset chat --query <text>
31
+ agentpack diff
32
+ agentpack replay
33
+ agentpack doctor
34
+ agentpack mcp
35
+ agentpack install codex
36
+ agentpack install claude
37
+ agentpack install claude-desktop
38
+ agentpack install cursor
39
+ ```
40
+
41
+ ## v0 File Format
42
+
43
+ `--query` is optional. Without it, resume/export include the full Source Cache. With it, Agentpack uses local lexical matching to include full source summaries for relevant records, always keeps changed/missing records in full, and uses compact path/status/topic stubs for unrelated unchanged records. If nothing matches, the full Source Cache is retained.
44
+
45
+ ```text
46
+ .agentpack/
47
+ config.json
48
+ state.json
49
+ events.jsonl
50
+ sources.json
51
+ checkpoints/
52
+ evidence/
53
+ instructions/
54
+ exports/
55
+ cache/
56
+ ```
57
+
58
+ `events.jsonl` is the append-only task ledger. `sources.json` records file hashes, summaries, and optional snippets. `checkpoints/` stores materialized resume snapshots plus git metadata.
59
+
60
+ Agentpack files are ignored by git by default. `agentpack init` appends the local-only Agentpack patterns to the project `.gitignore` when needed and preserves existing project rules. `.agentpack/` is local working state, not a repository artifact. Client integration files such as `.mcp.json`, `.codex/`, `.claude/`, `AGENTS.md`, and `CLAUDE.md` are also local developer setup for v0 and should normally stay ignored.
61
+
62
+ Client install commands use the repo name when writing MCP server keys, for example `agentpack-example-app`, so ignored local configs in different repos do not shadow a global `agentpack` server.
63
+
64
+ Team sharing is intentionally out of scope until after local-only workflows stabilize. The first sharing surface should be explicit export/import bundles, not committing live ledger state or local client config.
65
+
66
+ ## Budget Policy
67
+
68
+ Budget packing is deterministic and approximate. The v0 token estimate is intentionally simple:
69
+
70
+ ```text
71
+ estimated_tokens = ceil(characters / 4)
72
+ ```
73
+
74
+ Generated resumes include the requested budget, estimated usage, and a budget status line. If the requested budget is too small, Agentpack reports which required sections were truncated and which optional sections were omitted instead of silently dropping context.
75
+
76
+ Resume sections are prioritized:
77
+
78
+ 1. Goal, status, and next actions.
79
+ 2. Git state.
80
+ 3. Source cache and "do not re-open unless changed" guidance.
81
+ 4. Decisions.
82
+ 5. Dead ends.
83
+ 6. Evidence.
84
+ 7. Compact recent timeline digest.
85
+
86
+ The timeline digest is intentionally compact. Full event history stays available through `agentpack replay`; resume output should avoid repeating source summaries, decisions, and evidence previews that already appear in dedicated sections.
87
+
88
+ Suggested presets:
89
+
90
+ ```text
91
+ 1200: quick status ping
92
+ 4000: compact manual handoff
93
+ 8000: deeper coding-agent handoff
94
+ 16000: large debugging session or review
95
+ ```
96
+
97
+ MCP clients should choose the smallest budget that preserves next-action safety. Humans can override it per command.
@@ -0,0 +1,129 @@
1
+ # Roadmap
2
+
3
+ ## North Star
4
+
5
+ Agentpack is a local task-state layer for AI coding agents. It captures useful working context that usually gets lost in long sessions, restarts, and compaction: decisions, dead ends, inspected sources, evidence, checkpoints, and budgeted resumes.
6
+
7
+ Agentpack is not an orchestrator. It is the portable context ledger for humans, single agents, and agent teams working on a repo.
8
+
9
+ ## Product Principles
10
+
11
+ - Local-first.
12
+ - No telemetry.
13
+ - No network calls by default.
14
+ - Zero runtime dependencies while practical.
15
+ - Git stores code state; Agentpack stores task context.
16
+ - `.agentpack/` is local state and ignored by git by default.
17
+ - Client integration files are local by default for v0; do not require teams to commit `.mcp.json`, `.codex/`, `.claude/`, `AGENTS.md`, or `CLAUDE.md`.
18
+ - Prefer simple file formats over hidden databases until the need is obvious.
19
+ - Avoid framework lock-in; integrate through CLI, files, MCP, and project instructions.
20
+ - Install Agentpack once, initialize it per repo, and keep chats/sessions out of the core model.
21
+
22
+ ## State Model
23
+
24
+ Agentpack has four layers:
25
+
26
+ 1. Tool install: the `agentpack` binary is installed once on a developer machine.
27
+ 2. Repo init: each repo gets its own local `.agentpack/` directory.
28
+ 3. Repo source cache: inspected source conclusions and file hashes can be reused across tasks in the same repo.
29
+ 4. Task ledger: goal, status, decisions, dead ends, evidence, checkpoints, and exports belong to a workstream, not to a chat.
30
+
31
+ Agent sessions and web chats are transport surfaces. They should be able to resume, write, and hand off a task, but they are not first-class Agentpack state.
32
+
33
+ Sharing ledger state across machines or teammates is intentionally post-local-stability work. Prefer explicit sanitized export/import bundles before considering committed or synced shared state.
34
+
35
+ Target task UX:
36
+
37
+ ```bash
38
+ agentpack init
39
+ agentpack task start "Claude Desktop MCP install"
40
+ agentpack task list
41
+ agentpack task switch claude-desktop-mcp-install
42
+ agentpack resume --preset agent
43
+ agentpack checkpoint -m "Desktop config tested"
44
+ agentpack task close
45
+ ```
46
+
47
+ Target file shape:
48
+
49
+ ```text
50
+ .agentpack/
51
+ config.json
52
+ sources.json
53
+ tasks/
54
+ current
55
+ claude-desktop-mcp-install/
56
+ state.json
57
+ events.jsonl
58
+ checkpoints/
59
+ evidence/
60
+ exports/
61
+ ```
62
+
63
+ This keeps source knowledge reusable across a repo while preventing unrelated feature work from mixing decisions, dead ends, and next actions.
64
+
65
+ ## v0.1: Usable Manual CLI
66
+
67
+ Goal: useful in any repo without MCP.
68
+
69
+ - Budget presets: `quick`, `chat`, `agent`, `deep`.
70
+ - Top-level `agentpack note`.
71
+ - `agentpack run <command>` to capture command output as evidence.
72
+ - Clear docs for setup, budgets, and local `.agentpack/` state.
73
+ - Keep runtime dependency-free.
74
+
75
+ ## v0.2: Better Capture
76
+
77
+ Goal: make capture-as-you-go natural.
78
+
79
+ - `checkpoint --status --next` polish.
80
+ - `source status` for changed/unchanged/missing inspected files.
81
+ - Better evidence summaries in `resume`.
82
+ - Redaction tests.
83
+ - `doctor` command for repo/setup/MCP readiness.
84
+
85
+ ## v0.3: Useful MCP
86
+
87
+ Goal: agents record task state while they work.
88
+
89
+ - Test MCP JSON-RPC flows.
90
+ - Polish tool contracts.
91
+ - `install codex`.
92
+ - `install claude`.
93
+ - `install cursor`.
94
+ - Project instructions that tell agents when to call tools.
95
+
96
+ ## v0.4: Coding-Agent Demo
97
+
98
+ Goal: show the wow effect.
99
+
100
+ Before polishing the public demo, dogfood the workflow in this repo with the protocol in `AGENTS.md` and `docs/DOGFOOD.md`.
101
+
102
+ Demo story:
103
+
104
+ 1. Agent starts a bugfix.
105
+ 2. Agent records inspected sources.
106
+ 3. Agent runs tests and records failure.
107
+ 4. Agent records a dead end.
108
+ 5. Agent checkpoints.
109
+ 6. New agent resumes under a 4k budget.
110
+ 7. New agent avoids repeated work.
111
+
112
+ ## v1.0: Reliable Local Tool
113
+
114
+ - Stable `.agentpack/` schema.
115
+ - Stable CLI.
116
+ - Stable MCP tools.
117
+ - Task/workstream separation.
118
+ - Security model documented.
119
+ - npm publish as `agentpack-cli`.
120
+ - Good demo and examples.
121
+
122
+ ## Later
123
+
124
+ - Shareable bundles.
125
+ - Optional imports from markdown handoffs.
126
+ - Orchestrator adapters.
127
+ - Optional hosted sync.
128
+ - UI.
129
+ - Embeddings or semantic indexing only after file/hash/source summaries stop being enough.
package/docs/SETUP.md ADDED
@@ -0,0 +1,56 @@
1
+ # Development Setup
2
+
3
+ Agentpack is a TypeScript/Node project with a conservative npm setup. The npm package name is `agentpack-cli`; the installed command is `agentpack`.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 22 LTS recommended
8
+ - npm 10+
9
+
10
+ The runtime package has zero third-party dependencies in v0. Development uses TypeScript and Node type definitions only.
11
+
12
+ ## macOS Setup With fnm
13
+
14
+ ```bash
15
+ brew install fnm
16
+ fnm install 22
17
+ fnm default 22
18
+ ```
19
+
20
+ Add this to `~/.zshrc`:
21
+
22
+ ```bash
23
+ eval "$(fnm env --use-on-cd --shell zsh)"
24
+ ```
25
+
26
+ Restart the terminal, then verify:
27
+
28
+ ```bash
29
+ node --version
30
+ npm --version
31
+ ```
32
+
33
+ ## Install Dependencies
34
+
35
+ ```bash
36
+ npm ci --ignore-scripts
37
+ ```
38
+
39
+ The repo also includes `.npmrc` with:
40
+
41
+ ```text
42
+ ignore-scripts=true
43
+ save-exact=true
44
+ package-lock=true
45
+ ```
46
+
47
+ ## Run Checks
48
+
49
+ ```bash
50
+ npm test
51
+ npm run smoke
52
+ ```
53
+
54
+ ## Publishing Security Notes
55
+
56
+ For future public releases, prefer npm trusted publishing and provenance over long-lived npm tokens.
@@ -0,0 +1,63 @@
1
+ # Agentpack Execution Flow
2
+
3
+ ```mermaid
4
+ flowchart TD
5
+ cli["agentpack <cmd><br/>Terminal / CI"]
6
+ mcp["agentpack mcp<br/>Codex / Claude Code / Cursor / Desktop"]
7
+
8
+ cli --> dispatch["Command dispatch<br/>src/cli/index.ts"]
9
+ mcp --> root["MCP root resolution<br/>--root > AGENTPACK_ROOT > cwd"]
10
+ root --> server["MCP tool server<br/>src/mcp/server.ts"]
11
+ server --> dispatch
12
+
13
+ dispatch --> init["init<br/>create .agentpack/<br/>append local-only .gitignore patterns"]
14
+ dispatch --> install["install client<br/>project-local config<br/>or Desktop merge snippet"]
15
+ dispatch --> sourceAdd["source add<br/>hash file + store source conclusion"]
16
+ dispatch --> sourceStatus["source status<br/>UNCHANGED / CHANGED / MISSING"]
17
+ dispatch --> records["record_decision<br/>record_dead_end<br/>attach_evidence"]
18
+ dispatch --> checkpoint["checkpoint<br/>state + event + snapshot"]
19
+ dispatch --> resume["resume / load_context<br/>budgeted task context"]
20
+ dispatch --> replay["replay / diff<br/>timeline or checkpoint delta"]
21
+ dispatch --> doctor["doctor<br/>pack health + MCP setup checks"]
22
+
23
+ init --> storage
24
+ install --> localConfig["Project-local client config<br/>.codex/config.toml<br/>.mcp.json<br/>.cursor/mcp.json"]
25
+ sourceAdd --> operations["src/operations.ts<br/>hash + git status helpers"]
26
+ sourceStatus --> operations
27
+ records --> storage
28
+ checkpoint --> checkpoints["src/core/checkpoints.ts<br/>serialized writes under .lock"]
29
+ resume --> resumeBuilder["src/core/resume.ts<br/>pack root header + query filter"]
30
+ resumeBuilder --> budget["src/core/budget.ts<br/>truncate / omit sections"]
31
+ doctor --> doctorCore["src/core/doctor.ts<br/>local ignores + stale roots + source cache"]
32
+
33
+ operations --> storage
34
+ checkpoints --> storage
35
+ budget --> output
36
+ replay --> output
37
+ sourceStatus --> output
38
+ doctorCore --> output
39
+
40
+ storage[(".agentpack/<br/>state.json<br/>sources.json<br/>events.jsonl<br/>checkpoints/<br/>evidence/<br/>instructions/")]
41
+ output["Output to coding agent<br/>Pack root<br/>Git state<br/>Source cache guidance<br/>Decisions / dead ends / evidence<br/>Next actions"]
42
+
43
+ classDef entry fill:#0c2044,stroke:#388bfd,color:#c9d1d9;
44
+ classDef rootNode fill:#2a1d00,stroke:#d29922,color:#c9d1d9;
45
+ classDef command fill:#161b22,stroke:#30363d,color:#c9d1d9;
46
+ classDef core fill:#0a2a14,stroke:#3fb950,color:#c9d1d9;
47
+ classDef store fill:#1a0c3a,stroke:#8957e5,color:#c9d1d9;
48
+ classDef out fill:#0a2020,stroke:#39d353,color:#c9d1d9;
49
+
50
+ class cli,mcp entry;
51
+ class root rootNode;
52
+ class dispatch,init,install,sourceAdd,sourceStatus,records,checkpoint,resume,replay,doctor command;
53
+ class server,operations,checkpoints,resumeBuilder,budget,doctorCore,localConfig core;
54
+ class storage store;
55
+ class output out;
56
+ ```
57
+
58
+ ## Notes
59
+
60
+ - Normal CLI commands find the nearest `.agentpack/` root upward from the current working directory after `agentpack init`.
61
+ - MCP clients can also pass an explicit root. Agentpack resolves MCP roots as `--root`, then `AGENTPACK_ROOT`, then `cwd`.
62
+ - Codex, Claude Code, and Cursor use project-local config. Claude Desktop needs a merge snippet because its config is global.
63
+ - `.agentpack/` is local-only by default and should not be committed in v0.