opencode-swarm 6.61.0 → 6.63.0

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.
@@ -108,7 +108,7 @@ export declare function readLedgerEvents(directory: string): Promise<LedgerEvent
108
108
  * @param directory - The working directory
109
109
  * @param planId - Unique identifier for the plan
110
110
  */
111
- export declare function initLedger(directory: string, planId: string, initialPlanHash?: string): Promise<void>;
111
+ export declare function initLedger(directory: string, planId: string, initialPlanHash?: string, initialPlan?: Plan): Promise<void>;
112
112
  /**
113
113
  * Append a new event to the ledger.
114
114
  * Uses atomic write: write to temp file then rename.
@@ -206,7 +206,7 @@ interface ReplayOptions {
206
206
  * @param options - Optional replay options
207
207
  * @returns Reconstructed Plan from ledger events, or null if plan.json doesn't exist or ledger is empty
208
208
  */
209
- export declare function replayFromLedger(directory: string, options?: ReplayOptions): Promise<Plan | null>;
209
+ export declare function replayFromLedger(directory: string, _options?: ReplayOptions): Promise<Plan | null>;
210
210
  /**
211
211
  * Result type for readLedgerEventsWithIntegrity
212
212
  */
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Typed error for concurrent plan modification (#444 item 3).
3
+ * Thrown when savePlan exhausts CAS retries due to concurrent writers.
4
+ * Callers can catch this specifically to refresh and retry at the outer level.
5
+ */
6
+ export declare class PlanConcurrentModificationError extends Error {
7
+ constructor(message: string);
8
+ }
1
9
  import { type Plan, type RuntimePlan, type TaskStatus } from '../config/plan-schema';
2
10
  /** Reset the startup ledger check flag. For testing only. */
3
11
  export declare function resetStartupLedgerCheck(): void;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Tool to retrieve the last critic-approved immutable plan snapshot.
3
+ *
4
+ * Wraps `loadLastApprovedPlan` from `src/plan/ledger.ts` as a tool callable
5
+ * by the critic `phase_drift_verifier` agent. Enables active baseline drift
6
+ * comparison: the drift verifier can compare the immutable approved snapshot
7
+ * against the current `plan.json` to detect silent plan mutations introduced
8
+ * after approval.
9
+ *
10
+ * The tool internally derives `plan_id` from the current plan for
11
+ * cross-identity safety — the caller does not need to know the format.
12
+ *
13
+ * Read-only: no file writes.
14
+ *
15
+ * @see https://github.com/zaxbysauce/opencode-swarm/issues/449
16
+ */
17
+ import { tool } from '@opencode-ai/plugin';
18
+ interface GetApprovedPlanResult {
19
+ success: boolean;
20
+ reason?: string;
21
+ approved_plan?: ApprovedPlanPayload;
22
+ current_plan?: CurrentPlanPayload | null;
23
+ drift_detected?: boolean | 'unknown';
24
+ current_plan_error?: string;
25
+ }
26
+ interface ApprovedPlanPayload {
27
+ plan: unknown;
28
+ approval_metadata: Record<string, unknown> | undefined;
29
+ snapshot_seq: number;
30
+ snapshot_timestamp: string;
31
+ payload_hash: string;
32
+ }
33
+ interface CurrentPlanPayload {
34
+ plan: unknown;
35
+ current_hash: string;
36
+ }
37
+ /**
38
+ * Core execution logic — exported for direct testing.
39
+ */
40
+ export declare function executeGetApprovedPlan(args: {
41
+ summary_only?: boolean;
42
+ }, directory: string): Promise<GetApprovedPlanResult>;
43
+ export declare const get_approved_plan: ReturnType<typeof tool>;
44
+ export {};
@@ -12,6 +12,7 @@ export { doc_extract, doc_scan } from './doc-scan';
12
12
  export { detect_domains } from './domain-detector';
13
13
  export { evidence_check } from './evidence-check';
14
14
  export { extract_code_blocks } from './file-extractor';
15
+ export { get_approved_plan } from './get-approved-plan';
15
16
  export { fetchGitingest, type GitingestArgs, gitingest } from './gitingest';
16
17
  export { imports } from './imports';
17
18
  export { knowledge_add } from './knowledge-add';
@@ -3,7 +3,7 @@
3
3
  * Used for constants and agent setup references.
4
4
  */
5
5
  /** Union type of all valid tool names */
6
- export type ToolName = 'diff' | 'syntax_check' | 'placeholder_scan' | 'imports' | 'lint' | 'secretscan' | 'sast_scan' | 'build_check' | 'pre_check_batch' | 'quality_budget' | 'symbols' | 'complexity_hotspots' | 'schema_drift' | 'todo_extract' | 'evidence_check' | 'check_gate_status' | 'completion_verify' | 'sbom_generate' | 'checkpoint' | 'pkg_audit' | 'test_runner' | 'detect_domains' | 'gitingest' | 'retrieve_summary' | 'extract_code_blocks' | 'phase_complete' | 'save_plan' | 'update_task_status' | 'lint_spec' | 'write_retro' | 'write_drift_evidence' | 'declare_scope' | 'knowledge_query' | 'doc_scan' | 'doc_extract' | 'curator_analyze' | 'knowledge_add' | 'knowledge_recall' | 'knowledge_remove' | 'co_change_analyzer' | 'search' | 'batch_symbols' | 'suggest_patch' | 'req_coverage';
6
+ export type ToolName = 'diff' | 'syntax_check' | 'placeholder_scan' | 'imports' | 'lint' | 'secretscan' | 'sast_scan' | 'build_check' | 'pre_check_batch' | 'quality_budget' | 'symbols' | 'complexity_hotspots' | 'schema_drift' | 'todo_extract' | 'evidence_check' | 'check_gate_status' | 'completion_verify' | 'sbom_generate' | 'checkpoint' | 'pkg_audit' | 'test_runner' | 'detect_domains' | 'gitingest' | 'retrieve_summary' | 'extract_code_blocks' | 'phase_complete' | 'save_plan' | 'update_task_status' | 'lint_spec' | 'write_retro' | 'write_drift_evidence' | 'declare_scope' | 'knowledge_query' | 'doc_scan' | 'doc_extract' | 'curator_analyze' | 'knowledge_add' | 'knowledge_recall' | 'knowledge_remove' | 'co_change_analyzer' | 'search' | 'batch_symbols' | 'suggest_patch' | 'req_coverage' | 'get_approved_plan';
7
7
  /** Readonly array of all tool names */
8
8
  export declare const TOOL_NAMES: readonly ToolName[];
9
9
  /** Set for O(1) tool name validation */
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Centralized task ID validation (#452 item 2).
3
+ *
4
+ * Two strictness levels exist by design:
5
+ *
6
+ * - **Strict** (`isStrictTaskId`): Only numeric N.M or N.M.P format.
7
+ * Use for gate-evidence operations where task IDs map to plan phases/tasks.
8
+ *
9
+ * - **Broad** (`isValidTaskId` / `sanitizeTaskId`): Accepts numeric, retrospective
10
+ * (retro-N), internal tool IDs (sast_scan, etc.), and general alphanumeric.
11
+ * Use for evidence storage, trajectory logging, and other paths that handle
12
+ * non-plan task IDs.
13
+ *
14
+ * Both levels reject path traversal, null bytes, control characters, and
15
+ * other unsafe patterns.
16
+ */
17
+ /**
18
+ * Strict validation: only numeric N.M or N.M.P format.
19
+ * Use for gate-evidence operations where task IDs correspond to plan phases/tasks.
20
+ */
21
+ export declare function isStrictTaskId(taskId: string): boolean;
22
+ /**
23
+ * Broad validation: accepts numeric, retrospective, internal tool, and
24
+ * general alphanumeric task IDs.
25
+ * Use for evidence storage, trajectory logging, and non-plan task ID paths.
26
+ */
27
+ export declare function isValidTaskId(taskId: string): boolean;
28
+ /**
29
+ * Throws if the task ID fails strict validation.
30
+ * Use as a guard at the top of functions that build file paths from task IDs.
31
+ */
32
+ export declare function assertStrictTaskId(taskId: string): void;
33
+ /**
34
+ * Validates and returns the task ID (broad validation).
35
+ * Throws with a descriptive message if the ID is invalid.
36
+ * Replaces evidence/manager.ts sanitizeTaskId for new callers.
37
+ */
38
+ export declare function sanitizeTaskId(taskId: string): string;
39
+ /**
40
+ * Validation for tool input: returns error message string if invalid, undefined if valid.
41
+ * Strict numeric format only (for update-task-status, declare-scope, etc.).
42
+ */
43
+ export declare function validateTaskIdFormat(taskId: string): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "6.61.0",
3
+ "version": "6.63.0",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",