specsmd 0.0.0-dev.86 → 0.0.0-dev.87

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 (42) hide show
  1. package/README.md +15 -0
  2. package/bin/cli.js +15 -1
  3. package/flows/fire/agents/builder/agent.md +2 -2
  4. package/flows/fire/agents/builder/skills/code-review/SKILL.md +1 -1
  5. package/flows/fire/agents/builder/skills/run-execute/SKILL.md +16 -7
  6. package/flows/fire/agents/builder/skills/run-execute/scripts/complete-run.cjs +22 -3
  7. package/flows/fire/agents/builder/skills/run-execute/scripts/init-run.cjs +63 -20
  8. package/flows/fire/agents/builder/skills/run-execute/scripts/update-checkpoint.cjs +254 -0
  9. package/flows/fire/agents/builder/skills/run-execute/scripts/update-phase.cjs +17 -6
  10. package/flows/fire/agents/builder/skills/run-status/SKILL.md +1 -1
  11. package/flows/fire/agents/orchestrator/agent.md +1 -1
  12. package/flows/fire/agents/orchestrator/skills/status/SKILL.md +2 -2
  13. package/flows/fire/memory-bank.yaml +4 -4
  14. package/lib/dashboard/aidlc/parser.js +581 -0
  15. package/lib/dashboard/fire/model.js +382 -0
  16. package/lib/dashboard/fire/parser.js +470 -0
  17. package/lib/dashboard/flow-detect.js +86 -0
  18. package/lib/dashboard/git/changes.js +362 -0
  19. package/lib/dashboard/git/worktrees.js +248 -0
  20. package/lib/dashboard/index.js +709 -0
  21. package/lib/dashboard/runtime/watch-runtime.js +122 -0
  22. package/lib/dashboard/simple/parser.js +293 -0
  23. package/lib/dashboard/tui/app.js +1675 -0
  24. package/lib/dashboard/tui/components/error-banner.js +35 -0
  25. package/lib/dashboard/tui/components/header.js +60 -0
  26. package/lib/dashboard/tui/components/help-footer.js +15 -0
  27. package/lib/dashboard/tui/components/stats-strip.js +35 -0
  28. package/lib/dashboard/tui/file-entries.js +383 -0
  29. package/lib/dashboard/tui/flow-builders.js +991 -0
  30. package/lib/dashboard/tui/git-builders.js +218 -0
  31. package/lib/dashboard/tui/helpers.js +236 -0
  32. package/lib/dashboard/tui/overlays.js +242 -0
  33. package/lib/dashboard/tui/preview.js +220 -0
  34. package/lib/dashboard/tui/renderer.js +76 -0
  35. package/lib/dashboard/tui/row-builders.js +797 -0
  36. package/lib/dashboard/tui/sections.js +45 -0
  37. package/lib/dashboard/tui/store.js +44 -0
  38. package/lib/dashboard/tui/views/overview-view.js +61 -0
  39. package/lib/dashboard/tui/views/runs-view.js +93 -0
  40. package/lib/dashboard/tui/worktree-builders.js +229 -0
  41. package/lib/installers/CodexInstaller.js +72 -1
  42. package/package.json +7 -3
