claude-code-session-manager 0.145.0 → 0.146.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AppSettings-BR5b6oof.js → AppSettings-BXfkoKQq.js} +1 -1
- package/dist/assets/{History-B4U0mCdK.js → History-l7pBt_vO.js} +1 -1
- package/dist/assets/{HomeClaudeConfig-DQqG7lFE.js → HomeClaudeConfig-DtFwZxTx.js} +2 -2
- package/dist/assets/{Panel-CwsOJ0nI.js → Panel-C5hihgUD.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BzRowu8x.js → ProjectClaudeConfig-B3pODrM-.js} +1 -1
- package/dist/assets/{Scheduler-dr7CNOcL.js → Scheduler-IU9wo8_u.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-CroBPY4C.js → SkillReferenceGraph-Bmen0OOC.js} +1 -1
- package/dist/assets/{Skills-BiW2lCnD.js → Skills-jYVxqJr2.js} +1 -1
- package/dist/assets/{TiptapBody-CYTkQiva.js → TiptapBody-Dp2gtbb-.js} +1 -1
- package/dist/assets/{Toggle-WFBYo8JI.js → Toggle-C_0yUCS5.js} +1 -1
- package/dist/assets/{VoiceButton-DZu8dTpO.js → VoiceButton-BRPzqDa-.js} +1 -1
- package/dist/assets/{historyTotals-B7KeXLSE.js → historyTotals-pAv-MFnY.js} +1 -1
- package/dist/assets/{index-hXRNm0UJ.js → index-C6nhp7m_.js} +496 -496
- package/dist/index.html +1 -1
- package/dist-web/app.js +408 -408
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +4 -2
- package/scripts/scheduler-mcp-server.cjs +4 -3
- package/src/main/adminRouteRegistry.cjs +1 -1
- package/src/main/build-info.json +4 -4
- package/src/main/lib/claude/claudeJsonApproval.cjs +129 -0
- package/src/main/lib/demo-video-kit/resumableRun.cjs +15 -1
- package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
- package/src/main/lib/epic/epicSpawnCwd.cjs +1 -0
- package/src/main/lib/epic/planReviewInput.cjs +3 -6
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +136 -37
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +23 -3
- package/src/main/lib/git/gitWorktree.cjs +17 -0
- package/src/main/lib/mcpToolCatalog.cjs +2 -1
- package/src/main/lib/scheduler/planReleaseRoute.cjs +53 -5
- package/src/main/lib/scheduler/rcaReport.cjs +1 -0
- package/src/main/lib/scheduler/terminalRunOutcome.cjs +1 -0
- package/src/main/runVerify.cjs +30 -0
- package/src/main/scheduler.cjs +60 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.146.0",
|
|
4
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",
|
|
@@ -62,8 +62,10 @@ feedback_list_projects()
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Returns every project on this machine that can receive feedback (each already
|
|
65
|
-
has a `session-manager-operations/` directory)
|
|
66
|
-
|
|
65
|
+
has a `session-manager-operations/` directory), paged (`total`, `hasMore`; pass
|
|
66
|
+
`offset` for the next page). Match the user's name for the project against a
|
|
67
|
+
real `cwd` from that list. When you already have a path, check it with
|
|
68
|
+
`feedback_list_projects({ cwd })` — `lookup.canReceive` is the exact answer.
|
|
67
69
|
|
|
68
70
|
If the project you want is **absent**, it has simply never been opened in
|
|
69
71
|
Session Manager. Do not invent a path and do not create the directory. Tell the
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* scheduler_create_prd({ ... }) -> POST /admin/scheduler/create-prd
|
|
10
10
|
*
|
|
11
|
-
* feedback_list_projects()
|
|
11
|
+
* feedback_list_projects({cwd?,limit?,offset?}) -> GET /admin/feedback/targets
|
|
12
12
|
* feedback_open_session({ ... }) -> POST /admin/feedback/open-session
|
|
13
13
|
* feedback_reply({ message, outcome, ... }) -> POST /admin/feedback/reply
|
|
14
14
|
*
|
|
@@ -76,7 +76,7 @@ const { MCP_TOOL_CATALOG, MCP_RECIPES, composeDescription, FIXES_INPUT_SCHEMA }
|
|
|
76
76
|
// Shared with paired services (serviceMcpTools.cjs) so both see the same
|
|
77
77
|
// schemas. Its service-only tools (macro_run, events_read) are never listed here.
|
|
78
78
|
const {
|
|
79
|
-
FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA, FEEDBACK_OPEN_SESSION_INPUT_SCHEMA, MACRO_LIST_INPUT_SCHEMA, EPIC_GET_INPUT_SCHEMA,
|
|
79
|
+
FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA, feedbackListProjectsQuery, FEEDBACK_OPEN_SESSION_INPUT_SCHEMA, MACRO_LIST_INPUT_SCHEMA, EPIC_GET_INPUT_SCHEMA,
|
|
80
80
|
} = require('../src/main/lib/feedback-remote/serviceMcpTools.cjs');
|
|
81
81
|
const { SERVICE_TOOL_NAMES } = require('../src/main/lib/feedback-remote/servicePairings.cjs');
|
|
82
82
|
const { EPIC_OUTSIDE_STATES } = require('../src/main/lib/epic/epicOutsideState.cjs');
|
|
@@ -2133,7 +2133,8 @@ async function handleCallTool(request) {
|
|
|
2133
2133
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
2134
2134
|
}
|
|
2135
2135
|
if (name === 'feedback_list_projects') {
|
|
2136
|
-
const
|
|
2136
|
+
const qs = new URLSearchParams(feedbackListProjectsQuery(args)).toString();
|
|
2137
|
+
const result = await adminRequest('GET', `/admin/feedback/targets${qs ? `?${qs}` : ''}`);
|
|
2137
2138
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
2138
2139
|
}
|
|
2139
2140
|
if (name === 'feedback_open_session') {
|
|
@@ -44,7 +44,7 @@ function registerAppAdminRoutes(adminHttp, deps = {}) {
|
|
|
44
44
|
// Project-to-project feedback conduit — the app is the only process holding
|
|
45
45
|
// several projects' operations roots open, so it performs the cross-folder
|
|
46
46
|
// write (lib/feedback-remote/crossProjectFeedback.cjs).
|
|
47
|
-
require('./lib/feedback-remote/crossProjectFeedback.cjs').registerAdminRoute(adminHttp);
|
|
47
|
+
require('./lib/feedback-remote/crossProjectFeedback.cjs').registerAdminRoute(adminHttp, { warmTargetsAfterMs: 60_000 });
|
|
48
48
|
// POST /admin/projects/create — a paired service's new local (+ private GitHub) project; broadcasts `projects:created`.
|
|
49
49
|
require('./lib/feedback-remote/projectCreate.cjs').registerAdminRoute(adminHttp);
|
|
50
50
|
// POST /admin/services/pair-local[/confirm] — same-machine service pairing with no window step.
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.146.0",
|
|
3
|
+
"gitSha": "c056543b79977edaf33caef22701c57173afb42d",
|
|
4
|
+
"gitShortSha": "c056543b",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-28T07:55:22.582Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* Copy Claude Code's CLAUDE.md external-include approval from a parent project
|
|
4
|
+
* path to a new worktree path in the global config (~/.claude.json).
|
|
5
|
+
*
|
|
6
|
+
* Why: Claude Code (2.1.330) keys `projects[<path>]` by the session's own git
|
|
7
|
+
* root (`git rev-parse --show-toplevel`), so each new Epic/job worktree starts
|
|
8
|
+
* without `hasClaudeMdExternalIncludesApproved` and silently skips @-imports
|
|
9
|
+
* that resolve outside the repo (e.g. symlinked contracts).
|
|
10
|
+
*
|
|
11
|
+
* Concurrency: Claude Code holds the `<file>.lock` directory (proper-lockfile
|
|
12
|
+
* mkdir protocol) while it writes; we take the same lock, re-read fresh under
|
|
13
|
+
* it, and write atomically (tmp + rename) so no concurrent write is lost.
|
|
14
|
+
* hasTrustDialogAccepted is never copied.
|
|
15
|
+
*/
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const os = require('os');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const { writeTextAtomic, writeTextAtomicSync } = require('../util/atomicFs.cjs');
|
|
20
|
+
|
|
21
|
+
const STALE_MS = 10000;
|
|
22
|
+
const WAIT_MS = 2000;
|
|
23
|
+
const A = 'hasClaudeMdExternalIncludesApproved';
|
|
24
|
+
const W = 'hasClaudeMdExternalIncludesWarningShown';
|
|
25
|
+
|
|
26
|
+
function claudeJsonPath(env = process.env) {
|
|
27
|
+
if (env && env.CLAUDE_CONFIG_DIR) return path.join(env.CLAUDE_CONFIG_DIR, '.claude.json');
|
|
28
|
+
return path.join(os.homedir(), '.claude.json');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parentEntry(projects, fromPath) {
|
|
32
|
+
const key = path.resolve(fromPath);
|
|
33
|
+
if (projects[key]) return projects[key];
|
|
34
|
+
try {
|
|
35
|
+
const real = fs.realpathSync(key);
|
|
36
|
+
return projects[real];
|
|
37
|
+
} catch { return undefined; }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Return `config` with the parent project's external-include approval copied
|
|
42
|
+
* onto `toPath`'s project entry (unchanged `config` when there is nothing to
|
|
43
|
+
* copy). Does not mutate `config` and never writes a file, but it is not pure:
|
|
44
|
+
* when the parent key is absent it may call `fs.realpathSync` to resolve the
|
|
45
|
+
* parent key through symlinks.
|
|
46
|
+
*/
|
|
47
|
+
function applyApproval(config, fromPath, toPath) {
|
|
48
|
+
if (!config || typeof config !== 'object' || !config.projects || typeof config.projects !== 'object') return config;
|
|
49
|
+
const fromKey = path.resolve(fromPath);
|
|
50
|
+
const toKey = path.resolve(toPath);
|
|
51
|
+
if (fromKey === toKey) return config;
|
|
52
|
+
const parent = parentEntry(config.projects, fromPath);
|
|
53
|
+
if (!parent || parent[A] !== true) return config;
|
|
54
|
+
const existing = config.projects[toKey];
|
|
55
|
+
if (existing && existing[A] === true && existing[W] === true) return config;
|
|
56
|
+
const base = existing && typeof existing === 'object' ? existing : {
|
|
57
|
+
allowedTools: [], mcpContextUris: [], mcpServers: {}, enabledMcpjsonServers: [],
|
|
58
|
+
disabledMcpjsonServers: [], hasTrustDialogAccepted: false,
|
|
59
|
+
};
|
|
60
|
+
return { ...config, projects: { ...config.projects, [toKey]: { ...base, [A]: true, [W]: true } } };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @returns {'ok'|'retry'} */
|
|
64
|
+
function tryLock(lockDir) {
|
|
65
|
+
try { fs.mkdirSync(lockDir); return 'ok'; } catch (e) {
|
|
66
|
+
if (e.code !== 'EEXIST') throw e;
|
|
67
|
+
try {
|
|
68
|
+
if (Date.now() - fs.statSync(lockDir).mtimeMs > STALE_MS) { fs.rmdirSync(lockDir); return tryLock(lockDir); }
|
|
69
|
+
} catch { /* vanished or raced; retry */ }
|
|
70
|
+
return 'retry';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function sleepSync(ms) { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); }
|
|
75
|
+
const jitter = () => 25 + Math.floor(Math.random() * 25);
|
|
76
|
+
|
|
77
|
+
function prepare(configPath, fromPath, toPath) {
|
|
78
|
+
let raw; let stat;
|
|
79
|
+
try { stat = fs.statSync(configPath); raw = fs.readFileSync(configPath, 'utf8'); } catch (e) {
|
|
80
|
+
if (e.code === 'ENOENT') return { result: { ok: false, reason: 'missing' } };
|
|
81
|
+
return { result: { ok: false, reason: 'unreadable' } };
|
|
82
|
+
}
|
|
83
|
+
let config;
|
|
84
|
+
try { config = JSON.parse(raw); } catch { return { result: { ok: false, reason: 'unparseable' } }; }
|
|
85
|
+
const next = applyApproval(config, fromPath, toPath);
|
|
86
|
+
if (next === config) return { result: { ok: true, changed: false } };
|
|
87
|
+
const text = JSON.stringify(next, null, 2) + (raw.endsWith('\n') ? '\n' : '');
|
|
88
|
+
return { text, mode: stat.mode & 0o777 };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function copyExternalIncludeApproval({ fromPath, toPath, configPath } = {}) {
|
|
92
|
+
const file = configPath || claudeJsonPath();
|
|
93
|
+
const lockDir = `${file}.lock`;
|
|
94
|
+
try {
|
|
95
|
+
if (!fs.existsSync(file)) return { ok: false, reason: 'missing' };
|
|
96
|
+
const t0 = Date.now();
|
|
97
|
+
while (tryLock(lockDir) !== 'ok') {
|
|
98
|
+
if (Date.now() - t0 >= WAIT_MS) return { ok: false, reason: 'lock-timeout' };
|
|
99
|
+
await new Promise((r) => setTimeout(r, jitter()));
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const p = prepare(file, fromPath, toPath);
|
|
103
|
+
if (p.result) return p.result;
|
|
104
|
+
await writeTextAtomic(file, p.text, { mode: p.mode });
|
|
105
|
+
return { ok: true, changed: true };
|
|
106
|
+
} finally { try { fs.rmdirSync(lockDir); } catch { /* already gone */ } }
|
|
107
|
+
} catch (e) { return { ok: false, reason: String((e && e.message) || e) }; }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function copyExternalIncludeApprovalSync({ fromPath, toPath, configPath } = {}) {
|
|
111
|
+
const file = configPath || claudeJsonPath();
|
|
112
|
+
const lockDir = `${file}.lock`;
|
|
113
|
+
try {
|
|
114
|
+
if (!fs.existsSync(file)) return { ok: false, reason: 'missing' };
|
|
115
|
+
const t0 = Date.now();
|
|
116
|
+
while (tryLock(lockDir) !== 'ok') {
|
|
117
|
+
if (Date.now() - t0 >= WAIT_MS) return { ok: false, reason: 'lock-timeout' };
|
|
118
|
+
sleepSync(jitter());
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const p = prepare(file, fromPath, toPath);
|
|
122
|
+
if (p.result) return p.result;
|
|
123
|
+
writeTextAtomicSync(file, p.text, { mode: p.mode });
|
|
124
|
+
return { ok: true, changed: true };
|
|
125
|
+
} finally { try { fs.rmdirSync(lockDir); } catch { /* already gone */ } }
|
|
126
|
+
} catch (e) { return { ok: false, reason: String((e && e.message) || e) }; }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = { claudeJsonPath, applyApproval, copyExternalIncludeApproval, copyExternalIncludeApprovalSync };
|
|
@@ -193,6 +193,16 @@ function attachLive(stateDir, key) {
|
|
|
193
193
|
return null;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
// Supervisors this process started -> promise that resolves once node has
|
|
197
|
+
// reaped it (until then kill(pid, 0) still sees the zombie and attachLive would
|
|
198
|
+
// attach to it). The 'exit' listener does not keep the event loop alive (unref).
|
|
199
|
+
const supervisorExits = new Map();
|
|
200
|
+
|
|
201
|
+
/** Promise that resolves when a supervisor this process started has exited and been reaped; null for any other pid. */
|
|
202
|
+
function supervisorExited(pid) {
|
|
203
|
+
return supervisorExits.get(pid) || null;
|
|
204
|
+
}
|
|
205
|
+
|
|
196
206
|
/** Called with start.lock held: re-check, then start a fresh run. */
|
|
197
207
|
function startLocked({ stateDir, key, argv, cwd, leaseMs }) {
|
|
198
208
|
const s = readState(stateDir);
|
|
@@ -216,6 +226,10 @@ function startLocked({ stateDir, key, argv, cwd, leaseMs }) {
|
|
|
216
226
|
env: process.env,
|
|
217
227
|
});
|
|
218
228
|
child.unref();
|
|
229
|
+
supervisorExits.set(child.pid, new Promise((resolve) => {
|
|
230
|
+
child.once('exit', () => { supervisorExits.delete(child.pid); resolve(); });
|
|
231
|
+
child.once('error', () => { supervisorExits.delete(child.pid); resolve(); });
|
|
232
|
+
}));
|
|
219
233
|
} finally {
|
|
220
234
|
fs.closeSync(logFd);
|
|
221
235
|
}
|
|
@@ -302,4 +316,4 @@ if (require.main === module && process.argv[2] === '__supervise') {
|
|
|
302
316
|
supervise(process.argv.slice(3));
|
|
303
317
|
}
|
|
304
318
|
|
|
305
|
-
module.exports = { startOrAttach, waitForResult, writeResult, stopRun, readLogTail, winTreeKillArgv, DEFAULT_LEASE_MS };
|
|
319
|
+
module.exports = { startOrAttach, supervisorExited, waitForResult, writeResult, stopRun, readLogTail, winTreeKillArgv, DEFAULT_LEASE_MS };
|
|
@@ -19,9 +19,9 @@ const path = require('node:path');
|
|
|
19
19
|
const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
|
|
20
20
|
const { writeTextAtomic } = require('../util/atomicFs.cjs');
|
|
21
21
|
|
|
22
|
-
const KIT_VERSION = '
|
|
22
|
+
const KIT_VERSION = '47';
|
|
23
23
|
// sha256 of kitDigest(__dirname). Update together with a KIT_VERSION bump.
|
|
24
|
-
const KIT_DIGEST = '
|
|
24
|
+
const KIT_DIGEST = 'fbd7c7f8fa0e2bf006c0f3f6a0f3d91ca946a3666b42a77448f62f8f544a9300';
|
|
25
25
|
const KIT_FILES = Object.freeze(['checks.cjs', 'sound.cjs', 'capture.cjs', 'frames.cjs', 'character.cjs', 'playwrightLoader.cjs', 'export.cjs', 'kind-tiktok.md', 'kind-marketing.md', 'cast.md', 'project-home-html.md', 'resumableRun.cjs', 'voiceLibrary.cjs', 'voiceLane.cjs', 'kokoroSay.cjs', 'projectSounds.cjs', 'standalone.cjs']);
|
|
26
26
|
const STAMP_FILE = 'KIT_VERSION';
|
|
27
27
|
|
|
@@ -77,6 +77,7 @@ function restoreEpicWorktree({ dir, branch, baseCwd }) {
|
|
|
77
77
|
const run = (args) => execFileSync('git', args, { cwd: baseCwd, stdio: 'ignore', timeout: 15_000 });
|
|
78
78
|
run(['worktree', 'prune']);
|
|
79
79
|
run(['worktree', 'add', dir, branch]);
|
|
80
|
+
require('../claude/claudeJsonApproval.cjs').copyExternalIncludeApprovalSync({ fromPath: baseCwd, toPath: dir });
|
|
80
81
|
return isUsableDir(dir, fs.statSync);
|
|
81
82
|
} catch {
|
|
82
83
|
return false;
|
|
@@ -72,15 +72,14 @@ function buildPlanReviewInput({ epicId, cwd, epicGoal, validateSlug, members, ba
|
|
|
72
72
|
const list = Array.isArray(members) ? members : [];
|
|
73
73
|
const bare = bareSlug(validateSlug);
|
|
74
74
|
const slug = `plan-review-${bare}${round && round >= 2 ? `-r${round}` : ''}`;
|
|
75
|
-
const recordPath = `session-manager-operations/plan-records/${epicId}/${validateSlug}.plan-review.md`;
|
|
76
|
-
|
|
77
75
|
const acceptanceCriteria = list.map((m) => `Review ${m.slug}`);
|
|
78
|
-
acceptanceCriteria.push(`
|
|
76
|
+
acceptanceCriteria.push(`Return the review as the structured output object only; write no file — the scheduler saves the record (${validateSlug}.plan-review.json) from it`);
|
|
79
77
|
|
|
80
78
|
const lines = [
|
|
81
79
|
PERSONA_LINE,
|
|
82
80
|
`Epic goal: ${epicGoal || 'unknown'}`,
|
|
83
81
|
baseSha ? `Base: ${baseSha}` : 'Base: unknown',
|
|
82
|
+
'Deliverable: the structured output object (PLAN_REVIEW_SCHEMA) only. Write no file; the scheduler saves the review.',
|
|
84
83
|
'',
|
|
85
84
|
'Plan members:',
|
|
86
85
|
];
|
|
@@ -110,9 +109,7 @@ function buildPlanReviewInput({ epicId, cwd, epicGoal, validateSlug, members, ba
|
|
|
110
109
|
implementationNotes: lines.join('\n'),
|
|
111
110
|
outOfScope: ['Editing product code', 'Queuing fix PRDs'],
|
|
112
111
|
gate: ['none'],
|
|
113
|
-
files
|
|
114
|
-
deliverable: 'artifact',
|
|
115
|
-
artifactPaths: [recordPath],
|
|
112
|
+
// No `files`: the reviewer edits nothing (validateFiles refuses an empty list).
|
|
116
113
|
agentType: 'plan-reviewer',
|
|
117
114
|
tag: 'build',
|
|
118
115
|
sourcePromptId: epicId,
|
|
@@ -119,12 +119,23 @@ const MAX_ORIGIN_ASK_CHARS = 300;
|
|
|
119
119
|
const MAX_HUMAN_QUOTE_CHARS = 2000;
|
|
120
120
|
const KEBAB_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
121
121
|
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
const
|
|
122
|
+
/** Page size for listFeedbackTargets. The scan itself is NEVER capped — every
|
|
123
|
+
* `~/.claude/projects/` folder is resolved (see the folder memo below) — so a
|
|
124
|
+
* quiet project can't fall off the list; only the returned page is bounded.
|
|
125
|
+
* The old 300-most-recent-folders scan cap silently dropped real projects
|
|
126
|
+
* (2026-11-27: /home/bilko/Projects/3PMahjong missing, 14k folders on disk). */
|
|
127
|
+
const TARGET_PAGE_DEFAULT = 200;
|
|
128
|
+
const TARGET_PAGE_MAX = 1000;
|
|
129
|
+
/** How many transcript folders are resolved concurrently on a cold scan. */
|
|
130
|
+
const TARGET_SCAN_CONCURRENCY = 32;
|
|
131
|
+
/** full folder path -> { mtimeMs, cwd }: the resolved main-checkout cwd (or
|
|
132
|
+
* null) for a transcript folder at that folder mtime. A folder's mtime bumps
|
|
133
|
+
* when a transcript file is added, which is the only thing that can change
|
|
134
|
+
* which file's head names its cwd, so an unchanged mtime means an unchanged
|
|
135
|
+
* answer. Makes every scan after the first a stat pass (14k folders cold
|
|
136
|
+
* ~20 s, warm well under 1 s). Bounded by the folder count on disk; entries
|
|
137
|
+
* for vanished folders are pruned per scan of their root. */
|
|
138
|
+
const targetFolderMemo = new Map();
|
|
128
139
|
|
|
129
140
|
const PROJECTS_DIR = path.join(os.homedir(), '.claude', 'projects');
|
|
130
141
|
|
|
@@ -1180,7 +1191,9 @@ async function openReplyFallbackSession(input = {}, deps = {}) {
|
|
|
1180
1191
|
}
|
|
1181
1192
|
|
|
1182
1193
|
/**
|
|
1183
|
-
* listFeedbackTargets(
|
|
1194
|
+
* listFeedbackTargets({ limit?, offset?, cwd? }) →
|
|
1195
|
+
* { projects: [{ cwd, lastActivity }], total, offset, limit, hasMore, scanned }
|
|
1196
|
+
* or, with `cwd`: { lookup: { cwd, canReceive, reason } }
|
|
1184
1197
|
*
|
|
1185
1198
|
* Which projects can receive feedback. Resolved the same way CLAUDE.md
|
|
1186
1199
|
* requires everywhere else: a PROJECT IS A CWD, resolved from transcript
|
|
@@ -1188,7 +1201,9 @@ async function openReplyFallbackSession(input = {}, deps = {}) {
|
|
|
1188
1201
|
* into a path. A folder whose cwd cannot be resolved is DROPPED, not guessed.
|
|
1189
1202
|
*
|
|
1190
1203
|
* Two sources:
|
|
1191
|
-
* 1. transcript
|
|
1204
|
+
* 1. EVERY transcript folder under `~/.claude/projects/` (no recency cap —
|
|
1205
|
+
* `scanned` is how many folders were read; resolution is memoized per
|
|
1206
|
+
* folder mtime in targetFolderMemo);
|
|
1192
1207
|
* 2. the created-projects ledger (`createdProjects.cjs`, injectable as
|
|
1193
1208
|
* `createdProjects`, default `getCreatedProjects()`), so a folder made by
|
|
1194
1209
|
* project_create is a target before anyone has worked in it. Ledger cwds
|
|
@@ -1197,9 +1212,18 @@ async function openReplyFallbackSession(input = {}, deps = {}) {
|
|
|
1197
1212
|
* cwd in both sources is listed once.
|
|
1198
1213
|
* Results are then filtered to directories that still exist AND already carry
|
|
1199
1214
|
* an operations root — exactly `openFeedbackSession`'s own precondition, so
|
|
1200
|
-
* this list can't offer a target that would then be refused.
|
|
1215
|
+
* this list can't offer a target that would then be refused. Sorted newest
|
|
1216
|
+
* activity first, then paged by `offset`/`limit` (default 200, max 1000);
|
|
1217
|
+
* `total` counts every target and `hasMore` says another page exists.
|
|
1218
|
+
*
|
|
1219
|
+
* `cwd` is the authoritative yes/no for one path, independent of transcripts:
|
|
1220
|
+
* it runs openFeedbackSession's own toCwd checks (validatePath, existing
|
|
1221
|
+
* directory, operations root), so a project that was never chatted in — or
|
|
1222
|
+
* whose transcripts were deleted — still answers yes when it can receive.
|
|
1201
1223
|
*/
|
|
1202
|
-
async function listFeedbackTargets({ limit =
|
|
1224
|
+
async function listFeedbackTargets({ limit = TARGET_PAGE_DEFAULT, offset = 0, cwd, projectsDir, createdProjects } = {}) {
|
|
1225
|
+
if (cwd !== undefined) return { lookup: lookupFeedbackTarget(cwd) };
|
|
1226
|
+
|
|
1203
1227
|
const root = resolveProjectsDir(projectsDir);
|
|
1204
1228
|
let entries;
|
|
1205
1229
|
try {
|
|
@@ -1207,32 +1231,24 @@ async function listFeedbackTargets({ limit = TARGET_SCAN_LIMIT, projectsDir, cre
|
|
|
1207
1231
|
} catch {
|
|
1208
1232
|
entries = [];
|
|
1209
1233
|
}
|
|
1210
|
-
const dirs = entries.filter((e) => e.isDirectory());
|
|
1234
|
+
const dirs = entries.filter((e) => e.isDirectory()).map((d) => path.join(root, d.name));
|
|
1211
1235
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1236
|
+
const resolved = [];
|
|
1237
|
+
for (let i = 0; i < dirs.length; i += TARGET_SCAN_CONCURRENCY) {
|
|
1238
|
+
const batch = await Promise.all(dirs.slice(i, i + TARGET_SCAN_CONCURRENCY).map(resolveTargetFolder));
|
|
1239
|
+
for (const r of batch) if (r) resolved.push(r);
|
|
1240
|
+
}
|
|
1241
|
+
// Prune memo entries for folders under this root that no longer exist.
|
|
1242
|
+
const live = new Set(dirs);
|
|
1243
|
+
for (const key of targetFolderMemo.keys()) {
|
|
1244
|
+
if (path.dirname(key) === root && !live.has(key)) targetFolderMemo.delete(key);
|
|
1220
1245
|
}
|
|
1221
|
-
stamped.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
1222
|
-
const scanned = stamped.slice(0, limit);
|
|
1223
1246
|
|
|
1224
1247
|
const byCwd = new Map();
|
|
1225
|
-
for (const {
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
// list as a project. Collapse to the main checkout (same resolver the
|
|
1230
|
-
// admin routes use); a worktree whose main checkout can't be proven
|
|
1231
|
-
// stays ephemeral/worktree-shaped and is dropped, never listed.
|
|
1232
|
-
const cwd = resolveProjectContext({ cwd: rawCwd }).cwd;
|
|
1233
|
-
if (!cwd || isEphemeralCwd(cwd)) continue;
|
|
1234
|
-
const prior = byCwd.get(cwd);
|
|
1235
|
-
if (!prior || prior.lastActivity < mtimeMs) byCwd.set(cwd, { cwd, lastActivity: mtimeMs });
|
|
1248
|
+
for (const { cwd: c, mtimeMs } of resolved) {
|
|
1249
|
+
if (!c) continue;
|
|
1250
|
+
const prior = byCwd.get(c);
|
|
1251
|
+
if (!prior || prior.lastActivity < mtimeMs) byCwd.set(c, { cwd: c, lastActivity: mtimeMs });
|
|
1236
1252
|
}
|
|
1237
1253
|
|
|
1238
1254
|
// Second source: the created-projects ledger. A broken ledger never hides
|
|
@@ -1248,12 +1264,83 @@ async function listFeedbackTargets({ limit = TARGET_SCAN_LIMIT, projectsDir, cre
|
|
|
1248
1264
|
if (!prior || prior.lastActivity < e.createdAt) byCwd.set(e.cwd, { cwd: e.cwd, lastActivity: e.createdAt });
|
|
1249
1265
|
}
|
|
1250
1266
|
|
|
1251
|
-
const
|
|
1267
|
+
const all = [...byCwd.values()]
|
|
1252
1268
|
.filter((p) => isDirectory(p.cwd) && isSessionManagerProject(p.cwd))
|
|
1253
|
-
.sort((a, b) => b.lastActivity - a.lastActivity)
|
|
1269
|
+
.sort((a, b) => b.lastActivity - a.lastActivity);
|
|
1270
|
+
|
|
1271
|
+
const pageLimit = clampInt(limit, 1, TARGET_PAGE_MAX, TARGET_PAGE_DEFAULT);
|
|
1272
|
+
const pageOffset = clampInt(offset, 0, Number.MAX_SAFE_INTEGER, 0);
|
|
1273
|
+
const projects = all
|
|
1274
|
+
.slice(pageOffset, pageOffset + pageLimit)
|
|
1254
1275
|
.map((p) => ({ cwd: p.cwd, lastActivity: new Date(p.lastActivity).toISOString() }));
|
|
1255
1276
|
|
|
1256
|
-
return {
|
|
1277
|
+
return {
|
|
1278
|
+
projects,
|
|
1279
|
+
total: all.length,
|
|
1280
|
+
offset: pageOffset,
|
|
1281
|
+
limit: pageLimit,
|
|
1282
|
+
hasMore: pageOffset + projects.length < all.length,
|
|
1283
|
+
scanned: dirs.length,
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
function clampInt(v, min, max, fallback) {
|
|
1288
|
+
const n = typeof v === 'string' && v.trim() !== '' ? Number(v) : v;
|
|
1289
|
+
if (typeof n !== 'number' || !Number.isFinite(n)) return fallback;
|
|
1290
|
+
return Math.min(max, Math.max(min, Math.floor(n)));
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/** One transcript folder → { cwd, mtimeMs } (cwd null when unresolvable or a
|
|
1294
|
+
* worktree/ephemeral path), or null when the folder raced away. Memoized by
|
|
1295
|
+
* folder mtime. */
|
|
1296
|
+
async function resolveTargetFolder(full) {
|
|
1297
|
+
let mtimeMs;
|
|
1298
|
+
try {
|
|
1299
|
+
mtimeMs = (await fsp.stat(full)).mtimeMs;
|
|
1300
|
+
} catch {
|
|
1301
|
+
targetFolderMemo.delete(full);
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
const hit = targetFolderMemo.get(full);
|
|
1305
|
+
if (hit && hit.mtimeMs === mtimeMs) return hit;
|
|
1306
|
+
const rawCwd = await resolveCwdFromTranscriptDir(full);
|
|
1307
|
+
let cwd = null;
|
|
1308
|
+
if (rawCwd) {
|
|
1309
|
+
// Job/Epic worktrees carry a tracked operations root too, so each would
|
|
1310
|
+
// list as a project. Collapse to the main checkout (same resolver the
|
|
1311
|
+
// admin routes use); a worktree whose main checkout can't be proven
|
|
1312
|
+
// stays ephemeral/worktree-shaped and is dropped, never listed.
|
|
1313
|
+
const c = resolveProjectContext({ cwd: rawCwd }).cwd;
|
|
1314
|
+
if (c && !isEphemeralCwd(c)) cwd = c;
|
|
1315
|
+
}
|
|
1316
|
+
const rec = { mtimeMs, cwd };
|
|
1317
|
+
targetFolderMemo.set(full, rec);
|
|
1318
|
+
return rec;
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* lookupFeedbackTarget(cwd) → { cwd, canReceive, reason }
|
|
1323
|
+
*
|
|
1324
|
+
* The exact toCwd checks openFeedbackSession runs, minus the same-project
|
|
1325
|
+
* check (no fromCwd here). `reason` is null on yes, else one of
|
|
1326
|
+
* 'invalid' | 'rejected' | 'not-a-directory' | 'no-operations-root'.
|
|
1327
|
+
*/
|
|
1328
|
+
function lookupFeedbackTarget(cwd) {
|
|
1329
|
+
if (typeof cwd !== 'string' || !cwd.trim()) return { cwd: null, canReceive: false, reason: 'invalid' };
|
|
1330
|
+
let resolved;
|
|
1331
|
+
try {
|
|
1332
|
+
resolved = config.validatePath(path.resolve(cwd));
|
|
1333
|
+
} catch {
|
|
1334
|
+
return { cwd: path.resolve(cwd), canReceive: false, reason: 'rejected' };
|
|
1335
|
+
}
|
|
1336
|
+
if (!isDirectory(resolved)) return { cwd: resolved, canReceive: false, reason: 'not-a-directory' };
|
|
1337
|
+
if (!isSessionManagerProject(resolved)) return { cwd: resolved, canReceive: false, reason: 'no-operations-root' };
|
|
1338
|
+
return { cwd: resolved, canReceive: true, reason: null };
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/** Test isolation: forget every memoized folder resolution. */
|
|
1342
|
+
function __resetFeedbackTargetMemoForTests() {
|
|
1343
|
+
targetFolderMemo.clear();
|
|
1257
1344
|
}
|
|
1258
1345
|
|
|
1259
1346
|
/** Read the `cwd` field off the first JSON line of the newest .jsonl in a
|
|
@@ -1301,7 +1388,14 @@ async function resolveCwdFromTranscriptDir(dir) {
|
|
|
1301
1388
|
|
|
1302
1389
|
/** Registers both routes on the injected loopback admin transport. Mirrors
|
|
1303
1390
|
* prdCreate.cjs's registerAdminRoute — auth is the transport's job. */
|
|
1304
|
-
function registerAdminRoute(adminHttp, { getServiceStore } = {}) {
|
|
1391
|
+
function registerAdminRoute(adminHttp, { getServiceStore, warmTargetsAfterMs = null } = {}) {
|
|
1392
|
+
// Optional deferred warm-up of the target-folder memo, so the first
|
|
1393
|
+
// feedback_list_projects after boot doesn't pay the cold scan (seconds over
|
|
1394
|
+
// ~14k transcript folders). Opt-in: tests register routes without it.
|
|
1395
|
+
if (Number.isFinite(warmTargetsAfterMs)) {
|
|
1396
|
+
const t = setTimeout(() => { listFeedbackTargets({}).catch(() => {}); }, warmTargetsAfterMs);
|
|
1397
|
+
if (typeof t.unref === 'function') t.unref();
|
|
1398
|
+
}
|
|
1305
1399
|
adminHttp.registerRoute('POST', '/admin/feedback/open-session', async (req, res) => {
|
|
1306
1400
|
const raw = await readBody(req);
|
|
1307
1401
|
let parsed;
|
|
@@ -1335,7 +1429,10 @@ function registerAdminRoute(adminHttp, { getServiceStore } = {}) {
|
|
|
1335
1429
|
// where a feedback session may be written (that stays governed by
|
|
1336
1430
|
// openFeedbackSession's own validatePath + ops-root checks).
|
|
1337
1431
|
const projectsDir = query?.get('projectsDir') || undefined;
|
|
1338
|
-
const
|
|
1432
|
+
const cwd = query?.get('cwd') ?? undefined;
|
|
1433
|
+
const limit = query?.get('limit') ?? undefined;
|
|
1434
|
+
const offset = query?.get('offset') ?? undefined;
|
|
1435
|
+
const result = await listFeedbackTargets({ projectsDir, cwd, limit, offset });
|
|
1339
1436
|
sendJson(res, 200, { ok: true, ...result });
|
|
1340
1437
|
});
|
|
1341
1438
|
}
|
|
@@ -1367,5 +1464,7 @@ module.exports = {
|
|
|
1367
1464
|
findOpenReplyFallback,
|
|
1368
1465
|
openReplyFallbackSession,
|
|
1369
1466
|
listFeedbackTargets,
|
|
1467
|
+
lookupFeedbackTarget,
|
|
1468
|
+
__resetFeedbackTargetMemoForTests,
|
|
1370
1469
|
registerAdminRoute,
|
|
1371
1470
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* each { name, description, inputSchema, toRequest(args) } where toRequest
|
|
5
5
|
* maps the call onto the loopback admin route it mirrors:
|
|
6
6
|
*
|
|
7
|
-
* feedback_list_projects()
|
|
7
|
+
* feedback_list_projects({cwd?,limit?,offset?}) -> GET /admin/feedback/targets
|
|
8
8
|
* feedback_open_session({ ... }) -> POST /admin/feedback/open-session
|
|
9
9
|
* macro_list({ cwd? }) -> GET /admin/macros?cwd=
|
|
10
10
|
* macro_run({ cwd, id, inputs?, effort?, externalRef? }) -> POST /admin/macros/run
|
|
@@ -32,7 +32,26 @@
|
|
|
32
32
|
const { MCP_TOOL_CATALOG, composeDescription } = require('../mcpToolCatalog.cjs');
|
|
33
33
|
const { SERVICE_TOOL_NAMES } = require('./servicePairings.cjs');
|
|
34
34
|
|
|
35
|
-
const FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA = {
|
|
35
|
+
const FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA = {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
cwd: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Optional: answer yes/no for this one absolute path instead of listing — returns { lookup: { cwd, canReceive, reason } }, independent of how recently the project was active.',
|
|
41
|
+
},
|
|
42
|
+
limit: { type: 'integer', minimum: 1, maximum: 1000, description: 'Optional page size (default 200, max 1000).' },
|
|
43
|
+
offset: { type: 'integer', minimum: 0, description: 'Optional page start (default 0). Page while hasMore is true.' },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Shared by the service and stdio handlers: tool args -> GET query. */
|
|
48
|
+
function feedbackListProjectsQuery(args) {
|
|
49
|
+
const query = {};
|
|
50
|
+
if (typeof args?.cwd === 'string') query.cwd = args.cwd;
|
|
51
|
+
if (args?.limit !== undefined) query.limit = String(args.limit);
|
|
52
|
+
if (args?.offset !== undefined) query.offset = String(args.offset);
|
|
53
|
+
return query;
|
|
54
|
+
}
|
|
36
55
|
|
|
37
56
|
const FEEDBACK_OPEN_SESSION_INPUT_SCHEMA = {
|
|
38
57
|
type: 'object',
|
|
@@ -209,7 +228,7 @@ const SERVICE_TOOLS = Object.freeze([
|
|
|
209
228
|
name: 'feedback_list_projects',
|
|
210
229
|
description: catalogDescription('feedback_list_projects'),
|
|
211
230
|
inputSchema: FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA,
|
|
212
|
-
toRequest: () => ({ method: 'GET', path: '/admin/feedback/targets' }),
|
|
231
|
+
toRequest: (args) => ({ method: 'GET', path: '/admin/feedback/targets', query: feedbackListProjectsQuery(args) }),
|
|
213
232
|
},
|
|
214
233
|
{
|
|
215
234
|
name: 'feedback_open_session',
|
|
@@ -316,6 +335,7 @@ module.exports = {
|
|
|
316
335
|
SERVICE_ONLY_TOOL_NAMES,
|
|
317
336
|
EVENTS_READ_KINDS,
|
|
318
337
|
FEEDBACK_LIST_PROJECTS_INPUT_SCHEMA,
|
|
338
|
+
feedbackListProjectsQuery,
|
|
319
339
|
FEEDBACK_OPEN_SESSION_INPUT_SCHEMA,
|
|
320
340
|
MACRO_LIST_INPUT_SCHEMA,
|
|
321
341
|
EPIC_GET_INPUT_SCHEMA,
|
|
@@ -896,6 +896,21 @@ async function isRegisteredWorktreeOnBranch(cwd, dir, branch) {
|
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
|
|
899
|
+
/**
|
|
900
|
+
* Copy the parent project's CLAUDE.md external-include approval onto the
|
|
901
|
+
* worktree path in ~/.claude.json, so @-imports resolving outside the repo
|
|
902
|
+
* load in sessions started there. Best-effort: never throws.
|
|
903
|
+
*/
|
|
904
|
+
async function inheritIncludeApproval(cwd, dir) {
|
|
905
|
+
try {
|
|
906
|
+
const { copyExternalIncludeApproval } = require('../claude/claudeJsonApproval.cjs');
|
|
907
|
+
const r = await copyExternalIncludeApproval({ fromPath: cwd, toPath: dir });
|
|
908
|
+
if (r && r.ok === false && r.reason !== 'missing') console.warn(`[gitWorktree] include-approval copy skipped for ${dir}: ${r.reason}`);
|
|
909
|
+
} catch (err) {
|
|
910
|
+
console.warn(`[gitWorktree] include-approval copy skipped for ${dir}: ${(err && err.message) || err}`);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
899
914
|
/**
|
|
900
915
|
* Create a linked worktree on a fresh branch checked out from the main
|
|
901
916
|
* tree's current HEAD. Returns `{ ok: true, dir, branch, baseCwd,
|
|
@@ -988,6 +1003,7 @@ async function createWorktree({ kind, cwd, key, fromRef }) {
|
|
|
988
1003
|
} catch (err) {
|
|
989
1004
|
console.warn(`[gitWorktree] dep link sync failed for ${epicDir}: ${(err && err.message) || err}`);
|
|
990
1005
|
}
|
|
1006
|
+
await inheritIncludeApproval(cwd, epicDir);
|
|
991
1007
|
return { ok: true, dir: epicDir, branch: epicBranch, baseCwd: cwd, reused: true };
|
|
992
1008
|
}
|
|
993
1009
|
}
|
|
@@ -1041,6 +1057,7 @@ async function createWorktree({ kind, cwd, key, fromRef }) {
|
|
|
1041
1057
|
}
|
|
1042
1058
|
}
|
|
1043
1059
|
|
|
1060
|
+
await inheritIncludeApproval(cwd, dir);
|
|
1044
1061
|
registeredCheckouts.set(dir, { kind, branch });
|
|
1045
1062
|
const result = { ok: true, dir, branch, baseCwd: cwd, carriedPaths, baseBranch, setup };
|
|
1046
1063
|
if (resolvedFromRefSha) result.forkedFrom = fromRef;
|
|
@@ -332,7 +332,8 @@ const MCP_TOOL_CATALOG = [
|
|
|
332
332
|
whenToUse: "Call this FIRST when you need the exact `toCwd` for feedback_open_session and are not certain of it — never guess a path.",
|
|
333
333
|
whenNotToUse: 'A project missing from this list has simply never been opened in Session Manager; ask the human to open it once rather than inventing a path.',
|
|
334
334
|
exampleArgs: {},
|
|
335
|
-
notes:
|
|
335
|
+
notes: 'Lists every target, newest activity first, paged: { projects, total, offset, limit, hasMore }; limit defaults to 200 (max 1000), '
|
|
336
|
+
+ 'page with offset while hasMore. To validate one path, pass cwd: the answer is { lookup: { cwd, canReceive, reason } } and is exact for any project, however long it has been quiet.',
|
|
336
337
|
},
|
|
337
338
|
{
|
|
338
339
|
name: 'feedback_open_session',
|