@kata-sh/cli 0.1.0 → 0.1.2
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/LICENSE +21 -0
- package/README.md +156 -0
- package/dist/app-paths.d.ts +4 -0
- package/dist/app-paths.js +6 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +56 -0
- package/dist/loader.d.ts +2 -0
- package/dist/loader.js +95 -0
- package/dist/resource-loader.d.ts +18 -0
- package/dist/resource-loader.js +50 -0
- package/dist/wizard.d.ts +15 -0
- package/dist/wizard.js +159 -0
- package/package.json +50 -21
- package/pkg/dist/modes/interactive/theme/dark.json +85 -0
- package/pkg/dist/modes/interactive/theme/light.json +84 -0
- package/pkg/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/pkg/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/pkg/dist/modes/interactive/theme/theme.js +949 -0
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -0
- package/pkg/package.json +8 -0
- package/scripts/postinstall.js +45 -0
- package/src/resources/AGENTS.md +108 -0
- package/src/resources/KATA-WORKFLOW.md +661 -0
- package/src/resources/agents/researcher.md +29 -0
- package/src/resources/agents/scout.md +56 -0
- package/src/resources/agents/worker.md +31 -0
- package/src/resources/extensions/ask-user-questions.ts +200 -0
- package/src/resources/extensions/bg-shell/index.ts +2758 -0
- package/src/resources/extensions/browser-tools/BROWSER-TOOLS-V2-PROPOSAL.md +1277 -0
- package/src/resources/extensions/browser-tools/core.js +1057 -0
- package/src/resources/extensions/browser-tools/index.ts +4916 -0
- package/src/resources/extensions/browser-tools/package.json +20 -0
- package/src/resources/extensions/context7/index.ts +428 -0
- package/src/resources/extensions/context7/package.json +11 -0
- package/src/resources/extensions/get-secrets-from-user.ts +352 -0
- package/src/resources/extensions/github/formatters.ts +207 -0
- package/src/resources/extensions/github/gh-api.ts +537 -0
- package/src/resources/extensions/github/index.ts +778 -0
- package/src/resources/extensions/kata/activity-log.ts +88 -0
- package/src/resources/extensions/kata/auto.ts +2786 -0
- package/src/resources/extensions/kata/commands.ts +355 -0
- package/src/resources/extensions/kata/crash-recovery.ts +85 -0
- package/src/resources/extensions/kata/dashboard-overlay.ts +516 -0
- package/src/resources/extensions/kata/docs/preferences-reference.md +103 -0
- package/src/resources/extensions/kata/doctor.ts +683 -0
- package/src/resources/extensions/kata/files.ts +730 -0
- package/src/resources/extensions/kata/gitignore.ts +165 -0
- package/src/resources/extensions/kata/guided-flow.ts +976 -0
- package/src/resources/extensions/kata/index.ts +556 -0
- package/src/resources/extensions/kata/metrics.ts +397 -0
- package/src/resources/extensions/kata/observability-validator.ts +408 -0
- package/src/resources/extensions/kata/package.json +11 -0
- package/src/resources/extensions/kata/paths.ts +346 -0
- package/src/resources/extensions/kata/preferences.ts +695 -0
- package/src/resources/extensions/kata/prompt-loader.ts +50 -0
- package/src/resources/extensions/kata/prompts/complete-milestone.md +25 -0
- package/src/resources/extensions/kata/prompts/complete-slice.md +27 -0
- package/src/resources/extensions/kata/prompts/discuss.md +151 -0
- package/src/resources/extensions/kata/prompts/doctor-heal.md +29 -0
- package/src/resources/extensions/kata/prompts/execute-task.md +64 -0
- package/src/resources/extensions/kata/prompts/guided-complete-slice.md +1 -0
- package/src/resources/extensions/kata/prompts/guided-discuss-milestone.md +3 -0
- package/src/resources/extensions/kata/prompts/guided-discuss-slice.md +59 -0
- package/src/resources/extensions/kata/prompts/guided-execute-task.md +1 -0
- package/src/resources/extensions/kata/prompts/guided-plan-milestone.md +23 -0
- package/src/resources/extensions/kata/prompts/guided-plan-slice.md +1 -0
- package/src/resources/extensions/kata/prompts/guided-research-slice.md +11 -0
- package/src/resources/extensions/kata/prompts/guided-resume-task.md +1 -0
- package/src/resources/extensions/kata/prompts/plan-milestone.md +47 -0
- package/src/resources/extensions/kata/prompts/plan-slice.md +63 -0
- package/src/resources/extensions/kata/prompts/queue.md +85 -0
- package/src/resources/extensions/kata/prompts/reassess-roadmap.md +48 -0
- package/src/resources/extensions/kata/prompts/replan-slice.md +39 -0
- package/src/resources/extensions/kata/prompts/research-milestone.md +37 -0
- package/src/resources/extensions/kata/prompts/research-slice.md +28 -0
- package/src/resources/extensions/kata/prompts/run-uat.md +109 -0
- package/src/resources/extensions/kata/prompts/system.md +341 -0
- package/src/resources/extensions/kata/session-forensics.ts +550 -0
- package/src/resources/extensions/kata/skill-discovery.ts +137 -0
- package/src/resources/extensions/kata/state.ts +509 -0
- package/src/resources/extensions/kata/templates/context.md +76 -0
- package/src/resources/extensions/kata/templates/decisions.md +8 -0
- package/src/resources/extensions/kata/templates/milestone-summary.md +73 -0
- package/src/resources/extensions/kata/templates/plan.md +133 -0
- package/src/resources/extensions/kata/templates/preferences.md +15 -0
- package/src/resources/extensions/kata/templates/project.md +31 -0
- package/src/resources/extensions/kata/templates/reassessment.md +28 -0
- package/src/resources/extensions/kata/templates/requirements.md +81 -0
- package/src/resources/extensions/kata/templates/research.md +46 -0
- package/src/resources/extensions/kata/templates/roadmap.md +118 -0
- package/src/resources/extensions/kata/templates/slice-context.md +58 -0
- package/src/resources/extensions/kata/templates/slice-summary.md +99 -0
- package/src/resources/extensions/kata/templates/state.md +19 -0
- package/src/resources/extensions/kata/templates/task-plan.md +52 -0
- package/src/resources/extensions/kata/templates/task-summary.md +57 -0
- package/src/resources/extensions/kata/templates/uat.md +54 -0
- package/src/resources/extensions/kata/tests/activity-log-prune.test.ts +327 -0
- package/src/resources/extensions/kata/tests/auto-preflight.test.ts +97 -0
- package/src/resources/extensions/kata/tests/auto-supervisor.test.mjs +53 -0
- package/src/resources/extensions/kata/tests/complete-milestone.test.ts +317 -0
- package/src/resources/extensions/kata/tests/cost-projection.test.ts +160 -0
- package/src/resources/extensions/kata/tests/derive-state-deps.test.ts +477 -0
- package/src/resources/extensions/kata/tests/derive-state.test.ts +1013 -0
- package/src/resources/extensions/kata/tests/doctor.test.ts +718 -0
- package/src/resources/extensions/kata/tests/idle-recovery.test.ts +490 -0
- package/src/resources/extensions/kata/tests/metrics-io.test.ts +254 -0
- package/src/resources/extensions/kata/tests/metrics.test.ts +217 -0
- package/src/resources/extensions/kata/tests/must-have-parser.test.ts +309 -0
- package/src/resources/extensions/kata/tests/parsers.test.ts +1257 -0
- package/src/resources/extensions/kata/tests/plan-milestone.test.ts +185 -0
- package/src/resources/extensions/kata/tests/plan-quality-validator.test.ts +386 -0
- package/src/resources/extensions/kata/tests/reassess-prompt.test.ts +208 -0
- package/src/resources/extensions/kata/tests/replan-slice.test.ts +686 -0
- package/src/resources/extensions/kata/tests/requirements.test.ts +151 -0
- package/src/resources/extensions/kata/tests/resolve-ts-hooks.mjs +17 -0
- package/src/resources/extensions/kata/tests/resolve-ts.mjs +11 -0
- package/src/resources/extensions/kata/tests/run-uat.test.ts +383 -0
- package/src/resources/extensions/kata/tests/unit-runtime.test.ts +388 -0
- package/src/resources/extensions/kata/tests/workspace-index.test.ts +118 -0
- package/src/resources/extensions/kata/tests/worktree.test.ts +222 -0
- package/src/resources/extensions/kata/types.ts +159 -0
- package/src/resources/extensions/kata/unit-runtime.ts +163 -0
- package/src/resources/extensions/kata/workspace-index.ts +203 -0
- package/src/resources/extensions/kata/worktree.ts +182 -0
- package/src/resources/extensions/mac-tools/index.ts +852 -0
- package/src/resources/extensions/mac-tools/swift-cli/Package.swift +22 -0
- package/src/resources/extensions/mac-tools/swift-cli/Sources/main.swift +1318 -0
- package/src/resources/extensions/search-the-web/cache.ts +78 -0
- package/src/resources/extensions/search-the-web/format.ts +258 -0
- package/src/resources/extensions/search-the-web/http.ts +238 -0
- package/src/resources/extensions/search-the-web/index.ts +68 -0
- package/src/resources/extensions/search-the-web/tool-fetch-page.ts +519 -0
- package/src/resources/extensions/search-the-web/tool-llm-context.ts +404 -0
- package/src/resources/extensions/search-the-web/tool-search.ts +503 -0
- package/src/resources/extensions/search-the-web/url-utils.ts +91 -0
- package/src/resources/extensions/shared/confirm-ui.ts +126 -0
- package/src/resources/extensions/shared/interview-ui.ts +822 -0
- package/src/resources/extensions/shared/next-action-ui.ts +235 -0
- package/src/resources/extensions/shared/progress-widget.ts +282 -0
- package/src/resources/extensions/shared/thinking-widget.ts +107 -0
- package/src/resources/extensions/shared/ui.ts +400 -0
- package/src/resources/extensions/shared/wizard-ui.ts +551 -0
- package/src/resources/extensions/slash-commands/audit.ts +92 -0
- package/src/resources/extensions/slash-commands/create-extension.ts +375 -0
- package/src/resources/extensions/slash-commands/create-slash-command.ts +280 -0
- package/src/resources/extensions/slash-commands/index.ts +12 -0
- package/src/resources/extensions/slash-commands/kata-run.ts +34 -0
- package/src/resources/extensions/subagent/agents.ts +126 -0
- package/src/resources/extensions/subagent/index.ts +1293 -0
- package/src/resources/skills/debug-like-expert/SKILL.md +231 -0
- package/src/resources/skills/debug-like-expert/references/debugging-mindset.md +253 -0
- package/src/resources/skills/debug-like-expert/references/hypothesis-testing.md +373 -0
- package/src/resources/skills/debug-like-expert/references/investigation-techniques.md +337 -0
- package/src/resources/skills/debug-like-expert/references/verification-patterns.md +425 -0
- package/src/resources/skills/debug-like-expert/references/when-to-research.md +361 -0
- package/src/resources/skills/frontend-design/SKILL.md +45 -0
- package/src/resources/skills/swiftui/SKILL.md +208 -0
- package/src/resources/skills/swiftui/references/animations.md +921 -0
- package/src/resources/skills/swiftui/references/architecture.md +1561 -0
- package/src/resources/skills/swiftui/references/layout-system.md +1186 -0
- package/src/resources/skills/swiftui/references/navigation.md +1492 -0
- package/src/resources/skills/swiftui/references/networking-async.md +214 -0
- package/src/resources/skills/swiftui/references/performance.md +1706 -0
- package/src/resources/skills/swiftui/references/platform-integration.md +204 -0
- package/src/resources/skills/swiftui/references/state-management.md +1443 -0
- package/src/resources/skills/swiftui/references/swiftdata.md +297 -0
- package/src/resources/skills/swiftui/references/testing-debugging.md +247 -0
- package/src/resources/skills/swiftui/references/uikit-appkit-interop.md +218 -0
- package/src/resources/skills/swiftui/workflows/add-feature.md +191 -0
- package/src/resources/skills/swiftui/workflows/build-new-app.md +311 -0
- package/src/resources/skills/swiftui/workflows/debug-swiftui.md +192 -0
- package/src/resources/skills/swiftui/workflows/optimize-performance.md +197 -0
- package/src/resources/skills/swiftui/workflows/ship-app.md +203 -0
- package/src/resources/skills/swiftui/workflows/write-tests.md +235 -0
- package/dist/commands/task.d.ts +0 -9
- package/dist/commands/task.d.ts.map +0 -1
- package/dist/commands/task.js +0 -129
- package/dist/commands/task.js.map +0 -1
- package/dist/commands/task.test.d.ts +0 -2
- package/dist/commands/task.test.d.ts.map +0 -1
- package/dist/commands/task.test.js +0 -169
- package/dist/commands/task.test.js.map +0 -1
- package/dist/e2e/task-e2e.test.d.ts +0 -2
- package/dist/e2e/task-e2e.test.d.ts.map +0 -1
- package/dist/e2e/task-e2e.test.js +0 -173
- package/dist/e2e/task-e2e.test.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -93
- package/dist/index.js.map +0 -1
- package/dist/slug.d.ts +0 -2
- package/dist/slug.d.ts.map +0 -1
- package/dist/slug.js +0 -12
- package/dist/slug.js.map +0 -1
- package/dist/slug.test.d.ts +0 -2
- package/dist/slug.test.d.ts.map +0 -1
- package/dist/slug.test.js +0 -32
- package/dist/slug.test.js.map +0 -1
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
// Kata Extension — State Derivation
|
|
2
|
+
// Reads roadmap + plan files to determine current position.
|
|
3
|
+
// Pure TypeScript, zero Pi dependencies.
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
KataState,
|
|
7
|
+
ActiveRef,
|
|
8
|
+
Roadmap,
|
|
9
|
+
RoadmapSliceEntry,
|
|
10
|
+
SlicePlan,
|
|
11
|
+
MilestoneRegistryEntry,
|
|
12
|
+
} from "./types.ts";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
parseRoadmap,
|
|
16
|
+
parsePlan,
|
|
17
|
+
parseSummary,
|
|
18
|
+
loadFile,
|
|
19
|
+
parseRequirementCounts,
|
|
20
|
+
parseContextDependsOn,
|
|
21
|
+
} from "./files.ts";
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
milestonesDir,
|
|
25
|
+
resolveMilestonePath,
|
|
26
|
+
resolveMilestoneFile,
|
|
27
|
+
resolveSlicePath,
|
|
28
|
+
resolveSliceFile,
|
|
29
|
+
resolveTaskFile,
|
|
30
|
+
resolveKataRootFile,
|
|
31
|
+
} from "./paths.ts";
|
|
32
|
+
import { getActiveSliceBranch } from "./worktree.ts";
|
|
33
|
+
|
|
34
|
+
import { readdirSync } from "fs";
|
|
35
|
+
import { join } from "path";
|
|
36
|
+
|
|
37
|
+
// ─── Query Functions ───────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check if all tasks in a slice plan are done.
|
|
41
|
+
*/
|
|
42
|
+
export function isSliceComplete(plan: SlicePlan): boolean {
|
|
43
|
+
return plan.tasks.length > 0 && plan.tasks.every((t) => t.done);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Check if all slices in a roadmap are done.
|
|
48
|
+
*/
|
|
49
|
+
export function isMilestoneComplete(roadmap: Roadmap): boolean {
|
|
50
|
+
return roadmap.slices.length > 0 && roadmap.slices.every((s) => s.done);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ─── State Derivation ──────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Find all milestone directory IDs by scanning .kata/milestones/.
|
|
57
|
+
* Extracts the ID prefix (e.g. "M001") from directory names like "M001-PAYMENT-INTEGRATIONS".
|
|
58
|
+
*/
|
|
59
|
+
function findMilestoneIds(basePath: string): string[] {
|
|
60
|
+
const dir = milestonesDir(basePath);
|
|
61
|
+
try {
|
|
62
|
+
return readdirSync(dir, { withFileTypes: true })
|
|
63
|
+
.filter((d) => d.isDirectory())
|
|
64
|
+
.map((d) => {
|
|
65
|
+
const match = d.name.match(/^(M\d+)/);
|
|
66
|
+
return match ? match[1] : d.name;
|
|
67
|
+
})
|
|
68
|
+
.sort();
|
|
69
|
+
} catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Returns the ID of the first incomplete milestone, or null if all are complete.
|
|
76
|
+
*/
|
|
77
|
+
export async function getActiveMilestoneId(
|
|
78
|
+
basePath: string,
|
|
79
|
+
): Promise<string | null> {
|
|
80
|
+
const milestoneIds = findMilestoneIds(basePath);
|
|
81
|
+
for (const mid of milestoneIds) {
|
|
82
|
+
const roadmapFile = resolveMilestoneFile(basePath, mid, "ROADMAP");
|
|
83
|
+
const content = roadmapFile ? await loadFile(roadmapFile) : null;
|
|
84
|
+
if (!content) {
|
|
85
|
+
// No roadmap — but if a summary exists, the milestone is already complete
|
|
86
|
+
const summaryFile = resolveMilestoneFile(basePath, mid, "SUMMARY");
|
|
87
|
+
if (summaryFile) continue; // completed milestone, skip
|
|
88
|
+
return mid; // No roadmap and no summary — milestone is incomplete
|
|
89
|
+
}
|
|
90
|
+
const roadmap = parseRoadmap(content);
|
|
91
|
+
if (!isMilestoneComplete(roadmap)) return mid;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Reconstruct Kata state from files on disk.
|
|
98
|
+
* This is the source of truth — STATE.md is just a cache of this output.
|
|
99
|
+
*/
|
|
100
|
+
export async function deriveState(basePath: string): Promise<KataState> {
|
|
101
|
+
const milestoneIds = findMilestoneIds(basePath);
|
|
102
|
+
const requirements = parseRequirementCounts(
|
|
103
|
+
await loadFile(resolveKataRootFile(basePath, "REQUIREMENTS")),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (milestoneIds.length === 0) {
|
|
107
|
+
return {
|
|
108
|
+
activeMilestone: null,
|
|
109
|
+
activeSlice: null,
|
|
110
|
+
activeTask: null,
|
|
111
|
+
phase: "pre-planning",
|
|
112
|
+
recentDecisions: [],
|
|
113
|
+
blockers: [],
|
|
114
|
+
nextAction: "No milestones found. Run /kata to create one.",
|
|
115
|
+
registry: [],
|
|
116
|
+
requirements,
|
|
117
|
+
progress: {
|
|
118
|
+
milestones: { done: 0, total: 0 },
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Pre-compute the set of complete milestone IDs for dependency checking.
|
|
124
|
+
// This allows forward references (M002 depending on M003) to resolve correctly.
|
|
125
|
+
const completeMilestoneIds = new Set<string>();
|
|
126
|
+
for (const mid of milestoneIds) {
|
|
127
|
+
const rf = resolveMilestoneFile(basePath, mid, "ROADMAP");
|
|
128
|
+
const rc = rf ? await loadFile(rf) : null;
|
|
129
|
+
if (!rc) {
|
|
130
|
+
// No roadmap — milestone is complete if it has a summary
|
|
131
|
+
const sf = resolveMilestoneFile(basePath, mid, "SUMMARY");
|
|
132
|
+
if (sf) completeMilestoneIds.add(mid);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const rmap = parseRoadmap(rc);
|
|
136
|
+
if (!isMilestoneComplete(rmap)) continue;
|
|
137
|
+
const sf = resolveMilestoneFile(basePath, mid, "SUMMARY");
|
|
138
|
+
if (sf) completeMilestoneIds.add(mid);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Build the registry and locate the active milestone in a single pass.
|
|
142
|
+
const registry: MilestoneRegistryEntry[] = [];
|
|
143
|
+
let activeMilestone: ActiveRef | null = null;
|
|
144
|
+
let activeRoadmap: Roadmap | null = null;
|
|
145
|
+
let activeMilestoneFound = false;
|
|
146
|
+
|
|
147
|
+
for (const mid of milestoneIds) {
|
|
148
|
+
const roadmapFile = resolveMilestoneFile(basePath, mid, "ROADMAP");
|
|
149
|
+
const content = roadmapFile ? await loadFile(roadmapFile) : null;
|
|
150
|
+
if (!content) {
|
|
151
|
+
// No roadmap — check if a summary exists (completed milestone without roadmap)
|
|
152
|
+
const summaryFile = resolveMilestoneFile(basePath, mid, "SUMMARY");
|
|
153
|
+
if (summaryFile) {
|
|
154
|
+
const summaryContent = await loadFile(summaryFile);
|
|
155
|
+
const summaryTitle = summaryContent
|
|
156
|
+
? parseSummary(summaryContent).title || mid
|
|
157
|
+
: mid;
|
|
158
|
+
registry.push({ id: mid, title: summaryTitle, status: "complete" });
|
|
159
|
+
completeMilestoneIds.add(mid);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
// No roadmap and no summary — treat as incomplete/active
|
|
163
|
+
if (!activeMilestoneFound) {
|
|
164
|
+
activeMilestone = { id: mid, title: mid };
|
|
165
|
+
activeMilestoneFound = true;
|
|
166
|
+
registry.push({ id: mid, title: mid, status: "active" });
|
|
167
|
+
} else {
|
|
168
|
+
registry.push({ id: mid, title: mid, status: "pending" });
|
|
169
|
+
}
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const roadmap = parseRoadmap(content);
|
|
174
|
+
const title = roadmap.title.replace(/^M\d+[^:]*:\s*/, "");
|
|
175
|
+
const complete = isMilestoneComplete(roadmap);
|
|
176
|
+
|
|
177
|
+
if (complete) {
|
|
178
|
+
// All slices done — check if milestone summary exists
|
|
179
|
+
const summaryFile = resolveMilestoneFile(basePath, mid, "SUMMARY");
|
|
180
|
+
if (!summaryFile && !activeMilestoneFound) {
|
|
181
|
+
// All slices complete but no summary written yet → completing-milestone
|
|
182
|
+
activeMilestone = { id: mid, title };
|
|
183
|
+
activeRoadmap = roadmap;
|
|
184
|
+
activeMilestoneFound = true;
|
|
185
|
+
registry.push({ id: mid, title, status: "active" });
|
|
186
|
+
} else {
|
|
187
|
+
registry.push({ id: mid, title, status: "complete" });
|
|
188
|
+
}
|
|
189
|
+
} else if (!activeMilestoneFound) {
|
|
190
|
+
// Check milestone-level dependencies before promoting to active
|
|
191
|
+
const contextFile = resolveMilestoneFile(basePath, mid, "CONTEXT");
|
|
192
|
+
const contextContent = contextFile ? await loadFile(contextFile) : null;
|
|
193
|
+
const deps = parseContextDependsOn(contextContent);
|
|
194
|
+
const depsUnmet = deps.some((dep) => !completeMilestoneIds.has(dep));
|
|
195
|
+
if (depsUnmet) {
|
|
196
|
+
registry.push({ id: mid, title, status: "pending", dependsOn: deps });
|
|
197
|
+
// Do NOT set activeMilestoneFound — let the loop continue to the next milestone
|
|
198
|
+
} else {
|
|
199
|
+
activeMilestone = { id: mid, title };
|
|
200
|
+
activeRoadmap = roadmap;
|
|
201
|
+
activeMilestoneFound = true;
|
|
202
|
+
registry.push({
|
|
203
|
+
id: mid,
|
|
204
|
+
title,
|
|
205
|
+
status: "active",
|
|
206
|
+
...(deps.length > 0 ? { dependsOn: deps } : {}),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
const contextFile2 = resolveMilestoneFile(basePath, mid, "CONTEXT");
|
|
211
|
+
const contextContent2 = contextFile2
|
|
212
|
+
? await loadFile(contextFile2)
|
|
213
|
+
: null;
|
|
214
|
+
const deps2 = parseContextDependsOn(contextContent2);
|
|
215
|
+
registry.push({
|
|
216
|
+
id: mid,
|
|
217
|
+
title,
|
|
218
|
+
status: "pending",
|
|
219
|
+
...(deps2.length > 0 ? { dependsOn: deps2 } : {}),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const milestoneProgress = {
|
|
225
|
+
done: registry.filter((entry) => entry.status === "complete").length,
|
|
226
|
+
total: registry.length,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
if (!activeMilestone) {
|
|
230
|
+
// Check whether any milestones are pending (dep-blocked) vs all complete
|
|
231
|
+
const pendingEntries = registry.filter(
|
|
232
|
+
(entry) => entry.status === "pending",
|
|
233
|
+
);
|
|
234
|
+
if (pendingEntries.length > 0) {
|
|
235
|
+
// All incomplete milestones are dep-blocked — no progress possible
|
|
236
|
+
const blockerDetails = pendingEntries
|
|
237
|
+
.filter((entry) => entry.dependsOn && entry.dependsOn.length > 0)
|
|
238
|
+
.map(
|
|
239
|
+
(entry) =>
|
|
240
|
+
`${entry.id} is waiting on unmet deps: ${entry.dependsOn!.join(", ")}`,
|
|
241
|
+
);
|
|
242
|
+
return {
|
|
243
|
+
activeMilestone: null,
|
|
244
|
+
activeSlice: null,
|
|
245
|
+
activeTask: null,
|
|
246
|
+
phase: "blocked",
|
|
247
|
+
recentDecisions: [],
|
|
248
|
+
blockers:
|
|
249
|
+
blockerDetails.length > 0
|
|
250
|
+
? blockerDetails
|
|
251
|
+
: [
|
|
252
|
+
"All remaining milestones are dep-blocked but no deps listed — check CONTEXT.md files",
|
|
253
|
+
],
|
|
254
|
+
nextAction: "Resolve milestone dependencies before proceeding.",
|
|
255
|
+
registry,
|
|
256
|
+
requirements,
|
|
257
|
+
progress: {
|
|
258
|
+
milestones: milestoneProgress,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// All milestones complete
|
|
263
|
+
const lastEntry = registry[registry.length - 1];
|
|
264
|
+
return {
|
|
265
|
+
activeMilestone: lastEntry
|
|
266
|
+
? { id: lastEntry.id, title: lastEntry.title }
|
|
267
|
+
: null,
|
|
268
|
+
activeSlice: null,
|
|
269
|
+
activeTask: null,
|
|
270
|
+
phase: "complete",
|
|
271
|
+
recentDecisions: [],
|
|
272
|
+
blockers: [],
|
|
273
|
+
nextAction: "All milestones complete.",
|
|
274
|
+
registry,
|
|
275
|
+
requirements,
|
|
276
|
+
progress: {
|
|
277
|
+
milestones: milestoneProgress,
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (!activeRoadmap) {
|
|
283
|
+
// Active milestone exists but has no roadmap yet — needs planning
|
|
284
|
+
return {
|
|
285
|
+
activeMilestone,
|
|
286
|
+
activeSlice: null,
|
|
287
|
+
activeTask: null,
|
|
288
|
+
phase: "pre-planning",
|
|
289
|
+
recentDecisions: [],
|
|
290
|
+
blockers: [],
|
|
291
|
+
nextAction: `Plan milestone ${activeMilestone.id}.`,
|
|
292
|
+
registry,
|
|
293
|
+
requirements,
|
|
294
|
+
progress: {
|
|
295
|
+
milestones: milestoneProgress,
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Check if active milestone needs completion (all slices done, no summary)
|
|
301
|
+
if (isMilestoneComplete(activeRoadmap)) {
|
|
302
|
+
const sliceProgress = {
|
|
303
|
+
done: activeRoadmap.slices.length,
|
|
304
|
+
total: activeRoadmap.slices.length,
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
activeMilestone,
|
|
308
|
+
activeSlice: null,
|
|
309
|
+
activeTask: null,
|
|
310
|
+
phase: "completing-milestone",
|
|
311
|
+
recentDecisions: [],
|
|
312
|
+
blockers: [],
|
|
313
|
+
nextAction: `All slices complete in ${activeMilestone.id}. Write milestone summary.`,
|
|
314
|
+
registry,
|
|
315
|
+
requirements,
|
|
316
|
+
progress: {
|
|
317
|
+
milestones: milestoneProgress,
|
|
318
|
+
slices: sliceProgress,
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const sliceProgress = {
|
|
324
|
+
done: activeRoadmap.slices.filter((s) => s.done).length,
|
|
325
|
+
total: activeRoadmap.slices.length,
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// Find the active slice (first incomplete with deps satisfied)
|
|
329
|
+
const doneSliceIds = new Set(
|
|
330
|
+
activeRoadmap.slices.filter((s) => s.done).map((s) => s.id),
|
|
331
|
+
);
|
|
332
|
+
let activeSlice: ActiveRef | null = null;
|
|
333
|
+
|
|
334
|
+
for (const s of activeRoadmap.slices) {
|
|
335
|
+
if (s.done) continue;
|
|
336
|
+
if (s.depends.every((dep) => doneSliceIds.has(dep))) {
|
|
337
|
+
activeSlice = { id: s.id, title: s.title };
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (!activeSlice) {
|
|
343
|
+
return {
|
|
344
|
+
activeMilestone,
|
|
345
|
+
activeSlice: null,
|
|
346
|
+
activeTask: null,
|
|
347
|
+
phase: "blocked",
|
|
348
|
+
recentDecisions: [],
|
|
349
|
+
blockers: ["No slice eligible — check dependency ordering"],
|
|
350
|
+
nextAction: "Resolve dependency blockers or plan next slice.",
|
|
351
|
+
registry,
|
|
352
|
+
requirements,
|
|
353
|
+
progress: {
|
|
354
|
+
milestones: milestoneProgress,
|
|
355
|
+
slices: sliceProgress,
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const activeBranch = getActiveSliceBranch(basePath);
|
|
361
|
+
|
|
362
|
+
// Check if the slice has a plan
|
|
363
|
+
const planFile = resolveSliceFile(
|
|
364
|
+
basePath,
|
|
365
|
+
activeMilestone.id,
|
|
366
|
+
activeSlice.id,
|
|
367
|
+
"PLAN",
|
|
368
|
+
);
|
|
369
|
+
const slicePlanContent = planFile ? await loadFile(planFile) : null;
|
|
370
|
+
|
|
371
|
+
if (!slicePlanContent) {
|
|
372
|
+
return {
|
|
373
|
+
activeMilestone,
|
|
374
|
+
activeSlice,
|
|
375
|
+
activeTask: null,
|
|
376
|
+
phase: "planning",
|
|
377
|
+
recentDecisions: [],
|
|
378
|
+
blockers: [],
|
|
379
|
+
nextAction: `Plan slice ${activeSlice.id} (${activeSlice.title}).`,
|
|
380
|
+
activeBranch: activeBranch ?? undefined,
|
|
381
|
+
registry,
|
|
382
|
+
requirements,
|
|
383
|
+
progress: {
|
|
384
|
+
milestones: milestoneProgress,
|
|
385
|
+
slices: sliceProgress,
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const slicePlan = parsePlan(slicePlanContent);
|
|
391
|
+
const taskProgress = {
|
|
392
|
+
done: slicePlan.tasks.filter((t) => t.done).length,
|
|
393
|
+
total: slicePlan.tasks.length,
|
|
394
|
+
};
|
|
395
|
+
const activeTaskEntry = slicePlan.tasks.find((t) => !t.done);
|
|
396
|
+
|
|
397
|
+
if (!activeTaskEntry) {
|
|
398
|
+
// All tasks done but slice not marked complete
|
|
399
|
+
return {
|
|
400
|
+
activeMilestone,
|
|
401
|
+
activeSlice,
|
|
402
|
+
activeTask: null,
|
|
403
|
+
phase: "summarizing",
|
|
404
|
+
recentDecisions: [],
|
|
405
|
+
blockers: [],
|
|
406
|
+
nextAction: `All tasks done in ${activeSlice.id}. Write slice summary and complete slice.`,
|
|
407
|
+
activeBranch: activeBranch ?? undefined,
|
|
408
|
+
registry,
|
|
409
|
+
requirements,
|
|
410
|
+
progress: {
|
|
411
|
+
milestones: milestoneProgress,
|
|
412
|
+
slices: sliceProgress,
|
|
413
|
+
tasks: taskProgress,
|
|
414
|
+
},
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const activeTask: ActiveRef = {
|
|
419
|
+
id: activeTaskEntry.id,
|
|
420
|
+
title: activeTaskEntry.title,
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// ── Blocker detection: scan completed task summaries ──────────────────
|
|
424
|
+
// If any completed task has blocker_discovered: true and no REPLAN.md
|
|
425
|
+
// exists yet, transition to replanning-slice instead of executing.
|
|
426
|
+
const completedTasks = slicePlan.tasks.filter((t) => t.done);
|
|
427
|
+
let blockerTaskId: string | null = null;
|
|
428
|
+
for (const ct of completedTasks) {
|
|
429
|
+
const summaryFile = resolveTaskFile(
|
|
430
|
+
basePath,
|
|
431
|
+
activeMilestone.id,
|
|
432
|
+
activeSlice.id,
|
|
433
|
+
ct.id,
|
|
434
|
+
"SUMMARY",
|
|
435
|
+
);
|
|
436
|
+
if (!summaryFile) continue;
|
|
437
|
+
const summaryContent = await loadFile(summaryFile);
|
|
438
|
+
if (!summaryContent) continue;
|
|
439
|
+
const summary = parseSummary(summaryContent);
|
|
440
|
+
if (summary.frontmatter.blocker_discovered) {
|
|
441
|
+
blockerTaskId = ct.id;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (blockerTaskId) {
|
|
447
|
+
// Loop protection: if REPLAN.md already exists, a replan was already
|
|
448
|
+
// performed for this slice — skip further replanning and continue executing.
|
|
449
|
+
const replanFile = resolveSliceFile(
|
|
450
|
+
basePath,
|
|
451
|
+
activeMilestone.id,
|
|
452
|
+
activeSlice.id,
|
|
453
|
+
"REPLAN",
|
|
454
|
+
);
|
|
455
|
+
if (!replanFile) {
|
|
456
|
+
return {
|
|
457
|
+
activeMilestone,
|
|
458
|
+
activeSlice,
|
|
459
|
+
activeTask,
|
|
460
|
+
phase: "replanning-slice",
|
|
461
|
+
recentDecisions: [],
|
|
462
|
+
blockers: [
|
|
463
|
+
`Task ${blockerTaskId} discovered a blocker requiring slice replan`,
|
|
464
|
+
],
|
|
465
|
+
nextAction: `Task ${blockerTaskId} reported blocker_discovered. Replan slice ${activeSlice.id} before continuing.`,
|
|
466
|
+
activeBranch: activeBranch ?? undefined,
|
|
467
|
+
activeWorkspace: undefined,
|
|
468
|
+
registry,
|
|
469
|
+
requirements,
|
|
470
|
+
progress: {
|
|
471
|
+
milestones: milestoneProgress,
|
|
472
|
+
slices: sliceProgress,
|
|
473
|
+
tasks: taskProgress,
|
|
474
|
+
},
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
// REPLAN.md exists — loop protection: fall through to normal executing
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// Check for interrupted work
|
|
481
|
+
const sDir = resolveSlicePath(basePath, activeMilestone.id, activeSlice.id);
|
|
482
|
+
const continueFile = sDir
|
|
483
|
+
? resolveSliceFile(basePath, activeMilestone.id, activeSlice.id, "CONTINUE")
|
|
484
|
+
: null;
|
|
485
|
+
// Also check legacy continue.md
|
|
486
|
+
const hasInterrupted =
|
|
487
|
+
!!(continueFile && (await loadFile(continueFile))) ||
|
|
488
|
+
!!(sDir && (await loadFile(join(sDir, "continue.md"))));
|
|
489
|
+
|
|
490
|
+
return {
|
|
491
|
+
activeMilestone,
|
|
492
|
+
activeSlice,
|
|
493
|
+
activeTask,
|
|
494
|
+
phase: "executing",
|
|
495
|
+
recentDecisions: [],
|
|
496
|
+
blockers: [],
|
|
497
|
+
nextAction: hasInterrupted
|
|
498
|
+
? `Resume interrupted work on ${activeTask.id}: ${activeTask.title} in slice ${activeSlice.id}. Read continue.md first.`
|
|
499
|
+
: `Execute ${activeTask.id}: ${activeTask.title} in slice ${activeSlice.id}.`,
|
|
500
|
+
activeBranch: activeBranch ?? undefined,
|
|
501
|
+
registry,
|
|
502
|
+
requirements,
|
|
503
|
+
progress: {
|
|
504
|
+
milestones: milestoneProgress,
|
|
505
|
+
slices: sliceProgress,
|
|
506
|
+
tasks: taskProgress,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# {{milestoneId}}: {{milestoneTitle}} — Context
|
|
2
|
+
|
|
3
|
+
**Gathered:** {{date}}
|
|
4
|
+
**Status:** Ready for planning
|
|
5
|
+
|
|
6
|
+
## Project Description
|
|
7
|
+
|
|
8
|
+
{{description}}
|
|
9
|
+
|
|
10
|
+
## Why This Milestone
|
|
11
|
+
|
|
12
|
+
{{whatProblemThisSolves_AND_whyNow}}
|
|
13
|
+
|
|
14
|
+
## User-Visible Outcome
|
|
15
|
+
|
|
16
|
+
### When this milestone is complete, the user can:
|
|
17
|
+
|
|
18
|
+
- {{literalUserActionInRealEnvironment}}
|
|
19
|
+
- {{literalUserActionInRealEnvironment}}
|
|
20
|
+
|
|
21
|
+
### Entry point / environment
|
|
22
|
+
|
|
23
|
+
- Entry point: {{CLI command / URL / bot / extension / service / workflow}}
|
|
24
|
+
- Environment: {{local dev / browser / mobile / launchd / CI / production-like}}
|
|
25
|
+
- Live dependencies involved: {{telegram / database / webhook / rpc subprocess / none}}
|
|
26
|
+
|
|
27
|
+
## Completion Class
|
|
28
|
+
|
|
29
|
+
- Contract complete means: {{what can be proven by tests / fixtures / artifacts}}
|
|
30
|
+
- Integration complete means: {{what must work across real subsystems}}
|
|
31
|
+
- Operational complete means: {{what must work under real lifecycle conditions, or none}}
|
|
32
|
+
|
|
33
|
+
## Final Integrated Acceptance
|
|
34
|
+
|
|
35
|
+
To call this milestone complete, we must prove:
|
|
36
|
+
|
|
37
|
+
- {{one real end-to-end scenario}}
|
|
38
|
+
- {{one real end-to-end scenario}}
|
|
39
|
+
- {{what cannot be simulated if this milestone is to be considered truly done}}
|
|
40
|
+
|
|
41
|
+
## Risks and Unknowns
|
|
42
|
+
|
|
43
|
+
- {{riskOrUnknown}} — {{whyItMatters}}
|
|
44
|
+
|
|
45
|
+
## Existing Codebase / Prior Art
|
|
46
|
+
|
|
47
|
+
- `{{fileOrModule}}` — {{howItRelates}}
|
|
48
|
+
- `{{fileOrModule}}` — {{howItRelates}}
|
|
49
|
+
|
|
50
|
+
> See `.kata/DECISIONS.md` for all architectural and pattern decisions — it is an append-only register; read it during planning, append to it during execution.
|
|
51
|
+
|
|
52
|
+
## Relevant Requirements
|
|
53
|
+
|
|
54
|
+
- {{requirementId}} — {{howThisMilestoneAdvancesIt}}
|
|
55
|
+
|
|
56
|
+
## Scope
|
|
57
|
+
|
|
58
|
+
### In Scope
|
|
59
|
+
|
|
60
|
+
- {{inScopeItem}}
|
|
61
|
+
|
|
62
|
+
### Out of Scope / Non-Goals
|
|
63
|
+
|
|
64
|
+
- {{outOfScopeItem}}
|
|
65
|
+
|
|
66
|
+
## Technical Constraints
|
|
67
|
+
|
|
68
|
+
- {{constraint}}
|
|
69
|
+
|
|
70
|
+
## Integration Points
|
|
71
|
+
|
|
72
|
+
- {{systemOrService}} — {{howThisMilestoneInteractsWithIt}}
|
|
73
|
+
|
|
74
|
+
## Open Questions
|
|
75
|
+
|
|
76
|
+
- {{question}} — {{currentThinking}}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Decisions Register
|
|
2
|
+
|
|
3
|
+
<!-- Append-only. Never edit or remove existing rows.
|
|
4
|
+
To reverse a decision, add a new row that supersedes it.
|
|
5
|
+
Read this file at the start of any planning or research phase. -->
|
|
6
|
+
|
|
7
|
+
| # | When | Scope | Decision | Choice | Rationale | Revisable? |
|
|
8
|
+
|---|------|-------|----------|--------|-----------|------------|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: {{milestoneId}}
|
|
3
|
+
provides:
|
|
4
|
+
- {{whatThisMilestoneProvides}}
|
|
5
|
+
key_decisions:
|
|
6
|
+
- {{decision}}
|
|
7
|
+
patterns_established:
|
|
8
|
+
- {{pattern}}
|
|
9
|
+
observability_surfaces:
|
|
10
|
+
- {{status endpoint, structured log, persisted failure state, diagnostic command, or none}}
|
|
11
|
+
requirement_outcomes:
|
|
12
|
+
- id: {{requirementId}}
|
|
13
|
+
from_status: {{active|blocked|deferred}}
|
|
14
|
+
to_status: {{validated|deferred|blocked|out_of_scope}}
|
|
15
|
+
proof: {{whatEvidenceSupportsThisTransition}}
|
|
16
|
+
duration: {{duration}}
|
|
17
|
+
verification_result: passed
|
|
18
|
+
completed_at: {{date}}
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# {{milestoneId}}: {{milestoneTitle}}
|
|
22
|
+
|
|
23
|
+
<!-- One-liner must say what the milestone actually delivered, not just that it completed.
|
|
24
|
+
Good: "State machine integrity with completing-milestone gating, doctor audits, and observability validation"
|
|
25
|
+
Bad: "Milestone 2 completed" -->
|
|
26
|
+
|
|
27
|
+
**{{oneLiner}}**
|
|
28
|
+
|
|
29
|
+
## What Happened
|
|
30
|
+
|
|
31
|
+
<!-- Cross-slice narrative: compress all slice summaries into a coherent story.
|
|
32
|
+
Focus on what was built, how the slices connected, and what the milestone
|
|
33
|
+
achieved as a whole — not a task-by-task replay. -->
|
|
34
|
+
|
|
35
|
+
{{crossSliceNarrative}}
|
|
36
|
+
|
|
37
|
+
## Cross-Slice Verification
|
|
38
|
+
|
|
39
|
+
<!-- How were the milestone's success criteria verified?
|
|
40
|
+
Reference specific tests, commands, browser checks, or observable behaviors.
|
|
41
|
+
Each success criterion from the roadmap should have a corresponding verification entry. -->
|
|
42
|
+
|
|
43
|
+
{{howSuccessCriteriaWereVerified}}
|
|
44
|
+
|
|
45
|
+
## Requirement Changes
|
|
46
|
+
|
|
47
|
+
<!-- Transitions with evidence. Each requirement that changed status during this milestone
|
|
48
|
+
should be listed with the proof that supports the transition. -->
|
|
49
|
+
|
|
50
|
+
- {{requirementId}}: {{fromStatus}} → {{toStatus}} — {{evidence}}
|
|
51
|
+
|
|
52
|
+
## Forward Intelligence
|
|
53
|
+
|
|
54
|
+
<!-- Write what you wish you'd known at the start of this milestone.
|
|
55
|
+
This section is read by the next milestone's planning and research steps.
|
|
56
|
+
Be specific and concrete — this is the most valuable context you can transfer. -->
|
|
57
|
+
|
|
58
|
+
### What the next milestone should know
|
|
59
|
+
- {{insightThatWouldHelpDownstreamWork}}
|
|
60
|
+
|
|
61
|
+
### What's fragile
|
|
62
|
+
- {{fragileAreaOrThinImplementation}} — {{whyItMatters}}
|
|
63
|
+
|
|
64
|
+
### Authoritative diagnostics
|
|
65
|
+
- {{whereAFutureAgentShouldLookFirst}} — {{whyThisSignalIsTrustworthy}}
|
|
66
|
+
|
|
67
|
+
### What assumptions changed
|
|
68
|
+
- {{originalAssumption}} — {{whatActuallyHappened}}
|
|
69
|
+
|
|
70
|
+
## Files Created/Modified
|
|
71
|
+
|
|
72
|
+
- `{{filePath}}` — {{description}}
|
|
73
|
+
- `{{filePath}}` — {{description}}
|