claude-code-session-manager 0.138.0 → 0.140.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/.claude-plugin/marketplace.json +1 -1
- package/README.md +352 -79
- package/dist/assets/AppSettings-CMFEM68R.js +2 -0
- package/dist/assets/History--JwsFnbn.js +2 -0
- package/dist/assets/HomeClaudeConfig-ijEXs--3.js +3 -0
- package/dist/assets/{Panel-CeDiyuNn.js → Panel-CALyU0pe.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-sdlA-fUb.js +26 -0
- package/dist/assets/Scheduler-YT3j8SUa.js +16 -0
- package/dist/assets/{SkillReferenceGraph-CFMK8NJh.js → SkillReferenceGraph-CxAuwhNN.js} +1 -1
- package/dist/assets/Skills-DtRzghn5.js +67 -0
- package/dist/assets/{TiptapBody-D1kTj-tn.js → TiptapBody-DApeu7x8.js} +60 -54
- package/dist/assets/ViewTabs-B7qLXRAH.js +1 -0
- package/dist/assets/{VoiceButton-CZeyPM31.js → VoiceButton-DtStfv1H.js} +1 -1
- package/dist/assets/{historyTotals-B00l64Jw.js → historyTotals-ydfnwepc.js} +1 -1
- package/dist/assets/index-CtxruO1L.js +3121 -0
- package/dist/assets/{index-62tyjEQB.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +467 -451
- package/package.json +17 -6
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +12 -4
- package/plugins/session-manager-dev/skills/builder/scripts/publish-preflight.cjs +255 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +36 -22
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +2 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +360 -35
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +2 -2
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/exchanges.cjs +70 -5
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +172 -63
- package/src/main/historyDashboard.cjs +87 -17
- package/src/main/index.cjs +78 -4
- package/src/main/ipcSchemas.cjs +233 -20
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +92 -22
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/modelPricing.cjs +148 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +121 -0
- package/src/main/lib/epic/epicJobReceipt.cjs +87 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +423 -0
- package/src/main/lib/epic/epicOutsideState.cjs +233 -0
- package/src/main/lib/epic/epicSettle.cjs +1 -1
- package/src/main/lib/epic/epicStateWatcher.cjs +157 -0
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/externalRef.cjs +37 -0
- package/src/main/lib/epic/externalRefIndex.cjs +136 -0
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/epic/restorableSessions.cjs +151 -17
- package/src/main/lib/epic/transcriptUsage.cjs +197 -0
- package/src/main/lib/externalContract.cjs +137 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +176 -5
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +186 -9
- package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -6
- package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +50 -8
- package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +218 -4
- package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +19 -3
- package/src/main/lib/feedback-remote/feedbackImages.cjs +171 -0
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +11 -10
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +167 -21
- package/src/main/lib/feedback-remote/needsYouAdminRoutes.cjs +133 -0
- package/src/main/lib/feedback-remote/needsYouIpc.cjs +50 -0
- package/src/main/lib/feedback-remote/needsYouStore.cjs +285 -0
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +58 -5
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +232 -25
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/agentAdminRoutes.cjs +121 -0
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +351 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +96 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/promptSessionSchema.cjs +4 -0
- package/src/main/lib/remoteTranscriptTail.cjs +32 -1
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +12 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/lib/telemetry/auditEvents.cjs +176 -0
- package/src/main/lib/telemetry/eventsAdminRoutes.cjs +45 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +11 -2
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +4 -1
- package/src/main/scheduler/starvation.cjs +20 -18
- package/src/main/scheduler.cjs +774 -64
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +7 -1
- package/src/main/transcripts.cjs +62 -7
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +132 -20
- package/src/preload/api.d.ts +434 -28
- package/src/preload/apiSurface.cjs +7 -0
- package/src/preload/apiSurface.json +485 -81
- package/src/preload/index.cjs +38 -5
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AgentLibrary-C1d_D7uQ.js +0 -2
- package/dist/assets/AppSettings-CgDhqrsU.js +0 -2
- package/dist/assets/Button-Bk23rEnZ.js +0 -1
- package/dist/assets/DocumentEditorPane-BqY5Nq6W.js +0 -1
- package/dist/assets/Extensions-CXem-uwI.js +0 -2
- package/dist/assets/History-BwO3coo4.js +0 -2
- package/dist/assets/Library-BDV69fSe.js +0 -32
- package/dist/assets/ListDetail-CD-Fm6mh.js +0 -1
- package/dist/assets/ProjectClaudeConfig-NjdKdwe8.js +0 -25
- package/dist/assets/ProvenanceBadge-Bu8NmI_R.js +0 -1
- package/dist/assets/Scheduler-CkhTvG7C.js +0 -16
- package/dist/assets/Settings-COT34hBF.js +0 -2
- package/dist/assets/Skills-BgexoUkQ.js +0 -29
- package/dist/assets/SourceChip-BXjcdeb1.js +0 -1
- package/dist/assets/SystemPrompt-CeeH3EeW.js +0 -1
- package/dist/assets/Toggle-CENi19iK.js +0 -1
- package/dist/assets/ViewTabs-DDBb0x96.js +0 -1
- package/dist/assets/claude-settings-schema-COigsajx.js +0 -3
- package/dist/assets/index-CgCxpunJ.js +0 -3116
|
@@ -75,10 +75,13 @@ function splitFrontmatter(raw) {
|
|
|
75
75
|
* emitted only in its inline `[a, b]` list form (the sole form prdCreate.cjs
|
|
76
76
|
* ever writes; block-style YAML lists are out of scope). An empty array is
|
|
77
77
|
* never emitted, which is how `scheduler_update_prd` clears a dependency.
|
|
78
|
+
*
|
|
79
|
+
* `fixes` (the earlier PRDs this one repairs) is a one-line JSON array of
|
|
80
|
+
* { prd, missKind, reason } — see parseFixes.
|
|
78
81
|
*/
|
|
79
82
|
|
|
80
|
-
const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort']);
|
|
81
|
-
const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort'];
|
|
83
|
+
const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'riskTools']);
|
|
84
|
+
const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'riskTools'];
|
|
82
85
|
// Mirrors modelCatalog.cjs CATALOG_FLOOR.effortLevels. A closed set so the
|
|
83
86
|
// value is always safe as a frontmatter line and as a --effort argv token.
|
|
84
87
|
const PRD_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
@@ -125,6 +128,52 @@ function parseInlineList(raw) {
|
|
|
125
128
|
.filter((s) => s.length > 0);
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Quote-aware inline list for `riskTools` — tool-risk rule strings carry
|
|
133
|
+
* parentheses, spaces, colons and sometimes commas (`Bash(echo a,b)`), so a
|
|
134
|
+
* plain comma split cannot carry them. An entry that would be ambiguous bare
|
|
135
|
+
* (comma, bracket, quote, `#`, edge whitespace) is written as a JSON string;
|
|
136
|
+
* every other entry is written bare, so `riskTools: [a, b]` reads as ['a','b'].
|
|
137
|
+
* Returns null when `raw` isn't a well-formed bracketed list.
|
|
138
|
+
*/
|
|
139
|
+
function parseQuotedInlineList(raw) {
|
|
140
|
+
const v = String(raw ?? '').trim();
|
|
141
|
+
if (!v.startsWith('[') || !v.endsWith(']')) return null;
|
|
142
|
+
const inner = v.slice(1, -1);
|
|
143
|
+
const out = [];
|
|
144
|
+
let i = 0;
|
|
145
|
+
const skipWs = () => { while (i < inner.length && /\s/.test(inner[i])) i++; };
|
|
146
|
+
skipWs();
|
|
147
|
+
if (i === inner.length) return [];
|
|
148
|
+
for (;;) {
|
|
149
|
+
skipWs();
|
|
150
|
+
let item;
|
|
151
|
+
if (inner[i] === '"') {
|
|
152
|
+
let j = i + 1;
|
|
153
|
+
while (j < inner.length && inner[j] !== '"') j += inner[j] === '\\' ? 2 : 1;
|
|
154
|
+
if (j >= inner.length) return null;
|
|
155
|
+
try { item = JSON.parse(inner.slice(i, j + 1)); } catch { return null; }
|
|
156
|
+
i = j + 1;
|
|
157
|
+
skipWs();
|
|
158
|
+
if (i < inner.length && inner[i] !== ',') return null;
|
|
159
|
+
} else {
|
|
160
|
+
const j = inner.indexOf(',', i);
|
|
161
|
+
const end = j === -1 ? inner.length : j;
|
|
162
|
+
item = inner.slice(i, end).trim();
|
|
163
|
+
i = end;
|
|
164
|
+
}
|
|
165
|
+
if (item.length > 0) out.push(item);
|
|
166
|
+
if (i >= inner.length) break;
|
|
167
|
+
i++; // past ','
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function formatQuotedInlineList(list) {
|
|
173
|
+
const enc = (s) => (/[,\[\]"'#]|^\s|\s$/.test(s) ? JSON.stringify(s) : s);
|
|
174
|
+
return `[${list.map(enc).join(', ')}]`;
|
|
175
|
+
}
|
|
176
|
+
|
|
128
177
|
/**
|
|
129
178
|
* The one definition of an artifact-only PRD: `deliverable: artifact` plus a
|
|
130
179
|
* non-empty `artifactPaths` list. Used by runVerify's artifact exemption,
|
|
@@ -141,6 +190,27 @@ function isArtifactOnlyDeclaration(decl) {
|
|
|
141
190
|
&& decl.artifactPaths.length > 0;
|
|
142
191
|
}
|
|
143
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Parse the `fixes` value — a one-line JSON array of { prd, missKind, reason }
|
|
195
|
+
* (the sole form prdCreate.cjs's buildPrdBody writes). Returns null for anything
|
|
196
|
+
* else (not JSON, not an array, or an entry missing a string field), so a
|
|
197
|
+
* hand-mangled value is left unset rather than half-parsed.
|
|
198
|
+
*/
|
|
199
|
+
function parseFixes(raw) {
|
|
200
|
+
const v = String(raw ?? '').trim();
|
|
201
|
+
if (!v.startsWith('[')) return null;
|
|
202
|
+
let arr;
|
|
203
|
+
try { arr = JSON.parse(v); } catch { return null; }
|
|
204
|
+
if (!Array.isArray(arr)) return null;
|
|
205
|
+
const out = [];
|
|
206
|
+
for (const e of arr) {
|
|
207
|
+
if (e == null || typeof e !== 'object' || Array.isArray(e)) return null;
|
|
208
|
+
if (typeof e.prd !== 'string' || typeof e.missKind !== 'string' || typeof e.reason !== 'string') return null;
|
|
209
|
+
out.push({ prd: e.prd, missKind: e.missKind, reason: e.reason });
|
|
210
|
+
}
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
213
|
+
|
|
144
214
|
function arraysEqual(a, b) {
|
|
145
215
|
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
146
216
|
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
@@ -192,6 +262,11 @@ function applyKey(fm, key, after) {
|
|
|
192
262
|
if (list) fm.dependsOn = list;
|
|
193
263
|
return;
|
|
194
264
|
}
|
|
265
|
+
case 'fixes': {
|
|
266
|
+
const list = parseFixes(after);
|
|
267
|
+
if (list && list.length) fm.fixes = list;
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
195
270
|
case 'quietMachine':
|
|
196
271
|
// Opt-in exclusive-lease flag (PRD 1107) — only a literal `true`
|
|
197
272
|
// frontmatter value opts in; anything else (including an explicit
|
|
@@ -228,6 +303,12 @@ function applyKey(fm, key, after) {
|
|
|
228
303
|
if (list) fm.artifactPaths = list;
|
|
229
304
|
return;
|
|
230
305
|
}
|
|
306
|
+
case 'riskTools': {
|
|
307
|
+
// Quote-aware inline list (rule strings can hold commas) — see parseQuotedInlineList.
|
|
308
|
+
const list = parseQuotedInlineList(after);
|
|
309
|
+
if (list) fm.riskTools = list;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
231
312
|
}
|
|
232
313
|
}
|
|
233
314
|
|
|
@@ -263,7 +344,7 @@ function parsePrdFile(text) {
|
|
|
263
344
|
|
|
264
345
|
if (RECOGNIZED_KEYS.has(key)) {
|
|
265
346
|
applyKey(fm, key, after);
|
|
266
|
-
if (key === 'dependsOn' || key === 'artifactPaths') {
|
|
347
|
+
if (key === 'dependsOn' || key === 'artifactPaths' || key === 'fixes' || key === 'riskTools') {
|
|
267
348
|
if (fm[key]) {
|
|
268
349
|
if (!fm._raw) fm._raw = {};
|
|
269
350
|
fm._raw[key] = { line, parsed: fm[key] };
|
|
@@ -312,6 +393,11 @@ function serializePrdFile(fm, body) {
|
|
|
312
393
|
// dependency — never emitted, same as an absent key.
|
|
313
394
|
if (Array.isArray(v) && v.length === 0) continue;
|
|
314
395
|
const cached = fm._raw?.[key];
|
|
396
|
+
if (key === 'fixes') {
|
|
397
|
+
const line = `fixes: ${JSON.stringify(v.map((f) => ({ prd: f.prd, missKind: f.missKind, reason: f.reason })))}`;
|
|
398
|
+
out.push(cached && cached.line.trim() === line ? cached.line : line);
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
315
401
|
if (cached && (Array.isArray(v) ? arraysEqual(cached.parsed, v) : cached.parsed === v)) {
|
|
316
402
|
out.push(cached.line);
|
|
317
403
|
continue;
|
|
@@ -320,6 +406,10 @@ function serializePrdFile(fm, body) {
|
|
|
320
406
|
out.push(`${key}: ${v}`);
|
|
321
407
|
continue;
|
|
322
408
|
}
|
|
409
|
+
if (key === 'riskTools') {
|
|
410
|
+
out.push(`${key}: ${formatQuotedInlineList(v)}`);
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
323
413
|
if (Array.isArray(v)) {
|
|
324
414
|
out.push(`${key}: [${v.join(', ')}]`);
|
|
325
415
|
continue;
|
|
@@ -343,6 +433,9 @@ module.exports = {
|
|
|
343
433
|
parsePrdFile,
|
|
344
434
|
serializePrdFile,
|
|
345
435
|
parseInlineList,
|
|
436
|
+
parseQuotedInlineList,
|
|
437
|
+
formatQuotedInlineList,
|
|
438
|
+
parseFixes,
|
|
346
439
|
isArtifactOnlyDeclaration,
|
|
347
440
|
RECOGNIZED_KEYS,
|
|
348
441
|
PRD_EFFORT_LEVELS,
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Apply the login-item plan from loginItemPlan.cjs: write or remove the entry + start script,
|
|
3
|
+
// or set Electron's own login item for a packaged darwin/win32 build. Whether the login item is
|
|
4
|
+
// on is read from the system every time (the files, or app.getLoginItemSettings()) — there is
|
|
5
|
+
// deliberately no preference file. Starts no process (launchctl loading is out of scope: a
|
|
6
|
+
// LaunchAgent with RunAtLoad is picked up at the next login).
|
|
7
|
+
// Every outside thing (app, homeDir, env, resolveNpx) is an argument so tests need no real home.
|
|
8
|
+
|
|
9
|
+
const fs = require('node:fs');
|
|
10
|
+
const fsp = require('node:fs/promises');
|
|
11
|
+
const { planLoginItem, SCRIPT_MARKER } = require('./loginItemPlan.cjs');
|
|
12
|
+
const { writeTextAtomic } = require('../util/atomicFs.cjs');
|
|
13
|
+
|
|
14
|
+
const DESKTOP_MARKER = 'X-Session-Manager-Login-Item=1';
|
|
15
|
+
|
|
16
|
+
/** @param {string} p */
|
|
17
|
+
function readOrNull(p) {
|
|
18
|
+
try { return fs.readFileSync(p, 'utf8'); } catch { return null; }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @param {string} p */
|
|
22
|
+
function exists(p) {
|
|
23
|
+
try { fs.accessSync(p); return true; } catch { return false; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** True when the entry text carries our marker for this plan. */
|
|
27
|
+
function carriesMarker(plan, text) {
|
|
28
|
+
if (typeof text !== 'string') return false;
|
|
29
|
+
if (plan.mechanism === 'launch-agent') {
|
|
30
|
+
return text.includes(`<string>${plan.label}</string>`);
|
|
31
|
+
}
|
|
32
|
+
return text.split(/\r?\n/).some((l) => l.trim() === DESKTOP_MARKER);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** True when the start-script text carries our marker. */
|
|
36
|
+
function scriptCarriesMarker(text) {
|
|
37
|
+
return typeof text === 'string' && text.split(/\r?\n/).some((l) => l.trim() === SCRIPT_MARKER);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** True when a desktop entry has been switched off by hand (Hidden=true / Autostart-enabled=false). */
|
|
41
|
+
function switchedOff(text) {
|
|
42
|
+
return text.split(/\r?\n/).some((raw) => {
|
|
43
|
+
const l = raw.trim();
|
|
44
|
+
const m = /^([A-Za-z0-9-]+)\s*=\s*(.*)$/.exec(l);
|
|
45
|
+
if (!m) return false;
|
|
46
|
+
const val = m[2].trim().toLowerCase();
|
|
47
|
+
if (m[1] === 'Hidden') return val === 'true';
|
|
48
|
+
if (m[1] === 'X-GNOME-Autostart-enabled') return val === 'false';
|
|
49
|
+
return false;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {{ app?: any, platform: string, packaged: boolean, dev: boolean, homeDir?: string,
|
|
55
|
+
* env?: Record<string, string|undefined>, appId?: string, resolveNpx?: () => (string|null|undefined),
|
|
56
|
+
* warn?: (message: string, meta?: object) => void }} opts
|
|
57
|
+
*/
|
|
58
|
+
function createLoginItem(opts) {
|
|
59
|
+
const { app, platform, packaged, dev, homeDir, appId } = opts;
|
|
60
|
+
const env = opts.env || {};
|
|
61
|
+
const resolveNpx = opts.resolveNpx || (() => null);
|
|
62
|
+
const warn = opts.warn || ((message, meta) => console.warn(message, meta || ''));
|
|
63
|
+
|
|
64
|
+
function plan() {
|
|
65
|
+
return planLoginItem({
|
|
66
|
+
platform,
|
|
67
|
+
packaged,
|
|
68
|
+
dev,
|
|
69
|
+
homeDir,
|
|
70
|
+
appId,
|
|
71
|
+
appImagePath: env.APPIMAGE || null,
|
|
72
|
+
npxPath: resolveNpx() || null,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function statusOf(p) {
|
|
77
|
+
if (!p.supported) {
|
|
78
|
+
return { supported: false, enabled: false, mechanism: null, starts: null, entryPath: null, reason: p.reason };
|
|
79
|
+
}
|
|
80
|
+
if (p.mechanism === 'electron-login-item') {
|
|
81
|
+
const s = app.getLoginItemSettings();
|
|
82
|
+
return {
|
|
83
|
+
supported: true,
|
|
84
|
+
enabled: !!(s && s.openAtLogin),
|
|
85
|
+
mechanism: p.mechanism,
|
|
86
|
+
starts: p.starts,
|
|
87
|
+
entryPath: null,
|
|
88
|
+
reason: null,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const text = readOrNull(p.entryPath);
|
|
92
|
+
let enabled = false;
|
|
93
|
+
let reason = null;
|
|
94
|
+
if (text === null) {
|
|
95
|
+
reason = 'No login item file is present.';
|
|
96
|
+
} else if (!carriesMarker(p, text)) {
|
|
97
|
+
reason = `${p.entryPath} was not written by Session Manager.`;
|
|
98
|
+
} else if (switchedOff(text)) {
|
|
99
|
+
reason = `${p.entryPath} has been switched off.`;
|
|
100
|
+
} else if (p.starts === 'npx' && !exists(p.scriptPath)) {
|
|
101
|
+
reason = `${p.scriptPath} is missing.`;
|
|
102
|
+
} else if (p.starts === 'npx' && !scriptCarriesMarker(readOrNull(p.scriptPath))) {
|
|
103
|
+
reason = `${p.scriptPath} was not written by Session Manager.`;
|
|
104
|
+
} else {
|
|
105
|
+
enabled = true;
|
|
106
|
+
}
|
|
107
|
+
return { supported: true, enabled, mechanism: p.mechanism, starts: p.starts, entryPath: p.entryPath, reason };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function status() {
|
|
111
|
+
return statusOf(plan());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function refuseForeign(p) {
|
|
115
|
+
const text = readOrNull(p.entryPath);
|
|
116
|
+
if (text !== null && !carriesMarker(p, text)) {
|
|
117
|
+
throw new Error(`${p.entryPath} was not written by Session Manager; leaving it alone.`);
|
|
118
|
+
}
|
|
119
|
+
if (p.scriptPath) {
|
|
120
|
+
const script = readOrNull(p.scriptPath);
|
|
121
|
+
if (script !== null && !scriptCarriesMarker(script)) {
|
|
122
|
+
throw new Error(`${p.scriptPath} was not written by Session Manager; leaving it alone.`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @param {boolean} on */
|
|
128
|
+
async function setEnabled(on) {
|
|
129
|
+
const p = plan();
|
|
130
|
+
if (!p.supported) throw new Error(p.reason);
|
|
131
|
+
if (p.mechanism === 'electron-login-item') {
|
|
132
|
+
app.setLoginItemSettings({ openAtLogin: !!on });
|
|
133
|
+
return statusOf(p);
|
|
134
|
+
}
|
|
135
|
+
refuseForeign(p);
|
|
136
|
+
if (on) {
|
|
137
|
+
if (p.scriptPath) await writeTextAtomic(p.scriptPath, p.scriptText, { mode: 0o700 });
|
|
138
|
+
await writeTextAtomic(p.entryPath, p.entryText);
|
|
139
|
+
} else {
|
|
140
|
+
await fsp.rm(p.entryPath, { force: true });
|
|
141
|
+
if (p.scriptPath) await fsp.rm(p.scriptPath, { force: true });
|
|
142
|
+
}
|
|
143
|
+
return statusOf(p);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Rewrite the entry and the script when the login item is on and either differs from what
|
|
148
|
+
* this build would write (a later release changed the script, or npx moved). Never throws.
|
|
149
|
+
* @returns {Promise<boolean>} true when the files were rewritten
|
|
150
|
+
*/
|
|
151
|
+
async function refreshIfStale() {
|
|
152
|
+
try {
|
|
153
|
+
const p = plan();
|
|
154
|
+
if (!p.supported || p.mechanism === 'electron-login-item') return false;
|
|
155
|
+
if (!statusOf(p).enabled) return false;
|
|
156
|
+
const entryStale = readOrNull(p.entryPath) !== p.entryText;
|
|
157
|
+
const scriptStale = !!p.scriptPath && readOrNull(p.scriptPath) !== p.scriptText;
|
|
158
|
+
if (!entryStale && !scriptStale) return false;
|
|
159
|
+
if (p.scriptPath) await writeTextAtomic(p.scriptPath, p.scriptText, { mode: 0o700 });
|
|
160
|
+
await writeTextAtomic(p.entryPath, p.entryText);
|
|
161
|
+
return true;
|
|
162
|
+
} catch (e) {
|
|
163
|
+
warn('login item refresh failed', { error: e && /** @type {Error} */ (e).message });
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return { status, setEnabled, refreshIfStale };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
module.exports = { createLoginItem };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Plan the login item that starts Session Manager when the user logs in. Pure: reads no file
|
|
3
|
+
// and no env var; the caller passes everything in and writes whatever the plan names.
|
|
4
|
+
// Packaged darwin/win32 -> Electron's own login item. Linux -> an XDG autostart entry.
|
|
5
|
+
// npx install on darwin -> a LaunchAgent. Every npx plan runs start-at-login.sh, which runs
|
|
6
|
+
// the same `npx --yes claude-code-session-manager@latest` the in-app reboot uses.
|
|
7
|
+
|
|
8
|
+
const PKG = 'claude-code-session-manager';
|
|
9
|
+
const DEFAULT_APP_ID = 'run.bilko.session-manager';
|
|
10
|
+
// The start script's marker: its first comment line. loginItem.cjs only rewrites or removes a
|
|
11
|
+
// script that carries it.
|
|
12
|
+
const SCRIPT_MARKER = '# Written by Session Manager to start it at login.';
|
|
13
|
+
|
|
14
|
+
function joinHome(homeDir, rel) {
|
|
15
|
+
return `${String(homeDir).replace(/\/+$/, '')}/${rel}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// POSIX sh single-quoted literal; an embedded ' becomes '\''.
|
|
19
|
+
function shQuote(s) {
|
|
20
|
+
return `'${String(s).replace(/'/g, "'\\''")}'`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Desktop-entry Exec argument: double-quoted, with " ` $ \ backslash-escaped. A literal % is
|
|
24
|
+
// doubled because Exec treats %x as a field code.
|
|
25
|
+
function execQuote(s) {
|
|
26
|
+
return `"${String(s).replace(/["`$\\]/g, (c) => `\\${c}`).replace(/%/g, '%%')}"`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function xmlEscape(s) {
|
|
30
|
+
return String(s)
|
|
31
|
+
.replace(/&/g, '&')
|
|
32
|
+
.replace(/</g, '<')
|
|
33
|
+
.replace(/>/g, '>')
|
|
34
|
+
.replace(/"/g, '"')
|
|
35
|
+
.replace(/'/g, ''');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function desktopEntry(exec) {
|
|
39
|
+
return [
|
|
40
|
+
'[Desktop Entry]',
|
|
41
|
+
'Type=Application',
|
|
42
|
+
'Name=Session Manager',
|
|
43
|
+
'Comment=Start Session Manager at login',
|
|
44
|
+
`Exec=${exec}`,
|
|
45
|
+
'Terminal=false',
|
|
46
|
+
'X-GNOME-Autostart-enabled=true',
|
|
47
|
+
'X-Session-Manager-Login-Item=1',
|
|
48
|
+
'',
|
|
49
|
+
].join('\n');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function launchAgentPlist(label, scriptPath) {
|
|
53
|
+
return [
|
|
54
|
+
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
55
|
+
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
56
|
+
'<plist version="1.0">',
|
|
57
|
+
'<dict>',
|
|
58
|
+
' <key>Label</key>',
|
|
59
|
+
` <string>${xmlEscape(label)}</string>`,
|
|
60
|
+
' <key>ProgramArguments</key>',
|
|
61
|
+
' <array>',
|
|
62
|
+
' <string>/bin/sh</string>',
|
|
63
|
+
` <string>${xmlEscape(scriptPath)}</string>`,
|
|
64
|
+
' </array>',
|
|
65
|
+
' <key>RunAtLoad</key>',
|
|
66
|
+
' <true/>',
|
|
67
|
+
' <key>LimitLoadToSessionType</key>',
|
|
68
|
+
' <string>Aqua</string>',
|
|
69
|
+
'</dict>',
|
|
70
|
+
'</plist>',
|
|
71
|
+
'',
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function startScript({ logPath, npxPath }) {
|
|
76
|
+
return [
|
|
77
|
+
'#!/bin/sh',
|
|
78
|
+
SCRIPT_MARKER,
|
|
79
|
+
"# To remove it, turn off App Settings > Startup > 'Start at login'.",
|
|
80
|
+
`LOG=${shQuote(logPath)}`,
|
|
81
|
+
'log() {',
|
|
82
|
+
' mkdir -p "$(dirname "$LOG")" 2>/dev/null',
|
|
83
|
+
` printf '%s %s\\n' "$(date '+%Y-%m-%dT%H:%M:%S%z')" "$*" >> "$LOG"`,
|
|
84
|
+
'}',
|
|
85
|
+
`NPX=${shQuote(npxPath)}`,
|
|
86
|
+
'if [ ! -x "$NPX" ]; then',
|
|
87
|
+
' NPX=$(command -v npx 2>/dev/null || true)',
|
|
88
|
+
'fi',
|
|
89
|
+
'if [ -z "$NPX" ] || [ ! -x "$NPX" ]; then',
|
|
90
|
+
' NPX=',
|
|
91
|
+
' for LOGIN_SH in "$SHELL" /bin/bash /bin/zsh; do',
|
|
92
|
+
' if [ -n "$LOGIN_SH" ] && [ -x "$LOGIN_SH" ]; then',
|
|
93
|
+
` NPX=$("$LOGIN_SH" -lc 'command -v npx' 2>/dev/null | tail -n 1)`,
|
|
94
|
+
' if [ -n "$NPX" ] && [ -x "$NPX" ]; then break; fi',
|
|
95
|
+
' NPX=',
|
|
96
|
+
' fi',
|
|
97
|
+
' done',
|
|
98
|
+
'fi',
|
|
99
|
+
'if [ -z "$NPX" ] || [ ! -x "$NPX" ]; then',
|
|
100
|
+
" log 'npx not found'",
|
|
101
|
+
' exit 1',
|
|
102
|
+
'fi',
|
|
103
|
+
'PATH="$(dirname "$NPX"):$PATH"',
|
|
104
|
+
'export PATH',
|
|
105
|
+
`log "starting $NPX --yes ${PKG}@latest"`,
|
|
106
|
+
'START=$(date +%s)',
|
|
107
|
+
`"$NPX" --yes ${PKG}@latest >> "$LOG" 2>&1`,
|
|
108
|
+
'STATUS=$?',
|
|
109
|
+
'ELAPSED=$(( $(date +%s) - START ))',
|
|
110
|
+
'if [ "$STATUS" -ne 0 ] && [ "$ELAPSED" -lt 120 ]; then',
|
|
111
|
+
' log "exited $STATUS after ${ELAPSED}s; retrying once offline"',
|
|
112
|
+
` "$NPX" --yes --offline ${PKG} >> "$LOG" 2>&1`,
|
|
113
|
+
' STATUS=$?',
|
|
114
|
+
' log "offline run exited $STATUS"',
|
|
115
|
+
'fi',
|
|
116
|
+
'exit "$STATUS"',
|
|
117
|
+
'',
|
|
118
|
+
].join('\n');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function unsupported(reason) {
|
|
122
|
+
return { supported: false, reason };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {{ platform: string, packaged: boolean, dev: boolean, homeDir?: string,
|
|
127
|
+
* appImagePath?: string|null, npxPath?: string|null, appId?: string }} opts
|
|
128
|
+
*/
|
|
129
|
+
function planLoginItem(opts) {
|
|
130
|
+
const { platform, packaged, dev, homeDir, appImagePath, npxPath } = opts || {};
|
|
131
|
+
const appId = (opts && opts.appId) || DEFAULT_APP_ID;
|
|
132
|
+
|
|
133
|
+
if (dev) return unsupported('A dev run is not started at login; only an installed app is.');
|
|
134
|
+
|
|
135
|
+
if (packaged) {
|
|
136
|
+
if (platform === 'darwin' || platform === 'win32') {
|
|
137
|
+
return { supported: true, mechanism: 'electron-login-item', starts: 'app' };
|
|
138
|
+
}
|
|
139
|
+
if (platform !== 'linux') return unsupported(`Start at login is not available on ${platform}.`);
|
|
140
|
+
if (!appImagePath) {
|
|
141
|
+
return unsupported('This Linux build is not running from an AppImage, so there is no file to start at login.');
|
|
142
|
+
}
|
|
143
|
+
if (!homeDir) return unsupported('No home folder is known, so there is nowhere to write the login item.');
|
|
144
|
+
return {
|
|
145
|
+
supported: true,
|
|
146
|
+
mechanism: 'xdg-autostart',
|
|
147
|
+
starts: 'app',
|
|
148
|
+
entryPath: joinHome(homeDir, `.config/autostart/${PKG}.desktop`),
|
|
149
|
+
entryText: desktopEntry(execQuote(appImagePath)),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (platform === 'win32') {
|
|
154
|
+
return unsupported('Start at login is not available for an npx install on Windows; use the installer build.');
|
|
155
|
+
}
|
|
156
|
+
if (platform !== 'linux' && platform !== 'darwin') {
|
|
157
|
+
return unsupported(`Start at login is not available on ${platform}.`);
|
|
158
|
+
}
|
|
159
|
+
if (!npxPath) return unsupported('npx was not found, so there is no command to start at login.');
|
|
160
|
+
if (!homeDir) return unsupported('No home folder is known, so there is nowhere to write the login item.');
|
|
161
|
+
|
|
162
|
+
const scriptPath = joinHome(homeDir, '.claude/session-manager/start-at-login.sh');
|
|
163
|
+
const scriptText = startScript({
|
|
164
|
+
logPath: joinHome(homeDir, '.claude/session-manager/start-at-login.log'),
|
|
165
|
+
npxPath,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (platform === 'linux') {
|
|
169
|
+
return {
|
|
170
|
+
supported: true,
|
|
171
|
+
mechanism: 'xdg-autostart',
|
|
172
|
+
starts: 'npx',
|
|
173
|
+
entryPath: joinHome(homeDir, `.config/autostart/${PKG}.desktop`),
|
|
174
|
+
entryText: desktopEntry(`/bin/sh ${execQuote(scriptPath)}`),
|
|
175
|
+
scriptPath,
|
|
176
|
+
scriptText,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const label = `${appId}.login`;
|
|
181
|
+
return {
|
|
182
|
+
supported: true,
|
|
183
|
+
mechanism: 'launch-agent',
|
|
184
|
+
starts: 'npx',
|
|
185
|
+
label,
|
|
186
|
+
entryPath: joinHome(homeDir, `Library/LaunchAgents/${label}.plist`),
|
|
187
|
+
entryText: launchAgentPlist(label, scriptPath),
|
|
188
|
+
scriptPath,
|
|
189
|
+
scriptText,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
module.exports = { planLoginItem, shQuote, execQuote, xmlEscape, SCRIPT_MARKER };
|
|
@@ -50,6 +50,10 @@ const BRIDGE_JS = `(() => {
|
|
|
50
50
|
var out = [];
|
|
51
51
|
var src = d && Array.isArray(d.scenes) ? d.scenes : [];
|
|
52
52
|
for (var i = 0; i < src.length; i++) {
|
|
53
|
+
if (typeof src[i] === 'number') {
|
|
54
|
+
if (isFinite(src[i]) && src[i] >= 0) out.push({ t: src[i], label: '' });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
53
57
|
var s = src[i] || {};
|
|
54
58
|
var t = typeof s.t === 'number' ? s.t : s.start;
|
|
55
59
|
var label = s.label != null ? s.label : s.title;
|