copilot-operator 0.1.50 → 0.1.52

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 (97) hide show
  1. package/README.md +587 -574
  2. package/dist/src/api/operator.controller.js +119 -1023
  3. package/dist/src/api/operator.service.js +346 -2553
  4. package/dist/src/config/schema.js +13 -0
  5. package/dist/src/orchestrator/hold.js +49 -0
  6. package/dist/src/orchestrator/leadRunner.js +559 -0
  7. package/dist/src/orchestrator/taskRunner.js +211 -39
  8. package/dist/src/plan/kerrigan.js +232 -0
  9. package/dist/src/plan/systemGuide.js +758 -3757
  10. package/dist/src/protocol/leadSchema.js +156 -0
  11. package/dist/src/protocol/parser.js +1 -1
  12. package/dist/src/session/chatNotice.js +191 -0
  13. package/dist/src/session/checkpoint.js +19 -0
  14. package/dist/src/session/compose.js +1 -1
  15. package/dist/src/session/store.js +17 -126
  16. package/dist/src/session/workspace.js +52 -5
  17. package/dist/src/transport/chatTransport.js +1 -1
  18. package/dist/src/transport/copilotTransport.js +135 -1
  19. package/dist/web/404.html +13 -16
  20. package/dist/web/_next/static/_1zhoDsMOPAH2xW702E5A/_buildManifest.js +1 -0
  21. package/dist/web/_next/static/chunks/134-ddd50a7fbb536ec8.js +1 -0
  22. package/dist/web/_next/static/chunks/163.dbd7d36584d0bb37.js +1 -0
  23. package/dist/web/_next/static/chunks/220.35531b39410e1a9f.js +1 -0
  24. package/dist/web/_next/static/chunks/548.71ac96c94136659b.js +1 -0
  25. package/dist/web/_next/static/chunks/584.6df695c5b86a75aa.js +1 -0
  26. package/dist/web/_next/static/chunks/67.9ed79e2fbfb56f26.js +1 -0
  27. package/dist/web/_next/static/chunks/714.1e2338736a70b9c7.js +1 -0
  28. package/dist/web/_next/static/chunks/747.d2c1249d736dc03b.js +1 -0
  29. package/dist/web/_next/static/chunks/77.a200abef0f5b4a7f.js +1 -0
  30. package/dist/web/_next/static/chunks/808-bc7d7eac6d823291.js +1 -0
  31. package/dist/web/_next/static/chunks/921-dc5538cd779c6432.js +1 -0
  32. package/dist/web/_next/static/chunks/app/defaults/page-edd7534ca9ecf366.js +1 -0
  33. package/dist/web/_next/static/chunks/app/layout-8f99a164d76897a0.js +1 -0
  34. package/dist/web/_next/static/chunks/app/page-4bed816eda370d0c.js +1 -0
  35. package/dist/web/_next/static/chunks/app/system/page-1cf9e75e76da59ed.js +1 -0
  36. package/dist/web/_next/static/chunks/webpack-77147e31d2125631.js +1 -0
  37. package/dist/web/_next/static/css/3bea264adc472bc8.css +1 -0
  38. package/dist/web/defaults.html +13 -16
  39. package/dist/web/defaults.txt +22 -23
  40. package/dist/web/index.html +13 -16
  41. package/dist/web/index.txt +22 -23
  42. package/dist/web/system.html +13 -16
  43. package/dist/web/system.txt +22 -23
  44. package/package.json +5 -23
  45. package/prompts/lead1.md +116 -0
  46. package/dist/src/api/saveToDesktop.js +0 -157
  47. package/dist/src/plan/brief.js +0 -2003
  48. package/dist/src/plan/changes.js +0 -217
  49. package/dist/src/plan/script.js +0 -1014
  50. package/dist/src/session/debugExport.js +0 -165
  51. package/dist/src/session/exportRecord.js +0 -277
  52. package/dist/src/session/metrics.js +0 -95
  53. package/dist/src/vcs/prepareFromRemote.js +0 -288
  54. package/dist/src/vcs/remoteAuth.js +0 -117
  55. package/dist/src/vcs/startChoice.js +0 -367
  56. package/dist/src/vcs/syncCommand.js +0 -97
  57. package/dist/web/_next/static/chunks/197-f7c33a0114fc3db3.js +0 -1
  58. package/dist/web/_next/static/chunks/499-751e0be9d4f86e2d.js +0 -1
  59. package/dist/web/_next/static/chunks/534-56c68930a1a3c10f.js +0 -1
  60. package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +0 -1
  61. package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +0 -1
  62. package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.js +0 -1
  63. package/dist/web/_next/static/chunks/app/appearance/page-a18019cdc395de3d.js +0 -1
  64. package/dist/web/_next/static/chunks/app/defaults/page-614be29d185a2947.js +0 -1
  65. package/dist/web/_next/static/chunks/app/history/page-95bab4c1b1ff9339.js +0 -1
  66. package/dist/web/_next/static/chunks/app/import/page-8ef75fc08638e75f.js +0 -1
  67. package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +0 -1
  68. package/dist/web/_next/static/chunks/app/level1/page-dd3ebf37d29dce4f.js +0 -1
  69. package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.js +0 -1
  70. package/dist/web/_next/static/chunks/app/presets/page-93ab518db67e52a2.js +0 -1
  71. package/dist/web/_next/static/chunks/app/sessions/page-28376d2e4a9b4738.js +0 -1
  72. package/dist/web/_next/static/chunks/app/sessions/view/page-adb64f8ba3d8c06e.js +0 -1
  73. package/dist/web/_next/static/chunks/app/system/page-227a259e383ca2a0.js +0 -1
  74. package/dist/web/_next/static/chunks/webpack-0f31b926d9a9c5a4.js +0 -1
  75. package/dist/web/_next/static/css/4335e4ce269ba1ea.css +0 -1
  76. package/dist/web/_next/static/z74_FBfnnXW5IJCHTgTH2/_buildManifest.js +0 -1
  77. package/dist/web/appearance.html +0 -16
  78. package/dist/web/appearance.txt +0 -26
  79. package/dist/web/history.html +0 -16
  80. package/dist/web/history.txt +0 -26
  81. package/dist/web/import.html +0 -16
  82. package/dist/web/import.txt +0 -26
  83. package/dist/web/level1.html +0 -16
  84. package/dist/web/level1.txt +0 -26
  85. package/dist/web/presets.html +0 -19
  86. package/dist/web/presets.txt +0 -26
  87. package/dist/web/sessions/view.html +0 -16
  88. package/dist/web/sessions/view.txt +0 -26
  89. package/dist/web/sessions.html +0 -16
  90. package/dist/web/sessions.txt +0 -26
  91. package/prompts/organisation.bg.md +0 -43
  92. package/prompts/organisation.en.md +0 -43
  93. package/prompts/persona.bg.md +0 -17
  94. package/prompts/persona.en.md +0 -17
  95. package/prompts/work.bg.md +0 -19
  96. package/prompts/work.en.md +0 -19
  97. /package/dist/web/_next/static/{z74_FBfnnXW5IJCHTgTH2 → _1zhoDsMOPAH2xW702E5A}/_ssgManifest.js +0 -0
