@veewo/claw 0.2.16 → 0.2.17

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.
package/README.md CHANGED
@@ -1,141 +1,141 @@
1
- # @veewo/claw
2
-
3
- `@veewo/claw` is the CLI entrypoint for running the `.claw` workflow in a project.
4
-
5
- It gives agents and developers a concrete way to plan work, recall project knowledge, deposit truth and ADR notes, and close rounds out cleanly instead of leaving project state scattered across transient chats.
6
-
7
- ## What the CLI is for
8
-
9
- - initialize and normalize the `.claw` project surface
10
- - run project-scoped planning and task lifecycle commands
11
- - index and query project documentation recall
12
- - support truth ingestion and closeout flows
13
-
14
- ## Install
15
-
16
- ```bash
17
- npm install -g @veewo/claw
18
- ```
19
-
20
- After installing the CLI, project search still needs one-time setup inside each `.claw` project:
21
-
22
- 1. Run `claw context` so `.claw/project.json` is normalized and the default local embedding config is present.
23
- 2. Run `claw search index --refresh` once so the local embedding model can be downloaded or reused and the first vector index can be built.
24
-
25
- ## Host startup context
26
-
27
- `claw context --host <host>` is the single structured startup-state entrypoint
28
- for host adapters. A host Hook owns its native event payload, validates its
29
- trusted cwd and session identity, invokes `context`, and maps the JSON result
30
- to its own prompt, card, or host-action surface. The CLI does not own platform
31
- Hook event names or Hook-output envelopes.
32
-
33
- The result may contain `activeWorkflow`, `error`, `startupRecovery.versionSync`,
34
- and `searchGuidance`, in addition to project and session state. Adapters must
35
- not accept cwd or session identity from model input. A missing `activeWorkflow`
36
- means the session has no bound plan; it does not authorize plan discovery by
37
- scanning unrelated project tasks.
38
-
39
- Then run:
40
-
41
- ```bash
42
- claw init
43
- claw search index --refresh
44
- claw search "existing truth or ADR topic"
45
- claw plan create --title "My task" --goal "Define the first task"
46
- claw plan create "My templated task" --template default --goal "Route through the default template"
47
- claw plan create "Ephemeral harness" --scope session --goal "Use plan and Goal workflows without project deposition"
48
- ```
49
-
50
- `claw plan create` uses explicit `--template` first, otherwise the project's configured `defaultPlanTemplate`, and finally falls back to the built-in `default` template. You can select a template explicitly with `claw plan create "<title>" --template <name>` or `claw plan create --template <name> --title "<title>"`.
51
-
52
- New project tasks are grouped under `.claw/tasks/YYYY-MM-DD/`. On the first `claw context` call of each local calendar day, claw performs a lock-protected maintenance pass: it removes expired entries from `.claw/runtime/tmp/`, removes workflow task directories that exceed the task TTL even when incomplete, moves eligible date-scoped task folders into the archive, applies `maxTasksToKeep` and archive TTL, removes expired or invalid bindings, and sweeps expired session workflows. This is lazy maintenance, not a background scheduler.
53
-
54
- `--scope session` stores the workflow in a user-level directory keyed by the platform session id, so it works without a project `.claw` directory and recovers across cwd changes. It preserves plan/task/subplan/Goal behavior while disabling project knowledge capture, memory/GitNexus refresh, and project retention. Use `claw session clean` for the current session or `claw session clean --expired` for the seven-day TTL sweep.
55
-
56
- Projects can add reusable templates directly under `.claw/templates` with `.json`, `.js`, `.mjs`, or `.cjs` files. Put `defaultPlanTemplate` in `.claw/project.json` for a shared team default, or in `.claw/project-override.json` for a local personal override.
57
-
58
- When `.claw/project.json` has `planning: true`, the default `default` template seeds one planning task in `process.discussing`. It loads the effective `externalPlanningSkill`, falling back to `claw-kit:planning`, and stays open while the requirements and proposed solution are discussed and confirmed with the user. Use `plan start` when execution tasks remain; when planning itself resolves the request, complete task 1 and close the plan.
59
-
60
- When `planning: false`, `claw plan create` seeds the smallest executable plan directly in `process.active`.
61
-
62
- ## Workflow shape
63
-
64
- In a typical round, the CLI helps land this loop in a project:
65
-
66
- `plan` -> `search and recall` -> `execute` -> `deposit truth / ADR` -> `close out`
67
-
68
- That project-level plan structure helps agents carry longer-running work more cleanly than leaving the task in loose chat state alone.
69
-
70
- ## Persistent sessions
71
-
72
- Open a persistent terminal with:
73
-
74
- ```bash
75
- claw session open <dir> <agent-session-id>
76
- ```
77
-
78
- The workdir is immutable for the lifetime of that session. Opening another
79
- directory closes the prior live connection and opens the composite identity
80
- `(canonical workdir, agent session id)`; two directories with the same agent id
81
- remain isolated.
82
-
83
- Inside the terminal, these commands implicitly target `currentPlan`:
84
-
85
- ```text
86
- plan show [--simple]
87
- plan edit ...
88
- plan wait
89
- plan done --retrospective "..."
90
- task add ...
91
- task edit --id ...
92
- task done --id ...
93
- ```
94
-
95
- Use `plan resume` to resume the retained current plan, `plan resume <planId>` to
96
- make a specified resumable plan current, and `plan leave` to enter
97
- `end.leave` and clear focus. Every `end.*` triggers end-state finalization;
98
- `end.leave` remains resumable and does not set `completedAt`.
99
-
100
- `search --dir <dir> <query>` changes only that search operation. It never
101
- changes the session workdir or current plan.
102
-
103
- On an interrupted connection, mutations are never replayed automatically.
104
- Reopen with the exact command returned by the error, then inspect
105
- `plan show --simple`. Retained v2 state expires seven days after its last
106
- update. Legacy session caches are not migrated and canonical plans are never
107
- deleted by v2 cleanup.
108
-
109
- Host adapters remain compatible with the stateless CLI. They can adopt
110
- `@veewo/claw-client` incrementally once they consume the same structured
111
- post-commit effects; opening a persistent session does not change existing
112
- adapter behavior.
113
-
114
- Codex startup workflow should rely on the session hook or startup recovery path instead of treating any extra manual recovery step as required after plan creation.
115
-
116
- ## Search and recall
117
-
118
- `claw search` is the project recall command for `.claw` memory, truth, ADR, and declared markdown docs. Use it for retained project context rather than code search.
119
-
120
- When a task needs deeper code investigation or relationship tracing, GitNexus can complement this workflow, but it is optional rather than required for using `claw` itself.
121
-
122
- Typical setup:
123
-
124
- ```bash
125
- claw context
126
- claw search index --refresh
127
- ```
128
-
129
- If you need deeper backup detail on config or recall behavior, use the adapter reference notes in [packages/codex-adapter/references/project-config-reference.md](../codex-adapter/references/project-config-reference.md) or [packages/opencode-adapter/references/project-config-reference.md](../opencode-adapter/references/project-config-reference.md).
130
-
131
- ## Configuration
132
-
133
- If you need backup `.claw/project.json` detail, start with the adapter reference notes above and use [docs/project-json-reference.md](../../docs/project-json-reference.md) only for deeper canonical detail.
134
-
135
- `claw-kit` also stays usable alongside other harnesses or external skills, so the CLI does not assume a single host or investigation surface.
136
-
137
- The config model is team-friendly as well: `.claw/project.json` carries the shared canonical workflow, while `.claw/project-override.json` leaves room for personal runtime preferences.
138
-
139
- ## Repository
140
-
141
- - [claw-kit](https://github.com/chanyuenpang/claw-kit)
1
+ # @veewo/claw
2
+
3
+ `@veewo/claw` is the CLI entrypoint for running the `.claw` workflow in a project.
4
+
5
+ It gives agents and developers a concrete way to plan work, recall project knowledge, deposit truth and ADR notes, and close rounds out cleanly instead of leaving project state scattered across transient chats.
6
+
7
+ ## What the CLI is for
8
+
9
+ - initialize and normalize the `.claw` project surface
10
+ - run project-scoped planning and task lifecycle commands
11
+ - index and query project documentation recall
12
+ - support truth ingestion and closeout flows
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install -g @veewo/claw
18
+ ```
19
+
20
+ After installing the CLI, project search still needs one-time setup inside each `.claw` project:
21
+
22
+ 1. Run `claw context` so `.claw/project.json` is normalized and the default local embedding config is present.
23
+ 2. Run `claw search index --refresh` once so the local embedding model can be downloaded or reused and the first vector index can be built.
24
+
25
+ ## Host startup context
26
+
27
+ `claw context --host <host>` is the single structured startup-state entrypoint
28
+ for host adapters. A host Hook owns its native event payload, validates its
29
+ trusted cwd and session identity, invokes `context`, and maps the JSON result
30
+ to its own prompt, card, or host-action surface. The CLI does not own platform
31
+ Hook event names or Hook-output envelopes.
32
+
33
+ The result may contain `activeWorkflow`, `error`, `startupRecovery.versionSync`,
34
+ and `searchGuidance`, in addition to project and session state. Adapters must
35
+ not accept cwd or session identity from model input. A missing `activeWorkflow`
36
+ means the session has no bound plan; it does not authorize plan discovery by
37
+ scanning unrelated project tasks.
38
+
39
+ Then run:
40
+
41
+ ```bash
42
+ claw init
43
+ claw search index --refresh
44
+ claw search "existing truth or ADR topic"
45
+ claw plan create --title "My task" --goal "Define the first task"
46
+ claw plan create "My templated task" --template default --goal "Route through the default template"
47
+ claw plan create "Ephemeral harness" --scope session --goal "Use plan and Goal workflows without project deposition"
48
+ ```
49
+
50
+ `claw plan create` uses explicit `--template` first, otherwise the project's configured `defaultPlanTemplate`, and finally falls back to the built-in `default` template. You can select a template explicitly with `claw plan create "<title>" --template <name>` or `claw plan create --template <name> --title "<title>"`.
51
+
52
+ New project tasks are grouped under `.claw/tasks/YYYY-MM-DD/`. On the first `claw context` call of each local calendar day, claw performs a lock-protected maintenance pass: it removes expired entries from `.claw/runtime/tmp/`, removes workflow task directories that exceed the task TTL even when incomplete, moves eligible date-scoped task folders into the archive, applies `maxTasksToKeep` and archive TTL, removes expired or invalid bindings, and sweeps expired session workflows. This is lazy maintenance, not a background scheduler.
53
+
54
+ `--scope session` stores the workflow in a user-level directory keyed by the platform session id, so it works without a project `.claw` directory and recovers across cwd changes. It preserves plan/task/subplan/Goal behavior while disabling project knowledge capture, memory/GitNexus refresh, and project retention. Use `claw session clean` for the current session or `claw session clean --expired` for the seven-day TTL sweep.
55
+
56
+ Projects can add reusable templates directly under `.claw/templates` with `.json`, `.js`, `.mjs`, or `.cjs` files. Put `defaultPlanTemplate` in `.claw/project.json` for a shared team default, or in `.claw/project-override.json` for a local personal override.
57
+
58
+ When `.claw/project.json` has `planning: true`, the default `default` template seeds one planning task in `process.discussing`. It loads the effective `externalPlanningSkill`, falling back to `claw-kit:planning`, and stays open while the requirements and proposed solution are discussed and confirmed with the user. Use `plan start` when execution tasks remain; when planning itself resolves the request, complete task 1 and close the plan.
59
+
60
+ When `planning: false`, `claw plan create` seeds the smallest executable plan directly in `process.active`.
61
+
62
+ ## Workflow shape
63
+
64
+ In a typical round, the CLI helps land this loop in a project:
65
+
66
+ `plan` -> `search and recall` -> `execute` -> `deposit truth / ADR` -> `close out`
67
+
68
+ That project-level plan structure helps agents carry longer-running work more cleanly than leaving the task in loose chat state alone.
69
+
70
+ ## Persistent sessions
71
+
72
+ Open a persistent terminal with:
73
+
74
+ ```bash
75
+ claw session open <dir> <agent-session-id>
76
+ ```
77
+
78
+ The workdir is immutable for the lifetime of that session. Opening another
79
+ directory closes the prior live connection and opens the composite identity
80
+ `(canonical workdir, agent session id)`; two directories with the same agent id
81
+ remain isolated.
82
+
83
+ Inside the terminal, these commands implicitly target `currentPlan`:
84
+
85
+ ```text
86
+ plan show [--simple]
87
+ plan edit ...
88
+ plan wait
89
+ plan done --retrospective "..."
90
+ task add ...
91
+ task edit --id ...
92
+ task done --id ...
93
+ ```
94
+
95
+ Use `plan resume` to resume the retained current plan, `plan resume <planId>` to
96
+ make a specified resumable plan current, and `plan leave` to enter
97
+ `end.leave` and clear focus. Every `end.*` triggers end-state finalization;
98
+ `end.leave` remains resumable and does not set `completedAt`.
99
+
100
+ `search --dir <dir> <query>` changes only that search operation. It never
101
+ changes the session workdir or current plan.
102
+
103
+ On an interrupted connection, mutations are never replayed automatically.
104
+ Reopen with the exact command returned by the error, then inspect
105
+ `plan show --simple`. Retained v2 state expires seven days after its last
106
+ update. Legacy session caches are not migrated and canonical plans are never
107
+ deleted by v2 cleanup.
108
+
109
+ Host adapters remain compatible with the stateless CLI. They can adopt
110
+ `@veewo/claw-client` incrementally once they consume the same structured
111
+ post-commit effects; opening a persistent session does not change existing
112
+ adapter behavior.
113
+
114
+ Codex startup workflow should rely on the session hook or startup recovery path instead of treating any extra manual recovery step as required after plan creation.
115
+
116
+ ## Search and recall
117
+
118
+ `claw search` is the project recall command for `.claw` memory, truth, ADR, and declared markdown docs. Use it for retained project context rather than code search.
119
+
120
+ When a task needs deeper code investigation or relationship tracing, GitNexus can complement this workflow, but it is optional rather than required for using `claw` itself.
121
+
122
+ Typical setup:
123
+
124
+ ```bash
125
+ claw context
126
+ claw search index --refresh
127
+ ```
128
+
129
+ If you need deeper backup detail on config or recall behavior, use the adapter reference notes in [packages/codex-adapter/references/project-config-reference.md](../codex-adapter/references/project-config-reference.md) or [packages/opencode-adapter/references/project-config-reference.md](../opencode-adapter/references/project-config-reference.md).
130
+
131
+ ## Configuration
132
+
133
+ If you need backup `.claw/project.json` detail, start with the adapter reference notes above and use [docs/project-json-reference.md](../../docs/project-json-reference.md) only for deeper canonical detail.
134
+
135
+ `claw-kit` also stays usable alongside other harnesses or external skills, so the CLI does not assume a single host or investigation surface.
136
+
137
+ The config model is team-friendly as well: `.claw/project.json` carries the shared canonical workflow, while `.claw/project-override.json` leaves room for personal runtime preferences.
138
+
139
+ ## Repository
140
+
141
+ - [claw-kit](https://github.com/chanyuenpang/claw-kit)
package/dist/cli.js CHANGED
@@ -182,10 +182,10 @@ const COMMAND_HELP = {
182
182
  },
183
183
  done: {
184
184
  usage: ["{script} plan done --retrospective <text> [options]"],
185
- description: "Shortcut for applying closeout fields and --status end.completed in one ordered plan edit; it retains the task for at least one hour, sweeps older completed tasks into the archive, and queues the async completion refresh.",
186
- summary: "Shortcut for completing a plan with a retrospective and queueing completion refresh.",
185
+ description: "Shortcut for applying closeout fields and --status end.completed in one ordered plan edit; project scope requires a retrospective, while session scope completes without document deposition. It retains the task for at least one hour, sweeps older completed tasks into the archive, and queues the async completion refresh.",
186
+ summary: "Shortcut for completing a plan and queueing completion refresh.",
187
187
  options: [
188
- { flag: "--retrospective <text>", detail: "Retrospective summary (required)." },
188
+ { flag: "--retrospective <text>", detail: "Retrospective summary (required for project scope)." },
189
189
  { flag: "--key-decision <text>", detail: "Append a durable key decision when one exists (repeatable)." },
190
190
  { flag: "--what-worked <text>", detail: "Append a retrospective success (repeatable)." },
191
191
  { flag: "--issue <text>", detail: "Append a retrospective issue (repeatable)." },
@@ -788,9 +788,6 @@ function parsePersistentSessionCommand(line) {
788
788
  }
789
789
  if (group === "plan" && action === "done") {
790
790
  const retrospectiveSummary = consumeSessionFlag(tokens, "--retrospective");
791
- if (!retrospectiveSummary) {
792
- throw new ClawError("RETROSPECTIVE_REQUIRED", "plan done requires --retrospective.");
793
- }
794
791
  const keyDecisions = consumeAllSessionFlags(tokens, "--key-decision");
795
792
  const whatWorked = consumeAllSessionFlags(tokens, "--what-worked");
796
793
  const issues = consumeAllSessionFlags(tokens, "--issue");
@@ -801,7 +798,7 @@ function parsePersistentSessionCommand(line) {
801
798
  request: {
802
799
  operation: "plan.done",
803
800
  input: {
804
- retrospectiveSummary,
801
+ ...(retrospectiveSummary ? { retrospectiveSummary } : {}),
805
802
  ...(keyDecisions.length ? { keyDecisions } : {}),
806
803
  ...(whatWorked.length ? { whatWorked } : {}),
807
804
  ...(issues.length ? { issues } : {}),
@@ -1334,11 +1331,8 @@ async function runPlan(args, effectiveHost) {
1334
1331
  }
1335
1332
  case "done": {
1336
1333
  const retrospective = readOptionalFlag(args, "--retrospective");
1337
- if (!retrospective?.trim()) {
1338
- throw new ClawError("PROJECT_CONFIG_INVALID", "plan done requires --retrospective.");
1339
- }
1340
1334
  const updates = {
1341
- retrospectiveSummary: retrospective,
1335
+ ...(retrospective?.trim() ? { retrospectiveSummary: retrospective } : {}),
1342
1336
  keyDecisions: readRepeatedFlag(args, "--key-decision"),
1343
1337
  whatWorked: readRepeatedFlag(args, "--what-worked"),
1344
1338
  issues: readRepeatedFlag(args, "--issue"),
@@ -1352,6 +1346,10 @@ async function runPlan(args, effectiveHost) {
1352
1346
  ...target,
1353
1347
  ownerSessionKey,
1354
1348
  });
1349
+ const currentProject = resolveWorkflowProjectContext(process.cwd(), ownerSessionKey);
1350
+ if (currentProject.scope !== "session" && !retrospective?.trim()) {
1351
+ throw new ClawError("RETROSPECTIVE_REQUIRED", "plan done requires --retrospective for project-scoped plans.");
1352
+ }
1355
1353
  const project = tryResolveHookProject(process.cwd());
1356
1354
  const effectiveWriter = resolveKnowledgeWriterForHost(project
1357
1355
  ? resolvePlanEffectiveConfig(project.projectConfig, current.plan)?.knowledgeWriter
@@ -1441,6 +1439,7 @@ async function runPlanSync(args, effectiveHost) {
1441
1439
  plan: result.plan,
1442
1440
  projectRoot: project.projectRoot,
1443
1441
  projectConfig: project.projectConfig,
1442
+ scope: project.scope,
1444
1443
  previousStatus: "process.wait",
1445
1444
  host: effectiveHost,
1446
1445
  recoveryResync: true,
@@ -2785,6 +2784,7 @@ async function tryResolveActiveWorkflowSnapshot(cwd, ownerSessionKey, effectiveH
2785
2784
  plan: result.plan,
2786
2785
  projectRoot: project.projectRoot,
2787
2786
  projectConfig: project.projectConfig,
2787
+ scope: project.scope,
2788
2788
  host: effectiveHost,
2789
2789
  }),
2790
2790
  };