opencode-swarm 7.135.2 → 7.135.4
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/critic-gate/SKILL.md +10 -0
- package/dist/agents/explorer.d.ts +1 -1
- package/dist/agents/index.d.ts +12 -0
- package/dist/cli/{config-doctor-pj3yvxdb.js → config-doctor-fgmemknc.js} +3 -2
- package/dist/cli/{core-4va9z2ng.js → core-4z1s2ak1.js} +3 -2
- package/dist/cli/{curation-policy-b2caf3v3.js → curation-policy-frs28q57.js} +3 -3
- package/dist/cli/{curator-drift-2ta83hss.js → curator-drift-jpap6hv4.js} +2 -2
- package/dist/cli/{curator-llm-factory-9983528d.js → curator-llm-factory-pr59p535.js} +25 -24
- package/dist/cli/{curator-r1s2mwf2.js → curator-psq8m2j7.js} +25 -24
- package/dist/cli/{dispatch-wtk6dxky.js → dispatch-b1fge4xk.js} +2 -2
- package/dist/cli/{evidence-summary-service-feby8ny0.js → evidence-summary-service-w006jnpg.js} +5 -5
- package/dist/cli/{explorer-15gqzxh8.js → explorer-swjc297z.js} +1 -1
- package/dist/cli/{gate-evidence-84b03mb4.js → gate-evidence-aenyz6vt.js} +2 -2
- package/dist/cli/{guardrail-explain-pwxvg5n0.js → guardrail-explain-ws45zchy.js} +26 -25
- package/dist/cli/{guardrail-log-yzpz8b7t.js → guardrail-log-gbzek1pz.js} +5 -4
- package/dist/cli/{hive-promoter-586dhndj.js → hive-promoter-gdbg4nyd.js} +25 -24
- package/dist/cli/index-3jcyn8g6.js +1219 -0
- package/dist/cli/{index-hdy2nd5h.js → index-45t7w06b.js} +4 -4
- package/dist/cli/{index-hvrrq3f3.js → index-4g3nq4sh.js} +1 -1
- package/dist/cli/{index-02cqjna3.js → index-5s1q6xcw.js} +4 -4
- package/dist/cli/{index-340chr1e.js → index-66w4jjg6.js} +10124 -10005
- package/dist/cli/{index-dg1njnms.js → index-6mjf4vr1.js} +1 -1
- package/dist/cli/{index-9c3gf2wd.js → index-ajehqzvn.js} +6 -4
- package/dist/cli/{index-2pxk6qg4.js → index-b34vbxmx.js} +4 -2
- package/dist/cli/{index-d5psymdk.js → index-c9ddxv4k.js} +57 -8
- package/dist/cli/{index-j0kte6gd.js → index-cg413zhk.js} +8 -1210
- package/dist/cli/{index-7pnvf04s.js → index-cggqh2dz.js} +10 -10
- package/dist/cli/{index-bs4m85v1.js → index-cgqekdja.js} +2 -2
- package/dist/cli/{index-j92ser8n.js → index-ck9rx6j1.js} +5 -3
- package/dist/cli/{index-jgkjxpdh.js → index-fx7bn93y.js} +2 -2
- package/dist/cli/{index-qqkw794p.js → index-g86vfxnk.js} +3 -3
- package/dist/cli/{index-3m7kpnqf.js → index-jsp8r6f9.js} +1 -1
- package/dist/cli/{index-8gw8p7yh.js → index-mysdsqtk.js} +21 -4
- package/dist/cli/{index-3xbx305x.js → index-tcn457d5.js} +1 -1
- package/dist/cli/{index-ckdva4rs.js → index-tegdwx34.js} +5 -5
- package/dist/cli/{index-b0eva00y.js → index-vh39nxpx.js} +1 -1
- package/dist/cli/{index-73dfyfhq.js → index-x20cgr2q.js} +1 -1
- package/dist/cli/{index-cwdy5vw9.js → index-xfeg0c0c.js} +31 -29
- package/dist/cli/{index-g3meqrsg.js → index-ys04j1np.js} +12 -10
- package/dist/cli/index.js +28 -26
- package/dist/cli/{knowledge-escalator-w7by1m8m.js → knowledge-escalator-0060q7we.js} +4 -4
- package/dist/cli/{knowledge-events-n8xxsay3.js → knowledge-events-yh2qwa6k.js} +6 -2
- package/dist/cli/knowledge-link-mm1w967j.js +1 -1
- package/dist/cli/{knowledge-store-xzmvfnx3.js → knowledge-store-geqaez58.js} +2 -2
- package/dist/cli/{knowledge-validator-5q1amsq6.js → knowledge-validator-4zq4vm7t.js} +5 -5
- package/dist/cli/{pending-delegations-mt5gs1bt.js → pending-delegations-qajsxct0.js} +4 -4
- package/dist/cli/{pr-subscriptions-v5xd3j6d.js → pr-subscriptions-qhr41epq.js} +4 -4
- package/dist/cli/{scan-cursor-1q1zmt4b.js → scan-cursor-nk2rybhq.js} +3 -3
- package/dist/cli/{schema-8mtsfspm.js → schema-th3tx32c.js} +2 -1
- package/dist/cli/scope-persistence-h2fpgxww.js +2 -2
- package/dist/cli/{skill-generator-54xbjgak.js → skill-generator-1947bbkn.js} +6 -6
- package/dist/cli/{worktree-collision-ownership-15hymf1y.js → worktree-collision-ownership-13btcj9g.js} +5 -5
- package/dist/commands/approve-plan-critic.d.ts +21 -0
- package/dist/commands/registry.d.ts +8 -0
- package/dist/config/cache-paths.d.ts +48 -0
- package/dist/config/constants.d.ts +18 -0
- package/dist/config/host-path.d.ts +95 -0
- package/dist/config/lane-context.d.ts +117 -0
- package/dist/config/lane-permissions.d.ts +277 -0
- package/dist/config/schema.d.ts +10 -0
- package/dist/config/swarm-branch.d.ts +130 -0
- package/dist/hooks/curator-postmortem.d.ts +8 -0
- package/dist/hooks/delegate-ack-collector.d.ts +21 -0
- package/dist/hooks/delegation-gate.d.ts +42 -1
- package/dist/hooks/knowledge-events.d.ts +33 -1
- package/dist/hooks/skill-propagation-gate.d.ts +10 -0
- package/dist/index.js +225 -212
- package/dist/memory/schema.d.ts +4 -4
- package/dist/services/knowledge-diagnostics.d.ts +2 -0
- package/dist/tools/approve-plan-critic.d.ts +5 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/package.json +1 -1
- package/dist/cli/{index-bfd4xfpp.js → index-4qzeef9h.js} +3 -3
- package/dist/cli/{index-ryqnn3nv.js → index-mrtms113.js} +3 -3
- package/dist/cli/{index-m0ynxkaa.js → index-vm4xw9z3.js} +3 -3
|
@@ -9,17 +9,17 @@ import {
|
|
|
9
9
|
sweepStale,
|
|
10
10
|
unsubscribe,
|
|
11
11
|
updateSnapshot
|
|
12
|
-
} from "./index-
|
|
13
|
-
import"./index-
|
|
12
|
+
} from "./index-tcn457d5.js";
|
|
13
|
+
import"./index-4qzeef9h.js";
|
|
14
14
|
import"./index-fsrp8wp3.js";
|
|
15
15
|
import"./index-09b9zncg.js";
|
|
16
16
|
import"./index-7g4c7s5r.js";
|
|
17
|
-
import"./index-7a2hm51h.js";
|
|
18
17
|
import"./index-bpmtbmy9.js";
|
|
18
|
+
import"./index-7a2hm51h.js";
|
|
19
19
|
import"./index-z6xqpmqg.js";
|
|
20
20
|
import"./index-zjygnfay.js";
|
|
21
|
-
import"./index-zgwm4ryv.js";
|
|
22
21
|
import"./index-y111zefa.js";
|
|
22
|
+
import"./index-zgwm4ryv.js";
|
|
23
23
|
import"./index-a76rekgs.js";
|
|
24
24
|
export {
|
|
25
25
|
updateSnapshot,
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
alreadyCuratedThisGeneration,
|
|
5
5
|
claimNextScanBatch,
|
|
6
6
|
getScanStatus
|
|
7
|
-
} from "./index-
|
|
8
|
-
import"./index-
|
|
7
|
+
} from "./index-vh39nxpx.js";
|
|
8
|
+
import"./index-5s1q6xcw.js";
|
|
9
9
|
import"./index-ae75rja9.js";
|
|
10
10
|
import"./index-dzyjb33e.js";
|
|
11
11
|
import"./index-ey29aap6.js";
|
|
@@ -14,8 +14,8 @@ import"./index-fsrp8wp3.js";
|
|
|
14
14
|
import"./index-09b9zncg.js";
|
|
15
15
|
import"./index-7g4c7s5r.js";
|
|
16
16
|
import"./index-7a2hm51h.js";
|
|
17
|
-
import"./index-zgwm4ryv.js";
|
|
18
17
|
import"./index-y111zefa.js";
|
|
18
|
+
import"./index-zgwm4ryv.js";
|
|
19
19
|
import"./index-a76rekgs.js";
|
|
20
20
|
export {
|
|
21
21
|
getScanStatus,
|
|
@@ -93,8 +93,9 @@ import {
|
|
|
93
93
|
resolveGeneratedAgentRole,
|
|
94
94
|
resolveGuardrailsConfig,
|
|
95
95
|
stripKnownSwarmPrefix
|
|
96
|
-
} from "./index-
|
|
96
|
+
} from "./index-cg413zhk.js";
|
|
97
97
|
import"./index-bk5tah7q.js";
|
|
98
|
+
import"./index-3jcyn8g6.js";
|
|
98
99
|
import"./index-bpmtbmy9.js";
|
|
99
100
|
import"./index-zjygnfay.js";
|
|
100
101
|
import"./index-a76rekgs.js";
|
|
@@ -17,10 +17,10 @@ import"./index-wxyxf0bd.js";
|
|
|
17
17
|
import"./index-1kz6da87.js";
|
|
18
18
|
import"./index-09b9zncg.js";
|
|
19
19
|
import"./index-7g4c7s5r.js";
|
|
20
|
-
import"./index-7a2hm51h.js";
|
|
21
20
|
import"./index-bpmtbmy9.js";
|
|
22
|
-
import"./index-
|
|
21
|
+
import"./index-7a2hm51h.js";
|
|
23
22
|
import"./index-y111zefa.js";
|
|
23
|
+
import"./index-zgwm4ryv.js";
|
|
24
24
|
import"./index-a76rekgs.js";
|
|
25
25
|
export {
|
|
26
26
|
writeScopeToDisk,
|
|
@@ -33,12 +33,12 @@ import {
|
|
|
33
33
|
sanitizeSlug,
|
|
34
34
|
selectCandidateEntries,
|
|
35
35
|
writeEvalStub
|
|
36
|
-
} from "./index-
|
|
37
|
-
import"./index-
|
|
38
|
-
import"./index-
|
|
36
|
+
} from "./index-g86vfxnk.js";
|
|
37
|
+
import"./index-fx7bn93y.js";
|
|
38
|
+
import"./index-jsp8r6f9.js";
|
|
39
39
|
import"./index-rtry5xyf.js";
|
|
40
|
-
import"./index-
|
|
41
|
-
import"./index-
|
|
40
|
+
import"./index-5s1q6xcw.js";
|
|
41
|
+
import"./index-mysdsqtk.js";
|
|
42
42
|
import"./index-ae75rja9.js";
|
|
43
43
|
import"./index-dzyjb33e.js";
|
|
44
44
|
import"./index-ey29aap6.js";
|
|
@@ -48,8 +48,8 @@ import"./index-fsrp8wp3.js";
|
|
|
48
48
|
import"./index-09b9zncg.js";
|
|
49
49
|
import"./index-7g4c7s5r.js";
|
|
50
50
|
import"./index-7a2hm51h.js";
|
|
51
|
-
import"./index-zgwm4ryv.js";
|
|
52
51
|
import"./index-y111zefa.js";
|
|
52
|
+
import"./index-zgwm4ryv.js";
|
|
53
53
|
import"./index-a76rekgs.js";
|
|
54
54
|
export {
|
|
55
55
|
writeEvalStub,
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
scanWorktreeProvisioningOwnersForRecovery
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-x20cgr2q.js";
|
|
5
5
|
import {
|
|
6
6
|
scanWorktreeMergeFailuresForRecovery
|
|
7
7
|
} from "./index-b8zgtz81.js";
|
|
8
8
|
import {
|
|
9
9
|
scanDelegationFallbacksForRecovery,
|
|
10
10
|
scanDelegationsForRecovery
|
|
11
|
-
} from "./index-
|
|
12
|
-
import"./index-
|
|
11
|
+
} from "./index-45t7w06b.js";
|
|
12
|
+
import"./index-4qzeef9h.js";
|
|
13
13
|
import"./index-fsrp8wp3.js";
|
|
14
14
|
import"./index-09b9zncg.js";
|
|
15
15
|
import"./index-7g4c7s5r.js";
|
|
16
|
-
import"./index-7a2hm51h.js";
|
|
17
16
|
import"./index-bpmtbmy9.js";
|
|
17
|
+
import"./index-7a2hm51h.js";
|
|
18
18
|
import"./index-z6xqpmqg.js";
|
|
19
19
|
import"./index-zjygnfay.js";
|
|
20
|
-
import"./index-zgwm4ryv.js";
|
|
21
20
|
import {
|
|
22
21
|
bunSpawn
|
|
23
22
|
} from "./index-y111zefa.js";
|
|
23
|
+
import"./index-zgwm4ryv.js";
|
|
24
24
|
import"./index-a76rekgs.js";
|
|
25
25
|
|
|
26
26
|
// src/hooks/delegation-gate/worktree-collision-ownership.ts
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle /swarm approve-plan-critic command.
|
|
3
|
+
*
|
|
4
|
+
* Human-only escape hatch for the ratchet-tighter `critic_pre_plan` execution
|
|
5
|
+
* gate (issue #2012). When the critic returns APPROVED but the mechanical
|
|
6
|
+
* snapshot recorder fails to persist it (verdict-format mismatch, dispatch-
|
|
7
|
+
* signal miss, or a plan.json read race), the gate permanently blocks ALL
|
|
8
|
+
* coder delegations because `critic_pre_plan` defaults to `true` and cannot be
|
|
9
|
+
* disabled. This records a manual `plan_critic_gate` approval snapshot so the
|
|
10
|
+
* gate unblocks, with a distinct `method: 'manual_override'` audit marker.
|
|
11
|
+
*
|
|
12
|
+
* The command is `toolPolicy: 'restricted'` — the agent cannot run it via
|
|
13
|
+
* `swarm_command`; the agent must instead call the `approve_plan_critic` tool
|
|
14
|
+
* (or ask the user to run this command). Both paths funnel into
|
|
15
|
+
* `forceRecordPlanCriticApproval`. The command path sets `user_confirmed: true`
|
|
16
|
+
* (human-initiated); the tool path sets `user_confirmed: false`
|
|
17
|
+
* (agent-initiated) so a self-approve is visible in the audit trail.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors the PR_REVIEW #1898 escape-hatch pattern (`/swarm abort-pr-workflow`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function handleApprovePlanCriticCommand(directory: string, args: string[], sessionID: string): Promise<string>;
|
|
@@ -551,6 +551,14 @@ export declare const COMMAND_REGISTRY: {
|
|
|
551
551
|
readonly category: "utility";
|
|
552
552
|
readonly toolPolicy: "restricted";
|
|
553
553
|
};
|
|
554
|
+
readonly 'approve-plan-critic': {
|
|
555
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
556
|
+
readonly description: "Record a MANUAL plan-critic approval to unblock the critic_pre_plan execution gate [reason...]";
|
|
557
|
+
readonly args: "[reason...]";
|
|
558
|
+
readonly details: "Human-only escape hatch for the ratchet-tighter critic_pre_plan execution gate (issue #2012). When the critic already returned APPROVED but the mechanical snapshot recorder failed to persist it (verdict-format mismatch, dispatch-signal miss, or a plan.json read race), the gate permanently blocks ALL coder delegations because critic_pre_plan defaults to true and cannot be disabled. Running this records a manual plan_critic_gate approval snapshot so the gate unblocks, with a distinct method: \"manual_override\" audit marker. The agent itself cannot run this command; it must call the approve_plan_critic tool (or ask you to run this command). Both paths funnel into the same forceRecordPlanCriticApproval hook, which requires an active architect session. An audit event is appended to .swarm/events.jsonl. Prefer re-running MODE: CRITIC-GATE first; use this only as an escape hatch when a legitimate APPROVED was lost.";
|
|
559
|
+
readonly category: "utility";
|
|
560
|
+
readonly toolPolicy: "restricted";
|
|
561
|
+
};
|
|
554
562
|
readonly 'pr-review': {
|
|
555
563
|
readonly handler: (ctx: CommandContext) => CommandResult;
|
|
556
564
|
readonly description: "Launch deep PR review with multi-lane analysis [url] [--council]";
|
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
* Mirrors CONFIG_DIR in src/cli/index.ts.
|
|
4
4
|
*/
|
|
5
5
|
export declare function getPluginConfigDir(): string;
|
|
6
|
+
/**
|
|
7
|
+
* The config directory the OpenCode HOST is actually using, honouring
|
|
8
|
+
* `OPENCODE_CONFIG_DIR`.
|
|
9
|
+
*
|
|
10
|
+
* Verbatim host precedence (`C:\OpenCode\opencode.exe`, opencode 1.18.10,
|
|
11
|
+
* offset 107379448):
|
|
12
|
+
*
|
|
13
|
+
* ```js
|
|
14
|
+
* function y(N={}){return{home:G.home,data:G.data,cache:G.cache,
|
|
15
|
+
* config:e.OPENCODE_CONFIG_DIR??G.config, ...}}
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* This is deliberately SEPARATE from {@link getPluginConfigDir}, which has
|
|
19
|
+
* shared semantics relied on by `src/cli/index.ts` and
|
|
20
|
+
* `src/services/diagnose-service.ts` for locating plugin caches and lock files.
|
|
21
|
+
* Changing that function's meaning would move those consumers too.
|
|
22
|
+
*
|
|
23
|
+
* Only the worktree-lane permission allowlist uses this: under
|
|
24
|
+
* `OPENCODE_CONFIG_DIR` the two directories differ, and allowlisting the wrong
|
|
25
|
+
* one grants a directory the host is not reading while denying the one it is.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getHostConfigDir(): string;
|
|
28
|
+
/**
|
|
29
|
+
* The data directory the OpenCode HOST uses.
|
|
30
|
+
*
|
|
31
|
+
* Verbatim host source (opencode 1.18.10, offset ~107378180):
|
|
32
|
+
* `V = XDG_DATA_HOME || join(homedir(), ".local", "share")`
|
|
33
|
+
* `U = join(V, "opencode")` -> `Global.Path.data`
|
|
34
|
+
*
|
|
35
|
+
* Unlike `config`, the data path has no environment override: the `y()` service
|
|
36
|
+
* factory passes `data: G.data` straight through (offset 107379448).
|
|
37
|
+
*
|
|
38
|
+
* Used by the worktree-lane allowlist to re-grant `<data>/plans`, which the
|
|
39
|
+
* host natively allows to its `plan` agent.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getHostDataDir(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Where OpenCode caches URL-sourced skills (`skills.urls`).
|
|
44
|
+
*
|
|
45
|
+
* Both discovery implementations agree on the root:
|
|
46
|
+
* v1 (offset 102988349): `join(Global.Path.cache, "skills")`
|
|
47
|
+
* v2 (offset 103375250): `resolve(cache, "skills", Bun.hash(url))` — a
|
|
48
|
+
* per-URL subdirectory of the same root.
|
|
49
|
+
*
|
|
50
|
+
* Pure path construction, no I/O and no network: the pull itself is the host's
|
|
51
|
+
* job, and the plugin only needs to know where the result lands.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getHostSkillCacheDir(): string;
|
|
6
54
|
/**
|
|
7
55
|
* All known locations where OpenCode may cache the opencode-swarm plugin.
|
|
8
56
|
* Order: newest/canonical first so status reporting shows the most relevant
|
|
@@ -118,6 +118,24 @@ export declare const AUTO_PROCEED_BANNER = "## \u23ED\uFE0F AUTO-PROCEED STATUS\
|
|
|
118
118
|
* Zod schema in schema.ts).
|
|
119
119
|
*/
|
|
120
120
|
export declare const DEFAULT_LEAN_TURBO_CONFIG: LeanTurboConfig;
|
|
121
|
+
/**
|
|
122
|
+
* Directory name of the DD-6 default swarm-managed worktree base, created as a
|
|
123
|
+
* SIBLING of the project root (`<project-parent>/.swarm-worktrees`).
|
|
124
|
+
*
|
|
125
|
+
* Single source of truth shared by `resolveWorktreeBaseDir` in
|
|
126
|
+
* `src/worktree/core.ts` (which BUILDS lane paths) and
|
|
127
|
+
* `src/config/lane-context.ts` (which RECOGNISES a lane path after the fact,
|
|
128
|
+
* from inside the lane's own OpenCode instance). Those two must never drift: if
|
|
129
|
+
* creation and recognition disagree, a lane instance silently fails to be
|
|
130
|
+
* identified as a lane and falls back to unscoped permission behaviour.
|
|
131
|
+
*
|
|
132
|
+
* It lives in this leaf constants module rather than in `src/worktree/core.ts`
|
|
133
|
+
* so that the init-path-safe lane modules can share it without pulling the
|
|
134
|
+
* worktree lifecycle module into the plugin entry's import graph
|
|
135
|
+
* (AGENTS.md invariant 1; enforced by
|
|
136
|
+
* `tests/unit/turbo/lean/init-safety.test.ts`).
|
|
137
|
+
*/
|
|
138
|
+
export declare const SWARM_WORKTREE_DIR_NAME = ".swarm-worktrees";
|
|
121
139
|
export declare const DEFAULT_WORKTREE_ISOLATION_CONFIG: WorktreeIsolationConfig;
|
|
122
140
|
export declare const LEAN_TURBO_BANNER = "## \uD83D\uDEE4\uFE0F LEAN TURBO ACTIVE\n\nLane-based parallel execution is enabled for this phase.\n\nBehavioral changes:\n- Tasks are partitioned into parallel lanes based on file-scope conflicts. Tasks in the same lane run sequentially; tasks in different lanes run concurrently (up to max_parallel_coders).\n- **Lane dispatch overrides the one-agent-per-message rule**: for lean lane dispatch only, you may send multiple Task tool calls concurrently (one per lane).\n- **Lane tasks skip per-task Stage B** (reviewer + test_engineer). Quality is enforced at phase-end via phase reviewer and critic gates instead.\n- **Degraded tasks** (global files, protected paths, high-risk patterns) and **serialized tasks** (lock-conflicted) run through standard serial workflow with full Stage B gates.\n- **Phase reviewer and critic are REQUIRED** before phase_complete when lean turbo is active \u2014 they serve as the holistic quality gate for all lane work.\n- **Full-Auto composition**: if Full-Auto is also active, lane dispatch is subject to Full-Auto delegation policy and phase approval.\n- Use the lean_turbo_run_phase tool to execute a phase with parallel lanes\n\nDo NOT skip phase reviewer/critic when configured. Degraded and serialized tasks MUST still go through full Stage B.\n";
|
|
123
141
|
export declare const EPIC_MODE_BANNER = "## \uD83E\uDDED EPIC MODE ACTIVE\n\n**\u26D4 THE USER ALWAYS COMES FIRST \u2014 this overrides everything below.** The user can message you at ANY time, including mid-phase while coders are running or retrying. The instant a user message arrives \u2014 a question, a slash command, a comment, anything \u2014 STOP advancing the flow. Do not dispatch, do not retry, do not call another tool. Read what they said and respond to them directly, in plain conversation, first. Never keep executing the protocol and leave a user message unanswered \u2014 ignoring the user is the single worst failure mode in this mode. After you've answered, pick up where you left off. If you're mid-wave when they interrupt, tell them the state (\"3.1 and 3.2 are still running; I'll continue once I've answered you\") rather than going silent.\n\n**Activation \u2260 start.** Until the user asks for execution (\"start phase N\", \"run task X\", \"continue\"): do nothing. On `/swarm turbo epic`, `/swarm epic *` and any slash status/config command: call the named tool ONCE, surface its output VERBATIM, then stop. Don't infer intent \u2014 if unsure, ASK. This restraint applies ONLY before activation.\n\n**Talk to the user as you work** \u2014 like you naturally would. Once they ask you to run a phase, keep them in the loop with a sentence before each step about what you're doing and why (\"Declaring scopes for 3.1\u20133.3 so the planner can find parallelism\u2026\", \"Discrimination and calibration are independent, so I'll run 3.1 and 3.2 in parallel\u2026\"). This is normal conversation, not a form to fill in \u2014 the steps below tell you the key facts to share, but say them in your own voice. Don't go silent and tool-only through a phase.\n\nUse `epic_plan_waves` (NOT `lean_turbo_plan_lanes` or the deprecated `epic_run_phase`) for the wave plan. Do NOT call `lean_turbo_run_phase` directly.\n\n### Six-step flow (only when the user asks to run a phase)\n\n> Supersedes Rule 1a/3a: declare ALL pending scopes UP FRONT (step 1), BEFORE step 2. Just-in-time declaration breaks the wave planner.\n\n**1. `declare_scope` for every pending task** \u2014 one call per single `taskId` string (NOT ranges/arrays/globs). Tight, disjoint scopes; avoid shared files (`__init__.py`, barrels, registries) \u2014 they force serial waves. Declared scope is a CONTRACT; if a task needs more files mid-run, re-declare BEFORE dispatching.\n\n**2. `epic_decide_phase(directory, phase=N, sessionID)`** \u2014 returns:\n- `decided`+`promote` \u2192 step 3\n- `demoted` \u2192 step 6 (per-task serial)\n- `scopes-missing` \u2192 `declare_scope` each `missingScopes[]`, retry step 2\n- `no-phase` | `phase-empty` | `phase-already-complete` | `epic-state-unreadable` \u2192 fix per response `message`, retry. `phase-already-complete` means call step 2 with `phase=N+1` (NOT step 4 directly).\n- other \u2192 fix per `message`, retry\n\n**3. Surface the verdict to the user immediately, before any further action:**\n> Epic Mode: <PROMOTE|DEMOTE> (p=<value>) \u2014 <one-sentence rationale or top blocking reason>\n> Dependencies: <task_id> \u2190 <deps>; \u2026 (omit if none)\n\nThe verdict is the user's only visibility into what Epic is doing \u2014 silence here makes the mode invisible. If you're going to spend time on this phase, tell the user why up front. Phrase it naturally; the format above is a guide, not a script.\n\n**4. `epic_plan_waves(directory, phase=N)`** \u2014 returns `{ waves: [{ waveId, taskIds, files }], serializedTasks, degradedTasks, degradationSummary }`. Failure reasons mirror step 2; additionally: `git-failed` (retry), `planner-error` (check `errors[0]`).\n\n**4b. Surface the wave plan to the user, before dispatching any `Task`:**\n> Wave plan (<N> waves): Wave 1 \u2192 [<ids>] (parallel); Wave 2 \u2192 [<ids>]; \u2026 \u2014 serialized [<ids>], degraded [<ids>]\n\nWalk them through which tasks run in which wave and what's parallel \u2014 naturally, in your own words. If `waves.length` exceeds the distinct-dependency-layer count, also flag the over-split and its likely cause (typical: a shared file like a barrel/registry in multiple scopes forces serial waves), e.g. \"Wave N split into K single-task waves because every scope claims `<shared-file>` \u2014 re-declare those tasks without it to restore parallelism, then re-plan.\"\n\n`serializedTasks` causes (NOT `declare_scope`-fixable): cycle, `no-scope`, `invalid-scope`, cap-exhaustion. Fix dep graph or scope contents, re-plan.\n\n`degradedTasks[].reason` keys:\n- `global file conflict` / `protected path` \u2192 balanced mode, dispatch per-task after waves\n- `cross-batch upstream not committed (greenfield-smart Rule 3): <ids>` \u2192 commit named upstreams, re-plan\n- `unresolved in-batch dependency: <ids>` \u2192 fix upstream degrade/serialize, re-plan\n- `planning leftover (no identifiable blocker)` \u2192 surface as planner bug\n\n**5. Dispatch each wave: `wave.taskIds.length` SEPARATE `Task` calls in ONE assistant message.** Per wave in order:\n- One `Task(subagent_type=\"coder\", description=\"Phase N task <id>\", prompt=\"<scope + acceptance>\")` per `taskId`\n- ALL in same turn \u2192 concurrent\n- Wait for all in wave to reach `update_task_status(completed)` + `epic_record_divergence` before next wave\n\n\u26A0\uFE0F **Three defects:**\n1. **Bundling**: multiple ids in one Task call \u2192 kills 1:1 coder visibility\n2. **Splitting across messages**: serial execution, no parallelism\n3. **Skipping single-task waves**: still emit ONE Task, wait for completion+divergence\n\nThis is the only sanctioned dispatch path. Don't use `lean_turbo_run_phase`; don't bundle through other tools \u2014 visibility requires `Task`.\n\n`serializedTasks` + `degradedTasks` (after wave loop): ONE Task per assistant message each, never batched, wait for completion+divergence between.\n\n**6. After each `update_task_status(completed)`, call `epic_record_divergence(directory, taskId, sessionID)`** (feeds calibration). If `summary.isClean: false`:\n> Divergence: task `<id>` wrote <undeclaredCount> undeclared file(s) (ratio <ratio>)\n\n### Phase-complete + audit\n\nPhase reviewer + critic still required at `phase_complete` (Epic Mode doesn't change Stage B).\n\nAudit (no architect needed): `/swarm epic status | last | decide | calibration`.\n";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Faithful transcription of OpenCode's path-canonicalisation helpers.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this must exist
|
|
5
|
+
*
|
|
6
|
+
* The host asks for `external_directory` permission with a pattern it has run
|
|
7
|
+
* through `Filesystem.normalizePathPattern` — for example
|
|
8
|
+
* `src/tools/…` (offset 100715012):
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* let u = G.normalizePathPattern(Hr.join(y, "*"));
|
|
12
|
+
* yield* o.ask({ permission: "external_directory", patterns: [u], always: [u], … });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Rule patterns from config get NO such treatment: `Permission.fromConfig`
|
|
16
|
+
* applies only `~` / `$HOME` expansion. So for a rule to match, its text must
|
|
17
|
+
* already equal what the host will produce for the asked path.
|
|
18
|
+
*
|
|
19
|
+
* That matters because `normalizePathPattern` resolves symlinks via
|
|
20
|
+
* `realpathSync.native`. A lane reached through a Windows junction (or a macOS
|
|
21
|
+
* `/var` → `/private/var` symlink) is asked for under its REAL path, while an
|
|
22
|
+
* un-canonicalised rule names the link path — so the lane is denied access to
|
|
23
|
+
* its own granted directory.
|
|
24
|
+
*
|
|
25
|
+
* Verbatim host source (`C:\OpenCode\opencode.exe`, opencode 1.18.10,
|
|
26
|
+
* offsets 107196170-107196420; the minified names resolve via the chunk's own
|
|
27
|
+
* imports at offset 107192671: `ky`=`path.resolve`, `yy`=`path.join`,
|
|
28
|
+
* `ek`=`fs.realpathSync`):
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* function j(F){ let z=ky(X(F)); try{ return ek.native(z) }catch{ return z } }
|
|
32
|
+
* YW.normalizePath = j;
|
|
33
|
+
*
|
|
34
|
+
* function J(F){
|
|
35
|
+
* if(F==="*") return F;
|
|
36
|
+
* let z=F.match(/^(.*)[\\/]\*$/);
|
|
37
|
+
* if(!z) return j(F);
|
|
38
|
+
* let Z=/^[A-Za-z]:$/.test(z[1]) ? z[1]+"\\" : z[1];
|
|
39
|
+
* return yy(j(Z),"*");
|
|
40
|
+
* }
|
|
41
|
+
* YW.normalizePathPattern = J;
|
|
42
|
+
*
|
|
43
|
+
* function X(F){ return F
|
|
44
|
+
* .replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(z,Z)=>`${Z.toUpperCase()}:/`)
|
|
45
|
+
* .replace(/^\/([a-zA-Z])(?:\/|$)/,(z,Z)=>`${Z.toUpperCase()}:/`)
|
|
46
|
+
* .replace(/^\/cygdrive\/([a-zA-Z])(?:\/|$)/,(z,Z)=>`${Z.toUpperCase()}:/`)
|
|
47
|
+
* .replace(/^\/mnt\/([a-zA-Z])(?:\/|$)/,(z,Z)=>`${Z.toUpperCase()}:/`) }
|
|
48
|
+
* YW.windowsPath = X;
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* If a future OpenCode release changes these, lane rules stop matching. The
|
|
52
|
+
* shared-normaliser tests in `tests/unit/config/lane-permissions.test.ts` are
|
|
53
|
+
* the tripwire — re-extract before "fixing" them.
|
|
54
|
+
*
|
|
55
|
+
* @module config/host-path
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Test-only DI seam (AGENTS.md invariant 7). Lets tests simulate a symlink /
|
|
59
|
+
* junction without creating one, and assert the ENOENT degradation.
|
|
60
|
+
*/
|
|
61
|
+
export declare const _internals: {
|
|
62
|
+
realpathSyncNative: (p: string) => string;
|
|
63
|
+
};
|
|
64
|
+
/** Host `Filesystem.windowsPath`. */
|
|
65
|
+
declare function hostWindowsPath(input: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Host `Filesystem.normalizePath`: `realpathSync.native(path.resolve(windowsPath(p)))`,
|
|
68
|
+
* degrading to the un-realpath'd resolved form on ANY realpath failure.
|
|
69
|
+
*
|
|
70
|
+
* The host uses a bare `catch` here (not an ENOENT check), so a permission
|
|
71
|
+
* error degrades identically to a missing path. Transcribed as-is: diverging
|
|
72
|
+
* would make our rule text disagree with the host's asked text in exactly the
|
|
73
|
+
* cases where a lane is already having filesystem trouble.
|
|
74
|
+
*/
|
|
75
|
+
declare function hostNormalizePath(input: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Host `Filesystem.normalizePathPattern`.
|
|
78
|
+
*
|
|
79
|
+
* Canonicalises the DIRECTORY part of a `<dir>/*` pattern and re-appends the
|
|
80
|
+
* wildcard, leaving the bare `*` catch-all untouched. Note the drive-root
|
|
81
|
+
* special case: for `C:/*` the captured directory is `C:` which
|
|
82
|
+
* `path.resolve` would turn into the process's current directory on that
|
|
83
|
+
* drive, so the host appends a separator first.
|
|
84
|
+
*/
|
|
85
|
+
export declare function hostNormalizePathPattern(pattern: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Tier-0 test seam (writing-tests skill): pure transcriptions with no external
|
|
88
|
+
* dependency beyond the DI'd realpath. Only {@link hostNormalizePathPattern} is
|
|
89
|
+
* consumed by production code, so these stay internal.
|
|
90
|
+
*/
|
|
91
|
+
export declare const _test_exports: {
|
|
92
|
+
hostWindowsPath: typeof hostWindowsPath;
|
|
93
|
+
hostNormalizePath: typeof hostNormalizePath;
|
|
94
|
+
};
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swarm worktree-lane context detection.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists
|
|
5
|
+
*
|
|
6
|
+
* OpenCode partitions **all** permission state by *directory*. Every service
|
|
7
|
+
* that matters — `Permission.state`, `Agent.state`, `Plugin.state`,
|
|
8
|
+
* `ToolRegistry.state` — is built through the same directory-keyed
|
|
9
|
+
* `InstanceState` cache. When opencode-swarm creates a worktree-lane session
|
|
10
|
+
* bound to a new directory (`session.create({ query: { directory: lanePath } })`),
|
|
11
|
+
* that lane gets a brand-new permission universe: an empty `approved` list, so
|
|
12
|
+
* every prior "Allow always" is forgotten, and a private pending map. Because a
|
|
13
|
+
* lane instance has no TUI attached, an `external_directory` prompt raised there
|
|
14
|
+
* can never be answered and the lane hangs forever (the host's `Permission.ask`
|
|
15
|
+
* awaits its deferred with no timeout).
|
|
16
|
+
*
|
|
17
|
+
* The fix is to pre-resolve permissions for lane instances via the plugin
|
|
18
|
+
* `config` hook. That requires answering one question cheaply and reliably:
|
|
19
|
+
* **is this directory a swarm worktree lane, and if so, what project is it a
|
|
20
|
+
* worktree of?**
|
|
21
|
+
*
|
|
22
|
+
* ## Why there is no `git` subprocess here
|
|
23
|
+
*
|
|
24
|
+
* The obvious implementation is
|
|
25
|
+
* `git -C <lane> rev-parse --path-format=absolute --git-common-dir`. This module
|
|
26
|
+
* deliberately does not do that. `resolveLaneContext` is called from the plugin
|
|
27
|
+
* `config` hook, which the host runs inside `Plugin.state` initialisation —
|
|
28
|
+
* squarely on the plugin-init path that AGENTS.md invariant 1 governs, and that
|
|
29
|
+
* invariant names Git commands explicitly as forbidden there.
|
|
30
|
+
*
|
|
31
|
+
* Instead this module reads the two files git itself would consult:
|
|
32
|
+
*
|
|
33
|
+
* - `<lane>/.git` — in a linked worktree this is a *file*, not a directory,
|
|
34
|
+
* containing `gitdir: <main>/.git/worktrees/<name>`.
|
|
35
|
+
* - `<main>/.git/worktrees/<name>/commondir` — a relative pointer back to the
|
|
36
|
+
* shared `.git` directory (normally `../..`).
|
|
37
|
+
*
|
|
38
|
+
* That is the same information the subprocess would return, obtained with at
|
|
39
|
+
* most two small synchronous reads, no child process, no timeout to get wrong,
|
|
40
|
+
* and nothing to kill in a `finally`. It is strictly safer on the init path than
|
|
41
|
+
* a spawn would be, and it removes an entire class of invariant-3 exposure.
|
|
42
|
+
*
|
|
43
|
+
* @module config/lane-context
|
|
44
|
+
*/
|
|
45
|
+
import { addDeferredWarning } from '../services/warning-buffer';
|
|
46
|
+
/**
|
|
47
|
+
* A resolved swarm worktree lane.
|
|
48
|
+
*/
|
|
49
|
+
export interface LaneContext {
|
|
50
|
+
/** Absolute, resolved path of the lane worktree itself. */
|
|
51
|
+
lanePath: string;
|
|
52
|
+
/**
|
|
53
|
+
* Absolute, resolved path of the project this lane is a git worktree of —
|
|
54
|
+
* i.e. the main working tree that owns the shared `.git` directory.
|
|
55
|
+
*/
|
|
56
|
+
parentProjectPath: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Test-only dependency-injection seam (AGENTS.md invariant 7 — prefer
|
|
60
|
+
* `_internals` over `mock.module`, which leaks across files in Bun's shared
|
|
61
|
+
* test-runner process). Tests replace these to simulate unreadable `.git`
|
|
62
|
+
* files, malformed pointers, and permission errors. Restore in `afterEach`.
|
|
63
|
+
*/
|
|
64
|
+
export declare const _internals: {
|
|
65
|
+
readFileSync: (p: string, enc: BufferEncoding) => string;
|
|
66
|
+
statSync: (p: string) => {
|
|
67
|
+
isFile(): boolean;
|
|
68
|
+
};
|
|
69
|
+
addDeferredWarning: typeof addDeferredWarning;
|
|
70
|
+
/**
|
|
71
|
+
* Clears the detection cache. Test-only; production has no reason to call
|
|
72
|
+
* it because a directory's lane-ness cannot change while the process holds
|
|
73
|
+
* an OpenCode instance for that directory.
|
|
74
|
+
*/
|
|
75
|
+
clearCache: () => void;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Decides whether `directory` is a swarm worktree lane and, if so, resolves the
|
|
79
|
+
* lane path and the parent project it is a worktree of.
|
|
80
|
+
*
|
|
81
|
+
* Detection requires two independent conditions, the second of which may be
|
|
82
|
+
* satisfied either way:
|
|
83
|
+
*
|
|
84
|
+
* 1. REQUIRED — the directory (or a bounded number of its ancestors) is a real
|
|
85
|
+
* LINKED git worktree whose main working tree resolves. A main working tree
|
|
86
|
+
* has a `.git` directory rather than a file and is never a lane.
|
|
87
|
+
* 2. REQUIRED — the worktree is swarm-OWNED, established by EITHER
|
|
88
|
+
* (a) its branch matching the full grammar in `./swarm-branch.ts`
|
|
89
|
+
* (`swarm/<purpose>/<sessionId>/<id>` or `swarm-lane/<sessionId>/<id>`,
|
|
90
|
+
* with `<sessionId>` of the form `ses_…`) — the authoritative,
|
|
91
|
+
* path-independent signal; OR
|
|
92
|
+
* (b) the path sitting under a `.swarm-worktrees` base — the fallback for a
|
|
93
|
+
* worktree whose HEAD is detached or unreadable, so its branch cannot
|
|
94
|
+
* be consulted.
|
|
95
|
+
*
|
|
96
|
+
* (2a) is a full-grammar match rather than a `swarm/` prefix test on purpose: a
|
|
97
|
+
* user-authored `swarm/my-own-experiment` worktree must NOT be captured. A
|
|
98
|
+
* false positive is worse than a false negative here — see the module note in
|
|
99
|
+
* `./swarm-branch.ts`.
|
|
100
|
+
*
|
|
101
|
+
* A detached-HEAD swarm lane created OUTSIDE `.swarm-worktrees` (a
|
|
102
|
+
* `worktree_dir` override, or the Windows path-budget fallback) satisfies
|
|
103
|
+
* neither branch of (2) and is a false NEGATIVE: no permission changes, i.e.
|
|
104
|
+
* today's behaviour. That is the safe direction and is left as-is.
|
|
105
|
+
*
|
|
106
|
+
* NEVER throws. Any error — nonexistent directory, unreadable `.git`, malformed
|
|
107
|
+
* pointer, permission error, non-string input — yields `null` ("not a lane"),
|
|
108
|
+
* which preserves today's behaviour for ordinary sessions. That direction is
|
|
109
|
+
* the safe one: a false negative means "no permission changes at all", while a
|
|
110
|
+
* false positive would apply a deny-by-default ruleset to a normal project.
|
|
111
|
+
*
|
|
112
|
+
* @param directory - Directory to classify (typically the plugin's own
|
|
113
|
+
* `ctx.directory`, which under this host IS the instance
|
|
114
|
+
* directory).
|
|
115
|
+
* @returns The resolved lane context, or `null` when `directory` is not a lane.
|
|
116
|
+
*/
|
|
117
|
+
export declare function resolveLaneContext(directory: string): LaneContext | null;
|