@rpamis/comet 0.3.7 → 0.3.9

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 (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +557 -539
  3. package/assets/manifest.json +41 -34
  4. package/assets/skills/comet/SKILL.md +282 -329
  5. package/assets/skills/comet/reference/auto-transition.md +27 -0
  6. package/assets/skills/comet/reference/comet-yaml-fields.md +68 -0
  7. package/assets/skills/comet/reference/context-recovery.md +35 -0
  8. package/assets/skills/comet/reference/debug-gate.md +17 -0
  9. package/assets/skills/comet/reference/decision-point.md +20 -0
  10. package/assets/skills/comet/reference/dirty-worktree.md +59 -59
  11. package/assets/skills/comet/reference/file-structure.md +28 -0
  12. package/assets/skills/comet/reference/subagent-dispatch.md +113 -0
  13. package/assets/skills/comet/rules/comet-phase-guard.en.md +123 -0
  14. package/assets/skills/comet/rules/comet-phase-guard.md +125 -90
  15. package/assets/skills/comet/scripts/comet-guard.sh +27 -1
  16. package/assets/skills/comet/scripts/comet-hook-guard.sh +121 -45
  17. package/assets/skills/comet/scripts/comet-state.sh +162 -7
  18. package/assets/skills/comet/scripts/comet-yaml-validate.sh +3 -1
  19. package/assets/skills/comet-archive/SKILL.md +100 -106
  20. package/assets/skills/comet-build/SKILL.md +304 -316
  21. package/assets/skills/comet-design/SKILL.md +263 -272
  22. package/assets/skills/comet-hotfix/SKILL.md +204 -211
  23. package/assets/skills/comet-open/SKILL.md +220 -186
  24. package/assets/skills/comet-tweak/SKILL.md +180 -179
  25. package/assets/skills/comet-verify/SKILL.md +234 -240
  26. package/assets/skills-zh/comet/SKILL.md +269 -332
  27. package/assets/skills-zh/comet/reference/auto-transition.md +27 -0
  28. package/assets/skills-zh/comet/reference/comet-yaml-fields.md +71 -0
  29. package/assets/skills-zh/comet/reference/context-recovery.md +35 -0
  30. package/assets/skills-zh/comet/reference/debug-gate.md +17 -0
  31. package/assets/skills-zh/comet/reference/decision-point.md +20 -0
  32. package/assets/skills-zh/comet/reference/dirty-worktree.md +59 -59
  33. package/assets/skills-zh/comet/reference/file-structure.md +28 -0
  34. package/assets/skills-zh/comet/reference/subagent-dispatch.md +120 -0
  35. package/assets/skills-zh/comet-archive/SKILL.md +100 -106
  36. package/assets/skills-zh/comet-build/SKILL.md +317 -316
  37. package/assets/skills-zh/comet-design/SKILL.md +264 -273
  38. package/assets/skills-zh/comet-hotfix/SKILL.md +200 -207
  39. package/assets/skills-zh/comet-open/SKILL.md +220 -186
  40. package/assets/skills-zh/comet-tweak/SKILL.md +176 -175
  41. package/assets/skills-zh/comet-verify/SKILL.md +232 -238
  42. package/bin/comet.js +3 -3
  43. package/dist/cli/index.js +21 -1
  44. package/dist/cli/index.js.map +1 -1
  45. package/dist/commands/doctor.d.ts.map +1 -1
  46. package/dist/commands/doctor.js +5 -1
  47. package/dist/commands/doctor.js.map +1 -1
  48. package/dist/commands/i18n.d.ts +4 -0
  49. package/dist/commands/i18n.d.ts.map +1 -0
  50. package/dist/commands/i18n.js +154 -0
  51. package/dist/commands/i18n.js.map +1 -0
  52. package/dist/commands/init.d.ts +3 -0
  53. package/dist/commands/init.d.ts.map +1 -1
  54. package/dist/commands/init.js +127 -75
  55. package/dist/commands/init.js.map +1 -1
  56. package/dist/commands/uninstall.d.ts +9 -0
  57. package/dist/commands/uninstall.d.ts.map +1 -0
  58. package/dist/commands/uninstall.js +132 -0
  59. package/dist/commands/uninstall.js.map +1 -0
  60. package/dist/commands/update.d.ts +3 -2
  61. package/dist/commands/update.d.ts.map +1 -1
  62. package/dist/commands/update.js +105 -68
  63. package/dist/commands/update.js.map +1 -1
  64. package/dist/core/codegraph.d.ts +4 -7
  65. package/dist/core/codegraph.d.ts.map +1 -1
  66. package/dist/core/codegraph.js +63 -41
  67. package/dist/core/codegraph.js.map +1 -1
  68. package/dist/core/detect.d.ts +13 -1
  69. package/dist/core/detect.d.ts.map +1 -1
  70. package/dist/core/detect.js +68 -12
  71. package/dist/core/detect.js.map +1 -1
  72. package/dist/core/openspec.d.ts +2 -2
  73. package/dist/core/openspec.d.ts.map +1 -1
  74. package/dist/core/openspec.js +51 -22
  75. package/dist/core/openspec.js.map +1 -1
  76. package/dist/core/platforms.d.ts.map +1 -1
  77. package/dist/core/platforms.js +14 -1
  78. package/dist/core/platforms.js.map +1 -1
  79. package/dist/core/skills.d.ts +3 -1
  80. package/dist/core/skills.d.ts.map +1 -1
  81. package/dist/core/skills.js +151 -66
  82. package/dist/core/skills.js.map +1 -1
  83. package/dist/core/superpowers.d.ts +1 -1
  84. package/dist/core/superpowers.d.ts.map +1 -1
  85. package/dist/core/superpowers.js +5 -1
  86. package/dist/core/superpowers.js.map +1 -1
  87. package/dist/core/uninstall.d.ts +28 -0
  88. package/dist/core/uninstall.d.ts.map +1 -0
  89. package/dist/core/uninstall.js +421 -0
  90. package/dist/core/uninstall.js.map +1 -0
  91. package/dist/core/version.d.ts +31 -0
  92. package/dist/core/version.d.ts.map +1 -0
  93. package/dist/core/version.js +111 -0
  94. package/dist/core/version.js.map +1 -0
  95. package/dist/utils/file-system.d.ts +23 -0
  96. package/dist/utils/file-system.d.ts.map +1 -1
  97. package/dist/utils/file-system.js +100 -5
  98. package/dist/utils/file-system.js.map +1 -1
  99. package/package.json +69 -64
  100. package/scripts/postinstall.js +44 -44
@@ -10,6 +10,7 @@
10
10
  # check <change-name> <phase> — Verify entry requirements for a phase
11
11
  # check <change-name> <phase> --recover — Output structured recovery context for compaction resume
12
12
  # scale <change-name> — Assess and set verification mode based on metrics
13
+ # task-checkoff <file> <task-text> — Verify one unique task is checked
13
14
  #
14
15
  # Workflows: full, hotfix, tweak
15
16
  # Phases for check: open, design, build, verify, archive
@@ -234,6 +235,33 @@ project_auto_transition_default() {
234
235
  esac
235
236
  }
236
237
 
238
+ project_review_mode_default() {
239
+ local value="null"
240
+ local source="default"
241
+ if [ -n "${COMET_REVIEW_MODE:-}" ]; then
242
+ value="$COMET_REVIEW_MODE"
243
+ source="COMET_REVIEW_MODE"
244
+ elif [ -f ".comet/config.yaml" ]; then
245
+ local raw
246
+ raw=$(yaml_field "review_mode" ".comet/config.yaml" 2>/dev/null || true)
247
+ if [ -n "$raw" ]; then
248
+ value="$raw"
249
+ source=".comet/config.yaml"
250
+ fi
251
+ fi
252
+
253
+ case "$value" in
254
+ null|off|standard|thorough)
255
+ printf '%s\n' "$value"
256
+ ;;
257
+ *)
258
+ red "ERROR: Invalid review_mode from ${source}: '$value'" >&2
259
+ red "Valid values: off, standard, thorough" >&2
260
+ exit 1
261
+ ;;
262
+ esac
263
+ }
264
+
237
265
  # --- Subcommands ---
