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.
Files changed (72) hide show
  1. package/README.md +24 -3
  2. package/dist/src/api/operator.controller.js +55 -71
  3. package/dist/src/api/operator.service.js +243 -109
  4. package/dist/src/config/schema.js +45 -0
  5. package/dist/src/exec/policy.js +11 -1
  6. package/dist/src/exec/scriptFiles.js +108 -2
  7. package/dist/src/orchestrator/leadRunner.js +605 -0
  8. package/dist/src/orchestrator/review.js +9 -3
  9. package/dist/src/orchestrator/taskRunner.js +110 -20
  10. package/dist/src/plan/kerrigan.js +203 -47
  11. package/dist/src/plan/systemGuide.js +555 -499
  12. package/dist/src/protocol/leadSchema.js +156 -0
  13. package/dist/src/protocol/parser.js +1 -1
  14. package/dist/src/session/chatNotice.js +115 -0
  15. package/dist/src/session/checkpoint.js +19 -0
  16. package/dist/src/session/compose.js +17 -5
  17. package/dist/src/session/store.js +21 -72
  18. package/dist/src/transport/copilotTransport.js +2 -0
  19. package/dist/src/util/pacing.js +33 -2
  20. package/dist/src/vcs/git.js +11 -1
  21. package/dist/src/vcs/referenceGuard.js +299 -0
  22. package/dist/web/404.html +14 -18
  23. package/dist/web/_next/static/FGzV3mVZpXRCVjiw1diNu/_buildManifest.js +1 -0
  24. package/dist/web/_next/static/chunks/163.980c5145848efbdf.js +1 -0
  25. package/dist/web/_next/static/chunks/220.447d1d8624d4644c.js +1 -0
  26. package/dist/web/_next/static/chunks/500-34d01f8d8d73eb2c.js +1 -0
  27. package/dist/web/_next/static/chunks/548.c6dfd1cb270f3c93.js +1 -0
  28. package/dist/web/_next/static/chunks/584.fc9e061dd4069406.js +1 -0
  29. package/dist/web/_next/static/chunks/67.1a3ca07919abce27.js +1 -0
  30. package/dist/web/_next/static/chunks/714.5b2e291a430adc9c.js +1 -0
  31. package/dist/web/_next/static/chunks/747.157732b5b3f3c435.js +1 -0
  32. package/dist/web/_next/static/chunks/77.d478a6f2eafe31e3.js +1 -0
  33. package/dist/web/_next/static/chunks/921-b2219533c5a6e38f.js +1 -0
  34. package/dist/web/_next/static/chunks/app/defaults/page-b7e4e94a55e65806.js +1 -0
  35. package/dist/web/_next/static/chunks/app/layout-2b3718748721c1ac.js +1 -0
  36. package/dist/web/_next/static/chunks/app/page-59b9867b52914a6c.js +1 -0
  37. package/dist/web/_next/static/chunks/app/system/page-1cf9e75e76da59ed.js +1 -0
  38. package/dist/web/_next/static/chunks/webpack-0c3cad1f3181d857.js +1 -0
  39. package/dist/web/_next/static/css/06f314fa5fccd68d.css +1 -0
  40. package/dist/web/defaults.html +14 -18
  41. package/dist/web/defaults.txt +9 -9
  42. package/dist/web/index.html +14 -18
  43. package/dist/web/index.txt +9 -9
  44. package/dist/web/system.html +14 -18
  45. package/dist/web/system.txt +9 -9
  46. package/package.json +8 -5
  47. package/prompts/lead1.md +116 -0
  48. package/prompts/level1.md +32 -12
  49. package/prompts/review1.md +287 -286
  50. package/dist/src/vcs/prepareFromRemote.js +0 -288
  51. package/dist/src/vcs/remoteAuth.js +0 -117
  52. package/dist/src/vcs/syncCommand.js +0 -97
  53. package/dist/web/_next/static/chunks/190-70555f20dd0da19b.js +0 -1
  54. package/dist/web/_next/static/chunks/643-e85d221d57900ed7.js +0 -1
  55. package/dist/web/_next/static/chunks/867-869900ec999e6345.js +0 -1
  56. package/dist/web/_next/static/chunks/app/appearance/page-cdef33c421397cbe.js +0 -1
  57. package/dist/web/_next/static/chunks/app/defaults/page-e0a2b8f9a41a94c4.js +0 -1
  58. package/dist/web/_next/static/chunks/app/layout-b4fc21e26e1bad95.js +0 -1
  59. package/dist/web/_next/static/chunks/app/level1/page-31b74cae86d960d8.js +0 -1
  60. package/dist/web/_next/static/chunks/app/page-1075921d44db3e4d.js +0 -1
  61. package/dist/web/_next/static/chunks/app/presets/page-f8abdd83cdf468f7.js +0 -1
  62. package/dist/web/_next/static/chunks/app/system/page-2a270bb885885821.js +0 -1
  63. package/dist/web/_next/static/chunks/webpack-0f31b926d9a9c5a4.js +0 -1
  64. package/dist/web/_next/static/css/8b14cb3cf0051138.css +0 -1
  65. package/dist/web/_next/static/eqTUTH_SJtBgNgq8Zzy3n/_buildManifest.js +0 -1
  66. package/dist/web/appearance.html +0 -18
  67. package/dist/web/appearance.txt +0 -25
  68. package/dist/web/level1.html +0 -18
  69. package/dist/web/level1.txt +0 -25
  70. package/dist/web/presets.html +0 -21
  71. package/dist/web/presets.txt +0 -25
  72. /package/dist/web/_next/static/{eqTUTH_SJtBgNgq8Zzy3n → FGzV3mVZpXRCVjiw1diNu}/_ssgManifest.js +0 -0
