copilot-operator 0.1.43 → 0.1.45
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/src/api/operator.controller.js +77 -0
- package/dist/src/api/operator.service.js +146 -1
- package/dist/src/config/schema.js +18 -0
- package/dist/src/orchestrator/taskRunner.js +50 -2
- package/dist/src/plan/systemGuide.js +162 -2
- package/dist/src/session/checkpoint.js +91 -0
- package/dist/src/session/store.js +2 -0
- package/dist/src/session/workspace.js +71 -0
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/549-13aab16a40600608.js +1 -0
- package/dist/web/_next/static/chunks/867-88233b4570638286.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-12f138ee04d33c1e.js +1 -0
- package/dist/web/_next/static/chunks/app/page-b51630404f5eba03.js +1 -0
- package/dist/web/_next/static/css/{72c85e4322c21223.css → 70ceb261074b139c.css} +1 -1
- package/dist/web/appearance.html +2 -2
- package/dist/web/appearance.txt +10 -10
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +10 -10
- package/dist/web/history.html +2 -2
- package/dist/web/history.txt +10 -10
- package/dist/web/import.html +2 -2
- package/dist/web/import.txt +10 -10
- package/dist/web/index.html +2 -2
- package/dist/web/index.txt +10 -10
- package/dist/web/level1.html +2 -2
- package/dist/web/level1.txt +10 -10
- package/dist/web/presets.html +2 -2
- package/dist/web/presets.txt +10 -10
- package/dist/web/sessions/view.html +2 -2
- package/dist/web/sessions/view.txt +10 -10
- package/dist/web/sessions.html +2 -2
- package/dist/web/sessions.txt +10 -10
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +10 -10
- package/package.json +3 -2
- package/dist/web/_next/static/chunks/549-2415dd26f4e53d07.js +0 -1
- package/dist/web/_next/static/chunks/867-aea30f560bc18eaf.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-dc602b727480a653.js +0 -1
- package/dist/web/_next/static/chunks/app/page-d73a8ff300862cd8.js +0 -1
- /package/dist/web/_next/static/{WmzBz4QN36pcz4PL_cfEW → L6g_c8hW3p_AUNzreQ3Sj}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{WmzBz4QN36pcz4PL_cfEW → L6g_c8hW3p_AUNzreQ3Sj}/_ssgManifest.js +0 -0
|
@@ -524,6 +524,43 @@ let OperatorController = class OperatorController {
|
|
|
524
524
|
resetContext(kind, lang) {
|
|
525
525
|
return this.ops.resetContext(asContextKind(kind), lang ?? 'en');
|
|
526
526
|
}
|
|
527
|
+
/** The project folder the workbench has open, its files on disk, and one of them. Read-only. */
|
|
528
|
+
workspace() {
|
|
529
|
+
return this.ops.workspace().catch(fail);
|
|
530
|
+
}
|
|
531
|
+
workspaceFiles() {
|
|
532
|
+
return this.ops.workspaceFiles().catch(fail);
|
|
533
|
+
}
|
|
534
|
+
workspaceFile(path) {
|
|
535
|
+
if (!path)
|
|
536
|
+
throw new BadRequestException('path is required');
|
|
537
|
+
return this.ops.workspaceFile(path).catch(fail);
|
|
538
|
+
}
|
|
539
|
+
/** The chat's conversations, newest first. */
|
|
540
|
+
chatThreads() {
|
|
541
|
+
return this.ops.chatThreads().catch(fail);
|
|
542
|
+
}
|
|
543
|
+
/** A message in the chat: a task of its conversation (made in the open folder if there is none), or a note while it works. */
|
|
544
|
+
chatSend(body = {}) {
|
|
545
|
+
if (typeof body?.text !== 'string' || !body.text.trim())
|
|
546
|
+
throw new BadRequestException('text is required');
|
|
547
|
+
return this.ops
|
|
548
|
+
.chatSend({
|
|
549
|
+
text: body.text,
|
|
550
|
+
...(typeof body.threadId === 'string' && body.threadId ? { threadId: body.threadId } : {}),
|
|
551
|
+
...(typeof body.model === 'string' && body.model.trim() ? { model: body.model } : {}),
|
|
552
|
+
})
|
|
553
|
+
.catch(fail);
|
|
554
|
+
}
|
|
555
|
+
/** Back to before a message: the folder as it was then, that message and the ones after it taken out. */
|
|
556
|
+
async chatRewind(id, body = {}) {
|
|
557
|
+
if (typeof body?.taskId !== 'string' || !body.taskId)
|
|
558
|
+
throw new BadRequestException('taskId is required');
|
|
559
|
+
const r = await this.ops.chatRewind(id, body.taskId).catch(fail);
|
|
560
|
+
if (!r.ok)
|
|
561
|
+
throw new BadRequestException(r.problem);
|
|
562
|
+
return r;
|
|
563
|
+
}
|
|
527
564
|
/** One folder of the session's repository at its branch (or the task's commit): read-only, for the workbench. */
|
|
528
565
|
repoTree(id, path, task) {
|
|
529
566
|
return this.ops.repoTree(id, path ?? '', task?.trim() || undefined).catch(fail);
|
|
@@ -1196,6 +1233,46 @@ __decorate([
|
|
|
1196
1233
|
__metadata("design:paramtypes", [String, String]),
|
|
1197
1234
|
__metadata("design:returntype", Promise)
|
|
1198
1235
|
], OperatorController.prototype, "resetContext", null);
|
|
1236
|
+
__decorate([
|
|
1237
|
+
Get('workspace'),
|
|
1238
|
+
__metadata("design:type", Function),
|
|
1239
|
+
__metadata("design:paramtypes", []),
|
|
1240
|
+
__metadata("design:returntype", Promise)
|
|
1241
|
+
], OperatorController.prototype, "workspace", null);
|
|
1242
|
+
__decorate([
|
|
1243
|
+
Get('workspace/files'),
|
|
1244
|
+
__metadata("design:type", Function),
|
|
1245
|
+
__metadata("design:paramtypes", []),
|
|
1246
|
+
__metadata("design:returntype", Promise)
|
|
1247
|
+
], OperatorController.prototype, "workspaceFiles", null);
|
|
1248
|
+
__decorate([
|
|
1249
|
+
Get('workspace/file'),
|
|
1250
|
+
__param(0, Query('path')),
|
|
1251
|
+
__metadata("design:type", Function),
|
|
1252
|
+
__metadata("design:paramtypes", [String]),
|
|
1253
|
+
__metadata("design:returntype", Promise)
|
|
1254
|
+
], OperatorController.prototype, "workspaceFile", null);
|
|
1255
|
+
__decorate([
|
|
1256
|
+
Get('chat/threads'),
|
|
1257
|
+
__metadata("design:type", Function),
|
|
1258
|
+
__metadata("design:paramtypes", []),
|
|
1259
|
+
__metadata("design:returntype", Promise)
|
|
1260
|
+
], OperatorController.prototype, "chatThreads", null);
|
|
1261
|
+
__decorate([
|
|
1262
|
+
Post('chat'),
|
|
1263
|
+
__param(0, Body()),
|
|
1264
|
+
__metadata("design:type", Function),
|
|
1265
|
+
__metadata("design:paramtypes", [Object]),
|
|
1266
|
+
__metadata("design:returntype", Promise)
|
|
1267
|
+
], OperatorController.prototype, "chatSend", null);
|
|
1268
|
+
__decorate([
|
|
1269
|
+
Post('chat/:id/rewind'),
|
|
1270
|
+
__param(0, Param('id')),
|
|
1271
|
+
__param(1, Body()),
|
|
1272
|
+
__metadata("design:type", Function),
|
|
1273
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
1274
|
+
__metadata("design:returntype", Promise)
|
|
1275
|
+
], OperatorController.prototype, "chatRewind", null);
|
|
1199
1276
|
__decorate([
|
|
1200
1277
|
Get('sessions/:id/repo/tree'),
|
|
1201
1278
|
__param(0, Param('id')),
|
|
@@ -47,6 +47,8 @@ function sameFolder(a, b) {
|
|
|
47
47
|
}
|
|
48
48
|
import { composeLevel2, composePrompt, importPlan, personaBlock, plannedSessionSignature, taskSignature } from '../plan/importPlan.js';
|
|
49
49
|
import { checkChanges, kerriganReport } from '../plan/changes.js';
|
|
50
|
+
import { workspaceFile, workspaceFiles, workspaceInfo } from '../session/workspace.js';
|
|
51
|
+
import { restoreCheckpoint } from '../session/checkpoint.js';
|
|
50
52
|
import { readInterruption } from '../session/interruption.js';
|
|
51
53
|
import { baseRefOf, branchAt, commitInterrupted, nextAttemptBranch, repoDirOf, trackedRepoOf, vcsPreflight, restorePoint, restorePreview, restoreToBase, revertTaskWork, undoThisPreview, sessionBranches, sessionBranchName } from '../vcs/taskVcs.js';
|
|
52
54
|
import { branchExists, changedFilesBetween, commitsBetween, fileAt, freeBranchName, git, gitAvailable, localBranches, looksLikeRepo, plannedBranchName, repoUnusableReason } from '../vcs/git.js';
|
|
@@ -80,6 +82,7 @@ import { resolveDesktopDir, desktopIsSynced } from '../context/desktopDir.js';
|
|
|
80
82
|
import { saveAndReveal } from './saveToDesktop.js';
|
|
81
83
|
import { settingsOf, SettingsUnusableError } from './settings.js';
|
|
82
84
|
import { PolicyLockUnusableError } from '../config/lockedPolicy.js';
|
|
85
|
+
import { chatDenyPatterns } from '../config/schema.js';
|
|
83
86
|
/** Why a session set aside on the Sessions page does not run: one sentence for every start that refuses it. */
|
|
84
87
|
/** The id of the task a change names by id, number or title; see `plan/changes.ts`. */
|
|
85
88
|
function checkTaskRef(session, ref) {
|
|
@@ -1300,7 +1303,9 @@ let OperatorService = class OperatorService {
|
|
|
1300
1303
|
const queuedIds = queuedToRun(session, onlyTasks).map((t) => t.id);
|
|
1301
1304
|
if (queuedIds.length === 0)
|
|
1302
1305
|
return { started: false, reason: 'no queued tasks', done: Promise.resolve(idle) };
|
|
1303
|
-
const
|
|
1306
|
+
const loaded = await this.settings.load();
|
|
1307
|
+
// A chat conversation's git is the operator's: switching branches and committing are allowed there (2026-10-17).
|
|
1308
|
+
const cfg = session.kind === 'chat' ? { ...loaded, execution: { ...loaded.execution, denyPatterns: chatDenyPatterns(loaded.execution.denyPatterns) } } : loaded;
|
|
1304
1309
|
const policy = {
|
|
1305
1310
|
mode,
|
|
1306
1311
|
denyPatterns: cfg.execution.denyPatterns,
|
|
@@ -2239,6 +2244,146 @@ let OperatorService = class OperatorService {
|
|
|
2239
2244
|
duplicates: check.duplicates,
|
|
2240
2245
|
};
|
|
2241
2246
|
}
|
|
2247
|
+
// --- the workspace and its chat (2026-10-17, "like Windsurf") ------------------------------
|
|
2248
|
+
/** The project folder the workbench has open: Settings → the default project. */
|
|
2249
|
+
async workspace() {
|
|
2250
|
+
await this.init();
|
|
2251
|
+
const cfg = await this.settings.load();
|
|
2252
|
+
return await workspaceInfo(cfg.project?.rootDir ?? '', cfg.project?.name ?? '');
|
|
2253
|
+
}
|
|
2254
|
+
async workspaceFiles() {
|
|
2255
|
+
const ws = await this.workspace();
|
|
2256
|
+
if (!ws.ok)
|
|
2257
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2258
|
+
return { dir: ws.dir, ...(await workspaceFiles(ws.dir)) };
|
|
2259
|
+
}
|
|
2260
|
+
async workspaceFile(path) {
|
|
2261
|
+
const ws = await this.workspace();
|
|
2262
|
+
if (!ws.ok)
|
|
2263
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2264
|
+
return await workspaceFile(ws.dir, path);
|
|
2265
|
+
}
|
|
2266
|
+
/** The chat's conversations, newest first. */
|
|
2267
|
+
async chatThreads() {
|
|
2268
|
+
await this.init();
|
|
2269
|
+
return (await this.store.listSessions())
|
|
2270
|
+
.filter((s) => s.kind === 'chat')
|
|
2271
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
|
2272
|
+
.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 }));
|
|
2273
|
+
}
|
|
2274
|
+
/**
|
|
2275
|
+
* A message written in the chat. With no conversation yet, one is made in the open project folder: a session of
|
|
2276
|
+
* kind `chat`, one branch for all of it, no independent review, plan mode off, so each message is answered as
|
|
2277
|
+
* it would be in an IDE's chat. The message becomes a task of it, queued; the caller starts it (the start window
|
|
2278
|
+
* the first time, where the work starts being asked once). While the conversation is working, the message is a
|
|
2279
|
+
* note to the task in flight, which the chat gets with its next report.
|
|
2280
|
+
*/
|
|
2281
|
+
async chatSend(input) {
|
|
2282
|
+
await this.init();
|
|
2283
|
+
const text = (input.text ?? '').trim();
|
|
2284
|
+
if (!text)
|
|
2285
|
+
throw new Error('The message is empty.');
|
|
2286
|
+
if (text.length > MAX_INSTRUCTION_CHARS)
|
|
2287
|
+
throw new Error(`The message is ${text.length} characters; it can be at most ${MAX_INSTRUCTION_CHARS}.`);
|
|
2288
|
+
let session = input.threadId ? await this.store.getSession(input.threadId) : null;
|
|
2289
|
+
if (input.threadId && (!session || session.kind !== 'chat'))
|
|
2290
|
+
throw new Error('That conversation is not there any more. Start a new one.');
|
|
2291
|
+
if (session) {
|
|
2292
|
+
const inFlight = session.tasks.find((t) => t.status === 'running' || t.status === 'waiting-approval');
|
|
2293
|
+
if (inFlight && this.running.has(session.id)) {
|
|
2294
|
+
await this.addTaskNote(session.id, inFlight.id, text);
|
|
2295
|
+
return { threadId: session.id, taskId: inFlight.id, noted: true, needsStart: false };
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
else {
|
|
2299
|
+
const ws = await this.workspace();
|
|
2300
|
+
if (!ws.ok)
|
|
2301
|
+
throw new Error(ws.problem ?? 'No project folder is open.');
|
|
2302
|
+
const title = text.split(/\r?\n/)[0].trim().slice(0, 60);
|
|
2303
|
+
const created = await this.store.createSession(`chat: ${title}`, ws.dir);
|
|
2304
|
+
session = await this.store.updateSession(created.id, (s) => {
|
|
2305
|
+
s.kind = 'chat';
|
|
2306
|
+
s.onFailure = 'continue';
|
|
2307
|
+
s.review = { enabled: false, model: '' };
|
|
2308
|
+
s.planMode = 'off';
|
|
2309
|
+
/*
|
|
2310
|
+
* No version control of the bot's own (2026-10-17): no branch, no commit, no question about where the work
|
|
2311
|
+
* starts. The chat works on the branch the folder is on, with what is in it, as an IDE's chat does; each
|
|
2312
|
+
* message is photographed before it runs instead, so the operator can go back to before it.
|
|
2313
|
+
*/
|
|
2314
|
+
s.vcs = { ...(s.vcs ?? DEFAULT_VCS), enabled: false, repoDir: '' };
|
|
2315
|
+
s.projectDir = ws.dir;
|
|
2316
|
+
// The model chosen in the chat for this conversation: the operator's word, which outranks Settings.
|
|
2317
|
+
if (input.model?.trim()) {
|
|
2318
|
+
s.model = input.model.trim();
|
|
2319
|
+
s.modelSource = 'operator';
|
|
2320
|
+
}
|
|
2321
|
+
});
|
|
2322
|
+
this.bus.publish({ sessionId: session.id, type: 'chat-started', level: 'info', message: `a conversation in ${ws.dir}` });
|
|
2323
|
+
}
|
|
2324
|
+
const task = await this.store.addTask(session.id, {
|
|
2325
|
+
title: text.split(/\r?\n/)[0].trim().slice(0, 80) || 'message',
|
|
2326
|
+
level2: '',
|
|
2327
|
+
prompt: text,
|
|
2328
|
+
});
|
|
2329
|
+
// After going back, the conversation is told with this message: it still holds what was undone.
|
|
2330
|
+
const pending = (await this.store.getSession(session.id))?.rewindNote;
|
|
2331
|
+
if (pending) {
|
|
2332
|
+
await this.store.addTaskNote(session.id, task.id, pending);
|
|
2333
|
+
await this.store.updateSession(session.id, (s) => {
|
|
2334
|
+
s.rewindNote = undefined;
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
return { threadId: session.id, taskId: task.id, needsStart: false };
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Back to before a message of the chat (2026-10-17): the folder put back exactly as it was just before that
|
|
2341
|
+
* message ran — branch, commit, uncommitted changes — and that message and every one after it taken out of the
|
|
2342
|
+
* conversation, because they did not happen. They stay on the record (`Session.rewound`), and the folder as it
|
|
2343
|
+
* was before going back is kept as a safety photograph. The Copilot conversation still holds them, so its next
|
|
2344
|
+
* message says what was undone. See `session/checkpoint.ts`.
|
|
2345
|
+
*/
|
|
2346
|
+
async chatRewind(threadId, taskId) {
|
|
2347
|
+
await this.init();
|
|
2348
|
+
const session = await this.store.getSession(threadId);
|
|
2349
|
+
if (!session || session.kind !== 'chat')
|
|
2350
|
+
return { ok: false, problem: 'That conversation is not there any more.' };
|
|
2351
|
+
if (this.running.has(threadId) || session.status !== 'idle')
|
|
2352
|
+
return { ok: false, problem: 'The conversation is working. Stop it first, then go back.' };
|
|
2353
|
+
const at = session.tasks.findIndex((t) => t.id === taskId);
|
|
2354
|
+
if (at < 0)
|
|
2355
|
+
return { ok: false, problem: 'That message is not in the conversation.' };
|
|
2356
|
+
const task = session.tasks[at];
|
|
2357
|
+
// A message that never ran changed nothing: it is only taken out, with the ones after it.
|
|
2358
|
+
const firstRan = session.tasks.slice(at).find((t) => t.checkpoint);
|
|
2359
|
+
const dir = session.projectDir?.trim() || '';
|
|
2360
|
+
let safety;
|
|
2361
|
+
if (firstRan?.checkpoint) {
|
|
2362
|
+
const other = await this.runningIn(dir);
|
|
2363
|
+
if (other)
|
|
2364
|
+
return { ok: false, problem: `Session "${other.name}" is running in this folder. Stop it first.` };
|
|
2365
|
+
const done = await restoreCheckpoint(dir, firstRan.checkpoint);
|
|
2366
|
+
if (!done.ok)
|
|
2367
|
+
return { ok: false, problem: done.problem };
|
|
2368
|
+
safety = done.safety;
|
|
2369
|
+
}
|
|
2370
|
+
const removed = session.tasks.slice(at);
|
|
2371
|
+
const titles = removed.map((t) => `"${t.title}"`).join(', ');
|
|
2372
|
+
await this.store.updateSession(threadId, (s) => {
|
|
2373
|
+
s.tasks = s.tasks.slice(0, at);
|
|
2374
|
+
s.rewound = [...(s.rewound ?? []), { at: new Date().toISOString(), toBefore: taskId, safety: safety ?? '', tasks: removed }];
|
|
2375
|
+
s.rewindNote =
|
|
2376
|
+
`The operator went back to before the message "${task.title}": the folder is again exactly as it was then` +
|
|
2377
|
+
`${firstRan?.checkpoint ? ` (on ${firstRan.checkpoint.branch || 'commit ' + firstRan.checkpoint.head.slice(0, 8)})` : ''}, and that message and the ` +
|
|
2378
|
+
`${removed.length > 1 ? `${removed.length - 1} after it were` : 'ones after it were'} undone (${titles}). Forget what was done for them; ` +
|
|
2379
|
+
'work from the folder as it is now.';
|
|
2380
|
+
});
|
|
2381
|
+
const message = `went back to before "${task.title}": ${removed.length} message(s) taken out${safety ? `, the folder as it was is kept as ${safety.slice(0, 8)}` : ''}`;
|
|
2382
|
+
const cfg = await this.settings.load();
|
|
2383
|
+
await appendSessionLog(cfg.resolved.runsDir, threadId, { type: 'chat-rewind', message, data: { taskId, removed: removed.map((t) => t.id), safety } }).catch(() => undefined);
|
|
2384
|
+
this.bus.publish({ sessionId: threadId, type: 'chat-rewind', level: 'info', message, data: { taskId, removed: removed.length, safety } });
|
|
2385
|
+
return { ok: true, message, text: task.prompt, ...(safety ? { safety } : {}) };
|
|
2386
|
+
}
|
|
2242
2387
|
// --- the repository, read-only, for the workbench (2026-10-14) ------------------------------
|
|
2243
2388
|
/**
|
|
2244
2389
|
* Where a session's work is in its repository: the session's branch in per-session mode, the task's own
|
|
@@ -70,6 +70,24 @@ const GIT_SOMETIMES_WRITES = 'remote\\s+(?:add|remove|rm|rename|set-url|set-head
|
|
|
70
70
|
'config\\s+(?:set|unset|rename-section|remove-section|edit)\\b|' +
|
|
71
71
|
'reflog\\s+(?:delete|expire)|' +
|
|
72
72
|
'notes\\s+(?:add|append|edit|remove|copy|prune)';
|
|
73
|
+
/** The two default patterns that refuse git writes, as they stand in `execution.denyPatterns`. */
|
|
74
|
+
export const GIT_WRITE_DENY = [
|
|
75
|
+
`\\bgit\\s+(?:${GIT_GLOBAL_OPTION}\\s+)*(?:${GIT_ALWAYS_WRITES})(?![\\w-])`,
|
|
76
|
+
`\\bgit\\s+(?:${GIT_GLOBAL_OPTION}\\s+)*(?:${GIT_SOMETIMES_WRITES})`,
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* In the workbench's chat the git is the operator's (2026-10-17: "the program works on the branch I left; I may
|
|
80
|
+
* ask the bot to change it"): switching or making a branch, committing, staging, stashing, pulling and merging
|
|
81
|
+
* are theirs to ask for. Still refused there: what reaches the remote, rewrites history or throws work away —
|
|
82
|
+
* push, reset, rebase, clean, history filters, low-level ref and object surgery — and the settings ones.
|
|
83
|
+
*/
|
|
84
|
+
const GIT_CHAT_WRITES = 'push|reset|rebase|clean|filter-branch|filter-repo|update-ref|update-index|gc|prune|repack|worktree|' +
|
|
85
|
+
'submodule|init|clone|checkout-index|commit-tree|read-tree|prune-packed|update-server-info';
|
|
86
|
+
export function chatDenyPatterns(patterns) {
|
|
87
|
+
const [always] = GIT_WRITE_DENY;
|
|
88
|
+
// Only the default pattern is narrowed: a list the operator wrote themselves is kept as they wrote it.
|
|
89
|
+
return patterns.map((p) => (p === always ? `\\bgit\\s+(?:${GIT_GLOBAL_OPTION}\\s+)*(?:${GIT_CHAT_WRITES})(?![\\w-])` : p));
|
|
90
|
+
}
|
|
73
91
|
export const RunConfigSchema = z.object({
|
|
74
92
|
copilot: z
|
|
75
93
|
.object({
|
|
@@ -40,13 +40,14 @@ import { writeReport } from '../exec/reportFile.js';
|
|
|
40
40
|
import { Pacer } from '../util/pacing.js';
|
|
41
41
|
import { RunLog } from '../log/runLog.js';
|
|
42
42
|
import { composeOpening, operatorNotesSection, readOnlyNote } from '../session/compose.js';
|
|
43
|
+
import { takeAfter, takeCheckpoint } from '../session/checkpoint.js';
|
|
43
44
|
import { MIN_TRIED_APPROACHES } from '../protocol/replySchema.js';
|
|
44
45
|
import { enforceScope, scopeMessage, scopeNote } from '../vcs/scope.js';
|
|
45
46
|
import { PLAN_FIRST, PLAN_NOT_NOW, PLAN_NUDGE_AFTER, describePlan, planApprovedMessage, planFrom, planModeNote, planNudge, planReviseMessage } from './planMode.js';
|
|
46
47
|
import { composeHandoff } from '../session/handoff.js';
|
|
47
48
|
import { ProgressWatch } from './progress.js';
|
|
48
49
|
import { contractConflicts, readsTreeClean } from './contract.js';
|
|
49
|
-
import { treeFingerprint } from '../vcs/git.js';
|
|
50
|
+
import { commitFiles, treeFingerprint } from '../vcs/git.js';
|
|
50
51
|
import { isContinuable } from '../session/model.js';
|
|
51
52
|
import { prepareForTask, commitTaskResult, commitShortfall, repoDirOf, trackedRepoOf, whereLeft } from '../vcs/taskVcs.js';
|
|
52
53
|
import { protectInputs, inputsMessage, inputsAtCommit, untrackedInputs, blobOfFile } from '../vcs/inputs.js';
|
|
@@ -651,6 +652,19 @@ async function withOperatorHand(transport, wanted, first, hooks, sessionId, bus,
|
|
|
651
652
|
}
|
|
652
653
|
return { result, goOnAsItIs: false };
|
|
653
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* What a chat message is told about the folder (2026-10-17): it works on the operator's own branch, nothing is
|
|
657
|
+
* committed for it, and git is the operator's to ask for — unlike a task of the bot's sessions, where the runner
|
|
658
|
+
* owns the repository.
|
|
659
|
+
*/
|
|
660
|
+
const CHAT_NOTE = [
|
|
661
|
+
'## Working in the operator\'s folder',
|
|
662
|
+
'',
|
|
663
|
+
'This is the operator\'s chat in their own folder, on the branch it is on. Nothing is branched or committed for',
|
|
664
|
+
'you, and the rule against git commands that change something does not hold here: when the operator asks, you',
|
|
665
|
+
'may switch or create a branch, stage, commit, stash, pull or merge. Never push, reset, rebase or clean, and',
|
|
666
|
+
'never rewrite history; the runner refuses those. The operator can put the folder back to before any message.',
|
|
667
|
+
].join('\n');
|
|
654
668
|
/** Runs one task to completion inside an already-open transport. */
|
|
655
669
|
/** The approved plan a task works to: its own attempt's, else, for a continuation, the latest one before it. */
|
|
656
670
|
function approvedPlanOf(task) {
|
|
@@ -889,11 +903,28 @@ export async function runTask(transport, session, task, deps) {
|
|
|
889
903
|
}
|
|
890
904
|
return check;
|
|
891
905
|
};
|
|
906
|
+
/** A chat message's checkpoint and folder (2026-10-17), set where the task starts; read by `finish`. */
|
|
907
|
+
let chatCheckpoint = session.kind === 'chat' ? task.checkpoint : undefined;
|
|
908
|
+
const chatDir = session.kind === 'chat' ? session.projectDir?.trim() ?? '' : '';
|
|
892
909
|
const finish = async (status, reason, summary, finalReply) => {
|
|
893
910
|
// How it ended as reported; the runner's own checks below can still change it, and the final word is written at the end.
|
|
894
911
|
await record(`ENDING: ${status.toUpperCase()}`, [summary ?? '', reason ? `Reason: ${reason}` : ''].filter(Boolean).join('\n\n') || '(no details)');
|
|
895
912
|
// The net under the plan's own checks: whatever the task left running is stopped and named.
|
|
896
913
|
await reap(processesBefore, 'the task');
|
|
914
|
+
/*
|
|
915
|
+
* A chat message: the folder photographed again after it, on top of its checkpoint, so what it changed is
|
|
916
|
+
* one commit's worth of files, shown under the message and in the changes view. Nothing is committed on the
|
|
917
|
+
* operator's branch.
|
|
918
|
+
*/
|
|
919
|
+
if (chatCheckpoint && chatDir) {
|
|
920
|
+
const after = await takeAfter(chatDir, task.id, chatCheckpoint).catch((e) => ({ problem: e.message }));
|
|
921
|
+
if (!('problem' in after)) {
|
|
922
|
+
const files = await commitFiles(chatDir, after.commit).catch(() => []);
|
|
923
|
+
await setTask((t) => {
|
|
924
|
+
t.vcs = { baseCommit: chatCheckpoint.commit, commit: after.commit, files };
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
}
|
|
897
928
|
/*
|
|
898
929
|
* The operator's input files, once more before the commit: put back what the last round changed,
|
|
899
930
|
* so it is not committed as the task's work. One that cannot be put back fails a done task. See
|
|
@@ -1139,6 +1170,23 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1139
1170
|
t.reviewChecks = reviewChecks;
|
|
1140
1171
|
});
|
|
1141
1172
|
sink.event('task-started', { runId, title: task.title }, `task "${task.title}" starting (run ${runId})`);
|
|
1173
|
+
/*
|
|
1174
|
+
* A chat message: the folder photographed before it first runs, so the operator can go back to before it
|
|
1175
|
+
* (2026-10-17). Kept from the first attempt: a message carried on goes back to where it began.
|
|
1176
|
+
*/
|
|
1177
|
+
if (session.kind === 'chat' && !chatCheckpoint && chatDir) {
|
|
1178
|
+
const cp = await takeCheckpoint(chatDir, task.id).catch((e) => ({ problem: e.message }));
|
|
1179
|
+
if ('problem' in cp) {
|
|
1180
|
+
sink.event('chat-checkpoint-missing', { problem: cp.problem }, `no way back to before this message: ${cp.problem}`, 'warn');
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
chatCheckpoint = cp;
|
|
1184
|
+
await setTask((t) => {
|
|
1185
|
+
t.checkpoint = cp;
|
|
1186
|
+
});
|
|
1187
|
+
sink.event('chat-checkpoint', { commit: cp.commit, branch: cp.branch, head: cp.head }, `the folder before this message is kept as ${cp.commit.slice(0, 8)} (on ${cp.branch || cp.head.slice(0, 8)})`);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1142
1190
|
{
|
|
1143
1191
|
const sel = (await store.getSession(session.id))?.modelSelection;
|
|
1144
1192
|
if (sel) {
|
|
@@ -1416,7 +1464,7 @@ export async function runTask(transport, session, task, deps) {
|
|
|
1416
1464
|
// The operator's new prompt goes out whether or not the attempt it follows reached a conversation.
|
|
1417
1465
|
...(task.continuing?.instruction ? { instruction: { text: task.continuing.instruction, fromAttempt: task.continuing.fromAttempt, ended: task.continuing.ended } } : {}),
|
|
1418
1466
|
workDirNote: workingDirNote(work),
|
|
1419
|
-
vcsNote: prepared.note,
|
|
1467
|
+
vcsNote: session.kind === 'chat' ? CHAT_NOTE : prepared.note,
|
|
1420
1468
|
// What is said about a commit is true only where one happens (live run 2026-10-03: promised with commits off).
|
|
1421
1469
|
readOnlyNote: task.readOnly ? readOnlyNote(!!(session.vcs?.enabled && session.vcs.commitOnFinish !== false && trackedRepoOf(session)), artifactPatterns(session.vcs)) : undefined,
|
|
1422
1470
|
scopeNote: [
|
|
@@ -845,6 +845,14 @@ export const SYSTEM_GUIDE = [
|
|
|
845
845
|
doesEn: 'Opens the command palette (also Ctrl+K): any task, session, page or command, found by a few letters.',
|
|
846
846
|
doesBg: 'Отваря палитрата с команди (и с Ctrl+K): всяка задача, сесия, страница или команда, по няколко букви.',
|
|
847
847
|
},
|
|
848
|
+
{
|
|
849
|
+
key: 'wb.startChat',
|
|
850
|
+
kind: 'button',
|
|
851
|
+
en: 'Write in the chat',
|
|
852
|
+
bg: 'Пиши в чата',
|
|
853
|
+
doesEn: 'On the welcome: puts the keyboard in the chat on the right.',
|
|
854
|
+
doesBg: 'В поздрава: слага курсора в чата вдясно.',
|
|
855
|
+
},
|
|
848
856
|
{
|
|
849
857
|
key: 'wb.welcome',
|
|
850
858
|
kind: 'note',
|
|
@@ -1163,6 +1171,14 @@ export const SYSTEM_GUIDE = [
|
|
|
1163
1171
|
doesEn: 'The task\'s earlier attempts, with how each ended and whether it was undone.',
|
|
1164
1172
|
doesBg: 'По-ранните опити на задачата, с това как е завършил всеки и дали е отменен.',
|
|
1165
1173
|
},
|
|
1174
|
+
{
|
|
1175
|
+
key: 'wb.conversation',
|
|
1176
|
+
kind: 'disclosure',
|
|
1177
|
+
en: 'Its conversation',
|
|
1178
|
+
bg: 'Разговорът ѝ',
|
|
1179
|
+
doesEn: 'The task\'s exchange with Copilot: every message, reply and command with its output; open while it runs.',
|
|
1180
|
+
doesBg: 'Обменът на задачата с Copilot: всяко съобщение, отговор и команда с изхода ѝ; отворено, докато върви.',
|
|
1181
|
+
},
|
|
1166
1182
|
],
|
|
1167
1183
|
},
|
|
1168
1184
|
{
|
|
@@ -1198,8 +1214,8 @@ export const SYSTEM_GUIDE = [
|
|
|
1198
1214
|
kind: 'tab',
|
|
1199
1215
|
en: 'Chat',
|
|
1200
1216
|
bg: 'Чат',
|
|
1201
|
-
doesEn: 'The
|
|
1202
|
-
doesBg: '
|
|
1217
|
+
doesEn: 'The chat of the open project folder, as in an IDE: a message is sent to Copilot, the commands it answers with run in the folder and their output goes back, until it is done; shown as the conversation.',
|
|
1218
|
+
doesBg: 'Чатът на отворената папка, както в IDE: съобщението отива при Copilot, командите, с които отговаря, се изпълняват в папката и изходът им се връща, докато свърши; показва се като разговор.',
|
|
1203
1219
|
},
|
|
1204
1220
|
{
|
|
1205
1221
|
key: 'wb.kerriganTab',
|
|
@@ -1209,6 +1225,150 @@ export const SYSTEM_GUIDE = [
|
|
|
1209
1225
|
doesEn: 'Tell Kerrigan what happened and apply the changes she answers with.',
|
|
1210
1226
|
doesBg: 'Кажи на Кериган какво се случи и приложи промените, с които отговори.',
|
|
1211
1227
|
},
|
|
1228
|
+
{
|
|
1229
|
+
key: 'chat.thread',
|
|
1230
|
+
kind: 'select',
|
|
1231
|
+
en: 'Conversation',
|
|
1232
|
+
bg: 'Разговор',
|
|
1233
|
+
doesEn: 'Which conversation of the chat is shown: an earlier one, or "New conversation".',
|
|
1234
|
+
doesBg: 'Кой разговор на чата се показва: по-ранен или „Нов разговор“.',
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
key: 'chat.newThread',
|
|
1238
|
+
kind: 'select',
|
|
1239
|
+
en: 'New conversation',
|
|
1240
|
+
bg: 'Нов разговор',
|
|
1241
|
+
doesEn: 'In that list: a new conversation, made by the next message.',
|
|
1242
|
+
doesBg: 'В този списък: нов разговор, който започва със следващото съобщение.',
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
key: 'chat.newChat',
|
|
1246
|
+
kind: 'button',
|
|
1247
|
+
en: 'New conversation',
|
|
1248
|
+
bg: 'Нов разговор',
|
|
1249
|
+
doesEn: 'The + beside the list: starts a new conversation.',
|
|
1250
|
+
doesBg: 'Плюсът до списъка: започва нов разговор.',
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
key: 'chat.welcome',
|
|
1254
|
+
kind: 'note',
|
|
1255
|
+
en: 'Ask for a change in {folder}',
|
|
1256
|
+
bg: 'Поискай промяна в {folder}',
|
|
1257
|
+
doesEn: 'With no conversation chosen: what the chat works on (the open folder and its branch) and a few messages to begin with.',
|
|
1258
|
+
doesBg: 'Когато няма избран разговор: върху какво работи чатът (отворената папка и клонът ѝ) и няколко съобщения за начало.',
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
key: 'chat.openFolder',
|
|
1262
|
+
kind: 'button',
|
|
1263
|
+
en: 'Open a folder',
|
|
1264
|
+
bg: 'Отвори папка',
|
|
1265
|
+
doesEn: 'Opens the machine\'s folder dialog; the folder chosen becomes the project the chat and the Files view work on (Settings → project folder).',
|
|
1266
|
+
doesBg: 'Отваря прозореца за избор на папка; избраната става проектът, върху който работят чатът и изгледът „Файлове“ (Настройки → папка на проекта).',
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
key: 'chat.input',
|
|
1270
|
+
kind: 'field',
|
|
1271
|
+
en: 'Message to the chat',
|
|
1272
|
+
bg: 'Съобщение до чата',
|
|
1273
|
+
doesEn: 'The message: what to change or ask. Enter sends it, Shift+Enter starts a new line; while it works, what is written is added to what it is doing.',
|
|
1274
|
+
doesBg: 'Съобщението: какво да се промени или попита. Enter го изпраща, Shift+Enter започва нов ред; докато работи, написаното се добавя към това, което прави.',
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
key: 'chat.model',
|
|
1278
|
+
kind: 'select',
|
|
1279
|
+
en: 'Model',
|
|
1280
|
+
bg: 'Модел',
|
|
1281
|
+
doesEn: 'The model of this conversation (or of the next one): "As in Settings" or one the chat\'s picker offered when last read; it is chosen in Copilot when the next message runs.',
|
|
1282
|
+
doesBg: 'Моделът на този разговор (или на следващия): „Както е в Настройки“ или някой, предложен от избора в чата при последното четене; избира се в Copilot, когато тръгне следващото съобщение.',
|
|
1283
|
+
},
|
|
1284
|
+
{
|
|
1285
|
+
key: 'chat.readModels',
|
|
1286
|
+
kind: 'button',
|
|
1287
|
+
en: 'Read the latest models from Copilot',
|
|
1288
|
+
bg: 'Прочети последните модели от Copilot',
|
|
1289
|
+
doesEn: 'The ↻ beside the model: reads the models Copilot\'s own picker offers now (the browser opens for a moment; not while a conversation works).',
|
|
1290
|
+
doesBg: '↻ до модела: прочита моделите, които изборът в Copilot предлага сега (браузърът се отваря за момент; не и докато разговор работи).',
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
key: 'chat.rewind',
|
|
1294
|
+
kind: 'button',
|
|
1295
|
+
en: 'Go back to before this message',
|
|
1296
|
+
bg: 'Върни отпреди това съобщение',
|
|
1297
|
+
doesEn: 'The ↶ beside a message of yours: puts the folder back exactly as it was before that message — branch, files, uncommitted changes — and takes it and the messages after it out of the conversation; the folder as it was is kept in a safety copy, and the message goes back in the box.',
|
|
1298
|
+
doesBg: '↶ до твое съобщение: връща папката точно както беше преди него — клон, файлове, некомитнати промени — и маха него и следващите от разговора; папката, както е била, се пази като резервно копие, а съобщението се връща в полето.',
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
key: 'chat.mode',
|
|
1302
|
+
kind: 'select',
|
|
1303
|
+
en: 'How commands run',
|
|
1304
|
+
bg: 'Как се изпълняват командите',
|
|
1305
|
+
doesEn: 'Whether the commands the chat sends wait for you or run at once.',
|
|
1306
|
+
doesBg: 'Дали командите от чата чакат теб, или се изпълняват веднага.',
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
key: 'chat.modeAsk',
|
|
1310
|
+
kind: 'select',
|
|
1311
|
+
en: 'Ask before each command',
|
|
1312
|
+
bg: 'Питай преди всяка команда',
|
|
1313
|
+
doesEn: 'Each command waits on a card in the conversation: Run, Run this and the rest, or Skip.',
|
|
1314
|
+
doesBg: 'Всяка команда чака на карта в разговора: Изпълни, Изпълни тази и останалите или Пропусни.',
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
key: 'chat.modeAuto',
|
|
1318
|
+
kind: 'select',
|
|
1319
|
+
en: 'Run commands without asking',
|
|
1320
|
+
bg: 'Изпълнявай командите без питане',
|
|
1321
|
+
doesEn: 'Commands run at once, as in an unattended run; the list of forbidden commands still applies.',
|
|
1322
|
+
doesBg: 'Командите се изпълняват веднага, както при пускане без надзор; списъкът със забранени команди пак важи.',
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
key: 'chat.send',
|
|
1326
|
+
kind: 'button',
|
|
1327
|
+
en: 'Send',
|
|
1328
|
+
bg: 'Изпрати',
|
|
1329
|
+
doesEn: 'Sends the message and starts it on the branch the folder is on; nothing is asked about branches.',
|
|
1330
|
+
doesBg: 'Изпраща съобщението и го пуска на клона, на който е папката; нищо не се пита за клонове.',
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
key: 'chat.sendNote',
|
|
1334
|
+
kind: 'button',
|
|
1335
|
+
en: 'Add to it',
|
|
1336
|
+
bg: 'Добави',
|
|
1337
|
+
doesEn: 'While it works: adds the message to what it is doing; it gets it with its next report.',
|
|
1338
|
+
doesBg: 'Докато работи: добавя съобщението към това, което прави; получава го със следващия си отчет.',
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
key: 'chat.stop',
|
|
1342
|
+
kind: 'button',
|
|
1343
|
+
en: 'Stop',
|
|
1344
|
+
bg: 'Спри',
|
|
1345
|
+
doesEn: 'While it works: stops it; the message in flight ends stopped and can be carried on.',
|
|
1346
|
+
doesBg: 'Докато работи: спира го; текущото съобщение завършва спряно и може да продължи.',
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
key: 'chat.askRun',
|
|
1350
|
+
kind: 'button',
|
|
1351
|
+
en: 'Run',
|
|
1352
|
+
bg: 'Изпълни',
|
|
1353
|
+
doesEn: 'On a command waiting in the conversation: runs it.',
|
|
1354
|
+
doesBg: 'На команда, която чака в разговора: изпълнява я.',
|
|
1355
|
+
},
|
|
1356
|
+
{
|
|
1357
|
+
key: 'chat.askRunAll',
|
|
1358
|
+
kind: 'button',
|
|
1359
|
+
en: 'Run this and the rest',
|
|
1360
|
+
bg: 'Изпълни тази и останалите',
|
|
1361
|
+
doesEn: 'Runs it and stops asking for the rest of this message.',
|
|
1362
|
+
doesBg: 'Изпълнява я и спира да пита за останалото от това съобщение.',
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
key: 'chat.askSkip',
|
|
1366
|
+
kind: 'button',
|
|
1367
|
+
en: 'Skip',
|
|
1368
|
+
bg: 'Пропусни',
|
|
1369
|
+
doesEn: 'Does not run it; the chat is told and goes on.',
|
|
1370
|
+
doesBg: 'Не я изпълнява; чатът научава и продължава.',
|
|
1371
|
+
},
|
|
1212
1372
|
{
|
|
1213
1373
|
key: 'wb.toggleChat',
|
|
1214
1374
|
kind: 'button',
|