@@ -0,0 +1,220 @@
1
+ const fs = require('fs');
2
+ const { truncate, clampIndex } = require('./helpers');
3
+ const { colorizeMarkdownLine, sanitizeRenderLine } = require('./overlays');
4
+ const {
5
+ loadGitDiffPreview,
6
+ loadGitCommitPreview
7
+ } = require('../git/changes');
8
+
9
+ const MAX_PREVIEW_CACHE_ENTRIES = 64;
10
+ const previewContentCache = new Map();
11
+
12
+ function getFilePreviewCacheKey(filePath) {
13
+ if (typeof filePath !== 'string' || filePath.trim() === '') {
14
+ return null;
15
+ }
16
+
17
+ try {
18
+ const stat = fs.statSync(filePath);
19
+ return `file:${filePath}:${stat.size}:${Math.floor(stat.mtimeMs)}`;
20
+ } catch {
21
+ return `file:${filePath}:missing`;
22
+ }
23
+ }
24
+
25
+ function getGitPreviewCacheKey(fileEntry, isGitCommitPreview) {
26
+ if (!fileEntry || typeof fileEntry !== 'object') {
27
+ return null;
28
+ }
29
+
30
+ const repoRoot = typeof fileEntry.repoRoot === 'string' ? fileEntry.repoRoot : '';
31
+ if (isGitCommitPreview) {
32
+ const commitHash = typeof fileEntry.commitHash === 'string' ? fileEntry.commitHash : '';
33
+ return `git-commit:${repoRoot}:${commitHash}`;
34
+ }
35
+
36
+ const bucket = typeof fileEntry.bucket === 'string' ? fileEntry.bucket : '';
37
+ const relativePath = typeof fileEntry.relativePath === 'string' ? fileEntry.relativePath : '';
38
+ const pathValue = typeof fileEntry.path === 'string' ? fileEntry.path : '';
39
+ return `git-diff:${repoRoot}:${bucket}:${relativePath}:${pathValue}`;
40
+ }
41
+
42
+ function getCachedPreviewContent(cacheKey) {
43
+ if (!cacheKey || !previewContentCache.has(cacheKey)) {
44
+ return null;
45
+ }
46
+
47
+ const cached = previewContentCache.get(cacheKey);
48
+ previewContentCache.delete(cacheKey);
49
+ previewContentCache.set(cacheKey, cached);
50
+ return Array.isArray(cached) ? cached : null;
51
+ }
52
+
53
+ function setCachedPreviewContent(cacheKey, lines) {
54
+ if (!cacheKey || !Array.isArray(lines)) {
55
+ return;
56
+ }
57
+
58
+ if (previewContentCache.has(cacheKey)) {
59
+ previewContentCache.delete(cacheKey);
60
+ }
61
+ previewContentCache.set(cacheKey, lines);
62
+
63
+ while (previewContentCache.size > MAX_PREVIEW_CACHE_ENTRIES) {
64
+ const oldest = previewContentCache.keys().next().value;
65
+ if (!oldest) {
66
+ break;
67
+ }
68
+ previewContentCache.delete(oldest);
69
+ }
70
+ }
71
+
72
+ function clearPreviewContentCache() {
73
+ previewContentCache.clear();
74
+ }
75
+
76
+ function buildPreviewLines(fileEntry, width, scrollOffset, options = {}) {
77
+ const fullDocument = options?.fullDocument === true;
78
+
79
+ if (!fileEntry || typeof fileEntry.path !== 'string') {
80
+ return [{ text: truncate('No file selected', width), color: 'gray', bold: false }];
81
+ }
82
+
83
+ const isGitFilePreview = fileEntry.previewType === 'git-diff';
84
+ const isGitCommitPreview = fileEntry.previewType === 'git-commit-diff';
85
+ const isGitPreview = isGitFilePreview || isGitCommitPreview;
86
+ const cacheKey = isGitPreview
87
+ ? getGitPreviewCacheKey(fileEntry, isGitCommitPreview)
88
+ : getFilePreviewCacheKey(fileEntry.path);
89
+ let rawLines = getCachedPreviewContent(cacheKey);
90
+ if (!rawLines) {
91
+ if (isGitPreview) {
92
+ const diffText = isGitCommitPreview
93
+ ? loadGitCommitPreview(fileEntry)
94
+ : loadGitDiffPreview(fileEntry);
95
+ rawLines = String(diffText || '').split(/\r?\n/);
96
+ } else {
97
+ let content;
98
+ try {
99
+ content = fs.readFileSync(fileEntry.path, 'utf8');
100
+ } catch (error) {
101
+ return [{
102
+ text: truncate(`Unable to read ${fileEntry.label || fileEntry.path}: ${error.message}`, width),
103
+ color: 'red',
104
+ bold: false
105
+ }];
106
+ }
107
+ rawLines = String(content).split(/\r?\n/);
108
+ }
109
+
110
+ setCachedPreviewContent(cacheKey, rawLines);
111
+ }
112
+
113
+ const headLine = {
114
+ text: truncate(
115
+ isGitCommitPreview
116
+ ? `commit: ${fileEntry.commitHash || fileEntry.path}`
117
+ : `${isGitPreview ? 'diff' : 'file'}: ${fileEntry.path}`,
118
+ width
119
+ ),
120
+ color: 'cyan',
121
+ bold: true
122
+ };
123
+
124
+ const normalizedLines = rawLines.map((line) => sanitizeRenderLine(line));
125
+ const cappedLines = fullDocument ? normalizedLines : normalizedLines.slice(0, 300);
126
+ const hiddenLineCount = fullDocument ? 0 : Math.max(0, rawLines.length - cappedLines.length);
127
+ let inCodeBlock = false;
128
+
129
+ const highlighted = cappedLines.map((rawLine, index) => {
130
+ const prefixedLine = `${String(index + 1).padStart(4, ' ')} | ${rawLine}`;
131
+ let color;
132
+ let bold;
133
+ let togglesCodeBlock = false;
134
+
135
+ if (isGitPreview) {
136
+ if (rawLine.startsWith('+++ ') || rawLine.startsWith('--- ') || rawLine.startsWith('diff --git')) {
137
+ color = 'cyan';
138
+ bold = true;
139
+ } else if (rawLine.startsWith('@@')) {
140
+ color = 'magenta';
141
+ bold = true;
142
+ } else if (rawLine.startsWith('+')) {
143
+ color = 'green';
144
+ bold = false;
145
+ } else if (rawLine.startsWith('-')) {
146
+ color = 'red';
147
+ bold = false;
148
+ } else {
149
+ color = undefined;
150
+ bold = false;
151
+ }
152
+ } else {
153
+ const markdownStyle = colorizeMarkdownLine(rawLine, inCodeBlock);
154
+ color = markdownStyle.color;
155
+ bold = markdownStyle.bold;
156
+ togglesCodeBlock = markdownStyle.togglesCodeBlock;
157
+ }
158
+
159
+ if (togglesCodeBlock) {
160
+ inCodeBlock = !inCodeBlock;
161
+ }
162
+ return {
163
+ text: truncate(prefixedLine, width),
164
+ color,
165
+ bold
166
+ };
167
+ });
168
+
169
+ if (hiddenLineCount > 0) {
170
+ highlighted.push({
171
+ text: truncate(`... ${hiddenLineCount} additional lines hidden`, width),
172
+ color: 'gray',
173
+ bold: false
174
+ });
175
+ }
176
+
177
+ const clampedOffset = clampIndex(scrollOffset, highlighted.length);
178
+ const body = highlighted.slice(clampedOffset);
179
+
180
+ return [headLine, { text: '', color: undefined, bold: false }, ...body];
181
+ }
182
+
183
+ function allocateSingleColumnPanels(candidates, rowsBudget) {
184
+ const filtered = (candidates || []).filter(Boolean);
185
+ if (filtered.length === 0) {
186
+ return [];
187
+ }
188
+
189
+ const selected = [];
190
+ let remaining = Math.max(4, rowsBudget);
191
+
192
+ for (const panel of filtered) {
193
+ const margin = selected.length > 0 ? 1 : 0;
194
+ const minimumRows = 4 + margin;
195
+
196
+ if (remaining >= minimumRows || selected.length === 0) {
197
+ selected.push({
198
+ ...panel,
199
+ maxLines: 1
200
+ });
201
+ remaining -= minimumRows;
202
+ }
203
+ }
204
+
205
+ let index = 0;
206
+ while (remaining > 0 && selected.length > 0) {
207
+ const panelIndex = index % selected.length;
208
+ selected[panelIndex].maxLines += 1;
209
+ remaining -= 1;
210
+ index += 1;
211
+ }
212
+
213
+ return selected;
214
+ }
215
+
216
+ module.exports = {
217
+ buildPreviewLines,
218
+ allocateSingleColumnPanels,
219
+ clearPreviewContentCache
220
+ };
@@ -0,0 +1,76 @@
1
+ const { renderHeaderLines, truncate } = require('./components/header');
2
+ const { renderStatsLines } = require('./components/stats-strip');
3
+ const { renderErrorLines } = require('./components/error-banner');
4
+ const { renderHelpLines } = require('./components/help-footer');
5
+ const { renderRunsViewLines } = require('./views/runs-view');
6
+ const { renderOverviewViewLines } = require('./views/overview-view');
7
+
8
+ function normalizeWidth(width) {
9
+ if (!Number.isFinite(width)) {
10
+ return 120;
11
+ }
12
+
13
+ return Math.max(40, Math.min(Math.floor(width), 180));
14
+ }
15
+
16
+ function buildDashboardLines(params) {
17
+ const {
18
+ snapshot,
19
+ error,
20
+ flow,
21
+ workspacePath,
22
+ view,
23
+ watchEnabled,
24
+ watchStatus,
25
+ showHelp,
26
+ lastRefreshAt,
27
+ width
28
+ } = params;
29
+
30
+ const safeWidth = normalizeWidth(width);
31
+ const lines = [];
32
+
33
+ lines.push(...renderHeaderLines({
34
+ snapshot,
35
+ flow,
36
+ workspacePath,
37
+ view,
38
+ watchEnabled,
39
+ watchStatus,
40
+ lastRefreshAt,
41
+ width: safeWidth
42
+ }));
43
+
44
+ if (snapshot) {
45
+ lines.push(...renderStatsLines(snapshot, safeWidth));
46
+ lines.push('');
47
+ }
48
+
49
+ if (error) {
50
+ lines.push(...renderErrorLines(error, safeWidth, watchEnabled));
51
+ lines.push('');
52
+ }
53
+
54
+ if (!snapshot) {
55
+ lines.push(truncate('No snapshot available yet. Waiting for refresh...', safeWidth));
56
+ } else if (view === 'overview') {
57
+ lines.push(...renderOverviewViewLines(snapshot, safeWidth));
58
+ } else {
59
+ lines.push(...renderRunsViewLines(snapshot, safeWidth));
60
+ }
61
+
62
+ lines.push('');
63
+ lines.push(...renderHelpLines(showHelp, safeWidth));
64
+
65
+ return lines;
66
+ }
67
+
68
+ function formatDashboardText(params) {
69
+ return buildDashboardLines(params).join('\n');
70
+ }
71
+
72
+ module.exports = {
73
+ buildDashboardLines,
74
+ formatDashboardText,
75
+ normalizeWidth
76
+ };