opencode-swarm 7.111.0 → 7.112.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.opencode/skills/swarm-pr-feedback/SKILL.md +24 -0
  2. package/dist/background/pr-event-subscribers.d.ts +28 -0
  3. package/dist/background/pr-monitor-worker.d.ts +8 -1
  4. package/dist/background/pr-subscriptions.d.ts +6 -0
  5. package/dist/cli/{config-doctor-q5e9yzn6.js → config-doctor-mmw4c50z.js} +2 -2
  6. package/dist/cli/{core-9a7nn51x.js → core-f4cbabe7.js} +2 -2
  7. package/dist/cli/{curator-drift-169wgaxn.js → curator-drift-jvs1v6em.js} +2 -2
  8. package/dist/cli/curator-llm-factory-vxa4pz48.js +40 -0
  9. package/dist/cli/{curator-2hm297yd.js → curator-ztdgdpb6.js} +19 -19
  10. package/dist/cli/{dispatch-zr1xja4t.js → dispatch-wst7bypk.js} +2 -2
  11. package/dist/cli/{evidence-summary-service-8tasw2tt.js → evidence-summary-service-j6fnsfeq.js} +5 -5
  12. package/dist/cli/{gate-evidence-v6ds8rcp.js → gate-evidence-mk0ss1re.js} +3 -3
  13. package/dist/cli/guardrail-explain-gv1ht6b0.js +41 -0
  14. package/dist/cli/{guardrail-log-973nan7m.js → guardrail-log-xjgr00eq.js} +4 -4
  15. package/dist/cli/{hive-promoter-0f8xh2rn.js → hive-promoter-wdextf8h.js} +19 -19
  16. package/dist/cli/{index-1cn967sa.js → index-0dab9w37.js} +1 -1
  17. package/dist/cli/{index-r3j3458j.js → index-1rga1vvb.js} +1 -1
  18. package/dist/cli/{index-7xfh4k71.js → index-20hyxe3z.js} +403 -291
  19. package/dist/cli/{index-c483hnn4.js → index-30ejh1tx.js} +3 -3
  20. package/dist/cli/{index-v8pk35h7.js → index-32bx4kch.js} +70 -5
  21. package/dist/cli/{index-cmjq1kg7.js → index-82v0d72f.js} +3 -3
  22. package/dist/cli/{index-yw8qpf51.js → index-9fxs0rm1.js} +1 -1
  23. package/dist/cli/{index-9ptp9kky.js → index-azf2bmr5.js} +2 -2
  24. package/dist/cli/{index-0g5xsrp4.js → index-cq2hgvd2.js} +13 -5
  25. package/dist/cli/{index-j2v3w1ds.js → index-d0w40jm3.js} +4 -4
  26. package/dist/cli/{index-40h0yp9e.js → index-db1fh1fv.js} +1 -1
  27. package/dist/cli/{index-dnbca696.js → index-fhmw7evd.js} +2 -2
  28. package/dist/cli/{index-vzzt3ygr.js → index-g55nzpwn.js} +1 -1
  29. package/dist/cli/{index-yhmt3dw3.js → index-hpp2r0sd.js} +3 -3
  30. package/dist/cli/{index-kf2h31c7.js → index-hy5r0mgf.js} +21 -21
  31. package/dist/cli/{index-53z1afgh.js → index-npxmfj48.js} +1 -1
  32. package/dist/cli/{index-6jng9c8t.js → index-pm992z24.js} +1 -1
  33. package/dist/cli/{index-85bacexr.js → index-q1jaeynn.js} +4 -1
  34. package/dist/cli/{index-mvg66d9n.js → index-t6wfwdm1.js} +3 -3
  35. package/dist/cli/{index-5rfxzgmt.js → index-w84stmkx.js} +1 -1
  36. package/dist/cli/{index-xddysq89.js → index-xehrmy76.js} +1 -1
  37. package/dist/cli/index.js +19 -19
  38. package/dist/cli/{knowledge-escalator-0dkkenp2.js → knowledge-escalator-4gbz527n.js} +6 -6
  39. package/dist/cli/{knowledge-events-bckbj6ah.js → knowledge-events-b6x28fgc.js} +4 -4
  40. package/dist/cli/{knowledge-store-dvjbdn00.js → knowledge-store-h3cjx4dg.js} +9 -5
  41. package/dist/cli/{knowledge-validator-bqr936sg.js → knowledge-validator-q6jw2p0t.js} +5 -5
  42. package/dist/cli/{pending-delegations-yyz3fcfn.js → pending-delegations-gc3a2hfx.js} +2 -2
  43. package/dist/cli/{pr-subscriptions-vv8byxe6.js → pr-subscriptions-p8g2rzxd.js} +3 -3
  44. package/dist/cli/{schema-s48je8zt.js → schema-2p15yrvn.js} +1 -1
  45. package/dist/cli/{scope-persistence-tgp00wtd.js → scope-persistence-5ccgtebg.js} +2 -2
  46. package/dist/cli/{skill-generator-5rsjmmfq.js → skill-generator-fe6q8xgm.js} +7 -7
  47. package/dist/commands/ci-simulate.d.ts +36 -12
  48. package/dist/commands/pr-monitor-status.d.ts +8 -0
  49. package/dist/config/bundled-skills.d.ts +1 -1
  50. package/dist/config/schema.d.ts +5 -0
  51. package/dist/full-auto/oversight.d.ts +4 -1
  52. package/dist/full-auto/state.d.ts +12 -0
  53. package/dist/git/pr.d.ts +23 -0
  54. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +110 -0
  55. package/dist/hooks/delegation-gate.d.ts +17 -2
  56. package/dist/hooks/full-auto-intercept.d.ts +1 -1
  57. package/dist/hooks/knowledge-events.d.ts +21 -1
  58. package/dist/hooks/knowledge-injector.d.ts +4 -0
  59. package/dist/hooks/knowledge-reader.d.ts +16 -0
  60. package/dist/hooks/knowledge-store.d.ts +23 -0
  61. package/dist/index.js +217 -192
  62. package/dist/tools/placeholder-scan.d.ts +14 -1
  63. package/dist/utils/bun-compat.d.ts +6 -0
  64. package/dist/worktree/merge.d.ts +12 -0
  65. package/package.json +7 -5
  66. package/dist/cli/curator-llm-factory-19s0r5v6.js +0 -40
  67. package/dist/cli/guardrail-explain-8w9rkdjx.js +0 -41
  68. /package/dist/cli/{index-7xgqky26.js → index-h91bv3hy.js} +0 -0
