planflow-ai 1.3.5 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/create-plan.md +11 -0
- package/.claude/commands/discovery-plan.md +12 -0
- package/.claude/commands/execute-plan.md +114 -23
- package/.claude/commands/flow.md +27 -2
- package/.claude/commands/resume-work.md +261 -0
- package/.claude/commands/review-code.md +11 -0
- package/.claude/commands/review-pr.md +11 -0
- package/.claude/resources/core/_index.md +45 -2
- package/.claude/resources/core/atomic-commits.md +380 -0
- package/.claude/resources/core/autopilot-mode.md +3 -2
- package/.claude/resources/core/compaction-guide.md +15 -1
- package/.claude/resources/core/heartbeat.md +129 -1
- package/.claude/resources/core/per-task-verification.md +362 -0
- package/.claude/resources/core/phase-isolation.md +192 -4
- package/.claude/resources/core/session-scratchpad.md +1 -0
- package/.claude/resources/core/wave-execution.md +329 -0
- package/.claude/resources/patterns/plans-patterns.md +56 -0
- package/.claude/resources/patterns/plans-templates.md +152 -0
- package/.claude/resources/skills/_index.md +8 -6
- package/.claude/resources/skills/create-plan-skill.md +71 -5
- package/.claude/resources/skills/execute-plan-skill.md +355 -10
- package/.claude/resources/skills/resume-work-skill.md +159 -0
- package/dist/cli/commands/init.js +1 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/state.d.ts +12 -0
- package/dist/cli/commands/state.d.ts.map +1 -0
- package/dist/cli/commands/state.js +47 -0
- package/dist/cli/commands/state.js.map +1 -0
- package/dist/cli/daemon/desktop-notifier.d.ts +16 -0
- package/dist/cli/daemon/desktop-notifier.d.ts.map +1 -0
- package/dist/cli/daemon/desktop-notifier.js +53 -0
- package/dist/cli/daemon/desktop-notifier.js.map +1 -0
- package/dist/cli/daemon/event-writer.d.ts +22 -0
- package/dist/cli/daemon/event-writer.d.ts.map +1 -0
- package/dist/cli/daemon/event-writer.js +76 -0
- package/dist/cli/daemon/event-writer.js.map +1 -0
- package/dist/cli/daemon/heartbeat-daemon.js +81 -1
- package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
- package/dist/cli/daemon/log-writer.d.ts +17 -0
- package/dist/cli/daemon/log-writer.d.ts.map +1 -0
- package/dist/cli/daemon/log-writer.js +62 -0
- package/dist/cli/daemon/log-writer.js.map +1 -0
- package/dist/cli/daemon/notification-router.d.ts +17 -0
- package/dist/cli/daemon/notification-router.d.ts.map +1 -0
- package/dist/cli/daemon/notification-router.js +35 -0
- package/dist/cli/daemon/notification-router.js.map +1 -0
- package/dist/cli/daemon/prompt-manager.d.ts +27 -0
- package/dist/cli/daemon/prompt-manager.d.ts.map +1 -0
- package/dist/cli/daemon/prompt-manager.js +107 -0
- package/dist/cli/daemon/prompt-manager.js.map +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/state/flowconfig-parser.d.ts +16 -0
- package/dist/cli/state/flowconfig-parser.d.ts.map +1 -0
- package/dist/cli/state/flowconfig-parser.js +166 -0
- package/dist/cli/state/flowconfig-parser.js.map +1 -0
- package/dist/cli/state/heartbeat-state.d.ts +16 -0
- package/dist/cli/state/heartbeat-state.d.ts.map +1 -0
- package/dist/cli/state/heartbeat-state.js +97 -0
- package/dist/cli/state/heartbeat-state.js.map +1 -0
- package/dist/cli/state/model-router.d.ts +8 -0
- package/dist/cli/state/model-router.d.ts.map +1 -0
- package/dist/cli/state/model-router.js +36 -0
- package/dist/cli/state/model-router.js.map +1 -0
- package/dist/cli/state/plan-parser.d.ts +16 -0
- package/dist/cli/state/plan-parser.d.ts.map +1 -0
- package/dist/cli/state/plan-parser.js +124 -0
- package/dist/cli/state/plan-parser.js.map +1 -0
- package/dist/cli/state/session-state.d.ts +21 -0
- package/dist/cli/state/session-state.d.ts.map +1 -0
- package/dist/cli/state/session-state.js +36 -0
- package/dist/cli/state/session-state.js.map +1 -0
- package/dist/cli/state/state-md-parser.d.ts +18 -0
- package/dist/cli/state/state-md-parser.d.ts.map +1 -0
- package/dist/cli/state/state-md-parser.js +222 -0
- package/dist/cli/state/state-md-parser.js.map +1 -0
- package/dist/cli/state/types.d.ts +106 -0
- package/dist/cli/state/types.d.ts.map +1 -0
- package/dist/cli/state/types.js +8 -0
- package/dist/cli/state/types.js.map +1 -0
- package/dist/cli/state/wave-calculator.d.ts +18 -0
- package/dist/cli/state/wave-calculator.d.ts.map +1 -0
- package/dist/cli/state/wave-calculator.js +134 -0
- package/dist/cli/state/wave-calculator.js.map +1 -0
- package/dist/cli/types.d.ts +15 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/templates/shared/CLAUDE.md.template +4 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a complexity score to a model tier and model name.
|
|
3
|
+
*
|
|
4
|
+
* - 0-3 -> fast (haiku)
|
|
5
|
+
* - 4-5 -> standard (sonnet)
|
|
6
|
+
* - 6-10 -> powerful (opus)
|
|
7
|
+
*/
|
|
8
|
+
function complexityToTier(complexity) {
|
|
9
|
+
if (complexity <= 3) {
|
|
10
|
+
return { tier: 'fast', model: 'haiku' };
|
|
11
|
+
}
|
|
12
|
+
if (complexity <= 5) {
|
|
13
|
+
return { tier: 'standard', model: 'sonnet' };
|
|
14
|
+
}
|
|
15
|
+
return { tier: 'powerful', model: 'opus' };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Calculate model tiers for each plan phase based on complexity scores.
|
|
19
|
+
*
|
|
20
|
+
* Returns an empty array when model routing is disabled.
|
|
21
|
+
*/
|
|
22
|
+
export function calculateModelTiers(phases, modelRoutingEnabled) {
|
|
23
|
+
if (!modelRoutingEnabled) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return phases.map((phase) => {
|
|
27
|
+
const { tier, model } = complexityToTier(phase.complexity);
|
|
28
|
+
return {
|
|
29
|
+
phase: phase.number,
|
|
30
|
+
complexity: phase.complexity,
|
|
31
|
+
tier,
|
|
32
|
+
model,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=model-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-router.js","sourceRoot":"","sources":["../../../src/cli/state/model-router.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,UAAkB;IAC1C,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC1C,CAAC;IACD,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAmB,EACnB,mBAA4B;IAE5B,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC3D,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,IAAI;YACJ,KAAK;SACN,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan markdown parser
|
|
3
|
+
*
|
|
4
|
+
* Parses plan files (flow/plans/plan_*.md) into structured PlanPhase objects.
|
|
5
|
+
* Extracts phase headers, complexity scores, dependencies, tasks, and verify tags.
|
|
6
|
+
*/
|
|
7
|
+
import type { PlanPhase } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Parses a plan markdown file and returns an array of PlanPhase objects.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parsePlan(planPath: string): PlanPhase[];
|
|
12
|
+
/**
|
|
13
|
+
* Parses plan markdown content (for testability without file I/O).
|
|
14
|
+
*/
|
|
15
|
+
export declare function parsePlanContent(content: string): PlanPhase[];
|
|
16
|
+
//# sourceMappingURL=plan-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-parser.d.ts","sourceRoot":"","sources":["../../../src/cli/state/plan-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,YAAY,CAAC;AAWtD;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAGvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,CAiG7D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan markdown parser
|
|
3
|
+
*
|
|
4
|
+
* Parses plan files (flow/plans/plan_*.md) into structured PlanPhase objects.
|
|
5
|
+
* Extracts phase headers, complexity scores, dependencies, tasks, and verify tags.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from 'node:fs';
|
|
8
|
+
const PHASE_HEADER_RE = /^### Phase (\d+):\s*(.+)$/;
|
|
9
|
+
const COMPLEXITY_RE = /\*\*Complexity\*\*:\s*(\d+)\/10/;
|
|
10
|
+
const DEPENDENCIES_RE = /\*\*Dependencies\*\*:\s*(.+)/;
|
|
11
|
+
const TASK_RE = /^- \[[ x]\]\s+(.+)$/;
|
|
12
|
+
const VERIFY_RE = /<verify>(.+)<\/verify>/;
|
|
13
|
+
const PHASE_REF_RE = /Phase\s+(\d+)/gi;
|
|
14
|
+
const DEFAULT_COMPLEXITY = 5;
|
|
15
|
+
/**
|
|
16
|
+
* Parses a plan markdown file and returns an array of PlanPhase objects.
|
|
17
|
+
*/
|
|
18
|
+
export function parsePlan(planPath) {
|
|
19
|
+
const content = readFileSync(planPath, 'utf-8');
|
|
20
|
+
return parsePlanContent(content);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parses plan markdown content (for testability without file I/O).
|
|
24
|
+
*/
|
|
25
|
+
export function parsePlanContent(content) {
|
|
26
|
+
const phases = [];
|
|
27
|
+
const lines = content.split('\n');
|
|
28
|
+
let currentPhase = null;
|
|
29
|
+
let lastTaskIndex = -1;
|
|
30
|
+
for (let i = 0; i < lines.length; i++) {
|
|
31
|
+
const line = lines[i];
|
|
32
|
+
const trimmed = line.trim();
|
|
33
|
+
// Phase header
|
|
34
|
+
const headerMatch = trimmed.match(PHASE_HEADER_RE);
|
|
35
|
+
if (headerMatch) {
|
|
36
|
+
// Save previous phase
|
|
37
|
+
if (currentPhase) {
|
|
38
|
+
phases.push(finalizePhase(currentPhase));
|
|
39
|
+
}
|
|
40
|
+
currentPhase = {
|
|
41
|
+
number: parseInt(headerMatch[1], 10),
|
|
42
|
+
name: headerMatch[2].trim(),
|
|
43
|
+
complexity: null,
|
|
44
|
+
dependencies: null,
|
|
45
|
+
tasks: [],
|
|
46
|
+
};
|
|
47
|
+
lastTaskIndex = -1;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (!currentPhase)
|
|
51
|
+
continue;
|
|
52
|
+
// Complexity
|
|
53
|
+
const complexityMatch = trimmed.match(COMPLEXITY_RE);
|
|
54
|
+
if (complexityMatch) {
|
|
55
|
+
currentPhase.complexity = parseInt(complexityMatch[1], 10);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// Dependencies
|
|
59
|
+
const depsMatch = trimmed.match(DEPENDENCIES_RE);
|
|
60
|
+
if (depsMatch) {
|
|
61
|
+
const depsValue = depsMatch[1].trim();
|
|
62
|
+
if (/^none$/i.test(depsValue)) {
|
|
63
|
+
currentPhase.dependencies = [];
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const depNumbers = [];
|
|
67
|
+
let match;
|
|
68
|
+
// Reset regex state for each use
|
|
69
|
+
const phaseRefRe = /Phase\s+(\d+)/gi;
|
|
70
|
+
while ((match = phaseRefRe.exec(depsValue)) !== null) {
|
|
71
|
+
depNumbers.push(parseInt(match[1], 10));
|
|
72
|
+
}
|
|
73
|
+
currentPhase.dependencies = depNumbers.length > 0 ? depNumbers : [];
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
// Task line
|
|
78
|
+
const taskMatch = trimmed.match(TASK_RE);
|
|
79
|
+
if (taskMatch) {
|
|
80
|
+
const taskName = taskMatch[1].trim();
|
|
81
|
+
currentPhase.tasks.push({ index: currentPhase.tasks.length + 1, name: taskName, verify_command: null });
|
|
82
|
+
lastTaskIndex = currentPhase.tasks.length - 1;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
// Verify tag (must follow a task line)
|
|
86
|
+
if (lastTaskIndex >= 0) {
|
|
87
|
+
const verifyMatch = trimmed.match(VERIFY_RE);
|
|
88
|
+
if (verifyMatch) {
|
|
89
|
+
currentPhase.tasks[lastTaskIndex].verify_command = verifyMatch[1].trim();
|
|
90
|
+
lastTaskIndex = -1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// If non-empty, non-verify line after a task, reset lastTaskIndex
|
|
94
|
+
if (trimmed !== '') {
|
|
95
|
+
lastTaskIndex = -1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Save the last phase
|
|
100
|
+
if (currentPhase) {
|
|
101
|
+
phases.push(finalizePhase(currentPhase));
|
|
102
|
+
}
|
|
103
|
+
return phases;
|
|
104
|
+
}
|
|
105
|
+
function finalizePhase(phase) {
|
|
106
|
+
const complexity = phase.complexity ?? DEFAULT_COMPLEXITY;
|
|
107
|
+
// Dependencies: if explicitly set, use them; otherwise sequential fallback
|
|
108
|
+
let dependencies;
|
|
109
|
+
if (phase.dependencies !== null) {
|
|
110
|
+
dependencies = phase.dependencies;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// Sequential fallback: depend on previous phase, Phase 1 has no deps
|
|
114
|
+
dependencies = phase.number > 1 ? [phase.number - 1] : [];
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
number: phase.number,
|
|
118
|
+
name: phase.name,
|
|
119
|
+
complexity,
|
|
120
|
+
dependencies,
|
|
121
|
+
tasks: phase.tasks,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=plan-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-parser.js","sourceRoot":"","sources":["../../../src/cli/state/plan-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,MAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,MAAM,aAAa,GAAG,iCAAiC,CAAC;AACxD,MAAM,eAAe,GAAG,8BAA8B,CAAC;AACvD,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAC3C,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAEvC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,YAAY,GAML,IAAI,C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AAC,CAAC,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;gBACzE,aAAa,GAAG,CAAC,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YAED,kEAAkE;YAClE,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;gBACnB,aAAa,GAAG,CAAC,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,KAMtB;IACC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,kBAAkB,CAAC;IAE1D,2EAA2E;IAC3E,IAAI,YAAsB,CAAC;IAC3B,IAAI,KAAK,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;QAChC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;IACpC,CAAC;SAAM,CAAC;QACN,qEAAqE;QACrE,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,UAAU;QACV,YAAY;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session state checker — detects which session-start files exist
|
|
3
|
+
* in the flow directory, returning a structured SessionState object.
|
|
4
|
+
*/
|
|
5
|
+
import type { SessionState } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Checks existence of all session-start files and returns structured state.
|
|
8
|
+
*
|
|
9
|
+
* Files checked:
|
|
10
|
+
* - ledger.md
|
|
11
|
+
* - brain/index.md
|
|
12
|
+
* - tasklist.md
|
|
13
|
+
* - memory.md
|
|
14
|
+
* - .scratchpad.md
|
|
15
|
+
* - .heartbeat-events.jsonl
|
|
16
|
+
* - .heartbeat-state.json
|
|
17
|
+
* - .heartbeat-prompt.md
|
|
18
|
+
* - STATE.md
|
|
19
|
+
*/
|
|
20
|
+
export declare function getSessionState(flowDir: string): SessionState;
|
|
21
|
+
//# sourceMappingURL=session-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-state.d.ts","sourceRoot":"","sources":["../../../src/cli/state/session-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAc7D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session state checker — detects which session-start files exist
|
|
3
|
+
* in the flow directory, returning a structured SessionState object.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Checks existence of all session-start files and returns structured state.
|
|
9
|
+
*
|
|
10
|
+
* Files checked:
|
|
11
|
+
* - ledger.md
|
|
12
|
+
* - brain/index.md
|
|
13
|
+
* - tasklist.md
|
|
14
|
+
* - memory.md
|
|
15
|
+
* - .scratchpad.md
|
|
16
|
+
* - .heartbeat-events.jsonl
|
|
17
|
+
* - .heartbeat-state.json
|
|
18
|
+
* - .heartbeat-prompt.md
|
|
19
|
+
* - STATE.md
|
|
20
|
+
*/
|
|
21
|
+
export function getSessionState(flowDir) {
|
|
22
|
+
return {
|
|
23
|
+
files_present: {
|
|
24
|
+
ledger: existsSync(join(flowDir, 'ledger.md')),
|
|
25
|
+
brain_index: existsSync(join(flowDir, 'brain', 'index.md')),
|
|
26
|
+
tasklist: existsSync(join(flowDir, 'tasklist.md')),
|
|
27
|
+
memory: existsSync(join(flowDir, 'memory.md')),
|
|
28
|
+
scratchpad: existsSync(join(flowDir, '.scratchpad.md')),
|
|
29
|
+
heartbeat_events: existsSync(join(flowDir, '.heartbeat-events.jsonl')),
|
|
30
|
+
heartbeat_state: existsSync(join(flowDir, '.heartbeat-state.json')),
|
|
31
|
+
heartbeat_prompt: existsSync(join(flowDir, '.heartbeat-prompt.md')),
|
|
32
|
+
state_md: existsSync(join(flowDir, 'STATE.md')),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=session-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-state.js","sourceRoot":"","sources":["../../../src/cli/state/session-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,OAAO;QACL,aAAa,EAAE;YACb,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC9C,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAC3D,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YAClD,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC9C,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;YACvD,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;YACtE,eAAe,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC;YACnE,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;YACnE,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;SAChD;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* STATE.md Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses `flow/STATE.md` into a structured ExecutionState object.
|
|
5
|
+
* Uses regex-based line parsing consistent with flowconfig-parser and plan-parser patterns.
|
|
6
|
+
* Returns null if STATE.md doesn't exist.
|
|
7
|
+
*/
|
|
8
|
+
import type { ExecutionState } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Parse `flow/STATE.md` into a structured ExecutionState object.
|
|
11
|
+
* Returns null if STATE.md doesn't exist.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseStateMd(flowDir: string): ExecutionState | null;
|
|
14
|
+
/**
|
|
15
|
+
* Parse STATE.md content string (for testability without file I/O).
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseStateMdContent(content: string): ExecutionState;
|
|
18
|
+
//# sourceMappingURL=state-md-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-md-parser.d.ts","sourceRoot":"","sources":["../../../src/cli/state/state-md-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAqC,cAAc,EAAE,MAAM,YAAY,CAAC;AASpF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAenE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAuEnE"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* STATE.md Parser
|
|
3
|
+
*
|
|
4
|
+
* Parses `flow/STATE.md` into a structured ExecutionState object.
|
|
5
|
+
* Uses regex-based line parsing consistent with flowconfig-parser and plan-parser patterns.
|
|
6
|
+
* Returns null if STATE.md doesn't exist.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
const SECTION_RE = /^## (.+)$/;
|
|
11
|
+
const BOLD_KV_RE = /^- \*\*(.+?)\*\*:\s*(.*)$/;
|
|
12
|
+
const BULLET_RE = /^- (.+)$/;
|
|
13
|
+
const UPDATED_RE = /^\*\*Updated\*\*:\s*(.+)$/;
|
|
14
|
+
const COMPLETED_PHASE_RE = /^Phase (\d+):\s*(.+?)\s*—\s*(.+)$/;
|
|
15
|
+
const CURRENT_PHASE_RE = /^(\d+)\s*—\s*(.+)$/;
|
|
16
|
+
/**
|
|
17
|
+
* Parse `flow/STATE.md` into a structured ExecutionState object.
|
|
18
|
+
* Returns null if STATE.md doesn't exist.
|
|
19
|
+
*/
|
|
20
|
+
export function parseStateMd(flowDir) {
|
|
21
|
+
const statePath = join(flowDir, 'STATE.md');
|
|
22
|
+
if (!existsSync(statePath)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
let content;
|
|
26
|
+
try {
|
|
27
|
+
content = readFileSync(statePath, 'utf-8');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return parseStateMdContent(content);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse STATE.md content string (for testability without file I/O).
|
|
36
|
+
*/
|
|
37
|
+
export function parseStateMdContent(content) {
|
|
38
|
+
const state = {
|
|
39
|
+
active_skill: null,
|
|
40
|
+
active_plan: null,
|
|
41
|
+
current_phase: null,
|
|
42
|
+
current_task: null,
|
|
43
|
+
completed_phases: [],
|
|
44
|
+
decisions: [],
|
|
45
|
+
blockers: [],
|
|
46
|
+
files_modified: [],
|
|
47
|
+
next_action: null,
|
|
48
|
+
updated_at: null,
|
|
49
|
+
};
|
|
50
|
+
const lines = content.split('\n');
|
|
51
|
+
let currentSection = '';
|
|
52
|
+
let inCompletedPhases = false;
|
|
53
|
+
for (let i = 0; i < lines.length; i++) {
|
|
54
|
+
const line = lines[i];
|
|
55
|
+
const trimmed = line.trim();
|
|
56
|
+
// Updated timestamp (outside sections)
|
|
57
|
+
const updatedMatch = trimmed.match(UPDATED_RE);
|
|
58
|
+
if (updatedMatch) {
|
|
59
|
+
state.updated_at = updatedMatch[1].trim();
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// Section header
|
|
63
|
+
const sectionMatch = trimmed.match(SECTION_RE);
|
|
64
|
+
if (sectionMatch) {
|
|
65
|
+
currentSection = sectionMatch[1].trim();
|
|
66
|
+
inCompletedPhases = false;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (currentSection === 'Execution State') {
|
|
70
|
+
parseExecutionStateLine(trimmed, state, inCompletedPhases);
|
|
71
|
+
// Track if we just entered completed phases sub-list
|
|
72
|
+
const kvMatch = trimmed.match(BOLD_KV_RE);
|
|
73
|
+
if (kvMatch && kvMatch[1] === 'Completed Phases') {
|
|
74
|
+
inCompletedPhases = true;
|
|
75
|
+
}
|
|
76
|
+
else if (kvMatch && kvMatch[1] !== 'Completed Phases') {
|
|
77
|
+
inCompletedPhases = false;
|
|
78
|
+
}
|
|
79
|
+
// Indented bullets under Completed Phases
|
|
80
|
+
if (inCompletedPhases && line.match(/^\s{2,}- /)) {
|
|
81
|
+
const indentedContent = trimmed.replace(/^- /, '');
|
|
82
|
+
const phaseMatch = indentedContent.match(COMPLETED_PHASE_RE);
|
|
83
|
+
if (phaseMatch) {
|
|
84
|
+
state.completed_phases.push({
|
|
85
|
+
number: parseInt(phaseMatch[1], 10),
|
|
86
|
+
name: phaseMatch[2].trim(),
|
|
87
|
+
outcome: phaseMatch[3].trim(),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (currentSection === 'Decisions') {
|
|
93
|
+
parseDecisionLine(trimmed, state);
|
|
94
|
+
}
|
|
95
|
+
else if (currentSection === 'Blockers') {
|
|
96
|
+
parseBlockerLine(trimmed, state);
|
|
97
|
+
}
|
|
98
|
+
else if (currentSection === 'Files Modified') {
|
|
99
|
+
parseFileModifiedLine(trimmed, state);
|
|
100
|
+
}
|
|
101
|
+
else if (currentSection === 'Next Action') {
|
|
102
|
+
parseNextActionLine(trimmed, state);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return state;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parse a line within the Execution State section.
|
|
109
|
+
*/
|
|
110
|
+
function parseExecutionStateLine(trimmed, state, inCompletedPhases) {
|
|
111
|
+
if (inCompletedPhases)
|
|
112
|
+
return;
|
|
113
|
+
const kvMatch = trimmed.match(BOLD_KV_RE);
|
|
114
|
+
if (!kvMatch)
|
|
115
|
+
return;
|
|
116
|
+
const key = kvMatch[1].trim();
|
|
117
|
+
const value = kvMatch[2].trim();
|
|
118
|
+
switch (key) {
|
|
119
|
+
case 'Active Skill':
|
|
120
|
+
state.active_skill = value;
|
|
121
|
+
break;
|
|
122
|
+
case 'Active Plan':
|
|
123
|
+
state.active_plan = value;
|
|
124
|
+
break;
|
|
125
|
+
case 'Current Phase': {
|
|
126
|
+
const phaseMatch = value.match(CURRENT_PHASE_RE);
|
|
127
|
+
if (phaseMatch) {
|
|
128
|
+
state.current_phase = {
|
|
129
|
+
number: parseInt(phaseMatch[1], 10),
|
|
130
|
+
name: phaseMatch[2].trim(),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case 'Current Task':
|
|
136
|
+
state.current_task = value;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Parse a decision bullet line.
|
|
142
|
+
* Format: "- Chose X over Y (reason: Z)" or "- Decision text (reason: explanation)"
|
|
143
|
+
*/
|
|
144
|
+
function parseDecisionLine(trimmed, state) {
|
|
145
|
+
const bulletMatch = trimmed.match(BULLET_RE);
|
|
146
|
+
if (!bulletMatch)
|
|
147
|
+
return;
|
|
148
|
+
const text = bulletMatch[1].trim();
|
|
149
|
+
const reasonMatch = text.match(/^(.+?)\s*\(reason:\s*(.+?)\)$/);
|
|
150
|
+
if (reasonMatch) {
|
|
151
|
+
const decisionText = reasonMatch[1].trim();
|
|
152
|
+
// Try to extract "Chose X over Y" pattern
|
|
153
|
+
const choseMatch = decisionText.match(/^(?:Chose|Used)\s+(.+?)(?:\s+(?:over|for|instead of)\s+(.+))?$/i);
|
|
154
|
+
if (choseMatch) {
|
|
155
|
+
state.decisions.push({
|
|
156
|
+
decision: decisionText,
|
|
157
|
+
choice: choseMatch[1].trim(),
|
|
158
|
+
reason: reasonMatch[2].trim(),
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
state.decisions.push({
|
|
163
|
+
decision: decisionText,
|
|
164
|
+
choice: decisionText,
|
|
165
|
+
reason: reasonMatch[2].trim(),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
state.decisions.push({
|
|
171
|
+
decision: text,
|
|
172
|
+
choice: text,
|
|
173
|
+
reason: '',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Parse a blocker bullet line.
|
|
179
|
+
* Format: "- Issue description (status: X, tried: Y)"
|
|
180
|
+
*/
|
|
181
|
+
function parseBlockerLine(trimmed, state) {
|
|
182
|
+
const bulletMatch = trimmed.match(BULLET_RE);
|
|
183
|
+
if (!bulletMatch)
|
|
184
|
+
return;
|
|
185
|
+
const text = bulletMatch[1].trim();
|
|
186
|
+
const detailsMatch = text.match(/^(.+?)\s*\(status:\s*(.+?),\s*tried:\s*(.+?)\)$/);
|
|
187
|
+
if (detailsMatch) {
|
|
188
|
+
state.blockers.push({
|
|
189
|
+
issue: detailsMatch[1].trim(),
|
|
190
|
+
status: detailsMatch[2].trim(),
|
|
191
|
+
tried: detailsMatch[3].trim(),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
state.blockers.push({
|
|
196
|
+
issue: text,
|
|
197
|
+
status: 'unknown',
|
|
198
|
+
tried: '',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Parse a file path bullet line.
|
|
204
|
+
*/
|
|
205
|
+
function parseFileModifiedLine(trimmed, state) {
|
|
206
|
+
const bulletMatch = trimmed.match(BULLET_RE);
|
|
207
|
+
if (!bulletMatch)
|
|
208
|
+
return;
|
|
209
|
+
const filePath = bulletMatch[1].trim();
|
|
210
|
+
if (filePath) {
|
|
211
|
+
state.files_modified.push(filePath);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Parse the next action line (first non-empty line in the section).
|
|
216
|
+
*/
|
|
217
|
+
function parseNextActionLine(trimmed, state) {
|
|
218
|
+
if (trimmed && !state.next_action) {
|
|
219
|
+
state.next_action = trimmed;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=state-md-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-md-parser.js","sourceRoot":"","sources":["../../../src/cli/state/state-md-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAC/C,MAAM,SAAS,GAAG,UAAU,CAAC;AAC7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AEzB,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,OAAe,EAAE,KAAqB;IACjE,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAClC,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the deterministic state script (`planflow-ai state`).
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define the JSON output shape produced by parsing
|
|
5
|
+
* plan-flow config files, session state, heartbeat events, and plans.
|
|
6
|
+
*/
|
|
7
|
+
export interface FlowConfig {
|
|
8
|
+
autopilot: boolean;
|
|
9
|
+
commit: boolean;
|
|
10
|
+
push: boolean;
|
|
11
|
+
pr: boolean;
|
|
12
|
+
branch: string;
|
|
13
|
+
wave_execution: boolean;
|
|
14
|
+
phase_isolation: boolean;
|
|
15
|
+
model_routing: boolean;
|
|
16
|
+
max_verify_retries: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SessionState {
|
|
19
|
+
files_present: {
|
|
20
|
+
ledger: boolean;
|
|
21
|
+
brain_index: boolean;
|
|
22
|
+
tasklist: boolean;
|
|
23
|
+
memory: boolean;
|
|
24
|
+
scratchpad: boolean;
|
|
25
|
+
heartbeat_events: boolean;
|
|
26
|
+
heartbeat_state: boolean;
|
|
27
|
+
heartbeat_prompt: boolean;
|
|
28
|
+
state_md: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface HeartbeatSummary {
|
|
32
|
+
unread_count: number;
|
|
33
|
+
has_prompt: boolean;
|
|
34
|
+
last_read_timestamp: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface TaskCompletion {
|
|
37
|
+
task_number: number;
|
|
38
|
+
task_name: string;
|
|
39
|
+
files_created: string[];
|
|
40
|
+
files_modified: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface PlanTask {
|
|
43
|
+
index: number;
|
|
44
|
+
name: string;
|
|
45
|
+
verify_command: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface PlanPhase {
|
|
48
|
+
number: number;
|
|
49
|
+
name: string;
|
|
50
|
+
complexity: number;
|
|
51
|
+
dependencies: number[];
|
|
52
|
+
tasks: PlanTask[];
|
|
53
|
+
}
|
|
54
|
+
export interface WaveGroup {
|
|
55
|
+
wave_number: number;
|
|
56
|
+
phase_numbers: number[];
|
|
57
|
+
}
|
|
58
|
+
export type ModelTierLevel = 'fast' | 'standard' | 'powerful';
|
|
59
|
+
export interface ModelTier {
|
|
60
|
+
phase: number;
|
|
61
|
+
complexity: number;
|
|
62
|
+
tier: ModelTierLevel;
|
|
63
|
+
model: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CompletedPhase {
|
|
66
|
+
number: number;
|
|
67
|
+
name: string;
|
|
68
|
+
outcome: string;
|
|
69
|
+
}
|
|
70
|
+
export interface Decision {
|
|
71
|
+
decision: string;
|
|
72
|
+
choice: string;
|
|
73
|
+
reason: string;
|
|
74
|
+
}
|
|
75
|
+
export interface Blocker {
|
|
76
|
+
issue: string;
|
|
77
|
+
status: string;
|
|
78
|
+
tried: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ExecutionState {
|
|
81
|
+
active_skill: string | null;
|
|
82
|
+
active_plan: string | null;
|
|
83
|
+
current_phase: {
|
|
84
|
+
number: number;
|
|
85
|
+
name: string;
|
|
86
|
+
} | null;
|
|
87
|
+
current_task: string | null;
|
|
88
|
+
completed_phases: CompletedPhase[];
|
|
89
|
+
decisions: Decision[];
|
|
90
|
+
blockers: Blocker[];
|
|
91
|
+
files_modified: string[];
|
|
92
|
+
next_action: string | null;
|
|
93
|
+
updated_at: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface StateOutput {
|
|
96
|
+
config: FlowConfig;
|
|
97
|
+
session: SessionState;
|
|
98
|
+
heartbeat: HeartbeatSummary;
|
|
99
|
+
execution?: ExecutionState;
|
|
100
|
+
plan?: {
|
|
101
|
+
phases: PlanPhase[];
|
|
102
|
+
waves: WaveGroup[];
|
|
103
|
+
model_tiers: ModelTier[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cli/state/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IA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IAC3B,aAAa,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACvD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,cAAc,EAAE,CAAC;IACnC,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,SAAS,EAAE,CAAC;QACpB,KAAK,EAAE,SAAS,EAAE,CAAC;QACnB,WAAW,EAAE,SAAS,EAAE,CAAC;KAC1B,CAAC;CACH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the deterministic state script (`planflow-ai state`).
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define the JSON output shape produced by parsing
|
|
5
|
+
* plan-flow config files, session state, heartbeat events, and plans.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/cli/state/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave calculator — topological sort of phase dependencies into wave groups.
|
|
3
|
+
*
|
|
4
|
+
* Phases with no dependencies land in wave 1. Each subsequent phase lands in
|
|
5
|
+
* wave = max(wave of each dependency) + 1. A "Tests" phase (last phase whose
|
|
6
|
+
* name contains "test", case-insensitive) is always isolated in the final wave.
|
|
7
|
+
*
|
|
8
|
+
* If a circular dependency is detected the fallback is sequential execution:
|
|
9
|
+
* one phase per wave in phase-number order.
|
|
10
|
+
*/
|
|
11
|
+
import type { PlanPhase, WaveGroup } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Calculate wave groups from plan phases.
|
|
14
|
+
*
|
|
15
|
+
* @returns Sorted array of WaveGroup objects.
|
|
16
|
+
*/
|
|
17
|
+
export declare function calculateWaves(phases: PlanPhase[]): WaveGroup[];
|
|
18
|
+
//# sourceMappingURL=wave-calculator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wave-calculator.d.ts","sourceRoot":"","sources":["../../../src/cli/state/wave-calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA6CvD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAuF/D"}
|