gsd-pi 2.67.0-dev.509bd95 → 2.67.0-dev.5399650

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 (125) hide show
  1. package/dist/resources/extensions/gsd/auto/session.js +6 -0
  2. package/dist/resources/extensions/gsd/auto.js +27 -0
  3. package/dist/resources/extensions/gsd/init-wizard.js +34 -0
  4. package/dist/resources/extensions/gsd/workflow-mcp.js +38 -7
  5. package/dist/web/standalone/.next/BUILD_ID +1 -1
  6. package/dist/web/standalone/.next/app-path-routes-manifest.json +11 -11
  7. package/dist/web/standalone/.next/build-manifest.json +2 -2
  8. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  9. package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
  10. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  11. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  12. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  13. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  14. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  15. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  16. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  17. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  18. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  19. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  20. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/index.html +1 -1
  26. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app-paths-manifest.json +11 -11
  33. package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
  34. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  35. package/dist/web/standalone/.next/server/pages/500.html +1 -1
  36. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  37. package/package.json +4 -2
  38. package/packages/mcp-server/dist/cli.d.ts +9 -0
  39. package/packages/mcp-server/dist/cli.d.ts.map +1 -0
  40. package/packages/mcp-server/dist/cli.js +58 -0
  41. package/packages/mcp-server/dist/cli.js.map +1 -0
  42. package/packages/mcp-server/dist/index.d.ts +20 -0
  43. package/packages/mcp-server/dist/index.d.ts.map +1 -0
  44. package/packages/mcp-server/dist/index.js +14 -0
  45. package/packages/mcp-server/dist/index.js.map +1 -0
  46. package/packages/mcp-server/dist/readers/captures.d.ts +25 -0
  47. package/packages/mcp-server/dist/readers/captures.d.ts.map +1 -0
  48. package/packages/mcp-server/dist/readers/captures.js +67 -0
  49. package/packages/mcp-server/dist/readers/captures.js.map +1 -0
  50. package/packages/mcp-server/dist/readers/doctor-lite.d.ts +20 -0
  51. package/packages/mcp-server/dist/readers/doctor-lite.d.ts.map +1 -0
  52. package/packages/mcp-server/dist/readers/doctor-lite.js +173 -0
  53. package/packages/mcp-server/dist/readers/doctor-lite.js.map +1 -0
  54. package/packages/mcp-server/dist/readers/index.d.ts +14 -0
  55. package/packages/mcp-server/dist/readers/index.d.ts.map +1 -0
  56. package/packages/mcp-server/dist/readers/index.js +10 -0
  57. package/packages/mcp-server/dist/readers/index.js.map +1 -0
  58. package/packages/mcp-server/dist/readers/knowledge.d.ts +18 -0
  59. package/packages/mcp-server/dist/readers/knowledge.d.ts.map +1 -0
  60. package/packages/mcp-server/dist/readers/knowledge.js +82 -0
  61. package/packages/mcp-server/dist/readers/knowledge.js.map +1 -0
  62. package/packages/mcp-server/dist/readers/metrics.d.ts +32 -0
  63. package/packages/mcp-server/dist/readers/metrics.d.ts.map +1 -0
  64. package/packages/mcp-server/dist/readers/metrics.js +74 -0
  65. package/packages/mcp-server/dist/readers/metrics.js.map +1 -0
  66. package/packages/mcp-server/dist/readers/paths.d.ts +42 -0
  67. package/packages/mcp-server/dist/readers/paths.d.ts.map +1 -0
  68. package/packages/mcp-server/dist/readers/paths.js +199 -0
  69. package/packages/mcp-server/dist/readers/paths.js.map +1 -0
  70. package/packages/mcp-server/dist/readers/roadmap.d.ts +26 -0
  71. package/packages/mcp-server/dist/readers/roadmap.d.ts.map +1 -0
  72. package/packages/mcp-server/dist/readers/roadmap.js +194 -0
  73. package/packages/mcp-server/dist/readers/roadmap.js.map +1 -0
  74. package/packages/mcp-server/dist/readers/state.d.ts +43 -0
  75. package/packages/mcp-server/dist/readers/state.d.ts.map +1 -0
  76. package/packages/mcp-server/dist/readers/state.js +184 -0
  77. package/packages/mcp-server/dist/readers/state.js.map +1 -0
  78. package/packages/mcp-server/dist/server.d.ts +28 -0
  79. package/packages/mcp-server/dist/server.d.ts.map +1 -0
  80. package/packages/mcp-server/dist/server.js +319 -0
  81. package/packages/mcp-server/dist/server.js.map +1 -0
  82. package/packages/mcp-server/dist/session-manager.d.ts +54 -0
  83. package/packages/mcp-server/dist/session-manager.d.ts.map +1 -0
  84. package/packages/mcp-server/dist/session-manager.js +284 -0
  85. package/packages/mcp-server/dist/session-manager.js.map +1 -0
  86. package/packages/mcp-server/dist/types.d.ts +61 -0
  87. package/packages/mcp-server/dist/types.d.ts.map +1 -0
  88. package/packages/mcp-server/dist/types.js +11 -0
  89. package/packages/mcp-server/dist/types.js.map +1 -0
  90. package/packages/mcp-server/dist/workflow-tools.d.ts +9 -0
  91. package/packages/mcp-server/dist/workflow-tools.d.ts.map +1 -0
  92. package/packages/mcp-server/dist/workflow-tools.js +526 -0
  93. package/packages/mcp-server/dist/workflow-tools.js.map +1 -0
  94. package/packages/mcp-server/tsconfig.json +1 -1
  95. package/packages/rpc-client/dist/index.d.ts +10 -0
  96. package/packages/rpc-client/dist/index.d.ts.map +1 -0
  97. package/packages/rpc-client/dist/index.js +9 -0
  98. package/packages/rpc-client/dist/index.js.map +1 -0
  99. package/packages/rpc-client/dist/jsonl.d.ts +17 -0
  100. package/packages/rpc-client/dist/jsonl.d.ts.map +1 -0
  101. package/packages/rpc-client/dist/jsonl.js +54 -0
  102. package/packages/rpc-client/dist/jsonl.js.map +1 -0
  103. package/packages/rpc-client/dist/rpc-client.d.ts +259 -0
  104. package/packages/rpc-client/dist/rpc-client.d.ts.map +1 -0
  105. package/packages/rpc-client/dist/rpc-client.js +541 -0
  106. package/packages/rpc-client/dist/rpc-client.js.map +1 -0
  107. package/packages/rpc-client/dist/rpc-client.test.d.ts +2 -0
  108. package/packages/rpc-client/dist/rpc-client.test.d.ts.map +1 -0
  109. package/packages/rpc-client/dist/rpc-client.test.js +477 -0
  110. package/packages/rpc-client/dist/rpc-client.test.js.map +1 -0
  111. package/packages/rpc-client/dist/rpc-types.d.ts +566 -0
  112. package/packages/rpc-client/dist/rpc-types.d.ts.map +1 -0
  113. package/packages/rpc-client/dist/rpc-types.js +12 -0
  114. package/packages/rpc-client/dist/rpc-types.js.map +1 -0
  115. package/scripts/ensure-workspace-builds.cjs +2 -0
  116. package/scripts/link-workspace-packages.cjs +21 -14
  117. package/src/resources/extensions/gsd/auto/session.ts +6 -0
  118. package/src/resources/extensions/gsd/auto.ts +29 -1
  119. package/src/resources/extensions/gsd/init-wizard.ts +34 -0
  120. package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +29 -0
  121. package/src/resources/extensions/gsd/tests/init-bootstrap-completeness.test.ts +121 -0
  122. package/src/resources/extensions/gsd/tests/workflow-mcp.test.ts +39 -1
  123. package/src/resources/extensions/gsd/workflow-mcp.ts +41 -7
  124. /package/dist/web/standalone/.next/static/{mHJZ3Z8yGRzZ32BmQs-I7 → 6_QPFhgX0DQnDhhquheRc}/_buildManifest.js +0 -0
  125. /package/dist/web/standalone/.next/static/{mHJZ3Z8yGRzZ32BmQs-I7 → 6_QPFhgX0DQnDhhquheRc}/_ssgManifest.js +0 -0
