claude-code-session-manager 0.128.0 → 0.130.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 +2 -0
- package/dist/assets/AgentLibrary-ctvNes4y.js +2 -0
- package/dist/assets/AppSettings-C03qTDSi.js +2 -0
- package/dist/assets/Button-fOCJry21.js +1 -0
- package/dist/assets/Extensions-BWiDwigT.js +13 -0
- package/dist/assets/{History-4rrDdWNP.js → History-BIQFPXM8.js} +2 -2
- package/dist/assets/Library-BGmD-xZN.js +32 -0
- package/dist/assets/ListDetail-BeO3lY8t.js +1 -0
- package/dist/assets/{Memory-DgQlvQrO.js → Memory-BeXuYIcE.js} +8 -8
- package/dist/assets/{Panel-DZHiD8Ar.js → Panel-OUbLHNsS.js} +1 -1
- package/dist/assets/ProvenanceBadge-kr7arZqu.js +1 -0
- package/dist/assets/Scheduler-DycegnjH.js +16 -0
- package/dist/assets/Settings-BSq6VASG.js +2 -0
- package/dist/assets/{SkillReferenceGraph-C5lKqf5y.js → SkillReferenceGraph-CvPdxg56.js} +1 -1
- package/dist/assets/SourceChip-C2YMnlV8.js +1 -0
- package/dist/assets/SystemPrompt-fpXEK_Rm.js +1 -0
- package/dist/assets/{TiptapBody-C2Iu6rZd.js → TiptapBody-DusJg0je.js} +1 -1
- package/dist/assets/{Toggle-C-oD66BG.js → Toggle-BnJF4V6k.js} +1 -1
- package/dist/assets/ViewTabs-BYrRSHb6.js +1 -0
- package/dist/assets/VoiceButton-Bk66E-fP.js +1 -0
- package/dist/assets/{historyTotals-CbRSLD8f.js → historyTotals-DnuVADtI.js} +1 -1
- package/dist/assets/{index-DtdWBGrI.css → index-Bp8XE9A6.css} +1 -1
- package/dist/assets/index-DfWJO7nP.js +3086 -0
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +391 -405
- package/package.json +1 -1
- package/plugins/CLAUDE.md +2 -2
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +2 -2
- package/plugins/session-manager-dev/skills/builder/4-manual/SKILL.md +2 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +7 -5
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +62 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +169 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +183 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +39 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +79 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +400 -0
- package/scripts/hooks/lib/guard-inline-implementation-policy.cjs +10 -0
- package/scripts/scheduler-mcp-server.cjs +25 -6
- package/src/main/agentLibrary.cjs +36 -10
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +8 -0
- package/src/main/config.cjs +15 -0
- package/src/main/health.cjs +49 -22
- package/src/main/index.cjs +32 -3
- package/src/main/ipcSchemas.cjs +39 -4
- package/src/main/lib/claude/agentModelResolve.cjs +5 -3
- package/src/main/lib/claude/effectiveModelInfo.cjs +14 -4
- package/src/main/lib/claude/modelCatalog.cjs +26 -15
- package/src/main/lib/claudeConfig.cjs +156 -0
- package/src/main/lib/effectiveSettings.cjs +120 -0
- package/src/main/lib/epic/delegationReadiness.cjs +3 -3
- package/src/main/lib/epic/developLoopSpawn.cjs +18 -0
- package/src/main/lib/epic/epicMint.cjs +4 -2
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +4 -3
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +21 -21
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +84 -11
- package/src/main/lib/git/gitWorktree.cjs +400 -9
- package/src/main/lib/git/runtimeStateUntrack.cjs +124 -0
- package/src/main/lib/mcpToolCatalog.cjs +8 -2
- package/src/main/lib/memoryDirResolve.cjs +2 -8
- package/src/main/lib/opsOwnership.cjs +63 -2
- package/src/main/lib/persona-macro/builtinMacros.cjs +30 -0
- package/src/main/lib/persona-macro/macroLibrary.cjs +34 -6
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +46 -0
- package/src/main/lib/prd/prdCreate.cjs +15 -0
- package/src/main/lib/promptSessionSchema.cjs +8 -0
- package/src/main/lib/updateCheck.cjs +6 -1
- package/src/main/pluginInstall.cjs +100 -1
- package/src/main/scheduler.cjs +12 -2
- package/src/main/seedDevPlugin.cjs +2 -1
- package/src/main/templates/PRD_AUTHORING.md +3 -3
- package/src/main/updaterIpc.cjs +5 -1
- package/src/main/usage.cjs +5 -20
- package/src/main/voiceHotkey.cjs +16 -0
- package/src/main/voiceSettings.cjs +24 -0
- package/src/main/voiceWizard.cjs +27 -36
- package/src/preload/api.d.ts +59 -3
- package/src/preload/apiSurface.json +70 -7
- package/src/preload/index.cjs +17 -1
- package/src/seed/agents/architect.md +8 -8
- package/src/seed/agents/demo-video-builder.md +2 -2
- package/src/seed/agents/validator.md +2 -2
- package/dist/assets/AgentLibrary-cNQU5YWy.js +0 -2
- package/dist/assets/Button-9dIPAOBg.js +0 -1
- package/dist/assets/DataModel-DrDJ6ysw.js +0 -1
- package/dist/assets/Hooks-Bj_jF5Pa.js +0 -3
- package/dist/assets/Library-D-Wsxrh7.js +0 -46
- package/dist/assets/ListDetail-D7Om0H8j.js +0 -1
- package/dist/assets/McpServers-CbIbSd5o.js +0 -2
- package/dist/assets/Permissions-CfzduF4B.js +0 -3
- package/dist/assets/Plugins-D-AG5nAo.js +0 -2
- package/dist/assets/ProvenanceBadge-B9JSEjll.js +0 -1
- package/dist/assets/SaveBar-mVKig6hL.js +0 -1
- package/dist/assets/Scheduler-DFTCnh60.js +0 -16
- package/dist/assets/ScopeSwitcher-s8J-yr7Z.js +0 -1
- package/dist/assets/Settings-BTmxRMaP.js +0 -4
- package/dist/assets/Skills-CxOacq0k.js +0 -2
- package/dist/assets/SystemPrompt-BCWg5FAz.js +0 -1
- package/dist/assets/TagLibrary-BnF0_PkG.js +0 -1
- package/dist/assets/ViewTabs-Cs4v7vLY.js +0 -1
- package/dist/assets/index-DzY_GXYY.js +0 -3081
- package/dist/assets/listSkills-C1aWKf0T.js +0 -1
- package/dist/assets/settingsSchema-bSBfHuan.js +0 -1
- package/dist/assets/skillFrontmatter-BEseWm8r.js +0 -10
- package/dist/assets/useAgentsDirWatch-CdyHxKCI.js +0 -1
- package/src/main/lib/epic/epicStandingInstructions.cjs +0 -73
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* effectiveSettings.cjs — the ONE main-process resolver for Claude Code settings.
|
|
4
|
+
*
|
|
5
|
+
* Precedence (high → low): managed > local > project > user. Merge rules mirror
|
|
6
|
+
* src/renderer/lib/mergeScopes.ts: objects deep-merge, arrays accumulate across scopes
|
|
7
|
+
* (low → high order, so callers can dedupe keeping first sight), scalars/mixed → highest wins.
|
|
8
|
+
* Missing or invalid files are skipped and reported in `errors` (never thrown).
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const fs = require('node:fs');
|
|
13
|
+
const os = require('node:os');
|
|
14
|
+
const path = require('node:path');
|
|
15
|
+
|
|
16
|
+
/** @typedef {'managed'|'user'|'project'|'local'} SettingsScope */
|
|
17
|
+
|
|
18
|
+
/** Scopes low → high precedence. */
|
|
19
|
+
const SCOPE_ORDER = /** @type {SettingsScope[]} */ (['user', 'project', 'local', 'managed']);
|
|
20
|
+
|
|
21
|
+
/** @param {string} [platform] */
|
|
22
|
+
function managedSettingsPath(platform = process.platform) {
|
|
23
|
+
return platform === 'darwin'
|
|
24
|
+
? '/Library/Application Support/ClaudeCode/managed-settings.json'
|
|
25
|
+
: '/etc/claude-code/managed-settings.json';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @param {unknown} v @returns {'array'|'object'|'scalar'} */
|
|
29
|
+
function kindOf(v) {
|
|
30
|
+
if (Array.isArray(v)) return 'array';
|
|
31
|
+
if (v !== null && typeof v === 'object') return 'object';
|
|
32
|
+
return 'scalar';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Merge entries (LOW → HIGH precedence) into one value + per-leaf winner map.
|
|
37
|
+
* @param {{scope: SettingsScope, data: any}[]} entries
|
|
38
|
+
* @returns {{ merged: Record<string, any>, winnerByKey: Record<string, SettingsScope> }}
|
|
39
|
+
*/
|
|
40
|
+
function mergeLayers(entries) {
|
|
41
|
+
/** @type {Record<string, SettingsScope>} */
|
|
42
|
+
const winnerByKey = {};
|
|
43
|
+
/** @param {{scope: SettingsScope, data: any}[]} scoped @param {string[]} p @returns {any} */
|
|
44
|
+
const walk = (scoped, p) => {
|
|
45
|
+
if (scoped.every((s) => kindOf(s.data) === 'object')) {
|
|
46
|
+
/** @type {Record<string, any>} */
|
|
47
|
+
const out = {};
|
|
48
|
+
const keys = new Set(scoped.flatMap((s) => Object.keys(s.data)));
|
|
49
|
+
for (const k of keys) {
|
|
50
|
+
out[k] = walk(
|
|
51
|
+
scoped.filter((s) => Object.prototype.hasOwnProperty.call(s.data, k)).map((s) => ({ scope: s.scope, data: s.data[k] })),
|
|
52
|
+
[...p, k],
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
const top = scoped[scoped.length - 1];
|
|
58
|
+
winnerByKey[p.join('.')] = top.scope;
|
|
59
|
+
if (scoped.every((s) => kindOf(s.data) === 'array')) return scoped.flatMap((s) => s.data);
|
|
60
|
+
return top.data;
|
|
61
|
+
};
|
|
62
|
+
const live = entries.filter((e) => kindOf(e.data) === 'object');
|
|
63
|
+
return { merged: live.length ? walk(live, []) : {}, winnerByKey };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Highest-precedence value of `key` among layered settings ({user,project,local,managed}) that
|
|
68
|
+
* passes `pred`; an invalid value in a higher layer falls through to the next one.
|
|
69
|
+
* @param {Record<string, any> | null | undefined} layers
|
|
70
|
+
* @param {string} key
|
|
71
|
+
* @param {(v: any) => boolean} pred
|
|
72
|
+
*/
|
|
73
|
+
function pickByPrecedence(layers, key, pred) {
|
|
74
|
+
for (const scope of [...SCOPE_ORDER].reverse()) {
|
|
75
|
+
const s = layers && layers[scope];
|
|
76
|
+
if (s && typeof s === 'object' && pred(s[key])) return s[key];
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {{ home?: string, cwd?: string|null, fs?: any, platform?: string, managedPath?: string }} [opts]
|
|
83
|
+
* `cwd` is the project root (whose `.claude/` holds project + local settings); omit for user/managed only.
|
|
84
|
+
* @returns {{ merged: Record<string, any>, winnerByKey: Record<string, SettingsScope>,
|
|
85
|
+
* layers: Partial<Record<SettingsScope, any>>, errors: { file: string, scope: SettingsScope, error: string }[] }}
|
|
86
|
+
*/
|
|
87
|
+
function effectiveSettings(opts = {}) {
|
|
88
|
+
const fsImpl = opts.fs || fs;
|
|
89
|
+
const home = opts.home || os.homedir();
|
|
90
|
+
const cwd = opts.cwd ? path.resolve(opts.cwd) : null;
|
|
91
|
+
/** @type {{scope: SettingsScope, file: string}[]} */
|
|
92
|
+
const files = [{ scope: 'user', file: path.join(home, '.claude', 'settings.json') }];
|
|
93
|
+
if (cwd) files.push({ scope: 'project', file: path.join(cwd, '.claude', 'settings.json') });
|
|
94
|
+
files.push({ scope: 'local', file: path.join(home, '.claude', 'settings.local.json') });
|
|
95
|
+
if (cwd) files.push({ scope: 'local', file: path.join(cwd, '.claude', 'settings.local.json') });
|
|
96
|
+
files.push({ scope: 'managed', file: opts.managedPath || managedSettingsPath(opts.platform) });
|
|
97
|
+
|
|
98
|
+
/** @type {{ file: string, scope: SettingsScope, error: string }[]} */
|
|
99
|
+
const errors = [];
|
|
100
|
+
/** @type {Partial<Record<SettingsScope, any>>} */
|
|
101
|
+
const layers = {};
|
|
102
|
+
/** @type {{scope: SettingsScope, data: any}[]} */
|
|
103
|
+
const entries = [];
|
|
104
|
+
for (const { scope, file } of files) {
|
|
105
|
+
try {
|
|
106
|
+
const data = JSON.parse(fsImpl.readFileSync(file, 'utf8'));
|
|
107
|
+
if (kindOf(data) !== 'object') throw new Error('not a JSON object');
|
|
108
|
+
entries.push({ scope, data });
|
|
109
|
+
layers[scope] = layers[scope] ? mergeLayers([{ scope, data: layers[scope] }, { scope, data }]).merged : data;
|
|
110
|
+
} catch (e) {
|
|
111
|
+
errors.push({ file, scope, error: e instanceof Error ? e.message : String(e) });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Stable sort by scope rank (same-scope files keep file order: home-local below project-local).
|
|
115
|
+
entries.sort((a, b) => SCOPE_ORDER.indexOf(a.scope) - SCOPE_ORDER.indexOf(b.scope));
|
|
116
|
+
const { merged, winnerByKey } = mergeLayers(entries);
|
|
117
|
+
return { merged, winnerByKey, layers, errors };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = { effectiveSettings, mergeLayers, pickByPrecedence, managedSettingsPath, SCOPE_ORDER };
|
|
@@ -335,7 +335,7 @@ function checkDevPlugin({ homeDir }) {
|
|
|
335
335
|
...base,
|
|
336
336
|
ok: false,
|
|
337
337
|
detail: `${DEV_PLUGIN_ENABLED_KEY} missing from ~/.claude/settings.json enabledPlugins`,
|
|
338
|
-
fix: '
|
|
338
|
+
fix: 'Turn on the switch for session-manager-dev in Extensions › Plugins (writes ~/.claude/settings.json enabledPlugins)',
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -410,7 +410,7 @@ function checkAgentPersonas({ cwd, homeDir }) {
|
|
|
410
410
|
detail: ok
|
|
411
411
|
? `${count} persona(s) across ~/.claude/agents/ and ${cwd}/.claude/agents/`
|
|
412
412
|
: `no .md personas in ~/.claude/agents/ or ${cwd}/.claude/agents/`,
|
|
413
|
-
fix: ok ? null : 'Create a persona
|
|
413
|
+
fix: ok ? null : 'Create a persona on the Agents page',
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
416
|
|
|
@@ -542,7 +542,7 @@ function checkGuard(def, { cwd, homeDir = os.homedir() }) {
|
|
|
542
542
|
detail,
|
|
543
543
|
fix: ok
|
|
544
544
|
? null
|
|
545
|
-
: `Add a PreToolUse hook to ${cwd}/.claude/settings.json matching ${def.matcher} that runs ${nodeShellCommand(guardShimPath(def.scriptBasename, homeDir))}${def.nudge ? ' (a nudge, not a hard gate)' : ''}`,
|
|
545
|
+
: `Add a PreToolUse hook (Settings › Hooks) to ${cwd}/.claude/settings.json matching ${def.matcher} that runs ${nodeShellCommand(guardShimPath(def.scriptBasename, homeDir))}${def.nudge ? ' (a nudge, not a hard gate)' : ''}`,
|
|
546
546
|
fixAction: ok ? null : def.fixActionId,
|
|
547
547
|
};
|
|
548
548
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* developLoopSpawn.cjs — per-session opt-out of the session-manager-dev plugin.
|
|
4
|
+
*
|
|
5
|
+
* Session Manager installs the plugin (/develop, /builder, /send-feedback) at
|
|
6
|
+
* user scope, so every claude session gets it. An Epic whose row has
|
|
7
|
+
* `developLoop === false` wants a "pure claude" session: the launch passes
|
|
8
|
+
* `--settings '{"enabledPlugins":{"<key>":false}}'`, which outranks the user
|
|
9
|
+
* scope for that one session only. Every other Epic / plain tab gets no args.
|
|
10
|
+
*/
|
|
11
|
+
const { ENABLED_KEY } = require('../../seedDevPlugin.cjs');
|
|
12
|
+
|
|
13
|
+
function developLoopOffSettingsArgs(epic) {
|
|
14
|
+
if (epic?.developLoop !== false) return [];
|
|
15
|
+
return ['--settings', JSON.stringify({ enabledPlugins: { [ENABLED_KEY]: false } })];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { developLoopOffSettingsArgs };
|
|
@@ -212,7 +212,7 @@ function withPathLock(lockPath, task) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
|
-
* ensureEpic(cwd, { epicId?, goalText, tag?, status?, openingPrompt?, source?, agentType?, model?, effort?, mintAuthority? }) → Promise<{ epicId, prdDir, created }>
|
|
215
|
+
* ensureEpic(cwd, { epicId?, goalText, tag?, status?, openingPrompt?, source?, agentType?, model?, effort?, developLoop?, mintAuthority? }) → Promise<{ epicId, prdDir, created }>
|
|
216
216
|
*
|
|
217
217
|
* Two behaviors, and only two:
|
|
218
218
|
* - JOIN (the default, for every automated caller): `epicId` names an Epic
|
|
@@ -231,7 +231,7 @@ function withPathLock(lockPath, task) {
|
|
|
231
231
|
* The Epic's id doubles as its directory name under scheduler/epics/, so the
|
|
232
232
|
* PromptSession ↔ on-disk Epic mapping is 1:1 with no lookup table.
|
|
233
233
|
*/
|
|
234
|
-
function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'proposed', openingPrompt = null, sections = null, source = null, agentType = null, model = null, effort = null, mintAuthority = null } = {}, deps = {}) {
|
|
234
|
+
function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'proposed', openingPrompt = null, sections = null, source = null, agentType = null, model = null, effort = null, developLoop = null, mintAuthority = null } = {}, deps = {}) {
|
|
235
235
|
if (!cwd || typeof cwd !== 'string') throw new Error('ensureEpic: cwd is required');
|
|
236
236
|
// A relative cwd (e.g. a caller passing '.') would otherwise get stored
|
|
237
237
|
// verbatim on the minted Epic's `cwd` field — the renderer's EpicsWorkspace
|
|
@@ -344,6 +344,8 @@ function ensureEpic(cwd, { goalText, tag, epicId: explicitEpicId, status = 'prop
|
|
|
344
344
|
// Per-Epic runtime overrides — written only when set, so an Epic minted without one keeps its on-disk shape.
|
|
345
345
|
...(typeof model === 'string' && model ? { model } : {}),
|
|
346
346
|
...(typeof effort === 'string' && effort ? { effort } : {}),
|
|
347
|
+
// Only false is persisted: absent = develop loop on (byte-identical legacy shape).
|
|
348
|
+
...(developLoop === false ? { developLoop: false } : {}),
|
|
347
349
|
};
|
|
348
350
|
|
|
349
351
|
// Validate the constructed record against the canonical PromptSession
|
|
@@ -41,7 +41,7 @@ const { validatePath } = require('../../config.cjs');
|
|
|
41
41
|
* IPC (config:read-json/write-json, lib/epic/activeIndexMerge.cjs's own merge) is
|
|
42
42
|
* already required to pass through.
|
|
43
43
|
*/
|
|
44
|
-
async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, source, openingPrompt, sections } = {}) {
|
|
44
|
+
async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections } = {}) {
|
|
45
45
|
validatePath(cwd);
|
|
46
46
|
const { epicId } = await ensureEpic(cwd, {
|
|
47
47
|
goalText,
|
|
@@ -49,6 +49,7 @@ async function createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort,
|
|
|
49
49
|
agentType,
|
|
50
50
|
model,
|
|
51
51
|
effort,
|
|
52
|
+
developLoop,
|
|
52
53
|
source,
|
|
53
54
|
openingPrompt,
|
|
54
55
|
sections,
|
|
@@ -64,8 +65,8 @@ function registerPromptSessionsCreateEpicHandlers() {
|
|
|
64
65
|
const { schemas: s, validated: v } = require('../../ipcSchemas.cjs');
|
|
65
66
|
ipcMain.handle(
|
|
66
67
|
'promptSessions:create-epic',
|
|
67
|
-
v(s.promptSessionsCreateEpic, ({ cwd, goalText, tag, agentType, model, effort, source, openingPrompt, sections }) =>
|
|
68
|
-
createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, source, openingPrompt, sections })),
|
|
68
|
+
v(s.promptSessionsCreateEpic, ({ cwd, goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections }) =>
|
|
69
|
+
createEpicViaIpc(cwd, { goalText, tag, agentType, model, effort, developLoop, source, openingPrompt, sections })),
|
|
69
70
|
);
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -186,23 +186,20 @@ function seriesLine(series) {
|
|
|
186
186
|
* → { goalText, openingPrompt, sections }
|
|
187
187
|
*
|
|
188
188
|
* Pure. Mirrors the renderer's `composeEpicIntake` (lib/epicIntake.ts) —
|
|
189
|
-
* same `EpicIntakeSection` shape
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* deliberately emits only the section kinds whose text it OWNS:
|
|
189
|
+
* same `EpicIntakeSection` shape: kind = AIM slot (actor | input | mission)
|
|
190
|
+
* plus `part`. It cannot import that module (TS, renderer-side), so it emits
|
|
191
|
+
* only the parts whose text it OWNS, in AIM order:
|
|
193
192
|
*
|
|
194
|
-
* actor
|
|
195
|
-
* input
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* goal — the report itself.
|
|
199
|
-
* reference — attached paths.
|
|
193
|
+
* actor / persona — the persona line, same sentence template
|
|
194
|
+
* input / grounding — "an external report from Project-A", this module's fact
|
|
195
|
+
* input / reference — attached paths (before the report)
|
|
196
|
+
* mission / goal — the report itself
|
|
200
197
|
*
|
|
201
|
-
* There is NO
|
|
202
|
-
*
|
|
203
|
-
* here would be a second, drifting copy of a tag's meaning
|
|
204
|
-
*
|
|
205
|
-
*
|
|
198
|
+
* There is NO job-type part, on purpose. Its text is the tag's
|
|
199
|
+
* `initialPromptTemplate`, which lives in renderer-only agentTagDefs.ts;
|
|
200
|
+
* re-typing it here would be a second, drifting copy of a tag's meaning, and
|
|
201
|
+
* the auto-start path recomposes the full prompt through composeEpicIntake.
|
|
202
|
+
* The Epic still carries its `tag` field.
|
|
206
203
|
*
|
|
207
204
|
* Complexity: O(n) in the number of references.
|
|
208
205
|
*/
|
|
@@ -228,6 +225,7 @@ function composeFeedbackIntake({
|
|
|
228
225
|
if (agentName && agentDescription) {
|
|
229
226
|
sections.push({
|
|
230
227
|
kind: 'actor',
|
|
228
|
+
part: 'persona',
|
|
231
229
|
label: 'Actor',
|
|
232
230
|
text: `You are acting as the "${singleLine(agentName)}" agent: ${singleLine(agentDescription)}`,
|
|
233
231
|
source: agentName,
|
|
@@ -242,7 +240,8 @@ function composeFeedbackIntake({
|
|
|
242
240
|
const askClause = originAsk ? ` It was raised while working on: ${singleLine(originAsk)}.` : '';
|
|
243
241
|
sections.push({
|
|
244
242
|
kind: 'input',
|
|
245
|
-
|
|
243
|
+
part: 'grounding',
|
|
244
|
+
label: 'Grounding',
|
|
246
245
|
text:
|
|
247
246
|
`This session is INBOUND FEEDBACK from another project: ${origin}.${askClause} `
|
|
248
247
|
+ 'Nobody in this project wrote the report below — an agent working in that project did, and it '
|
|
@@ -263,18 +262,19 @@ function composeFeedbackIntake({
|
|
|
263
262
|
blocks.push(`## Details\n${trimmedBody}`);
|
|
264
263
|
const structured = blocks.join('\n\n');
|
|
265
264
|
|
|
266
|
-
const goalBody = trimmedTitle ? `Goal: ${trimmedTitle}\n\n${structured}` : structured;
|
|
267
|
-
sections.push({ kind: 'goal', label: 'Goal', text: goalBody });
|
|
268
|
-
|
|
269
265
|
for (const p of referencePaths) {
|
|
270
|
-
sections.push({ kind: 'reference', label: 'Reference', text: `Reference: ${singleLine(p)}`, source: p });
|
|
266
|
+
sections.push({ kind: 'input', part: 'reference', label: 'Reference', text: `Reference: ${singleLine(p)}`, source: p });
|
|
271
267
|
}
|
|
272
268
|
|
|
269
|
+
const goalBody = trimmedTitle ? `Goal: ${trimmedTitle}\n\n${structured}` : structured;
|
|
270
|
+
sections.push({ kind: 'mission', part: 'goal', label: 'Goal', text: goalBody });
|
|
271
|
+
|
|
272
|
+
// Part names are string literals: keep in step with AimPart in src/renderer/lib/epicIntake.ts.
|
|
273
273
|
// Same join rule as epicIntake.ts's joinSections: '\n\n' everywhere except
|
|
274
274
|
// between two consecutive reference lines, which stay one visual block.
|
|
275
275
|
const openingPrompt = sections.reduce((out, s, i) => {
|
|
276
276
|
if (i === 0) return s.text;
|
|
277
|
-
const sep = s.
|
|
277
|
+
const sep = s.part === 'reference' && sections[i - 1].part === 'reference' ? '\n' : '\n\n';
|
|
278
278
|
return out + sep + s.text;
|
|
279
279
|
}, '');
|
|
280
280
|
|
|
@@ -12,14 +12,23 @@
|
|
|
12
12
|
* event on success; every refusal is a 400 with no onChanged and no audit.
|
|
13
13
|
*
|
|
14
14
|
* cwd resolution matches projectHomeAdminRoutes.cjs's resolveCwd exactly
|
|
15
|
-
* (reused, not copied).
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* (reused, not copied). `surface` ('sessions' | 'project-home') is accepted on
|
|
16
|
+
* create and update; a create defaults it to 'sessions' and `projects` to
|
|
17
|
+
* [resolvedCwd]. `projects` is accepted ONLY as exactly ["*"] (show in every
|
|
18
|
+
* project); anything else is a 400. An update without `projects` leaves them
|
|
19
|
+
* unchanged. An update is refused (400) if the macro is not visible to the
|
|
20
|
+
* resolved cwd (macroLibrary.macroVisibleIn, so '*' macros are reachable), if
|
|
21
|
+
* `id` starts with `builtin-`, or if `id` is not found. Field validation
|
|
22
|
+
* reuses macroLibrary's `MacroSaveSchema`.
|
|
20
23
|
*
|
|
21
|
-
* A
|
|
22
|
-
*
|
|
24
|
+
* A save whose existing or resulting macro is shown in every project needs a
|
|
25
|
+
* VERIFIED human request: body.humanRequestQuote must appear in a prompt the
|
|
26
|
+
* human typed into body.originClaudeSessionId (humanPromptLedger) AND name
|
|
27
|
+
* every/all projects. Otherwise 400, no write, no onChanged, no audit.
|
|
28
|
+
*
|
|
29
|
+
* Every successful save appends one `admin_macro_save` audit event and calls
|
|
30
|
+
* `onChanged()` exactly once so the Sessions HOT KEYS strip updates live,
|
|
31
|
+
* matching the IPC handlers in index.cjs.
|
|
23
32
|
*/
|
|
24
33
|
'use strict';
|
|
25
34
|
|
|
@@ -27,6 +36,37 @@ const { readBody, sendJson } = require('./localAdminHttp.cjs');
|
|
|
27
36
|
const { resolveCwd } = require('./projectHomeAdminRoutes.cjs');
|
|
28
37
|
const macroLibrary = require('../persona-macro/macroLibrary.cjs');
|
|
29
38
|
const { appendAuditEvent } = require('../telemetry/auditLog.cjs');
|
|
39
|
+
const { findHumanPromptContaining } = require('./humanPromptLedger.cjs');
|
|
40
|
+
|
|
41
|
+
const EVERY_PROJECT_RE = /(^|[^a-z0-9])(every|all|each)\s+(of\s+)?(my\s+|the\s+|our\s+)?projects?($|[^a-z0-9])/;
|
|
42
|
+
|
|
43
|
+
/** True when the quote asks for every/all projects (or "everywhere"). */
|
|
44
|
+
function quoteNamesEveryProject(quote) {
|
|
45
|
+
if (typeof quote !== 'string') return false;
|
|
46
|
+
const q = quote.toLowerCase().replace(/[-_]/g, ' ');
|
|
47
|
+
return EVERY_PROJECT_RE.test(q) || /(^|[^a-z0-9])everywhere($|[^a-z0-9])/.test(q);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const HUMAN_HINT = "the human can set 'Show in every project' in the macro editor";
|
|
51
|
+
|
|
52
|
+
/** Fail-closed check that a human asked for an all-projects macro. */
|
|
53
|
+
function verifyAllProjectsRequest(body) {
|
|
54
|
+
const quote = body.humanRequestQuote;
|
|
55
|
+
if (typeof quote !== 'string' || !quote.trim()) {
|
|
56
|
+
return { ok: false, reason: `a macro shown in every project needs humanRequestQuote (a verbatim human request); ${HUMAN_HINT}` };
|
|
57
|
+
}
|
|
58
|
+
const origin = body.originClaudeSessionId;
|
|
59
|
+
if (typeof origin !== 'string' || origin.length < 1 || origin.length > 128) {
|
|
60
|
+
return { ok: false, reason: `a macro shown in every project needs originClaudeSessionId (1-128 chars); ${HUMAN_HINT}` };
|
|
61
|
+
}
|
|
62
|
+
if (!findHumanPromptContaining(origin, quote)) {
|
|
63
|
+
return { ok: false, reason: `humanRequestQuote was not found in a prompt the human typed in this session; ${HUMAN_HINT}` };
|
|
64
|
+
}
|
|
65
|
+
if (!quoteNamesEveryProject(quote)) {
|
|
66
|
+
return { ok: false, reason: `humanRequestQuote does not name every/all projects; ${HUMAN_HINT}` };
|
|
67
|
+
}
|
|
68
|
+
return { ok: true, quote };
|
|
69
|
+
}
|
|
30
70
|
|
|
31
71
|
/** Read + parse a JSON object body; on failure sends the 400 and returns null. */
|
|
32
72
|
async function readJsonBody(req, res) {
|
|
@@ -79,6 +119,12 @@ function saveHandler(onChanged, libOpts) {
|
|
|
79
119
|
sendJson(res, 400, { ok: false, error: 'built-in macros cannot be edited through this route' });
|
|
80
120
|
return;
|
|
81
121
|
}
|
|
122
|
+
const p = body.projects;
|
|
123
|
+
if (p !== undefined && !(Array.isArray(p) && p.length === 1 && p[0] === macroLibrary.ALL_PROJECTS)) {
|
|
124
|
+
sendJson(res, 400, { ok: false, error: 'projects: only ["*"] is accepted; omit it to use the current project' });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const wantsAll = p !== undefined;
|
|
82
128
|
let input;
|
|
83
129
|
try {
|
|
84
130
|
input = macroLibrary.MacroSaveSchema.parse({
|
|
@@ -88,24 +134,39 @@ function saveHandler(onChanged, libOpts) {
|
|
|
88
134
|
tag: body.tag,
|
|
89
135
|
prompt: body.prompt,
|
|
90
136
|
inputs: body.inputs,
|
|
137
|
+
surface: body.surface,
|
|
91
138
|
});
|
|
92
139
|
} catch (e) {
|
|
93
140
|
sendJson(res, 400, { ok: false, error: e?.issues?.[0]?.message ?? e?.message ?? 'invalid payload' });
|
|
94
141
|
return;
|
|
95
142
|
}
|
|
143
|
+
let existing;
|
|
96
144
|
if (input.id) {
|
|
97
145
|
const macros = await macroLibrary.listMacros(libOpts);
|
|
98
|
-
|
|
146
|
+
existing = macros.find((m) => m.id === input.id);
|
|
99
147
|
if (!existing) {
|
|
100
148
|
sendJson(res, 400, { ok: false, error: `macro not found: ${input.id}` });
|
|
101
149
|
return;
|
|
102
150
|
}
|
|
103
|
-
if (!
|
|
151
|
+
if (!macroLibrary.macroVisibleIn(existing, resolved.cwd)) {
|
|
104
152
|
sendJson(res, 400, { ok: false, error: `macro ${input.id} is not visible to ${resolved.cwd}` });
|
|
105
153
|
return;
|
|
106
154
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
155
|
+
}
|
|
156
|
+
const allProjects = Boolean(existing?.projects.includes(macroLibrary.ALL_PROJECTS)) || wantsAll;
|
|
157
|
+
let quote = null;
|
|
158
|
+
if (allProjects) {
|
|
159
|
+
const v = verifyAllProjectsRequest(body);
|
|
160
|
+
if (!v.ok) {
|
|
161
|
+
sendJson(res, 400, { ok: false, error: v.reason });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
quote = v.quote;
|
|
165
|
+
}
|
|
166
|
+
if (!input.id) {
|
|
167
|
+
input = { ...input, projects: wantsAll ? [macroLibrary.ALL_PROJECTS] : [resolved.cwd], surface: input.surface ?? 'sessions' };
|
|
168
|
+
} else if (wantsAll) {
|
|
169
|
+
input = { ...input, projects: [macroLibrary.ALL_PROJECTS] };
|
|
109
170
|
}
|
|
110
171
|
let macro;
|
|
111
172
|
try {
|
|
@@ -114,6 +175,17 @@ function saveHandler(onChanged, libOpts) {
|
|
|
114
175
|
sendJson(res, 400, { ok: false, error: e?.message ?? 'save failed' });
|
|
115
176
|
return;
|
|
116
177
|
}
|
|
178
|
+
const origin = body.originClaudeSessionId;
|
|
179
|
+
appendAuditEvent('admin_macro_save', {
|
|
180
|
+
route: '/admin/macros/save',
|
|
181
|
+
cwd: resolved.cwd,
|
|
182
|
+
macroId: macro.id,
|
|
183
|
+
projects: macro.projects,
|
|
184
|
+
surface: macro.surface,
|
|
185
|
+
created: !input.id,
|
|
186
|
+
humanRequestQuote: quote,
|
|
187
|
+
originClaudeSessionId: typeof origin === 'string' && origin.length >= 1 && origin.length <= 128 ? origin : null,
|
|
188
|
+
});
|
|
117
189
|
if (onChanged) onChanged();
|
|
118
190
|
sendJson(res, 200, { ok: true, macro });
|
|
119
191
|
};
|
|
@@ -165,4 +237,5 @@ function registerAdminRoute(adminHttp, { onChanged } = {}, opts = {}) {
|
|
|
165
237
|
|
|
166
238
|
module.exports = {
|
|
167
239
|
registerAdminRoute,
|
|
240
|
+
quoteNamesEveryProject,
|
|
168
241
|
};
|