238
266
 
239
267
  cmd_init() {
@@ -257,7 +285,7 @@ cmd_init() {
257
285
  mkdir -p "$change_dir"
258
286
 
259
287
  # Set workflow-appropriate defaults
260
- local phase build_mode isolation verify_mode context_compression auto_transition
288
+ local phase build_mode isolation verify_mode context_compression auto_transition review_mode
261
289
  phase="open"
262
290
  context_compression=$(project_context_compression)
263
291
  auto_transition="$(project_auto_transition_default)"
@@ -266,12 +294,14 @@ cmd_init() {
266
294
  full)
267
295
  build_mode="null"
268
296
  tdd_mode="null"
297
+ review_mode="$(project_review_mode_default)"
269
298
  isolation="null"
270
299
  verify_mode="null"
271
300
  ;;
272
301
  hotfix|tweak)
273
302
  build_mode="direct"
274
303
  tdd_mode="direct"
304
+ review_mode="off"
275
305
  isolation="branch"
276
306
  verify_mode="light"
277
307
  ;;
@@ -292,6 +322,7 @@ build_mode: $build_mode
292
322
  build_pause: null
293
323
  subagent_dispatch: null
294
324
  tdd_mode: $tdd_mode
325
+ review_mode: $review_mode
295
326
  isolation: $isolation
296
327
  verify_mode: $verify_mode
297
328
  auto_transition: $auto_transition
@@ -352,16 +383,25 @@ cmd_set() {
352
383
  # Validate field name
353
384
  case "$field" in
354
385
  phase)
355
- yellow "WARNING: Setting 'phase' directly bypasses state machine constraints." >&2
356
- yellow " Consider using: comet-state.sh transition <change-name> <event>" >&2
386
+ # Direct phase writes bypass state-machine evidence checks (open artifacts,
387
+ # design_doc, build decisions, verification evidence). Block them unless the
388
+ # call originates from cmd_transition (dynamic-scope flag) or the operator
389
+ # explicitly opts into the repair escape hatch.
390
+ if [ "${_COMET_IN_TRANSITION:-}" != "1" ] && [ "${COMET_FORCE_PHASE:-}" != "1" ]; then
391
+ red "ERROR: Setting 'phase' directly is not allowed; it bypasses state machine evidence checks." >&2
392
+ red " Use: comet-state.sh transition <change-name> <event>" >&2
393
+ red " Repair-only escape hatch: COMET_FORCE_PHASE=1 comet-state.sh set <change-name> phase <value>" >&2
394
+ exit 1
395
+ fi
396
+ validate_enum "$value" "open" "design" "build" "verify" "archive"
357
397
  ;;
358
- workflow|context_compression|build_mode|build_pause|subagent_dispatch|tdd_mode|isolation|verify_mode|auto_transition|verify_result|verification_report|branch_status|archived|design_doc|plan|verified_at|created_at|direct_override|build_command|verify_command|handoff_context|handoff_hash|base_ref)
398
+ workflow|context_compression|build_mode|build_pause|subagent_dispatch|tdd_mode|review_mode|isolation|verify_mode|auto_transition|verify_result|verification_report|branch_status|archived|design_doc|plan|verified_at|created_at|direct_override|build_command|verify_command|handoff_context|handoff_hash|base_ref)
359
399
  # Valid field