package/README.md CHANGED
@@ -412,12 +412,33 @@ Open a project folder, write what to change in the chat on the right, approve ea
412
412
  the conversation (or let them run without asking), and read the summary when it finishes. The
413
413
  files of the folder are on the left, with its git; a file opens in the editor, coloured by its
414
414
  language, and can be edited and saved. "Plan mode" under the chat's box asks Copilot for a plan
415
- first, shown in the conversation to approve. "Pause" holds the work at its next message or command
416
- and becomes "Continue". "Kerrigan" on the home screen hands out a persona to
417
- give another chat, which then helps you write tasks for this one (optional). See
415
+ first, shown in the conversation to approve; "Review" has a conversation of its own check the work
416
+ when Copilot says it is done. "Two chats" gives a complex task to a lead, which plans and directs,
417
+ and a worker, which runs the commands of each subtask and reports back — two conversations in the
418
+ same Copilot window, the lead asking you only what nobody else can decide. "Pause" holds the work at its next message or command and becomes
419
+ "Continue". The interface speaks nine languages (English, Bulgarian, German, Spanish, French,
420
+ Portuguese, Japanese, Korean, Arabic), chosen from "Language". "Kerrigan" on the home screen hands out a persona to
421
+ give another chat, which then helps you write tasks for this one (optional); she knows your projects,
422
+ with the level 2 you write for each in Settings. A project in Settings can be marked "For
423
+ reference only": the bot reads it and runs what only reads it, and whatever a command changes there
424
+ — files, branches, what is staged — is put back after that command, and the chat is told. See
418
425
  [`docs/ui.md`](docs/ui.md); the Sessions page, the task register and plans from JSON were removed
419
426
  on 2026-10-20.
420
427
 
