claude-code-session-manager 0.143.0 → 0.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/assets/AppSettings-BR5b6oof.js +2 -0
- package/dist/assets/{History-DTttbvPb.js → History-B4U0mCdK.js} +2 -2
- package/dist/assets/HomeClaudeConfig-DQqG7lFE.js +5 -0
- package/dist/assets/{Panel-B_D4Bg7L.js → Panel-CwsOJ0nI.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-BzRowu8x.js +26 -0
- package/dist/assets/Scheduler-dr7CNOcL.js +16 -0
- package/dist/assets/{SkillReferenceGraph-D1b2aiol.js → SkillReferenceGraph-CroBPY4C.js} +1 -1
- package/dist/assets/{Skills-cfV7sgk6.js → Skills-BiW2lCnD.js} +23 -23
- package/dist/assets/{TiptapBody-DVXtEIVy.js → TiptapBody-CYTkQiva.js} +27 -27
- package/dist/assets/{Toggle-CYajnSdx.js → Toggle-WFBYo8JI.js} +1 -1
- package/dist/assets/{VoiceButton-DJ4gGRuE.js → VoiceButton-DZu8dTpO.js} +1 -1
- package/dist/assets/{historyTotals-D3MoHY2U.js → historyTotals-B7KeXLSE.js} +1 -1
- package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
- package/dist/assets/{index-CdTppjKR.js → index-hXRNm0UJ.js} +698 -697
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +442 -439
- package/package.json +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +25 -19
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +91 -0
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +9 -6
- package/scripts/README.md +1 -1
- package/scripts/scheduler-mcp-server.cjs +77 -0
- package/src/main/adminRouteRegistry.cjs +6 -0
- package/src/main/agentLibrary.cjs +60 -11
- package/src/main/agentsIpc.cjs +19 -0
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +139 -0
- package/src/main/config.cjs +12 -0
- package/src/main/health.cjs +59 -17
- package/src/main/index.cjs +6 -2
- package/src/main/ipcSchemas.cjs +55 -1
- package/src/main/lib/claude/agentArmory.cjs +128 -0
- package/src/main/lib/claude/agentModelResolve.cjs +3 -2
- package/src/main/lib/claude/agentSnapshot.cjs +24 -3
- package/src/main/lib/claude/builtinTools.cjs +110 -0
- package/src/main/lib/claude/environmentProfiles.cjs +1 -1
- package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
- package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
- package/src/main/lib/claude/personaToolScope.cjs +100 -14
- package/src/main/lib/demo-video-kit/resumableRun.cjs +21 -14
- package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
- package/src/main/lib/epic/epicDepsSync.cjs +66 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +74 -2
- package/src/main/lib/epic/epicSettle.cjs +48 -4
- package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
- package/src/main/lib/epic/epicValidationHook.cjs +9 -1
- package/src/main/lib/epic/planReviewInput.cjs +125 -0
- package/src/main/lib/epic/restorableSessions.cjs +1 -0
- package/src/main/lib/epic/scriptStartedBy.cjs +86 -0
- package/src/main/lib/externalContract.cjs +12 -0
- package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +108 -14
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +24 -3
- package/src/main/lib/feedback-remote/pendingReplies.cjs +8 -4
- package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
- package/src/main/lib/feedback-remote/replyClaims.cjs +15 -6
- package/src/main/lib/feedback-remote/serviceMcpSession.cjs +35 -4
- package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
- package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
- package/src/main/lib/feedback-remote/servicePairings.cjs +95 -7
- package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +104 -1
- package/src/main/lib/git/gitWorktree.cjs +1 -1
- package/src/main/lib/git/worktreeDeps.cjs +9 -3
- package/src/main/lib/mcpToolCatalog.cjs +47 -7
- package/src/main/lib/mcpToolsProbe.cjs +19 -2
- package/src/main/lib/opsOwnership.cjs +2 -0
- package/src/main/lib/packs/packCatalog.cjs +98 -5
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
- package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
- package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
- package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
- package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
- package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +94 -0
- package/src/main/lib/prd/prdCreate.cjs +49 -5
- package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
- package/src/main/lib/prd/prdMcpReachWarnings.cjs +46 -0
- package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
- package/src/main/lib/process/peerChatSession.cjs +165 -0
- package/src/main/lib/project-pages/videoScriptPress.cjs +6 -0
- package/src/main/lib/project-pages/videoScriptRunRoute.cjs +24 -4
- package/src/main/lib/promptSessionSchema.cjs +2 -0
- package/src/main/lib/scheduler/baselineGate.cjs +31 -2
- package/src/main/lib/scheduler/planRecordHarvest.cjs +104 -12
- package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
- package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
- package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
- package/src/main/lib/scheduler/planReviewStore.cjs +150 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
- package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +12 -2
- package/src/main/lib/tasks/memoryConsolidation.cjs +118 -37
- package/src/main/lib/tasks/taskAdminRoutes.cjs +26 -14
- package/src/main/lib/tasks/taskRun.cjs +3 -1
- package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +298 -0
- package/src/main/projectPages.cjs +22 -14
- package/src/main/pty.cjs +3 -0
- package/src/main/runVerify.cjs +80 -5
- package/src/main/scheduler/gitTreeGuard.cjs +6 -0
- package/src/main/scheduler/planReviewHold.cjs +146 -0
- package/src/main/scheduler/prdParser.cjs +1 -0
- package/src/main/scheduler/prdPaths.cjs +10 -1
- package/src/main/scheduler/reviewLadder.cjs +2 -0
- package/src/main/scheduler/utilizationHold.cjs +7 -2
- package/src/main/scheduler.cjs +692 -86
- package/src/main/seedAgentPersonas.cjs +11 -6
- package/src/main/seedStatus.cjs +1 -1
- package/src/main/templates/PRD_AUTHORING.md +17 -2
- package/src/main/webRemote.cjs +69 -7
- package/src/preload/api.d.ts +79 -1
- package/src/preload/apiSurface.json +39 -0
- package/src/preload/index.cjs +11 -0
- package/src/seed/agents/architect.md +28 -43
- package/src/seed/agents/dev-lead.md +3 -1
- package/src/seed/agents/md-network-curator.md +27 -0
- package/src/seed/agents/plan-reviewer.md +47 -0
- package/src/seed/agents/validator.md +2 -1
- package/dist/assets/AppSettings-BO4jDVGO.js +0 -2
- package/dist/assets/HomeClaudeConfig-DADP5bfn.js +0 -3
- package/dist/assets/ProjectClaudeConfig-DPnDJKcr.js +0 -26
- package/dist/assets/Scheduler-CNLjn90m.js +0 -16
package/src/main/agentsIpc.cjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
const { schemas, validated } = require('./ipcSchemas.cjs');
|
|
10
10
|
const agentLibrary = require('./agentLibrary.cjs');
|
|
11
|
+
const personaUpgrade = require('./lib/persona-macro/personaUpgrade.cjs');
|
|
11
12
|
const agentModelResolve = require('./lib/claude/agentModelResolve.cjs');
|
|
12
13
|
const agentEffortResolve = require('./lib/claude/agentEffortResolve.cjs');
|
|
13
14
|
const { resolveEffectiveModelInfo } = require('./lib/claude/effectiveModelInfo.cjs');
|
|
@@ -51,6 +52,16 @@ function registerAgentsHandlers({ ipcMain, getWindow }) {
|
|
|
51
52
|
broadcastAgentsChanged();
|
|
52
53
|
return result;
|
|
53
54
|
}));
|
|
55
|
+
ipcMain.handle('agents:take-bundled-persona', validated(schemas.agentsTakeBundledPersona, async ({ name }) => {
|
|
56
|
+
const result = await personaUpgrade.takeBundledPersona(name);
|
|
57
|
+
broadcastAgentsChanged();
|
|
58
|
+
return result;
|
|
59
|
+
}));
|
|
60
|
+
ipcMain.handle('agents:dismiss-persona-upgrade', validated(schemas.agentsDismissPersonaUpgrade, async ({ name, bundledVersion }) => {
|
|
61
|
+
const result = await personaUpgrade.dismissPersonaUpgrade(name, bundledVersion);
|
|
62
|
+
broadcastAgentsChanged();
|
|
63
|
+
return result;
|
|
64
|
+
}));
|
|
54
65
|
// New Epic AIM composer (epicIntake.ts's `agentBody`/`agentPath`): unlike
|
|
55
66
|
// list-personas above (global dir only), this honors the project-overlay-
|
|
56
67
|
// then-global precedence so an Epic's opening prompt carries the persona
|
|
@@ -77,6 +88,14 @@ function registerAgentsHandlers({ ipcMain, getWindow }) {
|
|
|
77
88
|
// (cwd, agentType). Read-only observer; never affects what a launch resolves.
|
|
78
89
|
ipcMain.handle('agents:resolve-model-info', validated(schemas.agentsResolveModelInfo, (payload) =>
|
|
79
90
|
resolveEffectiveModelInfo(payload)));
|
|
91
|
+
|
|
92
|
+
// Gear armory read model (agentArmory.cjs) for the character sheet. Read-only;
|
|
93
|
+
// bannedTools is the scheduler's headless disallow list (lazy-required: scheduler.cjs is heavy).
|
|
94
|
+
ipcMain.handle('agents:armory', validated(schemas.agentsArmory, (payload) =>
|
|
95
|
+
require('./lib/claude/agentArmory.cjs').buildArmory({
|
|
96
|
+
cwd: payload.cwd,
|
|
97
|
+
deps: { bannedTools: [...require('./scheduler.cjs').HEADLESS_DISALLOWED_TOOLS] },
|
|
98
|
+
})));
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
module.exports = { registerAgentsHandlers };
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.145.0",
|
|
3
|
+
"gitSha": "2a609e11c1db8f39df7efe6b76e52abafbe191f2",
|
|
4
|
+
"gitShortSha": "2a609e11",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-27T22:59:01.972Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
package/src/main/chatRunner.cjs
CHANGED
|
@@ -56,7 +56,9 @@ const { developLoopOffSettingsArgs } = require('./lib/epic/developLoopSpawn.cjs'
|
|
|
56
56
|
const packSpawnArgs = require('./lib/packs/packSpawnArgs.cjs');
|
|
57
57
|
const { resolveEpicEffort, effortArgs } = require('./lib/claude/agentEffortResolve.cjs');
|
|
58
58
|
const { planEpicSpawn, resolveEpicTurnModel } = require('./lib/epic/epicSpawnPlan.cjs');
|
|
59
|
+
const { buildPersonaToolScope, personaToolScopeArgs, skillDenyArgs, HEADLESS_SCOPE_AGENT_NAME, CHAT_HARNESS_MCP_SERVERS } = require('./lib/claude/personaToolScope.cjs');
|
|
59
60
|
const epicWorktreeMint = require('./lib/epic/epicWorktreeMint.cjs');
|
|
61
|
+
const epicDepsSync = require('./lib/epic/epicDepsSync.cjs');
|
|
60
62
|
const logs = require('./logs.cjs');
|
|
61
63
|
const chatInflight = require('./lib/chatInflight.cjs');
|
|
62
64
|
const { feedChildStdin } = require('./lib/process/childStdin.cjs');
|
|
@@ -903,6 +905,12 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
903
905
|
settle();
|
|
904
906
|
return;
|
|
905
907
|
}
|
|
908
|
+
// Long-lived Epic worktree: refresh its node_modules links from the project checkout
|
|
909
|
+
// (fire-and-forget, throttled). The sync runs after the CLI is spawned, so it normally
|
|
910
|
+
// lands before the agent's first tool call but is not awaited; the next turn guarantees it.
|
|
911
|
+
if (plan.execCwd && plan.execCwd !== cwd) {
|
|
912
|
+
epicDepsSync.syncEpicWorktreeDeps({ projectCwd: cwd, worktreeCwd: plan.execCwd });
|
|
913
|
+
}
|
|
906
914
|
// Agent-CLI turn plan (agentCliTurn.cjs): command, argv, stdin, auth env, parser, transcript.
|
|
907
915
|
let agentPlan = null;
|
|
908
916
|
if (isAgentCli) {
|
|
@@ -920,6 +928,29 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
920
928
|
? cleanChildEnv({ PATH: pathWithUserBins(), SM_CHAT_SESSION_ID: sessionId, SM_PROJECT_ROOT: cwd, ...artifactsEnv, ...agentPlan.envExtra })
|
|
921
929
|
: null;
|
|
922
930
|
|
|
931
|
+
// Gear binds chat (stamped snapshots only): same tool/MCP/pack/skill scope a job gets.
|
|
932
|
+
let gearArgs = [];
|
|
933
|
+
if (!isAgentCli && plan.persona && plan.persona.snapshot) {
|
|
934
|
+
try {
|
|
935
|
+
const gear = gearChatArgs({ snapshot: plan.persona.snapshot, cwd: plan.execCwd || cwd, projectRoot: cwd });
|
|
936
|
+
gearArgs = gear.args;
|
|
937
|
+
// Persona-declared packs load with the Epic's (as for jobs); known ones only.
|
|
938
|
+
const snapPacks = (Array.isArray(plan.persona.snapshot.packs) ? plan.persona.snapshot.packs.map(String) : [])
|
|
939
|
+
.filter((p) => !(agentEpic?.packs || []).map(String).includes(p));
|
|
940
|
+
if (gear.args.length && snapPacks.length) {
|
|
941
|
+
const extra = packSpawnArgs.composePackSpawnArgs({ packIds: snapPacks });
|
|
942
|
+
packPluginDirArgs = [...packPluginDirArgs, ...(Array.isArray(extra.pluginDirArgs) ? extra.pluginDirArgs : [])];
|
|
943
|
+
if (extra.laws) packLaws = packLaws ? `${packLaws}\n\n${extra.laws}` : extra.laws;
|
|
944
|
+
}
|
|
945
|
+
for (const message of gear.errors) {
|
|
946
|
+
try {
|
|
947
|
+
opsErrorLog.appendError({ cwd, scope: 'chatRunner', level: 'warn', code: 'capability_unknown', tabId, tags: [], message, meta: { sessionId } });
|
|
948
|
+
} catch { /* logging must never fail a turn */ }
|
|
949
|
+
if (!silent) broadcast('chat:run:notice', { tabId, sessionId, message });
|
|
950
|
+
}
|
|
951
|
+
} catch { gearArgs = []; }
|
|
952
|
+
}
|
|
953
|
+
|
|
923
954
|
const useResume = plan.useResume;
|
|
924
955
|
if (!agentPlan && useResume !== !!resume) {
|
|
925
956
|
try {
|
|
@@ -942,6 +973,7 @@ function executeRun({ tabId, sessionId, prompt, cwd, resume, silent, onSilentRes
|
|
|
942
973
|
'--dangerously-skip-permissions',
|
|
943
974
|
...loopOffArgs,
|
|
944
975
|
...packPluginDirArgs,
|
|
976
|
+
...gearArgs,
|
|
945
977
|
...(packLaws ? ['--append-system-prompt', packLaws] : []),
|
|
946
978
|
'--output-format', 'stream-json',
|
|
947
979
|
'--verbose',
|
|
@@ -1655,6 +1687,111 @@ function registerChatHandlers() {
|
|
|
1655
1687
|
|
|
1656
1688
|
}
|
|
1657
1689
|
|
|
1690
|
+
const undecidedLogged = new Set();
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Servers in the argv's --mcp-config that no --agents tools entry (mcp__<s> or mcp__<s>__*) grants.
|
|
1694
|
+
* [] when either flag is absent or unparseable. Pure.
|
|
1695
|
+
* @param {string[]} args
|
|
1696
|
+
* @returns {string[]}
|
|
1697
|
+
*/
|
|
1698
|
+
function ungrantedMcpServers(args) {
|
|
1699
|
+
if (!Array.isArray(args)) return [];
|
|
1700
|
+
const ai = args.indexOf('--agents');
|
|
1701
|
+
const mi = args.indexOf('--mcp-config');
|
|
1702
|
+
if (ai < 0 || mi < 0) return [];
|
|
1703
|
+
let tools; let servers;
|
|
1704
|
+
try {
|
|
1705
|
+
const agents = JSON.parse(args[ai + 1]);
|
|
1706
|
+
const def = agents && agents[HEADLESS_SCOPE_AGENT_NAME];
|
|
1707
|
+
tools = def && Array.isArray(def.tools) ? def.tools.map(String) : null;
|
|
1708
|
+
servers = Object.keys((JSON.parse(args[mi + 1]) || {}).mcpServers || {});
|
|
1709
|
+
} catch { return []; }
|
|
1710
|
+
if (!tools) return [];
|
|
1711
|
+
const granted = new Set(tools.filter((t) => t.startsWith('mcp__')).map((t) => t.slice(5).split('__')[0]));
|
|
1712
|
+
return servers.filter((s) => !granted.has(s));
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* Gear for a chat turn (PRD 4768): the argv that gives an Epic whose pinned snapshot carries
|
|
1717
|
+
* `gearBindsChat` the same scope a job gets — persona tools, strict MCP with the declared servers,
|
|
1718
|
+
* packs' skill allow-list. HEADLESS_DISALLOWED_TOOLS is deliberately NOT applied to chat.
|
|
1719
|
+
* Unstamped (older) snapshots and Unbound personas add nothing; Undecided runs unscoped.
|
|
1720
|
+
* An unknown declared server/pack never crashes the turn: it is dropped and reported in `errors`.
|
|
1721
|
+
* Pure apart from reading ~/.claude.json and <cwd>/.mcp.json (declared servers), the pack catalog and the seeded MCP entry (injectable for tests).
|
|
1722
|
+
* `projectRoot` is the Epic's main project cwd: a worktree `cwd` still sees servers under projects[<main root>].
|
|
1723
|
+
* @param {{ snapshot: any, cwd?: string, projectRoot?: string, deps?: { home?: string, knownMcpServers?: Record<string, object>, listPacks?: () => { packs: any[] }, listUnpackedSkills?: () => string[], log?: (msg: string) => void, scopeArgs?: typeof personaToolScopeArgs } }} opts
|
|
1724
|
+
* @returns {{ args: string[], errors: string[] }}
|
|
1725
|
+
*/
|
|
1726
|
+
function gearChatArgs({ snapshot, cwd, projectRoot, deps = {} }) {
|
|
1727
|
+
const none = { args: [], errors: [] };
|
|
1728
|
+
if (!snapshot || snapshot.gearBindsChat !== true) return none;
|
|
1729
|
+
const loadout = snapshot.loadout;
|
|
1730
|
+
if (loadout === 'unbound') return none;
|
|
1731
|
+
if (loadout === 'undecided') {
|
|
1732
|
+
const key = String(snapshot.name || '');
|
|
1733
|
+
if (!undecidedLogged.has(key)) {
|
|
1734
|
+
undecidedLogged.add(key);
|
|
1735
|
+
try { (deps.log || ((m) => logs.writeLine({ scope: 'chatRunner', level: 'info', message: m })))(`persona "${key}" is undecided about gear; chat runs unscoped`); } catch { /* logging must never fail a turn */ }
|
|
1736
|
+
}
|
|
1737
|
+
return none;
|
|
1738
|
+
}
|
|
1739
|
+
let known = deps.knownMcpServers;
|
|
1740
|
+
/** @type {Record<string, string>} */
|
|
1741
|
+
let credentialed = {};
|
|
1742
|
+
if (!known) {
|
|
1743
|
+
try {
|
|
1744
|
+
const r = require('./lib/claude/headlessMcpServers.cjs').resolveHeadlessMcpServers({ cwd, projectRoot, ...(deps.home ? { home: deps.home } : {}) });
|
|
1745
|
+
known = r.known;
|
|
1746
|
+
credentialed = r.credentialed;
|
|
1747
|
+
} catch { known = {}; }
|
|
1748
|
+
}
|
|
1749
|
+
let catalog = [];
|
|
1750
|
+
try { catalog = (deps.listPacks || require('./lib/packs/packCatalog.cjs').listPacks)().packs || []; } catch { catalog = []; }
|
|
1751
|
+
let unpacked = [];
|
|
1752
|
+
try { unpacked = (deps.listUnpackedSkills || require('./lib/packs/packCatalog.cjs').listUnpackedSkills)(); } catch { unpacked = []; }
|
|
1753
|
+
const packs = Array.isArray(snapshot.packs) ? snapshot.packs.map(String) : [];
|
|
1754
|
+
const knownPackIds = new Set(catalog.map((p) => String(p.id)));
|
|
1755
|
+
const personaDeclared = Array.isArray(snapshot.mcpServers) ? snapshot.mcpServers.map(String) : [];
|
|
1756
|
+
// SM's own harness rides every scoped chat; the scheduler is always kept so its absence is reported below.
|
|
1757
|
+
const harness = CHAT_HARNESS_MCP_SERVERS.filter((n) => n === 'session-manager-scheduler' || Object.prototype.hasOwnProperty.call(known || {}, n));
|
|
1758
|
+
const declared = [...new Set([...personaDeclared, ...harness])];
|
|
1759
|
+
const scope = buildPersonaToolScope(snapshot.tools, { loadout, disallowed: [] });
|
|
1760
|
+
const scopeFn = deps.scopeArgs || personaToolScopeArgs;
|
|
1761
|
+
const attempt = scopeFn(scope, { mcpServers: known, declaredServers: declared, packs, knownPacks: [...knownPackIds] });
|
|
1762
|
+
/** @type {string[]} */ const errors = [];
|
|
1763
|
+
let scopeArgs = attempt.args;
|
|
1764
|
+
let equipped = packs;
|
|
1765
|
+
if (attempt.refusal) {
|
|
1766
|
+
// Run without the unknown capability instead of failing the turn: drop it and re-derive.
|
|
1767
|
+
const bad = new Set();
|
|
1768
|
+
let r = attempt.refusal;
|
|
1769
|
+
let guard = 0;
|
|
1770
|
+
let curDeclared = declared;
|
|
1771
|
+
let curPacks = packs;
|
|
1772
|
+
let curScope = scope;
|
|
1773
|
+
let cur = attempt;
|
|
1774
|
+
while (r && guard++ < 50) {
|
|
1775
|
+
bad.add(r.name);
|
|
1776
|
+
errors.push(Object.prototype.hasOwnProperty.call(credentialed, r.name)
|
|
1777
|
+
? `Gear: "${r.name}" is not available (${credentialed[r.name]}); this turn runs without it.`
|
|
1778
|
+
: `Gear: "${r.name}" is not available; this turn runs without it.`);
|
|
1779
|
+
curDeclared = curDeclared.filter((d) => d !== r.name);
|
|
1780
|
+
curPacks = curPacks.filter((p) => p !== r.name);
|
|
1781
|
+
curScope = curScope ? { tools: curScope.tools.filter((t) => !(t.startsWith('mcp__') && t.slice(5).split('__')[0] === r.name) && t !== r.name) } : curScope;
|
|
1782
|
+
cur = scopeFn(curScope, { mcpServers: known, declaredServers: curDeclared, packs: curPacks, knownPacks: [...knownPackIds] });
|
|
1783
|
+
r = cur.refusal;
|
|
1784
|
+
}
|
|
1785
|
+
scopeArgs = cur.args;
|
|
1786
|
+
equipped = curPacks;
|
|
1787
|
+
}
|
|
1788
|
+
// A loaded-but-ungranted server is invisible to the CLI (even ToolSearch) — never omit it silently.
|
|
1789
|
+
for (const name of ungrantedMcpServers(scopeArgs)) errors.push(`Gear: "${name}" was loaded but not granted to this chat's tools; its tools are unavailable this turn.`);
|
|
1790
|
+
const installedSkills = [...new Set([...catalog.flatMap((p) => p.skills || []), ...unpacked].map(String))];
|
|
1791
|
+
const deny = skillDenyArgs({ installedSkills, equippedPacks: equipped, packCatalog: catalog, loadout });
|
|
1792
|
+
return { args: [...scopeArgs, ...deny], errors };
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1658
1795
|
module.exports = {
|
|
1659
1796
|
run,
|
|
1660
1797
|
cancel,
|
|
@@ -1666,6 +1803,8 @@ module.exports = {
|
|
|
1666
1803
|
registerChatHandlers,
|
|
1667
1804
|
noteChatRunOrigin,
|
|
1668
1805
|
turnInstructionFor,
|
|
1806
|
+
gearChatArgs,
|
|
1807
|
+
ungrantedMcpServers,
|
|
1669
1808
|
shouldFollowUp,
|
|
1670
1809
|
parseStopSignal,
|
|
1671
1810
|
splitStopSignal,
|
package/src/main/config.cjs
CHANGED
|
@@ -79,6 +79,17 @@ function addAllowedRoot(dir) {
|
|
|
79
79
|
if (dir) allowedRoots.add(pathFor().resolve(dir));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Remove a root registered via addAllowedRoot (same normalization). Returns
|
|
84
|
+
* true when one was removed; the built-in home root is never removed.
|
|
85
|
+
*/
|
|
86
|
+
function removeAllowedRoot(dir) {
|
|
87
|
+
if (!dir) return false;
|
|
88
|
+
const abs = pathFor().resolve(dir);
|
|
89
|
+
if (abs === pathFor().resolve(os.homedir())) return false;
|
|
90
|
+
return allowedRoots.delete(abs);
|
|
91
|
+
}
|
|
92
|
+
|
|
82
93
|
/** Snapshot of the registered roots (main-process-registered only). */
|
|
83
94
|
function getAllowedRoots() {
|
|
84
95
|
return [...allowedRoots];
|
|
@@ -703,6 +714,7 @@ module.exports = {
|
|
|
703
714
|
listDir,
|
|
704
715
|
exists,
|
|
705
716
|
addAllowedRoot,
|
|
717
|
+
removeAllowedRoot,
|
|
706
718
|
getAllowedRoots,
|
|
707
719
|
registerPromptSessionsRoot,
|
|
708
720
|
transitionEpicArchiveWrite,
|
package/src/main/health.cjs
CHANGED
|
@@ -845,6 +845,52 @@ function evaluateVisibleRuntimeState(results = []) {
|
|
|
845
845
|
};
|
|
846
846
|
}
|
|
847
847
|
|
|
848
|
+
/**
|
|
849
|
+
* collectRuntimeStateHealth(roots, { findTracked, findVisible })
|
|
850
|
+
* → Promise<{ components: { tracked_runtime_state, visible_runtime_state }, issues }>
|
|
851
|
+
*
|
|
852
|
+
* Runs both runtime-state checks over `roots` (sequentially). Each side has its
|
|
853
|
+
* own failure handling: a throw on one side sets only that component to
|
|
854
|
+
* { ok: true, error } and adds no issues for it — the other side still reports.
|
|
855
|
+
* Non-critical: neither component ever sets ok=false.
|
|
856
|
+
*/
|
|
857
|
+
async function collectRuntimeStateHealth(roots = [], { findTracked, findVisible } = {}) {
|
|
858
|
+
const list = Array.isArray(roots) ? roots : [];
|
|
859
|
+
const components = {};
|
|
860
|
+
const visibleIssues = [];
|
|
861
|
+
const trackedIssues = [];
|
|
862
|
+
|
|
863
|
+
try {
|
|
864
|
+
const visible = [];
|
|
865
|
+
for (const cwd of list) {
|
|
866
|
+
visible.push({ cwd, count: (await findVisible(cwd)).length });
|
|
867
|
+
}
|
|
868
|
+
const visibleEval = evaluateVisibleRuntimeState(visible);
|
|
869
|
+
components.visible_runtime_state = visibleEval.component;
|
|
870
|
+
visibleIssues.push(...visibleEval.issues);
|
|
871
|
+
} catch (e) {
|
|
872
|
+
components.visible_runtime_state = { ok: true, error: e && e.message };
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
try {
|
|
876
|
+
const hits = [];
|
|
877
|
+
for (const cwd of list) {
|
|
878
|
+
const n = (await findTracked(cwd)).length;
|
|
879
|
+
if (n > 0) hits.push({ cwd, count: n });
|
|
880
|
+
}
|
|
881
|
+
components.tracked_runtime_state = hits.length === 0
|
|
882
|
+
? { ok: true }
|
|
883
|
+
: { ok: true, warn: true, projects: hits };
|
|
884
|
+
for (const h of hits) {
|
|
885
|
+
trackedIssues.push(`warn: ${h.cwd} tracks ${h.count} Session Manager runtime-state file(s) in git — untrack from its main checkout`);
|
|
886
|
+
}
|
|
887
|
+
} catch (e) {
|
|
888
|
+
components.tracked_runtime_state = { ok: true, error: e && e.message };
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
return { components, issues: [...visibleIssues, ...trackedIssues] };
|
|
892
|
+
}
|
|
893
|
+
|
|
848
894
|
/**
|
|
849
895
|
* evaluateCredentialHealth({ credState, now }) → { component, issues }
|
|
850
896
|
*
|
|
@@ -1515,28 +1561,23 @@ async function check(opts = {}) {
|
|
|
1515
1561
|
// 6.76. Tracked runtime state: projects that committed Session Manager
|
|
1516
1562
|
// runtime namespaces. Warning only (never flips ok) — untrack via
|
|
1517
1563
|
// runtimeStateUntrack.untrackRuntimeState from the project's main checkout.
|
|
1564
|
+
// Each check fails on its own inside collectRuntimeStateHealth; only a
|
|
1565
|
+
// failure computing the roots blanks both.
|
|
1566
|
+
let runtimeRoots = null;
|
|
1518
1567
|
try {
|
|
1519
|
-
|
|
1520
|
-
const hits = [];
|
|
1521
|
-
const visible = [];
|
|
1522
|
-
for (const cwd of roots) {
|
|
1523
|
-
const n = (await findTrackedRuntimeState(cwd)).length;
|
|
1524
|
-
if (n > 0) hits.push({ cwd, count: n });
|
|
1525
|
-
visible.push({ cwd, count: (await findVisibleRuntimeState(cwd)).length });
|
|
1526
|
-
}
|
|
1527
|
-
const visibleEval = evaluateVisibleRuntimeState(visible);
|
|
1528
|
-
status.components.visible_runtime_state = visibleEval.component;
|
|
1529
|
-
status.issues.push(...visibleEval.issues);
|
|
1530
|
-
status.components.tracked_runtime_state = hits.length === 0
|
|
1531
|
-
? { ok: true }
|
|
1532
|
-
: { ok: true, warn: true, projects: hits };
|
|
1533
|
-
for (const h of hits) {
|
|
1534
|
-
status.issues.push(`warn: ${h.cwd} tracks ${h.count} Session Manager runtime-state file(s) in git — untrack from its main checkout`);
|
|
1535
|
-
}
|
|
1568
|
+
runtimeRoots = [...new Set(allProjectCwds())].slice(0, 100).filter((cwd) => fs.existsSync(cwd));
|
|
1536
1569
|
} catch (e) {
|
|
1537
1570
|
status.components.tracked_runtime_state = { ok: true, error: e.message };
|
|
1538
1571
|
status.components.visible_runtime_state = { ok: true, error: e.message };
|
|
1539
1572
|
}
|
|
1573
|
+
if (runtimeRoots) {
|
|
1574
|
+
const runtime = await collectRuntimeStateHealth(runtimeRoots, {
|
|
1575
|
+
findTracked: findTrackedRuntimeState,
|
|
1576
|
+
findVisible: findVisibleRuntimeState,
|
|
1577
|
+
});
|
|
1578
|
+
Object.assign(status.components, runtime.components);
|
|
1579
|
+
status.issues.push(...runtime.issues);
|
|
1580
|
+
}
|
|
1540
1581
|
|
|
1541
1582
|
// 6.8. Credential health (informational-but-loud): is the Claude OAuth token
|
|
1542
1583
|
// usable? An expired/absent token silently voids every headless `claude -p`
|
|
@@ -1631,6 +1672,7 @@ module.exports = {
|
|
|
1631
1672
|
evaluateBuildFreshness,
|
|
1632
1673
|
evaluateMainDepLinks,
|
|
1633
1674
|
evaluateVisibleRuntimeState,
|
|
1675
|
+
collectRuntimeStateHealth,
|
|
1634
1676
|
WORKTREE_SAFETY_PATHS,
|
|
1635
1677
|
latestStarveEscalationReasons,
|
|
1636
1678
|
DISPATCH_STALL_THRESHOLD_MS,
|
package/src/main/index.cjs
CHANGED
|
@@ -393,6 +393,10 @@ function relaunchViaNpx() {
|
|
|
393
393
|
async function rebootApp({ force = false } = {}) {
|
|
394
394
|
if (force) {
|
|
395
395
|
logReboot('force reboot requested — immediate, not draining');
|
|
396
|
+
// This reboot IS the restart any pending request asked for; never leave one
|
|
397
|
+
// behind for the next boot to drain and restart a second time.
|
|
398
|
+
const retired = upgradeDrain.retireRestartRequestBestEffort();
|
|
399
|
+
if (!retired.ok) logReboot(`could not retire restart request (continuing): ${retired.error}`);
|
|
396
400
|
return performReboot();
|
|
397
401
|
}
|
|
398
402
|
const request = upgradeDrain.requestRestart({ reason: 'user-reboot', requestedBy: 'user' });
|
|
@@ -1594,7 +1598,7 @@ app.whenReady().then(async () => {
|
|
|
1594
1598
|
label: 'Help',
|
|
1595
1599
|
submenu: [
|
|
1596
1600
|
{
|
|
1597
|
-
label: 'Book a Free
|
|
1601
|
+
label: 'Book a Free Consultation',
|
|
1598
1602
|
click: () => {
|
|
1599
1603
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|
1600
1604
|
sendIfAlive(mainWindow, 'app:open-free-hour');
|
|
@@ -1787,7 +1791,7 @@ app.whenReady().then(async () => {
|
|
|
1787
1791
|
// ~/.claude/projects scan, banned on timer paths); a project with no
|
|
1788
1792
|
// subscriptions is a no-op.
|
|
1789
1793
|
const runWebhookDelivery = () => {
|
|
1790
|
-
scheduler.readQueue()
|
|
1794
|
+
Promise.resolve().then(() => scheduler.readQueue())
|
|
1791
1795
|
.then((q) => require('./lib/telemetry/webhookDelivery.cjs').runDeliveryPass({
|
|
1792
1796
|
cwds: (Array.isArray(q?.jobs) ? q.jobs : []).map((j) => j && j.cwd).filter((c) => typeof c === 'string' && c),
|
|
1793
1797
|
logs,
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -838,8 +838,48 @@ const setSessionSlotsSchema = z.object({
|
|
|
838
838
|
// only after a production incident (see scheduleJobSchema.cjs's header).
|
|
839
839
|
// Full field-level rules live in lib/persona-macro/agentPersonaSchema.cjs, mirroring
|
|
840
840
|
// AgentPersonaSaveInput (src/preload/api.d.ts) field-for-field.
|
|
841
|
-
|
|
841
|
+
// A project override (projectCwd set) may also carry the gear keys, validated with the persona
|
|
842
|
+
// frontmatter rules (saveOverlay re-checks the serialized lines). AgentPersonaSaveSchema is
|
|
843
|
+
// .strict(), so the gear keys are split off, validated here, and merged back.
|
|
844
|
+
const AgentOverlayGearSchema = z.object({
|
|
845
|
+
loadout: z.enum(['undecided', 'bare', 'equipped', 'unbound']).optional(),
|
|
846
|
+
mcpServers: z.array(z.string().trim().min(1).max(200)).max(64).optional(),
|
|
847
|
+
packs: z.array(z.string().trim().min(1).max(200)).max(64).optional(),
|
|
848
|
+
environment: z.string().trim().regex(/^[a-z0-9][a-z0-9-]*$/, 'environment must be a lowercase, hyphenated profile name').optional(),
|
|
849
|
+
}).strict();
|
|
850
|
+
const GEAR_KEYS = ['loadout', 'mcpServers', 'packs', 'environment'];
|
|
851
|
+
const agentsSavePersona = z.record(z.string(), z.unknown()).transform((raw, ctx) => {
|
|
852
|
+
/** @type {Record<string, unknown>} */
|
|
853
|
+
const gear = {};
|
|
854
|
+
const rest = { ...raw };
|
|
855
|
+
const hasCwd = rest.projectCwd !== undefined;
|
|
856
|
+
for (const k of GEAR_KEYS) {
|
|
857
|
+
if (k in rest) { gear[k] = rest[k]; delete rest[k]; }
|
|
858
|
+
}
|
|
859
|
+
// Global saves take the gear keys via AgentPersonaSaveSchema; 'undecided' is overlay-only.
|
|
860
|
+
if (!hasCwd && gear.loadout === 'undecided') {
|
|
861
|
+
ctx.addIssue({ code: 'custom', path: ['loadout'], message: "loadout 'undecided' is accepted only on a project override (projectCwd set)" });
|
|
862
|
+
return z.NEVER;
|
|
863
|
+
}
|
|
864
|
+
if (!hasCwd) {
|
|
865
|
+
const base = AgentPersonaSaveSchema.safeParse({ ...rest, ...gear });
|
|
866
|
+
if (!base.success) {
|
|
867
|
+
for (const i of base.error.issues) ctx.addIssue({ code: 'custom', path: i.path, message: i.message });
|
|
868
|
+
return z.NEVER;
|
|
869
|
+
}
|
|
870
|
+
return base.data;
|
|
871
|
+
}
|
|
872
|
+
const base = AgentPersonaSaveSchema.safeParse(rest);
|
|
873
|
+
const g = AgentOverlayGearSchema.safeParse(gear);
|
|
874
|
+
if (!base.success || !g.success) {
|
|
875
|
+
for (const r of [base, g]) if (!r.success) for (const i of r.error.issues) ctx.addIssue({ code: 'custom', path: i.path, message: i.message });
|
|
876
|
+
return z.NEVER;
|
|
877
|
+
}
|
|
878
|
+
return { ...base.data, ...g.data };
|
|
879
|
+
});
|
|
842
880
|
// agents:remove-override — an OPEN project's override, keyed by its absolute cwd (never a folder name).
|
|
881
|
+
const agentsTakeBundledPersona = z.object({ name: PersonaNameSchema }).strict();
|
|
882
|
+
const agentsDismissPersonaUpgrade = z.object({ name: PersonaNameSchema, bundledVersion: z.number().int().min(1) }).strict();
|
|
843
883
|
const agentsRemoveOverride = z.object({ name: PersonaNameSchema, projectCwd: ProjectCwdSchema }).strict();
|
|
844
884
|
// agents:delete-persona — a kebab-case name only; `.strict()` also bars deletePersona's injectable `globalDir`.
|
|
845
885
|
const agentsDeletePersona = z.object({ name: PersonaNameSchema }).strict();
|
|
@@ -1101,6 +1141,11 @@ const agentsResolveEpicModel = z.object({
|
|
|
1101
1141
|
}).strict();
|
|
1102
1142
|
const agentsResolveEpicEffort = agentsResolveEpicModel;
|
|
1103
1143
|
|
|
1144
|
+
// agents:armory — gear read model; cwd optional (global gear only when absent).
|
|
1145
|
+
const agentsArmory = z.object({
|
|
1146
|
+
cwd: z.string().min(1).max(4096).optional(),
|
|
1147
|
+
}).strict();
|
|
1148
|
+
|
|
1104
1149
|
// ──────────────────────────────────────────── Project Pages (PRD 932)
|
|
1105
1150
|
// Same validation split as projectBriefCwd above: real path validation is
|
|
1106
1151
|
// config.cjs's validatePath at first fs access in projectPages.cjs.
|
|
@@ -1518,6 +1563,7 @@ const webRemoteServicePairStart = z.object({
|
|
|
1518
1563
|
name: z.string().min(1).max(64).regex(/^[^\r\n]+$/),
|
|
1519
1564
|
homeCwd: z.string().min(1).max(4096),
|
|
1520
1565
|
scope: z.array(z.string().min(1).max(64)).min(1).max(16),
|
|
1566
|
+
projectRoot: z.string().min(1).max(4096).optional(),
|
|
1521
1567
|
}).strict();
|
|
1522
1568
|
const webRemoteServiceConfirmSas = z.object({
|
|
1523
1569
|
pairingId: z.string().regex(WEB_REMOTE_UUID_RE),
|
|
@@ -1529,6 +1575,10 @@ const webRemoteServicePairCancel = z.object({
|
|
|
1529
1575
|
const webRemoteServiceRevoke = z.object({
|
|
1530
1576
|
serviceId: z.string().regex(WEB_REMOTE_UUID_RE),
|
|
1531
1577
|
}).strict();
|
|
1578
|
+
const webRemoteServiceSetStartWork = z.object({
|
|
1579
|
+
serviceId: z.string().regex(WEB_REMOTE_UUID_RE),
|
|
1580
|
+
targets: z.array(z.string().min(1).max(4096)).max(200),
|
|
1581
|
+
}).strict();
|
|
1532
1582
|
const webRemoteRelayClientRevoke = z.object({
|
|
1533
1583
|
clientId: z.string().uuid(),
|
|
1534
1584
|
}).strict();
|
|
@@ -1862,6 +1912,7 @@ module.exports = {
|
|
|
1862
1912
|
webRemoteServiceConfirmSas,
|
|
1863
1913
|
webRemoteServicePairCancel,
|
|
1864
1914
|
webRemoteServiceRevoke,
|
|
1915
|
+
webRemoteServiceSetStartWork,
|
|
1865
1916
|
webRemoteRelayClientRevoke,
|
|
1866
1917
|
sessionSubscribe,
|
|
1867
1918
|
ptySpawn,
|
|
@@ -1998,6 +2049,8 @@ module.exports = {
|
|
|
1998
2049
|
exchangesList,
|
|
1999
2050
|
agentsSavePersona,
|
|
2000
2051
|
agentsRemoveOverride,
|
|
2052
|
+
agentsTakeBundledPersona,
|
|
2053
|
+
agentsDismissPersonaUpgrade,
|
|
2001
2054
|
agentsDeletePersona,
|
|
2002
2055
|
claudeConfigRead,
|
|
2003
2056
|
claudeConfigPatch,
|
|
@@ -2028,6 +2081,7 @@ module.exports = {
|
|
|
2028
2081
|
modelsCatalog,
|
|
2029
2082
|
agentsResolveEpicModel,
|
|
2030
2083
|
agentsResolveEpicEffort,
|
|
2084
|
+
agentsArmory,
|
|
2031
2085
|
delegationReadinessCwd,
|
|
2032
2086
|
appCreateProjectFolder,
|
|
2033
2087
|
telemetrySetConfig,
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* agentArmory.cjs — the Armory read model: one pure aggregate of catalogs that
|
|
5
|
+
* already exist (built-in tools + bundled skills, configured MCP servers with
|
|
6
|
+
* their last-known tools, packs + loose skills, tool-risk marks). No registry
|
|
7
|
+
* file, no probes run here. Every source is injected (`deps`); a source that
|
|
8
|
+
* throws adds a message to `errors` and leaves its group empty. Never throws.
|
|
9
|
+
*
|
|
10
|
+
* Deps (all optional, default to the real modules):
|
|
11
|
+
* - getBuiltinTools() -> { tools, skills }
|
|
12
|
+
* - listPacks() -> { packs, errors } ; listUnpackedSkills() -> string[]
|
|
13
|
+
* - listMcpServers({ cwd }) -> [{ name, scope }] (same config reader as mcpToolsProbe)
|
|
14
|
+
* - getMcpProbe({ name, scope, cwd }) -> { ok, tools: (string|{name})[] } | null (last result only)
|
|
15
|
+
* - loadMarks({ cwd }) -> { system, project } risk-mark layers
|
|
16
|
+
* - listEnvironments() -> { name, summary }[] (default: built-in profiles of environmentProfiles.cjs)
|
|
17
|
+
* - bannedTools: string[] (the scheduler's HEADLESS_DISALLOWED_TOOLS, passed by the caller)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const os = require('node:os');
|
|
21
|
+
const path = require('node:path');
|
|
22
|
+
|
|
23
|
+
/** @param {unknown} e */
|
|
24
|
+
const msg = (e) => String((e && /** @type {Error} */ (e).message) || e);
|
|
25
|
+
|
|
26
|
+
/** Default probe source: the last checkConfiguredMcpServer result held in memory. */
|
|
27
|
+
function defaultGetMcpProbe({ name, scope }) {
|
|
28
|
+
return require('../mcpToolsProbe.cjs').lastProbe(scope, name);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Real MCP config reader: user ~/.claude.json + <cwd>/.mcp.json via claudeConfig (as mcpToolsProbe). */
|
|
32
|
+
async function defaultListMcpServers({ cwd }) {
|
|
33
|
+
const claudeConfig = require('../claudeConfig.cjs');
|
|
34
|
+
const out = [];
|
|
35
|
+
const user = await claudeConfig.read({ fileId: 'claudeJson', scope: 'user', home: os.homedir() });
|
|
36
|
+
for (const name of Object.keys((user.data && user.data.mcpServers) || {})) out.push({ name, scope: 'user' });
|
|
37
|
+
if (typeof cwd === 'string' && path.isAbsolute(cwd)) {
|
|
38
|
+
const proj = await claudeConfig.read({ fileId: 'mcpJson', scope: 'project', cwd });
|
|
39
|
+
for (const name of Object.keys((proj.data && proj.data.mcpServers) || {})) out.push({ name, scope: 'project' });
|
|
40
|
+
}
|
|
41
|
+
// Plugin-provided servers have no config file here; they appear once checked.
|
|
42
|
+
for (const e of require('../mcpToolsProbe.cjs').probedServers('plugin')) out.push({ name: e.name, scope: 'plugin' });
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function defaultListEnvironments() {
|
|
47
|
+
const { BUILTIN_ENVIRONMENTS } = require('./environmentProfiles.cjs');
|
|
48
|
+
return Object.entries(BUILTIN_ENVIRONMENTS).map(([name, p]) => ({ name, summary: p.description }));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function defaultLoadMarks({ cwd }) {
|
|
52
|
+
const m = require('./toolRiskMarks.cjs');
|
|
53
|
+
return {
|
|
54
|
+
system: m.readMarksLayer(m.systemMarksPath(os.homedir())),
|
|
55
|
+
project: typeof cwd === 'string' && cwd ? m.readMarksLayer(m.projectMarksPath(cwd)) : null,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {{ cwd?: string, deps?: Record<string, any> }} [opts]
|
|
61
|
+
*/
|
|
62
|
+
async function buildArmory({ cwd, deps } = {}) {
|
|
63
|
+
const d = deps || {};
|
|
64
|
+
/** @type {string[]} */ const errors = [];
|
|
65
|
+
const out = { builtins: [], bundledSkills: [], mcpServers: [], packs: [], unpackedSkills: [], environments: [], errors };
|
|
66
|
+
|
|
67
|
+
/** Run one source; on failure record and return the fallback. */
|
|
68
|
+
const guard = async (label, fn, fallback) => {
|
|
69
|
+
try { return await fn(); } catch (e) { errors.push(`${label}: ${msg(e)}`); return fallback; }
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const banned = new Set(Array.isArray(d.bannedTools) ? d.bannedTools : []);
|
|
73
|
+
let floor = [];
|
|
74
|
+
try { floor = require('./personaToolScope.cjs').HEADLESS_TOOL_FLOOR; } catch (e) { errors.push(`toolFloor: ${msg(e)}`); }
|
|
75
|
+
const floorSet = new Set(floor);
|
|
76
|
+
|
|
77
|
+
const marks = await guard('toolRiskMarks', async () => (d.loadMarks || defaultLoadMarks)({ cwd }), null);
|
|
78
|
+
const isRisky = (tool) => {
|
|
79
|
+
if (!marks) return false;
|
|
80
|
+
try { return !!require('./toolRiskMarks.cjs').resolveMark({ tool }, marks); } catch { return false; }
|
|
81
|
+
};
|
|
82
|
+
const badgesFor = (name, { floorable = true } = {}) => {
|
|
83
|
+
/** @type {('risky'|'banned'|'floor')[]} */ const b = [];
|
|
84
|
+
if (isRisky(name)) b.push('risky');
|
|
85
|
+
if (banned.has(name)) b.push('banned');
|
|
86
|
+
if (floorable && floorSet.has(name)) b.push('floor');
|
|
87
|
+
return b;
|
|
88
|
+
};
|
|
89
|
+
const item = (name, opts) => ({ id: name, label: name, badges: badgesFor(name, opts) });
|
|
90
|
+
|
|
91
|
+
const builtin = await guard('builtinTools', async () => (d.getBuiltinTools || require('./builtinTools.cjs').getBuiltinTools)(), null);
|
|
92
|
+
if (builtin) {
|
|
93
|
+
out.builtins = (builtin.tools || []).map((t) => item(t));
|
|
94
|
+
out.bundledSkills = (builtin.skills || []).map((s) => item(s, { floorable: false }));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const packRes = await guard('packs', async () => (d.listPacks || require('../packs/packCatalog.cjs').listPacks)(), null);
|
|
98
|
+
if (packRes) {
|
|
99
|
+
out.packs = (packRes.packs || []).map((p) => ({
|
|
100
|
+
id: p.id, label: p.label || p.id, badges: [], skills: [...(p.skills || [])], source: p.source,
|
|
101
|
+
}));
|
|
102
|
+
for (const e of packRes.errors || []) errors.push(`packs: ${e.dir}: ${e.error}`);
|
|
103
|
+
}
|
|
104
|
+
out.unpackedSkills = await guard('unpackedSkills', async () => [...(d.listUnpackedSkills || require('../packs/packCatalog.cjs').listUnpackedSkills)()], []);
|
|
105
|
+
|
|
106
|
+
const servers = await guard('mcpServers', async () => (d.listMcpServers || defaultListMcpServers)({ cwd }), []);
|
|
107
|
+
for (const s of servers) {
|
|
108
|
+
let status = 'not-checked';
|
|
109
|
+
let tools = [];
|
|
110
|
+
try {
|
|
111
|
+
const probe = await (d.getMcpProbe || defaultGetMcpProbe)({ name: s.name, scope: s.scope, cwd });
|
|
112
|
+
if (probe && probe.ok === false) status = 'failing';
|
|
113
|
+
else if (probe && Array.isArray(probe.tools)) {
|
|
114
|
+
status = 'checked';
|
|
115
|
+
tools = probe.tools
|
|
116
|
+
.map((t) => (typeof t === 'string' ? t : t && t.name))
|
|
117
|
+
.filter((n) => typeof n === 'string' && n)
|
|
118
|
+
.map((n) => ({ id: `mcp__${s.name}__${n}`, label: n, badges: badgesFor(`mcp__${s.name}__${n}`, { floorable: false }) }));
|
|
119
|
+
}
|
|
120
|
+
} catch (e) { errors.push(`mcpProbe ${s.name}: ${msg(e)}`); }
|
|
121
|
+
out.mcpServers.push({ id: s.name, label: s.name, badges: [], tools, status, scope: s.scope });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
out.environments = await guard('environments', async () => (d.listEnvironments || defaultListEnvironments)(), []);
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = { buildArmory };
|
|
@@ -257,7 +257,7 @@ const DEFAULT_PRD_AGENT_TYPE = 'dev-lead';
|
|
|
257
257
|
* read) and this module's frontmatter-stripped-body cap.
|
|
258
258
|
*
|
|
259
259
|
* @param {{ cwd: string, agentType: string|null, deps?: object }} opts
|
|
260
|
-
* @returns {Promise<{ model: string|null, systemPrompt: string|null, personaPath: string|null, tools: string[]|null, refusal: null|{ code: 'persona_missing'|'persona_invalid', detail: string } }>}
|
|
260
|
+
* @returns {Promise<{ model: string|null, systemPrompt: string|null, personaPath: string|null, tools: string[]|null, loadout?: 'undecided'|'bare'|'equipped'|'unbound', refusal: null|{ code: 'persona_missing'|'persona_invalid', detail: string } }>}
|
|
261
261
|
*/
|
|
262
262
|
async function resolvePrdPersonaForSpawn({ cwd, agentType, deps = {} } = {}) {
|
|
263
263
|
const name = agentType || DEFAULT_PRD_AGENT_TYPE;
|
|
@@ -295,7 +295,8 @@ async function resolvePrdPersonaForSpawn({ cwd, agentType, deps = {} } = {}) {
|
|
|
295
295
|
const systemPrompt = buildPersonaBodyText(body, persona.path, { uncapped });
|
|
296
296
|
const parseTools = deps.parseTools || require('../../agentLibrary.cjs').parseTools;
|
|
297
297
|
const list = parseTools(typeof fm.tools === 'string' ? fm.tools : '');
|
|
298
|
-
|
|
298
|
+
const { loadoutState } = require('../persona-macro/personaLoadout.cjs');
|
|
299
|
+
return { model, systemPrompt, personaPath: persona.path, tools: list.length ? list : null, loadout: loadoutState(fm), refusal: null };
|
|
299
300
|
} catch (err) {
|
|
300
301
|
const msg = err && err.message ? err.message : String(err);
|
|
301
302
|
return refuse('persona_invalid', `agentType '${name}' persona ${persona.path || '(unknown path)'} could not be parsed: ${msg}`, persona.path || null);
|