opencode-swarm 7.90.0 → 7.91.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.
Files changed (29) hide show
  1. package/dist/cli/{evidence-summary-service-5me91eq8.js → evidence-summary-service-mr9sns2d.js} +5 -5
  2. package/dist/cli/{gate-evidence-y8zn7fe2.js → gate-evidence-nphg8hay.js} +4 -4
  3. package/dist/cli/{guardrail-explain-han9f51y.js → guardrail-explain-0ephhnjq.js} +10 -10
  4. package/dist/cli/{index-1ccnwh54.js → index-5hrexm02.js} +3 -3
  5. package/dist/cli/{index-bcp79s17.js → index-91qtsbce.js} +1 -1
  6. package/dist/cli/{index-mz2z7jtn.js → index-e9tp9p2w.js} +14 -14
  7. package/dist/cli/{index-q3265fxa.js → index-gpkbg9p4.js} +10 -10
  8. package/dist/cli/{index-fjwwrwr5.js → index-kv4dd5c5.js} +1 -1
  9. package/dist/cli/{index-e7h9bb6v.js → index-mh1ej70w.js} +2 -2
  10. package/dist/cli/{index-vqyfscxd.js → index-sf08zj91.js} +1 -1
  11. package/dist/cli/{index-axwxkbdd.js → index-w7gkpmq8.js} +2 -2
  12. package/dist/cli/{index-prppjv2q.js → index-wtyysb1n.js} +1 -1
  13. package/dist/cli/{index-p0ye10nd.js → index-xchgryg4.js} +10 -2
  14. package/dist/cli/{index-8y7qetpg.js → index-y1z6yaq4.js} +3 -3
  15. package/dist/cli/index.js +9 -9
  16. package/dist/cli/{knowledge-store-gsy6p46z.js → knowledge-store-eqans52j.js} +4 -4
  17. package/dist/cli/{pending-delegations-35fvcj7z.js → pending-delegations-shqbvfjc.js} +2 -2
  18. package/dist/cli/{pr-subscriptions-b18n1yd8.js → pr-subscriptions-2565fpsc.js} +3 -3
  19. package/dist/cli/{skill-generator-1hzfyhth.js → skill-generator-d0jzw6n2.js} +5 -5
  20. package/dist/cli/{telemetry-9bbyxrvn.js → telemetry-aa1ma1dr.js} +4 -2
  21. package/dist/index.js +5958 -7994
  22. package/dist/lang/registry.d.ts +1 -1
  23. package/dist/lang/symbol-graph.d.ts +43 -0
  24. package/dist/telemetry.d.ts +7 -0
  25. package/dist/tools/repo-graph/builder.d.ts +30 -1
  26. package/dist/tools/repo-graph/query.d.ts +5 -1
  27. package/dist/tools/repo-graph/types.d.ts +70 -1
  28. package/dist/tools/repo-graph.d.ts +2 -2
  29. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { type Parser } from './runtime';
