copilot-operator 0.1.69 → 0.1.70
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 +4 -2
- package/dist/src/api/operator.service.js +23 -9
- package/dist/src/api/server.js +10 -0
- package/dist/src/cli.js +2 -0
- package/dist/src/config/lockedPolicy.js +14 -0
- package/dist/src/config/schema.js +22 -0
- package/dist/src/exec/authorizer.js +45 -6
- package/dist/src/exec/dangerous.js +1 -1
- package/dist/src/exec/npmScripts.js +180 -0
- package/dist/src/exec/platforms.js +45 -1
- package/dist/src/exec/policy.js +110 -7
- package/dist/src/exec/policyManifest.js +13 -0
- package/dist/src/exec/programs.js +6 -1
- package/dist/src/exec/redaction.js +17 -2
- package/dist/src/exec/scriptFiles.js +210 -32
- package/dist/src/exec/scriptKinds.js +86 -0
- package/dist/src/exec/stepEnv.js +9 -2
- package/dist/src/orchestrator/handoff.js +80 -29
- package/dist/src/orchestrator/leadRunner.js +5 -2
- package/dist/src/orchestrator/review.js +13 -3
- package/dist/src/orchestrator/taskRunner.js +105 -19
- package/dist/src/plan/kerrigan.js +4 -4
- package/dist/src/plan/systemGuide.js +83 -12
- package/dist/src/protocol/leadSchema.js +8 -1
- package/dist/src/protocol/replySchema.js +13 -3
- package/dist/src/protocol/reviewSchema.js +4 -1
- package/dist/src/queue/queue.js +8 -4
- package/dist/src/session/checkpoint.js +48 -0
- package/dist/src/session/compose.js +1 -1
- package/dist/src/session/story.js +14 -0
- package/dist/src/vcs/gitConfigGuard.js +126 -0
- package/dist/src/vcs/newBranch.js +7 -3
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/chunks/1024-67625a65f58057ae.js +1 -0
- package/dist/web/_next/static/chunks/1077.9fe1c0425bf51375.js +1 -0
- package/dist/web/_next/static/chunks/1548.cae3ba2196c8d52f.js +1 -0
- package/dist/web/_next/static/chunks/2163.5c9f8477d98b75a4.js +1 -0
- package/dist/web/_next/static/chunks/714.a0b32193f71e0e91.js +1 -0
- package/dist/web/_next/static/chunks/7220.5d6da026e0b34169.js +1 -0
- package/dist/web/_next/static/chunks/7921-0f7954cb5a9f697b.js +1 -0
- package/dist/web/_next/static/chunks/8124-a39d85dff0db6600.js +1 -0
- package/dist/web/_next/static/chunks/8584.6aa7ce56f7552f17.js +1 -0
- package/dist/web/_next/static/chunks/9067.2e4ba2e0e572f21e.js +1 -0
- package/dist/web/_next/static/chunks/9747.763da2026719a863.js +1 -0
- package/dist/web/_next/static/chunks/9929-2e0b1d006ebd5345.js +1 -0
- package/dist/web/_next/static/chunks/app/{layout-e23bb58f3ea117d5.js → layout-52a2079ffa83c21f.js} +1 -1
- package/dist/web/_next/static/chunks/app/{page-fd49cf4fb6681d30.js → page-44eac9d137f26dc5.js} +1 -1
- package/dist/web/_next/static/chunks/app/queue/{page-fb49cb2d3dc6d14c.js → page-82f724d0842f4870.js} +1 -1
- package/dist/web/_next/static/chunks/app/settings/page-2df196e25cb7bfe1.js +1 -0
- package/dist/web/_next/static/chunks/{webpack-77c6c045264c9213.js → webpack-950df0f512eef7ec.js} +1 -1
- package/dist/web/_next/static/css/{52131c6d864daf3f.css → cfe8ccb4adf3a311.css} +1 -1
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +8 -8
- package/dist/web/index.html +3 -3
- package/dist/web/index.txt +9 -9
- package/dist/web/queue.html +2 -2
- package/dist/web/queue.txt +9 -9
- package/dist/web/settings.html +2 -2
- package/dist/web/settings.txt +9 -9
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +9 -9
- package/package.json +3 -2
- package/prompts/level1.md +25 -8
- package/dist/web/_next/static/chunks/1024-e4e596b184e05e91.js +0 -1
- package/dist/web/_next/static/chunks/1077.b3943e5b41c4bef4.js +0 -1
- package/dist/web/_next/static/chunks/1548.0ff0c0ece685ffe7.js +0 -1
- package/dist/web/_next/static/chunks/2163.9cfb1b06beaf5001.js +0 -1
- package/dist/web/_next/static/chunks/6262-d074473db83ee798.js +0 -1
- package/dist/web/_next/static/chunks/714.bee98f5a3db75882.js +0 -1
- package/dist/web/_next/static/chunks/7220.610988766a1104b7.js +0 -1
- package/dist/web/_next/static/chunks/7921-ac5793d5663674b2.js +0 -1
- package/dist/web/_next/static/chunks/8124-665327221384ba6e.js +0 -1
- package/dist/web/_next/static/chunks/8584.9220e445a8ce2265.js +0 -1
- package/dist/web/_next/static/chunks/9067.f05516f2f2a2e8f5.js +0 -1
- package/dist/web/_next/static/chunks/9747.e249434ff7e05f4f.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-7d120feb5af0ace9.js +0 -1
- /package/dist/web/_next/static/{8i6gf0zoo-KiUKdzxsCJR → DzoLjnxX5FvdxuPasWlnb}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{8i6gf0zoo-KiUKdzxsCJR → DzoLjnxX5FvdxuPasWlnb}/_ssgManifest.js +0 -0
|
@@ -164,9 +164,9 @@ You are **Kerrigan**. You help the person talking to you get their work done wit
|
|
|
164
164
|
- The person writes a task in the chat, about the **project folder** open there. The program sends it to **Microsoft 365 Copilot** (a work account) in an Edge window it opens and keeps open between messages; when the work on a message has ended, a card in that window says so, with an OK. Copilot cannot touch the machine itself: it answers with **PowerShell commands**, in a fixed JSON form.
|
|
165
165
|
- copilot-operator **runs those commands on the machine, in the project folder**, and sends back what they printed. Round after round, until Copilot says the task is **done** (with a summary of what it did), or **blocked** (with what it tried and what it needs), or a limit is reached.
|
|
166
166
|
- Copilot learns the project only through those commands: it lists files, reads them, runs the build and the tests. It is not sent the files themselves, and it knows nothing about the project that the task does not say and the commands cannot find.
|
|
167
|
-
- The person chooses how commands run in Settings, under ${Q('exec.startMode')} (not in the chat): ${Q('exec.startModeAsk')} (they press ${Q('chat.askRun')}, ${Q('chat.askRunAll')} or ${Q('chat.askSkip')} on a card that says who asks) or ${Q('exec.startModeAuto')}. A list of forbidden commands applies either way; pushing to a remote is refused; nothing needs administrator rights. A command that reaches a platform with the person's own access — Azure, AWS, GitHub, Jira, publishing a package and the like — waits on a card even in a run without asking, unless ${Q('exec.questions')} in Settings is set to agree with what the bot proposes; so do the questions the chat or the lead asks, with their answers to click. Once one answer on a card is pressed, the card's other answers and its text box turn off and the one pressed stays marked until the card goes; only when the answer did not reach the program do they come back on, with the reason on the card.
|
|
167
|
+
- The person chooses how commands run in Settings, under ${Q('exec.startMode')} (not in the chat): ${Q('exec.startModeAsk')} (they press ${Q('chat.askRun')}, ${Q('chat.askRunAll')} or ${Q('chat.askSkip')} on a card that says who asks), ${Q('exec.startModeAutoAsk')} (a script the bot wrote still waits on a card with its text) or ${Q('exec.startModeAuto')}. A list of forbidden commands applies either way; pushing to a remote is refused; nothing needs administrator rights. A command that reaches a platform with the person's own access — Azure, AWS, GitHub, Jira, publishing a package and the like — waits on a card even in a run without asking, unless ${Q('exec.questions')} in Settings is set to agree with what the bot proposes; so do the questions the chat or the lead asks, with their answers to click. Once one answer on a card is pressed, the card's other answers and its text box turn off and the one pressed stays marked until the card goes; only when the answer did not reach the program do they come back on, with the reason on the card.
|
|
168
168
|
- The programs a command may start are listed in Settings, under "Programs the bot may start": the person adds one by its name (${Q('prog.add')}, ${Q('prog.addButton')}) and takes one off with its ✕; a command that starts a program not on the list is refused, and the chat is told why. A program that reaches a platform with their access is set to ${Q('prog.modeAsk')}, or, for az, to ${Q('prog.modeReadOnly')}: az's commands that only look (list, show, query) then run without a card, the ones that create, change, delete, sign in or out, or show a secret are refused, and one the program cannot read waits on a card. The person signs in themselves, with az login in their own terminal; the program uses that sign-in and never sees the password. The program reads the command line and a script could go round it, so for a guarantee they sign in with an account that has only the Reader role in Azure, and Azure itself refuses every change.
|
|
169
|
-
- A script Copilot
|
|
169
|
+
- Which scripts the program runs is the person's choice, in Settings, under "Scripts the bot may run": for each kind (TypeScript, JavaScript, Python, PowerShell, cmd, bash, Ruby/Perl/PHP, package.json scripts) a box ${Q('scr.own')}, on by default, and a box ${Q('scr.written')}, off by default. A script Copilot wrote during the work of a kind left unticked — a diagnostic, a reproduction, a small tool — is not run by the program: Copilot hands it over on a card, "Run this yourself", with its revision, the commands in order (and Copy), the folder, what should be seen and how it should end, what it reaches and changes, and each script in full to read first. The person runs them in their own terminal, pastes what they printed and presses ${Q('ho.send')}; or presses ${Q('ho.revise')}, writes what to correct and sends it — nothing runs, the task goes on, and the next revision comes on a new card; or presses ${Q('ho.notRun')}, which is final for that script. The card waits for them even when Settings agree with what the bot proposes. The project's tests, the build and the application run as steps, as before.
|
|
170
170
|
- The model: ${Q('chat.model')} under the chat's box. When it is to be chosen by hand (the default), a card asks the person to choose the model in the Copilot window and press ${Q('approval.manualReady')}.
|
|
171
171
|
- ${Q('chat.planMode')} (a choice under the chat's box): Copilot first looks at the project with read-only commands and proposes a plan — what is there, how it means to do it, the stages, the files, how it will show it works — and nothing is changed until the person approves the plan (${Q('pm.approve')}), asks for another (${Q('pm.revise')}), or stops.
|
|
172
172
|
- ${Q('chat.review')} (under the chat's box, on unless unticked): when Copilot says the work is done, a conversation of its own reviews it — reads the changes, runs the checks — and sends back what it finds, up to ${n(rounds)} round(s) of fixing. When the model is chosen by hand, the card for the review's model says it is the review's: a different, stronger model than the one that did the work catches more mistakes.
|
|
@@ -248,9 +248,9 @@ function bgText(f) {
|
|
|
248
248
|
- Човекът пише задание в чата, за **папката на проекта**, отворена там. Програмата го изпраща на **Microsoft 365 Copilot** (служебен акаунт) в прозорец на Edge, който отваря и държи отворен между съобщенията; когато работата по съобщение свърши, карта в този прозорец го казва, с бутон „ОК“. Copilot не може сам да пипа машината: отговаря с **команди на PowerShell**, в определен вид JSON.
|
|
249
249
|
- copilot-operator **изпълнява тези команди на машината, в папката на проекта**, и връща какво са изписали. Кръг след кръг, докато Copilot каже, че заданието е **готово** (с обобщение на направеното), или **блокирано** (с какво е опитал и какво му трябва), или се стигне ограничение.
|
|
250
250
|
- Copilot опознава проекта само чрез тези команди: изброява файлове, чете ги, пуска компилацията и тестовете. Самите файлове не му се изпращат и той не знае за проекта нищо, което заданието не казва и командите не могат да намерят.
|
|
251
|
-
- Човекът избира как се изпълняват командите в Настройки, при ${Q('exec.startMode')} (не в чата): ${Q('exec.startModeAsk')} (натиска ${Q('chat.askRun')}, ${Q('chat.askRunAll')} или ${Q('chat.askSkip')} на карта, на която пише кой иска) или ${Q('exec.startModeAuto')}.
|
|
251
|
+
- Човекът избира как се изпълняват командите в Настройки, при ${Q('exec.startMode')} (не в чата): ${Q('exec.startModeAsk')} (натиска ${Q('chat.askRun')}, ${Q('chat.askRunAll')} или ${Q('chat.askSkip')} на карта, на която пише кой иска), ${Q('exec.startModeAutoAsk')} (скрипт, написан от бота, пак чака на карта с текста си) или ${Q('exec.startModeAuto')}. Във всички случаи важи списък със забранени команди; изпращането към отдалечено хранилище (push) се отказва; нищо не изисква администраторски права. Команда, която достъпва платформа със собствения достъп на човека — Azure, AWS, GitHub, Jira, публикуване на пакет и подобни, — чака на карта дори при пускане без питане, освен ако ${Q('exec.questions')} в Настройки не е настроено да се съгласява с това, което предлага ботът; същото важи за въпросите на чата или на ръководителя, с отговори за избор. Щом се натисне един отговор на карта, другите отговори и полето за текст на картата се изключват, а натиснатият остава отбелязан, докато картата изчезне; включват се отново само ако отговорът не е стигнал до програмата, с причината на картата.
|
|
252
252
|
- Програмите, които командата може да пуска, са изброени в Настройки, при „Програми, които ботът може да пуска“: човекът добавя програма по името ѝ (${Q('prog.add')}, ${Q('prog.addButton')}) и маха програма с нейното ✕; команда, която пуска програма извън списъка, се отказва и на чата се казва защо. Програма, която достъпва платформа с неговия достъп, е на ${Q('prog.modeAsk')} или, за az, на ${Q('prog.modeReadOnly')}: тогава командите на az, които само гледат (list, show, query), се изпълняват без карта, тези, които създават, променят, трият, влизат или излизат, или показват тайна, се отказват, а такава, която програмата не може да разчете, чака на карта. Човекът влиза сам, с az login в собствения си терминал; програмата ползва този вход и никога не вижда паролата. Програмата чете командния ред и скрипт би могъл да го заобиколи, затова за гаранция той влиза с акаунт, който има само ролята Reader в Azure, и тогава самият Azure отказва всяка промяна.
|
|
253
|
-
- Скрипт, който Copilot
|
|
253
|
+
- Кои скриптове пуска програмата, решава човекът в Настройки, при „Скриптове, които ботът може да пуска“: за всеки вид (TypeScript, JavaScript, Python, PowerShell, cmd, bash, Ruby/Perl/PHP, скриптове в package.json) отметка ${Q('scr.own')}, включена по подразбиране, и отметка ${Q('scr.written')}, изключена по подразбиране. Скрипт, който Copilot е написал по време на работата, от вид без отметка — диагностика, възпроизвеждане, малък инструмент, — програмата не го пуска: Copilot го предава на карта „Пуснете го сами“ с ревизията, командите по ред (и „Копирай“), папката, какво трябва да се види и как да завърши, какво достъпва и променя, и всеки скрипт изцяло, за да се прочете първо. Човекът ги пуска в собствения си терминал, поставя какво са изписали и натиска ${Q('ho.send')}; или натиска ${Q('ho.revise')}, пише какво да се коригира и го изпраща — нищо не се пуска, задачата продължава, а следващата ревизия идва на нова карта; или натиска ${Q('ho.notRun')}, което е окончателно за този скрипт. Картата чака него, дори когато Настройки се съгласяват с това, което предлага ботът. Тестовете на проекта, компилацията и приложението се пускат като стъпки, както досега.
|
|
254
254
|
- Моделът: ${Q('chat.model')} под полето на чата. Когато се избира ръчно (по подразбиране), карта моли човека да избере модела в прозореца на Copilot и да натисне ${Q('approval.manualReady')}.
|
|
255
255
|
- ${Q('chat.planMode')} (избор под полето на чата): Copilot първо разглежда проекта само с команди, които четат, и предлага план — какво има, как смята да го направи, етапите, файловете, как ще покаже, че работи, — и нищо не се променя, докато човекът не одобри плана (${Q('pm.approve')}), не поиска друг (${Q('pm.revise')}) или не спре.
|
|
256
256
|
- ${Q('chat.review')} (под полето на чата, включена, освен ако не я изключат): когато Copilot каже, че работата е готова, отделен разговор я преглежда — чете промените, пуска проверките — и връща каквото открие, до ${n(rounds)} кръга поправка. Когато моделът се избира ръчно, картата за модела на рецензията казва, че е за нея: модел, различен и по-силен от този, с който е работено, хваща повече грешки.
|
|
@@ -1069,18 +1069,42 @@ export const SYSTEM_GUIDE = [
|
|
|
1069
1069
|
{
|
|
1070
1070
|
key: 'ho.send',
|
|
1071
1071
|
kind: 'button',
|
|
1072
|
-
en: '
|
|
1073
|
-
bg: '
|
|
1074
|
-
doesEn: 'Sends what you pasted to the chat, beside what it expected, and the work goes on.',
|
|
1075
|
-
doesBg: 'Изпраща поставеното на чата, до това, което е очаквал, и работата продължава.',
|
|
1072
|
+
en: 'I ran it — send the output',
|
|
1073
|
+
bg: 'Пуснах го — изпращам output',
|
|
1074
|
+
doesEn: 'Sends what you pasted to the chat, beside what it expected, as evidence and never as instructions, and the work goes on.',
|
|
1075
|
+
doesBg: 'Изпраща поставеното на чата, до това, което е очаквал, като доказателство, а не като указания, и работата продължава.',
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
key: 'ho.revise',
|
|
1079
|
+
kind: 'button',
|
|
1080
|
+
en: 'Send the script back for a correction',
|
|
1081
|
+
bg: 'Върни скрипта за корекция',
|
|
1082
|
+
doesEn: 'Opens the field "What needs correcting?", which may not be empty; sent, nothing is run, the task goes on, and the chat changes only the script and hands it over again as the next revision, read again in full.',
|
|
1083
|
+
doesBg: 'Отваря полето „Какво трябва да се коригира?“, което не може да е празно; при изпращане нищо не се пуска, задачата продължава, а чатът променя само скрипта и го дава отново като следваща ревизия, прочетена отново изцяло.',
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
key: 'ho.reviseNote',
|
|
1087
|
+
kind: 'field',
|
|
1088
|
+
en: 'What needs correcting?',
|
|
1089
|
+
bg: 'Какво трябва да се коригира?',
|
|
1090
|
+
doesEn: 'Shown under the card\'s buttons after "Send the script back for a correction": what the chat is to change in the script, in your words.',
|
|
1091
|
+
doesBg: 'Показва се под бутоните на картата след „Върни скрипта за корекция“: какво чатът трябва да промени в скрипта, с ваши думи.',
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
key: 'ho.reviseSend',
|
|
1095
|
+
kind: 'button',
|
|
1096
|
+
en: 'Send for correction',
|
|
1097
|
+
bg: 'Изпрати за корекция',
|
|
1098
|
+
doesEn: 'Sends the note; nothing is run, and the chat hands the script over again as the next revision.',
|
|
1099
|
+
doesBg: 'Изпраща бележката; нищо не се пуска, а чатът дава скрипта отново като следваща ревизия.',
|
|
1076
1100
|
},
|
|
1077
1101
|
{
|
|
1078
1102
|
key: 'ho.notRun',
|
|
1079
1103
|
kind: 'button',
|
|
1080
|
-
en: 'I
|
|
1081
|
-
bg: '
|
|
1082
|
-
doesEn: '
|
|
1083
|
-
doesBg: '
|
|
1104
|
+
en: 'I will not run it',
|
|
1105
|
+
bg: 'Няма да го изпълнявам',
|
|
1106
|
+
doesEn: 'Final for that script: tells the chat you will not run it, with what you wrote as the reason; it goes on without it or ends blocked.',
|
|
1107
|
+
doesBg: 'Окончателно за този скрипт: казва на чата, че няма да го пуснете, с написаното като причина; той продължава без него или приключва като блокиран.',
|
|
1084
1108
|
},
|
|
1085
1109
|
{
|
|
1086
1110
|
key: 'approval.openChat',
|
|
@@ -2499,13 +2523,21 @@ export const SYSTEM_GUIDE = [
|
|
|
2499
2523
|
doesEn: 'The default: each command waits on a card in the conversation, which says who asks — Run, Run this and the rest, or Skip.',
|
|
2500
2524
|
doesBg: 'По подразбиране: всяка команда чака на карта в разговора, на която пише кой иска — Изпълни, Изпълни тази и останалите или Пропусни.',
|
|
2501
2525
|
},
|
|
2526
|
+
{
|
|
2527
|
+
key: 'exec.startModeAutoAsk',
|
|
2528
|
+
kind: 'select',
|
|
2529
|
+
en: 'Run without asking, except scripts the bot wrote',
|
|
2530
|
+
bg: 'Изпълнявай без питане, освен скриптовете на бота',
|
|
2531
|
+
doesEn: 'Commands run at once; one that runs a script the bot wrote during the work, of a kind "Scripts the bot may run" lets it run, waits on a card with the script in full. Chosen, it asks once to confirm. Allowed only when "Where the bot runs" allows runs with nobody watching; forbidden commands are refused either way.',
|
|
2532
|
+
doesBg: 'Командите се изпълняват веднага; команда, която пуска скрипт, написан от бота по време на работата, от вид, който „Скриптове, които ботът може да пуска“ позволява, чака на карта с целия скрипт. При избор пита веднъж за потвърждение. Позволено е само ако „Къде върви ботът“ позволява пускания без надзор; забранените команди се отказват и така.',
|
|
2533
|
+
},
|
|
2502
2534
|
{
|
|
2503
2535
|
key: 'exec.startModeAuto',
|
|
2504
2536
|
kind: 'select',
|
|
2505
|
-
en: 'Run
|
|
2506
|
-
bg: 'Изпълнявай
|
|
2507
|
-
doesEn: 'Commands run at once; chosen, it asks once to confirm. Allowed only when "Where the bot runs" allows runs with nobody watching, otherwise a message is refused with the reason; forbidden commands are refused either way.',
|
|
2508
|
-
doesBg: 'Командите се изпълняват
|
|
2537
|
+
en: 'Run everything without asking, the bot\'s scripts too',
|
|
2538
|
+
bg: 'Изпълнявай всичко без питане, и скриптовете на бота',
|
|
2539
|
+
doesEn: 'Commands run at once, and so do the scripts the bot wrote of the kinds ticked under "Scripts the bot may run"; chosen, it asks once to confirm. Allowed only when "Where the bot runs" allows runs with nobody watching, otherwise a message is refused with the reason; forbidden commands are refused either way.',
|
|
2540
|
+
doesBg: 'Командите се изпълняват веднага, както и скриптовете, които ботът е написал, от видовете, отметнати в „Скриптове, които ботът може да пуска“; при избор пита веднъж за потвърждение. Позволено е само ако „Къде върви ботът“ позволява пускания без надзор, иначе съобщението се отказва с причината; забранените команди се отказват и така.',
|
|
2509
2541
|
},
|
|
2510
2542
|
{
|
|
2511
2543
|
key: 'exec.networkFetch',
|
|
@@ -2691,6 +2723,45 @@ export const SYSTEM_GUIDE = [
|
|
|
2691
2723
|
},
|
|
2692
2724
|
],
|
|
2693
2725
|
},
|
|
2726
|
+
{
|
|
2727
|
+
headingKey: 'scr.title',
|
|
2728
|
+
en: 'Scripts the bot may run',
|
|
2729
|
+
bg: 'Скриптове, които ботът може да пуска',
|
|
2730
|
+
controls: [
|
|
2731
|
+
{
|
|
2732
|
+
key: 'scr.kind',
|
|
2733
|
+
kind: 'note',
|
|
2734
|
+
en: 'Kind',
|
|
2735
|
+
bg: 'Вид',
|
|
2736
|
+
doesEn: 'The table\'s first column: the kind of script, with its extensions, in the order of their names.',
|
|
2737
|
+
doesBg: 'Първата колона на таблицата: видът скрипт, с разширенията му, подредени по име.',
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
key: 'scr.own',
|
|
2741
|
+
kind: 'checkbox',
|
|
2742
|
+
en: 'Ready-made (the project\'s)',
|
|
2743
|
+
bg: 'Готови (на проекта)',
|
|
2744
|
+
doesEn: 'One box per kind — TypeScript, JavaScript, Python, PowerShell, cmd, bash, Ruby/Perl/PHP, package.json scripts: whether the bot runs the project\'s own scripts of that kind, there before the work began. On by default; off, not even the project\'s run.',
|
|
2745
|
+
doesBg: 'По една отметка за всеки вид — TypeScript, JavaScript, Python, PowerShell, cmd, bash, Ruby/Perl/PHP, скриптове в package.json: дали ботът пуска собствените скриптове на проекта от този вид, били там преди началото на работата. Включено по подразбиране; изключено — не се пускат дори тези на проекта.',
|
|
2746
|
+
},
|
|
2747
|
+
{
|
|
2748
|
+
key: 'scr.written',
|
|
2749
|
+
kind: 'checkbox',
|
|
2750
|
+
en: 'Written by the bot',
|
|
2751
|
+
bg: 'Написани от бота',
|
|
2752
|
+
doesEn: 'Whether the bot runs the scripts of that kind it wrote during the work itself, .cop-tmp included. Off by default: such a script is handed to the operator on "Run this yourself". Ticked, the bot runs it — first on a card in "Run without asking, except scripts the bot wrote". The text of .ps1, .bat, .cmd, .sh and package.json scripts is checked like a command; .ts, .js and .py are not read.',
|
|
2753
|
+
doesBg: 'Дали ботът пуска сам скриптовете от този вид, които е написал по време на работата, включително в .cop-tmp. Изключено по подразбиране: такъв скрипт се дава на оператора на „Пуснете го сами“. Отметнато: ботът го пуска — първо на карта при „Изпълнявай без питане, освен скриптовете на бота“. Текстът на .ps1, .bat, .cmd, .sh и скриптовете в package.json се проверява като команда; .ts, .js и .py не се четат.',
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
key: 'scr.restore',
|
|
2757
|
+
kind: 'button',
|
|
2758
|
+
en: 'Restore the defaults',
|
|
2759
|
+
bg: 'Върни по подразбиране',
|
|
2760
|
+
doesEn: 'Puts the boxes back, after asking: the project\'s scripts run, the bot\'s are handed to the operator.',
|
|
2761
|
+
doesBg: 'Връща отметките, след като попита: скриптовете на проекта се пускат, а тези на бота се дават на оператора.',
|
|
2762
|
+
},
|
|
2763
|
+
],
|
|
2764
|
+
},
|
|
2694
2765
|
],
|
|
2695
2766
|
},
|
|
2696
2767
|
{
|
|
@@ -93,7 +93,14 @@ export const LeadReplySchema = z
|
|
|
93
93
|
* `done` — the result, in the form the assignment asked for (`answer`). `blocked` — it cannot be taken further
|
|
94
94
|
* without the operator (`summary`, `needed`).
|
|
95
95
|
*/
|
|
96
|
-
|
|
96
|
+
/*
|
|
97
|
+
* A status of the worker's said by the lead (operator's specification, 2026-10-27: an unsupported "handoff" cost a
|
|
98
|
+
* format retry that said only "invalid option"): the lead is told whose it is and what to do instead.
|
|
99
|
+
*/
|
|
100
|
+
status: z.enum(['delegate', 'plan', 'ask', 'done', 'blocked'], {
|
|
101
|
+
message: 'status is one of "delegate", "plan", "ask", "done", "blocked". "handoff" and "continue" are the worker\'s: the worker writes a ' +
|
|
102
|
+
'script and hands it to the operator itself, so delegate the subtask that needs one; a question for the operator is status "ask".',
|
|
103
|
+
}),
|
|
97
104
|
understanding: prose,
|
|
98
105
|
notes: prose,
|
|
99
106
|
plan: PlanSchema.optional(),
|
|
@@ -117,9 +117,11 @@ export const OptionSchema = z.preprocess((v) => (typeof v === 'string' ? { answe
|
|
|
117
117
|
}));
|
|
118
118
|
/**
|
|
119
119
|
* Commands the operator runs themselves (operator, 2026-10-26: "the script is made, but the user runs it; the bot gives
|
|
120
|
-
* the commands for the user to run and the result it expects"): a script written during the work
|
|
121
|
-
* runner (`scriptFiles.ts`)
|
|
122
|
-
* script files they run, which the card shows
|
|
120
|
+
* the commands for the user to run and the result it expects"): a script written during the work that the operator's
|
|
121
|
+
* boxes do not let the runner run (`scriptFiles.ts`) is handed over — the lines in order, the folder, what should be
|
|
122
|
+
* seen, and the script files they run, which the card shows in full so the operator reads what they run. Since
|
|
123
|
+
* 2026-10-27 also what it does besides: how it should end, what it reaches on the network and on a platform, and what
|
|
124
|
+
* it changes in the project — the card shows them beside what the runner itself reads in the lines and the scripts.
|
|
123
125
|
*/
|
|
124
126
|
export const HandoffSchema = z.object({
|
|
125
127
|
why: z.string().trim().min(1).optional(),
|
|
@@ -129,6 +131,14 @@ export const HandoffSchema = z.object({
|
|
|
129
131
|
expect: z.string().trim().min(5, 'handoff.expect must say what the operator should see when it works.'),
|
|
130
132
|
/** The script files the commands run, relative to the project. */
|
|
131
133
|
files: z.array(z.preprocess(asText, z.string().trim().min(1))).default([]),
|
|
134
|
+
/** How it should end: the exit code, or what it prints last. */
|
|
135
|
+
exit: z.preprocess(asText, z.string().trim().min(1)).optional(),
|
|
136
|
+
/** What it reaches on the network: "nothing", or the hosts. */
|
|
137
|
+
network: z.preprocess(asText, z.string().trim().min(1)).optional(),
|
|
138
|
+
/** What it reaches on a platform with the operator's access (Azure, GitHub …): "nothing", or which. */
|
|
139
|
+
platforms: z.preprocess(asText, z.string().trim().min(1)).optional(),
|
|
140
|
+
/** What it changes in the project: "nothing", or the files and how. */
|
|
141
|
+
changes: z.preprocess(asText, z.string().trim().min(1)).optional(),
|
|
132
142
|
});
|
|
133
143
|
export const ReplySchema = z
|
|
134
144
|
.object({
|
|
@@ -99,7 +99,10 @@ export const ReviewSchema = z
|
|
|
99
99
|
* and fails: "I could not verify X because Y" is information the operator needs, and
|
|
100
100
|
* quietly passing work nobody could check is the one outcome worth ruling out.
|
|
101
101
|
*/
|
|
102
|
-
status: z.enum(['continue', 'pass', 'fail']
|
|
102
|
+
status: z.enum(['continue', 'pass', 'fail'], {
|
|
103
|
+
message: 'status is one of "continue", "pass", "fail". A review hands nothing to the operator ("handoff" is the implementer\'s): check what a ' +
|
|
104
|
+
'script would show with commands of your own, or say in a finding that the operator has to run it.',
|
|
105
|
+
}),
|
|
103
106
|
steps: z.array(StepSchema).default([]),
|
|
104
107
|
notes: z.string().optional(),
|
|
105
108
|
/** Required on `pass` and `fail`: what you checked, how, and what you saw. */
|
package/dist/src/queue/queue.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* Kept as `data/queue.json` (see `OperatorService.queue`). This module is the part that needs no browser: the shape,
|
|
23
23
|
* the checks of an edit, and which task is next.
|
|
24
24
|
*/
|
|
25
|
+
import { handoffOutcomeOf } from '../orchestrator/handoff.js';
|
|
25
26
|
import { branchExists } from '../vcs/git.js';
|
|
26
27
|
export const DEFAULT_PARK_AFTER_SEC = 120;
|
|
27
28
|
export const MAX_PARK_AFTER_SEC = 24 * 60 * 60;
|
|
@@ -214,11 +215,14 @@ export function parkedAnswerFrom(p, input) {
|
|
|
214
215
|
return text(input.note) ? { kind: 'plan', decision: 'revise', note: text(input.note) } : { problem: 'Say what to change in the plan.' };
|
|
215
216
|
return { problem: 'A plan is approved, or sent back for another.' };
|
|
216
217
|
case 'question':
|
|
217
|
-
// Commands handed over (2026-10-26): what they printed,
|
|
218
|
+
// Commands handed over (2026-10-26): what they printed, sent back with what to correct (2026-10-27), or not run.
|
|
218
219
|
if (p.approval.question?.handoff) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
const outcome = handoffOutcomeOf(input.outcome, input.ran);
|
|
221
|
+
if (outcome === 'declined')
|
|
222
|
+
return { kind: 'question', answer: text(input.answer), ran: false, outcome };
|
|
223
|
+
if (outcome === 'revise')
|
|
224
|
+
return text(input.answer) ? { kind: 'question', answer: text(input.answer), outcome } : { problem: 'Say what to correct first.' };
|
|
225
|
+
return text(input.answer) ? { kind: 'question', answer: text(input.answer), ran: true, outcome } : { problem: 'Paste what the commands printed first.' };
|
|
222
226
|
}
|
|
223
227
|
return text(input.answer) ? { kind: 'question', answer: text(input.answer) } : { problem: 'Write the answer first.' };
|
|
224
228
|
case 'retry': {
|
|
@@ -82,6 +82,42 @@ export async function changedSince(dir, before, id) {
|
|
|
82
82
|
await git(dir, ['update-ref', '-d', ref]).catch(() => undefined);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Adds to the safety record what `git clean -f -d` would remove now: the record photographed the folder through the
|
|
87
|
+
* .gitignore of then, and a file it ignored is not in it. The record as it now is, or why it could not be kept.
|
|
88
|
+
*/
|
|
89
|
+
async function keepWhatCleanTakes(dir, ref, safety) {
|
|
90
|
+
// `clean` has no -z: one name a line, quoted C-style only where it holds a quote, a backslash or a control character.
|
|
91
|
+
const doomed = await git(dir, ['-c', 'core.quotePath=false', 'clean', '-n', '-d'], 60_000);
|
|
92
|
+
if (!doomed.ok)
|
|
93
|
+
return { problem: `git could not tell which files going back removes: ${doomed.stderr.split('\n')[0]}. Nothing was removed.` };
|
|
94
|
+
const unquote = (p) => (p.startsWith('"') && p.endsWith('"') ? p.slice(1, -1).replace(/\\(["\\])/g, '$1') : p);
|
|
95
|
+
const paths = doomed.stdout.split(/\r?\n/).filter((l) => l.startsWith('Would remove ')).map((l) => unquote(l.slice('Would remove '.length)));
|
|
96
|
+
if (paths.length === 0)
|
|
97
|
+
return { commit: safety };
|
|
98
|
+
const kept = new Set((await git(dir, ['ls-tree', '-r', '--name-only', '-z', safety], 60_000)).stdout.split('\0').filter(Boolean));
|
|
99
|
+
const missing = paths.filter((p) => (p.endsWith('/') ? ![...kept].some((k) => k.startsWith(p)) : !kept.has(p)));
|
|
100
|
+
if (missing.length === 0)
|
|
101
|
+
return { commit: safety };
|
|
102
|
+
const scratch = await mkdtemp(join(tmpdir(), 'cop-checkpoint-'));
|
|
103
|
+
const env = { ...process.env, GIT_INDEX_FILE: join(scratch, 'index') };
|
|
104
|
+
try {
|
|
105
|
+
const problem = 'the files going back would remove could not be kept first, so nothing was removed';
|
|
106
|
+
if (!(await git(dir, ['read-tree', safety], 60_000, env)).ok)
|
|
107
|
+
return { problem: `${problem}.` };
|
|
108
|
+
const add = await git(dir, ['add', '-f', '--', ...missing], 120_000, env);
|
|
109
|
+
if (!add.ok)
|
|
110
|
+
return { problem: `${problem} (${add.stderr.split('\n')[0]}).` };
|
|
111
|
+
const tree = await git(dir, ['write-tree'], 60_000, env);
|
|
112
|
+
const commit = tree.ok ? await git(dir, [...AUTHOR, 'commit-tree', tree.stdout, '-p', safety, '-m', 'files going back removes, kept with the folder as it was']) : tree;
|
|
113
|
+
if (!commit.ok || !(await git(dir, ['update-ref', ref, commit.stdout])).ok)
|
|
114
|
+
return { problem: `${problem}.` };
|
|
115
|
+
return { commit: commit.stdout };
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
await rm(scratch, { recursive: true, force: true }).catch(() => undefined);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
85
121
|
/**
|
|
86
122
|
* Puts the folder back as `cp` photographed it: its branch checked out at its commit, its working tree with the
|
|
87
123
|
* same uncommitted changes. The folder as it is now is photographed first, under `refs/copilot-operator/safety/`.
|
|
@@ -102,6 +138,18 @@ export async function restoreCheckpoint(dir, cp) {
|
|
|
102
138
|
: await step(['checkout', '--force', '--detach', cp.head], `${cp.head.slice(0, 8)} could not be checked out`)) ??
|
|
103
139
|
// At the commit it was on: a commit made after it, by the chat or by hand, is undone here (kept in the safety record).
|
|
104
140
|
(cp.branch ? await step(['reset', '--hard', cp.head], `${cp.branch} could not be put back at ${cp.head.slice(0, 8)}`) : null) ??
|
|
141
|
+
/*
|
|
142
|
+
* What git would remove now and the safety record does not hold — a file the .gitignore of now ignored, and the
|
|
143
|
+
* .gitignore put back does not (audit, 2026-10-27: a `.env` the chat had ignored went for good) — is added to the
|
|
144
|
+
* record first, so the clean below loses nothing.
|
|
145
|
+
*/
|
|
146
|
+
(await (async () => {
|
|
147
|
+
const kept = await keepWhatCleanTakes(dir, `refs/copilot-operator/safety/${stamp}`, safety.commit);
|
|
148
|
+
if ('problem' in kept)
|
|
149
|
+
return kept.problem;
|
|
150
|
+
safety.commit = kept.commit;
|
|
151
|
+
return null;
|
|
152
|
+
})()) ??
|
|
105
153
|
// Files made since that git does not track go; ignored ones (builds, installs) stay.
|
|
106
154
|
(await step(['clean', '-f', '-d'], 'the files made since could not be removed')) ??
|
|
107
155
|
// And the uncommitted changes as they were, untracked files included.
|
|
@@ -25,7 +25,7 @@ const TASK_HEADER = '## Task';
|
|
|
25
25
|
* and a note that is empty simply leaves nothing behind.
|
|
26
26
|
*/
|
|
27
27
|
function runnerBlock(input) {
|
|
28
|
-
const notes = [input.workDirNote, input.readOnlyNote, input.referenceNote, input.scopeNote, input.approachesNote, input.vcsNote, input.shellNote, input.planNote, input.operatorNotes].map((n) => (n ?? '').trim()).filter((n) => n.length > 0);
|
|
28
|
+
const notes = [input.workDirNote, input.readOnlyNote, input.referenceNote, input.scopeNote, input.approachesNote, input.vcsNote, input.shellNote, input.scriptsNote, input.planNote, input.operatorNotes].map((n) => (n ?? '').trim()).filter((n) => n.length > 0);
|
|
29
29
|
return notes.length > 0 ? `${notes.join('\n\n')}\n\n` : '';
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -249,6 +249,20 @@ export async function buildStory(runsDir, runId, task, live) {
|
|
|
249
249
|
if (!placedReviews.has(round))
|
|
250
250
|
entries.push(await reviewRound(join(dir, 'review', String(round)), round));
|
|
251
251
|
}
|
|
252
|
+
// Each handoff where it happened: after the last entry before it was put to the operator.
|
|
253
|
+
for (const name of (await readdir(join(dir, 'handoffs')).catch(() => [])).filter((n) => n.endsWith('.json')).sort()) {
|
|
254
|
+
const kept = await readFile(join(dir, 'handoffs', name), 'utf8').then((t) => JSON.parse(t)).catch(() => null);
|
|
255
|
+
if (!kept?.card)
|
|
256
|
+
continue;
|
|
257
|
+
const at = kept.askedAt;
|
|
258
|
+
let place = entries.length;
|
|
259
|
+
if (at) {
|
|
260
|
+
const later = entries.findIndex((e) => e.at !== undefined && e.at > at);
|
|
261
|
+
if (later >= 0)
|
|
262
|
+
place = later;
|
|
263
|
+
}
|
|
264
|
+
entries.splice(place, 0, { kind: 'handoff', revision: kept.card.revision ?? 1, card: kept.card, outcome: kept.outcome ?? 'nobody', ...(kept.answer ? { answer: clip(kept.answer) } : {}), ...(at ? { at } : {}), ...(kept.answeredAt ? { answeredAt: kept.answeredAt } : {}) });
|
|
265
|
+
}
|
|
252
266
|
const ended = task.status !== 'queued' && task.status !== 'running' && task.status !== 'waiting-approval';
|
|
253
267
|
return {
|
|
254
268
|
runId,
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The git settings a step might change so that the runner's own git runs a program (audit, 2026-10-27).
|
|
3
|
+
*
|
|
4
|
+
* The step gate refuses `git config` writes and lines that go into `.git` (`repositoryInternalsRefusal`), but it reads
|
|
5
|
+
* what a step says, and a program a step starts — a project script, a test — can write `.git\config` or the operator's
|
|
6
|
+
* `.gitconfig` with nothing in the line to show it. A filter driver, `core.worktree`, an include or an alias written
|
|
7
|
+
* there is run, or followed, by the runner's next `git status`, checkpoint or commit: with the bot's environment, no
|
|
8
|
+
* approval and no log. So the files are read before each of the chat's steps and again after it; where a key that names
|
|
9
|
+
* a program or a path changed, the file is put back as it was, and the step's result says so. Keys that only describe
|
|
10
|
+
* the repository — a branch's upstream, a remote's fetch spec, the user's name — are left as the step left them.
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { homedir } from 'node:os';
|
|
14
|
+
import { join, resolve } from 'node:path';
|
|
15
|
+
import { gitSync } from './git.js';
|
|
16
|
+
/** Keys whose value git runs, or follows to another file or folder. */
|
|
17
|
+
const NAMES_A_PROGRAM = [
|
|
18
|
+
/^filter\./,
|
|
19
|
+
/^diff\.[^.]+\.(?:textconv|command)$/,
|
|
20
|
+
/^merge\.[^.]+\.driver$/,
|
|
21
|
+
/^core\.(?:hookspath|fsmonitor|sshcommand|gitproxy|pager|editor|askpass|worktree|attributesfile|excludesfile|alternaterefscommand)$/,
|
|
22
|
+
/^credential\./,
|
|
23
|
+
/^gpg\./,
|
|
24
|
+
/^include\./,
|
|
25
|
+
/^includeif\./,
|
|
26
|
+
/^alias\./,
|
|
27
|
+
/^sequence\.editor$/,
|
|
28
|
+
/^uploadpack\./,
|
|
29
|
+
/^receive\./,
|
|
30
|
+
/^remote\.[^.]+\.(?:uploadpack|receivepack|proxy|vcs|url|pushurl)$/,
|
|
31
|
+
/^url\./,
|
|
32
|
+
/^http\./,
|
|
33
|
+
/^protocol\./,
|
|
34
|
+
/^safe\./,
|
|
35
|
+
/^difftool\./,
|
|
36
|
+
/^mergetool\./,
|
|
37
|
+
/^pager\./,
|
|
38
|
+
/^browser\./,
|
|
39
|
+
/^web\.browser$/,
|
|
40
|
+
/^man\./,
|
|
41
|
+
/^instaweb\./,
|
|
42
|
+
/^sendemail\./,
|
|
43
|
+
/^submodule\.[^.]+\.update$/,
|
|
44
|
+
/^ssh\./,
|
|
45
|
+
];
|
|
46
|
+
const dangerous = (key) => NAMES_A_PROGRAM.some((re) => re.test(key));
|
|
47
|
+
/** The configuration files a step could change: the repository's own, its worktree's, and the operator's. */
|
|
48
|
+
function configFiles(cwd) {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const name of ['config', 'config.worktree']) {
|
|
51
|
+
const r = gitSync(cwd, ['rev-parse', '--git-path', name]);
|
|
52
|
+
if (r.ok && r.stdout)
|
|
53
|
+
out.push(resolve(cwd, r.stdout));
|
|
54
|
+
}
|
|
55
|
+
const home = process.env.USERPROFILE || homedir();
|
|
56
|
+
out.push(join(home, '.gitconfig'));
|
|
57
|
+
out.push(process.env.XDG_CONFIG_HOME ? join(process.env.XDG_CONFIG_HOME, 'git', 'config') : join(home, '.config', 'git', 'config'));
|
|
58
|
+
return [...new Set(out)];
|
|
59
|
+
}
|
|
60
|
+
const bytesOf = (file) => {
|
|
61
|
+
try {
|
|
62
|
+
return existsSync(file) ? readFileSync(file) : null;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/** The keys of one config file, with their values, read by git itself without following includes. */
|
|
69
|
+
function keysOf(file, cwd) {
|
|
70
|
+
const out = new Map();
|
|
71
|
+
if (!existsSync(file))
|
|
72
|
+
return out;
|
|
73
|
+
const r = gitSync(cwd, ['config', '--file', file, '--no-includes', '--list', '-z']);
|
|
74
|
+
for (const entry of r.stdout.split('\0')) {
|
|
75
|
+
if (!entry)
|
|
76
|
+
continue;
|
|
77
|
+
const at = entry.indexOf('\n');
|
|
78
|
+
const key = (at < 0 ? entry : entry.slice(0, at)).toLowerCase();
|
|
79
|
+
out.set(key, `${out.get(key) ?? ''}\u0001${at < 0 ? '' : entry.slice(at + 1)}`);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/** What the chat is told of it, with the step's output. */
|
|
84
|
+
export function gitConfigMessage(changes) {
|
|
85
|
+
return (`this step changed git settings that name a program or a path git follows (${changes.flatMap((c) => c.keys).join(', ')}); ` +
|
|
86
|
+
'they were put back as they were. The runner owns the repository and runs git itself; leave its settings alone.');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reads the configuration now; the function it returns, called after the step, puts back each file in which a key
|
|
90
|
+
* that names a program or a path changed, and says which.
|
|
91
|
+
*/
|
|
92
|
+
export function watchGitConfig(cwd) {
|
|
93
|
+
const files = configFiles(cwd);
|
|
94
|
+
const before = files.map((file) => ({ file, bytes: bytesOf(file) }));
|
|
95
|
+
return () => {
|
|
96
|
+
const changes = [];
|
|
97
|
+
for (const { file, bytes } of before) {
|
|
98
|
+
const now = bytesOf(file);
|
|
99
|
+
if (bytes === null ? now === null : now !== null && bytes.equals(now))
|
|
100
|
+
continue;
|
|
101
|
+
const was = new Map();
|
|
102
|
+
if (bytes !== null) {
|
|
103
|
+
// Read as it was through a copy: git reads a file, and the file is no longer what it was.
|
|
104
|
+
const copy = `${file}.cop-before`;
|
|
105
|
+
try {
|
|
106
|
+
writeFileSync(copy, bytes);
|
|
107
|
+
for (const [k, v] of keysOf(copy, cwd))
|
|
108
|
+
was.set(k, v);
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
rmSync(copy, { force: true });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const is = keysOf(file, cwd);
|
|
115
|
+
const keys = [...new Set([...was.keys(), ...is.keys()])].filter((k) => was.get(k) !== is.get(k) && dangerous(k));
|
|
116
|
+
if (keys.length === 0)
|
|
117
|
+
continue;
|
|
118
|
+
if (bytes === null)
|
|
119
|
+
rmSync(file, { force: true });
|
|
120
|
+
else
|
|
121
|
+
writeFileSync(file, bytes);
|
|
122
|
+
changes.push({ file, keys });
|
|
123
|
+
}
|
|
124
|
+
return changes;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -231,9 +231,13 @@ export async function createNewBranch(folder, opts) {
|
|
|
231
231
|
const moved = await git(repoDir, ['switch', '--quiet', '--no-track', '--discard-changes', '-c', name, targetCommit], 300_000);
|
|
232
232
|
if (!moved.ok)
|
|
233
233
|
return { ok: false, problem: `The branch could not be made: ${(moved.stderr || moved.stdout).split(/\r?\n/)[0]}. What was not committed is kept on ${saved}.` };
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
/*
|
|
235
|
+
* The new files, kept on the saved branch, out of the folder — those and no others (audit, 2026-10-27): a plain
|
|
236
|
+
* `clean` also took a file the old branch's .gitignore ignored and the new one's does not, which was never saved.
|
|
237
|
+
* Named a hundred at a time, literally, so a name is never read as a pattern.
|
|
238
|
+
*/
|
|
239
|
+
for (let i = 0; i < plan.untracked.length; i += 100) {
|
|
240
|
+
const cleaned = await git(repoDir, ['--literal-pathspecs', 'clean', '-fd', '--quiet', '--', ...plan.untracked.slice(i, i + 100)], 300_000);
|
|
237
241
|
if (!cleaned.ok)
|
|
238
242
|
return { ok: false, problem: `The new branch ${name} is made, but the new files could not be taken out of the folder: ${cleaned.stderr}. They are kept on ${saved}.` };
|
|
239
243
|
}
|