@cassiomc1/forgeloop 1.0.0 → 1.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 (95) hide show
  1. package/.cursor/rules/project-loop.mdc +3 -2
  2. package/.github/copilot-instructions.md +1 -0
  3. package/AGENTS.md +2 -1
  4. package/CLAUDE.md +1 -0
  5. package/DOCS_INDEX.md +36 -0
  6. package/ENG/design-code-eng.md +31 -0
  7. package/ENG/documentation-quality-eng.md +400 -0
  8. package/EXECUTION_STATE.md +23 -13
  9. package/GUIDE_ROUTER.md +23 -8
  10. package/LOOP_ENGINEERING.md +77 -12
  11. package/PROTOCOL_INTEGRATION.md +9 -6
  12. package/README.md +82 -39
  13. package/docs/ARTIFACT_REFERENCE.md +442 -0
  14. package/docs/CLI_REFERENCE.md +892 -0
  15. package/docs/CROSS_HARNESS_CONTINUITY.md +198 -0
  16. package/docs/DOCUMENTATION_GUIDE.md +161 -0
  17. package/docs/GETTING_STARTED.md +348 -0
  18. package/docs/RECIPES.md +250 -0
  19. package/docs/TROUBLESHOOTING.md +345 -0
  20. package/docs/assets/forgeloop-flow.svg +1 -1
  21. package/docs/forgeloop-flow.mmd +1 -1
  22. package/package.json +13 -2
  23. package/schemas/task-descriptor.schema.json +56 -0
  24. package/schemas/work-state.schema.json +18 -1
  25. package/scripts/CI_VALIDATORS.md +7 -0
  26. package/src/cli.js +280 -388
  27. package/src/commands/advance.js +5 -2
  28. package/src/commands/audit.js +11 -1
  29. package/src/commands/clear-continuity.js +5 -2
  30. package/src/commands/clear-state.js +5 -2
  31. package/src/commands/complete.js +9 -1
  32. package/src/commands/continuity.js +5 -2
  33. package/src/commands/inspect.js +10 -2
  34. package/src/commands/next.js +5 -2
  35. package/src/commands/preflight.js +9 -1
  36. package/src/commands/prepare-completion.js +5 -2
  37. package/src/commands/reconcile-continuity.js +5 -2
  38. package/src/commands/record-check.js +7 -1
  39. package/src/commands/record-continuity.js +21 -14
  40. package/src/commands/record-terminal-result.js +7 -1
  41. package/src/commands/route.js +22 -18
  42. package/src/commands/run-check.js +52 -44
  43. package/src/commands/status.js +18 -12
  44. package/src/commands/task-create.js +94 -0
  45. package/src/commands/task-list.js +48 -0
  46. package/src/commands/task-migrate.js +34 -0
  47. package/src/commands/task-scope.js +75 -0
  48. package/src/commands/task-show.js +81 -0
  49. package/src/commands/task-unlock.js +35 -0
  50. package/src/commands/validate-protocol.js +37 -20
  51. package/src/commands/validate-state.js +24 -18
  52. package/src/config/guides.json +42 -0
  53. package/src/core/activation.js +8 -4
  54. package/src/core/artifact-registry.js +166 -0
  55. package/src/core/audit.js +65 -12
  56. package/src/core/bundles.js +76 -50
  57. package/src/core/cli-command-definitions.js +611 -0
  58. package/src/core/cli-metadata.js +23 -0
  59. package/src/core/completion-artifacts.js +161 -74
  60. package/src/core/completion.js +134 -76
  61. package/src/core/continuity.js +20 -13
  62. package/src/core/contract.js +6 -3
  63. package/src/core/error-codes.js +197 -0
  64. package/src/core/events.js +19 -14
  65. package/src/core/execution.js +38 -6
  66. package/src/core/gate-artifact.js +12 -9
  67. package/src/core/gates.js +4 -2
  68. package/src/core/guide-metadata.js +7 -11
  69. package/src/core/guide-registry.js +29 -0
  70. package/src/core/inspect.js +7 -4
  71. package/src/core/native-adapters.js +6 -0
  72. package/src/core/phase.js +85 -33
  73. package/src/core/preflight-consistency.js +24 -14
  74. package/src/core/preflight-loaders.js +16 -11
  75. package/src/core/preflight.js +44 -25
  76. package/src/core/protocol.js +2 -11
  77. package/src/core/receipt.js +1 -1
  78. package/src/core/report.js +2 -2
  79. package/src/core/repository.js +46 -12
  80. package/src/core/resumability.js +6 -4
  81. package/src/core/route-artifact.js +9 -5
  82. package/src/core/router.js +11 -7
  83. package/src/core/schema-validation.js +1 -0
  84. package/src/core/task-command.js +41 -0
  85. package/src/core/task-context.js +126 -0
  86. package/src/core/task-descriptor.js +81 -0
  87. package/src/core/task-discovery.js +116 -0
  88. package/src/core/task-identity.js +76 -0
  89. package/src/core/task-lock.js +209 -0
  90. package/src/core/task-migration-validation.js +140 -0
  91. package/src/core/task-migration.js +361 -0
  92. package/src/core/task-paths.js +96 -0
  93. package/src/core/task-scope.js +179 -0
  94. package/src/core/templates.js +3 -9
  95. package/src/core/work-state.js +24 -13
