claude-mcp-workflow 0.1.7 → 0.1.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 (61) hide show
  1. package/.claude-plugin/plugin.json +4 -2
  2. package/README.md +39 -2
  3. package/build/engine.d.ts +21 -1
  4. package/build/engine.d.ts.map +1 -1
  5. package/build/engine.js +59 -6
  6. package/build/engine.js.map +1 -1
  7. package/build/storage.d.ts +20 -0
  8. package/build/storage.d.ts.map +1 -1
  9. package/build/storage.js +41 -0
  10. package/build/storage.js.map +1 -1
  11. package/build/types.d.ts +21 -20
  12. package/build/types.d.ts.map +1 -1
  13. package/build/types.js +2 -1
  14. package/build/types.js.map +1 -1
  15. package/hooks/hooks.json +4 -2
  16. package/hooks/workflow-cleanup.sh +58 -20
  17. package/hooks/workflow-start.sh +60 -32
  18. package/package.json +1 -1
  19. package/templates/bug-fix.yaml +98 -16
  20. package/templates/code-review.yaml +30 -12
  21. package/templates/coding.yaml +49 -4
  22. package/templates/debugging.yaml +39 -14
  23. package/templates/explore.yaml +48 -14
  24. package/templates/file-code.yaml +13 -4
  25. package/templates/file-review.yaml +25 -6
  26. package/templates/github-init.yaml +24 -8
  27. package/templates/investigate.yaml +13 -4
  28. package/templates/master.yaml +16 -13
  29. package/templates/new-feature.yaml +24 -26
  30. package/templates/planning.yaml +38 -7
  31. package/templates/reflection.yaml +11 -4
  32. package/templates/review-push.yaml +26 -7
  33. package/templates/skills/architecture/SKILL.md +131 -1
  34. package/templates/skills/aws-lambda/SKILL.md +9 -9
  35. package/templates/skills/browser-verify/SKILL.md +58 -0
  36. package/templates/skills/build-cmake/SKILL.md +24 -8
  37. package/templates/skills/ci-github-actions/SKILL.md +34 -18
  38. package/templates/skills/claude-code-config/SKILL.md +41 -19
  39. package/templates/skills/cleanup/SKILL.md +57 -0
  40. package/templates/skills/coding-skill-selector/SKILL.md +2 -1
  41. package/templates/skills/debug-bridge-scaffold/SKILL.md +98 -0
  42. package/templates/skills/domain-gamedev/SKILL.md +56 -6
  43. package/templates/skills/domain-pixi/SKILL.md +256 -7
  44. package/templates/skills/domain-reid/SKILL.md +39 -5
  45. package/templates/skills/domain-yolo/SKILL.md +18 -7
  46. package/templates/skills/ide-zed/SKILL.md +23 -0
  47. package/templates/skills/lang-as3/SKILL.md +7 -5
  48. package/templates/skills/lang-haxe/SKILL.md +538 -19
  49. package/templates/skills/lang-python/SKILL.md +6 -2
  50. package/templates/skills/math/SKILL.md +64 -2
  51. package/templates/skills/mcp-setup/SKILL.md +14 -2
  52. package/templates/skills/preferences/SKILL.md +10 -10
  53. package/templates/skills/skill-manager/SKILL.md +264 -0
  54. package/templates/skills/target-openfl-native/SKILL.md +52 -17
  55. package/templates/skills/target-openfl-native/references/build-and-versions.md +7 -4
  56. package/templates/skills/task-delegation/SKILL.md +76 -4
  57. package/templates/skills/web-reading/SKILL.md +33 -25
  58. package/templates/skills/workflow-authoring/SKILL.md +47 -12
  59. package/templates/subagent.yaml +29 -8
  60. package/templates/testing.yaml +64 -10
  61. package/templates/web-research.yaml +23 -13
