opencode-swarm 7.144.4 → 7.144.6
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/.opencode/skills/swarm-pr-review/references/prompt-templates.md +2 -2
- package/dist/background/workspace-snapshot.d.ts +7 -0
- package/dist/cli/{capability-probe-f1paszww.js → capability-probe-976tt4ba.js} +6 -2
- package/dist/cli/{config-doctor-rw9zrjk6.js → config-doctor-4chz0b95.js} +2 -2
- package/dist/cli/{core-zjx9aqaf.js → core-p04nvknr.js} +4 -3
- package/dist/cli/{curation-policy-0wbrh11c.js → curation-policy-a511r0qz.js} +4 -4
- package/dist/cli/{curator-drift-2jbjv03a.js → curator-drift-ckjm272w.js} +2 -2
- package/dist/cli/curator-llm-factory-vc1mrc3r.js +63 -0
- package/dist/cli/{curator-g54a7wv0.js → curator-sxeh36gw.js} +33 -32
- package/dist/cli/{dispatch-1y1rnv1h.js → dispatch-ndxbsk98.js} +2 -2
- package/dist/cli/{evidence-summary-service-fnr5y54e.js → evidence-summary-service-spyxcgsx.js} +13 -12
- package/dist/cli/{gate-evidence-2xt1x07r.js → gate-evidence-nz0bwa15.js} +7 -6
- package/dist/cli/guardrail-explain-ass47kn8.js +64 -0
- package/dist/cli/{guardrail-log-5w4b9zrw.js → guardrail-log-fyzd55fp.js} +4 -4
- package/dist/cli/{hive-promoter-x63ehffd.js → hive-promoter-k8gtah3n.js} +33 -32
- package/dist/cli/{index-h98t1m88.js → index-01nhedm7.js} +29 -1
- package/dist/cli/{index-q4ed1jk7.js → index-42ezdzam.js} +1994 -1333
- package/dist/cli/{index-y8j8ehc8.js → index-68mqwvf5.js} +11 -5
- package/dist/cli/{index-1csyxv0f.js → index-6z5jtf7d.js} +2 -2
- package/dist/cli/{index-2m7mavaz.js → index-7zehmnv1.js} +2 -2
- package/dist/cli/index-9e6fdz2h.js +282 -0
- package/dist/cli/{index-mazgg5s2.js → index-9s8drsf9.js} +1 -1
- package/dist/cli/{index-b6e016tv.js → index-abtrcs16.js} +1 -1
- package/dist/cli/{index-8fwhhayc.js → index-b44qqqt2.js} +27 -18
- package/dist/cli/{index-yts89pqg.js → index-bac12jpv.js} +4 -4
- package/dist/cli/{index-psvxq93b.js → index-ckq719fr.js} +2 -2
- package/dist/cli/{index-k3cxyk66.js → index-cwtpqm5f.js} +1 -1
- package/dist/cli/{index-d12jd5mn.js → index-dj8cah6s.js} +1 -1
- package/dist/cli/{index-pw83zgny.js → index-dvybg11w.js} +3 -3
- package/dist/cli/{index-03pv47h2.js → index-ec1kywxg.js} +6 -6
- package/dist/cli/{index-74hpm6sh.js → index-f36ybbsv.js} +12 -6
- package/dist/cli/{index-az8etqpp.js → index-fgdhf6a5.js} +298 -1179
- package/dist/cli/{index-rn0eq85g.js → index-fv0s19g9.js} +1 -1
- package/dist/cli/{index-ywn7vtxp.js → index-h1p08s3n.js} +1 -1
- package/dist/cli/{index-nckg4gxb.js → index-h5krb653.js} +15 -4
- package/dist/cli/{index-bt9aa01f.js → index-hkdgkkhb.js} +1 -1
- package/dist/cli/{index-p7cm3gtj.js → index-jqvsh0g3.js} +35 -34
- package/dist/cli/{index-x6tp0hfr.js → index-n06653nr.js} +5 -5
- package/dist/cli/{index-jabkn643.js → index-n4hwcsbd.js} +2 -2
- package/dist/cli/{index-z6v7kwpa.js → index-q6bhmyxb.js} +1 -1
- package/dist/cli/{index-cz25e8xp.js → index-sqe3nqh5.js} +166 -34
- package/dist/cli/{index-q67jb94n.js → index-sswzhcqb.js} +1 -1
- package/dist/cli/{index-8j0va7jp.js → index-tq89td7b.js} +43 -22
- package/dist/cli/{index-dty5qgk2.js → index-vdha477y.js} +1 -1
- package/dist/cli/{index-zb0xcz9t.js → index-vngs0meh.js} +3 -3
- package/dist/cli/{index-fqcjragy.js → index-wknz5c8q.js} +1 -1
- package/dist/cli/{index-9qq7c18c.js → index-ytzz6pq1.js} +36 -1
- package/dist/cli/{index-4w5qdbk7.js → index-zde2mkmg.js} +6 -6
- package/dist/cli/{index-4nt52yr9.js → index-zj6t9zgx.js} +173 -25
- package/dist/cli/{index-btmsqv7p.js → index-zxr5r9b7.js} +5 -4
- package/dist/cli/index-zy7f84cs.js +1210 -0
- package/dist/cli/index.d.ts +11 -1
- package/dist/cli/index.js +61 -39
- package/dist/cli/{knowledge-escalator-ypg14d5r.js → knowledge-escalator-yaxzz0k5.js} +12 -11
- package/dist/cli/{knowledge-events-nkrym4wb.js → knowledge-events-rgcwewpn.js} +10 -9
- package/dist/cli/{knowledge-link-e4qgqmpx.js → knowledge-link-4cg4776a.js} +3 -3
- package/dist/cli/{knowledge-store-vh3nhtg2.js → knowledge-store-qf8t25sw.js} +4 -4
- package/dist/cli/{knowledge-validator-jrxvexv6.js → knowledge-validator-dx6zzcdf.js} +6 -6
- package/dist/cli/{pending-delegations-pw79c8ds.js → pending-delegations-9h1jmtw1.js} +3 -3
- package/dist/cli/{pr-subscriptions-fk628bhc.js → pr-subscriptions-8pg34pev.js} +3 -3
- package/dist/cli/{runner-b02sz2vx.js → runner-cqecp1na.js} +4 -4
- package/dist/cli/{scan-cursor-fp7w5jmc.js → scan-cursor-pbcaj8hj.js} +7 -5
- package/dist/cli/{schema-rptwqbm4.js → schema-tzcjwe8j.js} +3 -1
- package/dist/cli/{scope-persistence-0bkaxawa.js → scope-persistence-mjg4we75.js} +7 -6
- package/dist/cli/{skill-generator-nh8b4gjv.js → skill-generator-7jrzbaej.js} +14 -13
- package/dist/cli/{workspace-snapshot-w3tg4ne5.js → workspace-snapshot-d89zm6wm.js} +5 -2
- package/dist/cli/{worktree-collision-ownership-hqd9ypsz.js → worktree-collision-ownership-vy0kxa98.js} +26 -19
- package/dist/cli/{worktree-isolation-canf3rj8.js → worktree-isolation-awpkp0yh.js} +33 -32
- package/dist/cli/{worktree-provisioning-owner-g24xd417.js → worktree-provisioning-owner-zzkjycp1.js} +3 -3
- package/dist/commands/ci-simulate.d.ts +2 -0
- package/dist/config/cache-paths.d.ts +57 -0
- package/dist/config/evidence-schema.d.ts +3 -3
- package/dist/config/schema.d.ts +9 -0
- package/dist/git/branch.d.ts +2 -0
- package/dist/git/pr.d.ts +2 -0
- package/dist/hooks/delegation-gate/worktree-isolation.d.ts +7 -0
- package/dist/hooks/diff-scope.d.ts +7 -0
- package/dist/hooks/review-receipt-scope.d.ts +7 -0
- package/dist/hooks/reviewer-scope-lifecycle.d.ts +9 -0
- package/dist/hooks/semantic-diff-injection.d.ts +8 -0
- package/dist/index.js +599 -589
- package/dist/mutation/engine.d.ts +11 -0
- package/dist/review/diff-source.d.ts +2 -0
- package/dist/sandbox/capability-probe.d.ts +22 -0
- package/dist/sandbox/executor.d.ts +15 -0
- package/dist/sandbox/linux/bubblewrap-executor.d.ts +6 -0
- package/dist/sandbox/macos/sandbox-exec-executor.d.ts +41 -0
- package/dist/tools/checkpoint.d.ts +11 -0
- package/dist/tools/complexity-hotspots.d.ts +15 -0
- package/dist/tools/diff-summary.d.ts +12 -0
- package/dist/tools/dispatch-lanes.d.ts +8 -0
- package/dist/tools/gh-evidence.d.ts +17 -1
- package/dist/tools/knowledge-receipt.d.ts +1 -1
- package/dist/tools/pkg-audit.d.ts +13 -0
- package/dist/tools/prepare-pr-workflow-checkout.d.ts +1 -0
- package/dist/utils/bun-compat.d.ts +80 -3
- package/dist/utils/git-binary-missing-error.d.ts +80 -2
- package/dist/utils/git-executable.d.ts +179 -0
- package/dist/utils/gitignore-warning.d.ts +10 -0
- package/dist/workflow/coder-settlement.d.ts +18 -0
- package/dist/worktree/core.d.ts +8 -0
- package/dist/worktree/merge.d.ts +33 -0
- package/package.json +3 -2
- package/dist/cli/curator-llm-factory-xgb4pxmm.js +0 -62
- package/dist/cli/guardrail-explain-6wcgr9tz.js +0 -63
- package/dist/cli/index-q1exe2b3.js +0 -256
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
readKnowledge,
|
|
4
4
|
transactKnowledge
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-ec1kywxg.js";
|
|
6
|
+
import {
|
|
7
|
+
init_git_executable,
|
|
8
|
+
resolveGitExecutableAsync
|
|
9
|
+
} from "./index-9e6fdz2h.js";
|
|
6
10
|
import {
|
|
7
11
|
resolveKnowledgeStoreDir
|
|
8
|
-
} from "./index-
|
|
12
|
+
} from "./index-h1p08s3n.js";
|
|
9
13
|
import {
|
|
10
14
|
init_knowledge_types,
|
|
11
15
|
isActiveStatus
|
|
@@ -27,6 +31,7 @@ init_knowledge_types();
|
|
|
27
31
|
init_logger();
|
|
28
32
|
|
|
29
33
|
// src/knowledge/cohort-identity.ts
|
|
34
|
+
init_git_executable();
|
|
30
35
|
import { execFile } from "child_process";
|
|
31
36
|
import { createHash } from "crypto";
|
|
32
37
|
import { realpathSync } from "fs";
|
|
@@ -111,10 +116,16 @@ function normalizeGitRemote(rawUrl) {
|
|
|
111
116
|
return null;
|
|
112
117
|
return `${host}/${pathPart}`;
|
|
113
118
|
}
|
|
114
|
-
function runGit(directory, args) {
|
|
119
|
+
async function runGit(directory, args) {
|
|
120
|
+
let gitExecutable;
|
|
121
|
+
try {
|
|
122
|
+
gitExecutable = await resolveGitExecutableAsync();
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
115
126
|
return new Promise((resolve2) => {
|
|
116
127
|
try {
|
|
117
|
-
const child = execFile(
|
|
128
|
+
const child = execFile(gitExecutable, ["-C", directory, ...args], {
|
|
118
129
|
timeout: GIT_TIMEOUT_MS,
|
|
119
130
|
windowsHide: true,
|
|
120
131
|
encoding: "utf-8",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
handleGuardrailExplain
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-7zehmnv1.js";
|
|
5
5
|
import {
|
|
6
6
|
handleGuardrailLog
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-sswzhcqb.js";
|
|
8
8
|
import {
|
|
9
9
|
COMMAND_REGISTRY,
|
|
10
10
|
SWARM_COMMAND_TOOL_ALLOWLIST,
|
|
@@ -85,67 +85,68 @@ import {
|
|
|
85
85
|
handleWriteRetroCommand,
|
|
86
86
|
normalizeSwarmCommandInput,
|
|
87
87
|
resolveCommand
|
|
88
|
-
} from "./index-
|
|
89
|
-
import"./index-
|
|
90
|
-
import"./index-
|
|
91
|
-
import"./index-
|
|
88
|
+
} from "./index-42ezdzam.js";
|
|
89
|
+
import"./index-dj8cah6s.js";
|
|
90
|
+
import"./index-01nhedm7.js";
|
|
91
|
+
import"./index-fgdhf6a5.js";
|
|
92
92
|
import"./index-134d35c1.js";
|
|
93
|
-
import"./index-
|
|
94
|
-
import"./index-
|
|
95
|
-
import"./index-
|
|
93
|
+
import"./index-abtrcs16.js";
|
|
94
|
+
import"./index-6z5jtf7d.js";
|
|
95
|
+
import"./index-wknz5c8q.js";
|
|
96
96
|
import"./index-y8552snf.js";
|
|
97
|
-
import"./index-
|
|
97
|
+
import"./index-h5krb653.js";
|
|
98
98
|
import"./index-70ha9e09.js";
|
|
99
99
|
import"./index-c8s9a3zh.js";
|
|
100
100
|
import"./index-9ss2m4rs.js";
|
|
101
|
-
import"./index-
|
|
102
|
-
import"./index-
|
|
103
|
-
import"./index-
|
|
104
|
-
import"./index-
|
|
105
|
-
import"./index-
|
|
106
|
-
import"./index-
|
|
101
|
+
import"./index-f36ybbsv.js";
|
|
102
|
+
import"./index-hkdgkkhb.js";
|
|
103
|
+
import"./index-vngs0meh.js";
|
|
104
|
+
import"./index-n06653nr.js";
|
|
105
|
+
import"./index-bac12jpv.js";
|
|
106
|
+
import"./index-vdha477y.js";
|
|
107
107
|
import"./index-rtry5xyf.js";
|
|
108
108
|
import"./index-zsrtt42s.js";
|
|
109
|
-
import"./index-
|
|
110
|
-
import"./index-
|
|
111
|
-
import"./index-
|
|
112
|
-
import"./index-
|
|
113
|
-
import"./index-
|
|
114
|
-
import"./index-
|
|
109
|
+
import"./index-n4hwcsbd.js";
|
|
110
|
+
import"./index-cwtpqm5f.js";
|
|
111
|
+
import"./index-sqe3nqh5.js";
|
|
112
|
+
import"./index-tq89td7b.js";
|
|
113
|
+
import"./index-dvybg11w.js";
|
|
114
|
+
import"./index-q6bhmyxb.js";
|
|
115
115
|
import"./index-556ja8an.js";
|
|
116
116
|
import"./index-7sy3aa9m.js";
|
|
117
117
|
import"./index-wx8zdh4a.js";
|
|
118
|
-
import"./index-
|
|
119
|
-
import"./index-
|
|
120
|
-
import"./index-
|
|
121
|
-
import"./index-
|
|
122
|
-
import"./index-
|
|
118
|
+
import"./index-b44qqqt2.js";
|
|
119
|
+
import"./index-zy7f84cs.js";
|
|
120
|
+
import"./index-ec1kywxg.js";
|
|
121
|
+
import"./index-zde2mkmg.js";
|
|
122
|
+
import"./index-ckq719fr.js";
|
|
123
123
|
import"./index-gprxjmm7.js";
|
|
124
124
|
import"./index-n832052r.js";
|
|
125
|
-
import"./index-
|
|
125
|
+
import"./index-fv0s19g9.js";
|
|
126
126
|
import"./index-z6xqpmqg.js";
|
|
127
|
-
import"./index-
|
|
127
|
+
import"./index-ytzz6pq1.js";
|
|
128
128
|
import {
|
|
129
129
|
init_schema,
|
|
130
130
|
stripKnownSwarmPrefix
|
|
131
|
-
} from "./index-
|
|
132
|
-
import"./index-4rhhvd1a.js";
|
|
131
|
+
} from "./index-68mqwvf5.js";
|
|
133
132
|
import {
|
|
134
133
|
AGENT_TOOL_MAP,
|
|
135
134
|
ORCHESTRATOR_NAME,
|
|
136
135
|
init_constants
|
|
137
136
|
} from "./index-v3y3qg48.js";
|
|
137
|
+
import"./index-9e6fdz2h.js";
|
|
138
|
+
import"./index-4rhhvd1a.js";
|
|
138
139
|
import"./index-zjygnfay.js";
|
|
139
140
|
import"./index-ae75rja9.js";
|
|
140
|
-
import"./index-
|
|
141
|
-
import"./index-
|
|
141
|
+
import"./index-h1p08s3n.js";
|
|
142
|
+
import"./index-9s8drsf9.js";
|
|
142
143
|
import"./index-ed5ykebp.js";
|
|
143
144
|
import"./index-bk5tah7q.js";
|
|
144
145
|
import"./index-f9vvg5xb.js";
|
|
145
146
|
import"./index-1jsmmx7y.js";
|
|
146
147
|
import"./index-7g4c7s5r.js";
|
|
147
148
|
import"./index-bpmtbmy9.js";
|
|
148
|
-
import"./index-
|
|
149
|
+
import"./index-zj6t9zgx.js";
|
|
149
150
|
import"./index-zgwm4ryv.js";
|
|
150
151
|
import"./index-a76rekgs.js";
|
|
151
152
|
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
resolveSwarmKnowledgePath,
|
|
7
7
|
transactKnowledge,
|
|
8
8
|
wordBigrams
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-ec1kywxg.js";
|
|
10
10
|
import {
|
|
11
11
|
queryHistoricalOutcomes,
|
|
12
12
|
readKnowledgeEvents,
|
|
13
13
|
recordKnowledgeEvent
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-zde2mkmg.js";
|
|
15
15
|
import {
|
|
16
16
|
init_knowledge_types,
|
|
17
17
|
isActiveStatus
|
|
@@ -224,11 +224,11 @@ async function maybeQuarantineOnContradiction(directory, entryId, threshold, win
|
|
|
224
224
|
alreadyInactive: true
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
const { quarantineEntry } = await import("./knowledge-validator-
|
|
227
|
+
const { quarantineEntry } = await import("./knowledge-validator-dx6zzcdf.js");
|
|
228
228
|
let policyConfig;
|
|
229
229
|
try {
|
|
230
|
-
const { KnowledgeConfigSchema } = await import("./schema-
|
|
231
|
-
const { loadPluginConfigWithMeta } = await import("./index-
|
|
230
|
+
const { KnowledgeConfigSchema } = await import("./schema-tzcjwe8j.js");
|
|
231
|
+
const { loadPluginConfigWithMeta } = await import("./index-zxr5r9b7.js");
|
|
232
232
|
const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
|
|
233
233
|
policyConfig = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
|
|
234
234
|
} catch {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
validateSwarmPath
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-fv0s19g9.js";
|
|
5
5
|
import {
|
|
6
6
|
withEvidenceLock
|
|
7
7
|
} from "./index-f9vvg5xb.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./index-bpmtbmy9.js";
|
|
12
12
|
import {
|
|
13
13
|
bunWrite
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-zj6t9zgx.js";
|
|
15
15
|
import {
|
|
16
16
|
init_logger,
|
|
17
17
|
warn
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
autoCommitDirty,
|
|
4
4
|
cleanUntrackedFiles
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-tq89td7b.js";
|
|
6
6
|
import {
|
|
7
7
|
isPathWithinDeclaredScope,
|
|
8
8
|
unsafePathTextReason
|
|
9
9
|
} from "./index-556ja8an.js";
|
|
10
10
|
import {
|
|
11
11
|
validateSwarmPath
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-fv0s19g9.js";
|
|
13
|
+
import {
|
|
14
|
+
init_git_executable,
|
|
15
|
+
resolveGitExecutable
|
|
16
|
+
} from "./index-9e6fdz2h.js";
|
|
13
17
|
import {
|
|
14
18
|
advisoryWarn,
|
|
15
19
|
init_warning_buffer
|
|
@@ -18,7 +22,7 @@ import {
|
|
|
18
22
|
atomicWriteFile,
|
|
19
23
|
taskEvidencePath,
|
|
20
24
|
withTaskEvidenceLock
|
|
21
|
-
} from "./index-
|
|
25
|
+
} from "./index-9s8drsf9.js";
|
|
22
26
|
import {
|
|
23
27
|
telemetry
|
|
24
28
|
} from "./index-1jsmmx7y.js";
|
|
@@ -27,8 +31,9 @@ import {
|
|
|
27
31
|
init_zod
|
|
28
32
|
} from "./index-bpmtbmy9.js";
|
|
29
33
|
import {
|
|
30
|
-
bunSpawn
|
|
31
|
-
|
|
34
|
+
bunSpawn,
|
|
35
|
+
classifySpawnFailure
|
|
36
|
+
} from "./index-zj6t9zgx.js";
|
|
32
37
|
import {
|
|
33
38
|
log
|
|
34
39
|
} from "./index-zgwm4ryv.js";
|
|
@@ -148,33 +153,99 @@ function recoveryReadErrored(directory) {
|
|
|
148
153
|
return readRecoveryRecords(directory).errored;
|
|
149
154
|
}
|
|
150
155
|
|
|
156
|
+
// src/utils/git-binary-missing-error.ts
|
|
157
|
+
class GitUnavailableError extends Error {
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class GitBinaryMissingError extends GitUnavailableError {
|
|
161
|
+
name = "GitBinaryMissingError";
|
|
162
|
+
constructor(message = "git binary is not available", options) {
|
|
163
|
+
super(message, options);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
class GitSpawnCwdError extends GitUnavailableError {
|
|
168
|
+
name = "GitSpawnCwdError";
|
|
169
|
+
cwd;
|
|
170
|
+
fault;
|
|
171
|
+
constructor(cwd, fault, options) {
|
|
172
|
+
super(fault === "missing" ? `git could not start: working directory no longer exists: ${cwd}` : `git could not start: working directory could not be inspected (permission denied): ${cwd}`, options);
|
|
173
|
+
this.cwd = cwd;
|
|
174
|
+
this.fault = fault;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function isGitBinaryMissing(err, cwd) {
|
|
178
|
+
return classifySpawnFailure(err, cwd) === "binary-missing";
|
|
179
|
+
}
|
|
180
|
+
function isSpawnCwdMissing(err, cwd) {
|
|
181
|
+
return classifySpawnFailure(err, cwd) === "cwd-missing";
|
|
182
|
+
}
|
|
183
|
+
function isSpawnCwdUnreadable(err, cwd) {
|
|
184
|
+
return classifySpawnFailure(err, cwd) === "cwd-unreadable";
|
|
185
|
+
}
|
|
186
|
+
|
|
151
187
|
// src/worktree/merge.ts
|
|
188
|
+
init_git_executable();
|
|
152
189
|
var _internals = {
|
|
153
190
|
bunSpawn,
|
|
154
191
|
platform: process.platform,
|
|
155
192
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
156
193
|
cleanupOrphanedBranches,
|
|
157
194
|
startupOrphanRecovery,
|
|
158
|
-
extractSessionId
|
|
195
|
+
extractSessionId,
|
|
196
|
+
resolveGitExecutable
|
|
159
197
|
};
|
|
160
198
|
var MERGE_TIMEOUT_MS = 30000;
|
|
199
|
+
var GIT_SPAWN_FAILURE_EXIT_CODE = 1;
|
|
200
|
+
var SOURCE_WORKTREE_GONE_STAGE = "source-worktree-gone";
|
|
201
|
+
var SOURCE_WORKTREE_UNCERTAIN_STAGE = "source-worktree-uncertain";
|
|
202
|
+
function gitSpawnFailureResult(error, cwd, args) {
|
|
203
|
+
const operation = args[0] ?? "command";
|
|
204
|
+
let kind;
|
|
205
|
+
let message;
|
|
206
|
+
if (isSpawnCwdMissing(error, cwd)) {
|
|
207
|
+
kind = "cwd-missing";
|
|
208
|
+
message = `git ${operation} could not start: working directory no longer exists: ${cwd}`;
|
|
209
|
+
} else if (isSpawnCwdUnreadable(error, cwd)) {
|
|
210
|
+
kind = "cwd-unreadable";
|
|
211
|
+
message = `git ${operation} could not start: working directory could not be inspected: ${cwd}`;
|
|
212
|
+
} else {
|
|
213
|
+
kind = "spawn-failed";
|
|
214
|
+
message = `git ${operation} could not start in ${cwd}: ${error instanceof Error ? error.message : String(error)}`;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
exitCode: GIT_SPAWN_FAILURE_EXIT_CODE,
|
|
218
|
+
stdout: "",
|
|
219
|
+
stderr: message,
|
|
220
|
+
spawnFailure: { kind, cwd, message }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
161
223
|
async function runGit(args, cwd, timeoutMs = MERGE_TIMEOUT_MS) {
|
|
162
|
-
|
|
163
|
-
cwd,
|
|
164
|
-
timeout: timeoutMs,
|
|
165
|
-
stdin: "ignore",
|
|
166
|
-
stdout: "pipe",
|
|
167
|
-
stderr: "pipe",
|
|
168
|
-
env: { ...process.env, LC_ALL: "C" }
|
|
169
|
-
});
|
|
224
|
+
let proc;
|
|
170
225
|
try {
|
|
226
|
+
proc = _internals.bunSpawn([_internals.resolveGitExecutable(), ...args], {
|
|
227
|
+
cwd,
|
|
228
|
+
timeout: timeoutMs,
|
|
229
|
+
stdin: "ignore",
|
|
230
|
+
stdout: "pipe",
|
|
231
|
+
stderr: "pipe",
|
|
232
|
+
env: { ...process.env, LC_ALL: "C" }
|
|
233
|
+
});
|
|
234
|
+
if (proc.spawnError) {
|
|
235
|
+
return gitSpawnFailureResult(proc.spawnError, cwd, args);
|
|
236
|
+
}
|
|
171
237
|
const exitCode = await proc.exited;
|
|
238
|
+
if (proc.spawnError) {
|
|
239
|
+
return gitSpawnFailureResult(proc.spawnError, cwd, args);
|
|
240
|
+
}
|
|
172
241
|
const stdout = await proc.stdout.text();
|
|
173
242
|
const stderr = await proc.stderr.text();
|
|
174
243
|
return { exitCode, stdout, stderr };
|
|
244
|
+
} catch (error) {
|
|
245
|
+
return gitSpawnFailureResult(error, cwd, args);
|
|
175
246
|
} finally {
|
|
176
247
|
try {
|
|
177
|
-
proc
|
|
248
|
+
proc?.kill();
|
|
178
249
|
} catch {}
|
|
179
250
|
}
|
|
180
251
|
}
|
|
@@ -275,10 +346,10 @@ async function reconcileLandedMerge(primaryDir, provenance) {
|
|
|
275
346
|
return trailerSearch.stdout.trim() ? { landed: true, method: "cherry-pick-trailer" } : { landed: false };
|
|
276
347
|
}
|
|
277
348
|
async function postMergeCleanup(directory, branchName) {
|
|
278
|
-
const deleteResult = await runGit(["branch", "-D", branchName], directory);
|
|
279
|
-
const deleteOk = deleteResult.exitCode === 0;
|
|
280
349
|
const pruneResult = await runGit(["worktree", "prune"], directory);
|
|
281
350
|
const pruneOk = pruneResult.exitCode === 0;
|
|
351
|
+
const deleteResult = await runGit(["branch", "-D", branchName], directory);
|
|
352
|
+
const deleteOk = deleteResult.exitCode === 0;
|
|
282
353
|
if (deleteOk && pruneOk) {
|
|
283
354
|
return { cleaned: true };
|
|
284
355
|
}
|
|
@@ -300,12 +371,46 @@ async function pruneStaleWorktreeMetadata(directory) {
|
|
|
300
371
|
error: result.stderr.trim() || result.stdout.trim() || `git worktree prune exited ${result.exitCode}`
|
|
301
372
|
};
|
|
302
373
|
}
|
|
374
|
+
async function readLaneBranchHead(branchName, primaryDir) {
|
|
375
|
+
return runGit(["rev-parse", "--verify", "--quiet", `refs/heads/${branchName}`], primaryDir);
|
|
376
|
+
}
|
|
377
|
+
async function captureLaneSourceHead(worktreePath, branchName, primaryDir, knownMissing) {
|
|
378
|
+
if (!knownMissing) {
|
|
379
|
+
const fromWorktree = await runGit(["rev-parse", "HEAD"], worktreePath);
|
|
380
|
+
if (fromWorktree.spawnFailure?.kind !== "cwd-missing") {
|
|
381
|
+
return { result: fromWorktree, sourceWorktreeMissing: false };
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
result: await readLaneBranchHead(branchName, primaryDir),
|
|
386
|
+
sourceWorktreeMissing: true
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
async function handleSourceWorktreeGone(branchHead, worktreePath, branchName, primaryDir, provenance) {
|
|
390
|
+
const branchResolved = branchHead.spawnFailure === undefined && branchHead.exitCode === 0 && branchHead.stdout.trim().length > 0;
|
|
391
|
+
if (!branchResolved) {
|
|
392
|
+
const definitelyAbsent = branchHead.spawnFailure === undefined && branchHead.exitCode === 1;
|
|
393
|
+
return {
|
|
394
|
+
failed: true,
|
|
395
|
+
stage: definitelyAbsent ? SOURCE_WORKTREE_GONE_STAGE : SOURCE_WORKTREE_UNCERTAIN_STAGE,
|
|
396
|
+
message: definitelyAbsent ? `Lane worktree "${worktreePath}" is gone and branch "${branchName}" no longer exists; nothing is recoverable` : `Lane worktree "${worktreePath}" is gone and branch "${branchName}" existence could not be determined: ${branchHead.stderr.trim() || `git exited ${branchHead.exitCode}`}`,
|
|
397
|
+
...provenance ? { provenance } : {}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const prune = await runGit(["worktree", "prune"], primaryDir);
|
|
401
|
+
if (prune.exitCode !== 0) {
|
|
402
|
+
log(`[worktree] attemptMergeBackFromDirty: worktree prune failed for "${worktreePath}": ${prune.stderr.trim() || prune.stdout.trim()}`);
|
|
403
|
+
}
|
|
404
|
+
advisoryWarn(`STALE_LANE_WORKTREE_DETECTED: lane worktree "${worktreePath}" no longer exists. ` + `Its stale git registration was pruned, and the merge-back for branch "${branchName}" ` + `is being taken from "${primaryDir}" instead. Any uncommitted work in that worktree is ` + "unrecoverable; every commit on the branch is preserved.");
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
303
407
|
async function attemptMergeBackFromDirty(worktreePath, branchName, primaryDir, strategy, options = {}) {
|
|
304
408
|
let autoCommitted = false;
|
|
305
409
|
let cleaned = false;
|
|
306
410
|
let autoCommitFailed = false;
|
|
307
411
|
let cleanFailed = false;
|
|
308
412
|
let provenance = options.resume;
|
|
413
|
+
let sourceWorktreeMissing = false;
|
|
309
414
|
if (provenance) {
|
|
310
415
|
if (provenance.branchName !== branchName || provenance.strategy !== strategy || options.operationId !== undefined && provenance.operationId !== options.operationId) {
|
|
311
416
|
return {
|
|
@@ -334,7 +439,14 @@ async function attemptMergeBackFromDirty(worktreePath, branchName, primaryDir, s
|
|
|
334
439
|
provenance
|
|
335
440
|
};
|
|
336
441
|
}
|
|
337
|
-
const
|
|
442
|
+
const source = await captureLaneSourceHead(worktreePath, branchName, primaryDir, false);
|
|
443
|
+
if (source.sourceWorktreeMissing) {
|
|
444
|
+
const unrecoverable = await handleSourceWorktreeGone(source.result, worktreePath, branchName, primaryDir, provenance);
|
|
445
|
+
if (unrecoverable)
|
|
446
|
+
return unrecoverable;
|
|
447
|
+
sourceWorktreeMissing = true;
|
|
448
|
+
}
|
|
449
|
+
const sourceHead = source.result;
|
|
338
450
|
const targetHead = await runGit(["rev-parse", "HEAD"], primaryDir);
|
|
339
451
|
if (sourceHead.exitCode !== 0 || targetHead.exitCode !== 0 || sourceHead.stdout.trim() !== provenance.sourceHead || targetHead.stdout.trim() !== provenance.targetHeadBefore) {
|
|
340
452
|
return {
|
|
@@ -345,7 +457,7 @@ async function attemptMergeBackFromDirty(worktreePath, branchName, primaryDir, s
|
|
|
345
457
|
};
|
|
346
458
|
}
|
|
347
459
|
}
|
|
348
|
-
if (!provenance) {
|
|
460
|
+
if (!provenance && !sourceWorktreeMissing) {
|
|
349
461
|
const commitResult = await autoCommitDirty(worktreePath);
|
|
350
462
|
if (commitResult.committed) {
|
|
351
463
|
autoCommitted = true;
|
|
@@ -354,20 +466,33 @@ async function attemptMergeBackFromDirty(worktreePath, branchName, primaryDir, s
|
|
|
354
466
|
log(`[worktree] attemptMergeBackFromDirty: auto-commit failed for worktree "${worktreePath}" branch "${branchName}": ${commitResult.reason}`);
|
|
355
467
|
}
|
|
356
468
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
cleaned
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
469
|
+
if (!sourceWorktreeMissing) {
|
|
470
|
+
const cleanResult = await cleanUntrackedFiles(worktreePath);
|
|
471
|
+
if (cleanResult.cleaned) {
|
|
472
|
+
cleaned = true;
|
|
473
|
+
} else {
|
|
474
|
+
cleanFailed = true;
|
|
475
|
+
log(`[worktree] attemptMergeBackFromDirty: clean untracked failed for worktree "${worktreePath}" branch "${branchName}": ${cleanResult.error}`);
|
|
476
|
+
}
|
|
363
477
|
}
|
|
364
478
|
if (autoCommitFailed && cleanFailed) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
479
|
+
const probe = await runGit(["rev-parse", "--git-dir"], worktreePath);
|
|
480
|
+
if (probe.spawnFailure?.kind === "cwd-missing") {
|
|
481
|
+
const unrecoverable = await handleSourceWorktreeGone(await readLaneBranchHead(branchName, primaryDir), worktreePath, branchName, primaryDir, provenance);
|
|
482
|
+
if (unrecoverable)
|
|
483
|
+
return unrecoverable;
|
|
484
|
+
sourceWorktreeMissing = true;
|
|
485
|
+
autoCommitFailed = false;
|
|
486
|
+
cleanFailed = false;
|
|
487
|
+
cleaned = false;
|
|
488
|
+
} else {
|
|
489
|
+
return {
|
|
490
|
+
failed: true,
|
|
491
|
+
stage: "cleanup",
|
|
492
|
+
message: "Auto-commit and clean both failed; abandoning worktree",
|
|
493
|
+
...provenance ? { provenance } : {}
|
|
494
|
+
};
|
|
495
|
+
}
|
|
371
496
|
}
|
|
372
497
|
if (!provenance && (options.operationId || options.onBeforeMerge)) {
|
|
373
498
|
if (!options.operationId) {
|
|
@@ -377,7 +502,14 @@ async function attemptMergeBackFromDirty(worktreePath, branchName, primaryDir, s
|
|
|
377
502
|
message: "A pre-merge callback requires a stable operationId"
|
|
378
503
|
};
|
|
379
504
|
}
|
|
380
|
-
const
|
|
505
|
+
const source = await captureLaneSourceHead(worktreePath, branchName, primaryDir, sourceWorktreeMissing);
|
|
506
|
+
if (source.sourceWorktreeMissing && !sourceWorktreeMissing) {
|
|
507
|
+
const unrecoverable = await handleSourceWorktreeGone(source.result, worktreePath, branchName, primaryDir, provenance);
|
|
508
|
+
if (unrecoverable)
|
|
509
|
+
return unrecoverable;
|
|
510
|
+
sourceWorktreeMissing = true;
|
|
511
|
+
}
|
|
512
|
+
const sourceHead = source.result;
|
|
381
513
|
const targetHead = await runGit(["rev-parse", "HEAD"], primaryDir);
|
|
382
514
|
if (sourceHead.exitCode !== 0 || targetHead.exitCode !== 0 || !sourceHead.stdout.trim() || !targetHead.stdout.trim()) {
|
|
383
515
|
return {
|
|
@@ -484,6 +616,7 @@ async function cleanupOrphanedBranches(directory, activeSessionIds = [], options
|
|
|
484
616
|
};
|
|
485
617
|
}
|
|
486
618
|
const branches = await listLaneBranches(directory);
|
|
619
|
+
await runGit(["worktree", "prune"], directory);
|
|
487
620
|
for (const branch of branches) {
|
|
488
621
|
const sessionId = extractSessionId(branch);
|
|
489
622
|
if (sessionId !== null && activeSessionIds.includes(sessionId)) {
|
|
@@ -504,7 +637,6 @@ async function cleanupOrphanedBranches(directory, activeSessionIds = [], options
|
|
|
504
637
|
});
|
|
505
638
|
}
|
|
506
639
|
}
|
|
507
|
-
await runGit(["worktree", "prune"], directory);
|
|
508
640
|
return {
|
|
509
641
|
removed,
|
|
510
642
|
skipped,
|
|
@@ -1369,4 +1501,4 @@ function compareTaskWorkflowStateRank(left, right) {
|
|
|
1369
1501
|
return WORKFLOW_STATE_RANK[left] - WORKFLOW_STATE_RANK[right];
|
|
1370
1502
|
}
|
|
1371
1503
|
|
|
1372
|
-
export { sanitizeTaskId, listRecoveryRecords, _internals, getMergeStrategy, reconcileLandedMerge, postMergeCleanup, pruneStaleWorktreeMetadata, attemptMergeBackFromDirty, cleanupOrphanedBranches, startupOrphanRecovery, readWorkflowWalFile, writeWorkflowWalFile, TASK_WORKFLOW_SCHEMA_MARKER, assertTaskEvidenceWriteAllowed, parseTaskEvidence, DEFAULT_REQUIRED_GATES, isValidTaskId, getTaskWorkflowSnapshot, reduceTaskWorkflowSnapshot, deriveRequiredGates, expandRequiredGates, transitionTaskWorkflowEvidence, withTaskEvidenceTransaction, recordGateEvidence, recordAgentDispatch, readTaskEvidence, readTaskEvidenceRaw, hasPassedAllGates, compareTaskWorkflowStateRank };
|
|
1504
|
+
export { sanitizeTaskId, listRecoveryRecords, GitBinaryMissingError, GitSpawnCwdError, isGitBinaryMissing, isSpawnCwdMissing, isSpawnCwdUnreadable, _internals, SOURCE_WORKTREE_GONE_STAGE, SOURCE_WORKTREE_UNCERTAIN_STAGE, getMergeStrategy, reconcileLandedMerge, postMergeCleanup, pruneStaleWorktreeMetadata, attemptMergeBackFromDirty, cleanupOrphanedBranches, startupOrphanRecovery, readWorkflowWalFile, writeWorkflowWalFile, TASK_WORKFLOW_SCHEMA_MARKER, assertTaskEvidenceWriteAllowed, parseTaskEvidence, DEFAULT_REQUIRED_GATES, isValidTaskId, getTaskWorkflowSnapshot, reduceTaskWorkflowSnapshot, deriveRequiredGates, expandRequiredGates, transitionTaskWorkflowEvidence, withTaskEvidenceTransaction, recordGateEvidence, recordAgentDispatch, readTaskEvidence, readTaskEvidenceRaw, hasPassedAllGates, compareTaskWorkflowStateRank };
|