opencode-swarm 7.121.0 → 7.121.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.
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  handleGuardrailExplain
4
- } from "./index-3je67dcz.js";
4
+ } from "./index-8cp19x15.js";
5
5
  import {
6
6
  handleGuardrailLog
7
7
  } from "./index-zvae4m8g.js";
@@ -83,7 +83,7 @@ import {
83
83
  handleWriteRetroCommand,
84
84
  normalizeSwarmCommandInput,
85
85
  resolveCommand
86
- } from "./index-gmc34yzt.js";
86
+ } from "./index-e7yqazk3.js";
87
87
  import"./index-kyvg2cmp.js";
88
88
  import"./index-vqcgmy4y.js";
89
89
  import"./index-j5xv8zbp.js";
package/dist/cli/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  getPluginLockFilePaths,
8
8
  package_default,
9
9
  resolveCommand
10
- } from "./index-gmc34yzt.js";
10
+ } from "./index-e7yqazk3.js";
11
11
  import"./index-kyvg2cmp.js";
12
12
  import"./index-vqcgmy4y.js";
13
13
  import"./index-j5xv8zbp.js";
@@ -10,4 +10,16 @@
10
10
  * --no-repro → appends noRepro=true to emitted signal
11
11
  * no args → returns usage string (no throw)
12
12
  */
13
+ import * as fs from 'node:fs';
14
+ /**
15
+ * DI seam for filesystem operations — allows tests to override synchronous fs calls.
16
+ */
17
+ export declare const _internals: {
18
+ writeFileSync: typeof fs.writeFileSync;
19
+ mkdirSync: typeof fs.mkdirSync;
20
+ renameSync: typeof fs.renameSync;
21
+ unlinkSync: typeof fs.unlinkSync;
22
+ readFileSync: typeof fs.readFileSync;
23
+ existsSync: typeof fs.existsSync;
24
+ };
13
25
  export declare function handleIssueCommand(directory: string, args: string[]): string;
@@ -101,6 +101,11 @@ interface MessageWithParts {
101
101
  info: MessageInfo;
102
102
  parts: MessagePart[];
103
103
  }
104
+ /**
105
+ * Returns whether the plan in the given directory has a valid plan-critic
106
+ * approval. Does not throw — returns `false` for any failure (fail-closed).
107
+ */
108
+ export declare function isPlanCriticApproved(directory: string): Promise<boolean>;
104
109
  declare function resolveDelegatedPlanTaskId(args: Record<string, unknown>, knownPlanTaskIds?: ReadonlySet<string>): string | null;