1
+ import type { Parser } from './runtime';
2
2
  export declare const _internals: {
3
3
  getLanguageForExtension: typeof getLanguageForExtension;
4
4
  listSupportedLanguages: typeof listSupportedLanguages;
@@ -0,0 +1,43 @@
1
+ export interface FileSymbolFacts {
2
+ defs: Array<{
3
+ name: string;
4
+ kind: 'function' | 'class' | 'const' | 'type' | 'interface' | 'enum' | 'method';
5
+ exported: boolean;
6
+ startLine: number;
7
+ endLine: number;
8
+ }>;
9
+ imports: Array<{
10
+ specifier: string;
11
+ importType: 'commonjs' | 'named' | 'namespace' | 'default';
12
+ bindings: Array<{
13
+ imported: string;
14
+ local: string;
15
+ }>;
16
+ }>;
17
+ refs: Array<{
18
+ identifier: string;
19
+ line: number;
20
+ enclosingDecl: string | null;
21
+ }>;
22
+ }
23
+ /**
24
+ * Extract symbol, import, and reference facts from a source string using
25
+ * tree-sitter.
26
+ *
27
+ * Fail-open: returns null on grammar-load failure, timeout, or parse error.
28
+ * The 500 ms `AST_TIMEOUT_MS` race bounds the async `loadGrammar` WASM load
29
+ * and races the parse attempt, but cannot hard-interrupt a synchronous
30
+ * `parser.parse()` once it begins (mirrors the `computeASTDiff` pattern in
31
+ * `src/diff/ast-diff.ts`). The primary async risk (WASM grammar load) IS
32
+ * bounded.
33
+ *
34
+ * The parsed tree is always deleted: the inner async IIFE owns tree cleanup
35
+ * via its own `finally` block (deletes the tree after `buildFacts` regardless
36
+ * of whether the outer race rejects on timeout). Tree cleanup is handled
37
+ * solely by that inner `finally`; there is no outer backstop.
38
+ *
39
+ * @param grammarId - Tree-sitter grammar id (e.g. 'typescript')
40
+ * @param source - Source code text
41
+ * @returns FileSymbolFacts, or null on failure
42
+ */
43
+ export declare function extractFileSymbols(grammarId: string, source: string): Promise<FileSymbolFacts | null>;
@@ -1,5 +1,11 @@
1
1
  export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'phase_changed' | 'budget_updated' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'snapshot_failed' | 'prm_pattern_detected' | 'prm_course_correction_injected' | 'prm_escalation_triggered' | 'prm_hard_stop';
2
2
  export type TelemetryListener = (event: TelemetryEvent, data: Record<string, unknown>) => void;
3
+ /**
4
+ * Number of emits between rotation checks. 50 keeps the overhead at one
5
+ * `statSync` per 50 telemetry writes (~once per few seconds in a busy
6
+ * session, roughly once per minute in a quiet one).
7
+ */
8
+ export declare const ROTATION_CHECK_INTERVAL = 50;
3
9
  /** @internal - For testing only */
4
10
  export declare function resetTelemetryForTesting(): void;
5
11
  /**
@@ -69,4 +75,5 @@ export declare const telemetry: {
69
75
  export declare const _internals: {
70
76
  telemetry: typeof telemetry;
71
77
  emit: typeof emit;
78
+ rotateTelemetryIfNeeded: typeof rotateTelemetryIfNeeded;
72
79
  };
@@ -10,10 +10,11 @@
10
10
  * Also exports upsertNode, addEdge, and resolveModuleSpecifier which are
11
11
  * used by both the builder and the incremental updater.
12
12
  */
13
+ import { extractFileSymbols } from '../../lang/symbol-graph';
13
14
  import { extractPythonSymbols, extractTSSymbols } from '../symbols';
14
15
  import { extractFileOntology } from './ontology';
15
16
  import { safeRealpathSync } from './safe-realpath';
16
- import type { BuildWorkspaceGraphOptions, GraphEdge, GraphNode, RepoGraph } from './types';
17
+ import type { BuildWorkspaceGraphOptions, GraphEdge, GraphNode, RepoGraph, SymbolEdge } from './types';
17
18
  /**
18
19
  * _internals DI seam for safeRealpathSync.
19
20
  * Defaults to the real implementation. Tests can override this to inject
@@ -28,6 +29,7 @@ export declare const _internals: {
28
29
  extractFileOntology: typeof extractFileOntology;
29
30
  stripComments: typeof stripComments;
30
31
  computeUsedSymbols: typeof computeUsedSymbols;
32
+ extractFileSymbols: typeof extractFileSymbols;
31
33
  };
32
34
  /**
33
35
  * Add or update a node in the graph.
@@ -130,6 +132,16 @@ export interface ScanResult {
130
132
  /** The edges created from this file's imports */
131
133
  edges: GraphEdge[];
132
134
  }
