claude-code-session-manager 0.130.3 → 0.132.0
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/dist/assets/{AgentLibrary-BmrXNwK8.js → AgentLibrary-C09MlPFx.js} +2 -2
- package/dist/assets/AppSettings-DvDKsCnD.js +2 -0
- package/dist/assets/{Button-UUr5giu8.js → Button-BzG_KdBC.js} +1 -1
- package/dist/assets/{DocumentEditorPane-C46Hj0lz.js → DocumentEditorPane-fm6zsnLM.js} +1 -1
- package/dist/assets/Extensions-DgxKT_OZ.js +2 -0
- package/dist/assets/{History-Bndupj87.js → History-Nd3bKjBq.js} +2 -2
- package/dist/assets/{Library-DFn0YPIW.js → Library-R71t6VAB.js} +12 -12
- package/dist/assets/{ListDetail-DjMn8a_3.js → ListDetail-CG50Ul7c.js} +1 -1
- package/dist/assets/{Panel-CIvb-XXN.js → Panel-C7EFG4eU.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BQQRtMdK.js → ProjectClaudeConfig-J92iNEGC.js} +7 -7
- package/dist/assets/{ProvenanceBadge-ej8W2ZIK.js → ProvenanceBadge-C3KB3ILO.js} +1 -1
- package/dist/assets/Scheduler-DeYBA7uc.js +16 -0
- package/dist/assets/{Settings-DqxUna06.js → Settings-B6r7N4v-.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-BEMTdxdD.js → SkillReferenceGraph-D7bt3fyB.js} +1 -1
- package/dist/assets/Skills-GpxtUrFP.js +29 -0
- package/dist/assets/{SourceChip-BrPci8FX.js → SourceChip-uyVMCZc7.js} +1 -1
- package/dist/assets/{SystemPrompt-B43hNP0X.js → SystemPrompt-Cv25uFSM.js} +1 -1
- package/dist/assets/{TiptapBody-B-R2Bpda.js → TiptapBody-uP8fJkbM.js} +1 -1
- package/dist/assets/{Toggle-DKb4x1BP.js → Toggle-DRs80cX-.js} +1 -1
- package/dist/assets/{ViewTabs-CcJdFZgv.js → ViewTabs-BDkvvzJ8.js} +1 -1
- package/dist/assets/{VoiceButton-BSH0UI3u.js → VoiceButton-Cmtz2sQt.js} +1 -1
- package/dist/assets/{historyTotals-5oUEu_fe.js → historyTotals-DHwAXunq.js} +1 -1
- package/dist/assets/index-CBCdyHbZ.js +3097 -0
- package/dist/assets/{index-CMCcT2yg.css → index-oXqzajWV.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +414 -390
- package/package.json +1 -1
- package/scripts/scheduler-mcp-server.cjs +83 -4
- package/src/main/build-info.json +4 -4
- package/src/main/index.cjs +11 -0
- package/src/main/ipcSchemas.cjs +28 -1
- package/src/main/lib/epic/epicMint.cjs +61 -6
- package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
- package/src/main/lib/epic/restorableSessions.cjs +749 -0
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +36 -13
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +2 -0
- package/src/main/lib/git/branchSweep.cjs +9 -3
- package/src/main/lib/git/gitExec.cjs +8 -1
- package/src/main/lib/git/gitWorktree.cjs +564 -62
- package/src/main/lib/git/jobWorktree.cjs +3 -0
- package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
- package/src/main/lib/mcpToolCatalog.cjs +43 -6
- package/src/main/lib/mcpToolsProbe.cjs +831 -0
- package/src/main/lib/persona-macro/builtinMacros.cjs +33 -0
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +8 -0
- package/src/main/lib/persona-macro/macroJobIpc.cjs +57 -11
- package/src/main/lib/persona-macro/macroLibrary.cjs +40 -10
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
- package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
- package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
- package/src/main/lib/project-pages/matrixStore.cjs +112 -0
- package/src/main/lib/promptSessionSchema.cjs +5 -0
- package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
- package/src/main/projectPages.cjs +25 -2
- package/src/main/promptSessionEvents.cjs +10 -6
- package/src/main/runVerify.cjs +8 -3
- package/src/main/scheduler/budget.cjs +146 -7
- package/src/main/scheduler/gitTreeGuard.cjs +10 -11
- package/src/main/scheduler/reviewLadder.cjs +60 -0
- package/src/main/scheduler.cjs +461 -48
- package/src/main/seedAgentPersonas.cjs +1 -1
- package/src/preload/api.d.ts +162 -2
- package/src/preload/apiSurface.json +21 -0
- package/src/preload/index.cjs +5 -0
- package/src/seed/agents/competitive-analyst.md +69 -0
- package/src/seed/agents/competitive-researcher.md +75 -0
- package/src/seed/agents/validator.md +2 -2
- package/dist/assets/AppSettings-Cs4POznd.js +0 -2
- package/dist/assets/Extensions-B9QdiNOV.js +0 -2
- package/dist/assets/Scheduler-DSVBWqRK.js +0 -16
- package/dist/assets/Skills-DTXehVS7.js +0 -12
- package/dist/assets/index-C9w-dVzo.js +0 -3090
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* matrixHtml.cjs — renders a valid CompetitiveMatrix (competitiveMatrix.cjs)
|
|
5
|
+
* into one self-contained, read-only HTML page for the Project Home Pages
|
|
6
|
+
* library. Pure: no I/O. No <script>, no href=/src= attributes, no CSS url(),
|
|
7
|
+
* so the page passes validateHomeHtml and never reaches the network.
|
|
8
|
+
*
|
|
9
|
+
* Every matrix string comes from web research, so every one of them goes
|
|
10
|
+
* through escapeHtml before it reaches the document.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { missingFeatures } = require('./competitiveMatrix.cjs');
|
|
14
|
+
|
|
15
|
+
const PRIORITIES = ['P0', 'P1', 'P2', 'P3', 'none'];
|
|
16
|
+
|
|
17
|
+
const STATUS = {
|
|
18
|
+
yes: { symbol: '✓', label: 'Has it' },
|
|
19
|
+
partial: { symbol: '◐', label: 'Partial' },
|
|
20
|
+
no: { symbol: '✗', label: 'Missing' },
|
|
21
|
+
unknown: { symbol: '?', label: 'Unknown' },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const ESCAPES = {
|
|
25
|
+
'&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '@': '@', '(': '(',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Escape & < > " ' for text and attribute contexts, plus @ and ( so research
|
|
30
|
+
* text like "@import url(https://…)" or "eval(" never trips validateHomeHtml's
|
|
31
|
+
* literal pattern checks.
|
|
32
|
+
*/
|
|
33
|
+
function escapeHtml(s) {
|
|
34
|
+
return String(s == null ? '' : s).replace(/[&<>"'@(]/g, (c) => ESCAPES[c]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const CSS = `
|
|
38
|
+
:root{--bg:#ffffff;--fg:#1f2328;--muted:#656d76;--border:#d0d7de;--head:#f6f8fa;
|
|
39
|
+
--yes-bg:#dafbe1;--yes-fg:#116329;--partial-bg:#fff8c5;--partial-fg:#7d4e00;
|
|
40
|
+
--no-bg:#ffebe9;--no-fg:#a40e26;--unknown-bg:#eaeef2;--unknown-fg:#57606a;--accent:#0969da}
|
|
41
|
+
@media (prefers-color-scheme: dark){:root{--bg:#0d1117;--fg:#e6edf3;--muted:#8d96a0;--border:#30363d;--head:#161b22;
|
|
42
|
+
--yes-bg:#0f2e1a;--yes-fg:#56d364;--partial-bg:#2e2508;--partial-fg:#e3b341;
|
|
43
|
+
--no-bg:#3a1118;--no-fg:#ff7b72;--unknown-bg:#21262d;--unknown-fg:#8d96a0;--accent:#4493f8}}
|
|
44
|
+
*{box-sizing:border-box}
|
|
45
|
+
body{margin:0;padding:24px;background:var(--bg);color:var(--fg);
|
|
46
|
+
font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}
|
|
47
|
+
h1{font-size:22px;margin:0 0 4px}
|
|
48
|
+
h2{font-size:17px;margin:28px 0 8px;border-bottom:1px solid var(--border);padding-bottom:4px}
|
|
49
|
+
h3{font-size:15px;margin:18px 0 6px}
|
|
50
|
+
.meta,.muted{color:var(--muted)}
|
|
51
|
+
.meta{margin:0 0 8px}
|
|
52
|
+
.vs{font-weight:400;color:var(--muted)}
|
|
53
|
+
.empty{padding:16px;border:1px dashed var(--border);border-radius:6px;color:var(--muted)}
|
|
54
|
+
.scroll{overflow-x:auto;border:1px solid var(--border);border-radius:6px;margin-bottom:8px}
|
|
55
|
+
table{border-collapse:separate;border-spacing:0;width:100%;font-size:13px}
|
|
56
|
+
th,td{padding:6px 8px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}
|
|
57
|
+
thead th{background:var(--head);font-weight:600;white-space:nowrap}
|
|
58
|
+
th.feat{position:sticky;left:0;z-index:1;background:var(--head);min-width:180px;max-width:280px}
|
|
59
|
+
tbody th.feat{background:var(--bg);font-weight:500}
|
|
60
|
+
tr:last-child th,tr:last-child td{border-bottom:none}
|
|
61
|
+
.chip{display:inline-block;padding:1px 7px;border-radius:10px;font-weight:600;font-size:12px;white-space:nowrap}
|
|
62
|
+
.s-yes{background:var(--yes-bg);color:var(--yes-fg)}
|
|
63
|
+
.s-partial{background:var(--partial-bg);color:var(--partial-fg)}
|
|
64
|
+
.s-no{background:var(--no-bg);color:var(--no-fg)}
|
|
65
|
+
.s-unknown{background:var(--unknown-bg);color:var(--unknown-fg)}
|
|
66
|
+
.note{display:block;color:var(--muted);font-size:12px;margin-top:2px}
|
|
67
|
+
.prio{display:inline-block;min-width:34px;text-align:center;padding:1px 6px;border-radius:4px;
|
|
68
|
+
border:1px solid var(--border);font-weight:700;font-size:12px;margin-right:6px}
|
|
69
|
+
.p-P0{color:var(--no-fg);border-color:var(--no-fg)}
|
|
70
|
+
.p-P1{color:var(--partial-fg);border-color:var(--partial-fg)}
|
|
71
|
+
ol,ul{padding-left:20px}
|
|
72
|
+
li{margin:4px 0}
|
|
73
|
+
.feature{border:1px solid var(--border);border-radius:6px;padding:10px 12px;margin:8px 0}
|
|
74
|
+
.feature h3{margin:0 0 4px}
|
|
75
|
+
.url{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;word-break:break-all;color:var(--accent)}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
function rank(f) {
|
|
79
|
+
return PRIORITIES.indexOf(f.recommendation.priority);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function byPriorityThenTitle(a, b) {
|
|
83
|
+
return (rank(a) - rank(b)) || a.title.localeCompare(b.title);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function dateOf(iso) {
|
|
87
|
+
return escapeHtml(String(iso || '').slice(0, 10));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function chip(status) {
|
|
91
|
+
const s = STATUS[status] || STATUS.unknown;
|
|
92
|
+
const key = STATUS[status] ? status : 'unknown';
|
|
93
|
+
return `<span class="chip s-${key}">${s.symbol} ${s.label}</span>`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function renderHeader(matrix) {
|
|
97
|
+
const names = matrix.competitors.map((c) => escapeHtml(c.name)).join(', ');
|
|
98
|
+
const runs = matrix.runs.length;
|
|
99
|
+
return [
|
|
100
|
+
'<header>',
|
|
101
|
+
`<h1>${escapeHtml(matrix.product.name)} <span class="vs">vs ${names}</span></h1>`,
|
|
102
|
+
`<p class="meta">Updated ${dateOf(matrix.updatedAt)} · ${runs} run${runs === 1 ? '' : 's'}`
|
|
103
|
+
+ ` · ${matrix.features.length} feature${matrix.features.length === 1 ? '' : 's'}</p>`,
|
|
104
|
+
matrix.product.summary ? `<p class="muted">${escapeHtml(matrix.product.summary)}</p>` : '',
|
|
105
|
+
'</header>',
|
|
106
|
+
].join('\n');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function renderGroupTable(group, features, products) {
|
|
110
|
+
const out = [];
|
|
111
|
+
out.push(`<h3>${escapeHtml(group.title)}</h3>`);
|
|
112
|
+
if (group.description) out.push(`<p class="muted">${escapeHtml(group.description)}</p>`);
|
|
113
|
+
out.push('<div class="scroll"><table><thead><tr><th class="feat">Feature</th>');
|
|
114
|
+
for (const p of products) out.push(`<th>${escapeHtml(p.name)}</th>`);
|
|
115
|
+
out.push('</tr></thead><tbody>');
|
|
116
|
+
for (const f of features) {
|
|
117
|
+
out.push(`<tr><th class="feat">${escapeHtml(f.title)}</th>`);
|
|
118
|
+
for (const p of products) {
|
|
119
|
+
const s = f.support[p.id] || { status: 'unknown', note: '' };
|
|
120
|
+
const note = s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : '';
|
|
121
|
+
out.push(`<td>${chip(s.status)}${note}</td>`);
|
|
122
|
+
}
|
|
123
|
+
out.push('</tr>');
|
|
124
|
+
}
|
|
125
|
+
out.push('</tbody></table></div>');
|
|
126
|
+
return out.join('');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function renderMatrixSection(matrix) {
|
|
130
|
+
const out = ['<section>', '<h2>Feature matrix</h2>'];
|
|
131
|
+
if (matrix.features.length === 0) {
|
|
132
|
+
out.push('<p class="empty">No features yet</p>', '</section>');
|
|
133
|
+
return out.join('\n');
|
|
134
|
+
}
|
|
135
|
+
const products = [{ id: 'self', name: matrix.product.name }, ...matrix.competitors];
|
|
136
|
+
for (const g of matrix.groups) {
|
|
137
|
+
const features = matrix.features.filter((f) => f.groupId === g.id).sort(byPriorityThenTitle);
|
|
138
|
+
if (features.length === 0) continue;
|
|
139
|
+
out.push(renderGroupTable(g, features, products));
|
|
140
|
+
}
|
|
141
|
+
out.push('</section>');
|
|
142
|
+
return out.join('\n');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function renderRecommendations(matrix) {
|
|
146
|
+
const missing = missingFeatures(matrix);
|
|
147
|
+
const out = ['<section>', '<h2>Recommendations</h2>'];
|
|
148
|
+
if (missing.length === 0) {
|
|
149
|
+
out.push('<p class="muted">Nothing missing — every tracked feature is covered.</p>');
|
|
150
|
+
} else {
|
|
151
|
+
out.push('<ol>');
|
|
152
|
+
for (const f of missing) {
|
|
153
|
+
const p = f.recommendation.priority;
|
|
154
|
+
out.push(`<li><span class="prio p-${escapeHtml(p)}">${escapeHtml(p)}</span>`
|
|
155
|
+
+ `<strong>${escapeHtml(f.title)}</strong> ${chip(f.support.self.status)}`
|
|
156
|
+
+ (f.recommendation.rationale ? `<span class="note">${escapeHtml(f.recommendation.rationale)}</span>` : '')
|
|
157
|
+
+ '</li>');
|
|
158
|
+
}
|
|
159
|
+
out.push('</ol>');
|
|
160
|
+
}
|
|
161
|
+
out.push('</section>');
|
|
162
|
+
return out.join('\n');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function renderDetails(matrix) {
|
|
166
|
+
if (matrix.features.length === 0) return '';
|
|
167
|
+
const groupTitle = new Map(matrix.groups.map((g) => [g.id, g.title]));
|
|
168
|
+
const groupOrder = new Map(matrix.groups.map((g, i) => [g.id, i]));
|
|
169
|
+
const features = matrix.features.slice().sort((a, b) =>
|
|
170
|
+
(groupOrder.get(a.groupId) - groupOrder.get(b.groupId)) || byPriorityThenTitle(a, b));
|
|
171
|
+
const out = ['<section>', '<h2>Feature details</h2>'];
|
|
172
|
+
for (const f of features) {
|
|
173
|
+
out.push('<div class="feature">',
|
|
174
|
+
`<h3>${escapeHtml(f.title)} <span class="vs">· ${escapeHtml(groupTitle.get(f.groupId) || f.groupId)}</span></h3>`,
|
|
175
|
+
`<p>${escapeHtml(f.description)}</p>`,
|
|
176
|
+
`<p class="muted">Sentiment: <strong>${escapeHtml(f.sentiment.signal)}</strong>`
|
|
177
|
+
+ (f.sentiment.summary ? ` — ${escapeHtml(f.sentiment.summary)}` : '') + '</p>',
|
|
178
|
+
'</div>');
|
|
179
|
+
}
|
|
180
|
+
out.push('</section>');
|
|
181
|
+
return out.join('\n');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function renderSources(matrix) {
|
|
185
|
+
const out = ['<section>', '<h2>Sources</h2>'];
|
|
186
|
+
if (matrix.sources.length === 0) {
|
|
187
|
+
out.push('<p class="muted">No sources yet</p>');
|
|
188
|
+
} else {
|
|
189
|
+
out.push('<ul>');
|
|
190
|
+
for (const s of matrix.sources) {
|
|
191
|
+
const bits = [s.publisher, s.publishedAt].filter(Boolean).map(escapeHtml).join(' · ');
|
|
192
|
+
out.push(`<li><strong>${escapeHtml(s.title)}</strong>`
|
|
193
|
+
+ (bits ? ` <span class="muted">${bits}</span>` : '')
|
|
194
|
+
+ `<span class="note url">${escapeHtml(s.url)}</span></li>`);
|
|
195
|
+
}
|
|
196
|
+
out.push('</ul>');
|
|
197
|
+
}
|
|
198
|
+
out.push('</section>');
|
|
199
|
+
return out.join('\n');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function renderRuns(matrix) {
|
|
203
|
+
const runs = matrix.runs.slice().sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
204
|
+
const out = ['<section>', '<h2>Run history</h2>', '<ul>'];
|
|
205
|
+
for (const r of runs) {
|
|
206
|
+
out.push(`<li><strong>${escapeHtml(String(r.at).replace('T', ' ').slice(0, 16))}</strong>`
|
|
207
|
+
+ ` <span class="muted">${escapeHtml(r.model)} · ${r.added.length} added · ${r.changed.length} changed`
|
|
208
|
+
+ (r.competitors.length ? ` · vs ${r.competitors.map(escapeHtml).join(', ')}` : '') + '</span>'
|
|
209
|
+
+ (r.notes ? `<span class="note">${escapeHtml(r.notes)}</span>` : '') + '</li>');
|
|
210
|
+
}
|
|
211
|
+
out.push('</ul>', '</section>');
|
|
212
|
+
return out.join('\n');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** renderMatrixHtml(matrix) → complete self-contained HTML document string. */
|
|
216
|
+
function renderMatrixHtml(matrix) {
|
|
217
|
+
return [
|
|
218
|
+
'<!DOCTYPE html>',
|
|
219
|
+
'<html lang="en">',
|
|
220
|
+
'<head>',
|
|
221
|
+
'<meta charset="utf-8">',
|
|
222
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
223
|
+
`<title>${escapeHtml(matrix.product.name)} — Competitor matrix</title>`,
|
|
224
|
+
`<style>${CSS}</style>`,
|
|
225
|
+
'</head>',
|
|
226
|
+
'<body>',
|
|
227
|
+
renderHeader(matrix),
|
|
228
|
+
renderMatrixSection(matrix),
|
|
229
|
+
renderRecommendations(matrix),
|
|
230
|
+
renderDetails(matrix),
|
|
231
|
+
renderSources(matrix),
|
|
232
|
+
renderRuns(matrix),
|
|
233
|
+
'</body>',
|
|
234
|
+
'</html>',
|
|
235
|
+
'',
|
|
236
|
+
].join('\n');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
module.exports = { renderMatrixHtml, escapeHtml };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* matrixStore.cjs — the one sanctioned writer of the Competitor matrix state
|
|
5
|
+
* (writer 'project-home', namespace project-pages). writeMatrix() validates,
|
|
6
|
+
* archives the previous valid matrix.json into history/ (newest HISTORY_KEEP
|
|
7
|
+
* kept), writes matrix.json + matrix.schema.json, and refreshes the HTML
|
|
8
|
+
* snapshot as the Pages library entry knowledge/competitive-matrix.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fsp = require('node:fs/promises');
|
|
12
|
+
const path = require('node:path');
|
|
13
|
+
const config = require('../../config.cjs');
|
|
14
|
+
const { opsPath, assertOpsWrite } = require('../opsOwnership.cjs');
|
|
15
|
+
const { validateMatrix, matrixJsonSchema, matrixPaths } = require('./competitiveMatrix.cjs');
|
|
16
|
+
const { renderMatrixHtml } = require('./matrixHtml.cjs');
|
|
17
|
+
|
|
18
|
+
const WRITER = 'project-home';
|
|
19
|
+
const HISTORY_KEEP = 50;
|
|
20
|
+
const PAGE_ID = 'competitive-matrix';
|
|
21
|
+
const HISTORY_NAME_RE = /^\d{8}T\d{6}Z\.json$/;
|
|
22
|
+
|
|
23
|
+
/** '2026-11-08T12:00:00.000Z' -> '20261108T120000Z'. */
|
|
24
|
+
function historyStamp(iso) {
|
|
25
|
+
const d = new Date(iso);
|
|
26
|
+
return d.toISOString().slice(0, 19).replace(/[-:]/g, '') + 'Z';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function write(abs, text) {
|
|
30
|
+
return config.writeTextAtomic(abs, text, { writer: WRITER });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Copy the current matrix.json into history/ if it is a valid matrix; -> path or null. */
|
|
34
|
+
async function archivePrevious(paths) {
|
|
35
|
+
let buf;
|
|
36
|
+
try {
|
|
37
|
+
buf = await fsp.readFile(paths.matrix);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
if (e && e.code === 'ENOENT') return null;
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
let value;
|
|
43
|
+
try {
|
|
44
|
+
value = JSON.parse(buf.toString('utf8'));
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const v = validateMatrix(value);
|
|
49
|
+
if (!v.ok) return null;
|
|
50
|
+
const dest = path.join(paths.history, `${historyStamp(v.matrix.updatedAt)}.json`);
|
|
51
|
+
await write(dest, buf.toString('utf8'));
|
|
52
|
+
return dest;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Remove all but the newest HISTORY_KEEP history files, through the same checks renameMigrated uses. */
|
|
56
|
+
async function pruneHistory(historyDir) {
|
|
57
|
+
let names;
|
|
58
|
+
try {
|
|
59
|
+
names = await fsp.readdir(historyDir);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
if (e && e.code === 'ENOENT') return;
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
64
|
+
const files = names.filter((n) => HISTORY_NAME_RE.test(n)).sort();
|
|
65
|
+
for (const name of files.slice(0, Math.max(0, files.length - HISTORY_KEEP))) {
|
|
66
|
+
const real = config.validatePath(path.join(historyDir, name));
|
|
67
|
+
config.validateWrite(real);
|
|
68
|
+
assertOpsWrite(real, WRITER);
|
|
69
|
+
await fsp.unlink(real);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* writeMatrix(realCwd, value, { model, renderHtml }) ->
|
|
75
|
+
* { ok: true, path, htmlPath, historyPath } | { ok: false, error }.
|
|
76
|
+
* Nothing is written when validation fails — of the matrix, or of the rendered
|
|
77
|
+
* HTML snapshot against validateHomeHtml (fail closed). renderHtml is a test seam.
|
|
78
|
+
*/
|
|
79
|
+
async function writeMatrix(realCwd, value, { model = '', renderHtml = renderMatrixHtml } = {}) {
|
|
80
|
+
const v = validateMatrix(value);
|
|
81
|
+
if (!v.ok) return { ok: false, error: v.error };
|
|
82
|
+
const paths = matrixPaths(realCwd);
|
|
83
|
+
if (!paths) return { ok: false, error: 'not a project' };
|
|
84
|
+
const matrix = v.matrix;
|
|
85
|
+
const { schemas } = require('../../ipcSchemas.cjs');
|
|
86
|
+
const topic = `${matrix.product.name} vs ${matrix.competitors.map((c) => c.name).join(', ')}`.slice(0, 120);
|
|
87
|
+
const meta = schemas.projectPageMeta.parse({
|
|
88
|
+
id: PAGE_ID,
|
|
89
|
+
title: 'Competitor matrix',
|
|
90
|
+
topic,
|
|
91
|
+
createdAt: new Date().toISOString(),
|
|
92
|
+
model: String(model || '').slice(0, 60),
|
|
93
|
+
});
|
|
94
|
+
const html = renderHtml(matrix);
|
|
95
|
+
// Lazy: projectHomeAdminRoutes.cjs requires this module (circular at top level).
|
|
96
|
+
const { validateHomeHtml } = require('../feedback-remote/projectHomeAdminRoutes.cjs');
|
|
97
|
+
const rejection = validateHomeHtml(html);
|
|
98
|
+
if (rejection) return { ok: false, error: `matrix page rejected: ${rejection}` };
|
|
99
|
+
|
|
100
|
+
const historyPath = await archivePrevious(paths);
|
|
101
|
+
if (historyPath) await pruneHistory(paths.history);
|
|
102
|
+
|
|
103
|
+
await write(paths.matrix, JSON.stringify(value, null, 2) + '\n');
|
|
104
|
+
await write(paths.schema, JSON.stringify(matrixJsonSchema(), null, 2) + '\n');
|
|
105
|
+
const pageDir = opsPath(realCwd, 'project-pages', 'knowledge', PAGE_ID);
|
|
106
|
+
const htmlPath = path.join(pageDir, 'index.html');
|
|
107
|
+
await write(htmlPath, html);
|
|
108
|
+
await write(path.join(pageDir, 'meta.json'), JSON.stringify(meta, null, 2) + '\n');
|
|
109
|
+
return { ok: true, path: paths.matrix, htmlPath, historyPath };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = { writeMatrix, HISTORY_KEEP, PAGE_ID };
|
|
@@ -97,6 +97,11 @@ const PromptSessionSchema = z.object({
|
|
|
97
97
|
// false = started with the develop loop (/develop skill, delegation guard, PRD queueing) switched off;
|
|
98
98
|
// fixed for the life of its session; absent = on; only false is ever written.
|
|
99
99
|
developLoop: z.boolean().optional(),
|
|
100
|
+
// true = this Epic adopted an existing CLI session as its claudeSessionId
|
|
101
|
+
// (ensureEpic's restoreSessionId) instead of a fresh one; absent otherwise.
|
|
102
|
+
// Only true is ever written: a false would fail here, and dropInvalidSessions
|
|
103
|
+
// (ipcSchemas.cjs) would then drop the whole stored row.
|
|
104
|
+
restoredSession: z.literal(true).optional(),
|
|
100
105
|
// Absent on Epics minted before this field existed — those fall back to
|
|
101
106
|
// rendering the flat `openingPrompt` as a single block (see
|
|
102
107
|
// ChatTranscriptTurn.tsx's EpicIntakeCard).
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
*/
|
|
33
33
|
'use strict';
|
|
34
34
|
|
|
35
|
+
const { isSafeEpicId } = require('../prd/prdLocations.cjs');
|
|
36
|
+
|
|
35
37
|
function isFixPlanSlug(slug) {
|
|
36
38
|
return /^\d+-fix-/.test(slug);
|
|
37
39
|
}
|
|
@@ -59,4 +61,16 @@ function resolveIsFixPlan(slug, isFixPlan) {
|
|
|
59
61
|
return isFixPlanSlug(slug);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The ONE repo-relative path a fix plan may name for a validation record
|
|
66
|
+
* (PRD 2883). Lives under the authored `reviews/` namespace — never under the
|
|
67
|
+
* gitignored `scheduler/` runtime folder, where the fix-plan PRD file itself
|
|
68
|
+
* sits. An unsafe/missing epicId drops the epic segment rather than
|
|
69
|
+
* concatenating it into a path.
|
|
70
|
+
*/
|
|
71
|
+
function fixPlanRecordPath(epicId, fixSlug) {
|
|
72
|
+
const base = 'session-manager-operations/reviews/validation';
|
|
73
|
+
return isSafeEpicId(epicId) ? `${base}/${epicId}/${fixSlug}.md` : `${base}/${fixSlug}.md`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = { isFixPlanSlug, classifyDiscoveredFixPlan, resolveIsFixPlan, fixPlanRecordPath };
|
|
@@ -279,6 +279,40 @@ function mapOutcomeToGateOutcome(outcome) {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
/**
|
|
283
|
+
* resolveReapGateOutcome(outcome, resultText) → 'passed'|'failed'|'never_ran'|'unknown'
|
|
284
|
+
*
|
|
285
|
+
* The reaper's gateOutcome for a non-pidless dead row. Unlike
|
|
286
|
+
* mapOutcomeToGateOutcome, 'passed' is NOT inferred from the CLI result
|
|
287
|
+
* event's subtype=success — that only says the session ended cleanly, not
|
|
288
|
+
* that a gate ran (Bilko job 1685 never ran its gate, printed no verdict, and
|
|
289
|
+
* was stamped 'passed'). 'passed' requires the run's own LAST
|
|
290
|
+
* `SCHEDULER_VERDICT:` line to say PASS. Each line is classified by
|
|
291
|
+
* runVerify.cjs's scanSentinel (the one SCHEDULER_VERDICT parser), scanned
|
|
292
|
+
* from the end so the final say wins.
|
|
293
|
+
*/
|
|
294
|
+
function lastVerdictLine(resultText) {
|
|
295
|
+
if (typeof resultText !== 'string' || !resultText) return null;
|
|
296
|
+
// Lazy require: runVerify.cjs is a larger module; keep this lib cheap to load.
|
|
297
|
+
const { scanSentinel } = require('../../runVerify.cjs');
|
|
298
|
+
const lines = resultText.split('\n');
|
|
299
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
300
|
+
const v = scanSentinel({ resultText: lines[i].replace(/\r$/, '') }, []);
|
|
301
|
+
if (v) return v;
|
|
302
|
+
}
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function resolveReapGateOutcome(outcome, resultText) {
|
|
307
|
+
if (outcome === 'failed') return 'failed';
|
|
308
|
+
if (outcome === 'no_result') return 'never_ran';
|
|
309
|
+
if (outcome !== 'success') return 'unknown';
|
|
310
|
+
const verdict = lastVerdictLine(resultText);
|
|
311
|
+
if (verdict === 'pass') return 'passed';
|
|
312
|
+
if (verdict === 'fail') return 'failed';
|
|
313
|
+
return 'unknown';
|
|
314
|
+
}
|
|
315
|
+
|
|
282
316
|
// Max times an orphaned job may be re-queued before giving up (marking failed).
|
|
283
317
|
// Single source of truth: both the in-app reaper (scheduler.cjs) and the external
|
|
284
318
|
// offline watchdog (watchdogHelpers.cjs) import this so their give-up budgets can
|
|
@@ -527,6 +561,7 @@ module.exports = {
|
|
|
527
561
|
isClaudeArgv,
|
|
528
562
|
classifyRunOutcome,
|
|
529
563
|
mapOutcomeToGateOutcome,
|
|
564
|
+
resolveReapGateOutcome,
|
|
530
565
|
ORPHAN_REQUEUE_CAP,
|
|
531
566
|
selectReapableJobs,
|
|
532
567
|
findLiveProcessForJob,
|
|
@@ -107,6 +107,8 @@ const ScheduleJobSchema = z
|
|
|
107
107
|
quietLeaseDegraded: z.boolean().optional(),
|
|
108
108
|
// Salvaged uncommitted diff patch path (PRD 1098).
|
|
109
109
|
salvagePatch: z.string().nullable().optional(),
|
|
110
|
+
// Pin of a dead run's uncommitted checkout work (refs/sm-uncommitted/...), PRD 2892.
|
|
111
|
+
uncommittedSnapshot: z.object({ sha: z.string(), ref: z.string() }).optional(),
|
|
110
112
|
// Leftover-attribution fields: the newly-dirty paths a terminal run left
|
|
111
113
|
// uncommitted, diffed against the persisted pre-run baseline
|
|
112
114
|
// (guardBaseline/guardHeadBefore below). Set on EVERY terminal outcome
|
|
@@ -63,13 +63,14 @@ const STATUS_HISTORY_CAP = 20;
|
|
|
63
63
|
* executor ever ran; kept distinct from 'completed' so unrun work can't
|
|
64
64
|
* read as shipped), running->pending (halt/rate-limit reset,
|
|
65
65
|
* transient-failure retry). Also reached with verdict
|
|
66
|
-
* 'reaped_without_integration' (source 'reapDeadRunningJobs', PRD 1133):
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* as
|
|
66
|
+
* 'reaped_without_integration' (source 'reapDeadRunningJobs', PRD 1133):
|
|
67
|
+
* the reaper lands a run that printed its own SCHEDULER_VERDICT: PASS
|
|
68
|
+
* line (integrating its worktree branch) and parks here only a run
|
|
69
|
+
* without one whose work cannot be shown to have landed — a worktree
|
|
70
|
+
* branch still holding unmerged commits, or an in-place run whose HEAD
|
|
71
|
+
* never advanced during the run window — naming the branch (or the lack
|
|
72
|
+
* of any commit) so the stranded work is never silently treated as
|
|
73
|
+
* shipped.
|
|
73
74
|
* - investigating->failed|needs_review (restore prior status once the
|
|
74
75
|
* investigation probe exits), investigating->completed (defensive: the
|
|
75
76
|
* restored prior status could in principle be 'completed' if a caller
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* refcounted per-cwd watcher pushes `project-pages:changed` for either. It
|
|
12
12
|
* never writes content (watch()'s mkdir creates an empty directory only).
|
|
13
13
|
* mdNetwork() maps the project's markdown link network on demand
|
|
14
|
-
* (lib/mdNetworkScan.cjs) for the Tools pane.
|
|
14
|
+
* (lib/mdNetworkScan.cjs) for the Tools pane. matrix() reads the saved
|
|
15
|
+
* Competitor matrix (lib/project-pages/competitiveMatrix.cjs readMatrix).
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
const { ipcMain } = require('electron');
|
|
@@ -23,6 +24,7 @@ const { opsPath, assertOpsWrite, resolveProjectRoot } = require('./lib/opsOwners
|
|
|
23
24
|
const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
24
25
|
const { listLibrary, migrateLegacy } = require('./lib/project-pages/pagesLibrary.cjs');
|
|
25
26
|
const { scanMdNetwork } = require('./lib/mdNetworkScan.cjs');
|
|
27
|
+
const { readMatrix } = require('./lib/project-pages/competitiveMatrix.cjs');
|
|
26
28
|
|
|
27
29
|
let mainWindow = null;
|
|
28
30
|
function attachWindow(window) {
|
|
@@ -103,11 +105,29 @@ async function mdNetwork({ cwd }) {
|
|
|
103
105
|
return scanMdNetwork(root);
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
const MATRIX_EPHEMERAL = 'refusing an ephemeral cwd (tmpdir or linked git worktree): no project matrix';
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* -> CompetitorMatrixResult: the saved Competitor matrix, read once per call.
|
|
112
|
+
* Resolves the project root like mdNetwork(); `{ ok: true, matrix, error }`
|
|
113
|
+
* from readMatrix (matrix null when none / invalid, error set when invalid),
|
|
114
|
+
* or `{ ok: false, error }` when the cwd has no project root.
|
|
115
|
+
*/
|
|
116
|
+
async function matrix({ cwd }) {
|
|
117
|
+
const { root, ephemeral } = tryProjectRoot(config.validatePath(cwd));
|
|
118
|
+
if (ephemeral) return { ok: false, error: MATRIX_EPHEMERAL };
|
|
119
|
+
const { matrix: m, error } = await readMatrix(root);
|
|
120
|
+
return { ok: true, matrix: m, error };
|
|
121
|
+
}
|
|
122
|
+
|
|
106
123
|
/** True for paths whose change should refresh the library (relative to project-pages/). */
|
|
107
124
|
function isLibraryPath(rel) {
|
|
108
125
|
const parts = rel.split(path.sep);
|
|
109
126
|
if (parts.length === 1) return parts[0] === 'home.html';
|
|
110
|
-
if (parts.length === 2)
|
|
127
|
+
if (parts.length === 2) {
|
|
128
|
+
if (parts[0] === 'matrix' && parts[1] === 'matrix.json') return true;
|
|
129
|
+
return parts[0] === 'demo-video' && parts[1] === 'index.html';
|
|
130
|
+
}
|
|
111
131
|
if (parts.length === 3 && (parts[0] === 'knowledge' || parts[0] === 'videos')) {
|
|
112
132
|
return parts[1] !== '_character' && (parts[2] === 'index.html' || parts[2] === 'meta.json');
|
|
113
133
|
}
|
|
@@ -275,6 +295,7 @@ function registerProjectPagesIpc() {
|
|
|
275
295
|
const { schemas: s, validated: v } = require('./ipcSchemas.cjs');
|
|
276
296
|
ipcMain.handle('project-pages:get', v(s.projectPagesCwd, get));
|
|
277
297
|
ipcMain.handle('project-pages:md-network', v(s.projectPagesCwd, mdNetwork));
|
|
298
|
+
ipcMain.handle('project-pages:matrix', v(s.projectPagesCwd, matrix));
|
|
278
299
|
ipcMain.handle('project-pages:watch', v(s.projectPagesCwd, ({ cwd }) => watchOutput(cwd)));
|
|
279
300
|
ipcMain.handle('project-pages:rename', v(s.projectPagesRename, renameEntry));
|
|
280
301
|
ipcMain.handle('project-pages:delete', v(s.projectPagesDelete, deleteEntry));
|
|
@@ -289,6 +310,8 @@ module.exports = {
|
|
|
289
310
|
registerProjectPagesIpc,
|
|
290
311
|
get,
|
|
291
312
|
mdNetwork,
|
|
313
|
+
matrix,
|
|
314
|
+
isLibraryPath,
|
|
292
315
|
renameEntry,
|
|
293
316
|
deleteEntry,
|
|
294
317
|
watchOutput,
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Main-process counterpart to promptSessions.ts's event chain, used
|
|
6
|
-
*
|
|
7
|
-
* scheduler.cjs)
|
|
5
|
+
* Main-process counterpart to promptSessions.ts's event chain, used by the
|
|
6
|
+
* scheduler's PRD-finished notification path (notifyOriginatingTab,
|
|
7
|
+
* scheduler.cjs) and by macros:dispatch-job (macroJobIpc.cjs), which appends a
|
|
8
|
+
* durable 'job-not-queued' notice when a macro's background build could not be
|
|
9
|
+
* queued for its Epic (PRD 2950). The renderer owns the live in-memory PromptSession store
|
|
8
10
|
* and its own persistActiveIndex; this module never touches that store — it
|
|
9
11
|
* reads/writes the SAME on-disk active-index.json directly, read-modify-
|
|
10
12
|
* write, so a scheduler job (which runs in the main process, with no
|
|
@@ -23,8 +25,8 @@ const config = require('./config.cjs');
|
|
|
23
25
|
const { activeIndexPath: promptSessionActiveIndexPath, withPathLock } = require('./lib/epic/epicMint.cjs');
|
|
24
26
|
|
|
25
27
|
// IPC channel broadcast whenever an event is appended to a PromptSession's
|
|
26
|
-
// chain from the main process (
|
|
27
|
-
//
|
|
28
|
+
// chain from the main process (the scheduler's and macroJobIpc's
|
|
29
|
+
// response-event appends below). Mirrors chatRunner.cjs's attachWindow/broadcast pattern.
|
|
28
30
|
const EVENT_APPENDED_CHANNEL = 'promptSession:event-appended';
|
|
29
31
|
|
|
30
32
|
let mainWindow = null;
|
|
@@ -68,7 +70,8 @@ function mintEventId() {
|
|
|
68
70
|
* regardless of the job's self-reported outcome; the authoring Epic's own
|
|
69
71
|
* validation pass is what may later move it to 'verified'/'refuted'. `agentType`
|
|
70
72
|
* (the job's agent) and `digestKey` (the settle digest's stable key) ride the
|
|
71
|
-
* same meta arg and are copied the same way
|
|
73
|
+
* same meta arg and are copied the same way, as is `notice` (PRD 2950 — a
|
|
74
|
+
* marker like 'job-not-queued' the renderer turns into a distinct notice). All
|
|
72
75
|
* keys are added to the event object only when present in `meta`, never as
|
|
73
76
|
* `undefined`-valued keys, so events appended without them serialize
|
|
74
77
|
* identically to before.
|
|
@@ -100,6 +103,7 @@ async function appendResponseEventWithReason(cwd, sourcePromptId, text, meta = {
|
|
|
100
103
|
if (meta && meta.validation) event.validation = meta.validation;
|
|
101
104
|
if (meta && meta.agentType) event.agentType = meta.agentType;
|
|
102
105
|
if (meta && meta.digestKey) event.digestKey = meta.digestKey;
|
|
106
|
+
if (meta && meta.notice) event.notice = meta.notice;
|
|
103
107
|
data.events[sourcePromptId] = [...events, event];
|
|
104
108
|
await config.writeJson(path, data, { writer: 'scheduler' });
|
|
105
109
|
broadcast(EVENT_APPENDED_CHANNEL, { cwd, promptSessionId: sourcePromptId, event });
|
package/src/main/runVerify.cjs
CHANGED
|
@@ -809,8 +809,10 @@ async function verifyRun({
|
|
|
809
809
|
// bare PASS with no commit from one is still a strong silent-failure
|
|
810
810
|
// signal and stays covered by this check.
|
|
811
811
|
const isFixPlanJob = /^\d+-fix-/.test(queueEntry?.slug || '');
|
|
812
|
-
// A transcript-reported commit that
|
|
813
|
-
//
|
|
812
|
+
// A transcript-reported commit that exists in the repo but never landed
|
|
813
|
+
// on the checkout's HEAD (on no ref, for -merge-main slugs) was dropped
|
|
814
|
+
// (detached HEAD, off-branch, rewritten base); no no-commit exemption may
|
|
815
|
+
// excuse it.
|
|
814
816
|
let unlandedTranscriptShas = [];
|
|
815
817
|
if (sentinel === 'pass' && !commitEvidence && cwdIsGitRepo) {
|
|
816
818
|
unlandedTranscriptShas = (transcriptCommitShas || [])
|
|
@@ -822,7 +824,10 @@ async function verifyRun({
|
|
|
822
824
|
if (unlandedTranscriptShas.length > 0) {
|
|
823
825
|
issues.push({
|
|
824
826
|
verdict: 'run_commit_not_landed',
|
|
825
|
-
reason: 'SCHEDULER_VERDICT: PASS but the transcript reports a commit that
|
|
827
|
+
reason: 'SCHEDULER_VERDICT: PASS but the transcript reports a commit that '
|
|
828
|
+
+ (isMergeMainSlug(queueEntry?.slug)
|
|
829
|
+
? 'is on no ref: '
|
|
830
|
+
: "exists in the repo but never landed on the checkout's HEAD: ")
|
|
826
831
|
+ unlandedTranscriptShas.join(', '),
|
|
827
832
|
priority: 1,
|
|
828
833
|
downgradeTo: 'needs_review',
|