@@ -1,5 +1,6 @@
1
1
  // @bun
2
2
  import {
3
+ MAX_CONFIRMED_BY,
3
4
  OUTCOME_SIGNAL_SMOOTHING,
4
5
  _internals,
5
6
  appendKnowledge,
@@ -9,6 +10,7 @@ import {
9
10
  bumpKnowledgeConfidenceBatch,
10
11
  computeConfidence,
11
12
  computeOutcomeSignal,
13
+ confirmEntriesPhase,
12
14
  enforceKnowledgeCap,
13
15
  findNearDuplicate,
14
16
  getArchivedKnowledgeIds,
@@ -32,16 +34,16 @@ import {
32
34
  transactFile,
33
35
  transactKnowledge,
34
36
  wordBigrams
35
- } from "./index-v8pk35h7.js";
37
+ } from "./index-32bx4kch.js";
36
38
  import"./index-bfwt3abw.js";
37
- import"./index-40h0yp9e.js";
39
+ import"./index-db1fh1fv.js";
38
40
  import"./index-jtqkh8jf.js";
39
41
  import"./index-zgwm4ryv.js";
40
- import"./index-1cn967sa.js";
42
+ import"./index-0dab9w37.js";
41
43
  import"./index-5mkc2f9z.js";
42
44
  import"./index-vn263hqt.js";
43
45
  import"./index-vvk2g744.js";
44
- import"./index-7xgqky26.js";
46
+ import"./index-h91bv3hy.js";
45
47
  import"./index-a76rekgs.js";
46
48
  export {
47
49
  wordBigrams,
@@ -67,6 +69,7 @@ export {
67
69
  getArchivedKnowledgeIds,
68
70
  findNearDuplicate,
69
71
  enforceKnowledgeCap,
72
+ confirmEntriesPhase,
70
73
  computeOutcomeSignal,
71
74
  computeConfidence,
72
75
  bumpKnowledgeConfidenceBatch,
@@ -75,5 +78,6 @@ export {
75
78
  appendKnowledgeWithCapEnforcement,
76
79
  appendKnowledge,
77
80
  _internals,
78
- OUTCOME_SIGNAL_SMOOTHING
81
+ OUTCOME_SIGNAL_SMOOTHING,
82
+ MAX_CONFIRMED_BY
79
83
  };
@@ -22,17 +22,17 @@ import {
22
22
  validateLesson,
23
23
  validateSkillCandidatePath,
24
24
  validateSkillPath
25
- } from "./index-c483hnn4.js";
26
- import"./index-v8pk35h7.js";
25
+ } from "./index-30ejh1tx.js";
26
+ import"./index-32bx4kch.js";
27
27
  import"./index-bfwt3abw.js";
28
- import"./index-40h0yp9e.js";
28
+ import"./index-db1fh1fv.js";
29
29
  import"./index-jtqkh8jf.js";
30
30
  import"./index-zgwm4ryv.js";
31
- import"./index-1cn967sa.js";
31
+ import"./index-0dab9w37.js";
32
32
  import"./index-5mkc2f9z.js";
33
33
  import"./index-vn263hqt.js";
34
34
  import"./index-vvk2g744.js";
35
- import"./index-7xgqky26.js";
35
+ import"./index-h91bv3hy.js";
36
36
  import"./index-a76rekgs.js";
37
37
  export {
38
38
  validateSkillPath,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  validateSwarmPath
4
- } from "./index-r3j3458j.js";
4
+ } from "./index-1rga1vvb.js";
5
5
  import"./index-jtqkh8jf.js";
6
6
  import"./index-5e4e2hvv.js";
7
7
  import"./index-p0arc26j.js";
@@ -17,7 +17,7 @@ import {
17
17
  } from "./index-5mkc2f9z.js";
18
18
  import"./index-vn263hqt.js";
19
19
  import"./index-vvk2g744.js";
20
- import"./index-7xgqky26.js";
20
+ import"./index-h91bv3hy.js";
21
21
  import"./index-a76rekgs.js";
22
22
 
23
23
  // src/background/pending-delegations.ts
@@ -9,8 +9,8 @@ import {
9
9
  sweepStale,
10
10
  unsubscribe,
11
11
  updateSnapshot
12
- } from "./index-85bacexr.js";
13
- import"./index-r3j3458j.js";
12
+ } from "./index-q1jaeynn.js";
13
+ import"./index-1rga1vvb.js";
14
14
  import"./index-jtqkh8jf.js";