135
+ /**
136
+ * Result of the async single-file scanner. Extends ScanResult with
137
+ * symbol-level reference edges produced by tree-sitter symbol extraction.
138
+ */
139
+ export interface AsyncScanResult {
140
+ node: GraphNode | null;
141
+ edges: GraphEdge[];
142
+ /** Symbol-to-symbol reference edges (schema >= 1.2.0). */
143
+ symbolEdges: SymbolEdge[];
144
+ }
133
145
  /**
134
146
  * Scan a single file and extract its graph node and edges.
135
147
  * Reuses the same logic from buildWorkspaceGraph for consistency.
@@ -140,6 +152,23 @@ export interface ScanResult {
140
152
  * @returns ScanResult with node and edges
141
153
  */
142
154
  export declare function scanFile(filePath: string, absoluteRoot: string, maxFileSize: number): ScanResult;
155
+ /**
156
+ * Async variant of scanFile that uses tree-sitter symbol extraction
157
+ * (extractFileSymbols) to populate exportRanges and symbolEdges.
158
+ *
159
+ * Fail-open: if extractFileSymbols returns null (grammar unavailable,
160
+ * timeout, parse error), falls back to a minimal file-level node with
161
+ * empty exports/imports/symbolEdges — never throws.
162
+ *
163
+ * Oversized, binary, or unreadable files return { node: null, edges: [], symbolEdges: [] }
164
+ * matching the sync scanFile contract.
165
+ *
166
+ * @param filePath - Absolute path to the file to scan
167
+ * @param absoluteRoot - Absolute path to workspace root
168
+ * @param maxFileSize - Maximum file size in bytes
169
+ * @returns AsyncScanResult with node, edges, and symbolEdges
170
+ */
171
+ export declare function scanFileAsync(filePath: string, absoluteRoot: string, maxFileSize: number): Promise<AsyncScanResult>;
143
172
  /**
144
173
  * Build a complete dependency graph for a workspace by scanning all source files.
145
174
  *
@@ -1,4 +1,4 @@
1
- import type { BlastRadiusResult, CallerReference, DeadExportsResult, FileOntology, FileReference, GraphNode, LocalizationBlock, PackageBoundarySummary, RepoGraph, SymbolReference } from './types';
1
+ import type { BlastRadiusResult, CallerReference, ContextPackResult, DeadExportsResult, FileOntology, FileReference, GraphNode, LocalizationBlock, PackageBoundarySummary, RepoGraph, SymbolReference } from './types';
2
2
  export declare function getGraphNode(graph: RepoGraph, input: string): GraphNode | undefined;
3
3
  export declare function resetQueryCache(): void;
4
4
  export declare function isGraphFresh(graph: RepoGraph | null, maxAgeMs?: number): boolean;
@@ -38,6 +38,10 @@ export declare function getLocalizationContext(graph: RepoGraph, filePath: strin
38
38
  maxDeps?: number;
39
39
  maxDepth?: number;
40
40
  }): LocalizationBlock;
41
+ export declare function getContextPack(graph: RepoGraph, file: string, symbol: string, options?: {
42
+ maxDepth?: number;
43
+ maxTokens?: number;
44
+ }): ContextPackResult;
41
45
  export declare function getPackageBoundaries(graph: RepoGraph, topN?: number): PackageBoundarySummary[];
42
46
  export declare function buildOntologyPreflightPacket(graph: RepoGraph, filePaths?: string[], options?: {
43
47
  maxFiles?: number;
@@ -16,8 +16,14 @@ export declare const REPO_GRAPH_FILENAME = "repo-graph.json";
16
16
  * versions (1.0.0) still load — but `dead_exports` requires >= 1.1.0 data and
17
17
  * self-gates via {@link isSchemaVersionAtLeast} rather than relying on the
18
18
  * loader (which only checks that a version string is present, not its value).
19
+ *
20
+ * 1.2.0 adds per-node `exportRanges` (1-based inclusive line spans for each
21
+ * exported symbol) and the top-level `symbolEdges` array (direct symbol-to-
22
+ * symbol reference edges). Both fields are optional, so 1.0.0 and 1.1.0 graphs
23
+ * still load without corruption. New queries may use these fields to provide
24
+ * more precise context-packing and symbol-level navigation.
19
25
  */
