claude-code-session-manager 0.138.0 → 0.139.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 +339 -82
- package/dist/assets/{AppSettings-CgDhqrsU.js → AppSettings-CUfWY9vN.js} +2 -2
- package/dist/assets/History-DDnqaLyw.js +2 -0
- package/dist/assets/HomeClaudeConfig-CGD2Onjv.js +3 -0
- package/dist/assets/{Panel-CeDiyuNn.js → Panel-Csyd9HbD.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-C-jlYpC_.js +26 -0
- package/dist/assets/{Scheduler-CkhTvG7C.js → Scheduler-NLs08fx7.js} +9 -9
- package/dist/assets/{SkillReferenceGraph-CFMK8NJh.js → SkillReferenceGraph-DcscPXAG.js} +1 -1
- package/dist/assets/Skills-BpGRKOcY.js +67 -0
- package/dist/assets/{TiptapBody-D1kTj-tn.js → TiptapBody-DSU3769X.js} +60 -54
- package/dist/assets/ViewTabs-C0PRZx4_.js +1 -0
- package/dist/assets/{VoiceButton-CZeyPM31.js → VoiceButton-D2rMurNg.js} +1 -1
- package/dist/assets/{historyTotals-B00l64Jw.js → historyTotals-TcIQs2sh.js} +1 -1
- package/dist/assets/{index-62tyjEQB.css → index-BCySPdtU.css} +1 -1
- package/dist/assets/{index-CgCxpunJ.js → index-C-d0DCre.js} +523 -515
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +469 -450
- package/package.json +13 -5
- 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 +12 -5
- package/scripts/README.md +1 -0
- package/scripts/scheduler-mcp-server.cjs +161 -18
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +2 -2
- package/src/main/exchanges.cjs +70 -5
- package/src/main/historyAggregator.cjs +84 -58
- package/src/main/historyDashboard.cjs +18 -13
- package/src/main/index.cjs +22 -2
- package/src/main/ipcSchemas.cjs +122 -5
- package/src/main/lib/claude/effectiveModelInfo.cjs +2 -2
- package/src/main/lib/claude/modelPricing.cjs +148 -0
- package/src/main/lib/epic/epicAdminRoutes.cjs +101 -0
- package/src/main/lib/epic/epicJobReceipt.cjs +87 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +306 -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/externalRef.cjs +37 -0
- package/src/main/lib/epic/externalRefIndex.cjs +136 -0
- package/src/main/lib/epic/restorableSessions.cjs +151 -17
- package/src/main/lib/epic/transcriptUsage.cjs +197 -0
- package/src/main/lib/externalContract.cjs +111 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +121 -4
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +83 -1
- 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 +120 -2
- 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 +281 -0
- package/src/main/lib/historyRollup.cjs +32 -5
- package/src/main/lib/mcpToolCatalog.cjs +111 -14
- package/src/main/lib/persona-macro/agentAdminRoutes.cjs +121 -0
- package/src/main/lib/promptSessionSchema.cjs +4 -0
- package/src/main/lib/remoteTranscriptTail.cjs +32 -1
- package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
- package/src/main/lib/telemetry/auditEvents.cjs +176 -0
- package/src/main/lib/telemetry/eventsAdminRoutes.cjs +45 -0
- package/src/main/loopEfficiencyHandlers.cjs +1 -1
- package/src/main/scheduler.cjs +29 -0
- package/src/main/templates/PRD_AUTHORING.md +1 -0
- package/src/main/transcripts.cjs +62 -7
- package/src/main/webRemote.cjs +122 -18
- package/src/preload/api.d.ts +71 -8
- package/src/preload/apiSurface.cjs +7 -0
- package/src/preload/apiSurface.json +408 -83
- package/src/preload/index.cjs +15 -3
- package/dist/assets/AgentLibrary-C1d_D7uQ.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/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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.139.0",
|
|
4
|
+
"description": "Free desktop app for Claude Code: run many sessions, each in its own git worktree; queue work that runs headless within your usage limits; agents drive it through an MCP server and skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
7
7
|
"bin": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.main.json",
|
|
48
48
|
"start": "electron .",
|
|
49
49
|
"prepack": "node scripts/write-build-info.cjs",
|
|
50
|
-
"prepublishOnly": "node scripts/write-build-info.cjs && npm run build",
|
|
50
|
+
"prepublishOnly": "node scripts/write-build-info.cjs && npm run build && npm run lint:readme",
|
|
51
51
|
"test:unit": "vitest run",
|
|
52
52
|
"test:unit:stability": "bash scripts/test-unit-stability.sh",
|
|
53
53
|
"bench": "node scripts/bench/main-bench.cjs",
|
|
@@ -67,6 +67,8 @@
|
|
|
67
67
|
"identity:scan": "bash scripts/identity-guard.sh tree",
|
|
68
68
|
"lint:hooks": "node scripts/check-conditional-hooks.cjs",
|
|
69
69
|
"lint:docs": "node scripts/check-doc-hierarchy.cjs",
|
|
70
|
+
"lint:readme": "node scripts/check-readme.cjs",
|
|
71
|
+
"readme:build": "node scripts/check-readme.cjs --write",
|
|
70
72
|
"lint:paths": "node scripts/check-ops-path-literals.cjs",
|
|
71
73
|
"lint:any": "node scripts/check-explicit-any.cjs",
|
|
72
74
|
"lint:main-ts-check": "node scripts/check-main-ts-check.cjs",
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
"lint:e2e-budget": "node scripts/check-e2e-budget.cjs",
|
|
78
80
|
"lint:scroll": "node scripts/check-scroll-into-view.cjs",
|
|
79
81
|
"check:frame": "node scripts/frame-integrity.mjs",
|
|
80
|
-
"lint": "npm run lint:selectors && npm run lint:hooks && npm run lint:docs && npm run lint:paths && npm run lint:any && npm run lint:main-ts-check && npm run lint:filenames && npm run lint:renderer-storage && npm run lint:test-smells && npm run lint:page-stewards && npm run lint:e2e-budget && npm run lint:scroll",
|
|
82
|
+
"lint": "npm run lint:selectors && npm run lint:hooks && npm run lint:docs && npm run lint:paths && npm run lint:any && npm run lint:main-ts-check && npm run lint:filenames && npm run lint:renderer-storage && npm run lint:test-smells && npm run lint:page-stewards && npm run lint:e2e-budget && npm run lint:scroll && npm run lint:readme",
|
|
81
83
|
"sync:settings-schema": "node scripts/sync-settings-schema.cjs"
|
|
82
84
|
},
|
|
83
85
|
"keywords": [
|
|
@@ -90,12 +92,18 @@
|
|
|
90
92
|
"cli",
|
|
91
93
|
"cockpit",
|
|
92
94
|
"mcp",
|
|
95
|
+
"mcp-server",
|
|
93
96
|
"agents",
|
|
94
97
|
"hooks",
|
|
95
98
|
"scheduler",
|
|
96
99
|
"voice",
|
|
97
100
|
"speech-to-text",
|
|
98
|
-
"prd"
|
|
101
|
+
"prd",
|
|
102
|
+
"claude-code-plugin",
|
|
103
|
+
"skills",
|
|
104
|
+
"git-worktree",
|
|
105
|
+
"headless",
|
|
106
|
+
"desktop-app"
|
|
99
107
|
],
|
|
100
108
|
"author": "bilkobibitkov",
|
|
101
109
|
"license": "MIT",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "session-manager-dev",
|
|
3
3
|
"description": "The default end-to-end development skillset for the Claude Code Session Manager: decompose work into scheduler PRDs and track them to a validated finish (/develop), publish releases to npm (/builder), hand a finding to another project on this machine (/send-feedback), and review or drift-check a project's CLAUDE.md/markdown network (/maintaining-md-network). Together with the session-manager scheduler these form a develop → queue → validate → release loop.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bilko Bibitkov",
|
|
7
7
|
"email": "BilkoBibitkov2000@gmail.com",
|
|
@@ -37,7 +37,7 @@ If a meaningful share of commits has no `type:` prefix at all (a bare "wip", "up
|
|
|
37
37
|
guess: list the unclassifiable commits and ask which bump to apply. A wrong semver bump is hard
|
|
38
38
|
to walk back once published.
|
|
39
39
|
|
|
40
|
-
## 3. Gate
|
|
40
|
+
## 3. Gate and publish preflight
|
|
41
41
|
|
|
42
42
|
Run each name in `build-target.json`'s `gates` as `timeout 300 npm run <gate>`, in order,
|
|
43
43
|
against `HEAD`, with no `--skip` flags. With no `gates` entry, run the pre-commit checks the
|
|
@@ -45,6 +45,12 @@ project's `CLAUDE.md` or README requires; with none documented, say so in the re
|
|
|
45
45
|
failure → stop: report the command and its real output, and that no bump, tag or publish
|
|
46
46
|
happened.
|
|
47
47
|
|
|
48
|
+
**Publish preflight.** After every gate passed, run once
|
|
49
|
+
`node <skill base dir>/scripts/publish-preflight.cjs --cwd <repo root>`; it picks the CI or
|
|
50
|
+
local path itself. Exit 1 / a `NPM_PUBLISH_PREFLIGHT: BLOCKED — ...` line → stop before step 4
|
|
51
|
+
(no `npm version`, commit, tag, push or publish) and report the line verbatim; don't retry
|
|
52
|
+
`npm login`, `npm publish` or the preflight. An OK line, any `WARN:` included, goes in the report.
|
|
53
|
+
|
|
48
54
|
## 4. Publish from an isolated worktree
|
|
49
55
|
|
|
50
56
|
A dirty main working tree does not block this: the build and publish run in a clean worktree
|
|
@@ -93,9 +99,10 @@ have no `release.yml`) always use steps 5-11:
|
|
|
93
99
|
A cold `test:unit` in a fresh publish worktree can time out under load; rerun the failed files, then the full suite, before calling the gate red — never publish on the partial rerun.
|
|
94
100
|
7. `npm publish` from inside the worktree, so `prepublishOnly` builds there too.
|
|
95
101
|
A 403 saying two-factor authentication or a bypass-2FA granular token is required is not a
|
|
96
|
-
login problem (`npm whoami` can succeed).
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
login problem (`npm whoami` can succeed). The step 3 preflight normally catches a token
|
|
103
|
+
without 'Bypass two-factor authentication' before the bump. Don't retry `npm login` or
|
|
104
|
+
`npm publish`: run `npm token list --json` (its `bypass_2fa` field; `npm profile get` errors
|
|
105
|
+
with granular tokens), stop, and report the exact 403 and that result so a human can supply an OTP or a token (the CLI cannot mint a granular token). An E409 "staged"
|
|
99
106
|
response means the publish waits for a human to approve it on npmjs.com — report that.
|
|
100
107
|
8. Back in the main repo: `git push origin main` and `git push origin v<version>`.
|
|
101
108
|
9. `git worktree remove "$HOME/.cache/sm-publish/v<version>" --force`
|
|
@@ -130,6 +137,7 @@ undoes it.
|
|
|
130
137
|
|
|
131
138
|
One plain-text report, whether the pipeline finished or stopped:
|
|
132
139
|
|
|
140
|
+
- **Preflight**: the NPM_PUBLISH_PREFLIGHT line, verbatim.
|
|
133
141
|
- **Version** previous → new, and the bump kind.
|
|
134
142
|
- **Commits covered**, grouped by the rule that classified each.
|
|
135
143
|
- **Gates** and their results.
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/**
|
|
4
|
+
* publish-preflight.cjs — dependency-free check, run BEFORE any version bump or tag, that a
|
|
5
|
+
* release can actually reach npm. `npm whoami` alone is not enough: it passes for a token that
|
|
6
|
+
* cannot publish (e.g. 'Bypass two-factor authentication' off → every `npm publish` gets E403).
|
|
7
|
+
*
|
|
8
|
+
* node publish-preflight.cjs [--cwd <dir>] (default: process.cwd())
|
|
9
|
+
*
|
|
10
|
+
* Prints exactly one line to stdout:
|
|
11
|
+
* NPM_PUBLISH_PREFLIGHT: OK — <detail>[; WARN: <warn>] exit 0
|
|
12
|
+
* NPM_PUBLISH_PREFLIGHT: BLOCKED — <detail naming the credential> exit 1
|
|
13
|
+
*
|
|
14
|
+
* Mode: `ci` when <cwd>/.github/workflows/release.yml has a top-level `npm-publish:` job, else
|
|
15
|
+
* `local`. CI mode blocks only when the newest completed v*-tag run's npm-publish job failed AND
|
|
16
|
+
* the local check blocks.
|
|
17
|
+
*
|
|
18
|
+
* The npm auth token is read only to compare it against the redacted `token` field of
|
|
19
|
+
* `npm token list --json`; it is never printed, logged or returned.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
const { spawnSync } = require('child_process');
|
|
25
|
+
|
|
26
|
+
const PREFIX = 'NPM_PUBLISH_PREFLIGHT:';
|
|
27
|
+
const TIMEOUT_MS = 30000;
|
|
28
|
+
const WARN_DAYS = 14;
|
|
29
|
+
const DAY_MS = 86400000;
|
|
30
|
+
const MAX_LINE = 400;
|
|
31
|
+
|
|
32
|
+
function defaultRun(cmd, args, { timeoutMs, cwd }) {
|
|
33
|
+
const r = spawnSync(cmd, args, { cwd, timeout: timeoutMs, encoding: 'utf8', shell: false });
|
|
34
|
+
return {
|
|
35
|
+
status: r.error ? null : r.status,
|
|
36
|
+
stdout: r.stdout || '',
|
|
37
|
+
stderr: r.stderr || (r.error ? String(r.error.message) : ''),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function defaultReadFile(p) {
|
|
42
|
+
try {
|
|
43
|
+
return fs.readFileSync(p, 'utf8');
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const firstLine = (s) => String(s || '').split(/\r?\n/).map((l) => l.trim()).find(Boolean) || 'no output';
|
|
50
|
+
const day = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
51
|
+
const clean = (s) => String(s).replace(/[\r\n]+/g, ' ');
|
|
52
|
+
|
|
53
|
+
function formatLine(ok, detail, warn) {
|
|
54
|
+
let line = `${PREFIX} ${ok ? 'OK' : 'BLOCKED'} — ${clean(detail)}`;
|
|
55
|
+
if (ok && warn) line += `; WARN: ${clean(warn)}`;
|
|
56
|
+
return line.length > MAX_LINE ? line.slice(0, MAX_LINE) : line;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function parseJson(text) {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(text);
|
|
62
|
+
} catch {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function packageName(cwd, readFile) {
|
|
68
|
+
const bt = parseJson(readFile(path.join(cwd, 'session-manager-operations', 'architecture', 'build-target.json')) || '');
|
|
69
|
+
if (bt && typeof bt.packageName === 'string' && bt.packageName) return bt.packageName;
|
|
70
|
+
const pj = parseJson(readFile(path.join(cwd, 'package.json')) || '');
|
|
71
|
+
if (pj && typeof pj.name === 'string' && pj.name) return pj.name;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function detectMode(cwd, readFile) {
|
|
76
|
+
const yml = readFile(path.join(cwd, '.github', 'workflows', 'release.yml'));
|
|
77
|
+
return yml && /^ {2}npm-publish:\s*$/m.test(yml) ? 'ci' : 'local';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The `_authToken` value in the npm userconfig for the registry's host, or null. */
|
|
81
|
+
function readInUseToken(ctx, registry) {
|
|
82
|
+
const uc = ctx.exec('npm', ['config', 'get', 'userconfig']);
|
|
83
|
+
if (uc.status !== 0) return null;
|
|
84
|
+
const file = ctx.readFile(firstLine(uc.stdout));
|
|
85
|
+
if (!file) return null;
|
|
86
|
+
let host;
|
|
87
|
+
try {
|
|
88
|
+
host = new URL(registry).host;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
for (const raw of file.split(/\r?\n/)) {
|
|
93
|
+
const m = /^\s*(\/\/[^:\s]+\/?):_authToken\s*=\s*(.+?)\s*$/.exec(raw);
|
|
94
|
+
if (!m) continue;
|
|
95
|
+
const keyHost = m[1].slice(2).split('/')[0];
|
|
96
|
+
if (keyHost !== host) continue;
|
|
97
|
+
const value = m[2].replace(/^["']|["']$/g, '').replace(/\$\{([^}]+)\}/g, (_, v) => ctx.env[v] || '');
|
|
98
|
+
return value || null;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function pickEntry(entries, inUse) {
|
|
104
|
+
if (inUse) {
|
|
105
|
+
const hits = entries.filter((e) => {
|
|
106
|
+
if (!e || typeof e.token !== 'string') return false;
|
|
107
|
+
const parts = e.token.split('...');
|
|
108
|
+
if (parts.length !== 2) return false;
|
|
109
|
+
return inUse.startsWith(parts[0]) && inUse.endsWith(parts[1]);
|
|
110
|
+
});
|
|
111
|
+
if (hits.length === 1) return hits[0];
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const live = entries.filter((e) => e && !e.revoked);
|
|
115
|
+
return live.length === 1 ? live[0] : null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function scopeCovers(entry, pkg) {
|
|
119
|
+
const pkgScopes = (Array.isArray(entry.scopes) ? entry.scopes : []).filter((s) => s && s.type === 'package');
|
|
120
|
+
if (pkgScopes.length === 0) return true;
|
|
121
|
+
const atScope = pkg.startsWith('@') ? pkg.split('/')[0] : null;
|
|
122
|
+
return pkgScopes.some((s) => s.name == null || s.name === pkg || (atScope && s.name === atScope));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function checkLocal(ctx, pkg) {
|
|
126
|
+
const reg = ctx.registry;
|
|
127
|
+
const who = ctx.exec('npm', ['whoami', '--registry', reg]);
|
|
128
|
+
if (who.status !== 0) {
|
|
129
|
+
return { ok: false, detail: `npm whoami failed (${firstLine(who.stderr)}): no working npm login on this machine` };
|
|
130
|
+
}
|
|
131
|
+
const user = firstLine(who.stdout);
|
|
132
|
+
|
|
133
|
+
let entry = null;
|
|
134
|
+
let warn = null;
|
|
135
|
+
const list = ctx.exec('npm', ['token', 'list', '--json', '--registry', reg]);
|
|
136
|
+
const entries = list.status === 0 ? parseJson(list.stdout) : undefined;
|
|
137
|
+
if (!Array.isArray(entries)) {
|
|
138
|
+
const why = list.status !== 0 ? firstLine(list.stderr || list.stdout) : firstLine(list.stdout);
|
|
139
|
+
warn = `token metadata unreadable (${why}); bypass-2FA not verified`;
|
|
140
|
+
} else {
|
|
141
|
+
entry = pickEntry(entries, readInUseToken(ctx, reg));
|
|
142
|
+
if (!entry) warn = 'could not tell which npm token is in use; bypass-2FA not verified';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let expiryMs = NaN;
|
|
146
|
+
if (entry) {
|
|
147
|
+
const name = entry.name || entry.key || 'unnamed';
|
|
148
|
+
expiryMs = entry.expiry ? Date.parse(entry.expiry) : NaN;
|
|
149
|
+
if (entry.revoked) return { ok: false, detail: `npm token '${name}' is revoked` };
|
|
150
|
+
if (Number.isFinite(expiryMs) && expiryMs < ctx.now()) {
|
|
151
|
+
return { ok: false, detail: `npm token '${name}' expired on ${day(expiryMs)}` };
|
|
152
|
+
}
|
|
153
|
+
if (entry.bypass_2fa !== true) {
|
|
154
|
+
return {
|
|
155
|
+
ok: false,
|
|
156
|
+
detail: `npm token '${name}' has 'Bypass two-factor authentication' off, so npm publish fails E403; regenerate it on npmjs.com with that box ticked`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!scopeCovers(entry, pkg)) return { ok: false, detail: `npm token '${name}' cannot write ${pkg}` };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const owners = ctx.exec('npm', ['owner', 'ls', pkg, '--registry', reg]);
|
|
163
|
+
if (owners.status === 0) {
|
|
164
|
+
const names = owners.stdout.split(/\r?\n/).map((l) => l.trim().split(/\s+/)[0]).filter(Boolean);
|
|
165
|
+
if (!names.includes(user)) return { ok: false, detail: `npm user ${user} is not a maintainer of ${pkg}` };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!entry) return { ok: true, detail: `local npm login as ${user} can reach ${pkg}`, warn };
|
|
169
|
+
const name = entry.name || entry.key || 'unnamed';
|
|
170
|
+
if (Number.isFinite(expiryMs)) {
|
|
171
|
+
const days = Math.ceil((expiryMs - ctx.now()) / DAY_MS);
|
|
172
|
+
if (days <= WARN_DAYS) warn = `token '${name}' expires ${day(expiryMs)} (${days} days); renew it before then`;
|
|
173
|
+
}
|
|
174
|
+
return { ok: true, detail: `local npm token '${name}' can publish ${pkg} as ${user}`, warn };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** → { state: 'ok'|'dead'|'unknown', tag?, runId? } */
|
|
178
|
+
function checkCi(ctx) {
|
|
179
|
+
const list = ctx.exec('gh', ['run', 'list', '--workflow', 'release.yml', '--limit', '20', '--json', 'databaseId,headBranch,status,conclusion']);
|
|
180
|
+
if (list.status !== 0) return { state: 'unknown' };
|
|
181
|
+
const runs = parseJson(list.stdout);
|
|
182
|
+
if (!Array.isArray(runs)) return { state: 'unknown' };
|
|
183
|
+
const run = runs.find((r) => r && r.status === 'completed' && /^v\d/.test(String(r.headBranch || '')));
|
|
184
|
+
if (!run) return { state: 'unknown' };
|
|
185
|
+
const view = ctx.exec('gh', ['run', 'view', String(run.databaseId), '--json', 'jobs']);
|
|
186
|
+
if (view.status !== 0) return { state: 'unknown' };
|
|
187
|
+
const data = parseJson(view.stdout);
|
|
188
|
+
const job = data && Array.isArray(data.jobs) ? data.jobs.find((j) => j && j.name === 'npm-publish') : null;
|
|
189
|
+
if (!job) return { state: 'unknown' };
|
|
190
|
+
const base = { tag: run.headBranch, runId: run.databaseId };
|
|
191
|
+
if (job.conclusion === 'success' || job.conclusion === 'skipped') return { state: 'ok', ...base };
|
|
192
|
+
if (job.conclusion === 'failure') return { state: 'dead', ...base };
|
|
193
|
+
return { state: 'unknown' };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function preflight(opts = {}) {
|
|
197
|
+
const cwd = opts.cwd || process.cwd();
|
|
198
|
+
const run = opts.run || defaultRun;
|
|
199
|
+
const readFile = opts.readFile || defaultReadFile;
|
|
200
|
+
const env = opts.env || process.env;
|
|
201
|
+
const now = opts.now || Date.now;
|
|
202
|
+
const ctx = {
|
|
203
|
+
readFile,
|
|
204
|
+
env,
|
|
205
|
+
now,
|
|
206
|
+
exec: (cmd, args) => run(cmd, args, { timeoutMs: TIMEOUT_MS, cwd }),
|
|
207
|
+
};
|
|
208
|
+
const done = (ok, detail, warn) => ({ ok, line: formatLine(ok, detail, warn) });
|
|
209
|
+
|
|
210
|
+
const pkg = packageName(cwd, readFile);
|
|
211
|
+
if (!pkg) return done(false, 'no package name in build-target.json or package.json');
|
|
212
|
+
|
|
213
|
+
const regOut = ctx.exec('npm', ['config', 'get', 'registry']);
|
|
214
|
+
const regLine = regOut.status === 0 ? firstLine(regOut.stdout) : '';
|
|
215
|
+
ctx.registry = /^https?:\/\//.test(regLine) ? regLine : 'https://registry.npmjs.org/';
|
|
216
|
+
|
|
217
|
+
if (detectMode(cwd, readFile) === 'local') {
|
|
218
|
+
const local = checkLocal(ctx, pkg);
|
|
219
|
+
return done(local.ok, local.detail, local.warn);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const ci = checkCi(ctx);
|
|
223
|
+
if (ci.state === 'ok') return done(true, `CI npm-publish succeeded on ${ci.tag} (run ${ci.runId})`);
|
|
224
|
+
const local = checkLocal(ctx, pkg);
|
|
225
|
+
const ciState = ci.state === 'dead'
|
|
226
|
+
? `CI npm-publish failed on ${ci.tag} (run ${ci.runId})`
|
|
227
|
+
: 'CI npm-publish has no earlier tag run to judge';
|
|
228
|
+
if (local.ok) return done(true, `${ciState}; local publish ready: ${local.detail}`, local.warn);
|
|
229
|
+
if (ci.state === 'dead') return done(false, `${ciState} and ${local.detail}`);
|
|
230
|
+
return done(true, `${ciState}; local check: ${local.detail}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function parseArgs(argv) {
|
|
234
|
+
const out = { cwd: process.cwd() };
|
|
235
|
+
for (let i = 0; i < argv.length; i++) {
|
|
236
|
+
if (argv[i] === '--cwd' && argv[i + 1]) out.cwd = path.resolve(argv[++i]);
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function main() {
|
|
242
|
+
const { cwd } = parseArgs(process.argv.slice(2));
|
|
243
|
+
let result;
|
|
244
|
+
try {
|
|
245
|
+
result = await preflight({ cwd });
|
|
246
|
+
} catch (e) {
|
|
247
|
+
result = { ok: false, line: formatLine(false, `preflight crashed (${firstLine(e && e.message)})`) };
|
|
248
|
+
}
|
|
249
|
+
process.stdout.write(result.line + '\n');
|
|
250
|
+
process.exitCode = result.ok ? 0 : 1;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (require.main === module) main();
|
|
254
|
+
|
|
255
|
+
module.exports = { preflight };
|
|
@@ -252,11 +252,18 @@ Rules:
|
|
|
252
252
|
safest reasonable choice, and report it. Why: queued work runs with no questions asked.
|
|
253
253
|
2. **A PLAN SETTLED digest.** Read the validator records it names. A `REFUTED` PRD, or a
|
|
254
254
|
Critical or Important finding, means a fix wave: one `behavior` or `wire` PRD per finding
|
|
255
|
-
plus a new validate PRD. Never fix inline.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
255
|
+
plus a new validate PRD. Never fix inline. The new validate PRD has one criterion per fix
|
|
256
|
+
PRD and one per PRD the earlier validator marked `REFUTED`, each cited by slug. Why: a
|
|
257
|
+
refuted PRD keeps its Epic blocked until a validator verifies that same PRD. A PRD marked
|
|
258
|
+
`REFUTED` again after its fix wave, on the same criterion, gets no third fix wave: list it
|
|
259
|
+
as open in the final report with the validator's reason and what was tried, for the human
|
|
260
|
+
to decide. Why: a second miss on the same criterion means the plan is wrong, and another
|
|
261
|
+
wave would repeat it. A Not validated list means validate exactly those PRDs here. All
|
|
262
|
+
`VERIFIED` with nothing open means Done: write the final report.
|
|
263
|
+
4. **Done** = the latest validator marked every PRD `VERIFIED`, including each PRD an earlier
|
|
264
|
+
validator refuted, no Critical or Important finding is open, and its record is committed.
|
|
265
|
+
Never "done with caveats": a REFUTED PRD gets a fix wave, or after its second refutation an
|
|
266
|
+
open entry in the final report for the human to decide.
|
|
260
267
|
|
|
261
268
|
### Final report
|
|
262
269
|
|
package/scripts/README.md
CHANGED
|
@@ -17,6 +17,7 @@ scripts/lib was moved into src/main/lib (2026-09); nothing under src/ may requir
|
|
|
17
17
|
| check-conditional-hooks.cjs | `npm run lint:hooks` (in `lint`) | no |
|
|
18
18
|
| check-epic-transcripts.cjs | manual read-only diagnostic (`--json`); also surfaced as a non-fatal warning in `npm run health` | no |
|
|
19
19
|
| check-doc-hierarchy.cjs | `npm run lint:docs` (in `lint`) | no |
|
|
20
|
+
| check-readme.cjs | `npm run readme:build` (`--write`) fills the README's generated regions; `npm run lint:readme` checks the README (run by `lint` and `prepublishOnly`) | no |
|
|
20
21
|
| check-explicit-any.cjs | `npm run lint:any` (in `lint`) — bans explicit `any`/`@ts-ignore` in renderer+preload; per-line `// lint-allow-any: <reason>` | no |
|
|
21
22
|
| check-main-ts-check.cjs | `npm run lint:main-ts-check` (in `lint`) — `tsconfig.main.json` `include` ⇔ `// @ts-check` first line, both directions; explicit list only, `checkJs` false | no |
|
|
22
23
|
| check-renderer-storage.cjs | `npm run lint:renderer-storage` (in `lint`) — ratchet-bans `localStorage.`/`sessionStorage.` in `src/renderer` outside an explicit ALLOWLIST (Epic stateless-ui-review) | no |
|