opencode-swarm 7.90.1 → 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.
- package/dist/cli/{guardrail-explain-w29j6dmx.js → guardrail-explain-0ephhnjq.js} +2 -2
- package/dist/cli/{index-4gm78w6c.js → index-e9tp9p2w.js} +5 -5
- package/dist/cli/{index-c5d6tgbs.js → index-gpkbg9p4.js} +2 -2
- package/dist/cli/{index-j49ge0mg.js → index-wtyysb1n.js} +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/index.js +5948 -7991
- package/dist/lang/registry.d.ts +1 -1
- package/dist/lang/symbol-graph.d.ts +43 -0
- package/dist/tools/repo-graph/builder.d.ts +30 -1
- package/dist/tools/repo-graph/query.d.ts +5 -1
- package/dist/tools/repo-graph/types.d.ts +70 -1
- package/dist/tools/repo-graph.d.ts +2 -2
- package/package.json +2 -2
package/dist/lang/registry.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -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.
|
|
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.
|
|
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 .",
|