package/build/types.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const StateDefinitionSchema: z.ZodObject<{
3
3
  prompt: z.ZodOptional<z.ZodString>;
4
4
  transitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
5
5
  terminal: z.ZodOptional<z.ZodBoolean>;
6
- outcome: z.ZodOptional<z.ZodEnum<["complete", "fail", "needs_action"]>>;
6
+ outcome: z.ZodOptional<z.ZodEnum<["complete", "fail"]>>;
7
7
  max_visits: z.ZodOptional<z.ZodNumber>;
8
8
  sub_workflow: z.ZodOptional<z.ZodString>;
9
9
  on_complete: z.ZodOptional<z.ZodString>;
@@ -44,7 +44,7 @@ export declare const StateDefinitionSchema: z.ZodObject<{
44
44
  type?: "prompt" | "exec" | "fetch" | undefined;
45
45
  transitions?: Record<string, string> | undefined;
46
46
  terminal?: boolean | undefined;
47
- outcome?: "complete" | "fail" | "needs_action" | undefined;
47
+ outcome?: "complete" | "fail" | undefined;
48
48
  max_visits?: number | undefined;
49
49
  sub_workflow?: string | undefined;
50
50
  on_complete?: string | undefined;
@@ -78,7 +78,7 @@ export declare const StateDefinitionSchema: z.ZodObject<{
78
78
  type?: "prompt" | "exec" | "fetch" | undefined;
79
79
  transitions?: Record<string, string> | undefined;
80
80
  terminal?: boolean | undefined;
81
- outcome?: "complete" | "fail" | "needs_action" | undefined;
81
+ outcome?: "complete" | "fail" | undefined;
82
82
  max_visits?: number | undefined;
83
83
  sub_workflow?: string | undefined;
84
84
  on_complete?: string | undefined;
@@ -118,7 +118,7 @@ export declare const WorkflowDefinitionSchema: z.ZodObject<{
118
118
  prompt: z.ZodOptional<z.ZodString>;
119
119
  transitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
120
120
  terminal: z.ZodOptional<z.ZodBoolean>;
121
- outcome: z.ZodOptional<z.ZodEnum<["complete", "fail", "needs_action"]>>;
121
+ outcome: z.ZodOptional<z.ZodEnum<["complete", "fail"]>>;
122
122
  max_visits: z.ZodOptional<z.ZodNumber>;
123
123
  sub_workflow: z.ZodOptional<z.ZodString>;
124
124
  on_complete: z.ZodOptional<z.ZodString>;
@@ -159,7 +159,7 @@ export declare const WorkflowDefinitionSchema: z.ZodObject<{
159
159
  type?: "prompt" | "exec" | "fetch" | undefined;
160
160
  transitions?: Record<string, string> | undefined;
161
161
  terminal?: boolean | undefined;
162
- outcome?: "complete" | "fail" | "needs_action" | undefined;
162
+ outcome?: "complete" | "fail" | undefined;
163
163
  max_visits?: number | undefined;
164
164
  sub_workflow?: string | undefined;
165
165
  on_complete?: string | undefined;
@@ -193,7 +193,7 @@ export declare const WorkflowDefinitionSchema: z.ZodObject<{
193
193
  type?: "prompt" | "exec" | "fetch" | undefined;
194
194
  transitions?: Record<string, string> | undefined;
195
195
  terminal?: boolean | undefined;
196
- outcome?: "complete" | "fail" | "needs_action" | undefined;
196
+ outcome?: "complete" | "fail" | undefined;
197
197
  max_visits?: number | undefined;
198
198
  sub_workflow?: string | undefined;
199
199
  on_complete?: string | undefined;
@@ -232,7 +232,7 @@ export declare const WorkflowDefinitionSchema: z.ZodObject<{
232
232
  type?: "prompt" | "exec" | "fetch" | undefined;
233
233
  transitions?: Record<string, string> | undefined;
234
234
  terminal?: boolean | undefined;
235
- outcome?: "complete" | "fail" | "needs_action" | undefined;
235
+ outcome?: "complete" | "fail" | undefined;
236
236
  max_visits?: number | undefined;
237
237
  sub_workflow?: string | undefined;
238
238
  on_complete?: string | undefined;
@@ -271,7 +271,7 @@ export declare const WorkflowDefinitionSchema: z.ZodObject<{
271
271
  type?: "prompt" | "exec" | "fetch" | undefined;
272
272
  transitions?: Record<string, string> | undefined;
273
273
  terminal?: boolean | undefined;
274
- outcome?: "complete" | "fail" | "needs_action" | undefined;
274
+ outcome?: "complete" | "fail" | undefined;
275
275
  max_visits?: number | undefined;
276
276
  sub_workflow?: string | undefined;
277
277
  on_complete?: string | undefined;
@@ -422,7 +422,7 @@ export declare const WorkflowModifyInputSchema: z.ZodObject<{
422
422
  prompt: z.ZodOptional<z.ZodString>;
423
423
  transitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
424
424
  terminal: z.ZodOptional<z.ZodBoolean>;
425
- outcome: z.ZodOptional<z.ZodEnum<["complete", "fail", "needs_action"]>>;
425
+ outcome: z.ZodOptional<z.ZodEnum<["complete", "fail"]>>;
426
426
  max_visits: z.ZodOptional<z.ZodNumber>;
427
427
  sub_workflow: z.ZodOptional<z.ZodString>;
428
428
  on_complete: z.ZodOptional<z.ZodString>;
@@ -466,7 +466,7 @@ export declare const WorkflowModifyInputSchema: z.ZodObject<{
466
466
  type?: "prompt" | "exec" | "fetch" | undefined;
467
467
  transitions?: Record<string, string> | undefined;
468
468
  terminal?: boolean | undefined;
469
- outcome?: "complete" | "fail" | "needs_action" | undefined;
469
+ outcome?: "complete" | "fail" | undefined;
470
470
  max_visits?: number | undefined;
471
471
  sub_workflow?: string | undefined;
472
472
  on_complete?: string | undefined;
@@ -501,7 +501,7 @@ export declare const WorkflowModifyInputSchema: z.ZodObject<{
501
501
  type?: "prompt" | "exec" | "fetch" | undefined;
502
502
  transitions?: Record<string, string> | undefined;
503
503
  terminal?: boolean | undefined;
504
- outcome?: "complete" | "fail" | "needs_action" | undefined;
504
+ outcome?: "complete" | "fail" | undefined;
505
505
  max_visits?: number | undefined;
506
506
  sub_workflow?: string | undefined;
507
507
  on_complete?: string | undefined;
@@ -562,7 +562,7 @@ export declare const WorkflowModifyInputSchema: z.ZodObject<{
562
562
  type?: "prompt" | "exec" | "fetch" | undefined;
563
563
  transitions?: Record<string, string> | undefined;
564
564
  terminal?: boolean | undefined;
565
- outcome?: "complete" | "fail" | "needs_action" | undefined;
565
+ outcome?: "complete" | "fail" | undefined;
566
566
  max_visits?: number | undefined;
567
567
  sub_workflow?: string | undefined;
568
568
  on_complete?: string | undefined;
@@ -609,7 +609,7 @@ export declare const WorkflowModifyInputSchema: z.ZodObject<{
609
609
  type?: "prompt" | "exec" | "fetch" | undefined;
610
610
  transitions?: Record<string, string> | undefined;
611
611
  terminal?: boolean | undefined;
612
- outcome?: "complete" | "fail" | "needs_action" | undefined;
612
+ outcome?: "complete" | "fail" | undefined;
613
613
  max_visits?: number | undefined;
614
614
  sub_workflow?: string | undefined;
615
615
  on_complete?: string | undefined;
@@ -659,7 +659,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
659
659
  prompt: z.ZodOptional<z.ZodString>;
660
660
  transitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
661
661
  terminal: z.ZodOptional<z.ZodBoolean>;
662
- outcome: z.ZodOptional<z.ZodEnum<["complete", "fail", "needs_action"]>>;
662
+ outcome: z.ZodOptional<z.ZodEnum<["complete", "fail"]>>;
663
663
  max_visits: z.ZodOptional<z.ZodNumber>;
664
664
  sub_workflow: z.ZodOptional<z.ZodString>;
665
665
  on_complete: z.ZodOptional<z.ZodString>;
@@ -700,7 +700,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
700
700
  type?: "prompt" | "exec" | "fetch" | undefined;
701
701
  transitions?: Record<string, string> | undefined;
702
702
  terminal?: boolean | undefined;
703
- outcome?: "complete" | "fail" | "needs_action" | undefined;
703
+ outcome?: "complete" | "fail" | undefined;
704
704
  max_visits?: number | undefined;
705
705
  sub_workflow?: string | undefined;
706
706
  on_complete?: string | undefined;
@@ -734,7 +734,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
734
734
  type?: "prompt" | "exec" | "fetch" | undefined;
735
735
  transitions?: Record<string, string> | undefined;
736
736
  terminal?: boolean | undefined;
737
- outcome?: "complete" | "fail" | "needs_action" | undefined;
737
+ outcome?: "complete" | "fail" | undefined;
738
738
  max_visits?: number | undefined;
739
739
  sub_workflow?: string | undefined;
740
740
  on_complete?: string | undefined;
@@ -771,7 +771,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
771
771
  type?: "prompt" | "exec" | "fetch" | undefined;
772
772
  transitions?: Record<string, string> | undefined;
773
773
  terminal?: boolean | undefined;
774
- outcome?: "complete" | "fail" | "needs_action" | undefined;
774
+ outcome?: "complete" | "fail" | undefined;
775
775
  max_visits?: number | undefined;
776
776
  sub_workflow?: string | undefined;
777
777
  on_complete?: string | undefined;
@@ -810,7 +810,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
810
810
  type?: "prompt" | "exec" | "fetch" | undefined;
811
811
  transitions?: Record<string, string> | undefined;
812
812
  terminal?: boolean | undefined;
813
- outcome?: "complete" | "fail" | "needs_action" | undefined;
813
+ outcome?: "complete" | "fail" | undefined;
814
814
  max_visits?: number | undefined;
815
815
  sub_workflow?: string | undefined;
816
816
  on_complete?: string | undefined;
@@ -852,7 +852,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
852
852
  type?: "prompt" | "exec" | "fetch" | undefined;
853
853
  transitions?: Record<string, string> | undefined;
854
854
  terminal?: boolean | undefined;
855
- outcome?: "complete" | "fail" | "needs_action" | undefined;
855
+ outcome?: "complete" | "fail" | undefined;
856
856
  max_visits?: number | undefined;
857
857
  sub_workflow?: string | undefined;
858
858
  on_complete?: string | undefined;
@@ -894,7 +894,7 @@ export declare const WorkflowCreateInputSchema: z.ZodObject<{
894
894
  type?: "prompt" | "exec" | "fetch" | undefined;
895
895
  transitions?: Record<string, string> | undefined;
896
896
  terminal?: boolean | undefined;
897
- outcome?: "complete" | "fail" | "needs_action" | undefined;
897
+ outcome?: "complete" | "fail" | undefined;
898
898
  max_visits?: number | undefined;
899
899
  sub_workflow?: string | undefined;
900
900
  on_complete?: string | undefined;
@@ -940,4 +940,5 @@ export declare const WorkflowSessionsInputSchema: z.ZodOptional<z.ZodObject<{},
940
940
  export declare const MAX_STACK_DEPTH = 10;
941
941
  export declare const DEFAULT_MAX_TRANSITIONS = 50;
942
942
  export declare const LOCK_STALE_MS = 5000;
943
+ export declare const KEEP_TERMINAL_SESSIONS = 3;
943
944
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2ChC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC;AAClC,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
package/build/types.js CHANGED
@@ -6,7 +6,7 @@ export const StateDefinitionSchema = z.object({
6
6
  prompt: z.string().optional(),
7
7
  transitions: z.record(z.string()).optional(),
8
8
  terminal: z.boolean().optional(),
9
- outcome: z.enum(["complete", "fail", "needs_action"]).optional(),
9
+ outcome: z.enum(["complete", "fail"]).optional(),
10
10
  max_visits: z.number().int().positive().optional(),
11
11
  sub_workflow: z.string().optional(),
12
12
  on_complete: z.string().optional(),
@@ -98,4 +98,5 @@ export const WorkflowSessionsInputSchema = z.object({}).optional();
98
98
  export const MAX_STACK_DEPTH = 10;
99
99
  export const DEFAULT_MAX_TRANSITIONS = 50;
100
100
  export const LOCK_STALE_MS = 5000;
101
+ export const KEEP_TERMINAL_SESSIONS = 3;
101
102
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iDAAiD;AAEjD,0EAA0E;AAC1E,mFAAmF;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAClD,YAAY,EAAE,CAAC,CAAC,MAAM,E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"\"${CLAUDE_PLUGIN_ROOT}\"/hooks/workflow-start.sh",
9
+ "timeout": 30
9
10
  }
10
11
  ]
11
12
  }
12
13
  ],
13
14
  "SessionEnd": [
14
15
  {
16
+ "matcher": "logout|prompt_input_exit|other|bypass_permissions_disabled",
15
17
  "hooks": [
16
18
  {
17
19
  "type": "command",
18
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/workflow-cleanup.sh"
20
+ "command": "\"${CLAUDE_PLUGIN_ROOT}\"/hooks/workflow-cleanup.sh"
19
21
  }
20
22
  ]
21
23
  }
@@ -1,28 +1,38 @@
1
1
  #!/bin/bash
2
- # SessionEnd hook: abandon active workflow sessions for this Claude Code instance.
2
+ # SessionEnd hook: abandon this Claude Code instance's active workflow sessions
3
+ # (and their descendants), then cap retained terminal sessions so the state
4
+ # dir keeps only the most recent few for history — never grows unbounded.
3
5
  # Skips sessions referenced in plan files (they should survive context clears).
4
- # Modifies JSON files directly — does NOT depend on MCP server / dashboard being alive.
6
+ # Modifies JSON files directly — does NOT depend on MCP server being alive.
5
7
  read -t 1 -r INPUT
6
8
  STATE_DIR="${STATE_DIR:-$HOME/.claude/workflow-state}"
7
9
  PLANS_DIR="$HOME/.claude/plans"
8
10
  NOW=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
11
+ # Mirror of KEEP_TERMINAL_SESSIONS in src/types.ts
12
+ KEEP_TERMINAL=3
9
13
  ABANDONED_SIDS=()
10
14
 
11
- for f in "$STATE_DIR"/*.json; do
12
- [ -f "$f" ] || continue
13
- SID=$(jq -r "select(.stack | length > 0) | select(.context.claude_code_pid == $PPID) | .session_id" "$f" 2>/dev/null)
14
- [ -n "$SID" ] || continue
15
- # Skip if session referenced in plan files
16
- [ -d "$PLANS_DIR" ] && grep -rql "$SID" "$PLANS_DIR"/ 2>/dev/null && continue
17
- # Abandon: clear stack, set outcome, append history entry
18
- TMP="${f}.tmp"
19
- jq --arg now "$NOW" '
20
- .history += [{ frame: .active_frame, event: "abandon", at: $now }] |
15
+ is_planned() {
16
+ [ -d "$PLANS_DIR" ] && [ -n "$1" ] && grep -rqlF "$1" "$PLANS_DIR"/ 2>/dev/null
17
+ }
18
+
19
+ abandon() {
20
+ local f="$1" event="${2:-abandon}" TMP="${f}.tmp"
21
+ jq --arg now "$NOW" --arg event "$event" '
22
+ .history += [{ frame: .active_frame, event: $event, at: $now }] |
21
23
  .stack = [] |
22
24
  .active_frame = -1 |
23
25
  .outcome = "abandoned" |
24
26
  .updated_at = $now
25
27
  ' "$f" > "$TMP" 2>/dev/null && mv "$TMP" "$f" || rm -f "$TMP"
28
+ }
29
+
30
+ for f in "$STATE_DIR"/*.json; do
31
+ [ -f "$f" ] || continue
32
+ SID=$(jq -r "select(.stack | length > 0) | select(.context.claude_code_pid == $PPID) | .session_id" "$f" 2>/dev/null)
33
+ [ -n "$SID" ] || continue
34
+ is_planned "$SID" && continue
35
+ abandon "$f"
26
36
  ABANDONED_SIDS+=("$SID")
27
37
  done
28
38
 
@@ -34,14 +44,8 @@ cascade_abandon() {
34
44
  local child_sid
35
45
  child_sid=$(jq -r --arg pid "$parent_sid" 'select(.parent_session_id == $pid) | select(.stack | length > 0) | .session_id' "$f" 2>/dev/null)
36
46
  [ -n "$child_sid" ] || continue
37
- TMP="${f}.tmp"
38
- jq --arg now "$NOW" '
39
- .history += [{ frame: .active_frame, event: "cascade_abandon", at: $now }] |
40
- .stack = [] |
41
- .active_frame = -1 |
42
- .outcome = "abandoned" |
43
- .updated_at = $now
44
- ' "$f" > "$TMP" 2>/dev/null && mv "$TMP" "$f" || rm -f "$TMP"
47
+ is_planned "$child_sid" && continue
48
+ abandon "$f" cascade_abandon
45
49
  cascade_abandon "$child_sid"
46
50
  done
47
51
  }
@@ -49,3 +53,37 @@ cascade_abandon() {
49
53
  for sid in "${ABANDONED_SIDS[@]}"; do
50
54
  cascade_abandon "$sid"
51
55
  done
56
+
57
+ # Cap retained terminal sessions: keep the KEEP_TERMINAL with the newest
58
+ # .updated_at, delete older ones. Full parity with Storage.pruneTerminal in
59
+ # src/storage.ts:
60
+ # - sort by the JSON .updated_at field (not file mtime) — abandon() bumps
61
+ # mtime via mv, so mtime order would diverge from the engine's retention;
62
+ # - secondary sort by .session_id — cascade abandon stamps every child with
63
+ # one identical .updated_at, so a stable tiebreak keeps the retained set
64
+ # deterministic and identical to the engine;
65
+ # - no is_planned guard here — terminal (empty-stack) sessions can never be
66
+ # plan-referenced (plan resume requires an active stack), same invariant
67
+ # the engine's pruneTerminal documents and relies on.
68
+ TERM_FILES=()
69
+ for f in "$STATE_DIR"/*.json; do
70
+ [ -f "$f" ] || continue
71
+ # `.stack == []` (not `length == 0`) — a file without a .stack array is a
72
+ # placeholder, not a terminal session, and must not be pruned.
73
+ jq -e '.stack == []' "$f" >/dev/null 2>&1 && TERM_FILES+=("$f")
74
+ done
75
+ if [ "${#TERM_FILES[@]}" -gt "$KEEP_TERMINAL" ]; then
76
+ i=0
77
+ while IFS= read -r f; do
78
+ i=$((i + 1))
79
+ [ "$i" -le "$KEEP_TERMINAL" ] && continue
80
+ rm -f "$f"
81
+ done < <(
82
+ for f in "${TERM_FILES[@]}"; do
83
+ meta=$(jq -r '[.updated_at // "", .session_id // ""] | @tsv' "$f" 2>/dev/null)
84
+ # Path goes FIRST: empty meta fields would collapse under IFS splitting,
85
+ # shifting the path into the wrong column.
86
+ printf '%s\t%s\n' "$f" "$meta"
87
+ done | LC_ALL=C sort -r -t $'\t' -k2,3 | awk -F'\t' '{print $1}'
88
+ )
89
+ fi
@@ -21,77 +21,105 @@ if [ -d "$SKILLS_SRC" ]; then
21
21
  done
22
22
  fi
23
23
 
24
+ ZED_SUFFIX=""
25
+ if [[ -n "$ZED_ENVIRONMENT" ]]; then
26
+ ZED_SUFFIX=" Then load skill ide-zed (Skill tool)."
27
+ fi
28
+
29
+ # Everything below requires jq — without it, still emit the fresh-start prompt.
30
+ command -v jq >/dev/null 2>&1 || { echo "STOP. Call mcp__plugin_workflow_wf__start (no args) first.$ZED_SUFFIX"; exit 0; }
31
+
24
32
  read -t 1 -r INPUT
33
+ SOURCE=$(echo "$INPUT" | jq -r '.source // empty')
25
34
  TRANSCRIPT=$(echo "$INPUT" | jq -r '.transcript_path // empty')
35
+ HOOK_CWD=$(echo "$INPUT" | jq -r '.cwd // empty')
36
+ # Physical path (pwd -P) so a symlinked cwd (e.g. /tmp → /private/tmp)
37
+ # compares equal to the engine's getcwd()-resolved context.cwd.
38
+ HOOK_CWD=$(cd "${HOOK_CWD:-$PWD}" 2>/dev/null && pwd -P || echo "$PWD")
26
39
  STATE_DIR="${STATE_DIR:-$HOME/.claude/workflow-state}"
27
40
  PLANS_DIR="$HOME/.claude/plans"
28
41
 
29
- ZED_SUFFIX=""
30
- if [[ -n "$ZED_ENVIRONMENT" ]]; then
31
- ZED_SUFFIX=" Then load skill ide-zed (Skill tool)."
32
- fi
42
+ # Session IDs are 8 hex chars; the {7,} length filter skips shorter incidental hex words.
43
+ SID_RE='[a-f0-9]{7,}'
44
+
45
+ # --- Helper: apply a jq filter to a file in place (atomic tmp+rename) ---
46
+ # $$ makes the temp name unique per hook instance, so concurrent hooks
47
+ # cannot clobber each other's half-written temp files.
48
+ jq_inplace() {
49
+ local filter="$1" f="$2" tmp="$2.tmp.$$"
50
+ jq "$filter" "$f" 2>/dev/null > "$tmp" && mv "$tmp" "$f" || rm -f "$tmp"
51
+ }
52
+
53
+ # --- Helper: check <sid> refers to a live planning session ---
54
+ # Live = state file exists + top stack frame is "planning" + not abandoned.
55
+ validate_planning_session() {
56
+ local sf="$STATE_DIR/$1.json"
57
+ [ -f "$sf" ] || return 1
58
+ jq -e '.outcome != "abandoned" and (.stack | length > 0) and .stack[-1].workflow == "planning"' "$sf" >/dev/null 2>&1
59
+ }
33
60
 
34
61
  # --- Helper: increment skill_epoch in a session JSON by ID ---
35
62
  bump_skill_epoch_by_id() {
36
- local sid="$1"
37
- local sf="$STATE_DIR/${sid}.json"
63
+ local sf="$STATE_DIR/$1.json"
38
64
  [ -f "$sf" ] || return
39
- jq '.skill_epoch = ((.skill_epoch // 0) + 1)' "$sf" 2>/dev/null > "${sf}.tmp" && mv "${sf}.tmp" "$sf" || rm -f "${sf}.tmp"
65
+ jq_inplace '.skill_epoch = ((.skill_epoch // 0) + 1)' "$sf"
40
66
  }
41
67
 
42
68
  # --- Helper: increment skill_epoch in active sessions for current PID ---
43
69
  bump_skill_epoch_by_pid() {
44
70
  [ -d "$STATE_DIR" ] || return
71
+ # $PPID is the Claude Code process: hook commands run as single-command
72
+ # `bash -c` invocations, which bash exec-optimizes (the shell replaces
73
+ # itself), so no intermediate shell sits between this script and Claude Code.
45
74
  local cc_pid=$PPID
46
75
  for sf in "$STATE_DIR"/*.json; do
47
76
  [ -f "$sf" ] || continue
48
77
  local pid
49
78
  pid=$(jq -r '.context.claude_code_pid // empty' "$sf" 2>/dev/null)
50
79
  [ "$pid" = "$cc_pid" ] || continue
51
- jq 'if .stack | length > 0 then .skill_epoch = ((.skill_epoch // 0) + 1) else . end' "$sf" 2>/dev/null > "${sf}.tmp" && mv "${sf}.tmp" "$sf" || rm -f "${sf}.tmp"
80
+ jq_inplace 'if .stack | length > 0 then .skill_epoch = ((.skill_epoch // 0) + 1) else . end' "$sf"
52
81
  done
53
82
  }
54
83
 
55
- # --- Helper: find active planning session from plan files ---
84
+ # --- Helper: find a live planning session for this project from plan files ---
85
+ # Only plans whose session context.cwd matches the hook's cwd are considered;
86
+ # candidates are checked newest-first by plan file mtime.
56
87
  find_plan_session() {
57
88
  [ -d "$PLANS_DIR" ] || return
58
- for plan in "$PLANS_DIR"/*.md; do
89
+ local plan sid
90
+ while IFS= read -r plan; do
59
91
  [ -f "$plan" ] || continue
60
- # Extract session ID from ## Workflow section (Session line: `<hex>`)
61
- local sid
62
- sid=$(grep -A5 '^## Workflow' "$plan" | grep 'Session' | grep -oE '[a-f0-9]{7,}' | head -1)
92
+ # Session ID from the ## Workflow section. -A5: the section contract is
93
+ # 5 list lines after the heading (Session / Current state / After approve /
94
+ # Execution workflow / Resume) Session is always within that window.
95
+ sid=$(grep -A5 '^## Workflow' "$plan" | grep 'Session' | grep -oE "$SID_RE" | head -1)
63
96
  [ -n "$sid" ] || continue
64
- # Check if this session is active and in planning state
65
- local state_file="$STATE_DIR/${sid}.json"
66
- [ -f "$state_file" ] || continue
67
- local wf
68
- wf=$(jq -r 'select(.stack | length > 0) | .stack[-1].workflow // empty' "$state_file" 2>/dev/null)
69
- if [ "$wf" = "planning" ]; then
70
- echo "$sid"
71
- return
72
- fi
73
- done
97
+ validate_planning_session "$sid" || continue
98
+ [ "$(jq -r '.context.cwd // empty' "$STATE_DIR/${sid}.json" 2>/dev/null)" = "$HOOK_CWD" ] || continue
99
+ echo "$sid"
100
+ return
101
+ done < <(ls -t "$PLANS_DIR"/*.md 2>/dev/null)
74
102
  }
75
103
 
76
- # --- 1. Transcript exists and has content → same process ---
77
- if [ -n "$TRANSCRIPT" ] && [ -s "$TRANSCRIPT" ]; then
78
- # Check for ExitPlanMode plan resume after context clear
79
- if grep -q 'ExitPlanMode' "$TRANSCRIPT" 2>/dev/null; then
80
- PLAN_SID=$(grep -oE 'transition\(\\"[a-f0-9]+\\"' "$TRANSCRIPT" | tail -1 | grep -oE '[a-f0-9]{7,}')
81
- if [ -n "$PLAN_SID" ]; then
104
+ # --- 1. clear/compact → same process, context lost ---
105
+ if [ "$SOURCE" = "clear" ] || [ "$SOURCE" = "compact" ]; then
106
+ # Transcript grep is only used to recover the planning session hex;
107
+ # validity is checked against the state file, not the transcript.
108
+ if [ -n "$TRANSCRIPT" ] && grep -q 'ExitPlanMode' "$TRANSCRIPT" 2>/dev/null; then
109
+ PLAN_SID=$(grep -oE 'transition\(\\"[a-f0-9]+\\"' "$TRANSCRIPT" | tail -1 | grep -oE "$SID_RE")
110
+ if [ -n "$PLAN_SID" ] && validate_planning_session "$PLAN_SID"; then
82
111
  bump_skill_epoch_by_id "$PLAN_SID"
83
112
  echo "PLAN RESUME (same process): call transition(\"$PLAN_SID\", \"planned\") to resume planning session.$ZED_SUFFIX"
84
113
  exit 0
85
114
  fi
86
115
  fi
87
- # Has content but no plan → context clear
88
116
  bump_skill_epoch_by_pid
89
117
  echo "Context was cleared. Call status() to check for active session and restore context.$ZED_SUFFIX"
90
118
  exit 0
91
119
  fi
92
120
 
93
- # --- 2. Transcript empty or missing → new process ---
94
- # Check plans/ for active planning sessions (cross-process plan resume)
121
+ # --- 2. startup/resume → new process ---
122
+ # Check plans/ for live planning sessions (cross-process plan resume)
95
123
  PLAN_SID=$(find_plan_session)
96
124
  if [ -n "$PLAN_SID" ]; then
97
125
  bump_skill_epoch_by_id "$PLAN_SID"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mcp-workflow",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Structured workflow orchestration for AI agents via finite-state machines",
5
5
  "author": "AxGord <axgord@gmail.com> (https://github.com/AxGord)",
6
6
  "license": "MIT",