428
+ Skills keep your instructions for a kind of task that comes back — a new test, a new entity, a migration — in
429
+ Settings; a message starting with `/its-name` (or with the skill chosen under the chat's box) carries them to the
430
+ chat. The three panels move as in VS Code: drag the grip ⠿ in a panel's head onto another. Settings can also make
431
+ the bot pause between messages to Copilot, by a fixed or a random time.
432
+
433
+ **What runs, and how.** Every command the chat sends is given to PowerShell as text
434
+ (`pwsh -NoProfile -NonInteractive -Command "…"`); the bot writes no script to run it. A script file
435
+ — `.ps1`, `.cmd`, `.bat`, `.sh`, `.vbs` — runs only when it is the project's own: committed in its
436
+ repository, unchanged since, and committed before the work began. One the chat wrote, changed or
437
+ downloaded is refused however it is called, and nothing in `.cop-tmp` is run. The project's tools
438
+ go on as usual — `npm test`, `npm run build`, `dotnet test`, `node` starting the application.
439
+ Downloads wait for you even in an unattended run, `npm install` runs no install scripts, and the
440
+ package itself has none.
441
+
421
442
  ### Removing it from a machine
422
443
 
423
444
  Nothing is installed system-wide, nothing runs at start-up, no service and no scheduled task
@@ -19,7 +19,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
19
19
  * What is here is what the chat and its workbench use, with Settings and Kerrigan (2026-10-20: the sessions, the task
20
20
  * register and the plan from JSON were removed, and their routes with them).
21
21
  */
22
- import { Body, Controller, Delete, Get, Inject, Param, Post, Put, Query, Res, NotFoundException, BadRequestException, ConflictException } from '@nestjs/common';
22
+ import { Body, Controller, Get, Inject, Param, Post, Put, Query, Res, NotFoundException, BadRequestException, ConflictException } from '@nestjs/common';
23
23
  import { OperatorService } from './operator.service.js';
24
24
  import { SettingsUnusableError } from './settings.js';
25
25
  import { PolicyLockUnusableError } from '../config/lockedPolicy.js';
@@ -83,34 +83,16 @@ let OperatorController = class OperatorController {
83
83
  return { ok: true };
84
84
  }
85
85
  // --- level 1 ----------------------------------------------------------------------------
86
+ /** The contract the bot gives Copilot, as it ships: shown in Settings to read, changed only by an update of the bot. */
86
87
  level1() {
87
88
  return this.ops.getLevel1();
88
89
  }
89
- async setLevel1(body) {
90
- if (typeof body?.content !== 'string' || body.content.trim().length < 100) {
91
- throw new BadRequestException('Level 1 must be a real contract, not a few words.');
92
- }
93
- await this.ops.setLevel1(body.content);
94
- return { ok: true };
95
- }
96
- resetLevel1() {
97
- return this.ops.resetLevel1();
98
- }
99
- // --- level 2 presets --------------------------------------------------------------------
100
- presets() {
101
- return this.ops.listPresets();
102
- }
103
- savePreset(name, body) {
104
- return this.ops.savePreset(name, body?.content ?? '').catch(fail);
105
- }
106
- async deletePreset(name) {
107
- await this.ops.deletePreset(name).catch(fail);
108
- return { ok: true };
109
- }
110
90
  // --- Kerrigan -------------------------------------------------------------------------------
111
91
  /** Kerrigan, the persona to give another chat: what copilot-operator is and how a task is best written for it. */
112
92
  kerrigan(lang) {
113
- return this.ops.kerrigan(lang === 'bg' ? 'bg' : 'en').catch(fail);
93
+ // Any language code of the interface: in one she is not written out in, the page fills in the controls' names.
94
+ const code = typeof lang === 'string' && /^[a-z]{2,3}$/.test(lang) ? lang : 'en';
95
+ return this.ops.kerrigan(code).catch(fail);
114
96
  }
115
97
  // --- the chat's conversations (sessions of kind `chat`) -------------------------------------
116
98
  sessions() {
@@ -273,8 +255,16 @@ let OperatorController = class OperatorController {
273
255
  ...(typeof body.threadId === 'string' && body.threadId ? { threadId: body.threadId } : {}),
274
256
  ...(typeof body.model === 'string' && body.model.trim() ? { model: body.model } : {}),
275
257
  ...(body.manualModel === true ? { manualModel: true } : {}),
276
- ...(body.lang === 'bg' || body.lang === 'en' ? { lang: body.lang } : {}),
258
+ // The page's language, any of the interface's (`web/lib/lang/languages.ts`): the window's card says it in it.
259
+ ...(typeof body.lang === 'string' && /^[a-z]{2,3}$/.test(body.lang) ? { lang: body.lang } : {}),
277
260
  ...(body.planMode === true ? { planMode: true } : {}),
261
+ ...(typeof body.review === 'boolean' ? { review: body.review } : {}),
262
+ // Two chats, for a new conversation: a lead that directs and a worker that carries out (2026-10-20).
263
+ ...(body.lead === true ? { lead: true } : {}),
264
+ ...(typeof body.workerModel === 'string' && body.workerModel.trim() ? { workerModel: body.workerModel } : {}),
265
+ ...(body.workerManualModel === true ? { workerManualModel: true } : {}),
266
+ // The skill chosen for this message (2026-10-21), by its name.
267
+ ...(typeof body.skill === 'string' && body.skill.trim() ? { skill: body.skill } : {}),
278
268
  })
279
269
  .catch(fail);
280
270
  }