15
15
  import"./index-5e4e2hvv.js";
16
16
  import"./index-p0arc26j.js";
@@ -19,7 +19,7 @@ import"./index-293f68mj.js";
19
19
  import"./index-5mkc2f9z.js";
20
20
  import"./index-vn263hqt.js";
21
21
  import"./index-vvk2g744.js";
22
- import"./index-7xgqky26.js";
22
+ import"./index-h91bv3hy.js";
23
23
  import"./index-a76rekgs.js";
24
24
  export {
25
25
  updateSnapshot,
@@ -86,7 +86,7 @@ import {
86
86
  resolveGeneratedAgentRole,
87
87
  resolveGuardrailsConfig,
88
88
  stripKnownSwarmPrefix
89
- } from "./index-0g5xsrp4.js";
89
+ } from "./index-cq2hgvd2.js";
90
90
  import"./index-bfwt3abw.js";
91
91
  import"./index-p0arc26j.js";
92
92
  import"./index-293f68mj.js";
@@ -6,9 +6,9 @@ import {
6
6
  readScopeFromDisk,
7
7
  resolveScopeWithFallbacks,
8
8
  writeScopeToDisk
9
- } from "./index-vzzt3ygr.js";
9
+ } from "./index-g55nzpwn.js";
10
10
  import"./index-vvk2g744.js";
11
- import"./index-7xgqky26.js";
11
+ import"./index-h91bv3hy.js";
12
12
  import"./index-a76rekgs.js";
13
13
  export {
14
14
  writeScopeToDisk,
@@ -33,19 +33,19 @@ import {
33
33
  sanitizeSlug,
34
34
  selectCandidateEntries,
35
35
  writeEvalStub
36
- } from "./index-cmjq1kg7.js";
37
- import"./index-c483hnn4.js";
38
- import"./index-yhmt3dw3.js";
39
- import"./index-v8pk35h7.js";
36
+ } from "./index-82v0d72f.js";
37
+ import"./index-30ejh1tx.js";
38
+ import"./index-hpp2r0sd.js";
39
+ import"./index-32bx4kch.js";
40
40
  import"./index-bfwt3abw.js";
41
- import"./index-40h0yp9e.js";
41
+ import"./index-db1fh1fv.js";
42
42
  import"./index-jtqkh8jf.js";
43
43
  import"./index-zgwm4ryv.js";
44
- import"./index-1cn967sa.js";
44
+ import"./index-0dab9w37.js";
45
45
  import"./index-5mkc2f9z.js";
46
46
  import"./index-vn263hqt.js";
47
47
  import"./index-vvk2g744.js";
48
- import"./index-7xgqky26.js";
48
+ import"./index-h91bv3hy.js";
49
49
  import"./index-a76rekgs.js";
