claude-code-session-manager 0.131.0 → 0.132.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/{AgentLibrary-CYXre0J-.js → AgentLibrary-C09MlPFx.js} +1 -1
- package/dist/assets/{AppSettings-xNSfCj8e.js → AppSettings-DvDKsCnD.js} +2 -2
- package/dist/assets/{Button-BWljh5IK.js → Button-BzG_KdBC.js} +1 -1
- package/dist/assets/{DocumentEditorPane-FUC2hZlp.js → DocumentEditorPane-fm6zsnLM.js} +1 -1
- package/dist/assets/{Extensions-CsyUoklz.js → Extensions-DgxKT_OZ.js} +2 -2
- package/dist/assets/{History-BvNmY9OQ.js → History-Nd3bKjBq.js} +1 -1
- package/dist/assets/{Library-DVXk77zA.js → Library-R71t6VAB.js} +1 -1
- package/dist/assets/{ListDetail-DAAx__24.js → ListDetail-CG50Ul7c.js} +1 -1
- package/dist/assets/{Panel-g2D-e-RM.js → Panel-C7EFG4eU.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-BDuHJwaO.js → ProjectClaudeConfig-J92iNEGC.js} +1 -1
- package/dist/assets/{ProvenanceBadge-wew4_nf3.js → ProvenanceBadge-C3KB3ILO.js} +1 -1
- package/dist/assets/{Scheduler-CbeUIqD-.js → Scheduler-DeYBA7uc.js} +1 -1
- package/dist/assets/{Settings-B23RsRfm.js → Settings-B6r7N4v-.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-BxQPCfsg.js → SkillReferenceGraph-D7bt3fyB.js} +1 -1
- package/dist/assets/{Skills-4AR2FQrI.js → Skills-GpxtUrFP.js} +1 -1
- package/dist/assets/{SourceChip-jrC0vjfw.js → SourceChip-uyVMCZc7.js} +1 -1
- package/dist/assets/{SystemPrompt-hHoBEnYb.js → SystemPrompt-Cv25uFSM.js} +1 -1
- package/dist/assets/{TiptapBody-FkUqxO9u.js → TiptapBody-uP8fJkbM.js} +1 -1
- package/dist/assets/{Toggle-DQMNWZKT.js → Toggle-DRs80cX-.js} +1 -1
- package/dist/assets/{ViewTabs-DGU0ZuxB.js → ViewTabs-BDkvvzJ8.js} +1 -1
- package/dist/assets/{VoiceButton-BPPvDllh.js → VoiceButton-Cmtz2sQt.js} +1 -1
- package/dist/assets/{historyTotals-D8Oc3wUK.js → historyTotals-DHwAXunq.js} +1 -1
- package/dist/assets/{index-9ajPMXBg.js → index-CBCdyHbZ.js} +287 -287
- package/dist/index.html +1 -1
- package/dist-web/app.js +345 -345
- package/package.json +1 -1
- package/scripts/scheduler-mcp-server.cjs +12 -4
- package/src/main/build-info.json +4 -4
- package/src/main/index.cjs +2 -0
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +36 -13
- package/src/main/lib/mcpToolCatalog.cjs +15 -6
- package/src/main/lib/persona-macro/builtinMacros.cjs +17 -0
- package/src/main/lib/persona-macro/macroJobIpc.cjs +57 -11
- package/src/main/lib/persona-macro/macroLibrary.cjs +40 -10
- package/src/main/projectPages.cjs +5 -1
- package/src/main/promptSessionEvents.cjs +10 -6
- package/src/preload/api.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0",
|
|
4
4
|
"description": "Local cockpit for the Claude Code CLI — multi-tab terminal, full config surface, scheduler, voice dictation, and live observability.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
@@ -661,14 +661,14 @@ const TOOLS = [
|
|
|
661
661
|
type: 'object',
|
|
662
662
|
properties: {
|
|
663
663
|
cwd: { type: 'string', description: "Optional: absolute path to the target project. Defaults to the calling session's own project root (SM_PROJECT_ROOT or process.cwd()) when omitted." },
|
|
664
|
-
id: { type: 'string', description: 'Optional: id of an existing macro (already visible to this project) to update. Omit to create a new macro
|
|
664
|
+
id: { type: 'string', description: 'Optional: id of an existing macro (already visible to this project) to update. Omit to create a new macro.' },
|
|
665
665
|
label: { type: 'string', description: 'Short label shown on the HOT KEYS button.' },
|
|
666
666
|
agentName: { type: 'string', description: 'Persona to run the macro as (e.g. "builder").' },
|
|
667
667
|
tag: { type: 'string', description: 'Mission tag for the macro.' },
|
|
668
668
|
prompt: { type: 'string', description: 'The opening prompt the macro sends. Write input placeholders as {{name}}; each is filled from the matching entry in `inputs` when the macro is pressed.' },
|
|
669
|
-
surface: { type: 'string', enum: ['sessions', 'project-home'], description: "Where the macro shows: 'sessions' = Sessions HOT KEYS strip
|
|
669
|
+
surface: { type: 'string', enum: ['sessions', 'project-home'], description: "Where the macro shows: 'sessions' = Sessions HOT KEYS strip; 'project-home' = a tool in Project Home ▸ Tools, shown in every project (only what it generates is per project). A 'project-home' save needs humanRequestQuote and a Session Manager chat session." },
|
|
670
670
|
projects: { type: 'array', items: { type: 'string' }, description: 'Optional: only ["*"] is accepted, to show the macro in every project. Needs humanRequestQuote and a Session Manager chat session.' },
|
|
671
|
-
humanRequestQuote: { type: 'string', description:
|
|
671
|
+
humanRequestQuote: { type: 'string', description: "With projects [\"*\"] or surface 'project-home': the exact words the human typed in this chat asking for every project or for a Project Home tool." },
|
|
672
672
|
inputs: {
|
|
673
673
|
type: 'array',
|
|
674
674
|
description: 'Optional input fields the human fills in before the macro runs. Prompt placeholders are written as {{name}}. Omit on update to keep the existing inputs; pass [] to clear them.',
|
|
@@ -1127,7 +1127,15 @@ async function handleCallTool(request) {
|
|
|
1127
1127
|
if (missing.length > 0) {
|
|
1128
1128
|
return errorResult(`missing or invalid required argument(s): ${missing.join(', ')}`);
|
|
1129
1129
|
}
|
|
1130
|
-
|
|
1130
|
+
// A Project Home tool is shown in every project, so it gets the same
|
|
1131
|
+
// human-session refusal as projects ["*"].
|
|
1132
|
+
if (args.surface === 'project-home') {
|
|
1133
|
+
const refusal = humanSessionRefusal(
|
|
1134
|
+
'refused: a Project Home tool is shown in every project and is saved only in a Session Manager chat session where the human asked for it. '
|
|
1135
|
+
+ 'Say in your final result that the human can add it from Project Home ▸ Tools ▸ Add a tool.',
|
|
1136
|
+
);
|
|
1137
|
+
if (refusal) return refusal;
|
|
1138
|
+
} else if (args.projects !== undefined) {
|
|
1131
1139
|
const refusal = humanSessionRefusal(
|
|
1132
1140
|
'refused: a macro shown in every project is saved only in a Session Manager chat session where the human asked for it. '
|
|
1133
1141
|
+ 'Say in your final result that the human can set Show in every project in the macro editor.',
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.132.0",
|
|
3
|
+
"gitSha": "4930de0b7e7bf78a7a1c00c60c30ac9298458411",
|
|
4
|
+
"gitShortSha": "4930de0b",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-08T22:44:12.441Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
package/src/main/index.cjs
CHANGED
|
@@ -623,6 +623,8 @@ require('./lib/persona-macro/macroJobIpc.cjs').registerMacroJobIpc(ipcMain, {
|
|
|
623
623
|
createPrd: (input) => prdCreate.createPrd(input, scheduler.remote),
|
|
624
624
|
loadJobs: async () => (await require('./lib/scheduler/queueStore.cjs').readMerged()).jobs || [],
|
|
625
625
|
archivePrd: (slug, cwd) => queueOps.archiveMany([slug], cwd),
|
|
626
|
+
// Durable 'job-not-queued' notice on the Epic when a dispatch fails (PRD 2950).
|
|
627
|
+
appendResponseEventWithReason: promptSessionEvents.appendResponseEventWithReason,
|
|
626
628
|
});
|
|
627
629
|
// claudeConfig (lib/claudeConfig.cjs): key-scoped read/patch of Claude's JSON config files.
|
|
628
630
|
// A successful patch broadcasts `config:changed` so renderer state refreshes.
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* cwd resolution matches projectHomeAdminRoutes.cjs's resolveCwd exactly
|
|
15
15
|
* (reused, not copied). `surface` ('sessions' | 'project-home') is accepted on
|
|
16
16
|
* create and update; a create defaults it to 'sessions' and `projects` to
|
|
17
|
-
* [resolvedCwd].
|
|
17
|
+
* [resolvedCwd]. A Project Home tool is part of Session Manager and shown in
|
|
18
|
+
* every project's Project Home, so any save whose resulting surface is
|
|
19
|
+
* 'project-home' stores projects ["*"]; only what it generates is per project.
|
|
20
|
+
* `projects` is accepted ONLY as exactly ["*"] (show in every
|
|
18
21
|
* project); anything else is a 400. An update without `projects` leaves them
|
|
19
22
|
* unchanged. An update is refused (400) if the macro is not visible to the
|
|
20
23
|
* resolved cwd (macroLibrary.macroVisibleIn, so '*' macros are reachable), if
|
|
@@ -24,7 +27,7 @@
|
|
|
24
27
|
* A save whose existing or resulting macro is shown in every project needs a
|
|
25
28
|
* VERIFIED human request: body.humanRequestQuote must appear in a prompt the
|
|
26
29
|
* human typed into body.originClaudeSessionId (humanPromptLedger) AND name
|
|
27
|
-
* every/all projects. Otherwise 400, no write, no onChanged, no audit.
|
|
30
|
+
* every/all projects (or, for a 'project-home' macro, Project Home). Otherwise 400, no write, no onChanged, no audit.
|
|
28
31
|
*
|
|
29
32
|
* Every successful save appends one `admin_macro_save` audit event and calls
|
|
30
33
|
* `onChanged()` exactly once so the Sessions HOT KEYS strip updates live,
|
|
@@ -47,23 +50,36 @@ function quoteNamesEveryProject(quote) {
|
|
|
47
50
|
return EVERY_PROJECT_RE.test(q) || /(^|[^a-z0-9])everywhere($|[^a-z0-9])/.test(q);
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
const PROJECT_HOME_RE = /(^|[^a-z0-9])project\s*home($|[^a-z0-9])/;
|
|
54
|
+
|
|
55
|
+
/** True when the quote names Project Home (project home / project-home / project_home). */
|
|
56
|
+
function quoteNamesProjectHome(quote) {
|
|
57
|
+
if (typeof quote !== 'string') return false;
|
|
58
|
+
const q = quote.toLowerCase().replace(/[-_]/g, ' ');
|
|
59
|
+
return PROJECT_HOME_RE.test(q);
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
const HUMAN_HINT = "the human can set 'Show in every project' in the macro editor";
|
|
63
|
+
const PROJECT_HOME_HINT =
|
|
64
|
+
"a Project Home tool is shown in every project's Project Home, so it needs humanRequestQuote (the human's words asking for a Project Home tool); the human can add one from Project Home ▸ Tools ▸ Add a tool";
|
|
51
65
|
|
|
52
|
-
/** Fail-closed check that a human asked for an all-projects macro. */
|
|
53
|
-
function verifyAllProjectsRequest(body) {
|
|
66
|
+
/** Fail-closed check that a human asked for an all-projects macro (or a Project Home tool). */
|
|
67
|
+
function verifyAllProjectsRequest(body, { projectHome = false } = {}) {
|
|
68
|
+
const hint = projectHome ? PROJECT_HOME_HINT : HUMAN_HINT;
|
|
54
69
|
const quote = body.humanRequestQuote;
|
|
55
70
|
if (typeof quote !== 'string' || !quote.trim()) {
|
|
56
|
-
return { ok: false, reason: `a macro shown in every project needs humanRequestQuote (a verbatim human request); ${
|
|
71
|
+
return { ok: false, reason: `a macro shown in every project needs humanRequestQuote (a verbatim human request); ${hint}` };
|
|
57
72
|
}
|
|
58
73
|
const origin = body.originClaudeSessionId;
|
|
59
74
|
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); ${
|
|
75
|
+
return { ok: false, reason: `a macro shown in every project needs originClaudeSessionId (1-128 chars); ${hint}` };
|
|
61
76
|
}
|
|
62
77
|
if (!findHumanPromptContaining(origin, quote)) {
|
|
63
|
-
return { ok: false, reason: `humanRequestQuote was not found in a prompt the human typed in this session; ${
|
|
78
|
+
return { ok: false, reason: `humanRequestQuote was not found in a prompt the human typed in this session; ${hint}` };
|
|
64
79
|
}
|
|
65
|
-
if (!quoteNamesEveryProject(quote)) {
|
|
66
|
-
|
|
80
|
+
if (!quoteNamesEveryProject(quote) && !(projectHome && quoteNamesProjectHome(quote))) {
|
|
81
|
+
const named = projectHome ? 'Project Home or every/all projects' : 'every/all projects';
|
|
82
|
+
return { ok: false, reason: `humanRequestQuote does not name ${named}; ${hint}` };
|
|
67
83
|
}
|
|
68
84
|
return { ok: true, quote };
|
|
69
85
|
}
|
|
@@ -153,10 +169,12 @@ function saveHandler(onChanged, libOpts) {
|
|
|
153
169
|
return;
|
|
154
170
|
}
|
|
155
171
|
}
|
|
156
|
-
const
|
|
172
|
+
const resultSurface = input.surface ?? existing?.surface ?? 'sessions';
|
|
173
|
+
const projectHome = resultSurface === 'project-home';
|
|
174
|
+
const allProjects = Boolean(existing?.projects.includes(macroLibrary.ALL_PROJECTS)) || wantsAll || projectHome;
|
|
157
175
|
let quote = null;
|
|
158
176
|
if (allProjects) {
|
|
159
|
-
const v = verifyAllProjectsRequest(body);
|
|
177
|
+
const v = verifyAllProjectsRequest(body, { projectHome });
|
|
160
178
|
if (!v.ok) {
|
|
161
179
|
sendJson(res, 400, { ok: false, error: v.reason });
|
|
162
180
|
return;
|
|
@@ -164,8 +182,12 @@ function saveHandler(onChanged, libOpts) {
|
|
|
164
182
|
quote = v.quote;
|
|
165
183
|
}
|
|
166
184
|
if (!input.id) {
|
|
167
|
-
input = {
|
|
168
|
-
|
|
185
|
+
input = {
|
|
186
|
+
...input,
|
|
187
|
+
projects: wantsAll || projectHome ? [macroLibrary.ALL_PROJECTS] : [resolved.cwd],
|
|
188
|
+
surface: input.surface ?? 'sessions',
|
|
189
|
+
};
|
|
190
|
+
} else if (wantsAll || projectHome) {
|
|
169
191
|
input = { ...input, projects: [macroLibrary.ALL_PROJECTS] };
|
|
170
192
|
}
|
|
171
193
|
let macro;
|
|
@@ -238,4 +260,5 @@ function registerAdminRoute(adminHttp, { onChanged } = {}, opts = {}) {
|
|
|
238
260
|
module.exports = {
|
|
239
261
|
registerAdminRoute,
|
|
240
262
|
quoteNamesEveryProject,
|
|
263
|
+
quoteNamesProjectHome,
|
|
241
264
|
};
|
|
@@ -462,8 +462,9 @@ const MCP_TOOL_CATALOG = [
|
|
|
462
462
|
name: 'macro_list',
|
|
463
463
|
group: 'macros',
|
|
464
464
|
purpose: "List this project's HOT KEYS macros — the saved (agent, tag, prompt) one-click buttons shown "
|
|
465
|
-
+ "in the Sessions tab's HOT KEYS strip or
|
|
466
|
-
+ "Each macro's `surface` tells where it shows: 'sessions' = Sessions HOT KEYS strip, 'project-home' =
|
|
465
|
+
+ "in the Sessions tab's HOT KEYS strip or as tools in Project Home ▸ Tools, via the session-manager app's admin API. "
|
|
466
|
+
+ "Each macro's `surface` tells where it shows: 'sessions' = Sessions HOT KEYS strip, 'project-home' = a tool in "
|
|
467
|
+
+ 'Project Home ▸ Tools, shown in every project (only what it generates is per project).',
|
|
467
468
|
whenToUse: 'Use to see what macros already exist for this project (including machine-wide `*` macros and '
|
|
468
469
|
+ 'built-ins) before deciding whether to add, update or delete one.',
|
|
469
470
|
whenNotToUse: 'WHEN NOT TO USE IT: macros are scoped to the caller\'s own project — this only ever returns '
|
|
@@ -479,13 +480,18 @@ const MCP_TOOL_CATALOG = [
|
|
|
479
480
|
+ 'the Sessions HOT KEYS strip reads from.',
|
|
480
481
|
whenToUse: 'Pass `id` to update an existing macro already visible to this project; omit `id` to create a new '
|
|
481
482
|
+ 'one scoped to this project. Use for things like a "Publish git + npm" macro a human will press '
|
|
482
|
-
+ 'repeatedly, when they have asked for that macro to exist.'
|
|
483
|
+
+ 'repeatedly, when they have asked for that macro to exist. A surface \'project-home\' macro is a Project Home '
|
|
484
|
+
+ 'tool and is always saved for every project; pass `humanRequestQuote` with the human\'s words naming Project Home '
|
|
485
|
+
+ '(or every project).',
|
|
483
486
|
whenNotToUse: 'WHEN NOT TO USE IT: macros are scoped to the caller\'s own project — this call is refused if '
|
|
484
487
|
+ '`id` resolves to a macro not visible to this project. Built-in macros (`id` starting with `builtin-`) '
|
|
485
488
|
+ "cannot be edited through this route. A macro is a HUMAN's one-click button, not a task runner — never "
|
|
486
489
|
+ 'create or update one unless the human has actually asked for that macro to exist. '
|
|
487
490
|
+ 'To remove a macro use macro_delete; never rewrite it into a placeholder. '
|
|
488
|
-
+ 'Never pass `projects` unless the human asked for every project in this chat; quote their words in `humanRequestQuote`.'
|
|
491
|
+
+ 'Never pass `projects` unless the human asked for every project in this chat; quote their words in `humanRequestQuote`. '
|
|
492
|
+
+ 'Never save a surface \'project-home\' macro unless the human asked in this chat for a Project Home tool — it is '
|
|
493
|
+
+ 'always saved for every project, needs `humanRequestQuote` naming Project Home (or every project), and is refused '
|
|
494
|
+
+ 'in a scheduled job or outside a Session Manager chat session.',
|
|
489
495
|
exampleArgs: {
|
|
490
496
|
cwd: '/home/bilko/Projects/session-manager',
|
|
491
497
|
label: 'Publish git + npm',
|
|
@@ -496,10 +502,13 @@ const MCP_TOOL_CATALOG = [
|
|
|
496
502
|
},
|
|
497
503
|
notes: "cwd is optional — defaults to the calling session's own project root (SM_PROJECT_ROOT or "
|
|
498
504
|
+ 'process.cwd()) when omitted. label, agentName, tag and prompt are all required strings. '
|
|
499
|
-
+ "`surface` is optional: 'sessions' = Sessions HOT KEYS strip, 'project-home' = Project Home
|
|
505
|
+
+ "`surface` is optional: 'sessions' = Sessions HOT KEYS strip, 'project-home' = a tool in Project Home ▸ Tools. "
|
|
506
|
+
+ "A surface 'project-home' macro is always saved for every project (only what it generates is per project); it "
|
|
507
|
+
+ 'needs `humanRequestQuote` naming Project Home (or every project) and is refused in a scheduled job or outside '
|
|
508
|
+
+ 'a Session Manager chat session. '
|
|
500
509
|
+ '`projects: ["*"]` shows the macro in every project; it needs `humanRequestQuote`, the words the human typed in '
|
|
501
510
|
+ 'this chat that ask for every/all projects, and is refused in a scheduled job or outside a Session Manager session. '
|
|
502
|
-
+
|
|
511
|
+
+ "Without `projects`, a 'sessions' macro stays scoped to this project. "
|
|
503
512
|
+ '`inputs` is an optional array of { name, label, default, required, options } fields the human fills in '
|
|
504
513
|
+ 'when pressing the macro; reference each in the prompt as {{name}}. Omitting `inputs` on update keeps '
|
|
505
514
|
+ 'the existing inputs; `[]` clears them.',
|
|
@@ -107,6 +107,23 @@ const BUILTIN_MACROS = Object.freeze([
|
|
|
107
107
|
prompt:
|
|
108
108
|
"Build this project's competitor feature matrix: how this product compares to its top 4 competitors. The competitors are named on a 'Competitors:' line in the additional instructions — up to 4 semicolon-separated slots, each a product name or 'auto' (an 'auto' slot means pick the most popular remaining competitor in this product's category, with cited popularity evidence); with no Competitors line, reuse the saved matrix's competitors, or make 4 auto picks when there is no saved matrix. Warm-start first: call project_matrix_read and, when a matrix exists, keep its feature, group and competitor ids stable and research only what is new since its last run plus unknown cells. Then fan out Haiku competitive-researcher subagents, one per competitor plus one user-voice sweep, collecting official announcements, dev blogs, changelogs, docs and what users rave about or ask for, with a source URL for every claim. Compare their findings against this repository's real features (read from the README, docs, manifest, source tree and git log, each backed by a path) and merge everything into 6-12 logical feature groups; for every feature record a stable id, title, detailed description, support per product (yes/partial/no/unknown with evidence), user sentiment, priority, rationale, and a ready-to-run sessionGoal where this project lacks or only partly has it. Append a runs[] entry and save the whole matrix with one project_matrix_write call.",
|
|
109
109
|
}),
|
|
110
|
+
Object.freeze({
|
|
111
|
+
id: 'builtin-cpu-audit',
|
|
112
|
+
label: 'CPU audit & fixes',
|
|
113
|
+
agentName: 'architect',
|
|
114
|
+
tag: 'feature',
|
|
115
|
+
surface: 'project-home',
|
|
116
|
+
projects: ['*'],
|
|
117
|
+
builtinVersion: 1,
|
|
118
|
+
inputs: Object.freeze([
|
|
119
|
+
Object.freeze({ name: 'scope', label: 'Scope', default: 'the whole project', required: true }),
|
|
120
|
+
Object.freeze({ name: 'scenario', label: 'Run scenario', default: 'idle, then its typical everyday load', required: true }),
|
|
121
|
+
]),
|
|
122
|
+
supersedes: Object.freeze(['cpu-audit-fixes-8bd5d1']),
|
|
123
|
+
priorPrompts: Object.freeze([]),
|
|
124
|
+
prompt:
|
|
125
|
+
"Critically evaluate how much CPU this project uses while it runs, then get the recommended changes built. Primary goal: it consumes fewer resources while it runs — CPU first, then memory, disk I/O, network and process count. Secondary goal: it gets faster. Behavior stays the same. Scope: {{scope}}. Run scenario to measure: {{scenario}}. The project's CLAUDE.md and AGENTS.md laws override this prompt.\n\n1. Learn how it really runs. Read the README, manifests and start scripts. List every long-running process and everything it starts: workers, child CLIs, MCP servers, file watchers, timers, cron entries. If the project has no long-running process (a library, CLI or static site), measure its main commands instead (build, test, a typical run).\n\n2. Measure a baseline before you look for fixes. If the project is already running on this machine, measure that instance; never start a second copy beside a live one (ports, locks and shared state clash). Put a hard timeout on every command. Measure each state of the run scenario over a fixed window of at least 5 minutes. Record per process: average and peak CPU %, RSS, threads, child processes started per minute, and wakeups or syscalls where you can (pidstat, ps, top -b, /proc/<pid>/stat deltas, strace -c -f). Then profile the top consumers so cost is attributed to functions, not guessed: attach a sampling profiler to the running process where the runtime allows it (perf, py-spy, the Node inspector, DevTools for renderer processes), and restart a process under a profiler only when nothing live depends on it. Save the exact commands so the after-measurement repeats them.\n\n3. Review the code critically, starting from the hottest profiled paths. Look for: polling and timers that fire while nothing changes (idle should be near 0% CPU); busy loops; full rescans or re-parses of large files and directories; recursive watchers on big trees; a process spawned per tick or per request; unbounded concurrency; work redone on every request or render instead of cached; UI re-render storms and animations running while hidden; sync I/O on hot paths; chatty logging; large JSON stringify/parse; retries without backoff; over-frequent heartbeats; leaks (listeners, intervals, caches that only grow). For each one, first ask whether the work needs to run at all, then how to make it cheaper. Prefer structural fixes (event-driven instead of polling, incremental instead of full rescans, one shared process instead of many) over micro-tuning.\n\n4. Rank findings by measured cost × confidence ÷ risk, and drop anything without a measurable cost. Show them as a table: rank | where (file:line) | what burns the resource | measured cost (CPU share, RSS, spawns/min) | recommended change | expected saving | risk or tradeoff. Name every tradeoff plainly, such as a slower refresh. If the project is already lean, say so with the numbers and stop; do not invent work.\n\n5. Build the changes through /develop, highest impact first. Each PRD carries its measured evidence, the change, and acceptance criteria a headless run can check: deterministic tests (fake timers proving nothing polls while idle, call or spawn counts, bounded work per tick) or a bounded micro-benchmark with a before number and a target. Never use \"launch the app and watch top\" as a criterion. Every fix gets a regression guard so the waste cannot quietly return, and existing tests stay green.\n\n6. Track the PRDs to a validated finish, then re-measure live with the same commands, window and scenario. Report a before/after table per process: average and peak CPU, RSS, spawns/min. If the running copy is an installed or released build rather than this tree, the after-measurement waits for that release: say exactly what has landed but is not live yet, and never claim a saving from tests alone.",
|
|
126
|
+
}),
|
|
110
127
|
]);
|
|
111
128
|
|
|
112
129
|
module.exports = { BUILTIN_MACROS };
|
|
@@ -6,17 +6,48 @@
|
|
|
6
6
|
* injected (index.cjs passes the real scheduler, createPrd and archive).
|
|
7
7
|
*
|
|
8
8
|
* deps: { schemas, validatePath, readActiveIndex, createPrd, loadJobs,
|
|
9
|
-
* archivePrd,
|
|
9
|
+
* archivePrd, appendResponseEventWithReason?, dispatchMacroJob?,
|
|
10
|
+
* macroJobStatuses?, readHistoryTail?, builtins? }
|
|
11
|
+
*
|
|
12
|
+
* When a dispatch returns ok:false for an Epic that exists in the cwd's
|
|
13
|
+
* active-index.json (and no build is already running for it — `activeSlug`),
|
|
14
|
+
* one durable 'response' event marked `notice: 'job-not-queued'` is appended
|
|
15
|
+
* to that Epic naming the macro, the error and the retry path (PRD 2950), so
|
|
16
|
+
* a job-macro Epic whose build never queued cannot read as a silently running
|
|
17
|
+
* session. The append is best effort: it never changes the returned result.
|
|
10
18
|
* `createPrd` is called as `chat:create-prd` calls it, so its own
|
|
11
19
|
* remote.requestReconcile() queues the row at once — no second rescan here.
|
|
12
20
|
*/
|
|
13
21
|
|
|
14
22
|
const { dispatchMacroJob: realDispatch } = require('./macroJobDispatch.cjs');
|
|
15
23
|
const { macroJobStatuses: realStatuses } = require('./macroJobStatus.cjs');
|
|
24
|
+
const { BUILTIN_MACROS } = require('./builtinMacros.cjs');
|
|
25
|
+
|
|
26
|
+
const JOB_NOT_QUEUED_NOTICE = 'job-not-queued';
|
|
27
|
+
|
|
28
|
+
function noticeText(label, error) {
|
|
29
|
+
return `${label} background build was not queued: ${error} — press it again in Project Home ▸ Tools to retry.`;
|
|
30
|
+
}
|
|
16
31
|
|
|
17
32
|
function registerMacroJobIpc(ipcMain, deps = {}) {
|
|
18
33
|
const dispatch = deps.dispatchMacroJob || realDispatch;
|
|
19
34
|
const statuses = deps.macroJobStatuses || realStatuses;
|
|
35
|
+
const builtins = deps.builtins || BUILTIN_MACROS;
|
|
36
|
+
|
|
37
|
+
async function appendNotice(cwd, macroId, epicId, error) {
|
|
38
|
+
if (typeof deps.appendResponseEventWithReason !== 'function') return;
|
|
39
|
+
try {
|
|
40
|
+
const macro = (builtins || []).find((m) => m && m.id === macroId);
|
|
41
|
+
const label = (macro && macro.label) || macroId;
|
|
42
|
+
const res = await deps.appendResponseEventWithReason(
|
|
43
|
+
cwd, epicId, noticeText(label, error),
|
|
44
|
+
{ notice: JOB_NOT_QUEUED_NOTICE, allowInactive: true },
|
|
45
|
+
);
|
|
46
|
+
if (res && res.ok === false) console.warn('[macroJobIpc] job-not-queued notice not appended', epicId, res.reason);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.warn('[macroJobIpc] job-not-queued notice append failed', epicId, e?.message ?? e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
20
51
|
|
|
21
52
|
ipcMain.handle('macros:dispatch-job', async (_event, rawPayload) => {
|
|
22
53
|
const payload = deps.schemas.macrosDispatchJob.parse(rawPayload);
|
|
@@ -24,17 +55,32 @@ function registerMacroJobIpc(ipcMain, deps = {}) {
|
|
|
24
55
|
const index = deps.readActiveIndex(cwd);
|
|
25
56
|
const sessions = index && index.sessions ? index.sessions : {};
|
|
26
57
|
const entry = Object.prototype.hasOwnProperty.call(sessions, payload.epicId) ? sessions[payload.epicId] : null;
|
|
27
|
-
if (!entry
|
|
58
|
+
if (!entry) {
|
|
28
59
|
return { ok: false, error: `epic ${payload.epicId} is not an active session in this project` };
|
|
29
60
|
}
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
if (entry.status !== 'active') {
|
|
62
|
+
const refused = { ok: false, error: `epic ${payload.epicId} is not an active session in this project` };
|
|
63
|
+
await appendNotice(cwd, payload.macroId, payload.epicId, refused.error);
|
|
64
|
+
return refused;
|
|
65
|
+
}
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
result = await dispatch(
|
|
69
|
+
{ cwd, macroId: payload.macroId, epicId: payload.epicId, extraInstructions: payload.extraInstructions },
|
|
70
|
+
{
|
|
71
|
+
createPrd: deps.createPrd,
|
|
72
|
+
listRows: async () => deps.loadJobs(),
|
|
73
|
+
archivePrd: (slug, rowCwd) => deps.archivePrd(slug, rowCwd),
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
await appendNotice(cwd, payload.macroId, payload.epicId, e?.message ?? String(e));
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
if (result && result.ok === false && !result.activeSlug) {
|
|
81
|
+
await appendNotice(cwd, payload.macroId, payload.epicId, result.error || 'unknown error');
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
38
84
|
});
|
|
39
85
|
|
|
40
86
|
ipcMain.handle('macros:job-status', async (_event, rawPayload) => {
|
|
@@ -47,4 +93,4 @@ function registerMacroJobIpc(ipcMain, deps = {}) {
|
|
|
47
93
|
});
|
|
48
94
|
}
|
|
49
95
|
|
|
50
|
-
module.exports = { registerMacroJobIpc };
|
|
96
|
+
module.exports = { registerMacroJobIpc, JOB_NOT_QUEUED_NOTICE };
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
* project). setMacroProject cannot narrow a '*' macro: it returns
|
|
32
32
|
* `{ ok: false, error: 'macro is shown in every project' }`.
|
|
33
33
|
*
|
|
34
|
+
* A surface 'project-home' macro is shown in every project (only its generated
|
|
35
|
+
* artifacts are per project); this module enforces that on load (a narrowed
|
|
36
|
+
* stored entry is widened to ['*']) and on save (projects forced to ['*']).
|
|
37
|
+
*
|
|
34
38
|
* Plain Node, no Electron imports.
|
|
35
39
|
*/
|
|
36
40
|
|
|
@@ -394,16 +398,35 @@ function ensureBuiltins(macros, builtins) {
|
|
|
394
398
|
return { macros: next, changed, retired };
|
|
395
399
|
}
|
|
396
400
|
|
|
397
|
-
/**
|
|
401
|
+
/**
|
|
402
|
+
* Pure. A 'project-home' macro is shown in every project, so any such entry
|
|
403
|
+
* whose `projects` is not exactly ['*'] comes back with ['*']. Every other
|
|
404
|
+
* field — notably `updatedAt` — is left as is: ensureBuiltins reads
|
|
405
|
+
* `updatedAt !== createdAt` as a human edit and would freeze a built-in.
|
|
406
|
+
* Returns `{ macros, changed }`.
|
|
407
|
+
*/
|
|
408
|
+
function widenProjectHomeScope(macros) {
|
|
409
|
+
let changed = false;
|
|
410
|
+
const next = macros.map((m) => {
|
|
411
|
+
if (m.surface !== 'project-home') return m;
|
|
412
|
+
if (m.projects.length === 1 && m.projects[0] === ALL_PROJECTS) return m;
|
|
413
|
+
changed = true;
|
|
414
|
+
return { ...m, projects: [ALL_PROJECTS] };
|
|
415
|
+
});
|
|
416
|
+
return { macros: changed ? next : macros, changed };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Apply project-home widening + builtin seeding/upgrades, writing only when something changed. */
|
|
398
420
|
async function applyBuiltins(filePath, macros, opts) {
|
|
399
421
|
const builtins = resolveBuiltins(opts);
|
|
400
|
-
const
|
|
401
|
-
|
|
422
|
+
const widened = widenProjectHomeScope(macros);
|
|
423
|
+
const { macros: next, changed: builtinsChanged, retired } = ensureBuiltins(widened.macros, builtins);
|
|
424
|
+
if (!builtinsChanged && !widened.changed) return { macros, failed: false };
|
|
402
425
|
try {
|
|
403
426
|
await writeStore(filePath, next);
|
|
404
427
|
} catch (err) {
|
|
405
|
-
console.warn('[macroLibrary] could not persist built-in macro seeding:', err && err.message);
|
|
406
|
-
return { macros, failed: false };
|
|
428
|
+
console.warn('[macroLibrary] could not persist built-in macro seeding / project-home widening:', err && err.message);
|
|
429
|
+
return { macros: widened.macros, failed: false };
|
|
407
430
|
}
|
|
408
431
|
for (const id of retired) {
|
|
409
432
|
const by = (builtins || []).find((b) => Array.isArray(b.supersedes) && b.supersedes.includes(id));
|
|
@@ -528,7 +551,7 @@ async function listMacrosRaw(opts) {
|
|
|
528
551
|
const first = await readStore(filePath);
|
|
529
552
|
if (first.state === 'ok') {
|
|
530
553
|
const { changed } = ensureBuiltins(first.macros, resolveBuiltins(opts));
|
|
531
|
-
if (!changed) return first.macros;
|
|
554
|
+
if (!changed && !widenProjectHomeScope(first.macros).changed) return first.macros;
|
|
532
555
|
}
|
|
533
556
|
// Missing/corrupt/needs-seeding: repair inside the write chain so racing callers don't double-seed.
|
|
534
557
|
return serialize(async () => (await loadStore(filePath, opts)).macros);
|
|
@@ -566,7 +589,10 @@ async function saveMacro(input, opts = {}) {
|
|
|
566
589
|
if (macros[idx].builtin && parsed.surface !== undefined && parsed.surface !== macros[idx].surface) {
|
|
567
590
|
throw new Error('built-in macro surface cannot be changed');
|
|
568
591
|
}
|
|
569
|
-
const
|
|
592
|
+
const surface = parsed.surface ?? macros[idx].surface;
|
|
593
|
+
const projects = surface === 'project-home'
|
|
594
|
+
? [ALL_PROJECTS]
|
|
595
|
+
: parsed.projects !== undefined ? normalizeProjects(parsed.projects) : macros[idx].projects;
|
|
570
596
|
saved = {
|
|
571
597
|
...macros[idx],
|
|
572
598
|
label: parsed.label,
|
|
@@ -574,7 +600,7 @@ async function saveMacro(input, opts = {}) {
|
|
|
574
600
|
tag: parsed.tag,
|
|
575
601
|
prompt: parsed.prompt,
|
|
576
602
|
projects,
|
|
577
|
-
surface
|
|
603
|
+
surface,
|
|
578
604
|
updatedAt: now,
|
|
579
605
|
};
|
|
580
606
|
if (parsed.inputs === undefined) {
|
|
@@ -594,7 +620,10 @@ async function saveMacro(input, opts = {}) {
|
|
|
594
620
|
assertPlaceholdersDeclared(saved);
|
|
595
621
|
macros[idx] = saved;
|
|
596
622
|
} else {
|
|
597
|
-
const
|
|
623
|
+
const surface = parsed.surface ?? 'sessions';
|
|
624
|
+
const projects = surface === 'project-home'
|
|
625
|
+
? [ALL_PROJECTS]
|
|
626
|
+
: parsed.projects !== undefined ? normalizeProjects(parsed.projects) : [];
|
|
598
627
|
saved = {
|
|
599
628
|
id: newId(parsed.label, new Set(macros.map((m) => m.id))),
|
|
600
629
|
label: parsed.label,
|
|
@@ -602,7 +631,7 @@ async function saveMacro(input, opts = {}) {
|
|
|
602
631
|
tag: parsed.tag,
|
|
603
632
|
prompt: parsed.prompt,
|
|
604
633
|
projects,
|
|
605
|
-
surface
|
|
634
|
+
surface,
|
|
606
635
|
createdAt: now,
|
|
607
636
|
updatedAt: now,
|
|
608
637
|
};
|
|
@@ -718,4 +747,5 @@ module.exports = {
|
|
|
718
747
|
removeMacroFromProject,
|
|
719
748
|
defaultFilePath,
|
|
720
749
|
ensureBuiltins,
|
|
750
|
+
widenProjectHomeScope,
|
|
721
751
|
};
|
|
@@ -124,7 +124,10 @@ async function matrix({ cwd }) {
|
|
|
124
124
|
function isLibraryPath(rel) {
|
|
125
125
|
const parts = rel.split(path.sep);
|
|
126
126
|
if (parts.length === 1) return parts[0] === 'home.html';
|
|
127
|
-
if (parts.length === 2)
|
|
127
|
+
if (parts.length === 2) {
|
|
128
|
+
if (parts[0] === 'matrix' && parts[1] === 'matrix.json') return true;
|
|
129
|
+
return parts[0] === 'demo-video' && parts[1] === 'index.html';
|
|
130
|
+
}
|
|
128
131
|
if (parts.length === 3 && (parts[0] === 'knowledge' || parts[0] === 'videos')) {
|
|
129
132
|
return parts[1] !== '_character' && (parts[2] === 'index.html' || parts[2] === 'meta.json');
|
|
130
133
|
}
|
|
@@ -308,6 +311,7 @@ module.exports = {
|
|
|
308
311
|
get,
|
|
309
312
|
mdNetwork,
|
|
310
313
|
matrix,
|
|
314
|
+
isLibraryPath,
|
|
311
315
|
renameEntry,
|
|
312
316
|
deleteEntry,
|
|
313
317
|
watchOutput,
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Main-process counterpart to promptSessions.ts's event chain, used
|
|
6
|
-
*
|
|
7
|
-
* scheduler.cjs)
|
|
5
|
+
* Main-process counterpart to promptSessions.ts's event chain, used by the
|
|
6
|
+
* scheduler's PRD-finished notification path (notifyOriginatingTab,
|
|
7
|
+
* scheduler.cjs) and by macros:dispatch-job (macroJobIpc.cjs), which appends a
|
|
8
|
+
* durable 'job-not-queued' notice when a macro's background build could not be
|
|
9
|
+
* queued for its Epic (PRD 2950). The renderer owns the live in-memory PromptSession store
|
|
8
10
|
* and its own persistActiveIndex; this module never touches that store — it
|
|
9
11
|
* reads/writes the SAME on-disk active-index.json directly, read-modify-
|
|
10
12
|
* write, so a scheduler job (which runs in the main process, with no
|
|
@@ -23,8 +25,8 @@ const config = require('./config.cjs');
|
|
|
23
25
|
const { activeIndexPath: promptSessionActiveIndexPath, withPathLock } = require('./lib/epic/epicMint.cjs');
|
|
24
26
|
|
|
25
27
|
// IPC channel broadcast whenever an event is appended to a PromptSession's
|
|
26
|
-
// chain from the main process (
|
|
27
|
-
//
|
|
28
|
+
// chain from the main process (the scheduler's and macroJobIpc's
|
|
29
|
+
// response-event appends below). Mirrors chatRunner.cjs's attachWindow/broadcast pattern.
|
|
28
30
|
const EVENT_APPENDED_CHANNEL = 'promptSession:event-appended';
|
|
29
31
|
|
|
30
32
|
let mainWindow = null;
|
|
@@ -68,7 +70,8 @@ function mintEventId() {
|
|
|
68
70
|
* regardless of the job's self-reported outcome; the authoring Epic's own
|
|
69
71
|
* validation pass is what may later move it to 'verified'/'refuted'. `agentType`
|
|
70
72
|
* (the job's agent) and `digestKey` (the settle digest's stable key) ride the
|
|
71
|
-
* same meta arg and are copied the same way
|
|
73
|
+
* same meta arg and are copied the same way, as is `notice` (PRD 2950 — a
|
|
74
|
+
* marker like 'job-not-queued' the renderer turns into a distinct notice). All
|
|
72
75
|
* keys are added to the event object only when present in `meta`, never as
|
|
73
76
|
* `undefined`-valued keys, so events appended without them serialize
|
|
74
77
|
* identically to before.
|
|
@@ -100,6 +103,7 @@ async function appendResponseEventWithReason(cwd, sourcePromptId, text, meta = {
|
|
|
100
103
|
if (meta && meta.validation) event.validation = meta.validation;
|
|
101
104
|
if (meta && meta.agentType) event.agentType = meta.agentType;
|
|
102
105
|
if (meta && meta.digestKey) event.digestKey = meta.digestKey;
|
|
106
|
+
if (meta && meta.notice) event.notice = meta.notice;
|
|
103
107
|
data.events[sourcePromptId] = [...events, event];
|
|
104
108
|
await config.writeJson(path, data, { writer: 'scheduler' });
|
|
105
109
|
broadcast(EVENT_APPENDED_CHANNEL, { cwd, promptSessionId: sourcePromptId, event });
|
package/src/preload/api.d.ts
CHANGED
|
@@ -347,7 +347,7 @@ export interface MacroJobStatus {
|
|
|
347
347
|
finishedAt: string | null;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
/** One user-defined sidebar HOT KEYS macro (macroLibrary.cjs). `projects` = absolute cwds or `'*'` (every project). */
|
|
350
|
+
/** One user-defined sidebar HOT KEYS macro (macroLibrary.cjs). `projects` = absolute cwds or `'*'` (every project); a surface `'project-home'` macro is always `['*']` (only its generated artifacts are per project). */
|
|
351
351
|
export interface Macro {
|
|
352
352
|
id: string;
|
|
353
353
|
label: string;
|
|
@@ -2848,6 +2848,8 @@ export interface PromptSessionEventAppendedPayload {
|
|
|
2848
2848
|
at: string;
|
|
2849
2849
|
prdSlug?: string;
|
|
2850
2850
|
text?: string;
|
|
2851
|
+
/** 'job-not-queued' = a macro's background build could not be queued for this Epic (macroJobIpc.cjs). */
|
|
2852
|
+
notice?: 'job-not-queued';
|
|
2851
2853
|
};
|
|
2852
2854
|
}
|
|
2853
2855
|
|