hadara 0.3.2 → 0.3.3-rc.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 (51) hide show
  1. package/README.md +38 -23
  2. package/dist/cli/context.js +110 -0
  3. package/dist/cli/help.js +6 -7
  4. package/dist/cli/init.js +56 -58
  5. package/dist/cli/main.js +12 -0
  6. package/dist/cli/session.js +37 -0
  7. package/dist/cli/task.js +52 -0
  8. package/dist/context/code-graph-extractor.js +123 -0
  9. package/dist/context/code-index.js +1154 -0
  10. package/dist/context/context-cache-store.js +925 -0
  11. package/dist/context/context-graph-builder.js +341 -0
  12. package/dist/context/context-graph.js +42 -0
  13. package/dist/context/context-pack.js +457 -0
  14. package/dist/context/context-slice-boundary.js +37 -0
  15. package/dist/context/context-slice.js +487 -0
  16. package/dist/context/document-extractors.js +343 -0
  17. package/dist/context/evidence-extractors.js +179 -0
  18. package/dist/context/extractor-contract.js +166 -0
  19. package/dist/context/registry-extractors.js +177 -0
  20. package/dist/context/release-extractors.js +175 -0
  21. package/dist/context/session-start.js +297 -0
  22. package/dist/context/source-manifest.js +566 -0
  23. package/dist/context/state-projection.js +196 -0
  24. package/dist/context/task-extractors.js +168 -0
  25. package/dist/core/schema.js +26 -0
  26. package/dist/harness/validate.js +7 -8
  27. package/dist/schemas/code-index.schema.json +173 -0
  28. package/dist/schemas/context-cache-record.schema.json +56 -0
  29. package/dist/schemas/context-cache-status.schema.json +167 -0
  30. package/dist/schemas/context-cache-warm.schema.json +222 -0
  31. package/dist/schemas/context-graph.schema.json +286 -0
  32. package/dist/schemas/context-pack.schema.json +246 -0
  33. package/dist/schemas/context-slice.schema.json +94 -0
  34. package/dist/schemas/context-source-manifest.schema.json +147 -0
  35. package/dist/schemas/schema-index.json +91 -0
  36. package/dist/schemas/session-start.schema.json +158 -0
  37. package/dist/schemas/task-close-repair-plan.schema.json +67 -0
  38. package/dist/schemas/task-context.schema.json +125 -0
  39. package/dist/schemas/task-finalize.schema.json +98 -0
  40. package/dist/schemas/task-lifecycle.schema.json +84 -0
  41. package/dist/services/capability-registry.js +266 -9
  42. package/dist/services/lifecycle-guide.js +23 -29
  43. package/dist/services/protocol-consistency.js +6 -8
  44. package/dist/task/acceptance.js +171 -0
  45. package/dist/task/task-close-repair-plan.js +190 -0
  46. package/dist/task/task-close.js +34 -35
  47. package/dist/task/task-finalize.js +377 -0
  48. package/dist/task/task-lifecycle.js +210 -0
  49. package/dist/task/task-next.js +10 -1
  50. package/dist/task/task-ready.js +4 -0
  51. package/package.json +1 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  <p align="center">
8
8
  <img alt="Stable npm release" src="https://img.shields.io/badge/npm-0.3.2-blue">
9
- <img alt="Source version" src="https://img.shields.io/badge/source-0.3.2-blue">
9
+ <img alt="Source version" src="https://img.shields.io/badge/source-0.3.3--rc.0-blue">
10
10
  <img alt="Node.js" src="https://img.shields.io/badge/node-%3E%3D22-brightgreen">
11
11
  <img alt="License" src="https://img.shields.io/badge/license-MIT-lightgrey">
12
12
  </p>
@@ -30,18 +30,18 @@ hadara@0.3.2
30
30
  Current release candidate:
31
31
 
32
32
  ```text
33
- hadara@0.3.2-rc.0
33
+ hadara@0.3.3-rc.0
34
34
  ```
35
35
 
36
- The 0.3.2 line is the Evidence v2 refactor release. It hardens evidence writer metadata, exact resolution markers, durable evidence id discovery, canonical/derived evidence boundaries, and release-facing docs after the 0.3.1 post-publish recycle.
36
+ The 0.3.3-rc.0 line is the context-routing and lifecycle release candidate. It adds project context graph, context pack/slice/session-start surfaces, explicit context cache warm paths, and makes the finalize-first lifecycle the default agent-facing task loop.
37
37
 
38
- Phase labels are internal implementation phases, not npm release-candidate labels. The stable `0.3.2` source is prepared for approval-gated npm publish; the `0.3.2-rc.0` package remains the prior release-candidate evaluation build until stable publish is executed.
38
+ Phase labels are internal implementation phases, not npm release-candidate labels. The stable `0.3.2` package is the default install target; `0.3.3-rc.0` is the current source candidate for the next `next` dist-tag publish.
39
39
 
40
40
  | Surface | Status |
41
41
  |---|---|