105
110
  /**
106
111
  * Parses structured per-task verdict lines from agent dispatch output.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Issue trace reducer — a pure transition function with zero I/O.
3
+ *
4
+ * Determines the next mode transition for an issue-trace workflow
5
+ * based on current trace state and workflow artifacts. Evaluated
6
+ * top-to-bottom (first-match-wins) against an 8-row decision table.
7
+ */
8
+ export interface IssueReference {
9
+ url: string;
10
+ owner: string;
11
+ repo: string;
12
+ number: number;
13
+ timestamp: string;
14
+ flags: {
15
+ plan?: boolean;
16
+ trace?: boolean;
17
+ noRepro?: boolean;
18
+ };
19
+ noReproWaiver?: {
20
+ waived: boolean;
21
+ reason: string;
22
+ timestamp: string;
23
+ };
24
+ }
25
+ export interface TraceState {
26
+ issueNumber: number;
27
+ lastTransition: string | null;
28
+ completed: boolean;
29
+ }
30
+ export interface WorkflowArtifacts {
31
+ specExists: boolean;
32
+ specIssueNumber: number | null;
33
+ planExists: boolean;
34
+ criticApproved: boolean;
35
+ allPhasesComplete: boolean;
36
+ }
37
+ export interface TransitionResult {
38
+ nextMode: string | null;
39
+ directive: string | null;
40
+ nextLastTransition: string | null;
41
+ nextCompleted: boolean;
42
+ }
43
+ export interface ComputeNextModeParams {
44
+ issueReference: IssueReference | null;
45
+ traceState: TraceState;
46
+ workflowArtifacts: WorkflowArtifacts;
47
+ }
48
+ /**
49
+ * Pure reducer: given trace state + workflow artifacts, return the
50
+ * next mode transition (or a no-op).
51
+ *
52
+ * Decision table (top-to-bottom, first match wins):
53
+ * (a) No issue reference or trace not requested → no-op
54
+ * (b) Trace already completed → no-op
55
+ * (c) Cross-issue guard (spec issue ≠ current issue) → no-op
56
+ * (d) Spec does not exist → no-op
57
+ * (e) Spec exists, no plan, never transitioned → PLAN
58
+ * (f) Plan exists but critic not approved → no-op
59
+ * (g) Critic approved, phases incomplete, not yet PLAN_TO_EXECUTE → EXECUTE
60
+ * (h) All phases complete, not yet EXECUTE_TO_COMMIT → COMMIT directive
61
+ *
62
+ * Idempotency: rows (e), (g), (h) return no-op when
63
+ * `traceState.lastTransition` already equals the target
64
+ * transition value.
65
+ */
66
+ export declare function computeNextMode(params: ComputeNextModeParams): TransitionResult;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Issue trace state adapter — reads and writes all artifacts for the
3
+ * issue-trace workflow engine.
4
+ *
5
+ * Uses the `_internals` DI seam pattern (AGENTS.md invariant 7) so
6
+ * tests can override filesystem calls without `mock.module` leakage.
7
+ */
8
+ import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
9
+ import type { Plan } from '../config/plan-schema';
10
+ import type { IssueReference, TraceState } from './issue-trace-reducer';
11
+ declare function _defaultLoadPlanFromLedger(directory: string): Promise<Plan | null>;
12
+ export declare const _internals: {
13
+ readFileSync: typeof readFileSync;
14
+ writeFileSync: typeof writeFileSync;
15
+ existsSync: typeof existsSync;
16
+ renameSync: typeof renameSync;
17
+ mkdirSync: typeof mkdirSync;
18
+ unlinkSync: typeof unlinkSync;
19
+ loadPlanFromLedger: typeof _defaultLoadPlanFromLedger;
20
+ };
21
+ /**
22
+ * Reads `.swarm/issue-reference.json` and returns the parsed object,
23
+ * or null if the file is absent or malformed.
24
+ */
25
+ export declare function readIssueReference(directory: string): IssueReference | null;
26
+ /**
27
+ * Reads `.swarm/issue-trace-state.json` and returns the parsed state,
28
+ * or a default `{issueNumber:0, lastTransition:null, completed:false}`
29
+ * if the file is absent or malformed.
30
+ */
31
+ export declare function readTraceState(directory: string): TraceState;
32
+ /**
33
+ * Writes `.swarm/issue-trace-state.json` atomically: creates a temp file
34
+ * inside `.swarm/`, writes JSON, then renames. Cleans up the temp on failure.
35
+ */
36
+ export declare function writeTraceState(directory: string, state: TraceState): void;
37
+ /**
38
+ * Reads `.swarm/spec.md` and extracts the issue number from the
39
+ * `## Source Issue` section. Looks for `- Number: N` or `- URL: ...issues/N`
40
+ * under the heading. Returns null if the section is absent or the number
41
+ * is unparseable.
42
+ */
43
+ export declare function readSpecIssueNumber(directory: string): number | null;
44
+ /**
45
+ * Loads the plan from the ledger-aware plan loader.
46
+ * Async because the underlying ledger loader is async.
47
+ */
48
+ export declare function loadPlanFromLedger(directory: string): Promise<Plan | null>;
49
+ /**
50
+ * Checks whether all phases in the plan have a completed status.
51
+ * Returns `{allComplete: false}` if the plan is null.
52
+ */
53
+ export declare function readPlanPhaseStatus(directory: string): Promise<{
54
+ allComplete: boolean;
55
+ }>;
56
+ /**
57
+ * Returns whether `.swarm/spec.md` exists.
58
+ */
59
+ export declare function specExists(directory: string): boolean;
60
+ /**
61
+ * Returns whether `.swarm/plan.json` exists.
62
+ */
63
+ export declare function planExists(directory: string): boolean;
64
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Issue trace hook — the deterministic trace transition engine.
3
+ *
4
+ * Ties together the reducer (issue-trace-reducer), the state adapter
5
+ * (issue-trace-state), and the approval helper (delegation-gate) into
6
+ * a single `messagesTransform` hook that the composeHandlers chain
7
+ * calls on every architect message cycle.
8
+ *
9
+ * Uses the `_internals` DI seam pattern (AGENTS.md invariant 7) so
10
+ * tests can override adapter functions without `mock.module` leakage.
11
+ */
12
+ import { isPlanCriticApproved } from './delegation-gate';
13
+ import { planExists, readIssueReference, readPlanPhaseStatus, readSpecIssueNumber, readTraceState, specExists, writeTraceState } from './issue-trace-state';
14
+ export declare const _internals: {
15
+ readIssueReference: typeof readIssueReference;
16
+ readTraceState: typeof readTraceState;
17
+ writeTraceState: typeof writeTraceState;
18
+ readSpecIssueNumber: typeof readSpecIssueNumber;
19
+ readPlanPhaseStatus: typeof readPlanPhaseStatus;
20
+ specExists: typeof specExists;
21
+ planExists: typeof planExists;
22
+ isPlanCriticApproved: typeof isPlanCriticApproved;
23
+ };
24
+ export declare function createIssueTraceHook(_config: unknown, directory: string, approvalTimeoutMs?: number): {
25
+ messagesTransform: (input: unknown, output: unknown) => Promise<void>;
26
+ };
27
+ /**
28
+ * Reset the approval cache. Called by tests in afterEach to avoid
29
+ * cross-test pollution from the module-level cache.
30
+ */
31
+ export declare function resetApprovalCache(): void;