20
- export declare const GRAPH_SCHEMA_VERSION = "1.1.0";
26
+ export declare const GRAPH_SCHEMA_VERSION = "1.2.0";
21
27
  /**
22
28
  * Compare dotted numeric version strings (e.g. '1.1.0' >= '1.1.0').
23
29
  * Missing/non-numeric segments are treated as 0. Returns true when `version`
@@ -96,6 +102,17 @@ export interface GraphNode {
96
102
  * `dead_exports` candidates at a location.
97
103
  */
98
104
  exportLines?: Record<string, number>;
105
+ /**
106
+ * 1-based inclusive line span for each exported symbol, keyed by symbol
107
+ * name. Present on graphs built at schema >= 1.2.0; absent on older
108
+ * graphs. Used for precise context-packing around a symbol.
109
+ * Each span value uses `startLine` / `endLine` to match the codebase
110
+ * convention (see `ContextPackSpan` and `FileSymbolFacts`).
111
+ */
112
+ exportRanges?: Record<string, {
113
+ startLine: number;
114
+ endLine: number;
115
+ }>;
99
116
  /** Imported module specifiers */
100
117
  imports: string[];
101
118
  /** Language/extension of the file */
@@ -140,6 +157,56 @@ export interface SymbolReference {
140
157
  line?: number;
141
158
  importedAs: string;
142
159
  }
160
+ /**
161
+ * A symbol-level reference edge: one exported symbol in one file directly
162
+ * references (calls / uses) an exported symbol in another file.
163
+ *
164
+ * Present in graphs built at schema >= 1.2.0. These edges are finer-grained
165
+ * than {@link GraphEdge} (which tracks file-level imports) and enable
166
+ * precise context-packing and symbol navigation queries.
167
+ */
168
+ export interface SymbolEdge {
169
+ /** Resolved absolute path of the source file (matches `GraphNode.filePath` keys). */
170
+ fromFile: string;
171
+ /** Enclosing top-level declaration in the source file, or `'<module>'` for module-scope references. */
172
+ fromSymbol: string;
173
+ /** Resolved absolute path of the target file. */
174
+ toFile: string;
175
+ /** Exported symbol referenced in the target file. */
176
+ toSymbol: string;
177
+ }
178
+ /**
179
+ * A contiguous line span inside a source file, used by context-packing to
180
+ * extract the relevant region around a symbol without reading the whole file.
181
+ */
182
+ export interface ContextPackSpan {
183
+ file: string;
184
+ symbol: string;
185
+ startLine: number;
186
+ endLine: number;
187
+ mode: 'full' | 'signature';
188
+ }
189
+ /**
190
+ * Result of a context-pack query: the set of spans needed to understand
191
+ * how a target symbol is used across the workspace.
192
+ */
193
+ export interface ContextPackResult {
194
+ /** False when the graph predates schema 1.2.0 (rebuild required for full results). */
195
+ schemaSupported: boolean;
196
+ /** The symbol whose usage context was requested. */
197
+ target: {
198
+ file: string;
199
+ symbol: string;
200
+ };
201
+ /** Deduped, budget-ordered spans covering usage sites. */
202
+ spans: ContextPackSpan[];
203
+ /** True when the span budget was exhausted before all sites could be returned. */
204
+ truncated: boolean;
205
+ /** Rough token estimate for the returned spans (sum of span sizes × a fixed multiplier). */
206
+ estimatedTokens: number;
207
+ /** Optional human-readable note about scope or limitations. */
208
+ note?: string;
209
+ }
143
210
  /**
144
211
  * A file that references a specific exported symbol of a target file.
145
212
  * `resolution` records how confidently the usage was attributed:
@@ -230,6 +297,8 @@ export interface RepoGraph {
230
297
  nodeCount: number;
231
298
  edgeCount: number;
232
299
  };
300
+ /** Symbol-level reference edges (schema >= 1.2.0; absent on older graphs). */
301
+ symbolEdges?: SymbolEdge[];
233
302
  }