50
50
  export {
51
51
  writeEvalStub,
@@ -1,16 +1,40 @@
1
+ /**
2
+ * Handle /swarm ci-simulate command.
3
+ *
4
+ * Simulates CI by merging a PR branch into a temporary worktree created from
5
+ * the detected default remote branch (origin/main, origin/master, etc.), then
6
+ * running the full validation suite:
7
+ * bun run typecheck
8
+ * bun run lint
9
+ * bun run build
10
+ * bun test
11
+ *
12
+ * This reproduces the merge-group CI environment locally, catching integration
13
+ * failures (pass on PR branch, fail on merged result) before they cause
14
+ * merge-queue kick-outs.
15
+ *
16
+ * Input contract:
17
+ * /swarm ci-simulate → uses current HEAD branch
18
+ * /swarm ci-simulate <pr-ref> → uses the specified branch/ref
19
+ */
1
20
  import * as fs from 'node:fs';
2
- type RunResult = {
3
- exitCode: number;
4
- stdout: string;
5
- stderr: string;
6
- stdoutTruncated?: boolean;
7
- stderrTruncated?: boolean;
8
- };
9
- declare function runCommand(cmd: string[], cwd: string, timeout: number): Promise<RunResult>;
21
+ import { getDefaultBaseBranch } from '../git/branch.js';
22
+ import { runExternalTool } from '../utils/external-tool-runner.js';
10
23
  export declare const _internals: {
11
- runCommand: typeof runCommand;
12
- now: () => number;
13
- mkdirSync: typeof fs.mkdirSync;
24
+ runExternalTool: typeof runExternalTool;
25
+ getDefaultBaseBranch: typeof getDefaultBaseBranch;
26
+ platform: string;
27
+ osTmpdir: () => string;
28
+ fs: {
29
+ existsSync: typeof fs.existsSync;
30
+ rmSync: typeof fs.rmSync;
31
+ };
14
32
  };
33
+ /**
34
+ * Handle /swarm ci-simulate command.
35
+ *
36
+ * @param directory - Project root (absolute path to the git working tree).
37
+ * @param args - Command arguments; first positional is the PR ref (optional).
38
+ * @returns Human-readable report string.
39
+ */
15
40
  export declare function handleCiSimulateCommand(directory: string, args: string[]): Promise<string>;
16
- export {};
@@ -31,11 +31,19 @@ declare function listMergeGroupRuns(directory: string, repoFullName: string, prN
31
31
  runs: MergeGroupRun[];
32
32
  error?: string;
33
33
  }>;
34
+ /**
35
+ * Format merge-group run status for display.
36
+ *
37
+ * Shows the run status (queued/in_progress/completed), conclusion if available,
38
+ * and a link reference.
39
+ */
40
+ declare function formatMergeGroupStatus(status?: string, conclusion?: string, htmlUrl?: string): string;
34
41
  /**
35
42
  * Exposed for unit testing via _internals.
36
43
  */
37
44
  export declare const _internals: {
38
45
  formatRelativeTime: typeof formatRelativeTime;
46
+ formatMergeGroupStatus: typeof formatMergeGroupStatus;
39
47
  listActive: typeof listActive;
40
48
  listMergeGroupRuns: typeof listMergeGroupRuns;
41
49
  parseMergeGroupRuns: typeof parseMergeGroupRuns;
@@ -1,4 +1,4 @@
1
- export declare const BUNDLED_PROJECT_SKILLS: readonly ["brainstorm", "specify", "clarify-spec", "resume", "clarify", "discover", "consult", "pre-phase-briefing", "council", "deep-dive", "deep-research", "codebase-review-swarm", "swarm-implement", "design-docs", "swarm-pr-review", "swarm", "swarm-pr-feedback", "swarm-pr-subscribe", "swarm-ci-monitor", "issue-ingest", "plan", "critic-gate", "execute", "phase-wrap", "loop", "writing-tests", "running-tests", "engineering-conventions", "commit-pr", "worktree-retry-cleanup", "skill-edit-validation", "merge-queue-readiness", "gate-attribution", "ci-failure-batching"];
1
+ export declare const BUNDLED_PROJECT_SKILLS: readonly ["brainstorm", "specify", "clarify-spec", "resume", "clarify", "discover", "consult", "pre-phase-briefing", "council", "deep-dive", "deep-research", "codebase-review-swarm", "swarm-implement", "design-docs", "swarm-pr-review", "swarm", "swarm-pr-feedback", "swarm-pr-subscribe", "swarm-ci-monitor", "issue-ingest", "plan", "critic-gate", "execute", "phase-wrap", "loop", "writing-tests", "running-tests", "engineering-conventions", "commit-pr", "ci-failure-batching", "gate-attribution", "merge-queue-readiness", "skill-edit-validation", "worktree-retry-cleanup"];
2
2
  interface CopyState {
3
3
  files: number;
4
4
  bytes: number;
@@ -273,6 +273,7 @@ export declare const PlaceholderScanConfigSchema: z.ZodObject<{
273
273
  deny_patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
274
274
  allow_globs: z.ZodDefault<z.ZodArray<z.ZodString>>;
275
275
  max_allowed_findings: z.ZodDefault<z.ZodNumber>;
276
+ sentinel_allowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
276
277
  }, z.core.$strip>;
277
278
  export type PlaceholderScanConfig = z.infer<typeof PlaceholderScanConfigSchema>;
278
279
  export declare const QualityBudgetConfigSchema: z.ZodObject<{
@@ -302,6 +303,7 @@ export declare const GateConfigSchema: z.ZodObject<{
302
303
  deny_patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
303
304
  allow_globs: z.ZodDefault<z.ZodArray<z.ZodString>>;
304
305
  max_allowed_findings: z.ZodDefault<z.ZodNumber>;
306
+ sentinel_allowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
305
307
  }, z.core.$strip>>;
306
308
  sast_scan: z.ZodDefault<z.ZodObject<{
307
309
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -1622,6 +1624,7 @@ export declare const PluginConfigSchema: z.ZodObject<{
1622
1624
  deny_patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
1623
1625
  allow_globs: z.ZodDefault<z.ZodArray<z.ZodString>>;
1624
1626
  max_allowed_findings: z.ZodDefault<z.ZodNumber>;
1627
+ sentinel_allowlist: z.ZodDefault<z.ZodArray<z.ZodString>>;
1625
1628
  }, z.core.$strip>>;
1626
1629
  sast_scan: z.ZodDefault<z.ZodObject<{
1627
1630
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -2416,6 +2419,8 @@ export declare const PluginConfigSchema: z.ZodObject<{
2416
2419
  every_tool_calls: z.ZodDefault<z.ZodNumber>;
2417
2420
  every_architect_turns: z.ZodDefault<z.ZodNumber>;
2418
2421
  every_minutes: z.ZodDefault<z.ZodNumber>;
2422
+ max_dispatch_retries: z.ZodDefault<z.ZodNumber>;
2423
+ max_consecutive_dispatch_failures: z.ZodDefault<z.ZodNumber>;
2419
2424
  }, z.core.$strip>>;
2420
2425
  }, z.core.$strip>>>;
2421
2426
  pr_monitor: z.ZodOptional<z.ZodObject<{
@@ -44,6 +44,10 @@ export interface DispatchFullAutoOversightInput {
44
44
  */
45
45
  fullAutoConfig?: {
46
46
  fail_closed?: boolean;
47
+ /** Override for max dispatch retries (default from schema: 2). */
48
+ max_dispatch_retries?: number;
49
+ /** Override for max consecutive dispatch failures (default from schema: 3). */
50
+ max_consecutive_dispatch_failures?: number;
47
51
  };
48
52
  }
49
53
  export declare function parseFullAutoCriticResponse(rawResponse: string): FullAutoCriticResult;
@@ -85,5 +89,4 @@ export declare function dispatchFullAutoOversight(input: DispatchFullAutoOversig
85
89
  */
86
90
  export declare const _internals: {
87
91
  resetSequence: () => void;
88
- sleep: (ms: number) => Promise<void>;
89
92
  };
@@ -13,6 +13,7 @@ export interface FullAutoCounters {
13
13
  testFailures: number;
14
14
  oversightChecks: number;
15
15
  consecutiveNoProgressTurns: number;
16
+ consecutiveOversightFailures: number;
16
17
  }
17
18
  export interface FullAutoRunState {
18
19
  status: FullAutoStatus;
@@ -34,6 +35,8 @@ export interface FullAutoRunState {
34
35
  counters: FullAutoCounters;
35
36
  pauseReason?: string;
36
37
  terminateReason?: string;
38
+ /** Consecutive oversight dispatch failures for auto-degrade. */
39
+ consecutiveOversightFailures?: number;
37
40
  }
38
41
  export interface FullAutoPersistedState {
39
42
  version: 2;
@@ -104,6 +107,15 @@ export declare function terminateFullAutoRun(directory: string, sessionID: strin
104
107
  export declare function isFullAutoRunActive(directory: string, sessionID: string): boolean;
105
108
  export type FullAutoCounterKey = keyof FullAutoCounters;
106
109
  export declare function incrementFullAutoCounter(directory: string, sessionID: string, counter: FullAutoCounterKey, delta?: number): FullAutoRunState | undefined;
110
+ /**
111
+ * Increment the consecutive-oversight-failure counter.
112
+ * Returns the new value after incrementing.
113
+ */
114
+ export declare function incrementOversightFailureCounter(directory: string, sessionID: string): number;
115
+ /**
116
+ * Reset the consecutive-oversight-failure counter to 0.
117
+ */
118
+ export declare function resetOversightFailureCounter(directory: string, sessionID: string): void;
107
119
  export declare function recordFullAutoDenial(directory: string, sessionID: string, denial: {
108
120
  tool?: string;
109
121
  code?: string;
package/dist/git/pr.d.ts CHANGED
@@ -69,6 +69,7 @@ export declare const _internals: {
69
69
  spawnSyncWithTransientRetry: typeof spawnSyncWithTransientRetry;
70
70
  spawnSync: typeof __spawnSyncSeam.spawnSync;
71
71
  readLaneEnvFileFromDiskSync: typeof readLaneEnvFileFromDiskSync;
72
+ getMergeGroupRun: typeof getMergeGroupRun;
72
73
  };
73
74
  /**
74
75
  * Check if gh CLI is available
@@ -107,6 +108,7 @@ export interface PRStatusResult {
107
108
  name: string;
108
109
  status: string;
109
110
  conclusion: string | null;
111
+ detailsUrl?: string;
110
112
  }>;
111
113
  }
112
114
  export interface PRCheckResult {
@@ -156,4 +158,25 @@ export declare function getMergeState(prNumber: number, repoFullName: string, cw
156
158
  * Uses async ghExecAsync to avoid blocking the event loop.
157
159
  */
158
160
  export declare function getPRReviewState(prNumber: number, repoFullName: string, cwd: string): Promise<ReviewStateResult>;
161
+ /**
162
+ * Result of fetching a GitHub Actions run for a PR's merge group.
163
+ */
164
+ export interface MergeGroupRunResult {
165
+ /** Run status: queued, in_progress, completed. */
166
+ status: string;
167
+ /** Run conclusion: success, failure, cancelled, etc. */
168
+ conclusion: string | null;
169
+ /** HTML URL to the run. */
170
+ htmlUrl: string;
171
+ }
172
+ /**
173
+ * Fetch the merge group GitHub Actions run for a PR.
174
+ *
175
+ * Searches the PR's statusCheckRollup for the "Merge pull request" check,
176
+ * extracts the run ID from its detailsUrl, and fetches the run details
177
+ * via `gh run view`.
178
+ *
179
+ * Returns null if no merge group check is found (PR not in a merge queue).
180
+ */
181
+ export declare function getMergeGroupRun(statusCheckRollup: PRStatusResult['statusCheckRollup'], repoFullName: string, cwd: string): Promise<MergeGroupRunResult | null>;
159
182
  export {};
@@ -9,6 +9,7 @@
9
9
  * The _internals seam allows test injection of worktree operations.
10
10
  */
11
11
  import type { PluginConfig, WorktreeIsolationConfig } from '../../config';
12
+ import { bunSpawn } from '../../utils/bun-compat';
12
13
  import type { WorktreeHandle } from '../../worktree';
13
14
  import { attemptMergeBackFromDirty, cleanupOrphanedBranches, postMergeCleanup, provisionWorktree, removeWorktree, startupOrphanRecovery } from '../../worktree';
14
15
  /**
@@ -107,6 +108,38 @@ declare function rememberStandardWorktreeSerializationSession(sessionID: string)
107
108
  export declare function sanitizeWorktreeTaskId(raw: string): string;
108
109
  import { resolveWorktreeIsolationConfig } from '../../config/worktree-isolation-config';
109
110
  export { resolveWorktreeIsolationConfig };
111
+ /**
112
+ * FR-001b SC-004: Runs `git worktree list --porcelain` and checks whether
113
+ * ANY registered worktree has a lane branch for the given taskId (regardless
114
+ * of which session owns it).
115
+ *
116
+ * The detection pattern matches both current `swarm/lane/<sessionId>/<taskId>`
117
+ * and legacy `swarm-lane/<sessionId>/<taskId>` branch formats.
118
+ *
119
+ * Returns collision info if any lane for this taskId is found registered in
120
+ * an active worktree. Does NOT check whether the worktree path is valid on
121
+ * disk — only whether the branch is checked out somewhere.
122
+ *
123
+ * @param taskId - Task ID to detect collisions for.
124
+ * @param directory - Project root (git working tree).
125
+ * @param sessionId - Current session ID (used only to populate ownerSessionId
126
+ * in the collision result; NOT used for collision detection).
127
+ */
128
+ export declare function preProvisionCollisionCheck(taskId: string, directory: string, _sessionId: string): Promise<{
129
+ collision: boolean;
130
+ existingBranch?: string;
131
+ ownerSessionId?: string;
132
+ worktreePath?: string;
133
+ }>;
134
+ /**
135
+ * FR-001b SC-005: Returns true when `branchName`'s embedded session ID matches
136
+ * `expectedSessionId`.
137
+ *
138
+ * Uses `extractSessionId` (merge.ts) to parse the branch name. Supports both
139
+ * legacy `swarm-lane/<sessionId>/<id>` and current `swarm/lane/<sessionId>/<id>`
140
+ * patterns.
141
+ */
142
+ export declare function isLaneOwnedByCurrentSession(branchName: string, expectedSessionId: string): boolean;
110
143
  export declare function precreateStandardWorktreeSession(args: {
111
144
  config: PluginConfig;
112
145
  directory: string;
@@ -122,6 +155,68 @@ export declare function precreateStandardWorktreeSession(args: {
122
155
  files: string[];
123
156
  };
124
157
  }): Promise<void>;
158
+ /**
159
+ * FR-001c: Preserves dirty work in a worktree before cleanup on denial or cancellation.
160
+ *
161
+ * Detects dirty state, auto-commits with a descriptive message, tags the commit,
162
+ * and returns the commit hash so the work is recoverable from the reflog.
163
+ *
164
+ * @returns Three distinct outcomes:
165
+ * - `{ outcome: 'clean', preserved: false }` — worktree was clean; nothing to preserve.
166
+ * - `{ outcome: 'preserved', preserved: true, ref: <hash> }` — dirty AND commit succeeded.
167
+ * - `{ outcome: 'preserve-failed', preserved: false, error: <msg> }` — dirty AND commit/tag failed.
168
+ */
169
+ export declare function preserveDirtyWorktreeForCallId(callID: string, reason: 'denied' | 'cancelled', _directory: string, _worktree_dir?: string): Promise<{
170
+ outcome: 'clean' | 'preserved' | 'preserve-failed';
171
+ preserved: false | true;
172
+ ref?: string;
173
+ error?: string;
174
+ }>;
175
+ /**
176
+ * FR-001b SC-004: Preserves dirty worktree state at a known worktree path.
177
+ *
178
+ * This is the path-based counterpart of `preserveDirtyWorktreeForCallId` for the
179
+ * pre-provision collision fallback path where the callID is no longer tracked in
180
+ * any map (dispatch was GC'd). It runs the same git status → add → commit → tag
181
+ * sequence on a direct worktreePath.
182
+ *
183
+ * @param worktreePath - Absolute path to the worktree directory.
184
+ * @param branchName - Branch name (used only for advisory messages).
185
+ * @param reason - Preservation reason: 'denied' (pre-provision collision) or 'cancelled'.
186
+ * @param directory - Project root for git commands.
187
+ * @param worktree_dir - Optional worktree-dir override.
188
+ * @returns Preservation result matching preserveDirtyWorktreeForCallId's shape.
189
+ */
190
+ export declare function preserveDirtyWorktreeAtPath(worktreePath: string, branchName: string, reason: 'denied' | 'cancelled', _directory: string, _worktree_dir?: string): Promise<{
191
+ outcome: 'clean' | 'preserved' | 'preserve-failed';
192
+ preserved: false | true;
193
+ ref?: string;
194
+ error?: string;
195
+ }>;
196
+ /**
197
+ * FR-001a: Unconditionally cleans up a standard worktree dispatch's resources.
198
+ *
199
+ * Called at the end of every dispatch outcome (success, denial, cancellation)
200
+ * to ensure no worktree or branch is left behind.
201
+ *
202
+ * @param callID - The callID of the dispatch to clean up.
203
+ * @param reason - The outcome reason: 'success', 'denied', or 'cancelled'.
204
+ * @param directory - The project root (required for git worktree/branch commands).
205
+ * @param worktree_dir - Configured worktree-dir override.
206
+ */
207
+ export declare function cleanupStandardWorktreeForCallId(callID: string, reason: 'success' | 'denied' | 'cancelled', directory: string, worktree_dir?: string): Promise<void>;
208
+ /**
209
+ * FR-001a: Abort an in-flight standard worktree dispatch.
210
+ *
211
+ * Called when a dispatch needs to be cancelled before merge-back completes.
212
+ * Handles the case where the worktree was never provisioned (no entry in
213
+ * standardWorktreeByCallID) by returning early with a no-op diagnostic.
214
+ *
215
+ * @param callID - The callID of the dispatch to abort.
216
+ * @param reason - The abort reason: 'denied' or 'cancelled'.
217
+ * @param directory - The project root (required for git worktree/branch commands).
218
+ */
219
+ export declare function abortStandardWorktreeDispatch(callID: string, reason: 'denied' | 'cancelled', directory: string): Promise<void>;
125
220
  export declare function finishStandardWorktreeDispatch(directory: string, dispatch: StandardWorktreeDispatch, config?: PluginConfig,
126
221
  /**
127
222
  * Optional callID for cleanup of awaitingMergeByCallID. When omitted,
@@ -165,4 +260,19 @@ export declare const _internals: {
165
260
  awaitingMergeByCallID: Map<string, AwaitingMergeRecord>;
166
261
  startupOrphanRecovery: typeof startupOrphanRecovery;
167
262
  cleanupOrphanedBranches: typeof cleanupOrphanedBranches;
263
+ /** FR-001a: cleanup entry point for finishStandardWorktreeDispatch. */
264
+ cleanupStandardWorktreeForCallId: typeof cleanupStandardWorktreeForCallId;
265
+ /** FR-001c: preserves dirty worktree state before cleanup on denial/cancellation. */
266
+ preserveDirtyWorktreeForCallId: typeof preserveDirtyWorktreeForCallId;
267
+ /** FR-001b SC-004: path-based dirty worktree preservation for stale-lane fallback. */
268
+ preserveDirtyWorktreeAtPath: typeof preserveDirtyWorktreeAtPath;
269
+ /** FR-001a: abort entry point for in-flight dispatches. */
270
+ abortStandardWorktreeDispatch: typeof abortStandardWorktreeDispatch;
271
+ standardWorktreeByCallID: Map<string, StandardWorktreeDispatch>;
272
+ /** FR-001b SC-004: pre-provision collision check. */
273
+ preProvisionCollisionCheck: typeof preProvisionCollisionCheck;
274
+ /** FR-001b SC-005: lane ownership validation. */
275
+ isLaneOwnedByCurrentSession: typeof isLaneOwnedByCurrentSession;
276
+ /** FR-001b: bunSpawn — exposed for test injection so collision check can be mocked. */
277
+ bunSpawn: typeof bunSpawn;
168
278
  };
@@ -83,8 +83,22 @@ interface MessageWithParts {
83
83
  parts: MessagePart[];
84
84
  }
85
85
  declare function resolveDelegatedPlanTaskId(args: Record<string, unknown>, knownPlanTaskIds?: ReadonlySet<string>): string | null;
86
- export declare function hasReviewedTaskRows(output: string): boolean;
87
- export declare function parseReviewedTaskIdsFromSetDispatchOutput(output: string): string[];
86
+ /**
87
+ * Parses structured per-task verdict lines from agent dispatch output.
88
+ *
89
+ * Recognized formats:
90
+ * [REVIEWED] | task-2.1 | APPROVED | ...
91
+ * [TESTED] | task-2.1 | PASS | ...
92
+ * [REVIEWED] | 2.1 | APPROVED | ... (bare task ID without prefix)
93
+ *
94
+ * Returns a Map from task ID to verdict string (e.g. "APPROVED", "REJECTED", "PASS", "FAIL").
95
+ * Only task IDs matching strict task ID format (N.M or N.M.P) are included.
96
+ * Lines that don't match the pattern are silently ignored.
97
+ *
98
+ * @param outputText - Raw text output from the agent dispatch
99
+ * @returns Map of taskId -> verdict string
100
+ */
101
+ export declare function parsePerTaskVerdicts(outputText: string): Map<string, string>;
88
102
  declare function buildParallelExecutionGuidance(directory: string | undefined, sessionID: string, session: AgentSessionState): Promise<string | null>;
89
103
  /**
90
104
  * Resolves the correct task ID for evidence recording by chaining:
@@ -109,6 +123,7 @@ declare function resolveEvidenceTaskId(args: Record<string, unknown> | undefined
109
123
  export declare const _internals: {
110
124
  resolveEvidenceTaskId: typeof resolveEvidenceTaskId;
111
125
  resolveDelegatedPlanTaskId: typeof resolveDelegatedPlanTaskId;
126
+ parsePerTaskVerdicts: typeof parsePerTaskVerdicts;
112
127
  buildParallelExecutionGuidance: typeof buildParallelExecutionGuidance;
113
128
  loadPlanJsonOnly: typeof loadPlanJsonOnly;
114
129
  resetStandardWorktreeIsolationState: typeof resetStandardWorktreeIsolationState;
@@ -53,7 +53,7 @@ export declare function injectVerdictIntoMessages(messages: MessageWithParts[],
53
53
  * This function encapsulates the critic invocation and event writing flow.
54
54
  * The critic response is awaited before writing the event to events.jsonl.
55
55
  */
56
- export declare function dispatchCriticAndWriteEvent(directory: string, architectOutput: string, criticContext: string, criticModel: string, escalationType: 'phase_completion' | 'question', interactionCount: number, deadlockCount: number, oversightAgentName: string, sessionID?: string): Promise<CriticDispatchResult>;
56
+ export declare function dispatchCriticAndWriteEvent(directory: string, architectOutput: string, criticContext: string, criticModel: string, escalationType: 'phase_completion' | 'question', interactionCount: number, deadlockCount: number, oversightAgentName: string, sessionID?: string, maxDispatchRetries?: number, maxConsecutiveDispatchFailures?: number): Promise<CriticDispatchResult>;
57
57
  /**
58
58
  * Creates the full-auto intercept hook factory.
59
59
  *
@@ -144,7 +144,27 @@ export interface SkillStaleBatchEvent {
144
144
  retiredCount: number;
145
145
  staleCount: number;
146
146
  }
147
- export type KnowledgeEvent = RetrievedEvent | ReceiptEvent | OutcomeEvent | ArchivedEvent | EscalationEvent | SkillStaleBatchEvent;
147
+ /**
148
+ * A diagnostic tombstone: the architect auto-injection hook skipped injection
149
+ * for a diagnosable reason (issue #1768). Every silent early-return in
150
+ * `createKnowledgeInjectorHook` emits one of these so the dead-path cause is
151
+ * recoverable from `.swarm/knowledge-events.jsonl`. Diagnostic only —
152
+ * `recomputeCounters` intentionally ignores it (no counter mutation).
153
+ */
154
+ export interface InjectionSkipEvent {
155
+ type: 'injection_skip';
156
+ schema_version?: number;
157
+ event_id: string;
158
+ timestamp: string;
159
+ /** Machine-readable reason tag (e.g. 'headroom_budget', 'no_agent_name'). */
160
+ reason: string;
161
+ agent?: string;
162
+ session_id?: string;
163
+ phase?: number;
164
+ /** Structured, redactable detail (char counts, model id, etc.). */
165
+ detail?: Record<string, unknown>;
166
+ }
167
+ export type KnowledgeEvent = RetrievedEvent | ReceiptEvent | OutcomeEvent | ArchivedEvent | EscalationEvent | SkillStaleBatchEvent | InjectionSkipEvent;
148
168
  export type KnowledgeEventType = KnowledgeEvent['type'];
149
169
  /**
150
170
  * Event shape accepted by {@link appendKnowledgeEvent} / {@link recordKnowledgeEvent}.
@@ -9,6 +9,8 @@ import { recordKnowledgeShown } from './knowledge-application.js';
9
9
  import { buildEscalationBriefing, readRecentEscalations } from './knowledge-escalator.js';
10
10
  import { recordKnowledgeEvent } from './knowledge-events.js';
11
11
  import type { RankedEntry } from './knowledge-reader.js';
12
+ import { recordLessonsShown } from './knowledge-reader.js';
13
+ import { confirmEntriesPhase } from './knowledge-store.js';
12
14
  import type { DirectivePriority, KnowledgeConfig, MessageWithParts } from './knowledge-types.js';
13
15
  import { searchKnowledge } from './search-knowledge.js';
14
16
  /** Marker that uniquely identifies the delegate directive block in a transcript. */
@@ -97,4 +99,6 @@ export declare const _internals: {
97
99
  recordKnowledgeShown: typeof recordKnowledgeShown;
98
100
  readRecentEscalations: typeof readRecentEscalations;
99
101
  buildEscalationBriefing: typeof buildEscalationBriefing;
102
+ recordLessonsShown: typeof recordLessonsShown;
103
+ confirmEntriesPhase: typeof confirmEntriesPhase;
100
104
  };
@@ -35,6 +35,21 @@ export interface RankedEntry extends KnowledgeEntryBase {
35
35
  };
36
36
  }
37
37
  declare function transactShownFile(shownFile: string, mutate: (data: Record<string, string[]>) => Record<string, string[]> | null): Promise<boolean>;
38
+ /**
39
+ * Records the set of knowledge IDs actually injected during a phase under the
40
+ * canonical `Phase N` key in `.swarm/.knowledge-shown.json`, so
41
+ * {@link updateRetrievalOutcome} can later attribute the phase's outcome to
42
+ * exactly those entries.
43
+ *
44
+ * Ownership (issue #1768): the shown-set write lives HERE at the injector layer
45
+ * (which knows the final rendered set), NOT inside `readMergedKnowledge` (which
46
+ * only sees the widened pre-rerank pool). Multiple injectors (architect +
47
+ * delegate) may write the same `Phase N` key within one phase, so the key is
48
+ * **union-merged** (dedup-safe) rather than overwritten — otherwise the last
49
+ * writer would clobber earlier id sets and those entries would receive no
50
+ * outcome attribution.
51
+ */
52
+ export declare function recordLessonsShown(directory: string, lessonIds: string[], currentPhase: string): Promise<void>;
38
53
  export declare function readMergedKnowledge(directory: string, config: KnowledgeConfig, context?: ProjectContext, opts?: {
39
54
  skipScopeFilter?: boolean;
40
55
  }): Promise<RankedEntry[]>;
@@ -52,5 +67,6 @@ export declare const _internals: {
52
67
  scoreDirectiveAgainstContext: typeof scoreDirectiveAgainstContext;
53
68
  transactShownFile: typeof transactShownFile;
54
69
  recordKnowledgeEvent: typeof recordKnowledgeEvent;
70
+ recordLessonsShown: typeof recordLessonsShown;
55
71
  };
56
72
  export {};