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
package/dist/src/exec/policy.js
CHANGED
|
@@ -5,7 +5,7 @@ import { inlineCodeRefusal, programRefusal } from './programs.js';
|
|
|
5
5
|
import { unattendedIsolationRefusal } from './isolation.js';
|
|
6
6
|
import { confinementRefusal } from './confinement.js';
|
|
7
7
|
import { botSelfRefusal, networkFetchReason, networkFetchRefusal } from './network.js';
|
|
8
|
-
import { scriptFileRefusal } from './scriptFiles.js';
|
|
8
|
+
import { ownScriptRefusal, scriptFileRefusal } from './scriptFiles.js';
|
|
9
9
|
export function describeStep(step) {
|
|
10
10
|
// The shell it will really be read by, not the one this file used to assume: a line in the
|
|
11
11
|
// log that names an interpreter the machine has not got explains the wrong failure.
|
|
@@ -173,6 +173,16 @@ export function unattendedPrecondition(cfg) {
|
|
|
173
173
|
* decision when it is refused without asking anyone.
|
|
174
174
|
*/
|
|
175
175
|
export function staticCheck(step, cfg, env = process.env, confinement) {
|
|
176
|
+
/*
|
|
177
|
+
* Only the project's own scripts, and nothing from .cop-tmp (operator, 2026-10-21): a script the chat wrote is not
|
|
178
|
+
* run, however it is called. First, so the chat is told that, and not the older advice of the shared gate to write
|
|
179
|
+
* a script in one step and run it in the next. See `scriptFiles.ts`.
|
|
180
|
+
*/
|
|
181
|
+
if (confinement) {
|
|
182
|
+
const own = ownScriptRefusal(step.cmd, confinement.cwd, confinement.workStartedAt);
|
|
183
|
+
if (own)
|
|
184
|
+
return { action: 'skip', reason: own };
|
|
185
|
+
}
|
|
176
186
|
// Screened against the shell that will actually read it: the traps in `shellExecuteTrap.ts`
|
|
177
187
|
// are shell-specific, so screening for one interpreter and running in another finds nothing.
|
|
178
188
|
const reason = commandRefusal(step.cmd, effectiveShell(step.shell), cfg.denyPatterns, cfg.allowedPrograms, env, confinement);
|
|
@@ -18,9 +18,19 @@
|
|
|
18
18
|
* Covered: PowerShell scripts given to `-File`, dot-sourced, or called with `&` or by path. Not
|
|
19
19
|
* covered, and stated so: a `.js`, `.py` or `.cs` file a project's own tools run. Those are the
|
|
20
20
|
* project's code, and this runner has never claimed to read it; the boundary there is isolation.
|
|
21
|
+
*
|
|
22
|
+
* And since 2026-10-21, for the chat's steps, a third rule (`ownScriptRefusal`): only the project's own scripts run
|
|
23
|
+
* at all. The operator: "I do not want the project to run scripts downloaded from the internet, or ones it created
|
|
24
|
+
* itself — everything is dynamic, not from files", then "that is for scripts from the internet; the ones that are
|
|
25
|
+
* part of it and needed stay", and "npm and the like of course; I mean only scripts from files, not whether the bot
|
|
26
|
+
* runs the tests or the back end". What the chat writes comes from Copilot, a service on the internet, so a script
|
|
27
|
+
* it wrote is a script from the internet. A script file a step runs must therefore be the project's own: committed
|
|
28
|
+
* in its repository, unchanged since, last committed by someone other than the runner and before the work began;
|
|
29
|
+
* nothing is run from `.cop-tmp`. What a step does it says in the step itself, which may be several lines.
|
|
21
30
|
*/
|
|
22
|
-
import { readFileSync, statSync } from 'node:fs';
|
|
23
|
-
import { isAbsolute, resolve } from 'node:path';
|
|
31
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
32
|
+
import { dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
33
|
+
import { gitSync, RUNNER_EMAIL } from '../vcs/git.js';
|
|
24
34
|
/** Larger than this is not a step's script; it is not read, and running it is refused. */
|
|
25
35
|
const MAX_SCRIPT_BYTES = 256 * 1024;
|
|
26
36
|
/** Paths of PowerShell scripts this command line runs, as written. */
|
|
@@ -79,3 +89,99 @@ export function scriptFileRefusal(command, cwd, screen) {
|
|
|
79
89
|
}
|
|
80
90
|
return null;
|
|
81
91
|
}
|
|
92
|
+
/** The folder for scratch files (`vcs/artifacts.ts` keeps it out of every commit); nothing in it is run. */
|
|
93
|
+
const SCRATCH = '.cop-tmp';
|
|
94
|
+
/** A program that runs a file it is given: the shells, the scripting runtimes, the TypeScript runners. */
|
|
95
|
+
const RUNS_A_FILE = String.raw `(?:node|nodejs|python3?|py|pwsh|powershell|cmd|tsx|ts-node|deno|bun|ruby|perl|php|cscript|wscript|bash|sh|java|dotnet|npx|vitest|jest|mocha)`;
|
|
96
|
+
/**
|
|
97
|
+
* The script files a command line runs — PowerShell's `.ps1` and `.psm1`, cmd's `.cmd` and `.bat`, bash's `.sh`,
|
|
98
|
+
* Windows Script Host's `.vbs`, `.wsf` and the rest — as full paths:
|
|
99
|
+
* given to `-File`, dot-sourced, called with `&` or by a path, passed to `cmd /c`, started with Start-Process, or
|
|
100
|
+
* imported as a module. A bare name counts only when that file is in the folder, where cmd and Start-Process look
|
|
101
|
+
* first; otherwise it is a program found on PATH — `npm.cmd`, `npx.cmd` — and not one of the project's files.
|
|
102
|
+
*/
|
|
103
|
+
export function shellScriptsRun(command, cwd) {
|
|
104
|
+
const named = new Set(scriptPathsRun(command));
|
|
105
|
+
const patterns = [
|
|
106
|
+
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.(?:ps1|psm1|cmd|bat))"|'([^']+\.(?:ps1|psm1|cmd|bat))'|(\S+\.(?:ps1|psm1|cmd|bat)))(?=\s|$)/gi,
|
|
107
|
+
/\bcmd(?:\.exe)?\b[^|;\n]*?\s\/[ck]\s+(?:"([^"]+\.(?:cmd|bat))"|'([^']+\.(?:cmd|bat))'|(\S+\.(?:cmd|bat)))/gi,
|
|
108
|
+
/\b(?:Start-Process|saps)\b[^|;\n]*?(?:"([^"]+\.(?:ps1|cmd|bat))"|'([^']+\.(?:ps1|cmd|bat))'|([^\s'",]+\.(?:ps1|cmd|bat)))/gi,
|
|
109
|
+
/\b(?:Import-Module|ipmo)\b[^|;\n]*?(?:"([^"]+\.psm1)"|'([^']+\.psm1)'|(\S+\.psm1))/gi,
|
|
110
|
+
// A shell script for bash and its kin (Git Bash, WSL), by a path or given to the shell.
|
|
111
|
+
/(?:^|[|;&(\n{]\s*)(?:"([^"]+\.(?:sh|bash|zsh))"|'([^']+\.(?:sh|bash|zsh))'|(\S+\.(?:sh|bash|zsh)))(?=\s|$)/gi,
|
|
112
|
+
/\b(?:bash|sh|zsh|ksh|dash|wsl)(?:\.exe)?\b[^|;\n]*?\s(?:"([^"]+\.(?:sh|bash|zsh))"|'([^']+\.(?:sh|bash|zsh))'|(\S+\.(?:sh|bash|zsh)))/gi,
|
|
113
|
+
// Windows Script Host's scripts.
|
|
114
|
+
/\b(?:wscript|cscript)(?:\.exe)?\b[^|;\n]*?\s(?:"([^"]+\.(?:vbs|vbe|js|jse|wsf|wsh))"|'([^']+\.(?:vbs|vbe|js|jse|wsf|wsh))'|(\S+\.(?:vbs|vbe|js|jse|wsf|wsh)))/gi,
|
|
115
|
+
/(?:^|[|;&(\n{]\s*)(?:[.&]\s+)?(?:"([^"]+\.(?:vbs|vbe|wsf|wsh|hta))"|'([^']+\.(?:vbs|vbe|wsf|wsh|hta))'|(\S+\.(?:vbs|vbe|wsf|wsh|hta)))(?=\s|$)/gi,
|
|
116
|
+
];
|
|
117
|
+
for (const re of patterns) {
|
|
118
|
+
for (const m of command.matchAll(re)) {
|
|
119
|
+
const p = (m[1] ?? m[2] ?? m[3] ?? '').trim();
|
|
120
|
+
if (p)
|
|
121
|
+
named.add(p);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const files = new Set();
|
|
125
|
+
for (const p of named) {
|
|
126
|
+
const full = isAbsolute(p) ? p : resolve(cwd, p);
|
|
127
|
+
if (!/[\\/]/.test(p) && !existsSync(full))
|
|
128
|
+
continue;
|
|
129
|
+
files.add(full);
|
|
130
|
+
}
|
|
131
|
+
return [...files];
|
|
132
|
+
}
|
|
133
|
+
/** Whether a path lies in the scratch folder, at any depth. */
|
|
134
|
+
const inScratch = (path) => path.split(/[\\/]+/).some((part) => part.toLowerCase() === SCRATCH);
|
|
135
|
+
/**
|
|
136
|
+
* Why a script is not one of the project's own, or null when it is: in its repository, committed, unchanged since,
|
|
137
|
+
* last committed by someone other than the runner and, when `since` is known, before the work began.
|
|
138
|
+
*/
|
|
139
|
+
export function notTheProjects(file, since) {
|
|
140
|
+
if (inScratch(file))
|
|
141
|
+
return `it is in ${SCRATCH}, the folder for scratch files, and nothing there is run`;
|
|
142
|
+
if (!existsSync(file))
|
|
143
|
+
return 'it does not exist';
|
|
144
|
+
const top = gitSync(dirname(file), ['rev-parse', '--show-toplevel']);
|
|
145
|
+
if (!top.ok || !top.stdout)
|
|
146
|
+
return 'it is not in a git repository, so nothing tells it apart from a script written during the work';
|
|
147
|
+
const rel = relative(top.stdout, file);
|
|
148
|
+
const path = rel && !rel.startsWith('..') && !isAbsolute(rel) ? rel.replace(/\\/g, '/') : file;
|
|
149
|
+
if (!gitSync(top.stdout, ['ls-files', '--error-unmatch', '--', path]).ok)
|
|
150
|
+
return 'it is not committed in its repository';
|
|
151
|
+
const diff = gitSync(top.stdout, ['diff', '--quiet', 'HEAD', '--', path]);
|
|
152
|
+
if (diff.code === 1)
|
|
153
|
+
return 'it was changed since it was last committed';
|
|
154
|
+
if (!diff.ok)
|
|
155
|
+
return `git could not compare it with its last commit${diff.stderr ? ` (${diff.stderr.split('\n')[0]})` : ''}`;
|
|
156
|
+
const last = gitSync(top.stdout, ['log', '-1', '--format=%ae%x09%ct', '--', path]);
|
|
157
|
+
const [email = '', time = ''] = last.stdout.split('\t');
|
|
158
|
+
if (email.trim().toLowerCase() === RUNNER_EMAIL)
|
|
159
|
+
return 'its last commit was made by copilot-operator, so it was written during the work';
|
|
160
|
+
const began = since ? Date.parse(since) : NaN;
|
|
161
|
+
if (Number.isFinite(began) && Number(time) * 1000 >= began - 1000)
|
|
162
|
+
return 'it was committed after this work began, so it was written during the work';
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Why a chat's step must not run a script, or null: a shell script that is not one of the project's own (see
|
|
167
|
+
* `notTheProjects`), or any file in `.cop-tmp` given to a program that runs it. Only for the chat's steps, the
|
|
168
|
+
* implementer's and the reviewer's: the operator's own checks are theirs to point at whatever they choose.
|
|
169
|
+
*/
|
|
170
|
+
export function ownScriptRefusal(command, cwd, since) {
|
|
171
|
+
// A file of code in it, given to a program that runs files — not its output written there (`node x.js > .cop-tmp\out.txt`).
|
|
172
|
+
const scratch = new RegExp(String.raw `\b${RUNS_A_FILE}(?:\.exe|\.cmd)?\b[^|;\n]*?(?:^|[\s'"=(,:])(?:\.[\\/])?(?:[^\s'"|;]*[\\/])?\.cop-tmp[\\/][^\s'"|;]*\.(?:ps1|psm1|cmd|bat|js|mjs|cjs|jsx|ts|mts|cts|tsx|py|rb|pl|php|vbs|vbe|wsf|sh|jar|dll|exe|csx)\b`, 'i');
|
|
173
|
+
const why = (file, reason) => `refused: ${relative(cwd, file) || file} is not one of the project's own scripts — ${reason}. A script written or ` +
|
|
174
|
+
'changed during the work is not run, nor anything in .cop-tmp (the operator\'s rule). Put what it does in the ' +
|
|
175
|
+
'step itself: a command may be several lines. If the script is meant to be part of the project, say so in "notes", ' +
|
|
176
|
+
'and the operator can commit it.';
|
|
177
|
+
for (const file of shellScriptsRun(command, cwd)) {
|
|
178
|
+
const reason = notTheProjects(file, since);
|
|
179
|
+
if (reason)
|
|
180
|
+
return why(file, reason);
|
|
181
|
+
}
|
|
182
|
+
if (scratch.test(command)) {
|
|
183
|
+
return ('refused: this runs a file in .cop-tmp, the folder for scratch files — nothing there is run (the operator\'s rule). ' +
|
|
184
|
+
'Put what it does in the step itself: a command may be several lines.');
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|