234
303
  /**
235
304
  * Options for building a workspace graph.
@@ -21,8 +21,8 @@ export { updateGraphForFiles } from './repo-graph/incremental';
21
21
  export type { ExtractFileOntologyInput } from './repo-graph/ontology';
22
22
  export { extractFileOntology } from './repo-graph/ontology';
23
23
  export type { DeadExportsOptions } from './repo-graph/query';
24
- export { buildOntologyPreflightPacket, getBlastRadius, getCallers, getDeadExports, getDependencies, getFileOntology, getGraphNode, getImporters, getKeyFiles, getLocalizationContext, getPackageBoundaries, getSymbolConsumers, isGraphFresh, resetQueryCache, } from './repo-graph/query';
24
+ export { buildOntologyPreflightPacket, getBlastRadius, getCallers, getContextPack, getDeadExports, getDependencies, getFileOntology, getGraphNode, getImporters, getKeyFiles, getLocalizationContext, getPackageBoundaries, getSymbolConsumers, isGraphFresh, resetQueryCache, } from './repo-graph/query';
25
25
  export { getGraphPath, loadGraph, loadGraphSync, loadOrCreateGraph, saveGraph, saveIfDirty, } from './repo-graph/storage';
26
- export type { BlastRadiusResult, BuildWorkspaceGraphOptions, CallerReference, ConventionFact, DataOperationFact, DeadExportCandidate, DeadExportsResult, FileOntology, FileReference, FileRole, GraphEdge, GraphNode, LocalizationBlock, OntologyFinding, PackageBoundarySummary, RepoGraph, RouteFact, RouteMethod, SecurityFact, SymbolReference, } from './repo-graph/types';
26
+ export type { BlastRadiusResult, BuildWorkspaceGraphOptions, CallerReference, ContextPackResult, ContextPackSpan, ConventionFact, DataOperationFact, DeadExportCandidate, DeadExportsResult, FileOntology, FileReference, FileRole, GraphEdge, GraphNode, LocalizationBlock, OntologyFinding, PackageBoundarySummary, RepoGraph, RouteFact, RouteMethod, SecurityFact, SymbolEdge, SymbolReference, } from './repo-graph/types';
27
27
  export { createEmptyGraph, GRAPH_SCHEMA_VERSION, isSchemaVersionAtLeast, normalizeGraphPath, REPO_GRAPH_FILENAME, updateGraphMetadata, } from './repo-graph/types';
28
28
  export { validateGraphEdge, validateGraphNode, validateWorkspace, } from './repo-graph/validation';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.90.0",
3
+ "version": "7.91.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",
@@ -71,7 +71,7 @@
71
71
  ],
72
72
  "scripts": {
73
73
  "clean": "bun -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
74
- "build": "bun run clean && bun run scripts/copy-grammars.ts && bun build src/index.ts --outdir dist --target node --format esm && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external bash-parser --splitting && bun run scripts/copy-grammars.ts --to-dist && tsc --emitDeclarationOnly",
74
+ "build": "bun run clean && bun run scripts/copy-grammars.ts && bun build src/index.ts --outdir dist --target node --format esm --external web-tree-sitter && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external bash-parser --splitting && bun run scripts/copy-grammars.ts --to-dist && tsc --emitDeclarationOnly",
75
75
  "typecheck": "tsc --noEmit",
76
76
  "test": "bun test",
77
77
  "lint": "biome lint .",