360
400
  ;;
361
401
  *)
362
402
  red "ERROR: Unknown field: '$field'" >&2
363
403
  red "Valid fields:" >&2
364
- red " workflow, phase, context_compression, design_doc, plan, build_mode, build_pause, subagent_dispatch, tdd_mode, isolation," >&2
404
+ red " workflow, phase, context_compression, design_doc, plan, build_mode, build_pause, subagent_dispatch, tdd_mode, review_mode, isolation," >&2
365
405
  red " verify_mode, auto_transition, verify_result, verification_report, branch_status," >&2
366
406
  red " verified_at, created_at, archived, base_ref, direct_override," >&2
367
407
  red " build_command, verify_command, handoff_context, handoff_hash" >&2
@@ -392,6 +432,9 @@ cmd_set() {
392
432
  tdd_mode)
393
433
  validate_enum "$value" "tdd" "direct"
394
434
  ;;
435
+ review_mode)
436
+ validate_enum "$value" "off" "standard" "thorough"
437
+ ;;
395
438
  isolation)
396
439
  validate_enum "$value" "branch" "worktree"
397
440
  ;;
@@ -443,6 +486,33 @@ require_phase() {
443
486
  fi
444
487
  }
445
488
 
489
+ require_open_artifacts() {
490
+ local change_name="$1"
491
+ local change_dir workflow f
492
+ change_dir=$(change_dir_for "$change_name")
493
+ workflow=$(cmd_get "$change_name" "workflow")
494
+ for f in proposal.md tasks.md; do
495
+ if [ ! -s "$change_dir/$f" ]; then
496
+ red "ERROR: Cannot transition '$change_name': $f must exist and be non-empty before leaving open" >&2
497
+ exit 1
498
+ fi
499
+ done
500
+ if [ "$workflow" = "full" ] && [ ! -s "$change_dir/design.md" ]; then
501
+ red "ERROR: Cannot transition '$change_name': design.md must exist and be non-empty before leaving open" >&2
502
+ exit 1
503
+ fi
504
+ }
505
+
506
+ require_design_evidence() {
507
+ local change_name="$1"
508
+ local design_doc
509
+ design_doc=$(cmd_get "$change_name" "design_doc")
510
+ if [ -z "$design_doc" ] || [ "$design_doc" = "null" ] || [ ! -s "$design_doc" ]; then
511
+ red "ERROR: Cannot transition '$change_name': design_doc must point to an existing Design Doc before leaving design" >&2
512
+ exit 1
513
+ fi
514
+ }
515
+
446
516
  require_verification_evidence() {
447
517
  local change_name="$1"
448
518
  local report branch_status
@@ -462,13 +532,14 @@ require_verification_evidence() {
462
532
 
463
533
  require_build_decisions() {
464
534
  local change_name="$1"
465
- local workflow build_mode isolation direct_override subagent_dispatch tdd_mode
535
+ local workflow build_mode isolation direct_override subagent_dispatch tdd_mode review_mode
466
536
  workflow=$(cmd_get "$change_name" "workflow")
467
537
  build_mode=$(cmd_get "$change_name" "build_mode")
468
538
  isolation=$(cmd_get "$change_name" "isolation")
469
539
  direct_override=$(cmd_get "$change_name" "direct_override" 2>/dev/null || true)
470
540
  subagent_dispatch=$(cmd_get "$change_name" "subagent_dispatch" 2>/dev/null || true)
471
541
  tdd_mode=$(cmd_get "$change_name" "tdd_mode" 2>/dev/null || true)
542
+ review_mode=$(cmd_get "$change_name" "review_mode" 2>/dev/null || true)
472
543
 
473
544
  case "$isolation" in
474
545
  branch|worktree) ;;
@@ -500,11 +571,24 @@ require_build_decisions() {
500
571
  red "ERROR: Cannot transition '$change_name': tdd_mode must be selected before leaving build (full workflow)" >&2
501
572
  exit 1
502
573
  fi
574
+
575
+ if [ "$workflow" = "full" ]; then
576
+ case "$review_mode" in
577
+ off|standard|thorough) ;;
578
+ *)
579
+ red "ERROR: Cannot transition '$change_name': review_mode must be selected before leaving build (full workflow); review_mode must be off, standard, or thorough, got '${review_mode:-null}'" >&2
580
+ exit 1
581
+ ;;
582
+ esac
583
+ fi
503
584
  }
