copilot-operator 0.1.51 → 0.1.53
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 +24 -3
- package/dist/src/api/operator.controller.js +55 -71
- package/dist/src/api/operator.service.js +243 -109
- package/dist/src/config/schema.js +45 -0
- package/dist/src/exec/policy.js +11 -1
- package/dist/src/exec/scriptFiles.js +108 -2
- package/dist/src/orchestrator/leadRunner.js +605 -0
- package/dist/src/orchestrator/review.js +9 -3
- package/dist/src/orchestrator/taskRunner.js +110 -20
- package/dist/src/plan/kerrigan.js +203 -47
- package/dist/src/plan/systemGuide.js +555 -499
- package/dist/src/protocol/leadSchema.js +156 -0
- package/dist/src/protocol/parser.js +1 -1
- package/dist/src/session/chatNotice.js +115 -0
- package/dist/src/session/checkpoint.js +19 -0
- package/dist/src/session/compose.js +17 -5
- package/dist/src/session/store.js +21 -72
- package/dist/src/transport/copilotTransport.js +2 -0
- package/dist/src/util/pacing.js +33 -2
- package/dist/src/vcs/git.js +11 -1
- package/dist/src/vcs/referenceGuard.js +299 -0
- package/dist/web/404.html +14 -18
- package/dist/web/_next/static/FGzV3mVZpXRCVjiw1diNu/_buildManifest.js +1 -0
- package/dist/web/_next/static/chunks/163.980c5145848efbdf.js +1 -0
- package/dist/web/_next/static/chunks/220.447d1d8624d4644c.js +1 -0
- package/dist/web/_next/static/chunks/500-34d01f8d8d73eb2c.js +1 -0
- package/dist/web/_next/static/chunks/548.c6dfd1cb270f3c93.js +1 -0
- package/dist/web/_next/static/chunks/584.fc9e061dd4069406.js +1 -0
- package/dist/web/_next/static/chunks/67.1a3ca07919abce27.js +1 -0
- package/dist/web/_next/static/chunks/714.5b2e291a430adc9c.js +1 -0
- package/dist/web/_next/static/chunks/747.157732b5b3f3c435.js +1 -0
- package/dist/web/_next/static/chunks/77.d478a6f2eafe31e3.js +1 -0
- package/dist/web/_next/static/chunks/921-b2219533c5a6e38f.js +1 -0
- package/dist/web/_next/static/chunks/app/defaults/page-b7e4e94a55e65806.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-2b3718748721c1ac.js +1 -0
- package/dist/web/_next/static/chunks/app/page-59b9867b52914a6c.js +1 -0
- package/dist/web/_next/static/chunks/app/system/page-1cf9e75e76da59ed.js +1 -0
- package/dist/web/_next/static/chunks/webpack-0c3cad1f3181d857.js +1 -0
- package/dist/web/_next/static/css/06f314fa5fccd68d.css +1 -0
- package/dist/web/defaults.html +14 -18
- package/dist/web/defaults.txt +9 -9
- package/dist/web/index.html +14 -18
- package/dist/web/index.txt +9 -9
- package/dist/web/system.html +14 -18
- package/dist/web/system.txt +9 -9
- package/package.json +8 -5
- package/prompts/lead1.md +116 -0
- package/prompts/level1.md +32 -12
- package/prompts/review1.md +287 -286
- package/dist/src/vcs/prepareFromRemote.js +0 -288
- package/dist/src/vcs/remoteAuth.js +0 -117
- package/dist/src/vcs/syncCommand.js +0 -97
- package/dist/web/_next/static/chunks/190-70555f20dd0da19b.js +0 -1
- package/dist/web/_next/static/chunks/643-e85d221d57900ed7.js +0 -1
- package/dist/web/_next/static/chunks/867-869900ec999e6345.js +0 -1
- package/dist/web/_next/static/chunks/app/appearance/page-cdef33c421397cbe.js +0 -1
- package/dist/web/_next/static/chunks/app/defaults/page-e0a2b8f9a41a94c4.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-b4fc21e26e1bad95.js +0 -1
- package/dist/web/_next/static/chunks/app/level1/page-31b74cae86d960d8.js +0 -1
- package/dist/web/_next/static/chunks/app/page-1075921d44db3e4d.js +0 -1
- package/dist/web/_next/static/chunks/app/presets/page-f8abdd83cdf468f7.js +0 -1
- package/dist/web/_next/static/chunks/app/system/page-2a270bb885885821.js +0 -1
- package/dist/web/_next/static/chunks/webpack-0f31b926d9a9c5a4.js +0 -1
- package/dist/web/_next/static/css/8b14cb3cf0051138.css +0 -1
- package/dist/web/_next/static/eqTUTH_SJtBgNgq8Zzy3n/_buildManifest.js +0 -1
- package/dist/web/appearance.html +0 -18
- package/dist/web/appearance.txt +0 -25
- package/dist/web/level1.html +0 -18
- package/dist/web/level1.txt +0 -25
- package/dist/web/presets.html +0 -21
- package/dist/web/presets.txt +0 -25
- /package/dist/web/_next/static/{eqTUTH_SJtBgNgq8Zzy3n → FGzV3mVZpXRCVjiw1diNu}/_ssgManifest.js +0 -0
|
@@ -30,6 +30,15 @@ import { chatNotice } from '../session/chatNotice.js';
|
|
|
30
30
|
import { kerriganFileName, kerriganPersona } from '../plan/kerrigan.js';
|
|
31
31
|
import { workspaceCommit, workspaceGit, workspaceGitVersions } from '../session/workspaceGit.js';
|
|
32
32
|
import { chatCode } from '../transport/chatSession.js';
|
|
33
|
+
/** The folders the operator works in: the default new sessions start on, and the rest by name. */
|
|
34
|
+
/** The longest level 2 a project may have: Kerrigan carries each one whole. */
|
|
35
|
+
export const MAX_PROJECT_LEVEL2 = 8000;
|
|
36
|
+
/** Its instructions: as long as a project's level 2, the longest text the opening carries besides the task. */
|
|
37
|
+
export const MAX_SKILL_TEXT = 8000;
|
|
38
|
+
export const MAX_SKILL_DESCRIPTION = 300;
|
|
39
|
+
export const MAX_SKILLS = 50;
|
|
40
|
+
/** What follows `/` at the start of a message: lowercase letters, digits and hyphens, 2 to 40 of them. */
|
|
41
|
+
export const SKILL_NAME = /^[a-z0-9][a-z0-9-]{0,38}[a-z0-9]$/;
|
|
33
42
|
/**
|
|
34
43
|
* A settings file or a policy lock that cannot be used: answered 409 with its own message on every route
|
|
35
44
|
* (see `server.ts`), so a start passes it on rather than answering it as a start that did not happen.
|
|
@@ -58,8 +67,6 @@ import { assessIsolation, readIsolationSignals } from '../exec/isolation.js';
|
|
|
58
67
|
import { unattendedPrecondition } from '../exec/policy.js';
|
|
59
68
|
import { createTransport } from '../transport/chatTransport.js';
|
|
60
69
|
import { composeHandoff } from '../session/handoff.js';
|
|
61
|
-
import { planPrepare, prepareFromRemote } from '../vcs/prepareFromRemote.js';
|
|
62
|
-
import { askpassProgram } from '../vcs/remoteAuth.js';
|
|
63
70
|
import { appendRunLog, appendSessionLog, readRunLog } from '../session/runLog.js';
|
|
64
71
|
import { StartFailures, failureReport, refOf } from '../session/startFailure.js';
|
|
65
72
|
import { formatTerminal, localTime, terminalLines, terminalLogFile } from '../log/terminal.js';
|
|
@@ -129,6 +136,15 @@ let OperatorService = class OperatorService {
|
|
|
129
136
|
startFailures = new StartFailures();
|
|
130
137
|
running = new Map();
|
|
131
138
|
waiting = new Map();
|
|
139
|
+
/**
|
|
140
|
+
* The workers of the two-chat mode, by the session of the lead they work for (2026-10-20). A worker's steps and cards
|
|
141
|
+
* carry its own session's id, while the run, its mode and its Stop are the lead's: they are looked up through this.
|
|
142
|
+
*/
|
|
143
|
+
workerLeads = new Map();
|
|
144
|
+
/** The session whose run a session's steps belong to: its own, or its lead's for a worker. */
|
|
145
|
+
runKey(sessionId) {
|
|
146
|
+
return this.running.has(sessionId) ? sessionId : (this.workerLeads.get(sessionId) ?? sessionId);
|
|
147
|
+
}
|
|
132
148
|
ready = null;
|
|
133
149
|
/**
|
|
134
150
|
* What has the browser now: one session's run, a batch, or a read of the model list.
|
|
@@ -227,30 +243,6 @@ let OperatorService = class OperatorService {
|
|
|
227
243
|
await this.init();
|
|
228
244
|
return await this.store.getLevel1();
|
|
229
245
|
}
|
|
230
|
-
async setLevel1(content) {
|
|
231
|
-
await this.init();
|
|
232
|
-
await this.store.setLevel1(content);
|
|
233
|
-
}
|
|
234
|
-
async resetLevel1() {
|
|
235
|
-
await this.init();
|
|
236
|
-
await this.store.resetLevel1();
|
|
237
|
-
return await this.store.getLevel1();
|
|
238
|
-
}
|
|
239
|
-
// --- the organisation's part of the plan persona -------------------------------------
|
|
240
|
-
// --- level 2 presets ------------------------------------------------------------------
|
|
241
|
-
async listPresets() {
|
|
242
|
-
await this.init();
|
|
243
|
-
return await this.store.listPresets();
|
|
244
|
-
}
|
|
245
|
-
async savePreset(name, content) {
|
|
246
|
-
await this.init();
|
|
247
|
-
return await this.store.savePreset(name, content);
|
|
248
|
-
}
|
|
249
|
-
async deletePreset(name) {
|
|
250
|
-
await this.init();
|
|
251
|
-
await this.store.deletePreset(name);
|
|
252
|
-
}
|
|
253
|
-
// --- named personas for the import page -----------------------------------------------
|
|
254
246
|
// --- sessions and tasks ---------------------------------------------------------------
|
|
255
247
|
async listSessions() {
|
|
256
248
|
await this.init();
|
|
@@ -270,7 +262,7 @@ let OperatorService = class OperatorService {
|
|
|
270
262
|
if (patch.active !== undefined && this.running.has(id)) {
|
|
271
263
|
throw new Error('This session is running; its status can be changed once it has stopped.');
|
|
272
264
|
}
|
|
273
|
-
|
|
265
|
+
const updated = await this.store.updateSession(id, (s) => {
|
|
274
266
|
const before = { model: s.model, manualModel: s.manualModel };
|
|
275
267
|
if (patch.name !== undefined)
|
|
276
268
|
s.name = patch.name.trim() || s.name;
|
|
@@ -296,6 +288,12 @@ let OperatorService = class OperatorService {
|
|
|
296
288
|
if ((patch.model !== undefined || typeof patch.manualModel === 'boolean') && (s.model !== before.model || !!s.manualModel !== !!before.manualModel)) {
|
|
297
289
|
delete s.modelByHand;
|
|
298
290
|
}
|
|
291
|
+
// The worker's model (two chats), kept on the lead's session and given to its worker below.
|
|
292
|
+
if (s.lead && (patch.workerModel !== undefined || typeof patch.workerManualModel === 'boolean')) {
|
|
293
|
+
const manual = typeof patch.workerManualModel === 'boolean' ? patch.workerManualModel : !!s.lead.workerManualModel;
|
|
294
|
+
const model = patch.workerModel !== undefined ? patch.workerModel.trim() : (s.lead.workerModel ?? '');
|
|
295
|
+
s.lead = { ...s.lead, workerManualModel: manual || undefined, workerModel: manual ? undefined : model || undefined };
|
|
296
|
+
}
|
|
299
297
|
// The same for the group: clearing it gives this session its conversation back. It does
|
|
300
298
|
// not move the conversation it is already in; that history is where it is.
|
|
301
299
|
if (patch.conversationGroup !== undefined)
|
|
@@ -397,6 +395,19 @@ let OperatorService = class OperatorService {
|
|
|
397
395
|
s.vcs = merged;
|
|
398
396
|
}
|
|
399
397
|
});
|
|
398
|
+
// The worker's model (two chats): given to the worker's session too, which asks again for one chosen by hand.
|
|
399
|
+
const workerId = updated.lead?.workerSessionId;
|
|
400
|
+
if (workerId && (patch.workerModel !== undefined || typeof patch.workerManualModel === 'boolean')) {
|
|
401
|
+
await this.store
|
|
402
|
+
.updateSession(workerId, (w) => {
|
|
403
|
+
w.manualModel = updated.lead?.workerManualModel ? true : undefined;
|
|
404
|
+
w.model = updated.lead?.workerManualModel ? undefined : updated.lead?.workerModel;
|
|
405
|
+
w.modelSource = w.model ? 'operator' : undefined;
|
|
406
|
+
delete w.modelByHand;
|
|
407
|
+
})
|
|
408
|
+
.catch(() => undefined);
|
|
409
|
+
}
|
|
410
|
+
return updated;
|
|
400
411
|
}
|
|
401
412
|
/**
|
|
402
413
|
* A note to the chat about a task (2026-10-14): queued, running or waiting, it goes out with the task's
|
|
@@ -581,7 +592,7 @@ let OperatorService = class OperatorService {
|
|
|
581
592
|
if (tasks.length === 0)
|
|
582
593
|
return;
|
|
583
594
|
// Refused at its turn, nothing of it began: said as a start that could not happen, not as a stop.
|
|
584
|
-
await window.showNotice(chatNotice(s.lang
|
|
595
|
+
await window.showNotice(chatNotice(s.lang || 'en', tasks, tally.error ?? tally.refused)).catch(() => undefined);
|
|
585
596
|
}
|
|
586
597
|
/** The program is closing: so is the window the chat left open. */
|
|
587
598
|
async onModuleDestroy() {
|
|
@@ -785,6 +796,11 @@ let OperatorService = class OperatorService {
|
|
|
785
796
|
const startedAt = new Date().toISOString();
|
|
786
797
|
const hold = new Hold();
|
|
787
798
|
this.running.set(sessionId, { controller, startedAt, mode, policy, hold });
|
|
799
|
+
{
|
|
800
|
+
const asLead = await this.store.getSession(sessionId);
|
|
801
|
+
if (asLead?.lead?.workerSessionId)
|
|
802
|
+
this.workerLeads.set(asLead.lead.workerSessionId, sessionId);
|
|
803
|
+
}
|
|
788
804
|
this.bus.publish({ sessionId, type: 'run-requested', level: 'info', message: `starting in ${mode} mode` });
|
|
789
805
|
// Said at the start of every run, in both modes, because it is the one fact about this tool a
|
|
790
806
|
// data-protection team needs and the one an operator forgets: the reports leave the machine.
|
|
@@ -851,6 +867,9 @@ let OperatorService = class OperatorService {
|
|
|
851
867
|
},
|
|
852
868
|
// Plan mode `approve`: the plan is put to the operator on the approvals card.
|
|
853
869
|
approvePlan: (ask) => this.askPlanApproval(ask, controller.signal),
|
|
870
|
+
// The two-chat mode (2026-10-20): the lead's questions, and the worker the run speaks for too.
|
|
871
|
+
askQuestion: (ask) => this.askLeadQuestion(ask, controller.signal),
|
|
872
|
+
onWorker: (workerId) => this.workerLeads.set(workerId, sessionId),
|
|
854
873
|
hold,
|
|
855
874
|
})
|
|
856
875
|
.then(async (outcome) => {
|
|
@@ -876,13 +895,13 @@ let OperatorService = class OperatorService {
|
|
|
876
895
|
return tally;
|
|
877
896
|
})
|
|
878
897
|
.finally(() => {
|
|
879
|
-
this.running.delete(sessionId);
|
|
880
898
|
for (const [id, w] of this.waiting) {
|
|
881
|
-
if (w.approval.sessionId === sessionId) {
|
|
899
|
+
if (this.runKey(w.approval.sessionId) === sessionId) {
|
|
882
900
|
w.resolve({ action: 'abort', reason: 'the run ended' });
|
|
883
901
|
this.waiting.delete(id);
|
|
884
902
|
}
|
|
885
903
|
}
|
|
904
|
+
this.running.delete(sessionId);
|
|
886
905
|
});
|
|
887
906
|
return { started: true, done };
|
|
888
907
|
}
|
|
@@ -943,7 +962,7 @@ let OperatorService = class OperatorService {
|
|
|
943
962
|
return { stopping: false };
|
|
944
963
|
r.controller.abort();
|
|
945
964
|
for (const [id, w] of this.waiting) {
|
|
946
|
-
if (w.approval.sessionId === sessionId) {
|
|
965
|
+
if (this.runKey(w.approval.sessionId) === sessionId) {
|
|
947
966
|
w.resolve({ action: 'abort', reason: 'stopped by the operator', by: 'operator' });
|
|
948
967
|
this.waiting.delete(id);
|
|
949
968
|
}
|
|
@@ -1052,30 +1071,45 @@ let OperatorService = class OperatorService {
|
|
|
1052
1071
|
}
|
|
1053
1072
|
/**
|
|
1054
1073
|
* Kerrigan (2026-10-20): the persona the operator may give to a chat of their own, in the language asked for, with
|
|
1055
|
-
* this machine's limits in it
|
|
1074
|
+
* this machine's limits in it and the projects of Settings — each one's folder, its branch now, and the level 2 the
|
|
1075
|
+
* operator wrote for it. Nothing is sent anywhere: the page saves it or copies it. See `plan/kerrigan.ts`; in a
|
|
1076
|
+
* language she is not written out in, the page fills in the names of the controls (`filled: false`).
|
|
1056
1077
|
*/
|
|
1057
1078
|
async kerrigan(lang) {
|
|
1058
1079
|
const cfg = await this.settings.load();
|
|
1080
|
+
const p = await this.project();
|
|
1081
|
+
const projects = [
|
|
1082
|
+
...(p.rootDir ? [{ name: p.name, rootDir: p.rootDir, ...(p.branch ? { branch: p.branch } : {}), level2: p.level2, chat: true, ...(p.readOnly ? { readOnly: true } : {}) }] : []),
|
|
1083
|
+
...p.others.map((o) => ({ name: o.name, rootDir: o.rootDir, ...(o.branch ? { branch: o.branch } : {}), level2: o.level2, ...(o.readOnly ? { readOnly: true } : {}) })),
|
|
1084
|
+
];
|
|
1085
|
+
// The skills, each with the name of the project it is for.
|
|
1086
|
+
const nameOf = (dir) => [{ name: p.name || p.rootDir, rootDir: p.rootDir }, ...p.others].find((x) => x.rootDir && sameFolder(x.rootDir, dir))?.name ?? dir;
|
|
1087
|
+
const skills = (await this.skills()).skills.map((k) => ({ name: k.name, description: k.description, ...(k.projectDir ? { project: nameOf(k.projectDir) } : {}) }));
|
|
1059
1088
|
const text = kerriganPersona(lang, {
|
|
1060
1089
|
version: botVersion(),
|
|
1090
|
+
skills,
|
|
1061
1091
|
maxIterations: cfg.limits.maxIterations,
|
|
1062
1092
|
maxRunMinutes: cfg.limits.maxRunMinutes,
|
|
1063
1093
|
autoContinue: cfg.limits.autoContinue ?? 0,
|
|
1094
|
+
maxReviewRounds: cfg.limits.maxReviewRounds ?? 2,
|
|
1095
|
+
maxSubtasks: cfg.limits.maxSubtasks ?? 20,
|
|
1096
|
+
projects,
|
|
1064
1097
|
});
|
|
1065
|
-
return { lang, fileName: kerriganFileName(lang), text };
|
|
1098
|
+
return { lang, fileName: kerriganFileName(lang), text, filled: lang === 'en' || lang === 'bg' };
|
|
1066
1099
|
}
|
|
1067
1100
|
/** The chat's conversations, newest first. */
|
|
1068
1101
|
async chatThreads() {
|
|
1069
1102
|
await this.init();
|
|
1070
1103
|
return (await this.store.listSessions())
|
|
1071
|
-
|
|
1104
|
+
// A worker's session (two chats) is not a conversation of the list: it is shown under its lead's messages.
|
|
1105
|
+
.filter((s) => s.kind === 'chat' && !s.workerOf)
|
|
1072
1106
|
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
|
1073
1107
|
.map((s) => ({ id: s.id, name: s.name, createdAt: s.createdAt, status: s.status, turns: s.tasks.length, running: this.running.has(s.id), repoDir: s.vcs?.repoDir || s.projectDir }));
|
|
1074
1108
|
}
|
|
1075
1109
|
/**
|
|
1076
1110
|
* A message written in the chat. With no conversation yet, one is made in the open project folder: a session of
|
|
1077
|
-
* kind `chat`, one branch for all of it,
|
|
1078
|
-
* it would be in an IDE's chat. The message becomes a task of it, queued; the caller starts it (the start window
|
|
1111
|
+
* kind `chat`, one branch for all of it, reviewed by a conversation of its own unless "Review" under the box is
|
|
1112
|
+
* unticked (2026-10-20), plan mode as chosen there, so each message is answered as it would be in an IDE's chat. The message becomes a task of it, queued; the caller starts it (the start window
|
|
1079
1113
|
* the first time, where the work starts being asked once). While the conversation is working, the message is a
|
|
1080
1114
|
* note to the task in flight, which the chat gets with its next report.
|
|
1081
1115
|
*/
|
|
@@ -1089,9 +1123,13 @@ let OperatorService = class OperatorService {
|
|
|
1089
1123
|
let session = input.threadId ? await this.store.getSession(input.threadId) : null;
|
|
1090
1124
|
if (input.threadId && (!session || session.kind !== 'chat'))
|
|
1091
1125
|
throw new Error('That conversation is not there any more. Start a new one.');
|
|
1126
|
+
// The skill chosen for this message, as it reads now: the task keeps this copy whatever is edited later.
|
|
1127
|
+
const skill = input.skill?.trim() ? await this.skillFor(input.skill, session?.projectDir ?? (await this.workspace()).dir) : undefined;
|
|
1092
1128
|
if (session) {
|
|
1093
1129
|
const inFlight = session.tasks.find((t) => t.status === 'running' || t.status === 'waiting-approval');
|
|
1094
1130
|
if (inFlight && this.running.has(session.id)) {
|
|
1131
|
+
if (skill)
|
|
1132
|
+
throw new Error(`A skill goes with a new message, and this one would be a note to the message at work. Send /${skill.name} when it has finished.`);
|
|
1095
1133
|
await this.addTaskNote(session.id, inFlight.id, text);
|
|
1096
1134
|
return { threadId: session.id, taskId: inFlight.id, noted: true, needsStart: false };
|
|
1097
1135
|
}
|
|
@@ -1105,7 +1143,12 @@ let OperatorService = class OperatorService {
|
|
|
1105
1143
|
session = await this.store.updateSession(created.id, (s) => {
|
|
1106
1144
|
s.kind = 'chat';
|
|
1107
1145
|
s.onFailure = 'continue';
|
|
1108
|
-
|
|
1146
|
+
/*
|
|
1147
|
+
* The review as chosen under the box (operator, 2026-10-20): the box is on unless unticked, and the page always
|
|
1148
|
+
* says which. A second conversation checks the work when it says it is done, and sends back what it finds; it
|
|
1149
|
+
* was off for the chat from 2026-10-17. Asked for without the box — the API on its own, a script — it stays off.
|
|
1150
|
+
*/
|
|
1151
|
+
s.review = { enabled: input.review === true, model: '' };
|
|
1109
1152
|
// Plan mode as chosen under the box (2026-10-20, "as in Claude Code"): the plan first, approved by the operator.
|
|
1110
1153
|
s.planMode = input.planMode ? 'approve' : 'off';
|
|
1111
1154
|
/*
|
|
@@ -1115,6 +1158,17 @@ let OperatorService = class OperatorService {
|
|
|
1115
1158
|
*/
|
|
1116
1159
|
s.vcs = { ...(s.vcs ?? DEFAULT_VCS), enabled: false, repoDir: '' };
|
|
1117
1160
|
s.projectDir = ws.dir;
|
|
1161
|
+
/*
|
|
1162
|
+
* Two chats (operator, 2026-10-20): this conversation is the lead's, and a worker carries out its subtasks. The
|
|
1163
|
+
* lead judges the worker's reports, so there is no review of its own.
|
|
1164
|
+
*/
|
|
1165
|
+
if (input.lead) {
|
|
1166
|
+
s.lead = {
|
|
1167
|
+
...(input.workerManualModel ? { workerManualModel: true } : {}),
|
|
1168
|
+
...(!input.workerManualModel && input.workerModel?.trim() ? { workerModel: input.workerModel.trim() } : {}),
|
|
1169
|
+
};
|
|
1170
|
+
s.review = { enabled: false, model: '' };
|
|
1171
|
+
}
|
|
1118
1172
|
// The model chosen in the chat for this conversation: the operator's word, which outranks Settings.
|
|
1119
1173
|
if (input.manualModel)
|
|
1120
1174
|
s.manualModel = true;
|
|
@@ -1129,6 +1183,7 @@ let OperatorService = class OperatorService {
|
|
|
1129
1183
|
title: text.split(/\r?\n/)[0].trim().slice(0, 80) || 'message',
|
|
1130
1184
|
level2: '',
|
|
1131
1185
|
prompt: text,
|
|
1186
|
+
...(skill ? { skill: { name: skill.name, description: skill.description, text: skill.text } } : {}),
|
|
1132
1187
|
});
|
|
1133
1188
|
// The language the workbench is in, for what the chat's window says when the work has ended (`chatWindowNotice`).
|
|
1134
1189
|
if (input.lang && session.lang !== input.lang) {
|
|
@@ -1146,6 +1201,64 @@ let OperatorService = class OperatorService {
|
|
|
1146
1201
|
}
|
|
1147
1202
|
return { threadId: session.id, taskId: task.id, needsStart: false };
|
|
1148
1203
|
}
|
|
1204
|
+
// --- skills (2026-10-21) ----------------------------------------------------------------------------
|
|
1205
|
+
/** The skills in Settings, and how long their instructions may be. */
|
|
1206
|
+
async skills() {
|
|
1207
|
+
const cfg = await this.settings.load();
|
|
1208
|
+
return {
|
|
1209
|
+
skills: (cfg.skills ?? []).map((k) => ({ name: k.name, description: k.description ?? '', text: k.text ?? '', projectDir: k.projectDir ?? '' })),
|
|
1210
|
+
maxText: MAX_SKILL_TEXT,
|
|
1211
|
+
maxDescription: MAX_SKILL_DESCRIPTION,
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Stores the list as given, held to the rules: a name to type after `/` — lowercase, digits and hyphens, each used
|
|
1216
|
+
* once — instructions that are there and not too long, a project that is one of Settings' or every project.
|
|
1217
|
+
*/
|
|
1218
|
+
async setSkills(list) {
|
|
1219
|
+
if (!Array.isArray(list))
|
|
1220
|
+
throw new Error('The skills come as a list.');
|
|
1221
|
+
if (list.length > MAX_SKILLS)
|
|
1222
|
+
throw new Error(`There can be at most ${MAX_SKILLS} skills.`);
|
|
1223
|
+
const cfg = await this.settings.load();
|
|
1224
|
+
const folders = [cfg.project.rootDir, ...cfg.project.others.map((o) => o.rootDir)].filter((d) => d?.trim());
|
|
1225
|
+
const seen = new Set();
|
|
1226
|
+
const skills = list.map((k) => {
|
|
1227
|
+
const name = String(k?.name ?? '').trim().toLowerCase();
|
|
1228
|
+
if (!SKILL_NAME.test(name))
|
|
1229
|
+
throw new Error(`"${name || '(no name)'}" cannot be a skill's name: 2 to 40 lowercase letters, digits and hyphens, as typed after / — new-test, new-entity, db-migration.`);
|
|
1230
|
+
if (seen.has(name))
|
|
1231
|
+
throw new Error(`Two skills are named "${name}". The name is how a message calls one, so each needs its own.`);
|
|
1232
|
+
seen.add(name);
|
|
1233
|
+
const description = String(k?.description ?? '').trim();
|
|
1234
|
+
if (description.length > MAX_SKILL_DESCRIPTION)
|
|
1235
|
+
throw new Error(`What "${name}" is for is longer than ${MAX_SKILL_DESCRIPTION} characters; one line is enough.`);
|
|
1236
|
+
const text = String(k?.text ?? '');
|
|
1237
|
+
if (!text.trim())
|
|
1238
|
+
throw new Error(`The skill "${name}" has no instructions: write what the chat should know and do for this kind of task.`);
|
|
1239
|
+
if (text.length > MAX_SKILL_TEXT)
|
|
1240
|
+
throw new Error(`The instructions of "${name}" are longer than ${MAX_SKILL_TEXT.toLocaleString('en')} characters.`);
|
|
1241
|
+
const projectDir = String(k?.projectDir ?? '').trim();
|
|
1242
|
+
if (projectDir && !folders.some((f) => sameFolder(f, projectDir)))
|
|
1243
|
+
throw new Error(`The skill "${name}" is for ${projectDir}, which is not one of the projects in Settings.`);
|
|
1244
|
+
return { name, description, text, projectDir };
|
|
1245
|
+
});
|
|
1246
|
+
await this.settings.update((raw) => ({ ...raw, skills }));
|
|
1247
|
+
return await this.skills();
|
|
1248
|
+
}
|
|
1249
|
+
/** The skill a message calls, for the folder it works in: one for every project, or one for this one. */
|
|
1250
|
+
async skillFor(asked, dir) {
|
|
1251
|
+
const name = asked.trim().replace(/^\//, '').toLowerCase();
|
|
1252
|
+
const { skills } = await this.skills();
|
|
1253
|
+
const fits = skills.filter((k) => !k.projectDir || (dir && sameFolder(k.projectDir, dir)));
|
|
1254
|
+
const found = fits.find((k) => k.name === name);
|
|
1255
|
+
if (found)
|
|
1256
|
+
return found;
|
|
1257
|
+
const other = skills.find((k) => k.name === name);
|
|
1258
|
+
if (other)
|
|
1259
|
+
throw new Error(`The skill "${name}" is for ${other.projectDir}, not for the folder this chat works in.`);
|
|
1260
|
+
throw new Error(`There is no skill called "${name}"${fits.length > 0 ? `; there are ${fits.map((k) => k.name).join(', ')}` : ''}. Skills are written in Settings → Skills.`);
|
|
1261
|
+
}
|
|
1149
1262
|
/**
|
|
1150
1263
|
* Back to before a message of the chat (2026-10-17): the folder put back exactly as it was just before that
|
|
1151
1264
|
* message ran — branch, commit, uncommitted changes — and that message and every one after it taken out of the
|
|
@@ -1213,9 +1326,9 @@ let OperatorService = class OperatorService {
|
|
|
1213
1326
|
sessionId: ask.sessionId,
|
|
1214
1327
|
taskId: '',
|
|
1215
1328
|
stepId: 0,
|
|
1216
|
-
description: ask.asked ? `Choose "${ask.asked}" in the Copilot window` : 'Choose the model in the Copilot window'
|
|
1329
|
+
description: `${ask.asked ? `Choose "${ask.asked}" in the Copilot window` : 'Choose the model in the Copilot window'}${ask.review ? ' for the review' : ask.role ? ` for the ${ask.role}` : ''}`,
|
|
1217
1330
|
createdAt: new Date().toISOString(),
|
|
1218
|
-
model: { asked: ask.asked, shown: ask.shown, why: ask.why, tries: ask.tries, ...(ask.manual ? { manual: true } : {}) },
|
|
1331
|
+
model: { asked: ask.asked, shown: ask.shown, why: ask.why, tries: ask.tries, ...(ask.manual ? { manual: true } : {}), ...(ask.review ? { review: true } : {}), ...(ask.role ? { role: ask.role } : {}) },
|
|
1219
1332
|
};
|
|
1220
1333
|
this.waiting.set(approval.id, {
|
|
1221
1334
|
approval,
|
|
@@ -1225,6 +1338,49 @@ let OperatorService = class OperatorService {
|
|
|
1225
1338
|
message: `choose "${ask.asked}" in the Copilot window, then answer on the card`, data: { approvalId: approval.id, model: approval.model } });
|
|
1226
1339
|
});
|
|
1227
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* The lead's question for the operator (two chats, 2026-10-20): what only a person can decide, on a card in the
|
|
1343
|
+
* conversation, waiting in every mode — an unattended run included, since nobody else can answer it — until it is
|
|
1344
|
+
* answered or the task is stopped.
|
|
1345
|
+
*/
|
|
1346
|
+
askLeadQuestion(ask, signal) {
|
|
1347
|
+
return new Promise((resolveAnswer) => {
|
|
1348
|
+
if (signal.aborted) {
|
|
1349
|
+
resolveAnswer('stop');
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
const approval = {
|
|
1353
|
+
id: newId('a-'),
|
|
1354
|
+
sessionId: ask.sessionId,
|
|
1355
|
+
taskId: ask.taskId,
|
|
1356
|
+
stepId: 0,
|
|
1357
|
+
description: `The lead asks: ${ask.question}`,
|
|
1358
|
+
createdAt: new Date().toISOString(),
|
|
1359
|
+
question: { text: ask.question, ...(ask.why ? { why: ask.why } : {}), options: ask.options },
|
|
1360
|
+
};
|
|
1361
|
+
this.waiting.set(approval.id, {
|
|
1362
|
+
approval,
|
|
1363
|
+
// A stop, the end of the run, "abort" on the card: the task stops at the question.
|
|
1364
|
+
resolve: () => resolveAnswer('stop'),
|
|
1365
|
+
resolveAnswer,
|
|
1366
|
+
});
|
|
1367
|
+
this.bus.publish({ sessionId: ask.sessionId, taskId: ask.taskId, type: 'approval-requested', level: 'warn',
|
|
1368
|
+
message: `the lead asks the operator: ${ask.question}`, data: { approvalId: approval.id, question: approval.question } });
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
/** The operator's answer to the lead's question. */
|
|
1372
|
+
answerQuestion(approvalId, text) {
|
|
1373
|
+
const w = this.waiting.get(approvalId);
|
|
1374
|
+
if (!w?.resolveAnswer)
|
|
1375
|
+
return { ok: false, problem: 'No question of the lead is waiting under that id.' };
|
|
1376
|
+
if (!text.trim())
|
|
1377
|
+
return { ok: false, problem: 'Write the answer first.' };
|
|
1378
|
+
this.waiting.delete(approvalId);
|
|
1379
|
+
w.resolveAnswer({ answer: text.trim() });
|
|
1380
|
+
this.bus.publish({ sessionId: w.approval.sessionId, taskId: w.approval.taskId, type: 'approval-decided', level: 'info',
|
|
1381
|
+
message: 'the operator answered the lead', data: { approvalId, question: true } });
|
|
1382
|
+
return { ok: true };
|
|
1383
|
+
}
|
|
1228
1384
|
/**
|
|
1229
1385
|
* A task's plan, put to the operator (plan mode `approve`, in a run that asks before each command): it
|
|
1230
1386
|
* waits on the approvals card, on every page, until it is approved, sent back for another, or the task
|
|
@@ -1273,8 +1429,9 @@ let OperatorService = class OperatorService {
|
|
|
1273
1429
|
message: `plan: ${action}${text ? ' (with a note)' : ''}`, data: { approvalId, action, plan: true } });
|
|
1274
1430
|
return { ok: true };
|
|
1275
1431
|
}
|
|
1432
|
+
/** What waits for the operator; of one session, its worker's included (two chats: they are asked in its conversation). */
|
|
1276
1433
|
pendingApprovals(sessionId) {
|
|
1277
|
-
return [...this.waiting.values()].map((w) => w.approval).filter((a) => !sessionId || a.sessionId === sessionId);
|
|
1434
|
+
return [...this.waiting.values()].map((w) => w.approval).filter((a) => !sessionId || a.sessionId === sessionId || this.workerLeads.get(a.sessionId) === sessionId);
|
|
1278
1435
|
}
|
|
1279
1436
|
/**
|
|
1280
1437
|
* Answers one pending approval.
|
|
@@ -1290,7 +1447,7 @@ let OperatorService = class OperatorService {
|
|
|
1290
1447
|
return { ok: false };
|
|
1291
1448
|
this.waiting.delete(approvalId);
|
|
1292
1449
|
if (action === 'run-all')
|
|
1293
|
-
this.setRunMode(w.approval.sessionId, 'unattended');
|
|
1450
|
+
this.setRunMode(this.runKey(w.approval.sessionId), 'unattended');
|
|
1294
1451
|
const decision = action === 'run' || action === 'run-all'
|
|
1295
1452
|
? { action: 'run' }
|
|
1296
1453
|
: action === 'skip'
|
|
@@ -1344,10 +1501,10 @@ let OperatorService = class OperatorService {
|
|
|
1344
1501
|
});
|
|
1345
1502
|
if (mode === 'unattended') {
|
|
1346
1503
|
for (const [id, w] of this.waiting) {
|
|
1347
|
-
if (w.approval.sessionId !== sessionId)
|
|
1504
|
+
if (this.runKey(w.approval.sessionId) !== sessionId)
|
|
1348
1505
|
continue;
|
|
1349
|
-
// A fetch waits for its own answer: "run the rest without asking" is not an answer to it.
|
|
1350
|
-
if (w.approval.network || w.approval.model)
|
|
1506
|
+
// A fetch waits for its own answer: "run the rest without asking" is not an answer to it; nor is a question.
|
|
1507
|
+
if (w.approval.network || w.approval.model || w.approval.question || w.approval.plan)
|
|
1351
1508
|
continue;
|
|
1352
1509
|
this.waiting.delete(id);
|
|
1353
1510
|
w.resolve({ action: 'run' });
|
|
@@ -1370,7 +1527,7 @@ let OperatorService = class OperatorService {
|
|
|
1370
1527
|
// This is checked per step rather than captured once, which is what makes the switch
|
|
1371
1528
|
// take effect from the very next step instead of the next run. A held step is the
|
|
1372
1529
|
// exception: it is asked about in an unattended run too, which is the point of holding it.
|
|
1373
|
-
if (!held && this.running.get(ctx.sessionId ?? '')?.mode === 'unattended') {
|
|
1530
|
+
if (!held && this.running.get(this.runKey(ctx.sessionId ?? ''))?.mode === 'unattended') {
|
|
1374
1531
|
resolvePromise({ action: 'run' });
|
|
1375
1532
|
return;
|
|
1376
1533
|
}
|
|
@@ -1653,54 +1810,6 @@ let OperatorService = class OperatorService {
|
|
|
1653
1810
|
}
|
|
1654
1811
|
return undefined;
|
|
1655
1812
|
}
|
|
1656
|
-
/** Throws unless the folder is a project in Settings or the repository of a session. */
|
|
1657
|
-
async knownProjectFolder(dir, otherwise) {
|
|
1658
|
-
const wanted = normaliseDir(dir);
|
|
1659
|
-
const cfg = await this.settings.load();
|
|
1660
|
-
const known = new Set([cfg.project?.rootDir ?? '', ...(cfg.project?.others ?? []).map((o) => o.rootDir), ...(await this.store.listSessions()).flatMap((s) => [s.vcs?.repoDir ?? '', s.projectDir ?? ''])]
|
|
1661
|
-
.filter((d) => d.trim())
|
|
1662
|
-
.map(normaliseDir));
|
|
1663
|
-
if (!wanted || !known.has(wanted)) {
|
|
1664
|
-
throw new Error(`That folder is not one of the projects in Settings or the repository of a session, so ${otherwise}.`);
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
/**
|
|
1668
|
-
* "Prepare the folder from the remote main branch", first half: fetches and says what would be
|
|
1669
|
-
* kept where and what the folder would be. See `vcs/prepareFromRemote.ts`.
|
|
1670
|
-
*/
|
|
1671
|
-
async preparePreview(dir, fetch = true) {
|
|
1672
|
-
await this.init();
|
|
1673
|
-
await this.knownProjectFolder(dir, 'it is not prepared from here');
|
|
1674
|
-
// The operator pressed the button and is looking: the remote may ask for a password through Git's own window.
|
|
1675
|
-
return await planPrepare(resolve(dir.trim()), { fetch, askpass: fetch ? await askpassProgram() : null });
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* The second half: does it, if the folder is still what the preview showed. Refused while anything
|
|
1679
|
-
* runs, or is being started, in that folder or one around it: it moves the checkout.
|
|
1680
|
-
*/
|
|
1681
|
-
async prepareProject(dir, fingerprint, names = {}) {
|
|
1682
|
-
await this.init();
|
|
1683
|
-
await this.knownProjectFolder(dir, 'it is not prepared from here');
|
|
1684
|
-
if (this.running.size > 0)
|
|
1685
|
-
return { ok: false, problem: 'A run is going. Stop it before preparing the folder; nothing was changed.' };
|
|
1686
|
-
if (this.browser?.kind === 'run')
|
|
1687
|
-
return { ok: false, problem: 'A run is being started. Wait for it, or stop it, before preparing the folder; nothing was changed.' };
|
|
1688
|
-
const other = await this.runningIn(dir);
|
|
1689
|
-
if (other)
|
|
1690
|
-
return { ok: false, problem: `Session "${other.name}" is running in this folder. Stop it before preparing the folder; nothing was changed.` };
|
|
1691
|
-
const done = await prepareFromRemote(resolve(dir.trim()), String(fingerprint ?? ''), { names });
|
|
1692
|
-
// Kept on every session working in that folder: it moved the checkout and made saved branches.
|
|
1693
|
-
if (done.ok) {
|
|
1694
|
-
const cfg = await this.settings.load();
|
|
1695
|
-
const here = normaliseDir(dir);
|
|
1696
|
-
for (const s of (await this.store.listSessions()).filter((x) => normaliseDir(repoDirOf(x)) === here)) {
|
|
1697
|
-
const message = `the folder was prepared from ${done.target}: ${done.result}`;
|
|
1698
|
-
await appendSessionLog(cfg.resolved.runsDir, s.id, { type: 'folder-prepared', message, data: { target: done.target, commit: done.commit, branch: done.branch, saved: done.saved, removedFromFolder: done.removedFromFolder } }).catch(() => undefined);
|
|
1699
|
-
this.bus.publish({ sessionId: s.id, type: 'folder-prepared', level: 'info', message, data: { target: done.target, commit: done.commit, saved: done.saved } });
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1702
|
-
return done;
|
|
1703
|
-
}
|
|
1704
1813
|
// --- the project being worked on ---------------------------------------------------------
|
|
1705
1814
|
/**
|
|
1706
1815
|
* The folder new sessions start pointed at, and whether it can carry version control.
|
|
@@ -1711,18 +1820,26 @@ let OperatorService = class OperatorService {
|
|
|
1711
1820
|
async project() {
|
|
1712
1821
|
const cfg = await this.settings.load();
|
|
1713
1822
|
const rootDir = (cfg.project?.rootDir ?? '').trim();
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1823
|
+
/*
|
|
1824
|
+
* The branch each folder is on now (operator, 2026-10-20: "show which branch is chosen"), read from git each
|
|
1825
|
+
* time, since the operator switches it by hand and the chat works on whatever is checked out.
|
|
1826
|
+
*/
|
|
1827
|
+
const entry = async (name, dir, level2, readOnly) => {
|
|
1828
|
+
const problem = dir ? repoUnusableReason(dir) : 'no folder';
|
|
1829
|
+
const branch = dir && problem === null ? await git(dir, ['rev-parse', '--abbrev-ref', 'HEAD']).catch(() => null) : null;
|
|
1830
|
+
return {
|
|
1831
|
+
name,
|
|
1832
|
+
rootDir: dir,
|
|
1833
|
+
repoOk: dir !== '' && problem === null,
|
|
1834
|
+
...(dir && problem ? { repoProblem: problem } : {}),
|
|
1835
|
+
...(branch?.ok && branch.stdout ? { branch: branch.stdout } : {}),
|
|
1836
|
+
level2,
|
|
1837
|
+
readOnly,
|
|
1838
|
+
};
|
|
1725
1839
|
};
|
|
1840
|
+
const main = await entry((cfg.project?.name ?? '').trim(), rootDir, cfg.project?.level2 ?? '', cfg.project?.readOnly === true);
|
|
1841
|
+
const others = await Promise.all((cfg.project?.others ?? []).map((o) => entry(o.name, o.rootDir, o.level2 ?? '', o.readOnly === true)));
|
|
1842
|
+
return { ...main, others };
|
|
1726
1843
|
}
|
|
1727
1844
|
/**
|
|
1728
1845
|
* Stores the project folder and the other folders the operator works in. A field left out
|
|
@@ -1741,13 +1858,30 @@ let OperatorService = class OperatorService {
|
|
|
1741
1858
|
await this.settings.update((raw) => {
|
|
1742
1859
|
const current = (raw.project ?? {});
|
|
1743
1860
|
const rootDir = patch.rootDir !== undefined ? patch.rootDir.trim() : (current.rootDir ?? '').trim();
|
|
1861
|
+
const readOnly = patch.readOnly !== undefined ? patch.readOnly === true : current.readOnly === true;
|
|
1744
1862
|
const name = patch.name !== undefined ? patch.name.trim() : (current.name ?? '').trim();
|
|
1863
|
+
const level2 = patch.level2 !== undefined ? patch.level2 : (current.level2 ?? '');
|
|
1864
|
+
// Each goes into Kerrigan whole, and she is pasted into a chat: bounded, so one project cannot crowd out the rest.
|
|
1865
|
+
const tooLong = [{ name: name || rootDir, level2 }, ...(patch.others ?? [])].find((o) => (o.level2 ?? '').length > MAX_PROJECT_LEVEL2);
|
|
1866
|
+
if (tooLong)
|
|
1867
|
+
throw new Error(`The level 2 of "${tooLong.name}" is longer than ${MAX_PROJECT_LEVEL2.toLocaleString('en')} characters; keep it to what a chat needs to know about the project.`);
|
|
1745
1868
|
if (rootDir && !existsSync(rootDir))
|
|
1746
1869
|
throw new Error(`The folder ${rootDir} does not exist on this machine.`);
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1870
|
+
/*
|
|
1871
|
+
* A project's level 2 is kept with it when the list comes without one — renamed or moved, or saved by a page that
|
|
1872
|
+
* does not know the field — matched by its folder, then by its name.
|
|
1873
|
+
*/
|
|
1874
|
+
const before = current.others ?? [];
|
|
1875
|
+
const others = (patch.others ?? before).map((o) => {
|
|
1876
|
+
const was = before.find((b) => sameFolder(b.rootDir ?? '', o.rootDir ?? '')) ?? before.find((b) => (b.name ?? '').trim() === (o.name ?? '').trim());
|
|
1877
|
+
return {
|
|
1878
|
+
name: (o.name ?? '').trim(),
|
|
1879
|
+
rootDir: (o.rootDir ?? '').trim(),
|
|
1880
|
+
level2: o.level2 !== undefined ? o.level2 : (was?.level2 ?? ''),
|
|
1881
|
+
// Kept like the level 2 when the list comes without it: a page that does not know the box must not clear it.
|
|
1882
|
+
readOnly: o.readOnly !== undefined ? o.readOnly === true : was?.readOnly === true,
|
|
1883
|
+
};
|
|
1884
|
+
});
|
|
1751
1885
|
const seen = new Set();
|
|
1752
1886
|
for (const o of others) {
|
|
1753
1887
|
if (!o.name)
|
|
@@ -1765,7 +1899,7 @@ let OperatorService = class OperatorService {
|
|
|
1765
1899
|
}
|
|
1766
1900
|
// What the removed Desktop copies left in the stored project is dropped with the next save.
|
|
1767
1901
|
const { mirror: _m, desktop: _d, mirrorToDesktop: _t, ...rest } = current;
|
|
1768
|
-
return { ...raw, project: { ...rest, rootDir, name, others } };
|
|
1902
|
+
return { ...raw, project: { ...rest, rootDir, name, level2, readOnly, others } };
|
|
1769
1903
|
});
|
|
1770
1904
|
return await this.project();
|
|
1771
1905
|
}
|
|
@@ -308,6 +308,17 @@ export const RunConfigSchema = z.object({
|
|
|
308
308
|
* default one had nowhere to put it.
|
|
309
309
|
*/
|
|
310
310
|
name: z.string().trim().default(''),
|
|
311
|
+
/**
|
|
312
|
+
* Level 2 of this project (operator, 2026-10-20: "a level 2 template for each project"): what the operator
|
|
313
|
+
* writes about it — its stack, its conventions, how its tests run, what not to touch. It goes into Kerrigan,
|
|
314
|
+
* saved or copied, so the chat she helps in knows the project; the bot sends it nowhere by itself.
|
|
315
|
+
*/
|
|
316
|
+
level2: z.string().default(''),
|
|
317
|
+
/**
|
|
318
|
+
* For reference only (operator, 2026-10-21): the bot may read it and run what only reads, and nothing in it
|
|
319
|
+
* may change while it works. Whatever a step changes there is put back (see `vcs/referenceGuard.ts`).
|
|
320
|
+
*/
|
|
321
|
+
readOnly: z.boolean().default(false),
|
|
311
322
|
/**
|
|
312
323
|
* The other folders this operator works in, each with a short name: a front end, a back
|
|
313
324
|
* end, the test suite. They are not defaults — a new session still starts on `rootDir` —
|
|
@@ -320,15 +331,44 @@ export const RunConfigSchema = z.object({
|
|
|
320
331
|
.array(z.object({
|
|
321
332
|
name: z.string().trim().min(1),
|
|
322
333
|
rootDir: z.string().trim().min(1),
|
|
334
|
+
/** Its level 2, as the default project's `level2`. */
|
|
335
|
+
level2: z.string().default(''),
|
|
336
|
+
/** For reference only, as the default project's `readOnly`. */
|
|
337
|
+
readOnly: z.boolean().default(false),
|
|
323
338
|
}))
|
|
324
339
|
.default([]),
|
|
325
340
|
})
|
|
326
341
|
.prefault({}),
|
|
342
|
+
/**
|
|
343
|
+
* Skills (operator, 2026-10-21: "a skill I can set and call for a certain task — information that belongs only to
|
|
344
|
+
* one task that comes back: adding a new automated test, a new entity, migrations of the database"): instructions
|
|
345
|
+
* for a kind of task, chosen under the chat's box or with `/its-name` at the start of a message, and sent to the
|
|
346
|
+
* chat with that message. `projectDir` is the project a skill is for; empty, every project. Kept loose here, so a
|
|
347
|
+
* hand-edited file still loads; the API holds what it saves to the rules (see `setSkills` in operator.service.ts).
|
|
348
|
+
*/
|
|
349
|
+
skills: z
|
|
350
|
+
.array(z.object({
|
|
351
|
+
name: z.string().trim().min(1),
|
|
352
|
+
description: z.string().default(''),
|
|
353
|
+
text: z.string().default(''),
|
|
354
|
+
projectDir: z.string().default(''),
|
|
355
|
+
}))
|
|
356
|
+
.default([]),
|
|
327
357
|
pacing: z
|
|
328
358
|
.object({
|
|
329
359
|
enabled: z.boolean().default(true),
|
|
330
360
|
settleMs: z.number().int().nonnegative().default(1000),
|
|
331
361
|
maxMessagesPerHour: z.number().int().positive().default(60),
|
|
362
|
+
/**
|
|
363
|
+
* A pause between two messages to Copilot (operator, 2026-10-21: "how often a message may be sent — one a minute,
|
|
364
|
+
* say: a message sent, the next no sooner than 60 seconds after"), and with `gapRandom` a time drawn anew each
|
|
365
|
+
* time between `gapSec` and `gapMaxSec` ("between 60 and 90"). Held across every conversation of the window,
|
|
366
|
+
* the lead's and the worker's alike (see `util/pacing.ts`).
|
|
367
|
+
*/
|
|
368
|
+
gapEnabled: z.boolean().default(false),
|
|
369
|
+
gapSec: z.number().int().min(1).max(3600).default(60),
|
|
370
|
+
gapRandom: z.boolean().default(false),
|
|
371
|
+
gapMaxSec: z.number().int().min(1).max(3600).default(90),
|
|
332
372
|
})
|
|
333
373
|
.prefault({}),
|
|
334
374
|
limits: z
|
|
@@ -411,6 +451,11 @@ export const RunConfigSchema = z.object({
|
|
|
411
451
|
* Zero turns it off.
|
|
412
452
|
*/
|
|
413
453
|
autoContinue: z.number().int().min(0).max(20).default(3),
|
|
454
|
+
/*
|
|
455
|
+
* The most subtasks the lead of a two-chat conversation may give its worker for one message (2026-10-20). Each
|
|
456
|
+
* subtask is a task of the worker's, with the limits above; this bounds the whole. Settings → Execution.
|
|
457
|
+
*/
|
|
458
|
+
maxSubtasks: z.number().int().min(1).max(100).default(20),
|
|
414
459
|
/*
|
|
415
460
|
* How many genuinely different approaches the chat must have tried before it may end a task
|
|
416
461
|
* "blocked". The reply format's own floor is 2 (replySchema.ts); this raises it. A "blocked"
|