@@ -0,0 +1,32 @@
1
+ export interface MetricsUnit {
2
+ type: string;
3
+ id: string;
4
+ model: string;
5
+ startedAt: number;
6
+ finishedAt: number;
7
+ tokens: {
8
+ input: number;
9
+ output: number;
10
+ cacheRead: number;
11
+ cacheWrite: number;
12
+ total: number;
13
+ };
14
+ cost: number;
15
+ toolCalls: number;
16
+ apiRequests: number;
17
+ }
18
+ export interface HistoryResult {
19
+ entries: MetricsUnit[];
20
+ totals: {
21
+ cost: number;
22
+ tokens: {
23
+ input: number;
24
+ output: number;
25
+ total: number;
26
+ };
27
+ units: number;
28
+ durationMs: number;
29
+ };
30
+ }
31
+ export declare function readHistory(projectDir: string, limit?: number): HistoryResult;
32
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/readers/metrics.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QACzD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAqCD,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,CA4C7E"}
@@ -0,0 +1,74 @@
1
+ // GSD MCP Server — metrics/history reader
2
+ // Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
3
+ import { readFileSync, existsSync } from 'node:fs';
4
+ import { resolveGsdRoot, resolveRootFile } from './paths.js';
5
+ // ---------------------------------------------------------------------------
6
+ // Parser
7
+ // ---------------------------------------------------------------------------
8
+ function parseMetricsJson(content) {
9
+ try {
10
+ const data = JSON.parse(content);
11
+ if (!data.units || !Array.isArray(data.units))
12
+ return [];
13
+ return data.units.map((u) => ({
14
+ type: String(u.type ?? 'unknown'),
15
+ id: String(u.id ?? ''),
16
+ model: String(u.model ?? 'unknown'),
17
+ startedAt: Number(u.startedAt ?? 0),
18
+ finishedAt: Number(u.finishedAt ?? 0),
19
+ tokens: {
20
+ input: Number(u.tokens?.input ?? 0),
21
+ output: Number(u.tokens?.output ?? 0),
22
+ cacheRead: Number(u.tokens?.cacheRead ?? 0),
23
+ cacheWrite: Number(u.tokens?.cacheWrite ?? 0),
24
+ total: Number(u.tokens?.total ?? 0),
25
+ },
26
+ cost: Number(u.cost ?? 0),
27
+ toolCalls: Number(u.toolCalls ?? 0),
28
+ apiRequests: Number(u.apiRequests ?? 0),
29
+ }));
30
+ }
31
+ catch {
32
+ return [];
33
+ }
34
+ }
35
+ // ---------------------------------------------------------------------------
36
+ // Public API
37
+ // ---------------------------------------------------------------------------
38
+ export function readHistory(projectDir, limit) {
39
+ const gsd = resolveGsdRoot(projectDir);
40
+ // metrics.json (primary)
41
+ const metricsPath = resolveRootFile(gsd, 'metrics.json');
42
+ let units = [];
43
+ if (existsSync(metricsPath)) {
44
+ const content = readFileSync(metricsPath, 'utf-8');
45
+ units = parseMetricsJson(content);
46
+ }
47
+ // Sort by startedAt descending (most recent first)
48
+ units.sort((a, b) => b.startedAt - a.startedAt);
49
+ // Apply limit
50
+ if (limit && limit > 0) {
51
+ units = units.slice(0, limit);
52
+ }
53
+ // Compute totals from ALL units (not just limited set)
54
+ const allUnits = existsSync(metricsPath)
55
+ ? parseMetricsJson(readFileSync(metricsPath, 'utf-8'))
56
+ : [];
57
+ const totals = {
58
+ cost: 0,
59
+ tokens: { input: 0, output: 0, total: 0 },
60
+ units: allUnits.length,
61
+ durationMs: 0,
62
+ };
63
+ for (const u of allUnits) {
64
+ totals.cost += u.cost;
65
+ totals.tokens.input += u.tokens.input;
66
+ totals.tokens.output += u.tokens.output;
67
+ totals.tokens.total += u.tokens.total;
68
+ totals.durationMs += (u.finishedAt - u.startedAt);
69
+ }
70
+ // Round cost to 4 decimal places
71
+ totals.cost = Math.round(totals.cost * 10000) / 10000;
72
+ return { entries: units, totals };
73
+ }
74
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/readers/metrics.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,4DAA4D;AAE5D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,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EAAE;QACzC,KAAK,EAAE,QAAQ,CAAC,MAAM;QACtB,UAAU,EAAE,CAAC;KACd,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC;QACtB,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACtC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;IAED,iCAAiC;IACjC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;IAEtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// GSD MCP Server — metrics/history reader\n// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport { resolveGsdRoot, resolveRootFile } from './paths.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface MetricsUnit {\n type: string;\n id: string;\n model: string;\n startedAt: number;\n finishedAt: number;\n tokens: {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n total: number;\n };\n cost: number;\n toolCalls: number;\n apiRequests: number;\n}\n\nexport interface HistoryResult {\n entries: MetricsUnit[];\n totals: {\n cost: number;\n tokens: { input: number; output: number; total: number };\n units: number;\n durationMs: number;\n };\n}\n\n// ---------------------------------------------------------------------------\n// Parser\n// ---------------------------------------------------------------------------\n\nfunction parseMetricsJson(content: string): MetricsUnit[] {\n try {\n const data = JSON.parse(content);\n if (!data.units || !Array.isArray(data.units)) return [];\n\n return data.units.map((u: Record<string, unknown>) => ({\n type: String(u.type ?? 'unknown'),\n id: String(u.id ?? ''),\n model: String(u.model ?? 'unknown'),\n startedAt: Number(u.startedAt ?? 0),\n finishedAt: Number(u.finishedAt ?? 0),\n tokens: {\n input: Number((u.tokens as Record<string, unknown>)?.input ?? 0),\n output: Number((u.tokens as Record<string, unknown>)?.output ?? 0),\n cacheRead: Number((u.tokens as Record<string, unknown>)?.cacheRead ?? 0),\n cacheWrite: Number((u.tokens as Record<string, unknown>)?.cacheWrite ?? 0),\n total: Number((u.tokens as Record<string, unknown>)?.total ?? 0),\n },\n cost: Number(u.cost ?? 0),\n toolCalls: Number(u.toolCalls ?? 0),\n apiRequests: Number(u.apiRequests ?? 0),\n }));\n } catch {\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport function readHistory(projectDir: string, limit?: number): HistoryResult {\n const gsd = resolveGsdRoot(projectDir);\n\n // metrics.json (primary)\n const metricsPath = resolveRootFile(gsd, 'metrics.json');\n let units: MetricsUnit[] = [];\n\n if (existsSync(metricsPath)) {\n const content = readFileSync(metricsPath, 'utf-8');\n units = parseMetricsJson(content);\n }\n\n // Sort by startedAt descending (most recent first)\n units.sort((a, b) => b.startedAt - a.startedAt);\n\n // Apply limit\n if (limit && limit > 0) {\n units = units.slice(0, limit);\n }\n\n // Compute totals from ALL units (not just limited set)\n const allUnits = existsSync(metricsPath)\n ? parseMetricsJson(readFileSync(metricsPath, 'utf-8'))\n : [];\n\n const totals = {\n cost: 0,\n tokens: { input: 0, output: 0, total: 0 },\n units: allUnits.length,\n durationMs: 0,\n };\n\n for (const u of allUnits) {\n totals.cost += u.cost;\n totals.tokens.input += u.tokens.input;\n totals.tokens.output += u.tokens.output;\n totals.tokens.total += u.tokens.total;\n totals.durationMs += (u.finishedAt - u.startedAt);\n }\n\n // Round cost to 4 decimal places\n totals.cost = Math.round(totals.cost * 10000) / 10000;\n\n return { entries: units, totals };\n}\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Resolve the .gsd/ root directory for a project.
3
+ *
4
+ * Probes in order:
5
+ * 1. projectDir/.gsd (fast path)
6
+ * 2. git repo root/.gsd
7
+ * 3. Walk up from projectDir
8
+ * 4. Fallback: projectDir/.gsd (even if missing — for init)
9
+ */
10
+ export declare function resolveGsdRoot(projectDir: string): string;
11
+ /** Resolve path to a .gsd/ root file (STATE.md, KNOWLEDGE.md, etc.) */
12
+ export declare function resolveRootFile(gsdRoot: string, name: string): string;
13
+ /** Resolve path to milestones directory */
14
+ export declare function milestonesDir(gsdRoot: string): string;
15
+ /**
16
+ * Find all milestone directory IDs (M001, M002, etc.).
17
+ * Handles both bare (M001/) and descriptor (M001-FLIGHT-SIM/) naming.
18
+ */
19
+ export declare function findMilestoneIds(gsdRoot: string): string[];
20
+ /**
21
+ * Resolve the actual directory name for a milestone ID.
22
+ * M001 might live in M001/ or M001-SOME-DESCRIPTOR/.
23
+ */
24
+ export declare function resolveMilestoneDir(gsdRoot: string, milestoneId: string): string | null;
25
+ /**
26
+ * Resolve a milestone-level file (M001-ROADMAP.md, M001-CONTEXT.md, etc.).
27
+ * Handles various naming conventions.
28
+ */
29
+ export declare function resolveMilestoneFile(gsdRoot: string, milestoneId: string, suffix: string): string | null;
30
+ /** Find all slice IDs within a milestone (S01, S02, etc.) */
31
+ export declare function findSliceIds(gsdRoot: string, milestoneId: string): string[];
32
+ /** Resolve the actual directory for a slice */
33
+ export declare function resolveSliceDir(gsdRoot: string, milestoneId: string, sliceId: string): string | null;
34
+ /** Resolve a slice-level file (S01-PLAN.md, etc.) */
35
+ export declare function resolveSliceFile(gsdRoot: string, milestoneId: string, sliceId: string, suffix: string): string | null;
36
+ /** Find all task files in a slice's tasks/ directory */
37
+ export declare function findTaskFiles(gsdRoot: string, milestoneId: string, sliceId: string): Array<{
38
+ id: string;
39
+ hasPlan: boolean;
40
+ hasSummary: boolean;
41
+ }>;
42
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/readers/paths.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAoCzD;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,2CAA2C;AAC3C,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAc1D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBvF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBxG;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAiB3E;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBpG;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GACpE,MAAM,GAAG,IAAI,CAef;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GACpD,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAuB9D"}
@@ -0,0 +1,199 @@
1
+ // GSD MCP Server — .gsd/ directory resolution
2
+ // Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
3
+ import { existsSync, statSync, readdirSync } from 'node:fs';
4
+ import { join, resolve, dirname, basename } from 'node:path';
5
+ import { execFileSync } from 'node:child_process';
6
+ /**
7
+ * Resolve the .gsd/ root directory for a project.
8
+ *
9
+ * Probes in order:
10
+ * 1. projectDir/.gsd (fast path)
11
+ * 2. git repo root/.gsd
12
+ * 3. Walk up from projectDir
13
+ * 4. Fallback: projectDir/.gsd (even if missing — for init)
14
+ */
15
+ export function resolveGsdRoot(projectDir) {
16
+ const resolved = resolve(projectDir);
17
+ // Fast path: .gsd/ in the given directory
18
+ const direct = join(resolved, '.gsd');
19
+ if (existsSync(direct) && statSync(direct).isDirectory()) {
20
+ return direct;
21
+ }
22
+ // Try git repo root
23
+ try {
24
+ const gitRoot = execFileSync('git', ['rev-parse', '--show-toplevel'], {
25
+ cwd: resolved,
26
+ encoding: 'utf-8',
27
+ stdio: ['pipe', 'pipe', 'pipe'],
28
+ }).trim();
29
+ const gitGsd = join(gitRoot, '.gsd');
30
+ if (existsSync(gitGsd) && statSync(gitGsd).isDirectory()) {
31
+ return gitGsd;
32
+ }
33
+ }
34
+ catch {
35
+ // Not a git repo or git not available
36
+ }
37
+ // Walk up from projectDir
38
+ let dir = resolved;
39
+ while (dir !== dirname(dir)) {
40
+ const candidate = join(dir, '.gsd');
41
+ if (existsSync(candidate) && statSync(candidate).isDirectory()) {
42
+ return candidate;
43
+ }
44
+ dir = dirname(dir);
45
+ }
46
+ // Fallback
47
+ return direct;
48
+ }
49
+ /** Resolve path to a .gsd/ root file (STATE.md, KNOWLEDGE.md, etc.) */
50
+ export function resolveRootFile(gsdRoot, name) {
51
+ return join(gsdRoot, name);
52
+ }
53
+ /** Resolve path to milestones directory */
54
+ export function milestonesDir(gsdRoot) {
55
+ return join(gsdRoot, 'milestones');
56
+ }
57
+ /**
58
+ * Find all milestone directory IDs (M001, M002, etc.).
59
+ * Handles both bare (M001/) and descriptor (M001-FLIGHT-SIM/) naming.
60
+ */
61
+ export function findMilestoneIds(gsdRoot) {
62
+ const dir = milestonesDir(gsdRoot);
63
+ if (!existsSync(dir))
64
+ return [];
65
+ const entries = readdirSync(dir, { withFileTypes: true });
66
+ const ids = [];
67
+ for (const entry of entries) {
68
+ if (!entry.isDirectory())
69
+ continue;
70
+ const match = entry.name.match(/^(M\d+)/);
71
+ if (match)
72
+ ids.push(match[1]);
73
+ }
74
+ return ids.sort();
75
+ }
76
+ /**
77
+ * Resolve the actual directory name for a milestone ID.
78
+ * M001 might live in M001/ or M001-SOME-DESCRIPTOR/.
79
+ */
80
+ export function resolveMilestoneDir(gsdRoot, milestoneId) {
81
+ const dir = milestonesDir(gsdRoot);
82
+ if (!existsSync(dir))
83
+ return null;
84
+ // Fast path: exact match
85
+ const exact = join(dir, milestoneId);
86
+ if (existsSync(exact) && statSync(exact).isDirectory())
87
+ return exact;
88
+ // Prefix match
89
+ const entries = readdirSync(dir, { withFileTypes: true });
90
+ for (const entry of entries) {
91
+ if (entry.isDirectory() && entry.name.startsWith(milestoneId)) {
92
+ return join(dir, entry.name);
93
+ }
94
+ }
95
+ return null;
96
+ }
97
+ /**
98
+ * Resolve a milestone-level file (M001-ROADMAP.md, M001-CONTEXT.md, etc.).
99
+ * Handles various naming conventions.
100
+ */
101
+ export function resolveMilestoneFile(gsdRoot, milestoneId, suffix) {
102
+ const mDir = resolveMilestoneDir(gsdRoot, milestoneId);
103
+ if (!mDir)
104
+ return null;
105
+ const dirName = basename(mDir);
106
+ // Try: M001-ROADMAP.md, then DIRNAME-ROADMAP.md
107
+ const candidates = [
108
+ join(mDir, `${milestoneId}-${suffix}.md`),
109
+ join(mDir, `${dirName}-${suffix}.md`),
110
+ join(mDir, `${suffix}.md`),
111
+ ];
112
+ for (const c of candidates) {
113
+ if (existsSync(c))
114
+ return c;
115
+ }
116
+ return null;
117
+ }
118
+ /** Find all slice IDs within a milestone (S01, S02, etc.) */
119
+ export function findSliceIds(gsdRoot, milestoneId) {
120
+ const mDir = resolveMilestoneDir(gsdRoot, milestoneId);
121
+ if (!mDir)
122
+ return [];
123
+ const slicesDir = join(mDir, 'slices');
124
+ if (!existsSync(slicesDir))
125
+ return [];
126
+ const entries = readdirSync(slicesDir, { withFileTypes: true });
127
+ const ids = [];
128
+ for (const entry of entries) {
129
+ if (!entry.isDirectory())
130
+ continue;
131
+ const match = entry.name.match(/^(S\d+)/);
132
+ if (match)
133
+ ids.push(match[1]);
134
+ }
135
+ return ids.sort();
136
+ }
137
+ /** Resolve the actual directory for a slice */
138
+ export function resolveSliceDir(gsdRoot, milestoneId, sliceId) {
139
+ const mDir = resolveMilestoneDir(gsdRoot, milestoneId);
140
+ if (!mDir)
141
+ return null;
142
+ const slicesDir = join(mDir, 'slices');
143
+ if (!existsSync(slicesDir))
144
+ return null;
145
+ const exact = join(slicesDir, sliceId);
146
+ if (existsSync(exact) && statSync(exact).isDirectory())
147
+ return exact;
148
+ const entries = readdirSync(slicesDir, { withFileTypes: true });
149
+ for (const entry of entries) {
150
+ if (entry.isDirectory() && entry.name.startsWith(sliceId)) {
151
+ return join(slicesDir, entry.name);
152
+ }
153
+ }
154
+ return null;
155
+ }
156
+ /** Resolve a slice-level file (S01-PLAN.md, etc.) */
157
+ export function resolveSliceFile(gsdRoot, milestoneId, sliceId, suffix) {
158
+ const sDir = resolveSliceDir(gsdRoot, milestoneId, sliceId);
159
+ if (!sDir)
160
+ return null;
161
+ const dirName = basename(sDir);
162
+ const candidates = [
163
+ join(sDir, `${sliceId}-${suffix}.md`),
164
+ join(sDir, `${dirName}-${suffix}.md`),
165
+ join(sDir, `${suffix}.md`),
166
+ ];
167
+ for (const c of candidates) {
168
+ if (existsSync(c))
169
+ return c;
170
+ }
171
+ return null;
172
+ }
173
+ /** Find all task files in a slice's tasks/ directory */
174
+ export function findTaskFiles(gsdRoot, milestoneId, sliceId) {
175
+ const sDir = resolveSliceDir(gsdRoot, milestoneId, sliceId);
176
+ if (!sDir)
177
+ return [];
178
+ const tasksDir = join(sDir, 'tasks');
179
+ if (!existsSync(tasksDir))
180
+ return [];
181
+ const files = readdirSync(tasksDir);
182
+ const taskMap = new Map();
183
+ for (const f of files) {
184
+ const match = f.match(/^(T\d+).*-(PLAN|SUMMARY)\.md$/i);
185
+ if (!match)
186
+ continue;
187
+ const [, id, type] = match;
188
+ const existing = taskMap.get(id) ?? { hasPlan: false, hasSummary: false };
189
+ if (type.toUpperCase() === 'PLAN')
190
+ existing.hasPlan = true;
191
+ if (type.toUpperCase() === 'SUMMARY')
192
+ existing.hasSummary = true;
193
+ taskMap.set(id, existing);
194
+ }
195
+ return Array.from(taskMap.entries())
196
+ .map(([id, info]) => ({ id, ...info }))
197
+ .sort((a, b) => a.id.localeCompare(b.id));
198
+ }
199
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/readers/paths.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,4DAA4D;AAE5D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAErC,0CAA0C;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,Q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AE,CAAC;QACtB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QAC1E,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM;YAAE,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;QAC3D,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,SAAS;YAAE,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;SACtC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["// GSD MCP Server — .gsd/ directory resolution\n// Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>\n\nimport { existsSync, statSync, readdirSync } from 'node:fs';\nimport { join, resolve, dirname, basename } from 'node:path';\nimport { execFileSync } from 'node:child_process';\n\n/**\n * Resolve the .gsd/ root directory for a project.\n *\n * Probes in order:\n * 1. projectDir/.gsd (fast path)\n * 2. git repo root/.gsd\n * 3. Walk up from projectDir\n * 4. Fallback: projectDir/.gsd (even if missing — for init)\n */\nexport function resolveGsdRoot(projectDir: string): string {\n const resolved = resolve(projectDir);\n\n // Fast path: .gsd/ in the given directory\n const direct = join(resolved, '.gsd');\n if (existsSync(direct) && statSync(direct).isDirectory()) {\n return direct;\n }\n\n // Try git repo root\n try {\n const gitRoot = execFileSync('git', ['rev-parse', '--show-toplevel'], {\n cwd: resolved,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n const gitGsd = join(gitRoot, '.gsd');\n if (existsSync(gitGsd) && statSync(gitGsd).isDirectory()) {\n return gitGsd;\n }\n } catch {\n // Not a git repo or git not available\n }\n\n // Walk up from projectDir\n let dir = resolved;\n while (dir !== dirname(dir)) {\n const candidate = join(dir, '.gsd');\n if (existsSync(candidate) && statSync(candidate).isDirectory()) {\n return candidate;\n }\n dir = dirname(dir);\n }\n\n // Fallback\n return direct;\n}\n\n/** Resolve path to a .gsd/ root file (STATE.md, KNOWLEDGE.md, etc.) */\nexport function resolveRootFile(gsdRoot: string, name: string): string {\n return join(gsdRoot, name);\n}\n\n/** Resolve path to milestones directory */\nexport function milestonesDir(gsdRoot: string): string {\n return join(gsdRoot, 'milestones');\n}\n\n/**\n * Find all milestone directory IDs (M001, M002, etc.).\n * Handles both bare (M001/) and descriptor (M001-FLIGHT-SIM/) naming.\n */\nexport function findMilestoneIds(gsdRoot: string): string[] {\n const dir = milestonesDir(gsdRoot);\n if (!existsSync(dir)) return [];\n\n const entries = readdirSync(dir, { withFileTypes: true });\n const ids: string[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const match = entry.name.match(/^(M\\d+)/);\n if (match) ids.push(match[1]);\n }\n\n return ids.sort();\n}\n\n/**\n * Resolve the actual directory name for a milestone ID.\n * M001 might live in M001/ or M001-SOME-DESCRIPTOR/.\n */\nexport function resolveMilestoneDir(gsdRoot: string, milestoneId: string): string | null {\n const dir = milestonesDir(gsdRoot);\n if (!existsSync(dir)) return null;\n\n // Fast path: exact match\n const exact = join(dir, milestoneId);\n if (existsSync(exact) && statSync(exact).isDirectory()) return exact;\n\n // Prefix match\n const entries = readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory() && entry.name.startsWith(milestoneId)) {\n return join(dir, entry.name);\n }\n }\n\n return null;\n}\n\n/**\n * Resolve a milestone-level file (M001-ROADMAP.md, M001-CONTEXT.md, etc.).\n * Handles various naming conventions.\n */\nexport function resolveMilestoneFile(gsdRoot: string, milestoneId: string, suffix: string): string | null {\n const mDir = resolveMilestoneDir(gsdRoot, milestoneId);\n if (!mDir) return null;\n\n const dirName = basename(mDir);\n\n // Try: M001-ROADMAP.md, then DIRNAME-ROADMAP.md\n const candidates = [\n join(mDir, `${milestoneId}-${suffix}.md`),\n join(mDir, `${dirName}-${suffix}.md`),\n join(mDir, `${suffix}.md`),\n ];\n\n for (const c of candidates) {\n if (existsSync(c)) return c;\n }\n return null;\n}\n\n/** Find all slice IDs within a milestone (S01, S02, etc.) */\nexport function findSliceIds(gsdRoot: string, milestoneId: string): string[] {\n const mDir = resolveMilestoneDir(gsdRoot, milestoneId);\n if (!mDir) return [];\n\n const slicesDir = join(mDir, 'slices');\n if (!existsSync(slicesDir)) return [];\n\n const entries = readdirSync(slicesDir, { withFileTypes: true });\n const ids: string[] = [];\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const match = entry.name.match(/^(S\\d+)/);\n if (match) ids.push(match[1]);\n }\n\n return ids.sort();\n}\n\n/** Resolve the actual directory for a slice */\nexport function resolveSliceDir(gsdRoot: string, milestoneId: string, sliceId: string): string | null {\n const mDir = resolveMilestoneDir(gsdRoot, milestoneId);\n if (!mDir) return null;\n\n const slicesDir = join(mDir, 'slices');\n if (!existsSync(slicesDir)) return null;\n\n const exact = join(slicesDir, sliceId);\n if (existsSync(exact) && statSync(exact).isDirectory()) return exact;\n\n const entries = readdirSync(slicesDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isDirectory() && entry.name.startsWith(sliceId)) {\n return join(slicesDir, entry.name);\n }\n }\n return null;\n}\n\n/** Resolve a slice-level file (S01-PLAN.md, etc.) */\nexport function resolveSliceFile(\n gsdRoot: string, milestoneId: string, sliceId: string, suffix: string,\n): string | null {\n const sDir = resolveSliceDir(gsdRoot, milestoneId, sliceId);\n if (!sDir) return null;\n\n const dirName = basename(sDir);\n const candidates = [\n join(sDir, `${sliceId}-${suffix}.md`),\n join(sDir, `${dirName}-${suffix}.md`),\n join(sDir, `${suffix}.md`),\n ];\n\n for (const c of candidates) {\n if (existsSync(c)) return c;\n }\n return null;\n}\n\n/** Find all task files in a slice's tasks/ directory */\nexport function findTaskFiles(\n gsdRoot: string, milestoneId: string, sliceId: string,\n): Array<{ id: string; hasPlan: boolean; hasSummary: boolean }> {\n const sDir = resolveSliceDir(gsdRoot, milestoneId, sliceId);\n if (!sDir) return [];\n\n const tasksDir = join(sDir, 'tasks');\n if (!existsSync(tasksDir)) return [];\n\n const files = readdirSync(tasksDir);\n const taskMap = new Map<string, { hasPlan: boolean; hasSummary: boolean }>();\n\n for (const f of files) {\n const match = f.match(/^(T\\d+).*-(PLAN|SUMMARY)\\.md$/i);\n if (!match) continue;\n const [, id, type] = match;\n const existing = taskMap.get(id) ?? { hasPlan: false, hasSummary: false };\n if (type.toUpperCase() === 'PLAN') existing.hasPlan = true;\n if (type.toUpperCase() === 'SUMMARY') existing.hasSummary = true;\n taskMap.set(id, existing);\n }\n\n return Array.from(taskMap.entries())\n .map(([id, info]) => ({ id, ...info }))\n .sort((a, b) => a.id.localeCompare(b.id));\n}\n"]}
@@ -0,0 +1,26 @@
1
+ export interface TaskInfo {
2
+ id: string;
3
+ title: string;
4
+ status: 'done' | 'pending';
5
+ }
6
+ export interface SliceInfo {
7
+ id: string;
8
+ title: string;
9
+ status: 'done' | 'active' | 'pending';
10
+ risk: string;
11
+ depends: string[];
12
+ demo: string;
13
+ tasks: TaskInfo[];
14
+ }
15
+ export interface MilestoneInfo {
16
+ id: string;
17
+ title: string;
18
+ status: 'done' | 'active' | 'pending' | 'parked';
19
+ vision: string;
20
+ slices: SliceInfo[];
21
+ }
22
+ export interface RoadmapResult {
23
+ milestones: MilestoneInfo[];
24
+ }
25
+ export declare function readRoadmap(projectDir: string, filterMilestoneId?: string): RoadmapResult;
26
+ //# sourceMappingURL=roadmap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roadmap.d.ts","sourceRoot":"","sources":["../../src/readers/roadmap.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AA4ID,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,aAAa,CA+EzF"}
@@ -0,0 +1,194 @@
1
+ // GSD MCP Server — roadmap structure reader
2
+ // Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
3
+ import { readFileSync, existsSync } from 'node:fs';
4
+ import { resolveGsdRoot, findMilestoneIds, resolveMilestoneFile, findSliceIds, resolveSliceFile, findTaskFiles, } from './paths.js';
5
+ // ---------------------------------------------------------------------------
6
+ // ROADMAP.md table parser
7
+ // ---------------------------------------------------------------------------
8
+ function parseRoadmapTable(content) {
9
+ const results = [];
10
+ // Try table format first: | S01 | Title | risk | depends | done-icon | demo |
11
+ const tableSection = content.match(/## (?:Slice[s]?|Slice Overview|Slice Table)\s*\n([\s\S]*?)(?=\n##|\n$|$)/i);
12
+ if (tableSection) {
13
+ const lines = tableSection[1].split('\n');
14
+ for (const line of lines) {
15
+ if (!line.includes('|'))
16
+ continue;
17
+ const cells = line.split('|').map((c) => c.trim()).filter(Boolean);
18
+ if (cells.length < 4)
19
+ continue;
20
+ if (cells[0] === 'ID' || cells[0].startsWith('--'))
21
+ continue;
22
+ const id = cells[0].match(/S\d+/)?.[0];
23
+ if (!id)
24
+ continue;
25
+ const done = cells.some((c) => c === '\u2611' || c === '\u2705' || c.toLowerCase() === 'done');
26
+ const depends = (cells[3] ?? '').replace(/\u2014/g, '').split(',').map((d) => d.trim()).filter(Boolean);
27
+ results.push({
28
+ id,
29
+ title: cells[1] ?? '',
30
+ risk: cells[2] ?? 'medium',
31
+ depends,
32
+ done,
33
+ demo: cells[5] ?? '',
34
+ });
35
+ }
36
+ if (results.length > 0)
37
+ return results;
38
+ }
39
+ // Try checkbox format: - [x] **S01: Title** `risk:high` `depends:[S01]`
40
+ const checkboxRe = /^-\s+\[([ xX])\]\s+\*\*(S\d+):\s*(.+?)\*\*(?:.*?`risk:(\w+)`)?(?:.*?`depends:\[([^\]]*)\]`)?/gm;
41
+ let match;
42
+ while ((match = checkboxRe.exec(content)) !== null) {
43
+ const [, checked, id, title, risk, deps] = match;
44
+ results.push({
45
+ id,
46
+ title: title.trim(),
47
+ risk: risk ?? 'medium',
48
+ depends: deps ? deps.split(',').map((d) => d.trim()).filter(Boolean) : [],
49
+ done: checked !== ' ',
50
+ demo: '',
51
+ });
52
+ }
53
+ if (results.length > 0)
54
+ return results;
55
+ // Try prose headers: ## S01: Title
56
+ const headerRe = /^##\s+(S\d+):\s*(.+)/gm;
57
+ while ((match = headerRe.exec(content)) !== null) {
58
+ results.push({
59
+ id: match[1],
60
+ title: match[2].trim(),
61
+ risk: 'medium',
62
+ depends: [],
63
+ done: false,
64
+ demo: '',
65
+ });
66
+ }
67
+ return results;
68
+ }
69
+ // ---------------------------------------------------------------------------
70
+ // PLAN.md task parser
71
+ // ---------------------------------------------------------------------------
72
+ function parseSlicePlanTasks(content) {
73
+ const results = [];
74
+ // Checkbox format: - [x] **T01: Title** — description
75
+ const taskRe = /^-\s+\[([ xX])\]\s+\*\*(T\d+):\s*(.+?)\*\*/gm;
76
+ let match;
77
+ while ((match = taskRe.exec(content)) !== null) {
78
+ results.push({
79
+ id: match[2],
80
+ title: match[3].trim(),
81
+ done: match[1] !== ' ',
82
+ });
83
+ }
84
+ if (results.length > 0)
85
+ return results;
86
+ // H3 format: ### T01: Title
87
+ const h3Re = /^###\s+(T\d+):\s*(.+)/gm;
88
+ while ((match = h3Re.exec(content)) !== null) {
89
+ results.push({
90
+ id: match[1],
91
+ title: match[2].trim(),
92
+ done: false,
93
+ });
94
+ }
95
+ return results;
96
+ }
97
+ // ---------------------------------------------------------------------------
98
+ // Milestone title from CONTEXT.md or ROADMAP.md H1
99
+ // ---------------------------------------------------------------------------
100
+ function readMilestoneTitle(gsdRoot, mid) {
101
+ const ctxPath = resolveMilestoneFile(gsdRoot, mid, 'CONTEXT');
102
+ if (ctxPath && existsSync(ctxPath)) {
103
+ const content = readFileSync(ctxPath, 'utf-8');
104
+ const h1 = content.match(/^#\s+(?:M\d+:?\s*)?(.+)/m);
105
+ if (h1)
106
+ return h1[1].trim();
107
+ }
108
+ const roadmapPath = resolveMilestoneFile(gsdRoot, mid, 'ROADMAP');
109
+ if (roadmapPath && existsSync(roadmapPath)) {
110
+ const content = readFileSync(roadmapPath, 'utf-8');
111
+ const h1 = content.match(/^#\s+(?:M\d+:?\s*)?(.+)/m);
112
+ if (h1)
113
+ return h1[1].trim();
114
+ }
115
+ return mid;
116
+ }
117
+ function readVision(gsdRoot, mid) {
118
+ const roadmapPath = resolveMilestoneFile(gsdRoot, mid, 'ROADMAP');
119
+ if (!roadmapPath || !existsSync(roadmapPath))
120
+ return '';
121
+ const content = readFileSync(roadmapPath, 'utf-8');
122
+ const section = content.match(/## Vision\s*\n([\s\S]*?)(?=\n##|\n$|$)/i);
123
+ return section ? section[1].trim() : '';
124
+ }
125
+ // ---------------------------------------------------------------------------
126
+ // Public API
127
+ // ---------------------------------------------------------------------------
128
+ export function readRoadmap(projectDir, filterMilestoneId) {
129
+ const gsd = resolveGsdRoot(projectDir);
130
+ let milestoneIds = findMilestoneIds(gsd);
131
+ if (filterMilestoneId) {
132
+ milestoneIds = milestoneIds.filter((id) => id === filterMilestoneId);
133
+ }
134
+ const milestones = [];
135
+ for (const mid of milestoneIds) {
136
+ const title = readMilestoneTitle(gsd, mid);
137
+ const vision = readVision(gsd, mid);
138
+ const summaryPath = resolveMilestoneFile(gsd, mid, 'SUMMARY');
139
+ const hasSummary = summaryPath !== null && existsSync(summaryPath);
140
+ const roadmapPath = resolveMilestoneFile(gsd, mid, 'ROADMAP');
141
+ let roadmapSlices = [];
142
+ if (roadmapPath && existsSync(roadmapPath)) {
143
+ roadmapSlices = parseRoadmapTable(readFileSync(roadmapPath, 'utf-8'));
144
+ }
145
+ const fsSliceIds = findSliceIds(gsd, mid);
146
+ const sliceIdSet = new Set([
147
+ ...roadmapSlices.map((s) => s.id),
148
+ ...fsSliceIds,
149
+ ]);
150
+ const slices = [];
151
+ for (const sid of Array.from(sliceIdSet).sort()) {
152
+ const roadmapEntry = roadmapSlices.find((s) => s.id === sid);
153
+ const taskFiles = findTaskFiles(gsd, mid, sid);
154
+ const planPath = resolveSliceFile(gsd, mid, sid, 'PLAN');
155
+ let planTasks = [];
156
+ if (planPath && existsSync(planPath)) {
157
+ planTasks = parseSlicePlanTasks(readFileSync(planPath, 'utf-8'));
158
+ }
159
+ const tasks = [];
160
+ const seenIds = new Set();
161
+ for (const pt of planTasks) {
162
+ const fsTask = taskFiles.find((t) => t.id === pt.id);
163
+ const done = fsTask?.hasSummary ?? pt.done;
164
+ tasks.push({ id: pt.id, title: pt.title, status: done ? 'done' : 'pending' });
165
+ seenIds.add(pt.id);
166
+ }
167
+ for (const ft of taskFiles) {
168
+ if (seenIds.has(ft.id))
169
+ continue;
170
+ tasks.push({ id: ft.id, title: ft.id, status: ft.hasSummary ? 'done' : 'pending' });
171
+ }
172
+ const allDone = tasks.length > 0 && tasks.every((t) => t.status === 'done');
173
+ const anyDone = tasks.some((t) => t.status === 'done');
174
+ const sliceStatus = allDone ? 'done' : anyDone ? 'active' : 'pending';
175
+ slices.push({
176
+ id: sid,
177
+ title: roadmapEntry?.title ?? sid,
178
+ status: sliceStatus,
179
+ risk: roadmapEntry?.risk ?? 'medium',
180
+ depends: roadmapEntry?.depends ?? [],
181
+ demo: roadmapEntry?.demo ?? '',
182
+ tasks,
183
+ });
184
+ }
185
+ const allSlicesDone = slices.length > 0 && slices.every((s) => s.status === 'done');
186
+ const anySliceActive = slices.some((s) => s.status === 'active' || s.status === 'done');
187
+ const milestoneStatus = hasSummary
188
+ ? 'done'
189
+ : allSlicesDone ? 'done' : anySliceActive ? 'active' : 'pending';
190
+ milestones.push({ id: mid, title, status: milestoneStatus, vision, slices });
191
+ }
192
+ return { milestones };
193
+ }
194
+ //# sourceMappingURL=roadmap.js.map