504
585
 
505
586
  cmd_transition() {
506
587
  local change_name="$1"
507
588
  local event="$2"
589
+ # Dynamic-scope flag: authorizes the internal cmd_set phase writes below while
590
+ # still blocking direct `set <name> phase` from the CLI.
591
+ local _COMET_IN_TRANSITION=1
508
592
 
509
593
  validate_change_name "$change_name"
510
594
  validate_enum "$event" "open-complete" "design-complete" "build-complete" "verify-pass" "verify-fail" "archive-reopen" "archived"
@@ -512,6 +596,7 @@ cmd_transition() {
512
596
  case "$event" in
513
597
  open-complete)
514
598
  require_phase "$change_name" "open"
599
+ require_open_artifacts "$change_name"
515
600
  local workflow
516
601
  workflow=$(cmd_get "$change_name" "workflow")
517
602
  if [ "$workflow" = "full" ]; then
@@ -522,6 +607,7 @@ cmd_transition() {
522
607
  ;;
523
608
  design-complete)
524
609
  require_phase "$change_name" "design"
610
+ require_design_evidence "$change_name"
525
611
  cmd_set "$change_name" phase build
526
612
  ;;
527
613
  build-complete)
@@ -565,6 +651,12 @@ cmd_transition() {
565
651
  ;;
566
652
  archived)
567
653
  require_phase "$change_name" "archive"
654
+ local archived_verify_result
655
+ archived_verify_result=$(cmd_get "$change_name" "verify_result")
656
+ if [ "$archived_verify_result" != "pass" ]; then
657
+ red "ERROR: Cannot transition '$change_name': verify_result must be pass before archiving" >&2
658
+ exit 1
659
+ fi
568
660
  cmd_set "$change_name" archived true
569
661
  ;;
570
662
  esac