@@ -1,157 +0,0 @@
1
- /**
2
- * A log, on the Desktop, with Explorer already pointing at it.
3
- *
4
- * The operator does not read these logs in a browser. They run the bot, and then they hand
5
- * what came out of it to a separate chat that orchestrates the whole effort. Offering the log
6
- * as a page in a new tab was answering a question nobody had: getting it from that tab into
7
- * the chat meant save-as, then remembering where the browser put it, then finding it again,
8
- * then dragging it. Four steps, every one of them somewhere else on the screen.
9
- *
10
- * So the log is written as a file instead, and Explorer is opened on it with the file already
11
- * selected. One press, and the thing the operator wants to drag is under the cursor. The
12
- * browser is not asked to be a file manager, because it is not one.
13
- *
14
- * The files go into one folder under the Desktop rather than loose on it. A Desktop that
15
- * slowly fills with task logs is a worse outcome than the tab ever was, and a folder that is
16
- * always the same one is also a place the operator learns, so the second log is found without
17
- * being revealed at all.
18
- *
19
- * Nothing here overwrites. A log that was saved once may already have been dragged into a
20
- * chat, attached to a message or renamed by somebody; writing over it because the same button
21
- * was pressed twice would destroy a file the bot has no claim on. Every save earns its own
22
- * name, and the timestamp in that name is what tells two saves of one attempt apart.
23
- *
24
- * Revealing is a Windows idea and this module says so plainly anywhere else, in the manner of
25
- * `folderPicker.ts`: the file is still written, and the caller is told where, so the feature
26
- * degrades to something useful rather than to an error.
27
- */
28
- import { spawn } from 'node:child_process';
29
- import { existsSync } from 'node:fs';
30
- import { mkdir, writeFile } from 'node:fs/promises';
31
- import { extname, join } from 'node:path';
32
- import { resolveDesktopDir } from '../context/desktopDir.js';
33
- /** The one folder under the Desktop that every saved log lands in. */
34
- export const LOGS_FOLDER = 'copilot-operator-logs';
35
- /** The folder every saved log goes into. */
36
- export function logsDir(env = process.env) {
37
- return join(resolveDesktopDir(env), LOGS_FOLDER);
38
- }
39
- /**
40
- * One part of a file name, made safe for NTFS.
41
- *
42
- * Session names and task titles are prose written by a human, so they carry colons, slashes
43
- * and quotation marks as a matter of course — every one of them illegal in a Windows file
44
- * name. A name Windows refuses is a save that fails for a reason the operator cannot act on,
45
- * so the illegal characters become dashes rather than a refusal. The trailing dots and spaces
46
- * go too: Windows silently drops them, which would leave the path the caller was told about
47
- * and the file actually on disk disagreeing.
48
- */
49
- export function sanitiseNamePart(part, limit = 60) {
50
- const cleaned = part
51
- .replace(/[<>:"/\\|?*\u0000-\u001f]/g, '-')
52
- .replace(/\s+/g, ' ')
53
- .trim()
54
- .slice(0, limit)
55
- .replace(/[. ]+$/, '');
56
- return cleaned.length > 0 ? cleaned : 'unnamed';
57
- }
58
- /** The timestamp in a file name: sortable, readable, and legal, so local time with no colons. */
59
- function stampOf(at) {
60
- const two = (n) => String(n).padStart(2, '0');
61
- return (`${at.getFullYear()}-${two(at.getMonth() + 1)}-${two(at.getDate())}` +
62
- `-${two(at.getHours())}${two(at.getMinutes())}${two(at.getSeconds())}`);
63
- }
64
- /**
65
- * The name a saved log is given: the session, the task, the attempt and when it was saved.
66
- *
67
- * All four are there because the operator ends up with a folder of these and has to tell them
68
- * apart by sight, in the drag-and-drop list of a chat, without opening any of them.
69
- */
70
- export function logFileName(naming, at = new Date()) {
71
- const parts = [sanitiseNamePart(naming.session, 40), sanitiseNamePart(naming.task, 60)];
72
- if (naming.attempt !== undefined)
73
- parts.push(`attempt ${naming.attempt}`);
74
- // A task's own file keeps its extension; the consolidated log is text and says so.
75
- const extension = naming.file ? extname(naming.file) || '.txt' : '.txt';
76
- if (naming.file) {
77
- const stem = naming.file.slice(0, naming.file.length - extname(naming.file).length);
78
- parts.push(sanitiseNamePart(stem, 50));
79
- }
80
- parts.push(stampOf(at));
81
- return `${parts.join(' - ')}${extension}`;
82
- }
83
- /**
84
- * The asked-for name, or the first free variation of it.
85
- *
86
- * Two saves inside the same second collide on the timestamp, and so does a folder restored
87
- * from a backup. Windows' own ` (2)` suffix is used because the operator has seen it before
88
- * and knows what it means.
89
- */
90
- export function freeName(dir, fileName, taken = existsSync) {
91
- if (!taken(join(dir, fileName)))
92
- return fileName;
93
- const extension = extname(fileName);
94
- const stem = fileName.slice(0, fileName.length - extension.length);
95
- for (let n = 2; n < 1000; n += 1) {
96
- const candidate = `${stem} (${n})${extension}`;
97
- if (!taken(join(dir, candidate)))
98
- return candidate;
99
- }
100
- // A thousand collisions is not a folder anyone is still reading, so stop guessing politely.
101
- return `${stem} (${Date.now()})${extension}`;
102
- }
103
- /**
104
- * Explorer, opened on the folder with the file selected.
105
- *
106
- * `explorer.exe` exits with a non-zero code when it has done exactly what was asked, which is
107
- * long-standing and documented behaviour rather than a bug to work around, so the exit code is
108
- * ignored entirely. Only a failure to start the process at all means the reveal did not
109
- * happen. The arguments go through verbatim because Explorer parses `/select,"<path>"` itself
110
- * and Node's own quoting of an argument with spaces in it would leave it parsing something
111
- * else.
112
- *
113
- * `windowsHide` is deliberately not set, unlike everywhere else in this codebase that starts a
114
- * process: it asks Windows to start the child with its window hidden, and a hidden window is
115
- * the exact opposite of the point here. Explorer is a windowed program with no console of its
116
- * own, so nothing flashes for leaving it off.
117
- */
118
- export const revealInExplorer = (path) => new Promise((settle, fail) => {
119
- const child = spawn('explorer.exe', [`/select,"${path}"`], {
120
- windowsVerbatimArguments: true,
121
- detached: true,
122
- stdio: 'ignore',
123
- });
124
- child.on('error', fail);
125
- // Explorer outlives the API process; nothing here waits for it to close.
126
- child.on('spawn', () => {
127
- child.unref();
128
- settle();
129
- });
130
- });
131
- /**
132
- * Writes the text to the Desktop folder and opens Explorer on it.
133
- *
134
- * Failing to reveal is not failing to save. The file is on disk either way and the caller is
135
- * told where, because a path the operator can paste into an address bar is still most of what
136
- * they wanted.
137
- */
138
- export async function saveAndReveal(text, naming, options = {}) {
139
- const env = options.env ?? process.env;
140
- const platform = options.platform ?? process.platform;
141
- const dir = logsDir(env);
142
- await mkdir(dir, { recursive: true });
143
- const fileName = freeName(dir, logFileName(naming, options.now ?? new Date()));
144
- const path = join(dir, fileName);
145
- await writeFile(path, text, 'utf8');
146
- if (platform !== 'win32') {
147
- return { path, dir, fileName, revealed: false, note: 'Opening the folder is Windows-only. The file was saved.' };
148
- }
149
- const reveal = options.reveal ?? revealInExplorer;
150
- try {
151
- await reveal(path);
152
- return { path, dir, fileName, revealed: true };
153
- }
154
- catch (e) {
155
- return { path, dir, fileName, revealed: false, note: `The file was saved, but Explorer did not open: ${e.message}` };
156
- }
157
- }