@@ -297,6 +287,13 @@ let OperatorController = class OperatorController {
297
287
  }
298
288
  return this.ops.decide(id, body.action);
299
289
  }
290
+ /** The lead's question (two chats): the operator's answer, as text. Stopping the task is `approvals/:id` with abort. */
291
+ answerQuestion(id, body) {
292
+ const result = this.ops.answerQuestion(id, typeof body?.text === 'string' ? body.text : '');
293
+ if (!result.ok)
294
+ throw new BadRequestException(result.problem);
295
+ return result;
296
+ }
300
297
  /** A plan waiting for approval (plan mode): approve it, with a note or not; ask for another; or stop the task. */
301
298
  decidePlan(id, body) {
302
299
  if (!['approve', 'revise', 'stop'].includes(body?.action ?? ''))
@@ -319,15 +316,29 @@ let OperatorController = class OperatorController {
319
316
  }
320
317
  /** Stores it. A field left out is kept; an empty `rootDir` clears the default. */
321
318
  setProject(body) {
322
- return this.ops.setProject({ rootDir: body?.rootDir, name: body?.name, others: body?.others }).catch(fail);
319
+ const text = (v) => (typeof v === 'string' ? v : undefined);
320
+ const flag = (v) => (typeof v === 'boolean' ? v : undefined);
321
+ const others = Array.isArray(body?.others)
322
+ ? body.others.map((o) => ({
323
+ name: String(o?.name ?? ''),
324
+ rootDir: String(o?.rootDir ?? ''),
325
+ ...(typeof o?.level2 === 'string' ? { level2: o.level2 } : {}),
326
+ ...(typeof o?.readOnly === 'boolean' ? { readOnly: o.readOnly } : {}),
327
+ }))
328
+ : undefined;
329
+ return this.ops
330
+ .setProject({ rootDir: text(body?.rootDir), name: text(body?.name), level2: text(body?.level2), readOnly: flag(body?.readOnly), ...(others ? { others } : {}) })
331
+ .catch(fail);
323
332
  }
324
- /** "Prepare the folder from the remote main branch": what it would do (fetches, changes nothing else). */
325
- repoPreparePreview(body) {
326
- return this.ops.preparePreview(body?.dir ?? '', body?.fetch !== false).catch(fail);
333
+ // --- skills (2026-10-21) ---------------------------------------------------------------------
334
+ skills() {
335
+ return this.ops.skills();
327
336
  }
328
- /** …and doing it, if the folder is still what the preview showed. */
329
- repoPrepare(body) {
330
- return this.ops.prepareProject(body?.dir ?? '', body?.fingerprint ?? '', { savedBranch: body?.savedBranch, savedMainBranch: body?.savedMainBranch }).catch(fail);
337
+ /** The whole list, as Settings show it: each skill's name, what it is for, its instructions and its project. */
338
+ setSkills(body = {}) {
339
+ if (!Array.isArray(body?.skills))
340
+ throw new BadRequestException('skills must be a list');
341
+ return this.ops.setSkills(body.skills).catch(fail);
331
342
  }
332
343
  // --- the model picker ---------------------------------------------------------------------
333
344
  /** The cached list. Returns null when the picker has never been read on this machine. */
@@ -393,40 +404,6 @@ __decorate([
393
404
  __metadata("design:paramtypes", []),
394
405
  __metadata("design:returntype", Promise)
395
406
  ], OperatorController.prototype, "level1", null);
396
- __decorate([
397
- Put('level1'),
398
- __param(0, Body()),
399
- __metadata("design:type", Function),
400
- __metadata("design:paramtypes", [Object]),
401
- __metadata("design:returntype", Promise)
402
- ], OperatorController.prototype, "setLevel1", null);
403
- __decorate([
404
- Delete('level1'),
405
- __metadata("design:type", Function),
406
- __metadata("design:paramtypes", []),
407
- __metadata("design:returntype", Promise)
408
- ], OperatorController.prototype, "resetLevel1", null);
409
- __decorate([
410
- Get('presets'),
411
- __metadata("design:type", Function),
412
- __metadata("design:paramtypes", []),
413
- __metadata("design:returntype", Promise)
414
- ], OperatorController.prototype, "presets", null);
415
- __decorate([
416
- Put('presets/:name'),
417
- __param(0, Param('name')),
418
- __param(1, Body()),
419
- __metadata("design:type", Function),
420
- __metadata("design:paramtypes", [String, Object]),
421
- __metadata("design:returntype", Promise)
422
- ], OperatorController.prototype, "savePreset", null);
423
- __decorate([
424
- Delete('presets/:name'),
425
- __param(0, Param('name')),
426
- __metadata("design:type", Function),
427
- __metadata("design:paramtypes", [String]),
428
- __metadata("design:returntype", Promise)
429
- ], OperatorController.prototype, "deletePreset", null);
430
407
  __decorate([
431
408
  Get('kerrigan'),
432
409
  __param(0, Query('lang')),
@@ -634,6 +611,14 @@ __decorate([
634
611
  __metadata("design:paramtypes", [String, Object]),
635
612
  __metadata("design:returntype", Object)
636
613
  ], OperatorController.prototype, "decide", null);
614
+ __decorate([
615
+ Post('approvals/:id/answer'),
616
+ __param(0, Param('id')),
617
+ __param(1, Body()),
618
+ __metadata("design:type", Function),
619
+ __metadata("design:paramtypes", [String, Object]),
620
+ __metadata("design:returntype", Object)
621
+ ], OperatorController.prototype, "answerQuestion", null);
637
622
  __decorate([
638
623
  Post('approvals/:id/plan'),
639
624
  __param(0, Param('id')),
@@ -662,19 +647,18 @@ __decorate([
662
647
  __metadata("design:returntype", Promise)
663
648
  ], OperatorController.prototype, "setProject", null);
664
649
  __decorate([
665
- Post('repo/prepare/preview'),
666
- __param(0, Body()),
650
+ Get('skills'),
667
651
  __metadata("design:type", Function),
668
- __metadata("design:paramtypes", [Object]),
652
+ __metadata("design:paramtypes", []),
669
653
  __metadata("design:returntype", Promise)
670
- ], OperatorController.prototype, "repoPreparePreview", null);
654
+ ], OperatorController.prototype, "skills", null);
671
655
  __decorate([
672
- Post('repo/prepare'),
656
+ Put('skills'),
673
657
  __param(0, Body()),
674
658
  __metadata("design:type", Function),
675
659
  __metadata("design:paramtypes", [Object]),
676
660
  __metadata("design:returntype", Promise)
677
- ], OperatorController.prototype, "repoPrepare", null);
661
+ ], OperatorController.prototype, "setSkills", null);
678
662
  __decorate([
679
663
  Get('models'),
680
664
  __metadata("design:type", Function),