@@ -771,7 +863,7 @@ cmd_recover() {
771
863
 
772
864
  # Read all relevant fields
773
865
  local design_doc plan verify_result verify_mode verification_report
774
- local branch_status handoff_context handoff_hash isolation build_mode build_pause subagent_dispatch tdd_mode direct_override
866
+ local branch_status handoff_context handoff_hash isolation build_mode build_pause subagent_dispatch tdd_mode review_mode direct_override
775
867
  design_doc=$(cmd_get "$change_name" "design_doc")
776
868
  plan=$(cmd_get "$change_name" "plan")
777
869
  verify_result=$(cmd_get "$change_name" "verify_result")
@@ -785,6 +877,7 @@ cmd_recover() {
785
877
  build_pause=$(cmd_get "$change_name" "build_pause" 2>/dev/null || true)
786
878
  subagent_dispatch=$(cmd_get "$change_name" "subagent_dispatch" 2>/dev/null || true)
787
879
  tdd_mode=$(cmd_get "$change_name" "tdd_mode" 2>/dev/null || true)
880
+ review_mode=$(cmd_get "$change_name" "review_mode" 2>/dev/null || true)
788
881
  direct_override=$(cmd_get "$change_name" "direct_override" 2>/dev/null || true)
789
882
 
790
883
  echo "State fields:"
@@ -840,6 +933,7 @@ cmd_recover() {
840
933
  field_status "build_mode" "$build_mode"
841
934
  field_status "build_pause" "$build_pause"
842
935
  field_status "tdd_mode" "$tdd_mode"
936
+ field_status "review_mode" "$review_mode"
843
937
  if [ "$build_mode" = "subagent-driven-development" ] || { [ -n "$subagent_dispatch" ] && [ "$subagent_dispatch" != "null" ]; }; then
844
938
  field_status "subagent_dispatch" "$subagent_dispatch"
845
939
  fi
@@ -1024,6 +1118,59 @@ cmd_scale() {
1024
1118
  green "[SCALE] verify_mode=$result"
1025
1119
  }
1026
1120
 
1121
+ cmd_task_checkoff() {
1122
+ local task_file="$1"
1123
+ local task_text="$2"
1124
+
1125
+ validate_path_field "$task_file" "task file"
1126
+
1127
+ if [ -z "$task_text" ]; then
1128
+ red "ERROR: Task text cannot be empty" >&2
1129
+ exit 1
1130
+ fi
1131
+
1132
+ if [ ! -f "$task_file" ]; then
1133
+ red "ERROR: Task file not found: $task_file" >&2
1134
+ exit 1
1135
+ fi
1136
+
1137
+ local counts
1138
+ counts=$(TASK_TEXT="$task_text" awk '
1139
+ BEGIN {
1140
+ task = ENVIRON["TASK_TEXT"]
1141
+ }
1142
+ {
1143
+ sub(/\r$/, "")
1144
+ if ($0 == "- [ ] " task || $0 == "- [x] " task || $0 == "- [X] " task) {
1145
+ total++
1146
+ }
1147
+ if ($0 == "- [x] " task || $0 == "- [X] " task) {
1148
+ checked++
1149
+ }
1150
+ }
1151
+ END {
1152
+ printf "%d %d\n", total + 0, checked + 0
1153
+ }
1154
+ ' "$task_file")
1155
+
1156
+ local total="${counts%% *}"
1157
+ local checked="${counts##* }"
1158
+
1159
+ if [ "$total" -ne 1 ]; then
1160
+ red "ERROR: task text must appear exactly once in $task_file (found $total): $task_text" >&2
1161
+ exit 1
1162
+ fi
1163
+
1164
+ if [ "$checked" -ne 1 ]; then
1165
+ red "ERROR: task is not checked in $task_file: $task_text" >&2
1166
+ exit 1
1167
+ fi
1168
+
1169
+ echo "TASK_CHECKOFF: PASS"
1170
+ echo "FILE: $task_file"
1171
+ echo "TASK: $task_text"
1172
+ }
1173
+
1027
1174
  # Resolve the next workflow step after a guard --apply phase advance.
1028
1175
  # Reads the (already advanced) phase, workflow, and auto_transition, then emits
1029
1176
  # a deterministic next-step contract so skills don't hardcode the next skill name.
@@ -1155,6 +1302,13 @@ case "$SUBCOMMAND" in
1155
1302
  fi
1156
1303
  cmd_scale "$@"
1157
1304
  ;;
1305
+ task-checkoff)
1306
+ if [ $# -lt 2 ]; then
1307
+ red "Usage: comet-state.sh task-checkoff <file> <task-text>" >&2
1308
+ exit 1
1309
+ fi
1310
+ cmd_task_checkoff "$@"
1311
+ ;;
1158
1312
  next)
1159
1313
  if [ $# -lt 1 ]; then
1160
1314
  red "Usage: comet-state.sh next <change-name>" >&2
@@ -1174,6 +1328,7 @@ case "$SUBCOMMAND" in
1174
1328
  echo " transition <change-name> <event> — Apply a validated state transition" >&2
1175
1329
  echo " check <change-name> <phase> — Verify entry requirements for a phase" >&2
1176
1330
  echo " scale <change-name> — Assess and set verification mode based on metrics" >&2
1331
+ echo " task-checkoff <file> <task-text> — Verify one unique task is checked" >&2
1177
1332
  echo " next <change-name> — Resolve the next workflow step (auto/manual/done)" >&2
1178
1333
  echo "" >&2
1179
1334
  echo "Workflows: full, hotfix, tweak" >&2
@@ -143,6 +143,7 @@ build_mode=$(field_value "build_mode")
143
143
  build_pause=$(field_value "build_pause")
144
144
  subagent_dispatch=$(field_value "subagent_dispatch")
145
145
  tdd_mode=$(field_value "tdd_mode")
146
+ review_mode=$(field_value "review_mode")
146
147
  isolation=$(field_value "isolation")
147
148
  verify_mode=$(field_value "verify_mode")
148
149
  auto_transition=$(field_value "auto_transition")
@@ -162,6 +163,7 @@ validate_enum "build_mode" "$build_mode" "subagent-driven-development exe
162
163
  validate_enum "build_pause" "$build_pause" "null plan-ready"
163
164
  validate_enum "subagent_dispatch" "$subagent_dispatch" "null confirmed"
164
165
  validate_enum "tdd_mode" "$tdd_mode" "tdd direct null"
166
+ validate_enum "review_mode" "$review_mode" "off standard thorough"
165
167
  validate_enum "isolation" "$isolation" "branch worktree"
166
168
  validate_enum "verify_mode" "$verify_mode" "light full"
167
169
  if grep -q "^auto_transition:" "$YAML" 2>/dev/null; then
@@ -199,7 +201,7 @@ if [ -n "$handoff_hash" ] && [ "$handoff_hash" != "null" ]; then
199
201
  fi
200
202
 
201
203
  # --- Unknown keys check ---
202
- KNOWN_KEYS="workflow phase context_compression design_doc plan build_mode build_pause subagent_dispatch tdd_mode isolation verify_mode auto_transition verify_result verification_report branch_status verified_at created_at archived direct_override build_command verify_command handoff_context handoff_hash base_ref"
204
+ KNOWN_KEYS="workflow phase context_compression design_doc plan build_mode build_pause subagent_dispatch tdd_mode review_mode isolation verify_mode auto_transition verify_result verification_report branch_status verified_at created_at archived direct_override build_command verify_command handoff_context handoff_hash base_ref"
203
205
  while IFS=: read -r key _; do
204
206
  key="${key// /}"
205
207
  [ -z "$key" ] && continue
@@ -1,106 +1,100 @@
1
- ---
2
- name: comet-archive
3
- description: "Comet Phase 5: Archive. Invoke with /comet-archive. Merge delta specs into main specs with OpenSpec semantics, archive change."
4
- ---
5
-
6
- # Comet Phase 5: Archive (Archive)
7
-
8
- ## Prerequisites
9
-
10
- - Verification passed (Phase 4 complete)
11
- - Branch handled
12
- - `verify_result: pass` in `openspec/changes/<name>/.comet.yaml`
13
-
14
- ## Steps
15
-
16
- ### 0. Output Language Constraint
17
-
18
- Archive summaries and lifecycle closure notes must use the language of the user request that triggered this workflow.
19
-
20
- ### 0. Entry State Verification (Entry Check)
21
-
22
- Execute entry verification:
23
-
24
- ```bash
25
- COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
26
- if [ -z "$COMET_ENV" ]; then
27
- echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
28
- return 1
29
- fi
30
- . "$COMET_ENV"
31
- "$COMET_BASH" "$COMET_STATE" check <name> archive
32
- ```
33
-
34
- Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
35
-
36
- ### 1. Final Archive Confirmation (Blocking Point)
37
-
38
- After entry verification passes, **must use the current platform's available user input/confirmation mechanism to pause and wait for the user to confirm whether to archive immediately**. Must not run `"$COMET_BASH" "$COMET_ARCHIVE" "<change-name>"` before user confirmation. If the current platform has no structured question tool, ask an equivalent single-select question in the conversation, stop the workflow, and wait for the user's reply before continuing.
39
-
40
- Before confirmation, show the user a brief summary:
41
- - Change name
42
- - Verification report path and result
43
- - Branch handling status
44
- - Irreversible actions this archive will perform: merge main specs with OpenSpec delta semantics, annotate design doc / plan, and move the change to the archive directory
45
-
46
- The user confirmation question must be presented as a single-select question with these options:
47
- - "Confirm archive" — immediately run the archive script to complete spec merge and change movement
48
- - "Needs adjustment or re-verification" — do not archive; run `"$COMET_BASH" "$COMET_STATE" transition <change-name> archive-reopen` to return to `phase: verify`, then invoke `/comet-verify`. If verification confirms fixes are needed, follow `/comet-verify`'s verification-failure decision flow back to `/comet-build`
49
- - "Do not archive yet" — do not archive; keep the current `phase: archive` state and wait for the user to invoke `/comet-archive` again later
50
-
51
- Only after the user selects "Confirm archive" may Step 2 continue. After the user selects "Needs adjustment or re-verification", must first run the `archive-reopen` state transition; do not edit `.comet.yaml` manually.
52
-
53
- ### 2. Execute Archive
54
-
55
- Run the archive script to automatically complete all steps:
56
-
57
- ```bash
58
- "$COMET_BASH" "$COMET_ARCHIVE" "<change-name>"
59
- ```
60
-
61
- The script automatically executes:
62
- 1. Entry state validation (phase=archive, verify_result=pass, archived=false)
63
- 2. Design doc frontmatter annotation (archived-with, status)
64
- 3. Plan frontmatter annotation (archived-with)
65
- 4. OpenSpec archive for delta-merge semantics and moving the change to the archive directory
66
- 5. Main spec guard against leaked delta-only section headings
67
- 6. Update `archived: true` through `comet-state transition <archive-name> archived`
68
-
69
- If script returns non-zero exit code, report error and stop.
70
- If script returns zero exit code, archive is complete.
71
- The summary `X/Y steps succeeded` counts real executed steps and does not double-count delta spec sync or document annotation.
72
-
73
- The script calls OpenSpec archive to merge `ADDED/MODIFIED/REMOVED/RENAMED` delta semantics into main specs, then verifies main specs do not contain delta-only section headings.
74
-
75
- Use `--dry-run` flag to preview without executing.
76
-
77
- ### 3. Lifecycle Closed Loop
78
-
79
- Spec lifecycle completes here:
80
- ```
81
- brainstorming → delta spec → implementation → verification → main spec merge → design doc annotation → archive
82
- ```
83
-
84
- ## Exit Conditions
85
-
86
- - Archive script executed successfully (exit code 0)
87
- - Archive directory `openspec/changes/archive/YYYY-MM-DD-<change-name>/` exists
88
- - Archived `.comet.yaml` contains `archived: true`
89
-
90
- The archive script moves `openspec/changes/<name>/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`.
91
-
92
- > **WARNING**: After successful archive, **do not run** `"$COMET_BASH" "$COMET_GUARD" <change-name> archive` against the old active change name; the active directory no longer exists. Doing so will cause the guard to error with "change directory not found". Archive completeness is determined by script exit code and archived directory state.
93
-
94
- ## Complete
95
-
96
- Comet workflow complete. To start new work, invoke `/comet` or `/comet-open`.
97
-
98
- ## Context Compaction Recovery
99
-
100
- The archive phase may trigger context compaction during execution. On resume, first run:
101
-
102
- ```bash
103
- "$COMET_BASH" "$COMET_STATE" check <change-name> archive --recover
104
- ```
105
-
106
- The script outputs structured recovery context (archive status, completed steps). Follow the Recovery action to determine next steps. If `archived: true` and the archive directory exists, archiving is already complete — no need to run the archive operation again.
1
+ ---
2
+ name: comet-archive
3
+ description: "Comet Phase 5: Archive. Invoke with /comet-archive. Merge delta specs into main specs with OpenSpec semantics, archive change."
4
+ ---
5
+
6
+ # Comet Phase 5: Archive (Archive)
7
+
8
+ ## Prerequisites
9
+
10
+ - Verification passed (Phase 4 complete)
11
+ - Branch handled
12
+ - `verify_result: pass` in `openspec/changes/<name>/.comet.yaml`
13
+
14
+ ## Steps
15
+
16
+ ### 0. Output Language Constraint
17
+
18
+ Archive summaries and lifecycle closure notes must use the language of the user request that triggered this workflow.
19
+
20
+ ### 0. Entry State Verification (Entry Check)
21
+
22
+ Execute entry verification:
23
+
24
+ ```bash
25
+ COMET_ENV="${COMET_ENV:-$(find . "$HOME"/.*/skills "$HOME/.config" "$HOME/.gemini" -path '*/comet/scripts/comet-env.sh' -type f -print -quit 2>/dev/null)}"
26
+ if [ -z "$COMET_ENV" ]; then
27
+ echo "ERROR: comet-env.sh not found. Ensure the comet skill is installed." >&2
28
+ return 1
29
+ fi
30
+ . "$COMET_ENV"
31
+ "$COMET_BASH" "$COMET_STATE" check <name> archive
32
+ ```
33
+
34
+ Proceed to Step 1 after verification passes. The script outputs specific failure reasons when verification fails.
35
+
36
+ ### 1. Final Archive Confirmation (Blocking Point)
37
+
38
+ After entry verification passes, **must follow the `comet/reference/decision-point.md` protocol to pause and wait for the user to confirm whether to archive immediately**. Must not run `"$COMET_BASH" "$COMET_ARCHIVE" "<change-name>"` before user confirmation.
39
+
40
+ Before confirmation, show the user a brief summary:
41
+ - Change name
42
+ - Verification report path and result
43
+ - Branch handling status
44
+ - Irreversible actions this archive will perform: merge main specs with OpenSpec delta semantics, annotate design doc / plan, and move the change to the archive directory
45
+
46
+ The user confirmation question must be presented as a single-select question with these options:
47
+ - "Confirm archive" — immediately run the archive script to complete spec merge and change movement
48
+ - "Needs adjustment or re-verification" — do not archive; run `"$COMET_BASH" "$COMET_STATE" transition <change-name> archive-reopen` to return to `phase: verify`, then invoke `/comet-verify`. If verification confirms fixes are needed, follow `/comet-verify`'s verification-failure decision flow back to `/comet-build`
49
+ - "Do not archive yet" — do not archive; keep the current `phase: archive` state and wait for the user to invoke `/comet-archive` again later
50
+
51
+ Only after the user selects "Confirm archive" may Step 2 continue. After the user selects "Needs adjustment or re-verification", must first run the `archive-reopen` state transition; do not edit `.comet.yaml` manually.
52
+
53
+ ### 2. Execute Archive
54
+
55
+ Run the archive script to automatically complete all steps:
56
+
57
+ ```bash
58
+ "$COMET_BASH" "$COMET_ARCHIVE" "<change-name>"
59
+ ```
60
+
61
+ The script automatically executes:
62
+ 1. Entry state validation (phase=archive, verify_result=pass, archived=false)
63
+ 2. Design doc frontmatter annotation (archived-with, status)
64
+ 3. Plan frontmatter annotation (archived-with)
65
+ 4. OpenSpec archive for delta-merge semantics and moving the change to the archive directory
66
+ 5. Main spec guard against leaked delta-only section headings
67
+ 6. Update `archived: true` through `comet-state transition <archive-name> archived`
68
+
69
+ If script returns non-zero exit code, report error and stop.
70
+ If script returns zero exit code, archive is complete.
71
+ The summary `X/Y steps succeeded` counts real executed steps and does not double-count delta spec sync or document annotation.
72
+
73
+ The script calls OpenSpec archive to merge `ADDED/MODIFIED/REMOVED/RENAMED` delta semantics into main specs, then verifies main specs do not contain delta-only section headings.
74
+
75
+ Use `--dry-run` flag to preview without executing.
76
+
77
+ ### 3. Lifecycle Closed Loop
78
+
79
+ Spec lifecycle completes here:
80
+ ```
81
+ brainstorming → delta spec → implementation → verification → main spec merge → design doc annotation → archive
82
+ ```
83
+
84
+ ## Exit Conditions
85
+
86
+ - Archive script executed successfully (exit code 0)
87
+ - Archive directory `openspec/changes/archive/YYYY-MM-DD-<change-name>/` exists
88
+ - Archived `.comet.yaml` contains `archived: true`
89
+
90
+ The archive script moves `openspec/changes/<name>/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`.
91
+
92
+ > **WARNING**: After successful archive, **do not run** `"$COMET_BASH" "$COMET_GUARD" <change-name> archive` against the old active change name; the active directory no longer exists. Doing so will cause the guard to error with "change directory not found". Archive completeness is determined by script exit code and archived directory state.
93
+
94
+ ## Complete
95
+
96
+ Comet workflow complete. To start new work, invoke `/comet` or `/comet-open`.
97
+
98
+ ## Context Compression Recovery
99
+
100
+ Follow `comet/reference/context-recovery.md` with phase set to `archive`. If `archived: true` and archive directory exists, archival is complete — do not re-execute archive operations.