claude-code-session-manager 0.139.0 → 0.141.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/README.md +20 -4
- package/dist/assets/AppSettings-DExeJhqQ.js +2 -0
- package/dist/assets/History-DJMiuXyK.js +2 -0
- package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-Csyd9HbD.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/Scheduler-cyr61UAC.js +16 -0
- package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-BpGRKOcY.js → Skills-C1v91GEO.js} +26 -26
- package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/index-B2TQz3nd.js +3121 -0
- package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +423 -426
- package/package.json +5 -2
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -19
- 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 +1 -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 +205 -18
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +88 -5
- package/src/main/historyDashboard.cjs +69 -4
- package/src/main/index.cjs +56 -2
- package/src/main/ipcSchemas.cjs +122 -16
- 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 +90 -20
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -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 +25 -5
- package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
- package/src/main/lib/epic/epicOutsideState.cjs +2 -2
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/externalContract.cjs +31 -5
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
- package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
- 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 +26 -0
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +132 -13
- 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/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 +377 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +121 -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/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/preflightCheck.cjs +97 -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/reviewNotice.cjs +39 -0
- 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 +3 -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/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +10 -1
- 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 +19 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +89 -18
- package/src/main/scheduler.cjs +1080 -89
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +14 -1
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +10 -2
- package/src/preload/api.d.ts +364 -21
- package/src/preload/apiSurface.json +89 -10
- package/src/preload/index.cjs +23 -2
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
- package/dist/assets/History-DDnqaLyw.js +0 -2
- package/dist/assets/Scheduler-NLs08fx7.js +0 -16
- package/dist/assets/index-C-d0DCre.js +0 -3124
package/src/main/supervisor.cjs
CHANGED
|
@@ -18,6 +18,7 @@ const { spawn, execFileSync } = require('node:child_process');
|
|
|
18
18
|
const { ipcMain } = require('electron');
|
|
19
19
|
const { resolveClaudeBin, claudeSpawnTarget } = require('./lib/claude/claudeBin.cjs');
|
|
20
20
|
const { headlessPermissionArgs, ensureCliCapsProbed } = require('./lib/claude/claudeCliCaps.cjs');
|
|
21
|
+
const { buildJobSandboxSettings } = require('./lib/claude/jobSandboxPolicy.cjs');
|
|
21
22
|
const { withProcRole } = require('./lib/process/cleanEnv.cjs');
|
|
22
23
|
const { feedChildStdin } = require('./lib/process/childStdin.cjs');
|
|
23
24
|
const schedulerPaths = require('./lib/scheduler/schedulerPaths.cjs');
|
|
@@ -247,13 +248,16 @@ async function runProbe(claudeBin, prompt) {
|
|
|
247
248
|
let child;
|
|
248
249
|
try {
|
|
249
250
|
const target = claudeSpawnTarget('aux', 'supervisor', claudeBin);
|
|
251
|
+
// No spawn cwd is set, so the child inherits process.cwd() — the sandbox roots there.
|
|
252
|
+
const sandboxDir = process.cwd();
|
|
253
|
+
const sandbox = buildJobSandboxSettings({ agentType: 'aux', worktreeDir: sandboxDir, projectRoot: sandboxDir, homeDir: os.homedir(), tmpDir: os.tmpdir(), deps: { available: false, missing: [] } });
|
|
250
254
|
child = spawn(target.command, [
|
|
251
255
|
'-p',
|
|
252
256
|
'--model', 'claude-haiku-5-5',
|
|
253
257
|
'--no-session-persistence',
|
|
254
258
|
'--output-format', 'json',
|
|
255
259
|
'--max-budget-usd', '0.50',
|
|
256
|
-
|
|
260
|
+
...sandbox.argv,
|
|
257
261
|
...headlessPermissionArgs(),
|
|
258
262
|
'--strict-mcp-config',
|
|
259
263
|
'--allowedTools', 'Bash',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- PRD_AUTHORING.md
|
|
1
|
+
<!-- PRD_AUTHORING.md v24 -->
|
|
2
2
|
# PRD Authoring Guide — Scheduler Safety Rules
|
|
3
3
|
|
|
4
4
|
Rule: every PRD you queue follows the rules below.
|
|
@@ -75,6 +75,11 @@ Rule: every PRD needs these fields.
|
|
|
75
75
|
|
|
76
76
|
`planId` is written by the API, never by you. It groups PRDs into the plan (wave) they belong to: an `append` PRD, or one with an explicit `dependsOn`, inherits the `planId` of the PRD it attaches behind; a fresh PRD mints a new one. The Scheduler groups a plan card as a validate PRD (slug `validate-*`) plus everything it depends on, titled by that PRD's title.
|
|
77
77
|
|
|
78
|
+
Records: a validate PRD's record, and the ship/deploy record of a release or deploy PRD, is written to `session-manager-operations/plan-records/<epic-id>/<slug>.md` — machine-local runtime state the scheduler copies to the main checkout and prunes `planRecordsDays` after the Epic completes. A record is never committed and never force-added (`git add -f`); don't list it in `# Files` or a commit step. Why: records used to be committed under `reviews/validation/`, and they piled up in every project with no cleanup.
|
|
79
|
+
|
|
80
|
+
Rule: a PRD that must call a tool marked `irreversible`, `money` or `public` names it in `riskTools` on `scheduler_create_prd` (at most 20 rules, the marks' syntax, e.g. `["Bash(npm publish:*)"]`). Name only what the work needs; a Task can never be cleared.
|
|
81
|
+
Why: the headless job's guard-tool-risk hook refuses an uncleared marked tool. Marks, lookup order and limits: Session Manager's `session-manager-operations/architecture/tool-risk.md`.
|
|
82
|
+
|
|
78
83
|
Artifact-only PRDs (`deliverable: artifact` + `artifactPaths: [...]`) — use this ONLY when every deliverable is a file the repo deliberately git-excludes, so "no commit" is the correct outcome, not a miss.
|
|
79
84
|
1. Every artifact path is listed in `artifactPaths` and is relative, never `..`.
|
|
80
85
|
2. Each file must be non-empty and written during the run window — the verifier stat-checks it on disk.
|
|
@@ -111,6 +116,13 @@ Both fields are required in every `scheduler_create_prd` call.
|
|
|
111
116
|
2. No absolute paths, no `~` at the start, no `..` or `.` segments, no `*` or `?`, no `\` or backticks, no leading `-`. Use `/` between folders.
|
|
112
117
|
3. The scheduler never runs two PRDs with overlapping files at once (held as `files-overlap`); `dependsOn` is for real output or order dependencies only.
|
|
113
118
|
|
|
119
|
+
### preflight
|
|
120
|
+
|
|
121
|
+
Optional. One read-only command in gate syntax (every §6 gate rule applies; one line, at most 500 chars, never `none`), run without a shell for at most 60 s. Exit 0 = the precondition holds.
|
|
122
|
+
Rule: declare it on a PRD whose work needs an external state a person controls — a store agreement, billing, DNS, OAuth consent, a device. While it exits non-zero the scheduler holds the PRD `pending` and re-checks on its own; the hold is described in Session Manager's `session-manager-operations/architecture/scheduler-operations.md` §4b.
|
|
123
|
+
Rule: the executor still ends `SCHEDULER_VERDICT: FAIL` naming what is missing when it meets the missing state; a red preflight at that point reroutes the run to the hold instead of a park.
|
|
124
|
+
Why: a human-only blocker used to park `needs_review` and spend the recovery ladder on work no model can do.
|
|
125
|
+
|
|
114
126
|
### What the API writes
|
|
115
127
|
|
|
116
128
|
The API writes the frontmatter and renders two body sections from the fields above: `# Files` (right after `# Acceptance criteria`) and `# Gate` (after `# Out of scope`, before `## Engineering standards`). Do not write those two sections yourself. Do not put a gate fence (three backticks + `gate`), a `# Gate` heading or a `# Files` heading in any text field — the API rejects that. For `["none"]`, the Gate section says the PRD has no runnable check and to verify each AC line by reading the files, with the fence holding the single word `none`.
|
|
@@ -235,6 +247,7 @@ Before queueing a new PRD, verify each of these:
|
|
|
235
247
|
- [ ] **§11 End green:** the gate runs last; any intentional failure runs early and is captured.
|
|
236
248
|
- [ ] **Gate baseline:** every gate command ran green once at HEAD in the main checkout; a red suite is scoped to the PRD's own test files and the PRD notes say why. Why: a gate already red on base parks as `sentinel_fail`.
|
|
237
249
|
- [ ] **No human-only gates:** no gate or criterion needs a human or the passage of time (cron install, live post wait, live payment, dashboard action); keep them out of the PRD at authoring time; an executor that meets one ends `SCHEDULER_VERDICT: FAIL` naming what is missing. Why: no executor can pass them.
|
|
250
|
+
- [ ] **§6 Preflight:** a PRD whose work needs an external state a person controls declares a read-only `preflight` (exit 0 = precondition holds); every other PRD omits it.
|
|
238
251
|
- [ ] **No interactive AC:** no criterion asks to launch the app, click through, capture a screenshot, run under xvfb or open a browser. Why: a headless run stalls on a rendered frame and is SIGTERM'd uncommitted; recommend manual visual confirmation in the report instead.
|
|
239
252
|
- [ ] **Contract consumers gated:** a PRD that changes a return shape, IPC payload or remote contract greps `tests/` (and `src/**/__tests__`) for every spec using it and puts each in its gate and files. Why: scoped gates let other specs go red unseen until the release gate.
|
|
240
253
|
- [ ] **Gate purity:** a gate command must not create or modify tracked files; outputs go to the per-gate TMPDIR or a gitignored path. Why: a dirtied tree fails the clean-tree check.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validationQualityHandlers.cjs — `history:validation-quality` IPC and
|
|
3
|
+
* GET /admin/validation-quality?cwd=<abs>. Gathers each project's Epic
|
|
4
|
+
* verdict events (active index + archived Epic files) and scheduler rows
|
|
5
|
+
* (queue + the project's own history shard, which carry `fixes`) and feeds
|
|
6
|
+
* the pure calculator in lib/scheduler/validationQuality.cjs.
|
|
7
|
+
*
|
|
8
|
+
* Zero-scan: the IPC never enumerates ~/.claude/projects (lib/CLAUDE.md). Its
|
|
9
|
+
* project list is the cwd values of the scheduler rows, and those same cwds
|
|
10
|
+
* are the registered roots handed to the archive readers, so the archive
|
|
11
|
+
* path never falls back to defaultProjectRoots' allProjectCwds scan.
|
|
12
|
+
*
|
|
13
|
+
* Read-only; every gather resolves { ok: false, error } instead of throwing.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const { computeValidationQuality } = require('./lib/scheduler/validationQuality.cjs');
|
|
20
|
+
|
|
21
|
+
const HISTORY_ROWS_PER_PROJECT = 500;
|
|
22
|
+
|
|
23
|
+
/** @param {unknown} e */
|
|
24
|
+
const errText = (e) => (e instanceof Error ? e.message : String(e));
|
|
25
|
+
/** @param {unknown} v */
|
|
26
|
+
const isObj = (v) => v != null && typeof v === 'object' && !Array.isArray(v);
|
|
27
|
+
/** @param {string} p */
|
|
28
|
+
const norm = (p) => path.resolve(String(p)).replace(/[\\/]+$/, '');
|
|
29
|
+
|
|
30
|
+
/** Default loaders — required lazily so tests can inject fixtures. */
|
|
31
|
+
const defaults = {
|
|
32
|
+
/** Every live queue row (scheduler's merged queue read). */
|
|
33
|
+
async loadQueueJobs() {
|
|
34
|
+
const state = await require('./lib/scheduler/queueStore.cjs').readMerged();
|
|
35
|
+
return Array.isArray(state && state.jobs) ? state.jobs : [];
|
|
36
|
+
},
|
|
37
|
+
/** Newest federated history rows — only used to discover project cwds. */
|
|
38
|
+
async loadRecentHistory() {
|
|
39
|
+
return require('./lib/scheduler/queueHistory.cjs').readHistory({ limit: HISTORY_ROWS_PER_PROJECT });
|
|
40
|
+
},
|
|
41
|
+
/** One project's own history shard (newest-first, bounded tail). */
|
|
42
|
+
/** @param {string} cwd */
|
|
43
|
+
loadProjectHistory(cwd) {
|
|
44
|
+
const { readHistoryFileTailSync } = require('./lib/scheduler/queueHistory.cjs');
|
|
45
|
+
const { projectHistoryPath } = require('./lib/scheduler/queueStore.cjs');
|
|
46
|
+
return readHistoryFileTailSync(projectHistoryPath(cwd), { maxRows: HISTORY_ROWS_PER_PROJECT });
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Terminal history rows only (skip needs_review ledger lines, which carry a `kind`). */
|
|
51
|
+
function isHistoryJobRow(r) {
|
|
52
|
+
return isObj(r) && typeof r.slug === 'string' && typeof r.cwd === 'string' && !('kind' in r && r.kind);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Epic verdict events of one project: open Epics' chains from the active
|
|
57
|
+
* index, plus every archived Epic's events. Unreadable files are skipped.
|
|
58
|
+
* @param {string} cwd @param {() => string[]} projectRoots
|
|
59
|
+
*/
|
|
60
|
+
function epicsOf(cwd, projectRoots) {
|
|
61
|
+
const { readActiveIndex } = require('./lib/epic/epicMint.cjs');
|
|
62
|
+
const { listArchived, readArchived } = require('./promptSessionsIpc.cjs');
|
|
63
|
+
/** @type {Map<string, any[]>} */
|
|
64
|
+
const byId = new Map();
|
|
65
|
+
try {
|
|
66
|
+
const index = readActiveIndex(cwd);
|
|
67
|
+
for (const [epicId, chain] of Object.entries(isObj(index.events) ? index.events : {})) {
|
|
68
|
+
if (Array.isArray(chain)) byId.set(epicId, chain.slice());
|
|
69
|
+
}
|
|
70
|
+
} catch { /* no active index */ }
|
|
71
|
+
let ids = [];
|
|
72
|
+
try {
|
|
73
|
+
const listed = listArchived(cwd, { projectRoots });
|
|
74
|
+
ids = listed && Array.isArray(listed.ids) ? listed.ids : [];
|
|
75
|
+
} catch { /* unregistered or unreadable */ }
|
|
76
|
+
for (const epicId of ids) {
|
|
77
|
+
try {
|
|
78
|
+
const res = readArchived(cwd, epicId, { projectRoots });
|
|
79
|
+
const events = res && res.exists && isObj(res.data) && Array.isArray(res.data.events) ? res.data.events : [];
|
|
80
|
+
byId.set(epicId, [...(byId.get(epicId) || []), ...events]);
|
|
81
|
+
} catch { /* skip this archive */ }
|
|
82
|
+
}
|
|
83
|
+
return [...byId].map(([epicId, events]) => ({ cwd, epicId, events }));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Rows of the given projects: live queue rows + each project's history shard.
|
|
88
|
+
* Queue rows come first so a slug's live row wins over its archived copy.
|
|
89
|
+
*/
|
|
90
|
+
function rowsFor(cwds, queueJobs, loadProjectHistory) {
|
|
91
|
+
const want = new Set(cwds);
|
|
92
|
+
const rows = [];
|
|
93
|
+
for (const j of queueJobs) if (isObj(j) && typeof j.cwd === 'string' && want.has(norm(j.cwd))) rows.push({ ...j, cwd: norm(j.cwd) });
|
|
94
|
+
for (const cwd of cwds) {
|
|
95
|
+
let hist = [];
|
|
96
|
+
try { hist = loadProjectHistory(cwd) || []; } catch { /* no shard */ }
|
|
97
|
+
for (const r of hist) if (isHistoryJobRow(r) && norm(r.cwd) === cwd) rows.push({ ...r, cwd });
|
|
98
|
+
}
|
|
99
|
+
return rows;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* One project (cwd given) or every project that has scheduler rows (no cwd).
|
|
104
|
+
* @param {{ cwd?: string, nowMs?: number, projectRoots?: () => string[], loadQueueJobs?: () => Promise<any[]> | any[], loadRecentHistory?: () => Promise<any[]> | any[], loadProjectHistory?: (cwd: string) => any[] }} [opts]
|
|
105
|
+
* @returns {Promise<{ ok: true, projects: any[] } | { ok: false, error: string }>}
|
|
106
|
+
*/
|
|
107
|
+
async function gatherValidationQuality(opts = {}) {
|
|
108
|
+
try {
|
|
109
|
+
const o = isObj(opts) ? opts : {};
|
|
110
|
+
const now = typeof o.nowMs === 'number' && Number.isFinite(o.nowMs) ? o.nowMs : Date.now();
|
|
111
|
+
const loadQueueJobs = o.loadQueueJobs || defaults.loadQueueJobs;
|
|
112
|
+
const loadRecentHistory = o.loadRecentHistory || defaults.loadRecentHistory;
|
|
113
|
+
const loadProjectHistory = o.loadProjectHistory || defaults.loadProjectHistory;
|
|
114
|
+
|
|
115
|
+
const queueJobs = (await loadQueueJobs()) || [];
|
|
116
|
+
/** @type {string[]} */
|
|
117
|
+
let cwds;
|
|
118
|
+
if (o.cwd !== undefined) {
|
|
119
|
+
if (typeof o.cwd !== 'string' || !path.isAbsolute(o.cwd)) return { ok: false, error: 'cwd must be an absolute path' };
|
|
120
|
+
cwds = [norm(o.cwd)];
|
|
121
|
+
} else {
|
|
122
|
+
const seen = new Set();
|
|
123
|
+
for (const j of queueJobs) if (isObj(j) && typeof j.cwd === 'string' && path.isAbsolute(j.cwd)) seen.add(norm(j.cwd));
|
|
124
|
+
let recent = [];
|
|
125
|
+
try { recent = (await loadRecentHistory()) || []; } catch { /* queue rows alone */ }
|
|
126
|
+
for (const r of recent) if (isHistoryJobRow(r) && path.isAbsolute(r.cwd)) seen.add(norm(r.cwd));
|
|
127
|
+
cwds = [...seen].sort();
|
|
128
|
+
}
|
|
129
|
+
// The rows' own cwds are the registered roots for the IPC (no machine scan);
|
|
130
|
+
// the admin route passes its own registration source.
|
|
131
|
+
const projectRoots = o.projectRoots || (() => cwds);
|
|
132
|
+
|
|
133
|
+
const rows = rowsFor(cwds, queueJobs, loadProjectHistory);
|
|
134
|
+
const epics = cwds.flatMap((cwd) => epicsOf(cwd, projectRoots));
|
|
135
|
+
// A project with no rows and no Epic still gets its (empty) row.
|
|
136
|
+
for (const cwd of cwds) if (!epics.some((e) => e.cwd === cwd)) epics.push({ cwd, epicId: '', events: [] });
|
|
137
|
+
const { projects } = computeValidationQuality({ epics, rows, nowMs: now });
|
|
138
|
+
return { ok: true, projects };
|
|
139
|
+
} catch (e) {
|
|
140
|
+
return { ok: false, error: errText(e) };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* GET /admin/validation-quality?cwd=<abs>
|
|
146
|
+
* → 200 { ok: true, project } | 400 missing/relative cwd | 404 unregistered project
|
|
147
|
+
* | 500 { ok: false, error } when the gather fails.
|
|
148
|
+
* @param {{ registerRoute: Function }} adminHttp
|
|
149
|
+
* @param {{ projectRoots?: () => string[], nowMs?: () => number, loadQueueJobs?: () => any, loadProjectHistory?: (cwd: string) => any[] }} [deps]
|
|
150
|
+
*/
|
|
151
|
+
function registerAdminRoute(adminHttp, deps = {}) {
|
|
152
|
+
const { sendJson } = require('./lib/feedback-remote/localAdminHttp.cjs');
|
|
153
|
+
adminHttp.registerRoute('GET', '/admin/validation-quality', async (/** @type {any} */ _req, /** @type {any} */ res, /** @type {any} */ query) => {
|
|
154
|
+
const cwd = query && typeof query.get === 'function' ? query.get('cwd') : null;
|
|
155
|
+
if (typeof cwd !== 'string' || !cwd || !path.isAbsolute(cwd)) {
|
|
156
|
+
sendJson(res, 400, { ok: false, error: 'cwd must be an absolute path' });
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const root = norm(cwd);
|
|
160
|
+
try {
|
|
161
|
+
require('./lib/opsOwnership.cjs').opsPath(root);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
sendJson(res, 400, { ok: false, error: errText(e) });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const { listArchived, defaultProjectRoots } = require('./promptSessionsIpc.cjs');
|
|
167
|
+
const projectRoots = deps.projectRoots || defaultProjectRoots;
|
|
168
|
+
try {
|
|
169
|
+
listArchived(root, { projectRoots });
|
|
170
|
+
} catch {
|
|
171
|
+
sendJson(res, 404, { ok: false, error: 'not a registered project' });
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const out = await gatherValidationQuality({
|
|
175
|
+
cwd: root,
|
|
176
|
+
nowMs: deps.nowMs ? deps.nowMs() : Date.now(),
|
|
177
|
+
projectRoots,
|
|
178
|
+
loadQueueJobs: deps.loadQueueJobs,
|
|
179
|
+
loadProjectHistory: deps.loadProjectHistory,
|
|
180
|
+
});
|
|
181
|
+
if (!out.ok) {
|
|
182
|
+
sendJson(res, 500, out);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const project = out.projects.find((p) => p.cwd === root) || out.projects[0] || null;
|
|
186
|
+
sendJson(res, 200, { ok: true, project });
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @param {{ ipcMain?: { handle: Function }, gather?: typeof gatherValidationQuality }} [deps]
|
|
192
|
+
*/
|
|
193
|
+
function registerValidationQualityHandlers(deps = {}) {
|
|
194
|
+
const ipc = deps.ipcMain || require('electron').ipcMain;
|
|
195
|
+
const gather = deps.gather || gatherValidationQuality;
|
|
196
|
+
ipc.handle('history:validation-quality', async () => gather({ nowMs: Date.now() }));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
module.exports = { gatherValidationQuality, registerValidationQualityHandlers, registerAdminRoute };
|
package/src/main/webRemote.cjs
CHANGED
|
@@ -1218,6 +1218,12 @@ function respond(msgId, payload, typeOverride, client) {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
1220
|
|
|
1221
|
+
// A 'project-video' macro is a background Video tool run only from the desktop's
|
|
1222
|
+
// Project Home ▸ Video — the phone remote neither lists nor starts one.
|
|
1223
|
+
function isRemoteMacro(macro) {
|
|
1224
|
+
return macro.surface !== 'project-video';
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1221
1227
|
// Lazy-loaded dispatch map — avoids circular require at module load time.
|
|
1222
1228
|
let _dispatchMap = null;
|
|
1223
1229
|
|
|
@@ -1410,7 +1416,7 @@ function getDispatchMap() {
|
|
|
1410
1416
|
projects: tabs.map((t) => ({ cwd: t.cwd, title: t.label })),
|
|
1411
1417
|
agents: personas.map((a) => ({ name: a.name, description: a.description })),
|
|
1412
1418
|
tags: EpicTagSchema.options,
|
|
1413
|
-
macros: await macroLibrary.listMacros(),
|
|
1419
|
+
macros: (await macroLibrary.listMacros()).filter(isRemoteMacro),
|
|
1414
1420
|
macroInputs: true,
|
|
1415
1421
|
};
|
|
1416
1422
|
},
|
|
@@ -1430,7 +1436,9 @@ function getDispatchMap() {
|
|
|
1430
1436
|
const macroLibrary = require('./lib/persona-macro/macroLibrary.cjs');
|
|
1431
1437
|
const macros = await macroLibrary.listMacros();
|
|
1432
1438
|
const macro = macros.find((m) => m.id === parsed.macroId);
|
|
1433
|
-
if (!macro || !macroLibrary.macroVisibleIn(macro, parsed.cwd))
|
|
1439
|
+
if (!macro || !isRemoteMacro(macro) || !macroLibrary.macroVisibleIn(macro, parsed.cwd)) {
|
|
1440
|
+
throw new Error('unknown macro');
|
|
1441
|
+
}
|
|
1434
1442
|
const result = macroLibrary.renderMacroPrompt(parsed.prompt, macro.inputs, parsed.inputs ?? {});
|
|
1435
1443
|
if (!result.ok) throw new Error(result.error);
|
|
1436
1444
|
prompt = result.prompt;
|