@@ -0,0 +1,892 @@
1
+ # ForgeLoop CLI Reference
2
+
3
+ This document provides a complete operational reference for every ForgeLoop CLI command.
4
+
5
+ ```text
6
+ Usage: forgeloop <command> [options]
7
+ ```
8
+
9
+ ## Common Options
10
+
11
+ <!-- BEGIN FORGELOOP GENERATED: cli-common-options -->
12
+
13
+ - `--path <directory>`: target project directory (default: current directory)
14
+ - `--help`: show this help
15
+ - `--version`: show the installed package version
16
+
17
+ Commands that support structured machine-readable output document `--json` in their command-specific option list.
18
+
19
+ <!-- END FORGELOOP GENERATED: cli-common-options -->
20
+
21
+ ---
22
+
23
+ ## CLI Syntax Contract
24
+
25
+ ForgeLoop uses a definition-driven command-line parser:
26
+
27
+ - **Bootstrap Options**: Before the command, only common options (`--path <directory>`, `--help`, `--version`, `-h`, `-v`) are accepted.
28
+ - **Command-Specific Options**: Available after command discovery.
29
+ - **Equals Syntax**: All value-taking long options support both `--option value` and `--option=value`.
30
+ - **String Options**: Reject empty values by default (e.g. `--path=` or `--task=""` are rejected).
31
+ - **Boolean Flags**: Never accept inline values (e.g. `--json=false` is rejected).
32
+ - **Argv Passthrough**: Everything after a command's `--` passthrough marker is preserved exactly and is not parsed as ForgeLoop syntax.
33
+
34
+ ---
35
+
36
+ ## Command Index by Purpose
37
+
38
+ <!-- BEGIN FORGELOOP GENERATED: cli-command-index -->
39
+
40
+ | Category | Commands |
41
+ | --- | --- |
42
+ | **Setup & Maintenance** | [`init`](#init), [`update`](#update), [`task-migrate`](#task-migrate), [`task-unlock`](#task-unlock) |
43
+ | **Inspection & Diagnostics** | [`doctor`](#doctor), [`inspect`](#inspect), [`status`](#status), [`validate-state`](#validate-state), [`validate-protocol`](#validate-protocol) |
44
+ | **Lifecycle & State** | [`activate`](#activate), [`route`](#route), [`preflight`](#preflight), [`advance`](#advance), [`next`](#next), [`complete`](#complete), [`clear-state`](#clear-state), [`task-create`](#task-create), [`task-list`](#task-list), [`task-show`](#task-show), [`task-scope`](#task-scope) |
45
+ | **Cross-Harness Continuity** | [`continuity`](#continuity), [`record-continuity`](#record-continuity), [`reconcile-continuity`](#reconcile-continuity), [`clear-continuity`](#clear-continuity) |
46
+ | **Verification & Completion** | [`prepare-completion`](#prepare-completion), [`run-check`](#run-check), [`record-check`](#record-check), [`record-terminal-result`](#record-terminal-result), [`audit`](#audit), [`report`](#report), [`validate-receipt`](#validate-receipt) |
47
+ | **Policy & Auditing** | [`policy`](#policy), [`bundle`](#bundle) |
48
+
49
+ <!-- END FORGELOOP GENERATED: cli-command-index -->
50
+
51
+ ---
52
+
53
+ ## 1. Setup & Maintenance
54
+
55
+ ### `init`
56
+
57
+ Initializes ForgeLoop in a target repository.
58
+
59
+ - **Purpose**: Installs canonical instruction templates under `.forgeloop/kit/`, creates discovery shims at root, and prepares `.forgeloop/`.
60
+ - **When to use**: Once when onboarding a new repository to ForgeLoop.
61
+ - **Mutation**: Writes `.forgeloop/kit/`, `.forgeloop/forgeloop.gitignore`, `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/project-loop.mdc`, `.github/copilot-instructions.md`.
62
+ - **Options**:
63
+
64
+ <!-- BEGIN FORGELOOP GENERATED: cli:init:options -->
65
+
66
+ - `--path <directory>`: target project directory (default: current directory)
67
+ - `--dry-run`: show planned writes without changing files
68
+
69
+ <!-- END FORGELOOP GENERATED: cli:init:options -->
70
+
71
+ - **Example**:
72
+
73
+ ```bash
74
+ forgeloop init
75
+ ```
76
+
77
+ ### `doctor`
78
+
79
+ Inspects repository health, adapter synchronization, and template integrity.
80
+
81
+ - **Purpose**: Diagnose missing files, unmanaged adapters, profile issues, and broken kit references.
82
+ - **When to use**: After initialization, after git merges, or when troubleshooting.
83
+ - **Mutation**: Read-only (unless `--fix` is passed).
84
+ - **Options**:
85
+
86
+ <!-- BEGIN FORGELOOP GENERATED: cli:doctor:options -->
87
+
88
+ - `--path <directory>`: target project directory (default: current directory)
89
+ - `--json`: emit doctor findings as JSON
90
+ - `--strict`: treat warnings as unhealthy
91
+ - `--fix`: restore missing managed template files
92
+ - `--adopt <path>`: preserve an existing adapter in the manifest (repeatable)
93
+
94
+ <!-- END FORGELOOP GENERATED: cli:doctor:options -->
95
+
96
+ - **Example**:
97
+
98
+ ```bash
99
+ forgeloop doctor --json
100
+ ```
101
+
102
+ ### `update`
103
+
104
+ Updates the managed instruction kit to match the current ForgeLoop package version.
105
+
106
+ - **Purpose**: Safely updates `.forgeloop/kit/` while preserving project profile facts and local modifications.
107
+ - **When to use**: After upgrading `@cassiomc1/forgeloop` package version.
108
+ - **Mutation**: Updates `.forgeloop/kit/` and adapter shims.
109
+ - **Options**:
110
+
111
+ <!-- BEGIN FORGELOOP GENERATED: cli:update:options -->
112
+
113
+ - `--path <directory>`: target project directory (default: current directory)
114
+ - `--dry-run`: show planned writes without changing files
115
+
116
+ <!-- END FORGELOOP GENERATED: cli:update:options -->
117
+
118
+ - **Example**:
119
+
120
+ ```bash
121
+ forgeloop update
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 2. Activation & Planning
127
+
128
+ ### `route`
129
+
130
+ Calculates and persists deterministic engineering guide routing.
131
+
132
+ - **Purpose**: Selects relevant technical guides (e.g. `clean`, `test`, `security`, `design`) based on declared work attributes.
133
+ - **When to use**: During discovery before preflight.
134
+ - **Mutation**: Writes `.forgeloop/routing-result.json`.
135
+ - **Options**:
136
+
137
+ <!-- BEGIN FORGELOOP GENERATED: cli:route:options -->
138
+
139
+ - `--path <directory>`: target project directory (default: current directory)
140
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
141
+ - `--work <type>`: declared work type
142
+ - `--surface <value>`: affected surface (repeatable)
143
+ - `--risk <value>`: task risk (repeatable)
144
+ - `--platform <value>`: affected platform (repeatable)
145
+ - `--behavior-change`: declare behavior change
146
+ - `--executable-change`: declare executable/configuration change
147
+ - `--json`: emit route result as JSON
148
+
149
+ <!-- END FORGELOOP GENERATED: cli:route:options -->
150
+
151
+ - **Example**:
152
+
153
+ ```bash
154
+ forgeloop route --work complete-website --surface ui --risk untrusted-input --json
155
+ ```
156
+
157
+ ### `preflight`
158
+
159
+ Validates pre-implementation readiness and establishes protocol readiness state.
160
+
161
+ - **Purpose**: Verifies that the contract, route, profile facts, and mandatory pre-implementation gates (e.g. `design`) are satisfied and consistent.
162
+ - **When to use**: Before starting implementation.
163
+ - **Mutation**: Persists `.forgeloop/preflight.json` and, when the protocol is ready, may create or synchronize resumable work state and lifecycle events.
164
+ - **Return Status**: `READY` or `BLOCKED`.
165
+ - **Options**:
166
+
167
+ <!-- BEGIN FORGELOOP GENERATED: cli:preflight:options -->
168
+
169
+ - `--path <directory>`: target project directory (default: current directory)
170
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
171
+ - `--strict`: require strict protocol compliance
172
+ - `--json`: emit structured output as JSON
173
+
174
+ <!-- END FORGELOOP GENERATED: cli:preflight:options -->
175
+
176
+ - **Example**:
177
+
178
+ ```bash
179
+ forgeloop preflight --json
180
+ ```
181
+
182
+ ### `activate`
183
+
184
+ Creates a protocol/session activation marker for the current harness session.
185
+
186
+ - **Purpose**: Creates an activation marker containing `sessionId`, `activationMarker`, and `createdAt` for the current harness session. It does not create the canonical lifecycle work state.
187
+ - **When to use**: When starting a session after `preflight` is established.
188
+ - **Mutation**: Writes `.forgeloop/session.json`.
189
+ - **Options**:
190
+
191
+ <!-- BEGIN FORGELOOP GENERATED: cli:activate:options -->
192
+
193
+ - `--path <directory>`: target project directory (default: current directory)
194
+ - `--json`: emit structured output as JSON
195
+
196
+ <!-- END FORGELOOP GENERATED: cli:activate:options -->
197
+
198
+ - **Example**:
199
+
200
+ ```bash
201
+ forgeloop activate --json
202
+ ```
203
+
204
+ ### `advance`
205
+
206
+ Advances the protocol lifecycle phase.
207
+
208
+ - **Purpose**: Transitions between valid protocol phases (`PLANNED`, `EXECUTING`, `VERIFYING`, `REVIEWING`).
209
+ - **When to use**: To declare transitions between workflow stages.
210
+ - **Mutation**: Updates `.forgeloop/work-state.json` and appends transition event to ledger.
211
+ - **Options**:
212
+
213
+ <!-- BEGIN FORGELOOP GENERATED: cli:advance:options -->
214
+
215
+ - `--path <directory>`: target project directory (default: current directory)
216
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
217
+ - `--to <phase>`: destination workflow phase
218
+ - `--json`: emit structured output as JSON
219
+
220
+ <!-- END FORGELOOP GENERATED: cli:advance:options -->
221
+
222
+ - **Example**:
223
+
224
+ ```bash
225
+ forgeloop advance --to EXECUTING
226
+ ```
227
+
228
+ ### `next`
229
+
230
+ Computes the deterministic next action required by the protocol.
231
+
232
+ - **Purpose**: Tells the executing agent or harness exactly what action or command to perform next based on current state, evidence, and continuity.
233
+ - **When to use**: Continuously after each step, and upon starting any session.
234
+ - **Mutation**: Read-only.
235
+ - **Options**:
236
+
237
+ <!-- BEGIN FORGELOOP GENERATED: cli:next:options -->
238
+
239
+ - `--path <directory>`: target project directory (default: current directory)
240
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
241
+ - `--json`: emit structured output as JSON
242
+
243
+ <!-- END FORGELOOP GENERATED: cli:next:options -->
244
+
245
+ - **Example**:
246
+
247
+ ```bash
248
+ forgeloop next --json
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 3. Continuity & Handoff
254
+
255
+ ### `continuity`
256
+
257
+ Reads current operational continuity context.
258
+
259
+ - **Purpose**: Retrieves the active focus, remaining items, known issues, and inspect-first notes recorded by the previous harness.
260
+ - **When to use**: When resuming an existing task.
261
+ - **Mutation**: Read-only.
262
+ - **Options**:
263
+
264
+ <!-- BEGIN FORGELOOP GENERATED: cli:continuity:options -->
265
+
266
+ - `--path <directory>`: target project directory (default: current directory)
267
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
268
+ - `--json`: emit structured output as JSON
269
+
270
+ <!-- END FORGELOOP GENERATED: cli:continuity:options -->
271
+
272
+ - **Example**:
273
+
274
+ ```bash
275
+ forgeloop continuity --json
276
+ ```
277
+
278
+ ### `record-continuity`
279
+
280
+ Records operational handoff context before pausing or switching tools.
281
+
282
+ - **Purpose**: Stores immediate work-in-progress notes to help the next harness continue without confusion.
283
+ - **When to use**: Before ending a session or transferring control.
284
+ - **Mutation**: Writes `.forgeloop/continuity.json`.
285
+ - **Options**:
286
+
287
+ <!-- BEGIN FORGELOOP GENERATED: cli:record-continuity:options -->
288
+
289
+ - `--path <directory>`: target project directory (default: current directory)
290
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
291
+ - `--focus-id <id>`: current implementation focus ID
292
+ - `--focus-summary <text>`: current implementation focus summary
293
+ - `--remaining <id:summary>`: remaining implementation item (repeatable)
294
+ - `--known-issue <id:summary>`: known implementation issue (repeatable)
295
+ - `--changed-area <path>`: changed project area (repeatable)
296
+ - `--inspect-first <path>`: suggested inspection path (repeatable)
297
+ - `--resume-note <text>`: bounded operational resume note
298
+ - `--json`: emit structured output as JSON
299
+
300
+ <!-- END FORGELOOP GENERATED: cli:record-continuity:options -->
301
+
302
+ - **Example**:
303
+
304
+ ```bash
305
+ forgeloop record-continuity \
306
+ --focus-id auth-jwt \
307
+ --focus-summary "Implement JWT refresh token rotation" \
308
+ --remaining "tests:Add token expiration test" \
309
+ --inspect-first src/auth/token.js \
310
+ --resume-note "Access tokens are working; refresh token rotation is in progress."
311
+ ```
312
+
313
+ ### `reconcile-continuity`
314
+
315
+ Reconciles continuity with the active work state and checkout.
316
+
317
+ - **Purpose**: Compares continuity bindings against the canonical work state, contract, phase, repository fingerprint, and checkout state.
318
+ - **When to use**: When starting a session in an active task.
319
+ - **Mutation**: Read-only.
320
+ - **Options**:
321
+
322
+ <!-- BEGIN FORGELOOP GENERATED: cli:reconcile-continuity:options -->
323
+
324
+ - `--path <directory>`: target project directory (default: current directory)
325
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
326
+ - `--json`: emit structured output as JSON
327
+
328
+ <!-- END FORGELOOP GENERATED: cli:reconcile-continuity:options -->
329
+
330
+ - **Example**:
331
+
332
+ ```bash
333
+ forgeloop reconcile-continuity --json
334
+ ```
335
+
336
+ ### `clear-continuity`
337
+
338
+ Clears operational continuity context while preserving canonical work state.
339
+
340
+ - **Purpose**: Removes stale or corrupt continuity handoff data when starting fresh from the last work-state checkpoint.
341
+ - **When to use**: When continuity is unrecoverably stale or no longer relevant.
342
+ - **Mutation**: Removes `.forgeloop/continuity.json`.
343
+ - **Options**:
344
+
345
+ <!-- BEGIN FORGELOOP GENERATED: cli:clear-continuity:options -->
346
+
347
+ - `--path <directory>`: target project directory (default: current directory)
348
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
349
+ - `--json`: emit structured output as JSON
350
+
351
+ <!-- END FORGELOOP GENERATED: cli:clear-continuity:options -->
352
+
353
+ - **Example**:
354
+
355
+ ```bash
356
+ forgeloop clear-continuity
357
+ ```
358
+
359
+ ---
360
+
361
+ ## 4. Verification
362
+
363
+ ### `run-check`
364
+
365
+ Executes a verification command with ForgeLoop-attested provenance.
366
+
367
+ - **Purpose**: Runs an exact command, records the execution artifact in `.forgeloop/executions/`, and binds the resulting observed check evidence to that execution through `executionRef`.
368
+ - **When to use**: During `VERIFYING` phase to execute test suites, linters, or validators.
369
+ - **Mutation**: Writes `.forgeloop/executions/exec-*.json`, updates `.forgeloop/execution-receipt.json`, appends to ledger.
370
+ - **Options**:
371
+
372
+ <!-- BEGIN FORGELOOP GENERATED: cli:run-check:options -->
373
+
374
+ - `--path <directory>`: target project directory (default: current directory)
375
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
376
+ - `--id <id>`: stable check identifier
377
+ - `--requirement <id>`: completion requirement covered by the check
378
+ - `--details <json>`: additional structured check details
379
+ - `-- <argv...>`: exact command argv to classify, execute, and attest
380
+ - `--json`: emit structured output as JSON
381
+
382
+ <!-- END FORGELOOP GENERATED: cli:run-check:options -->
383
+
384
+ - **Example**:
385
+
386
+ ```bash
387
+ forgeloop run-check --id unit-tests --requirement "All unit tests pass" -- npm test
388
+ ```
389
+
390
+ ### `record-check`
391
+
392
+ Records an observed or manual verification check result without executing commands.
393
+
394
+ - **Purpose**: Records manual review evidence or external observations.
395
+ - **When to use**: For manual reviews, accessibility inspections, or external validations.
396
+ - **Mutation**: Updates `.forgeloop/execution-receipt.json` and appends to ledger.
397
+ - **Options**:
398
+
399
+ <!-- BEGIN FORGELOOP GENERATED: cli:record-check:options -->
400
+
401
+ - `--path <directory>`: target project directory (default: current directory)
402
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
403
+ - `--id <id>`: stable check identifier
404
+ - `--requirement <id>`: completion requirement covered by the check
405
+ - `--kind <kind>`: check kind (default: command; use manual-review for manual evidence)
406
+ - `--status <status>`: passed, failed, blocked, or not-run
407
+ - `--evidence-kind <kind>`: OBSERVED, INFERRED, NOT_VERIFIED, or BLOCKED
408
+ - `--command <text>`: recorded only as metadata; it is never executed
409
+ - `--result <text>`: observed result supplied by the actor
410
+ - `--exit-code <number>`: observed process exit code
411
+ - `--execution-ref <id>`: ForgeLoop execution artifact reference
412
+ - `--provenance <value>`: FORGELOOP_EXECUTED, ACTOR_REPORTED, or MANUAL_OBSERVATION
413
+ - `--details <json>`: additional structured check details
414
+ - `--json`: emit structured output as JSON
415
+
416
+ <!-- END FORGELOOP GENERATED: cli:record-check:options -->
417
+
418
+ - **Example**:
419
+
420
+ ```bash
421
+ forgeloop record-check \
422
+ --id manual-a11y-review \
423
+ --requirement "WCAG AA contrast compliant" \
424
+ --status passed \
425
+ --kind manual-review \
426
+ --evidence-kind OBSERVED \
427
+ --result "Verified contrast ratios exceed 4.5:1 across all color schemes"
428
+ ```
429
+
430
+ ### `validate-state`
431
+
432
+ Validates `.forgeloop/work-state.json` structure, hash chain, and repository binding.
433
+
434
+ - **Purpose**: Integrity check for work state.
435
+ - **Mutation**: Read-only.
436
+ - **Options**:
437
+
438
+ <!-- BEGIN FORGELOOP GENERATED: cli:validate-state:options -->
439
+
440
+ - `--path <directory>`: target project directory (default: current directory)
441
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
442
+ - `--json`: emit structured output as JSON
443
+
444
+ <!-- END FORGELOOP GENERATED: cli:validate-state:options -->
445
+
446
+ - **Example**:
447
+
448
+ ```bash
449
+ forgeloop validate-state --json
450
+ ```
451
+
452
+ ### `validate-receipt`
453
+
454
+ Validates `.forgeloop/execution-receipt.json` schema and check references.
455
+
456
+ - **Purpose**: Integrity check for completion receipt.
457
+ - **Mutation**: Read-only.
458
+ - **Options**:
459
+
460
+ <!-- BEGIN FORGELOOP GENERATED: cli:validate-receipt:options -->
461
+
462
+ - `--path <directory>`: target project directory (default: current directory)
463
+ - `--file <path>`: receipt file relative to target
464
+ - `--json`: emit structured output as JSON
465
+
466
+ <!-- END FORGELOOP GENERATED: cli:validate-receipt:options -->
467
+
468
+ - **Example**:
469
+
470
+ ```bash
471
+ forgeloop validate-receipt --json
472
+ ```
473
+
474
+ ### `validate-protocol`
475
+
476
+ Performs comprehensive protocol validation across all active artifacts.
477
+
478
+ - **Purpose**: Validates contract, route, state, receipt, executions, and event ledger freshness and consistency.
479
+ - **Mutation**: Read-only.
480
+ - **Options**:
481
+
482
+ <!-- BEGIN FORGELOOP GENERATED: cli:validate-protocol:options -->
483
+
484
+ - `--path <directory>`: target project directory (default: current directory)
485
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
486
+ - `--contract-file <path>`: current JSON contract used for freshness comparison
487
+ - `--route-file <path>`: routing-result JSON relative to target
488
+ - `--state-file <path>`: work-state JSON relative to target
489
+ - `--receipt-file <path>`: execution-receipt JSON relative to target
490
+ - `--continuity-file <path>`: optional execution-continuity JSON relative to target
491
+ - `--task-brief-file <path>`: task brief JSON file (repeatable)
492
+ - `--delegated-result-file <path>`: delegated result JSON file (repeatable)
493
+ - `--json`: emit structured output as JSON
494
+
495
+ <!-- END FORGELOOP GENERATED: cli:validate-protocol:options -->
496
+
497
+ - **Example**:
498
+
499
+ ```bash
500
+ forgeloop validate-protocol --json
501
+ ```
502
+
503
+ ---
504
+
505
+ ## 5. Completion & Reporting
506
+
507
+ ### `prepare-completion`
508
+
509
+ Initializes or refreshes `.forgeloop/execution-receipt.json`.
510
+
511
+ - **Purpose**: Maps contract requirements to evidence coverage slots.
512
+ - **When to use**: Upon entering the `VERIFYING` phase before recording checks.
513
+ - **Mutation**: Writes `.forgeloop/execution-receipt.json`.
514
+ - **Options**:
515
+
516
+ <!-- BEGIN FORGELOOP GENERATED: cli:prepare-completion:options -->
517
+
518
+ - `--path <directory>`: target project directory (default: current directory)
519
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
520
+ - `--json`: emit structured output as JSON
521
+
522
+ <!-- END FORGELOOP GENERATED: cli:prepare-completion:options -->
523
+
524
+ - **Example**:
525
+
526
+ ```bash
527
+ forgeloop prepare-completion --json
528
+ ```
529
+
530
+ ### `record-terminal-result`
531
+
532
+ Records external publication or production-readiness observations.
533
+
534
+ - **Purpose**: Records evidence for terminal requirements (e.g. git push, npm publish, staging deploy).
535
+ - **When to use**: When the contract contains explicit publication or production-readiness requirements.
536
+ - **Mutation**: Updates work state and receipt with terminal status.
537
+ - **Options**:
538
+
539
+ <!-- BEGIN FORGELOOP GENERATED: cli:record-terminal-result:options -->
540
+
541
+ - `--path <directory>`: target project directory (default: current directory)
542
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
543
+ - `--requirement <id>`: terminal requirement covered by the result
544
+ - `--type <type>`: PUBLICATION or PRODUCTION_READINESS
545
+ - `--status <status>`: observed terminal status
546
+ - `--source <text>`: external action source (e.g. npm publish, git push)
547
+ - `--result <text>`: observed external result description
548
+ - `--details <json>`: additional structured result details
549
+ - `--json`: emit structured output as JSON
550
+
551
+ <!-- END FORGELOOP GENERATED: cli:record-terminal-result:options -->
552
+
553
+ - **Example**:
554
+
555
+ ```bash
556
+ forgeloop record-terminal-result \
557
+ --requirement release-publish \
558
+ --type PUBLICATION \
559
+ --status passed \
560
+ --source "npm publish" \
561
+ --result "v1.1.0 published to registry"
562
+ ```
563
+
564
+ ### `audit`
565
+
566
+ Performs a read-only dry-run evaluation of completion readiness.
567
+
568
+ - **Purpose**: Checks if all requirements are covered, ledger is valid, and fingerprints are fresh without changing lifecycle phase.
569
+ - **When to use**: In `REVIEWING` phase before running `complete`.
570
+ - **Mutation**: Read-only.
571
+ - **Options**:
572
+
573
+ <!-- BEGIN FORGELOOP GENERATED: cli:audit:options -->
574
+
575
+ - `--path <directory>`: target project directory (default: current directory)
576
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
577
+ - `--strict`: require strict protocol compliance
578
+ - `--json`: emit structured output as JSON
579
+
580
+ <!-- END FORGELOOP GENERATED: cli:audit:options -->
581
+
582
+ - **Example**:
583
+
584
+ ```bash
585
+ forgeloop audit --json
586
+ ```
587
+
588
+ ### `complete`
589
+
590
+ Validates protocol completion and transitions the task to `COMPLETE`.
591
+
592
+ - **Purpose**: Authoritative protocol validation of the entire task lifecycle.
593
+ - **When to use**: In `REVIEWING` phase when all checks have passed.
594
+ - **Mutation**: Updates `.forgeloop/work-state.json` to `COMPLETE` and records completion event.
595
+ - **Return Status**: `VALID`, `INCOMPLETE`, `STALE`, `INCONSISTENT`, or `INVALID`.
596
+ - **Options**:
597
+
598
+ <!-- BEGIN FORGELOOP GENERATED: cli:complete:options -->
599
+
600
+ - `--path <directory>`: target project directory (default: current directory)
601
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
602
+ - `--strict`: require strict protocol compliance
603
+ - `--json`: emit structured output as JSON
604
+
605
+ <!-- END FORGELOOP GENERATED: cli:complete:options -->
606
+
607
+ - **Example**:
608
+
609
+ ```bash
610
+ forgeloop complete --json
611
+ ```
612
+
613
+ ### `report`
614
+
615
+ Emits an independent multi-dimensional status report.
616
+
617
+ - **Purpose**: Reports task completion, publication status, and production readiness as independent dimensions.
618
+ - **Mutation**: Read-only.
619
+ - **Options**:
620
+
621
+ <!-- BEGIN FORGELOOP GENERATED: cli:report:options -->
622
+
623
+ - `--path <directory>`: target project directory (default: current directory)
624
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
625
+ - `--strict`: require strict protocol compliance
626
+ - `--json`: emit structured output as JSON
627
+
628
+ <!-- END FORGELOOP GENERATED: cli:report:options -->
629
+
630
+ - **Example**:
631
+
632
+ ```bash
633
+ forgeloop report --json
634
+ ```
635
+
636
+ ### `bundle`
637
+
638
+ Exports a portable, self-contained task bundle.
639
+
640
+ - **Purpose**: Bundles contract, route, state, receipt, executions, and ledger for archiving or cross-environment migration.
641
+ - **Mutation**: Writes portable bundle under `.forgeloop/tasks/<taskId>`.
642
+ - **Options**:
643
+
644
+ <!-- BEGIN FORGELOOP GENERATED: cli:bundle:options -->
645
+
646
+ - `--path <directory>`: target project directory (default: current directory)
647
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
648
+ - `--json`: emit structured output as JSON
649
+
650
+ <!-- END FORGELOOP GENERATED: cli:bundle:options -->
651
+
652
+ - **Example**:
653
+
654
+ ```bash
655
+ forgeloop bundle --task task-001 --json
656
+ ```
657
+
658
+ ---
659
+
660
+ ## 6. Inspection & Recovery
661
+
662
+ ### `status`
663
+
664
+ Displays human-readable or structured summary of current task state.
665
+
666
+ - **Purpose**: Quick overview of task ID, phase, cycle, active guides, and completion status.
667
+ - **Mutation**: Read-only.
668
+ - **Options**:
669
+
670
+ <!-- BEGIN FORGELOOP GENERATED: cli:status:options -->
671
+
672
+ - `--path <directory>`: target project directory (default: current directory)
673
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
674
+ - `--contract-file <path>`: current JSON contract used for freshness comparison
675
+ - `--json`: emit structured output as JSON
676
+
677
+ <!-- END FORGELOOP GENERATED: cli:status:options -->
678
+
679
+ - **Example**:
680
+
681
+ ```bash
682
+ forgeloop status --json
683
+ ```
684
+
685
+ ### `inspect`
686
+
687
+ Inspects checkout changes and compares them against contract deliverables.
688
+
689
+ - **Purpose**: Shows modified files, untracked files, and deliverable coverage.
690
+ - **Mutation**: Read-only.
691
+ - **Options**:
692
+
693
+ <!-- BEGIN FORGELOOP GENERATED: cli:inspect:options -->
694
+
695
+ - `--path <directory>`: target project directory (default: current directory)
696
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
697
+ - `--contract-file <path>`: current JSON contract used for freshness comparison
698
+ - `--json`: emit structured output as JSON
699
+
700
+ <!-- END FORGELOOP GENERATED: cli:inspect:options -->
701
+
702
+ - **Example**:
703
+
704
+ ```bash
705
+ forgeloop inspect --json
706
+ ```
707
+
708
+ ### `policy`
709
+
710
+ Evaluates compliance against a named policy pack.
711
+
712
+ - **Purpose**: Checks repository conformity against organizational or protocol policy packs.
713
+ - **Mutation**: Read-only.
714
+ - **Options**:
715
+
716
+ <!-- BEGIN FORGELOOP GENERATED: cli:policy:options -->
717
+
718
+ - `--path <directory>`: target project directory (default: current directory)
719
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
720
+ - `<name>`: policy pack name
721
+ - `--json`: emit structured output as JSON
722
+
723
+ <!-- END FORGELOOP GENERATED: cli:policy:options -->
724
+
725
+ - **Example**:
726
+
727
+ ```bash
728
+ forgeloop policy default --json
729
+ ```
730
+
731
+ ### `clear-state`
732
+
733
+ Clears canonical work-state checkpoint for the current task.
734
+
735
+ - **Purpose**: Emergency reset of local work-state checkpoint.
736
+ - **When to use**: Only when abandoning a task or resetting state after an unrecoverable corruption.
737
+ - **Mutation**: Removes `.forgeloop/work-state.json` only. Sibling ForgeLoop artifacts (such as contracts, routes, gates, and ledger history) are preserved.
738
+ - **Safety Note**: This is not a full `.forgeloop/` reset command.
739
+ - **Options**:
740
+
741
+ <!-- BEGIN FORGELOOP GENERATED: cli:clear-state:options -->
742
+
743
+ - `--path <directory>`: target project directory (default: current directory)
744
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
745
+ - `--json`: emit structured output as JSON
746
+
747
+ <!-- END FORGELOOP GENERATED: cli:clear-state:options -->
748
+
749
+ - **Example**:
750
+
751
+ ```bash
752
+ forgeloop clear-state
753
+ ```
754
+
755
+ ---
756
+
757
+ ## 7. Multi-Task Management
758
+
759
+ ### `task-create`
760
+
761
+ Initializes a new isolated task namespace with write claims and contract.
762
+
763
+ - **Purpose**: Creates `.forgeloop/task-state/<taskKey>/task.json` descriptor.
764
+ - **Mutation**: Writes task descriptor.
765
+ - **Options**:
766
+
767
+ <!-- BEGIN FORGELOOP GENERATED: cli:task-create:options -->
768
+
769
+ - `--path <directory>`: target project directory (default: current directory)
770
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
771
+ - `--claim <path>`: scoped file path or directory prefix claimed for mutation (repeatable)
772
+ - `--contract-file <path>`: path to initial contract file
773
+ - `--json`: emit structured output as JSON
774
+
775
+ <!-- END FORGELOOP GENERATED: cli:task-create:options -->
776
+
777
+ - **Example**:
778
+
779
+ ```bash
780
+ forgeloop task-create --id task-001 --claim src/auth --prompt "Add auth module" --json
781
+ ```
782
+
783
+ ### `task-list`
784
+
785
+ Lists all tasks discovered in `.forgeloop/task-state/`.
786
+
787
+ - **Purpose**: Discovers tasks, their keys, phases, write claims, and lock status.
788
+ - **Mutation**: Read-only.
789
+ - **Options**:
790
+
791
+ <!-- BEGIN FORGELOOP GENERATED: cli:task-list:options -->
792
+
793
+ - `--path <directory>`: target project directory (default: current directory)
794
+ - `--json`: emit structured output as JSON
795
+
796
+ <!-- END FORGELOOP GENERATED: cli:task-list:options -->
797
+
798
+ - **Example**:
799
+
800
+ ```bash
801
+ forgeloop task-list --json
802
+ ```
803
+
804
+ ### `task-show`
805
+
806
+ Displays details of a specific task by ID or storage key.
807
+
808
+ - **Purpose**: Inspects task descriptor, write claims, active lock, and lifecycle state.
809
+ - **Mutation**: Read-only.
810
+ - **Options**:
811
+
812
+ <!-- BEGIN FORGELOOP GENERATED: cli:task-show:options -->
813
+
814
+ - `--path <directory>`: target project directory (default: current directory)
815
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
816
+ - `--json`: emit structured output as JSON
817
+
818
+ <!-- END FORGELOOP GENERATED: cli:task-show:options -->
819
+
820
+ - **Example**:
821
+
822
+ ```bash
823
+ forgeloop task-show --task task-001 --json
824
+ ```
825
+
826
+ ### `task-scope`
827
+
828
+ Updates or inspects write claims for a task.
829
+
830
+ - **Purpose**: Modifies write claims before execution starts.
831
+ - **Mutation**: Updates `task.json`.
832
+ - **Options**:
833
+
834
+ <!-- BEGIN FORGELOOP GENERATED: cli:task-scope:options -->
835
+
836
+ - `--path <directory>`: target project directory (default: current directory)
837
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
838
+ - `--claim <path>`: scoped file path or directory prefix claimed for mutation (repeatable)
839
+ - `--json`: emit structured output as JSON
840
+
841
+ <!-- END FORGELOOP GENERATED: cli:task-scope:options -->
842
+
843
+ - **Example**:
844
+
845
+ ```bash
846
+ forgeloop task-scope --task task-001 --claim src/auth tests/auth --json
847
+ ```
848
+
849
+ ### `task-migrate`
850
+
851
+ Migrates a legacy 1.0 single-task `.forgeloop/` layout into a namespaced task directory.
852
+
853
+ - **Purpose**: Converts root `.forgeloop/` artifacts into `.forgeloop/task-state/<taskKey>/`.
854
+ - **Mutation**: Moves task artifacts into task state subfolder.
855
+ - **Options**:
856
+
857
+ <!-- BEGIN FORGELOOP GENERATED: cli:task-migrate:options -->
858
+
859
+ - `--path <directory>`: target project directory (default: current directory)
860
+ - `--dry-run`: show planned migration actions without moving files
861
+ - `--json`: emit structured output as JSON
862
+
863
+ <!-- END FORGELOOP GENERATED: cli:task-migrate:options -->
864
+
865
+ - **Example**:
866
+
867
+ ```bash
868
+ forgeloop task-migrate --json
869
+ ```
870
+
871
+ ### `task-unlock`
872
+
873
+ Forces the release of a stale task lock.
874
+
875
+ - **Purpose**: Removes `.lock` file from the task directory when process crashed.
876
+ - **Mutation**: Deletes task lock file.
877
+ - **Options**:
878
+
879
+ <!-- BEGIN FORGELOOP GENERATED: cli:task-unlock:options -->
880
+
881
+ - `--path <directory>`: target project directory (default: current directory)
882
+ - `--task <id>`: task ID to operate on (when omitted, resolved from context or single active task)
883
+ - `--force`: force release of an orphaned task lock
884
+ - `--json`: emit structured output as JSON
885
+
886
+ <!-- END FORGELOOP GENERATED: cli:task-unlock:options -->
887
+
888
+ - **Example**:
889
+
890
+ ```bash
891
+ forgeloop task-unlock --task task-001 --force --json
892
+ ```