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
|
@@ -24,11 +24,11 @@ const crypto = require('node:crypto');
|
|
|
24
24
|
const path = require('node:path');
|
|
25
25
|
const { writeJsonAtomicSync, readJsonOrSync } = require('../util/atomicFs.cjs');
|
|
26
26
|
const { schedulerHome } = require('../scheduler/schedulerPaths.cjs');
|
|
27
|
+
const { isCommitHash, MAX_COMMITS } = require('./replyClaims.cjs');
|
|
27
28
|
|
|
28
29
|
const STORE_VERSION = 1;
|
|
29
30
|
const FILE_NAME = 'pending-replies.json';
|
|
30
31
|
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
31
|
-
const COMMIT_RE = /^[0-9a-f]{7,40}$/;
|
|
32
32
|
/** Failed delivery attempts (one per hourly pass) before an entry gives up for good. */
|
|
33
33
|
const MAX_DELIVERY_ATTEMPTS = 24;
|
|
34
34
|
|
|
@@ -82,14 +82,18 @@ function normalizeYSource(v) {
|
|
|
82
82
|
try { return JSON.parse(JSON.stringify(v)); } catch { return null; }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Lowercased, de-duplicated commit hashes (replyClaims.isCommitHash), at most
|
|
87
|
+
* MAX_COMMITS; invalid entries are dropped (the route already validated). [] when none.
|
|
88
|
+
*/
|
|
86
89
|
function normalizeCommits(v) {
|
|
87
90
|
if (!Array.isArray(v)) return [];
|
|
88
91
|
const out = [];
|
|
89
92
|
for (const c of v) {
|
|
90
|
-
if (
|
|
93
|
+
if (out.length === MAX_COMMITS) break;
|
|
94
|
+
if (!isCommitHash(c)) continue;
|
|
91
95
|
const lc = c.toLowerCase();
|
|
92
|
-
if (
|
|
96
|
+
if (!out.includes(lc)) out.push(lc);
|
|
93
97
|
}
|
|
94
98
|
return out;
|
|
95
99
|
}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* projectCreate.cjs — the logic behind the project_create tool: create a new
|
|
6
|
+
* local project folder for a paired service (and optionally a private GitHub
|
|
7
|
+
* repo for it), so the service can open a Build Epic in it.
|
|
8
|
+
*
|
|
9
|
+
* createServiceProject(input, deps):
|
|
10
|
+
* 1. validates everything before touching disk — any refusal creates nothing;
|
|
11
|
+
* 2. under one module-level queue: answers a repeat (same fromCwd +
|
|
12
|
+
* externalRef) with the recorded folder, else mkdirs <parentDir>/<name>
|
|
13
|
+
* (non-recursive, via createProjectFolder), runs `git init` on main with
|
|
14
|
+
* one empty commit (so Epic worktrees can fork), creates the bare
|
|
15
|
+
* operations root (so feedback_open_session accepts it as toCwd) and
|
|
16
|
+
* records it in the created-projects ledger;
|
|
17
|
+
* 3. optionally runs `gh repo create <login>/<name> --private` with the new
|
|
18
|
+
* folder as source and origin. A GitHub failure keeps the local project.
|
|
19
|
+
*
|
|
20
|
+
* Never throws; returns a result object. Never uses a shell.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const fs = require('node:fs');
|
|
24
|
+
const path = require('node:path');
|
|
25
|
+
const { execFile } = require('node:child_process');
|
|
26
|
+
const { createProjectFolder, validateProjectName } = require('../projectFolder.cjs');
|
|
27
|
+
const { normalizeExternalRef } = require('../epic/externalRef.cjs');
|
|
28
|
+
const { OPS_ROOT_DIR } = require('../opsOwnership.cjs');
|
|
29
|
+
|
|
30
|
+
const SERVICE_PROJECT_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
31
|
+
const GH_TIMEOUT_MS = 60_000;
|
|
32
|
+
const GITHUB_REMOTE_RE = /github\.com[:/]([A-Za-z0-9._-]+)\/([A-Za-z0-9._-]+?)(?:\.git)?\/?$/;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {{ fullName: string, url: string, private: true }} RepoInfo
|
|
36
|
+
* @typedef {import('./createdProjects.cjs').CreatedProjectsStore} Ledger
|
|
37
|
+
* @typedef {(cwd: string, args: string[], opts?: { timeout?: number, env?: Record<string, string> }) => Promise<string>} ExecGit
|
|
38
|
+
* @typedef {(args: string[], opts?: { cwd?: string }) => Promise<{ stdout: string, stderr?: string }>} ExecGh
|
|
39
|
+
* @typedef {{
|
|
40
|
+
* ledger?: Ledger,
|
|
41
|
+
* execGit?: ExecGit,
|
|
42
|
+
* execGh?: ExecGh,
|
|
43
|
+
* validatePath?: (abs: string) => string,
|
|
44
|
+
* appendAudit?: (kind: string, fields: Record<string, unknown>) => void,
|
|
45
|
+
* }} Deps
|
|
46
|
+
* @typedef {{
|
|
47
|
+
* name?: unknown,
|
|
48
|
+
* parentDir?: unknown,
|
|
49
|
+
* fromCwd?: unknown,
|
|
50
|
+
* externalRef?: unknown,
|
|
51
|
+
* github?: unknown,
|
|
52
|
+
* }} Input
|
|
53
|
+
* @typedef {{ ok: false, status: number, code: string, error: string }} Refusal
|
|
54
|
+
* @typedef {{
|
|
55
|
+
* ok: true,
|
|
56
|
+
* status: 'created' | 'existing',
|
|
57
|
+
* existing?: true,
|
|
58
|
+
* cwd: string,
|
|
59
|
+
* name: string,
|
|
60
|
+
* externalRef: string,
|
|
61
|
+
* repo: RepoInfo | null,
|
|
62
|
+
* github?: { ok: false, error: string },
|
|
63
|
+
* }} Success
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/** @type {ExecGh} */
|
|
67
|
+
function defaultExecGh(args, opts = {}) {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
execFile('gh', args, {
|
|
70
|
+
cwd: opts.cwd,
|
|
71
|
+
timeout: GH_TIMEOUT_MS,
|
|
72
|
+
windowsHide: true,
|
|
73
|
+
encoding: 'utf8',
|
|
74
|
+
}, (err, stdout, stderr) => {
|
|
75
|
+
if (err) {
|
|
76
|
+
reject(Object.assign(err, { stderrText: stderr }));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
resolve({ stdout: stdout || '', stderr: stderr || '' });
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {Deps} deps
|
|
86
|
+
* @returns {Required<Deps>}
|
|
87
|
+
*/
|
|
88
|
+
function resolveDeps(deps) {
|
|
89
|
+
return {
|
|
90
|
+
ledger: deps.ledger || require('./createdProjects.cjs').getCreatedProjects(),
|
|
91
|
+
execGit: deps.execGit || require('../git/gitExec.cjs').execGit,
|
|
92
|
+
execGh: deps.execGh || defaultExecGh,
|
|
93
|
+
validatePath: deps.validatePath || ((abs) => require('../../config.cjs').validatePath(abs)),
|
|
94
|
+
appendAudit: deps.appendAudit || ((kind, fields) => {
|
|
95
|
+
require('../telemetry/auditLog.cjs').appendAuditEvent(kind, fields);
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {number} status
|
|
102
|
+
* @param {string} code
|
|
103
|
+
* @param {string} error
|
|
104
|
+
* @returns {Refusal}
|
|
105
|
+
*/
|
|
106
|
+
function refuse(status, code, error) {
|
|
107
|
+
return { ok: false, status, code, error };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @param {unknown} err
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
function errText(err) {
|
|
115
|
+
const e = err && typeof err === 'object' ? /** @type {{ stderrText?: unknown, message?: unknown }} */ (err) : null;
|
|
116
|
+
const stderr = e && typeof e.stderrText === 'string' ? e.stderrText.trim() : '';
|
|
117
|
+
if (stderr) return stderr;
|
|
118
|
+
return (e && typeof e.message === 'string' && e.message) || String(err);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* undefined/false = no repo; true = {}; an object may carry owner + private.
|
|
123
|
+
* @param {unknown} github
|
|
124
|
+
* @returns {{ ok: true, value: { owner?: string } | null } | { ok: false, error: string }}
|
|
125
|
+
*/
|
|
126
|
+
function normalizeGithub(github) {
|
|
127
|
+
if (github === undefined || github === null || github === false) return { ok: true, value: null };
|
|
128
|
+
if (github === true) return { ok: true, value: {} };
|
|
129
|
+
if (typeof github !== 'object' || Array.isArray(github)) {
|
|
130
|
+
return { ok: false, error: 'github must be true, false or { owner?, private? }.' };
|
|
131
|
+
}
|
|
132
|
+
const g = /** @type {Record<string, unknown>} */ (github);
|
|
133
|
+
if (g.private === false) return { ok: false, error: 'Only private GitHub repositories can be created.' };
|
|
134
|
+
if (g.private !== undefined && g.private !== true) {
|
|
135
|
+
return { ok: false, error: 'github.private must be true when given.' };
|
|
136
|
+
}
|
|
137
|
+
if (g.owner !== undefined && (typeof g.owner !== 'string' || !g.owner.trim())) {
|
|
138
|
+
return { ok: false, error: 'github.owner must be a non-empty string when given.' };
|
|
139
|
+
}
|
|
140
|
+
return { ok: true, value: typeof g.owner === 'string' ? { owner: g.owner.trim() } : {} };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {string} url
|
|
145
|
+
* @returns {RepoInfo | null}
|
|
146
|
+
*/
|
|
147
|
+
function parseGithubRemote(url) {
|
|
148
|
+
const m = GITHUB_REMOTE_RE.exec(String(url || '').trim());
|
|
149
|
+
if (!m) return null;
|
|
150
|
+
const fullName = `${m[1]}/${m[2]}`;
|
|
151
|
+
return { fullName, url: `https://github.com/${fullName}`, private: true };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @param {ExecGit} execGit
|
|
156
|
+
* @param {string} cwd
|
|
157
|
+
* @returns {Promise<string | null>}
|
|
158
|
+
*/
|
|
159
|
+
async function readOrigin(execGit, cwd) {
|
|
160
|
+
try {
|
|
161
|
+
const out = (await execGit(cwd, ['remote', 'get-url', 'origin'])).trim();
|
|
162
|
+
return out || null;
|
|
163
|
+
} catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Create the private repo, wire it as origin, record it.
|
|
170
|
+
* @param {Required<Deps>} d
|
|
171
|
+
* @param {string} cwd
|
|
172
|
+
* @param {string} login
|
|
173
|
+
* @param {string} name
|
|
174
|
+
* @returns {Promise<{ ok: true, repo: RepoInfo } | { ok: false, error: string }>}
|
|
175
|
+
*/
|
|
176
|
+
async function runGithubStep(d, cwd, login, name) {
|
|
177
|
+
try {
|
|
178
|
+
await d.execGh(
|
|
179
|
+
['repo', 'create', `${login}/${name}`, '--private', `--source=${cwd}`, '--remote=origin', '--push'],
|
|
180
|
+
{ cwd },
|
|
181
|
+
);
|
|
182
|
+
} catch (err) {
|
|
183
|
+
return { ok: false, error: `gh repo create failed: ${errText(err)}` };
|
|
184
|
+
}
|
|
185
|
+
const origin = await readOrigin(d.execGit, cwd);
|
|
186
|
+
const repo = origin ? parseGithubRemote(origin) : null;
|
|
187
|
+
if (!repo) return { ok: false, error: `origin is not a GitHub remote after gh repo create: ${origin || '(unset)'}` };
|
|
188
|
+
try {
|
|
189
|
+
await d.ledger.setRepo(cwd, repo.url);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
return { ok: false, error: `could not record the repo: ${errText(err)}` };
|
|
192
|
+
}
|
|
193
|
+
return { ok: true, repo };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** @param {unknown} err */
|
|
197
|
+
function isIdentityError(err) {
|
|
198
|
+
const t = errText(err);
|
|
199
|
+
return /tell me who you are|user\.email|user\.name|empty ident|unable to auto-detect email/i.test(t);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** @type {Promise<unknown>} */
|
|
203
|
+
let queue = Promise.resolve();
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @template T
|
|
207
|
+
* @param {() => Promise<T>} fn
|
|
208
|
+
* @returns {Promise<T>}
|
|
209
|
+
*/
|
|
210
|
+
function serialize(fn) {
|
|
211
|
+
const run = queue.then(fn);
|
|
212
|
+
queue = run.catch(() => {});
|
|
213
|
+
return run;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @param {Input} input
|
|
218
|
+
* @param {Deps} [deps]
|
|
219
|
+
* @returns {Promise<Success | Refusal>}
|
|
220
|
+
*/
|
|
221
|
+
async function createServiceProject(input, deps = {}) {
|
|
222
|
+
const d = resolveDeps(deps || {});
|
|
223
|
+
const { name, parentDir, fromCwd, externalRef, github } = input && typeof input === 'object' ? input : /** @type {Input} */ ({});
|
|
224
|
+
|
|
225
|
+
const ref = normalizeExternalRef(externalRef);
|
|
226
|
+
if (!ref.ok) return refuse(400, 'invalid-ref', ref.error);
|
|
227
|
+
if (!ref.value) return refuse(400, 'invalid-ref', 'externalRef is required.');
|
|
228
|
+
const refValue = ref.value;
|
|
229
|
+
|
|
230
|
+
if (typeof fromCwd !== 'string' || !path.isAbsolute(fromCwd) || fromCwd.includes('\0')) {
|
|
231
|
+
return refuse(400, 'invalid-ref', 'fromCwd must be an absolute path.');
|
|
232
|
+
}
|
|
233
|
+
const from = path.resolve(fromCwd);
|
|
234
|
+
|
|
235
|
+
if (typeof parentDir !== 'string' || !path.isAbsolute(parentDir) || parentDir.includes('\0')) {
|
|
236
|
+
return refuse(400, 'invalid-parent', 'parentDir must be an absolute path.');
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
d.validatePath(parentDir);
|
|
240
|
+
} catch (err) {
|
|
241
|
+
return refuse(400, 'invalid-parent', errText(err));
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
if (!fs.statSync(parentDir).isDirectory()) {
|
|
245
|
+
return refuse(400, 'invalid-parent', `${parentDir} is not a folder.`);
|
|
246
|
+
}
|
|
247
|
+
} catch {
|
|
248
|
+
return refuse(400, 'invalid-parent', `Parent folder ${parentDir} does not exist.`);
|
|
249
|
+
}
|
|
250
|
+
const parent = path.resolve(parentDir);
|
|
251
|
+
|
|
252
|
+
const v = validateProjectName(name);
|
|
253
|
+
if (!v.ok) return refuse(400, 'invalid-name', v.error);
|
|
254
|
+
if (v.name !== name || !SERVICE_PROJECT_NAME_RE.test(v.name)) {
|
|
255
|
+
return refuse(400, 'invalid-name', 'Project name must be 1 to 100 letters, digits or . _ - and start with a letter or digit.');
|
|
256
|
+
}
|
|
257
|
+
if (/\.git$/i.test(v.name)) return refuse(400, 'invalid-name', 'Project name cannot end in ".git".');
|
|
258
|
+
const projectName = v.name;
|
|
259
|
+
|
|
260
|
+
const g = normalizeGithub(github);
|
|
261
|
+
if (!g.ok) return refuse(400, 'invalid-github', g.error);
|
|
262
|
+
/** @type {string | null} */
|
|
263
|
+
let login = null;
|
|
264
|
+
if (g.value) {
|
|
265
|
+
try {
|
|
266
|
+
const { stdout } = await d.execGh(['api', 'user', '--jq', '.login']);
|
|
267
|
+
login = String(stdout || '').trim();
|
|
268
|
+
} catch (err) {
|
|
269
|
+
return refuse(400, 'gh-unavailable', `gh is not available or not signed in: ${errText(err)}`);
|
|
270
|
+
}
|
|
271
|
+
if (!login) return refuse(400, 'gh-unavailable', 'gh api user returned no login.');
|
|
272
|
+
if (g.value.owner && g.value.owner.toLowerCase() !== login.toLowerCase()) {
|
|
273
|
+
return refuse(403, 'gh-owner', `github.owner ${g.value.owner} is not the signed-in gh account.`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return serialize(async () => {
|
|
278
|
+
const recorded = d.ledger.findByRef(from, refValue);
|
|
279
|
+
if (recorded) return answerExisting(d, recorded.cwd, refValue, login);
|
|
280
|
+
|
|
281
|
+
const made = await createProjectFolder({ parentDir: parent, name: projectName });
|
|
282
|
+
if (!made.ok) {
|
|
283
|
+
if (made.code === 'exists') return refuse(409, 'exists', made.error);
|
|
284
|
+
if (made.code === 'invalid-name') return refuse(400, 'invalid-name', made.error);
|
|
285
|
+
if (made.code === 'invalid-parent') return refuse(400, 'invalid-parent', made.error);
|
|
286
|
+
return refuse(500, 'io', made.error);
|
|
287
|
+
}
|
|
288
|
+
const cwd = made.path;
|
|
289
|
+
|
|
290
|
+
/** @param {string} msg */
|
|
291
|
+
const rollback = async (msg) => {
|
|
292
|
+
try { await fs.promises.rm(cwd, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
293
|
+
return refuse(500, 'io', msg);
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
try {
|
|
297
|
+
await d.execGit(cwd, ['init', '--initial-branch=main']);
|
|
298
|
+
} catch (err) {
|
|
299
|
+
return rollback(`git init failed: ${errText(err)}`);
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
await d.execGit(cwd, ['commit', '--allow-empty', '-m', 'Initial commit']);
|
|
303
|
+
} catch (err) {
|
|
304
|
+
const hint = isIdentityError(err)
|
|
305
|
+
? ' Set git user.name and user.email (git config --global user.name / user.email) and retry.'
|
|
306
|
+
: '';
|
|
307
|
+
return rollback(`git commit failed: ${errText(err)}.${hint}`);
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
await fs.promises.mkdir(path.join(cwd, OPS_ROOT_DIR));
|
|
311
|
+
} catch (err) {
|
|
312
|
+
return rollback(`could not create ${OPS_ROOT_DIR}/: ${errText(err)}`);
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
await d.ledger.record({ cwd, fromCwd: from, externalRef: refValue, repo: null });
|
|
316
|
+
} catch (err) {
|
|
317
|
+
return rollback(`could not record the project: ${errText(err)}`);
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
d.appendAudit('project_created', { cwd, fromCwd: from, externalRef: refValue, repo: null });
|
|
321
|
+
} catch { /* best effort */ }
|
|
322
|
+
|
|
323
|
+
/** @type {Success} */
|
|
324
|
+
const answer = { ok: true, status: 'created', cwd, name: projectName, externalRef: refValue, repo: null };
|
|
325
|
+
if (login) {
|
|
326
|
+
const gh = await runGithubStep(d, cwd, login, projectName);
|
|
327
|
+
if (gh.ok) answer.repo = gh.repo;
|
|
328
|
+
else answer.github = { ok: false, error: gh.error };
|
|
329
|
+
}
|
|
330
|
+
return answer;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @param {Required<Deps>} d
|
|
336
|
+
* @param {string} cwd
|
|
337
|
+
* @param {string} externalRef
|
|
338
|
+
* @param {string | null} login
|
|
339
|
+
* @returns {Promise<Success | Refusal>}
|
|
340
|
+
*/
|
|
341
|
+
async function answerExisting(d, cwd, externalRef, login) {
|
|
342
|
+
let present = false;
|
|
343
|
+
try { present = fs.statSync(cwd).isDirectory(); } catch { present = false; }
|
|
344
|
+
if (!present) return refuse(409, 'gone', `The project created for ${externalRef} no longer exists at ${cwd}.`);
|
|
345
|
+
const name = path.basename(cwd);
|
|
346
|
+
const origin = await readOrigin(d.execGit, cwd);
|
|
347
|
+
/** @type {Success} */
|
|
348
|
+
const answer = {
|
|
349
|
+
ok: true,
|
|
350
|
+
status: 'existing',
|
|
351
|
+
existing: true,
|
|
352
|
+
cwd,
|
|
353
|
+
name,
|
|
354
|
+
externalRef,
|
|
355
|
+
repo: origin ? parseGithubRemote(origin) : null,
|
|
356
|
+
};
|
|
357
|
+
if (login && !origin) {
|
|
358
|
+
const gh = await runGithubStep(d, cwd, login, name);
|
|
359
|
+
if (gh.ok) answer.repo = gh.repo;
|
|
360
|
+
else answer.github = { ok: false, error: gh.error };
|
|
361
|
+
}
|
|
362
|
+
return answer;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Tell every renderer window a project was freshly created, so the app can
|
|
367
|
+
* open it as a dormant tab. Electron is required lazily so unit tests never
|
|
368
|
+
* need it. Never throws. Mirrors crossProjectFeedback.cjs defaultNotifyRenderer.
|
|
369
|
+
* @param {{ cwd: string }} payload
|
|
370
|
+
*/
|
|
371
|
+
function defaultNotifyRenderer(payload) {
|
|
372
|
+
try {
|
|
373
|
+
const { BrowserWindow } = require('electron');
|
|
374
|
+
const { sendIfAlive } = require('../sendToRenderer.cjs');
|
|
375
|
+
for (const win of BrowserWindow.getAllWindows()) {
|
|
376
|
+
try {
|
|
377
|
+
sendIfAlive(win, 'projects:created', payload);
|
|
378
|
+
} catch { /* window going away */ }
|
|
379
|
+
}
|
|
380
|
+
} catch { /* not running under Electron */ }
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @typedef {{
|
|
385
|
+
* registerRoute: (method: string, path: string, handler: (req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse) => Promise<void>) => void,
|
|
386
|
+
* }} AdminHttp
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Registers POST /admin/projects/create on the injected loopback admin
|
|
391
|
+
* transport (auth is the transport's job). Only a fresh create notifies.
|
|
392
|
+
* @param {AdminHttp} adminHttp
|
|
393
|
+
* @param {{ notify?: (payload: { cwd: string }) => void, deps?: Deps }} [opts]
|
|
394
|
+
*/
|
|
395
|
+
function registerAdminRoute(adminHttp, { notify = defaultNotifyRenderer, deps } = {}) {
|
|
396
|
+
const { readBody, sendJson } = require('./localAdminHttp.cjs');
|
|
397
|
+
adminHttp.registerRoute('POST', '/admin/projects/create', async (req, res) => {
|
|
398
|
+
const raw = await readBody(req);
|
|
399
|
+
/** @type {Input} */
|
|
400
|
+
let parsed;
|
|
401
|
+
try {
|
|
402
|
+
parsed = raw ? JSON.parse(raw) : {};
|
|
403
|
+
} catch {
|
|
404
|
+
sendJson(res, 400, { ok: false, error: 'invalid JSON body' });
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const result = await createServiceProject(parsed, deps);
|
|
408
|
+
if (result.ok && result.status === 'created') {
|
|
409
|
+
try { notify({ cwd: result.cwd }); } catch { /* a notify failure never fails the create */ }
|
|
410
|
+
}
|
|
411
|
+
sendJson(res, result.ok ? 200 : result.status, result);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
module.exports = { createServiceProject, SERVICE_PROJECT_NAME_RE, parseGithubRemote, registerAdminRoute, defaultNotifyRenderer };
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Used by crossProjectReply.cjs (the app route) and
|
|
6
6
|
* scripts/scheduler-mcp-server.cjs (the MCP server), so it must load outside
|
|
7
|
-
* Electron: requires only node built-ins
|
|
7
|
+
* Electron: requires only node built-ins, ../util/atomicFs.cjs and
|
|
8
|
+
* ../git/gitExec.cjs.
|
|
8
9
|
*
|
|
9
10
|
* - findUnfilledPlaceholders: version-ish template tokens left in a message
|
|
10
11
|
* ('{version}', '{{appVersion}}', '${release}', '<semver>', ...).
|
|
@@ -16,14 +17,19 @@
|
|
|
16
17
|
*/
|
|
17
18
|
'use strict';
|
|
18
19
|
|
|
19
|
-
const fs = require('node:fs');
|
|
20
20
|
const path = require('node:path');
|
|
21
|
+
const { readJsonOrSync } = require('../util/atomicFs.cjs');
|
|
21
22
|
|
|
22
23
|
const SM_PACKAGE_NAME = 'claude-code-session-manager';
|
|
23
24
|
const VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
24
25
|
const COMMIT_RE = /^[0-9a-f]{7,40}$/i;
|
|
25
26
|
const MAX_COMMITS = 20;
|
|
26
27
|
|
|
28
|
+
/** True only for a string of 7-40 hex chars (either case) — the one commit-hash rule. */
|
|
29
|
+
function isCommitHash(v) {
|
|
30
|
+
return typeof v === 'string' && COMMIT_RE.test(v);
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
const PLACEHOLDER_NAMES = [
|
|
28
34
|
'version', 'appversion', 'app_version', 'app-version', 'release',
|
|
29
35
|
'releaseversion', 'release_version', 'smversion', 'sm_version', 'semver',
|
|
@@ -88,7 +94,7 @@ function normalizeReleaseClaim(raw) {
|
|
|
88
94
|
}
|
|
89
95
|
const out = [];
|
|
90
96
|
for (const c of commits) {
|
|
91
|
-
if (
|
|
97
|
+
if (!isCommitHash(c)) {
|
|
92
98
|
return fail(`release.commits has an invalid commit hash: ${JSON.stringify(c)}`);
|
|
93
99
|
}
|
|
94
100
|
const lc = c.toLowerCase();
|
|
@@ -98,13 +104,14 @@ function normalizeReleaseClaim(raw) {
|
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
function isSessionManagerRepo(cwd) {
|
|
107
|
+
if (typeof cwd !== 'string' || !cwd) return false;
|
|
108
|
+
let pkg;
|
|
101
109
|
try {
|
|
102
|
-
|
|
103
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
104
|
-
return !!pkg && typeof pkg === 'object' && pkg.name === SM_PACKAGE_NAME;
|
|
110
|
+
pkg = readJsonOrSync(path.join(cwd, 'package.json'), null);
|
|
105
111
|
} catch {
|
|
106
112
|
return false;
|
|
107
113
|
}
|
|
114
|
+
return !!pkg && typeof pkg === 'object' && !Array.isArray(pkg) && pkg.name === SM_PACKAGE_NAME;
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
function defaultRunGit(cwd, args) {
|
|
@@ -156,4 +163,6 @@ module.exports = {
|
|
|
156
163
|
normalizeReleaseClaim,
|
|
157
164
|
isSessionManagerRepo,
|
|
158
165
|
checkReleaseContains,
|
|
166
|
+
isCommitHash,
|
|
167
|
+
MAX_COMMITS,
|
|
159
168
|
};
|
|
@@ -25,16 +25,23 @@
|
|
|
25
25
|
* in another project; events_read keeps epic_state_changed rows only for a
|
|
26
26
|
* ledger (cwd, epicId) and epic_cross_project_reply rows only for a ledger
|
|
27
27
|
* (fromCwd, fromEpicId).
|
|
28
|
+
* - project_create is pinned to the pairing's owner-approved projects folder:
|
|
29
|
+
* no service.projectRoot -> refused (403, 'refused:projectRoot'); a given
|
|
30
|
+
* parentDir that does not path.resolve() to projectRoot -> refused (403,
|
|
31
|
+
* 'refused:parentDir'); otherwise the route gets parentDir = projectRoot and
|
|
32
|
+
* fromCwd = service.homeCwd (a caller's fromCwd is overwritten).
|
|
28
33
|
*
|
|
29
34
|
* response is null for a notification (no id). audit is null for anything but
|
|
30
35
|
* tools/call, else { tool, result } (result: 'ok' | 'error:<status>' |
|
|
31
|
-
* 'refused:scope' | 'refused:fromCwd' | 'refused:ledger' |
|
|
36
|
+
* 'refused:scope' | 'refused:fromCwd' | 'refused:ledger' |
|
|
37
|
+
* 'refused:projectRoot' | 'refused:parentDir' | 'error:invalid-params'
|
|
32
38
|
* | 'error:invoke').
|
|
33
39
|
*
|
|
34
40
|
* No Electron, no I/O of its own.
|
|
35
41
|
*/
|
|
36
42
|
'use strict';
|
|
37
43
|
|
|
44
|
+
const path = require('node:path');
|
|
38
45
|
const { SERVICE_TOOLS, EVENTS_READ_KINDS } = require('./serviceMcpTools.cjs');
|
|
39
46
|
const { SUPPORTED_PROTOCOL_VERSIONS } = require('../mcpStdioServer.cjs');
|
|
40
47
|
|
|
@@ -83,8 +90,10 @@ function isOk(answer) {
|
|
|
83
90
|
return answer.status >= 200 && answer.status < 300 && answer.json?.ok === true;
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
async function callInvoke(invoke, req) {
|
|
87
|
-
const
|
|
93
|
+
async function callInvoke(invoke, req, trustedService) {
|
|
94
|
+
const opts = { body: req.body, query: req.query };
|
|
95
|
+
if (trustedService) opts.trustedService = trustedService;
|
|
96
|
+
const answer = await invoke(req.method, req.path, opts);
|
|
88
97
|
return { status: Number(answer?.status) || 500, json: answer?.json ?? null };
|
|
89
98
|
}
|
|
90
99
|
|
|
@@ -125,7 +134,8 @@ async function runTool(tool, args, { service, invoke, store }) {
|
|
|
125
134
|
};
|
|
126
135
|
}
|
|
127
136
|
if (pinned.replyMode === undefined || pinned.replyMode === null) pinned.replyMode = 'event';
|
|
128
|
-
|
|
137
|
+
// The service id rides the invoke option (in-process only), never the body.
|
|
138
|
+
const answer = await callInvoke(invoke, tool.toRequest(pinned), { serviceId: service.serviceId });
|
|
129
139
|
const ledgerError = await recordEpic(store, service, answer, pinned.toCwd, pinned.externalRef);
|
|
130
140
|
return { answer, result: isOk(answer) ? 'ok' : `error:${answer.status}`, ledgerError };
|
|
131
141
|
}
|
|
@@ -160,6 +170,27 @@ async function runTool(tool, args, { service, invoke, store }) {
|
|
|
160
170
|
}
|
|
161
171
|
return { answer, result: isOk(answer) ? 'ok' : `error:${answer.status}` };
|
|
162
172
|
}
|
|
173
|
+
case 'project_create': {
|
|
174
|
+
const projectRoot = typeof service.projectRoot === 'string' && service.projectRoot !== '' ? service.projectRoot : null;
|
|
175
|
+
if (projectRoot === null) {
|
|
176
|
+
return {
|
|
177
|
+
answer: { status: 403, json: { ok: false, error: 'this pairing has no approved projects folder; re-pair to grant project_create' } },
|
|
178
|
+
result: 'refused:projectRoot',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const given = args.parentDir;
|
|
182
|
+
if (given !== undefined && given !== null && given !== ''
|
|
183
|
+
&& (typeof given !== 'string' || given.includes('\0') || path.resolve(given) !== projectRoot)) {
|
|
184
|
+
return {
|
|
185
|
+
answer: { status: 403, json: { ok: false, error: 'parentDir must be the projects folder approved at pairing', projectRoot } },
|
|
186
|
+
result: 'refused:parentDir',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const req = tool.toRequest({ ...args, parentDir: projectRoot });
|
|
190
|
+
req.body = { ...req.body, parentDir: projectRoot, fromCwd: service.homeCwd };
|
|
191
|
+
const answer = await callInvoke(invoke, req);
|
|
192
|
+
return { answer, result: isOk(answer) ? 'ok' : `error:${answer.status}` };
|
|
193
|
+
}
|
|
163
194
|
default: {
|
|
164
195
|
const answer = await callInvoke(invoke, tool.toRequest(args));
|
|
165
196
|
return { answer, result: isOk(answer) ? 'ok' : `error:${answer.status}` };
|
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
* macro_run({ cwd, id, inputs?, effort?, externalRef? }) -> POST /admin/macros/run
|
|
11
11
|
* epic_get({ cwd, id | externalRef, receipt? }) -> GET /admin/epic?cwd=&id=|externalRef=&receipt=1
|
|
12
12
|
* events_read({ after?, kinds?, limit? }) -> GET /admin/events?after=&kinds=&limit=
|
|
13
|
+
* project_create({ name, externalRef, github?, parentDir? }) -> POST /admin/projects/create
|
|
13
14
|
*
|
|
14
15
|
* The four tools the stdio server (scripts/scheduler-mcp-server.cjs) also
|
|
15
16
|
* serves share their inputSchema OBJECTS with it — that server imports them
|
|
16
17
|
* from here, so a service and a local agent see the same names and schemas.
|
|
17
18
|
* Their descriptions come from mcpToolCatalog.cjs via composeDescription.
|
|
18
19
|
*
|
|
19
|
-
* macro_run and
|
|
20
|
+
* macro_run, events_read and project_create are SERVICE-ONLY in v1: they are not catalog
|
|
20
21
|
* entries (the external-contract fingerprint stays put) and the stdio server
|
|
21
22
|
* never registers them — a local agent keeps no Epic-starting tool
|
|
22
23
|
* (SINGLE-CREATOR law). No inputSchema uses a top-level oneOf/anyOf (the
|
|
@@ -166,6 +167,31 @@ const EVENTS_READ_INPUT_SCHEMA = {
|
|
|
166
167
|
},
|
|
167
168
|
};
|
|
168
169
|
|
|
170
|
+
const PROJECT_CREATE_INPUT_SCHEMA = {
|
|
171
|
+
type: 'object',
|
|
172
|
+
properties: {
|
|
173
|
+
name: { type: 'string', description: 'Folder name of the new project (becomes <projects folder>/<name>).' },
|
|
174
|
+
externalRef: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
description: 'Your own id for this project. A repeat call with the same externalRef creates nothing new and answers status existing.',
|
|
177
|
+
},
|
|
178
|
+
github: {
|
|
179
|
+
type: ['boolean', 'object'],
|
|
180
|
+
description: 'Optional: also create a GitHub repo and set it as origin. Pass true (create the repo with defaults), '
|
|
181
|
+
+ 'false (no repo, same as omitting it), or { private: true, owner? } (create it private, optionally under a given owner).',
|
|
182
|
+
properties: {
|
|
183
|
+
private: { type: 'boolean', description: 'Create the repo private (true).' },
|
|
184
|
+
owner: { type: 'string', description: 'Optional: GitHub user or org to own the repo; defaults to the signed-in account.' },
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
parentDir: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
description: 'Optional: the projects folder. Only the folder the owner approved at pairing is accepted; omit it to use that folder.',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
required: ['name', 'externalRef'],
|
|
193
|
+
};
|
|
194
|
+
|
|
169
195
|
const CATALOG_BY_NAME = new Map(MCP_TOOL_CATALOG.map((entry) => [entry.name, entry]));
|
|
170
196
|
|
|
171
197
|
function catalogDescription(name) {
|
|
@@ -258,6 +284,20 @@ const SERVICE_TOOLS = Object.freeze([
|
|
|
258
284
|
return { method: 'GET', path: '/admin/events', query };
|
|
259
285
|
},
|
|
260
286
|
},
|
|
287
|
+
{
|
|
288
|
+
name: 'project_create',
|
|
289
|
+
description: 'Create a new project folder in the projects folder the owner approved at pairing: git with one empty '
|
|
290
|
+
+ 'commit, the Session Manager operations root, and optionally a private GitHub repo (github: { private: true }) set '
|
|
291
|
+
+ 'as origin. Idempotent by externalRef: a repeat answers status existing with the same cwd and repo. Then open its '
|
|
292
|
+
+ 'first session with feedback_open_session (toCwd = cwd). Answer: { ok, status, cwd, name, externalRef, repo, github? }.',
|
|
293
|
+
inputSchema: PROJECT_CREATE_INPUT_SCHEMA,
|
|
294
|
+
toRequest: (args) => {
|
|
295
|
+
const body = { name: args?.name, externalRef: args?.externalRef };
|
|
296
|
+
if (args?.github !== undefined) body.github = args.github;
|
|
297
|
+
if (args?.parentDir !== undefined) body.parentDir = args.parentDir;
|
|
298
|
+
return { method: 'POST', path: '/admin/projects/create', body };
|
|
299
|
+
},
|
|
300
|
+
},
|
|
261
301
|
].map((tool) => Object.freeze(tool)));
|
|
262
302
|
|
|
263
303
|
// Fail at require time if the tool list and the pairing grant list drift.
|
|
@@ -269,7 +309,7 @@ const SERVICE_TOOLS = Object.freeze([
|
|
|
269
309
|
}
|
|
270
310
|
|
|
271
311
|
/** Names served only to a paired service, never by the local stdio server. */
|
|
272
|
-
const SERVICE_ONLY_TOOL_NAMES = Object.freeze(['macro_run', 'events_read']);
|
|
312
|
+
const SERVICE_ONLY_TOOL_NAMES = Object.freeze(['macro_run', 'events_read', 'project_create']);
|
|
273
313
|
|
|
274
314
|
module.exports = {
|
|
275
315
|
SERVICE_TOOLS,
|
|
@@ -281,4 +321,5 @@ module.exports = {
|
|
|
281
321
|
EPIC_GET_INPUT_SCHEMA,
|
|
282
322
|
MACRO_RUN_INPUT_SCHEMA,
|
|
283
323
|
EVENTS_READ_INPUT_SCHEMA,
|
|
324
|
+
PROJECT_CREATE_INPUT_SCHEMA,
|
|
284
325
|
};
|