42
42
  | Current stable | [`hadara@0.3.2`](docs/RELEASE_NOTES.md#032) |
43
- | Current RC | [`hadara@0.3.2-rc.0`](docs/RELEASE_NOTES.md#032-rc0) |
44
- | Previous RC | [`hadara@0.3.1-rc.1`](docs/RELEASE_NOTES.md#031-rc1) |
43
+ | Current RC | [`hadara@0.3.3-rc.0`](docs/RELEASE_NOTES.md#033-rc0) |
44
+ | Previous RC | [`hadara@0.3.2-rc.0`](docs/RELEASE_NOTES.md#032-rc0) |
45
45
  | Historical RCs | See [Release Notes](docs/RELEASE_NOTES.md). |
46
46
  | GitHub Release | Secondary target, approval-gated. |
47
47
  | Docker image | Deferred. |
@@ -72,8 +72,8 @@ npx hadara@0.3.2 doctor --json
72
72
  Evaluate the release candidate explicitly:
73
73
 
74
74
  ```bash
75
- npm install -g hadara@0.3.2-rc.0
76
- npx hadara@0.3.2-rc.0 help
75
+ npm install -g hadara@0.3.3-rc.0
76
+ npx hadara@0.3.3-rc.0 help
77
77
  ```
78
78
 
79
79
  For release or recycle evidence, prefer an isolated prefix install when PATH, global installs, or `npx` cache behavior may be stale:
@@ -122,23 +122,22 @@ hadara help command task.close
122
122
 
123
123
  ## Primary Capsule Lifecycle
124
124
 
125
- The primary path is intentionally small:
125
+ The 0.3.3 primary path is intentionally small. Agents should use `task finalize` as the default lifecycle close path:
126
126
 
127
127
  ```bash
128
128
  hadara task next --json
129
129
  hadara task create "implement a focused change" --json
130
130
  hadara task status --task T-XXXX --json
131
131
  hadara evidence add-command --task T-XXXX --summary "..." --result passed --category validation --idempotency-key "command:T-XXXX:check" --json
132
- hadara task finish --task T-XXXX --json
133
- hadara task finish --task T-XXXX --execute --json
134
132
  # Finalize Task Capsule docs and tracked state docs before closing.
135
- hadara task ready --task T-XXXX --level done --json
136
- hadara task close --task T-XXXX --json
137
- hadara task close --task T-XXXX --execute --json
138
- hadara task audit-close --task T-XXXX --json
133
+ hadara task lifecycle --task T-XXXX --json
134
+ hadara task finalize --task T-XXXX --json
135
+ hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
139
136
  hadara handoff suggest --task T-XXXX --json
140
137
  ```
141
138
 
139
+ `task finalize --json` is the reviewed dry-run. It reports the current lifecycle step, write boundaries, expected write paths, and a current `planHash`. `task finalize --execute --plan-hash ...` rechecks that plan hash, executes phases serially, stops on blockers, and succeeds only after final close audit is `closed-valid`.
140
+
142
141
  When `evidence add-command` uses both legacy `--result` and v2 `--outcome`, matching outcomes must agree with the legacy result. `recorded` and `not-applicable` outcomes keep legacy result `unknown`; incompatible combinations fail before evidence is appended.
143
142
 
144
143
  Use `hadara evidence list --task T-XXXX` to discover evidence ids before writing exact resolution markers. Text output shows `[id] time | category/outcome | visibility | summary`; JSON output includes `id`, `idSource`, `idStability`, `persistedSchemaVersion`, `category`, `outcome`, and `tags`. For long-lived references, copy only durable persisted `ev:` ids:
@@ -152,23 +151,39 @@ Legacy compatibility ids are inspection-only and are not the preferred durable r
152
151
 
153
152
  Deferred Evidence v2 scope is explicit: rebuild preview/execute, `check-id`, `subject`, and a new add-command report schema id are future candidates, not current command behavior. Treat `evidence.jsonl` as canonical append-only evidence and `EVIDENCE.md` as a non-canonical human summary.
154
153
 
155
- Optional workflow compression is read-only. Use it separately when you want a compact current-stage report and next recommended action:
154
+ Use read-only lifecycle diagnostics when you want a compact current-stage report, next recommended action, or close-proof repair explanation:
156
155
 
157
156
  ```bash
158
157
  hadara task complete --task T-XXXX --json
158
+ hadara task lifecycle --task T-XXXX --json
159
+ hadara task close-repair-plan --task T-XXXX --json
160
+ ```
161
+
162
+ Low-level proof-boundary commands remain available for debugging, recovery, and command implementation work:
163
+
164
+ ```bash
165
+ hadara task finish --task T-XXXX --json
166
+ hadara task finish --task T-XXXX --execute --json
167
+ hadara task ready --task T-XXXX --level done --json
168
+ hadara task close --task T-XXXX --json
169
+ hadara task close --task T-XXXX --execute --json
170
+ hadara task audit-close --task T-XXXX --json
159
171
  ```
160
172
 
173
+ Those commands are canonical proof boundaries under the wrapper, but they are no longer the default agent-facing cycle.
174
+
161
175
  Important boundaries:
162
176
 
163
177
  | Command | Boundary |
164
178
  |---|---|
165
179
  | `task status` | Read-only operator console. `ok:true` means the report was generated, not that the task is ready. |
166
180
  | `task complete` | Optional read-only workflow compressor. It reports the current stage and next action. |
167
- | `task finish --execute` | Writes only bounded status bookkeeping in `TASK.md` and `docs/TASK_BOARD.md`. |
168
- | `task close --execute` | Appends close evidence only. |
169
- | `task audit-close` | Read-only close proof audit. |
181
+ | `task lifecycle` | Read-only normalized lifecycle phase report for agents. |
182
+ | `task close-repair-plan` | Read-only close-proof repair classifier. |
183
+ | `task finalize` | Default agent close path. Read-only by default; guarded execute requires a matching current `planHash` and preserves underlying write boundaries. |
184
+ | `task finish` / `task ready` / `task close` / `task audit-close` | Low-level proof-boundary commands for debugging and recovery. |
170
185
 
171
- Before `task close --execute`, finish Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, Task Board updates, and tracked state docs. After close execute, changing close-source docs intentionally invalidates the previous close proof and requires rerunning ready/close/audit.
186
+ Before executing `task finalize`, finish Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, Task Board updates, and tracked state docs. After final close proof, changing close-source docs intentionally invalidates the previous close proof and requires rerunning finalize or the low-level ready/close/audit sequence.
172
187
 
173
188
  The full command semantics live in `docs/TASK_WORKFLOW_COMMANDS.md`.
174
189
 
@@ -245,7 +260,7 @@ Dashboard, TUI, Hermes, MCP, installer, package, release, and run commands stay
245
260
 
246
261
  ## Safety Boundaries
247
262
 
248
- HADARA 0.3.2 is not:
263
+ HADARA 0.3.3-rc.0 is not:
249
264
 
250
265
  - a full agent runtime;
251
266
  - Rack/enterprise behavior;
@@ -285,7 +300,7 @@ Portable/local state is not committed. Project docs, Task Capsules, and reduced
285
300
 
286
301
  `evidence.jsonl` is the canonical Task Capsule evidence source. `EVIDENCE.md` is a non-canonical human summary that can help review validation history, but it must not be treated as the source of truth for rebuild, migration, or resolution logic.
287
302
 
288
- 0.3.2 does not implement `hadara evidence rebuild --json` or an execute mode. Future rebuild work must first define whether a difference is formatting regeneration, managed-section drift, or data inconsistency before reporting `wouldChange`. Any later write-capable rebuild flow must be dry-run-first, reviewed, and before-hash guarded before it rewrites derived Markdown.
303
+ 0.3.3-rc.0 does not implement `hadara evidence rebuild --json` or an execute mode. Future rebuild work must first define whether a difference is formatting regeneration, managed-section drift, or data inconsistency before reporting `wouldChange`. Any later write-capable rebuild flow must be dry-run-first, reviewed, and before-hash guarded before it rewrites derived Markdown.
289
304
 
290
305
  ## Development / Contributing
291
306
 
@@ -298,7 +313,7 @@ hadara init --profile standard
298
313
  hadara init --profile governed
299
314
  ```
300
315
 
301
- Every profile generates `docs/TASK_WORKFLOW_COMMANDS.md` so fresh projects get the current evidence, ready, finish, close, and audit-close loop.
316
+ Every profile generates `docs/TASK_WORKFLOW_COMMANDS.md` so fresh projects get the current 0.3.3 finalize-first lifecycle loop plus low-level proof-boundary reference commands.
302
317
 
303
318
  | Profile | Use When |
304
319
  |---|---|
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleContextCommand = handleContextCommand;
4
+ const args_1 = require("./args");
5
+ const context_cache_store_1 = require("../context/context-cache-store");
6
+ const context_graph_builder_1 = require("../context/context-graph-builder");
7
+ const context_pack_1 = require("../context/context-pack");
8
+ const context_slice_1 = require("../context/context-slice");
9
+ function handleContextCommand(input) {
10
+ const sub = input.args[1];
11
+ if (sub === 'graph')
12
+ return handleContextGraphCommand(input);
13
+ if (sub === 'pack')
14
+ return handleContextPackCommand(input);
15
+ if (sub === 'slice')
16
+ return handleContextSliceCommand(input);
17
+ if (sub === 'cache')
18
+ return handleContextCacheCommand(input);
19
+ return false;
20
+ }
21
+ function handleContextGraphCommand(input) {
22
+ const taskId = (0, args_1.getStringOption)(input.args, '--task');
23
+ const includeCode = (0, args_1.getFlag)(input.args, '--include-code');
24
+ const report = (0, context_graph_builder_1.buildContextGraphReport)({
25
+ projectRoot: input.projectRoot,
26
+ includeCode,
27
+ ...(taskId ? { taskId, mode: 'task' } : { mode: 'full' })
28
+ });
29
+ if (input.jsonOutput) {
30
+ console.log(JSON.stringify(report, null, 2));
31
+ }
32
+ else {
33
+ console.log(JSON.stringify(report, null, 2));
34
+ }
35
+ if (!report.ok)
36
+ process.exitCode = 6;
37
+ return true;
38
+ }
39
+ function handleContextPackCommand(input) {
40
+ const taskId = (0, args_1.getStringOption)(input.args, '--task');
41
+ const includeCode = (0, args_1.getFlag)(input.args, '--include-code');
42
+ const budget = contextPackBudgetFromArgs(input.args);
43
+ const report = (0, context_pack_1.buildContextPackReport)({
44
+ projectRoot: input.projectRoot,
45
+ includeCode,
46
+ ...(taskId ? { taskId } : {}),
47
+ ...(Object.keys(budget).length > 0 ? { budget } : {})
48
+ });
49
+ if (input.jsonOutput) {
50
+ console.log(JSON.stringify(report, null, 2));
51
+ }
52
+ else {
53
+ console.log(JSON.stringify(report, null, 2));
54
+ }
55
+ if (!report.ok)
56
+ process.exitCode = 6;
57
+ return true;
58
+ }
59
+ function handleContextSliceCommand(input) {
60
+ const report = (0, context_slice_1.buildContextSliceReport)({
61
+ projectRoot: input.projectRoot,
62
+ path: (0, args_1.getStringOption)(input.args, '--path'),
63
+ from: (0, args_1.getIntegerOption)(input.args, '--from', { min: 1 }),
64
+ to: (0, args_1.getIntegerOption)(input.args, '--to', { min: 1 }),
65
+ symbol: (0, args_1.getStringOption)(input.args, '--symbol'),
66
+ keyword: (0, args_1.getStringOption)(input.args, '--keyword'),
67
+ window: (0, args_1.getIntegerOption)(input.args, '--window', { min: 0, max: 500 }),
68
+ tail: (0, args_1.getIntegerOption)(input.args, '--tail', { min: 1, max: 1000 }),
69
+ managedSection: (0, args_1.getStringOption)(input.args, '--managed-section'),
70
+ taskId: (0, args_1.getStringOption)(input.args, '--task'),
71
+ candidateId: (0, args_1.getStringOption)(input.args, '--candidate'),
72
+ includeCode: (0, args_1.getFlag)(input.args, '--include-code')
73
+ });
74
+ if (input.jsonOutput) {
75
+ console.log(JSON.stringify(report, null, 2));
76
+ }
77
+ else {
78
+ console.log(JSON.stringify(report, null, 2));
79
+ }
80
+ if (!report.ok)
81
+ process.exitCode = 6;
82
+ return true;
83
+ }
84
+ function handleContextCacheCommand(input) {
85
+ const action = input.args[2];
86
+ if (action !== 'status' && action !== 'warm')
87
+ return false;
88
+ const report = action === 'status'
89
+ ? (0, context_cache_store_1.createContextCacheStatusReport)({ projectRoot: input.projectRoot })
90
+ : (0, context_cache_store_1.createContextCacheWarmReport)({ projectRoot: input.projectRoot, execute: (0, args_1.getFlag)(input.args, '--execute') });
91
+ if (input.jsonOutput) {
92
+ console.log(JSON.stringify(report, null, 2));
93
+ }
94
+ else {
95
+ console.log(JSON.stringify(report, null, 2));
96
+ }
97
+ if (!report.ok)
98
+ process.exitCode = 6;
99
+ return true;
100
+ }
101
+ function contextPackBudgetFromArgs(args) {
102
+ const targetTokens = (0, args_1.getIntegerOption)(args, '--budget', { min: 1 });
103
+ const maxItems = (0, args_1.getIntegerOption)(args, '--max-items', { min: 1, max: 500 });
104
+ const maxReadFirstItems = (0, args_1.getIntegerOption)(args, '--max-read-first', { min: 1, max: 100 });
105
+ return {
106
+ ...(targetTokens !== undefined ? { targetTokens } : {}),
107
+ ...(maxItems !== undefined ? { maxItems } : {}),
108
+ ...(maxReadFirstItems !== undefined ? { maxReadFirstItems } : {})
109
+ };
110
+ }
package/dist/cli/help.js CHANGED
@@ -7,7 +7,7 @@ exports.renderCommandHelp = renderCommandHelp;
7
7
  exports.renderFamilyHelp = renderFamilyHelp;
8
8
  const capability_registry_1 = require("../services/capability-registry");
9
9
  const lifecycle_guide_1 = require("../services/lifecycle-guide");
10
- const LIFECYCLE_ORDER = ['discover', 'create', 'inspect', 'evidence', 'finish', 'ready', 'close', 'audit', 'handoff'];
10
+ const LIFECYCLE_ORDER = ['discover', 'create', 'inspect', 'evidence', 'phase-check', 'finalize', 'handoff'];
11
11
  function handleHelpCommand(input) {
12
12
  const topic = input.args[1];
13
13
  if (!topic) {
@@ -74,17 +74,16 @@ function renderLifecycleHelp() {
74
74
  const report = (0, lifecycle_guide_1.createLifecycleGuideReport)();
75
75
  const diagnostics = (0, capability_registry_1.listCommandRegistryEntries)({ family: 'proof-diagnostics' }).filter((entry) => entry.requiredness === 'diagnostic');
76
76
  const lines = [
77
- 'HADARA canonical task lifecycle',
77
+ 'HADARA 0.3.3 primary task lifecycle',
78
78
  '',
79
79
  'Primary capsule lifecycle:'
80
80
  ];
81
81
  for (const step of report.primaryPath) {
82
- lines.push(` ${step.order} ${step.stage.padEnd(9)} ${step.command}`);
83
- if (step.commandId === 'task.finish')
84
- lines.push(' hadara task finish --task T-XXXX --execute --json');
85
- if (step.commandId === 'task.close')
86
- lines.push(' hadara task close --task T-XXXX --execute --json');
82
+ lines.push(` ${step.order} ${step.stage.padEnd(11)} ${step.command}`);
83
+ if (step.commandId === 'task.finalize')
84
+ lines.push(' hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json');
87
85
  }
86
+ lines.push('', 'Low-level proof-boundary commands are available through `hadara help family capsule-lifecycle`.');
88
87
  lines.push('', 'Diagnostics when blocked:');
89
88
  for (const entry of diagnostics)
90
89
  lines.push(` ${entry.id} ${entry.command}`);
package/dist/cli/init.js CHANGED
@@ -1087,10 +1087,10 @@ Keep capsule docs current as work changes:
1087
1087
  | Before execution | \`PLAN.md\` |
1088
1088
  | During execution | \`DECISIONS.md\`, \`RISKS.md\`, and \`FILES.md\` |
1089
1089
  | Immediately after validation | \`TESTS.md\` and \`EVIDENCE.md\` |
1090
- | Before finish/ready/close | \`ACCEPTANCE.md\`, \`HANDOFF.md\`, and shared state docs |
1090
+ | Before finalize execute | \`ACCEPTANCE.md\`, \`HANDOFF.md\`, and shared state docs |
1091
1091
  | Before close-source hash is captured | \`docs/TASK_BOARD.md\`, \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when applicable |
1092
1092
 
1093
- Parallelize read-only discovery, \`rg\`/file inspection, independent validation commands, package or registry metadata inspection, read-only diagnostics, and draft preparation before writes. Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board writes, Project State writes, Agent Handoff writes, before-hash execute operations, \`task finish --execute\`, \`task close --execute\`, and release artifact or publish operations.
1093
+ Parallelize read-only discovery, \`rg\`/file inspection, independent validation commands, package or registry metadata inspection, read-only diagnostics, and draft preparation before writes. Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board writes, Project State writes, Agent Handoff writes, before-hash execute operations, \`task finalize --execute\`, low-level \`task finish --execute\`, low-level \`task close --execute\`, and release artifact or publish operations.
1094
1094
 
1095
1095
  ## Status Token And Document Ownership Policy
1096
1096
 
@@ -1100,11 +1100,11 @@ Use distinct token families for persistent task state, close proof state, docume
1100
1100
 
1101
1101
  \`DocStatus\` belongs only to the docs registry and uses \`canonical\`, \`active\`, \`reference\`, \`historical\`, \`superseded\`, and \`archived\`. Evidence outcomes are \`passed\`, \`failed\`, \`blocked\`, and \`unknown\`; preserve failed or blocked evidence and append newer corrective evidence instead of rewriting history.
1102
1102
 
1103
- Ownership boundaries follow the lifecycle command model. \`task finish --execute\` owns bounded status bookkeeping in \`TASK.md\` and command-owned \`docs/TASK_BOARD.md\` cells. \`task close --execute\` owns only close evidence append. Operators own close-source prose and shared state docs before close, then rerun ready/close/audit after any intentional close-source edit.
1103
+ Ownership boundaries follow the lifecycle command model. \`task finalize --execute --plan-hash <hash>\` is the default 0.3.3 agent close path and preserves the underlying write boundaries: \`task finish --execute\` owns bounded status bookkeeping in \`TASK.md\` and command-owned \`docs/TASK_BOARD.md\` cells, and \`task close --execute\` owns only close evidence append. Operators own close-source prose and shared state docs before finalize execute, then rerun finalize or the low-level ready/close/audit sequence after any intentional close-source edit.
1104
1104
 
1105
1105
  ## Standard Task Workflow Loop
1106
1106
 
1107
- The authoritative command semantics live in \`docs/TASK_WORKFLOW_COMMANDS.md\`. For ordinary implementation capsules, use this loop:
1107
+ The authoritative command semantics live in \`docs/TASK_WORKFLOW_COMMANDS.md\`. From 0.3.3 onward, agents should use this loop for ordinary implementation capsules:
1108
1108
 
1109
1109
  \`\`\`bash
1110
1110
  hadara task next --json
@@ -1120,20 +1120,11 @@ hadara task status --task T-XXXX --json
1120
1120
 
1121
1121
  hadara evidence add-command --task T-XXXX --summary "..." --result passed --category validation --idempotency-key "command:T-XXXX:check" --json
1122
1122
 
1123
- hadara task finish --task T-XXXX --json
1124
- hadara task finish --task T-XXXX --execute --json
1125
-
1126
1123
  # Finalize Task Capsule docs and tracked state docs before closing.
1127
1124
 
1128
- hadara task ready --task T-XXXX --level done --json
1129
-
1130
- # Optional workflow compression / next action preview:
1131
- hadara task complete --task T-XXXX --json
1132
-
1133
- hadara task close --task T-XXXX --json
1134
- hadara task close --task T-XXXX --execute --json
1135
-
1136
- hadara task audit-close --task T-XXXX --json
1125
+ hadara task lifecycle --task T-XXXX --json
1126
+ hadara task finalize --task T-XXXX --json
1127
+ hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
1137
1128
  \`\`\`
1138
1129
 
1139
1130
  | Command | Default Write Behavior | Notes |
@@ -1141,24 +1132,24 @@ hadara task audit-close --task T-XXXX --json
1141
1132
  | \`task next\` | Read-only | Recommends work; does not create tasks. |
1142
1133
  | \`task status\` | Read-only | \`ok\` means report generation succeeded; readiness is in \`state.ready\`, \`summary.blockers\`, and \`issues\`. |
1143
1134
  | \`evidence add-command\` | Write | Appends command-log evidence; does not execute shell commands; optional \`--category\`/\`--outcome\`/\`--resolves\`/\`--supersedes\` enrich v2 metadata, result/outcome mismatches are rejected, and optional \`--idempotency-key\` prevents duplicate same-key records. |
1144
- | \`task ready\` | Read-only | Checks readiness; does not mutate evidence or status docs. |
1145
- | \`task finish\` | Dry-run by default; writes only with \`--execute\` | Bounded to \`TASK.md\` and \`docs/TASK_BOARD.md\`. |
1146
- | \`task close\` | Dry-run by default; writes only with \`--execute\` | Bounded to close evidence append. |
1147
- | \`task audit-close\` | Read-only | Verifies close evidence after close. |
1135
+ | \`task lifecycle\` | Read-only | Reports normalized lifecycle phase, checks, blockers, and one next action. |
1136
+ | \`task close-repair-plan\` | Read-only | Classifies close proof repair state and exact repair command. |
1137
+ | \`task finalize\` | Read-only by default; guarded execute requires \`--plan-hash\` | Default agent close path. Rechecks the current plan hash, executes phases serially, stops on blockers, and preserves finish/close write boundaries. |
1138
+ | \`task finish\` / \`task ready\` / \`task close\` / \`task audit-close\` | Low-level proof-boundary commands | Use directly for debugging, recovery, or command implementation work. |
1148
1139
 
1149
- Before running \`task ready\` and \`task close\`, finish all close-source edits: Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, \`docs/TASK_BOARD.md\`, and tracked state docs such as \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when they apply. After \`task close --execute --json\`, do not edit those close-source documents unless you intend to rerun \`task ready\`, \`task close\`, and \`task audit-close\`. Avoid writing volatile close evidence ids into close-source docs; use stable wording such as "close evidence appended; audit returned closed-valid".
1140
+ Before running \`task finalize --execute\`, finish all close-source edits: Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, \`docs/TASK_BOARD.md\`, and tracked state docs such as \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when they apply. After finalize closes the task, do not edit those close-source documents unless you intend to rerun finalize or the low-level \`task ready\`, \`task close\`, and \`task audit-close\` sequence. Avoid writing volatile close evidence ids into close-source docs; use stable wording such as "close evidence appended; audit returned closed-valid".
1150
1141
 
1151
1142
  ## Validation
1152
1143
 
1153
1144
  1. Run relevant tests.
1154
1145
  2. Record meaningful evidence in \`EVIDENCE.md\` and \`evidence.jsonl\`.
1155
- 3. Preview and execute \`hadara task finish --task <task-id> --json\` and \`hadara task finish --task <task-id> --execute --json\`.
1156
- 4. Finalize Task Capsule docs and tracked state docs before close so the close source hash remains stable.
1157
- 5. Run \`hadara task ready --task <task-id> --level done --json\` after finish and before close.
1158
- 6. Preview and execute \`hadara task close --task <task-id> --json\` and \`hadara task close --task <task-id> --execute --json\`, then run \`hadara task audit-close --task <task-id> --json\`.
1146
+ 3. Finalize Task Capsule docs and tracked state docs before close so the close source hash remains stable.
1147
+ 4. Run \`hadara task lifecycle --task <task-id> --json\` when you need a compact phase check.
1148
+ 5. Run \`hadara task finalize --task <task-id> --json\`, review the current plan hash and write boundaries, then execute \`hadara task finalize --task <task-id> --execute --plan-hash <hash> --json\`.
1149
+ 6. Use low-level \`task finish\`, \`task ready\`, \`task close\`, and \`task audit-close\` only when debugging or repairing one proof boundary directly.
1159
1150
  7. Add project-specific integration or deployment smoke checks only after those surfaces exist and are documented for this project.
1160
1151
 
1161
- \`task ready\` and \`task close\` include done-level Task Capsule validation. Use \`hadara harness validate --task <task-id> --level done --json\` directly when you need to debug capsule format or done-level validation failures.
1152
+ \`task finalize\` and low-level \`task ready\`/\`task close\` include done-level Task Capsule validation. Use \`hadara harness validate --task <task-id> --level done --json\` directly when you need to debug capsule format or done-level validation failures.
1162
1153
 
1163
1154
  ## Evidence Records
1164
1155
 
@@ -1274,16 +1265,16 @@ function createTestStrategyDoc() {
1274
1265
  |---|---|---|
1275
1266
  | 1 | Run the relevant suite from the table above. | Task Capsule \`EVIDENCE.md\` |
1276
1267
  | 2 | Record meaningful evidence in the Task Capsule. | Task Capsule \`EVIDENCE.md\` and \`evidence.jsonl\` |
1277
- | 3 | Preview and execute \`task finish\` to synchronize status bookkeeping. | Task Capsule \`TASK.md\` and \`docs/TASK_BOARD.md\` |
1278
- | 4 | Finalize Task Capsule docs and tracked state docs before close. | Task Capsule docs and tracked state docs |
1279
- | 5 | Run \`hadara task ready --task <task-id> --level done --json\` after finish and before close. | Task Capsule \`EVIDENCE.md\` and \`evidence.jsonl\` |
1280
- | 6 | Preview and execute \`task close\`, then run \`task audit-close\`. | Task Capsule close evidence |
1268
+ | 3 | Finalize Task Capsule docs and tracked state docs before close. | Task Capsule docs and tracked state docs |
1269
+ | 4 | Run \`hadara task lifecycle --task <task-id> --json\` when you need a compact phase check. | Task Capsule docs and evidence |
1270
+ | 5 | Run \`hadara task finalize --task <task-id> --json\`, review the plan hash, then execute \`hadara task finalize --task <task-id> --execute --plan-hash <hash> --json\`. | Task Capsule close evidence |
1271
+ | 6 | Use low-level \`task finish\`, \`task ready\`, \`task close\`, and \`task audit-close\` only when debugging or repairing one proof boundary directly. | Task Capsule evidence |
1281
1272
 
1282
1273
  ## Diagnostic Checks
1283
1274
 
1284
1275
  | Check | Command | When To Use |
1285
1276
  |---|---|---|
1286
- | Task Capsule format | \`hadara harness validate --task <task-id> --level done --json\` | \`task ready\` or \`task close\` reports done-level validation failures. |
1277
+ | Task Capsule format | \`hadara harness validate --task <task-id> --level done --json\` | \`task finalize\` or low-level \`task ready\`/\`task close\` reports done-level validation failures. |
1287
1278
  | Evidence index | \`hadara evidence lint --task <task-id> --json\` | Evidence files were touched manually by mistake or evidence drift is suspected. |
1288
1279
 
1289
1280
  ## Special-Case Checks
@@ -1324,7 +1315,7 @@ HADARA task workflow commands are split by responsibility. Similar-looking comma
1324
1315
 
1325
1316
  ## Standard Task Loop
1326
1317
 
1327
- Use this loop for ordinary implementation capsules:
1318
+ From 0.3.3 onward, agents should use the finalize-first loop for ordinary implementation capsules:
1328
1319
 
1329
1320
  \`\`\`bash
1330
1321
  hadara task next --json
@@ -1340,27 +1331,31 @@ hadara task status --task T-XXXX --json
1340
1331
 
1341
1332
  hadara evidence add-command --task T-XXXX --summary "..." --result passed --category validation --idempotency-key "command:T-XXXX:check" --json
1342
1333
 
1343
- hadara task finish --task T-XXXX --json
1344
- hadara task finish --task T-XXXX --execute --json
1345
-
1346
1334
  # Finalize Task Capsule docs and tracked state docs before closing.
1347
1335
 
1348
- hadara task ready --task T-XXXX --level done --json
1336
+ hadara task lifecycle --task T-XXXX --json
1337
+ hadara task finalize --task T-XXXX --json
1338
+ hadara task finalize --task T-XXXX --execute --plan-hash sha256:... --json
1339
+ \`\`\`
1340
+
1341
+ \`task finalize --json\` is the reviewed dry-run. It reports the current lifecycle step, write boundaries, expected write paths, and a current \`planHash\`. \`task finalize --execute --plan-hash ...\` rechecks that plan hash, runs the underlying phases serially, stops on the first blocker, and succeeds only after the final close audit is \`closed-valid\`.
1349
1342
 
1350
- # Optional workflow compression / next action preview:
1351
- hadara task complete --task T-XXXX --json
1343
+ Low-level proof-boundary commands remain available for debugging, recovery, and command implementation work:
1352
1344
 
1345
+ \`\`\`bash
1346
+ hadara task finish --task T-XXXX --json
1347
+ hadara task finish --task T-XXXX --execute --json
1348
+ hadara task ready --task T-XXXX --level done --json
1353
1349
  hadara task close --task T-XXXX --json
1354
1350
  hadara task close --task T-XXXX --execute --json
1355
-
1356
1351
  hadara task audit-close --task T-XXXX --json
1357
1352
  \`\`\`
1358
1353
 
1359
- \`task finish\`, \`task ready\`, and \`task close\` are intentionally separate. \`finish\` synchronizes bounded status bookkeeping first. \`ready\` then validates the Done-level state. \`close\` records close evidence after validation succeeds. \`audit-close\` checks the resulting close evidence after the write.
1354
+ \`task finish\`, \`task ready\`, \`task close\`, and \`task audit-close\` are canonical proof boundaries under \`task finalize\`, but they are not the default agent-facing cycle. \`finish\` synchronizes bounded status bookkeeping first. \`ready\` then validates the Done-level state. \`close\` records close evidence after validation succeeds. \`audit-close\` checks the resulting close evidence after the write.
1360
1355
 
1361
1356
  The close model has three separate phases: validation proves readiness, close records the proof, and audit checks the already-recorded close evidence. Close evidence is excluded from the current validation loop because it is appended after validation; requiring it as a same-run precondition would create a fixed-point loop.
1362
1357
 
1363
- \`task ready\` and \`task close\` include done-level Task Capsule validation. Use \`hadara harness validate --task T-XXXX --level done --json\` directly when debugging capsule format, status-history, acceptance, evidence, or handoff validation failures.
1358
+ \`task finalize\` and low-level \`task ready\`/\`task close\` include done-level Task Capsule validation. Use \`hadara harness validate --task T-XXXX --level done --json\` directly when debugging capsule format, status-history, acceptance, evidence, or handoff validation failures.
1364
1359
 
1365
1360
  ## Status Token And Ownership Policy
1366
1361
 
@@ -1424,15 +1419,15 @@ Evidence outcome tokens are \`passed\`, \`failed\`, \`blocked\`, and \`unknown\`
1424
1419
  | Shared state docs | Mixed/human-owned; update before close when they are close-source relevant. |
1425
1420
  | \`.hadara/docs-registry.json\` and \`docs/DOC_REGISTRY.md\` | Docs registry-owned; registry mutations should stay dry-run-first or explicitly scoped. |
1426
1421
 
1427
- Before close, finish all close-source edits: Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, \`docs/TASK_BOARD.md\`, and tracked state docs such as \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when they apply. After \`task close --execute --json\`, changing those documents changes the close source hash and requires rerunning \`task ready\`, \`task close\`, and \`task audit-close\`. Do not paste volatile close evidence ids into close-source docs; prefer stable wording such as "close evidence appended; audit returned closed-valid".
1422
+ Before finalize execute, finish all close-source edits: Task Capsule docs, acceptance/tests/handoff notes, evidence summaries, \`docs/TASK_BOARD.md\`, and tracked state docs such as \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and roadmap/slice docs when they apply. After \`task finalize --execute --plan-hash ...\` reaches close proof, changing those documents changes the close source hash and requires rerunning finalize or the low-level \`task ready\`, \`task close\`, and \`task audit-close\` sequence. Do not paste volatile close evidence ids into close-source docs; prefer stable wording such as "close evidence appended; audit returned closed-valid".
1428
1423
 
1429
1424
  ## Documentation Timing and Write Coordination
1430
1425
 
1431
- Do not defer all documentation until after implementation. Keep \`PLAN.md\` current before execution; update \`DECISIONS.md\`, \`RISKS.md\`, and \`FILES.md\` during execution; update \`TESTS.md\` and \`EVIDENCE.md\` immediately after validation; update \`ACCEPTANCE.md\`, \`HANDOFF.md\`, and shared state docs before finish/ready/close; and update shared close-source docs before the close-source hash is captured.
1426
+ Do not defer all documentation until after implementation. Keep \`PLAN.md\` current before execution; update \`DECISIONS.md\`, \`RISKS.md\`, and \`FILES.md\` during execution; update \`TESTS.md\` and \`EVIDENCE.md\` immediately after validation; update \`ACCEPTANCE.md\`, \`HANDOFF.md\`, and shared state docs before finalize execute; and update shared close-source docs before the close-source hash is captured.
1432
1427
 
1433
1428
  Parallelize read-only discovery, \`rg\`/file inspection, independent validation commands, package or registry metadata inspection, read-only diagnostics, and draft preparation before writes.
1434
1429
 
1435
- Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board writes, Project State writes, Agent Handoff writes, before-hash execute operations, \`task finish --execute\`, \`task close --execute\`, and release artifact or publish operations.
1430
+ Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board writes, Project State writes, Agent Handoff writes, before-hash execute operations, \`task finalize --execute\`, low-level \`task finish --execute\`, low-level \`task close --execute\`, and release artifact or publish operations.
1436
1431
 
1437
1432
  ## Command Semantics
1438
1433
 
@@ -1442,30 +1437,33 @@ Serialize same-file writes, evidence append, Task Capsule doc writes, Task Board
1442
1437
  | \`task status\` | Read-only | \`ok\` means report generation succeeded; readiness is in \`state.ready\`, \`summary.blockers\`, and \`issues\`. |
1443
1438
  | \`task create\` | Write | Creates a Draft Task Capsule and Task Board row. It does not imply the task is ready or done. |
1444
1439
  | \`evidence add-command\` | Write | Appends operator-supplied command-log evidence. It does not execute shell commands or capture stdout/stderr; optional \`--category\`/\`--outcome\`/\`--resolves\`/\`--supersedes\` enrich v2 metadata, result/outcome mismatches are rejected, and optional \`--idempotency-key\` prevents duplicate same-key records. |
1445
- | \`task finish\` | Dry-run by default; writes only with \`--execute\` | Updates only \`TASK.md\` status bookkeeping and the matching \`docs/TASK_BOARD.md\` row. |
1446
- | \`task ready\` | Read-only | Checks whether the task can satisfy the requested readiness level after finish. |
1447
- | \`task complete\` | Read-only | Summarizes the current completion stage and next command; it does not execute lifecycle writes. |
1448
- | \`task close\` | Dry-run by default; writes only with \`--execute\` | Appends only canonical close evidence after close preconditions pass. |
1449
- | \`task audit-close\` | Read-only | Verifies close evidence after close. |
1440
+ | \`task lifecycle\` | Read-only | Reports normalized lifecycle phase, checks, blockers, repair metadata, and one next action. |
1441
+ | \`task close-repair-plan\` | Read-only | Classifies close proof repair state and exact repair command. |
1442
+ | \`task finalize\` | Read-only by default; guarded execute requires \`--plan-hash\` | Default agent close path. Rechecks the current plan hash, executes phases serially, stops on blockers, and succeeds only after final audit is \`closed-valid\`. |
1443
+ | \`task finish\` / \`task ready\` / \`task close\` / \`task audit-close\` | Low-level proof-boundary commands | Use directly for debugging, recovery, or command implementation work. |
1444
+ | \`task complete\` | Legacy read-only workflow compressor | Summarizes the current completion stage and next command; prefer \`task lifecycle\` and \`task finalize\` for 0.3.3 agent flows. |
1450
1445
 
1451
1446
  ## Non-Overlap Rules
1452
1447
 
1453
1448
  - \`task next\` chooses work; it does not create a capsule or infer completion.
1454
1449
  - \`task status\` is an operator console; \`ok: true\` means report generation succeeded, not that the task is ready.
1455
- - \`task ready\` checks readiness; it does not write evidence or status.
1450
+ - \`task ready\` checks readiness; it does not write evidence or status. In normal 0.3.3 agent work, call it through \`task finalize\` unless debugging a readiness blocker directly.
1456
1451
  - \`harness validate\` is a direct diagnostic for Task Capsule structure and done-level gates; it is not a replacement for close evidence.
1457
- - \`task complete\` is a read-only workflow compressor. It may report the next lifecycle command, but it must not execute finish, ready, close, or audit commands.
1452
+ - \`task complete\` is a legacy read-only workflow compressor. It may report the next lifecycle command, but it must not execute finish, ready, close, or audit commands. Prefer \`task lifecycle\` and \`task finalize\` for 0.3.3 agent flows.
1453
+ - \`task lifecycle\` is the read-only normalized phase API for agents.
1454
+ - \`task close-repair-plan\` is a read-only close-proof repair classifier.
1455
+ - \`task finalize\` is read-only by default. Guarded execute requires a matching current dry-run \`planHash\`, runs phases serially, stops on blockers, and returns success only after \`task audit-close\` is \`closed-valid\`.
1458
1456
  - \`evidence list\` is the supported evidence id discovery surface. Text output shows \`[id] time | category/outcome | visibility | summary\`; JSON records expose \`id\`, \`idSource\`, \`idStability\`, \`persistedSchemaVersion\`, \`category\`, \`outcome\`, and \`tags\`. Use durable persisted \`ev:\` ids for long-lived \`--resolves\` and \`--supersedes\` references. Legacy compatibility ids are inspection-only and are not the preferred durable reference.
1459
1457
  - \`evidence add-command\` records an operator-supplied command result; it does not run the command. \`--category\` and \`--outcome\` set persisted v2 metadata explicitly, while \`--result\` remains the legacy-compatible command result. When both are supplied, \`--result\` must match \`--outcome\` for \`passed\`, \`failed\`, \`blocked\`, and \`unknown\`; \`recorded\` and \`not-applicable\` require \`--result unknown\` or no explicit \`--result\`. \`--resolves\` and \`--supersedes\` append exact v2 resolution tags from passed or recorded follow-up evidence. \`--idempotency-key\` is optional; when supplied, same-key repeats return the existing record without appending duplicate Markdown or JSONL rows.
1460
1458
  - Evidence v2 deferred scope remains explicit: rebuild preview/execute, \`check-id\`, \`subject\`, and a new add-command report schema id are future candidates. Do not infer those commands or schema changes from the current \`evidence list\` and \`evidence add-command\` ergonomics.
1461
- - \`task finish\` may update only the Task Capsule \`TASK.md\` status and the matching \`docs/TASK_BOARD.md\` row's command-owned cells: \`ID\`, \`Title\`, \`Status\`, and \`Capsule\`. It preserves human/mixed-owned \`Notes\` and any extra cells.
1462
- - \`task close\` may append only close evidence. It must not update status docs, Task Board rows, handoff, Project State, roadmap docs, or arbitrary evidence.
1463
- - After \`task close --execute --json\`, close-source document edits intentionally invalidate the previous close proof. Make those edits before close, or rerun ready/close/audit if the edit is unavoidable.
1464
- - \`task audit-close\` is read-only and should be run after \`task close --execute --json\`.
1459
+ - \`task finish\` may update only the Task Capsule \`TASK.md\` status and the matching \`docs/TASK_BOARD.md\` row's command-owned cells: \`ID\`, \`Title\`, \`Status\`, and \`Capsule\`. It preserves human/mixed-owned \`Notes\` and any extra cells. In normal 0.3.3 agent work, call it through \`task finalize --execute\`.
1460
+ - \`task close\` may append only close evidence. It must not update status docs, Task Board rows, handoff, Project State, roadmap docs, or arbitrary evidence. In normal 0.3.3 agent work, call it through \`task finalize --execute\`.
1461
+ - After close proof is recorded, close-source document edits intentionally invalidate the previous close proof. Make those edits before finalize execute, or rerun finalize/low-level ready-close-audit if the edit is unavoidable.
1462
+ - \`task audit-close\` is read-only and is normally reached through \`task finalize --execute\`.
1465
1463
 
1466
1464
  ## State Documents
1467
1465
 
1468
- \`task finish --execute --json\` deliberately does not update broad prose state. Operators still update \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and any roadmap/slice docs generated for the selected profile when the task changes project state.
1466
+ \`task finalize --execute --plan-hash <hash>\` deliberately preserves narrow write boundaries; it does not update broad prose state beyond the underlying finish/close writes. Operators still update \`docs/PROJECT_STATE.md\`, \`docs/AGENT_HANDOFF.md\`, and any roadmap/slice docs generated for the selected profile before finalize when the task changes project state.
1469
1467
  `;
1470
1468
  }
1471
1469
  function createAgentsDoc(spec) {
@@ -1497,8 +1495,8 @@ function createAgentsDoc(spec) {
1497
1495
  ['Task creation', 'If no suitable capsule exists, create one with `hadara task create <title>`.', '`docs/TASK_BOARD.md`'],
1498
1496
  ['Evidence', 'Do not mark work done without evidence. Do not hand-edit `evidence.jsonl`; record failed or blocked checks honestly instead of replacing them with optimistic summaries.', '`EVIDENCE.md`, `evidence.jsonl`'],
1499
1497
  ['Documentation timing', 'Do not defer all documentation until after implementation; keep capsule docs current as work changes.', 'Task Capsule docs and shared state docs'],
1500
- ['Write coordination', 'Parallelize read-only discovery and independent validation; serialize evidence append, Task Capsule doc writes, shared state doc writes, before-hash executes, finish/close executes, and release/publish operations.', 'Task Capsule evidence'],
1501
- ['Task workflow', 'For task workflow commands, follow `docs/TASK_WORKFLOW_COMMANDS.md`: record evidence, preview and execute `task finish`, finalize close-source docs, run `task ready`, preview and execute `task close`, then run `task audit-close`.', 'Task Capsule evidence'],
1498
+ ['Write coordination', 'Parallelize read-only discovery and independent validation; serialize evidence append, Task Capsule doc writes, shared state doc writes, before-hash executes, `task finalize --execute`, low-level finish/close executes, and release/publish operations.', 'Task Capsule evidence'],
1499
+ ['Task workflow', 'For task workflow commands, follow `docs/TASK_WORKFLOW_COMMANDS.md`: from 0.3.3 onward, agents should use `task lifecycle` and reviewed `task finalize --json` / `task finalize --execute --plan-hash <hash>` as the default close path. Use `task finish`, `task ready`, `task close`, and `task audit-close` only as low-level proof-boundary commands for debugging, recovery, or command implementation work.', 'Task Capsule evidence'],
1502
1500
  ['Safety', 'Do not execute dangerous commands without explicit user approval.', 'Task Capsule evidence'],
1503
1501
  ['Secrets', 'Do not write secrets, private logs, or machine-local state into committed files.', 'Changed-file review'],
1504
1502
  ['Store boundary', 'Preserve the portable/project store boundary.', spec.docs.architecture ? '`.gitignore`, `docs/ARCHITECTURE.md`' : '`.gitignore`'],
package/dist/cli/main.js CHANGED
@@ -179,6 +179,18 @@ async function main(args = process.argv.slice(2)) {
179
179
  return;
180
180
  break;
181
181
  }
182
+ case 'context': {
183
+ const { handleContextCommand } = await Promise.resolve().then(() => __importStar(require('./context')));
184
+ if (handleContextCommand({ args, projectRoot: paths.projectRoot, jsonOutput }))
185
+ return;
186
+ break;
187
+ }
188
+ case 'session': {
189
+ const { handleSessionCommand } = await Promise.resolve().then(() => __importStar(require('./session')));
190
+ if (handleSessionCommand({ args, projectRoot: paths.projectRoot, jsonOutput }))
191
+ return;
192
+ break;
193
+ }
182
194
  case 'dashboard': {
183
195
  const { handleDashboardCommand } = await Promise.resolve().then(() => __importStar(require('./dashboard')));
184
196
  if (handleDashboardCommand({ args, projectRoot: paths.projectRoot }))
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleSessionCommand = handleSessionCommand;
4
+ const args_1 = require("./args");
5
+ const session_start_1 = require("../context/session-start");
6
+ function handleSessionCommand(input) {
7
+ const sub = input.args[1];
8
+ if (sub !== 'start')
9
+ return false;
10
+ const budget = sessionStartBudgetFromArgs(input.args);
11
+ const report = (0, session_start_1.buildSessionStartReport)({
12
+ projectRoot: input.projectRoot,
13
+ taskId: (0, args_1.getStringOption)(input.args, '--task'),
14
+ includeCode: (0, args_1.getFlag)(input.args, '--include-code'),
15
+ allowLiveContextPack: (0, args_1.getFlag)(input.args, '--live'),
16
+ ...(Object.keys(budget).length > 0 ? { budget } : {})
17
+ });
18
+ if (input.jsonOutput) {
19
+ console.log(JSON.stringify(report, null, 2));
20
+ }
21
+ else {
22
+ console.log(JSON.stringify(report, null, 2));
23
+ }
24
+ if (!report.ok)
25
+ process.exitCode = 6;
26
+ return true;
27
+ }
28
+ function sessionStartBudgetFromArgs(args) {
29
+ const targetTokens = (0, args_1.getIntegerOption)(args, '--budget', { min: 1 });
30
+ const maxItems = (0, args_1.getIntegerOption)(args, '--max-items', { min: 1, max: 200 });
31
+ const maxReadFirstItems = (0, args_1.getIntegerOption)(args, '--max-read-first', { min: 1, max: 50 });
32
+ return {
33
+ ...(targetTokens !== undefined ? { targetTokens } : {}),
34
+ ...(maxItems !== undefined ? { maxItems } : {}),
35
+ ...(maxReadFirstItems !== undefined ? { maxReadFirstItems } : {})
36
+ };
37
+ }