@wrongstack/tools 0.298.3 → 0.300.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 (42) hide show
  1. package/dist/audit.js +6 -2
  2. package/dist/bash.js +20 -2
  3. package/dist/builtin.js +1901 -327
  4. package/dist/codebase-index/background-indexer.d.ts +6 -1
  5. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +34 -0
  6. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +34 -0
  7. package/dist/codebase-index/import-extractor.d.ts +39 -0
  8. package/dist/codebase-index/index-service.d.ts +24 -2
  9. package/dist/codebase-index/index.d.ts +4 -2
  10. package/dist/codebase-index/index.js +1779 -256
  11. package/dist/codebase-index/languages.d.ts +24 -0
  12. package/dist/codebase-index/module-resolver.d.ts +78 -0
  13. package/dist/codebase-index/module-roots.d.ts +81 -0
  14. package/dist/codebase-index/parser-output.d.ts +29 -0
  15. package/dist/codebase-index/project-server.js +1556 -237
  16. package/dist/codebase-index/rs-parser.d.ts +22 -0
  17. package/dist/codebase-index/schema.d.ts +47 -1
  18. package/dist/codebase-index/worker-protocol.d.ts +14 -0
  19. package/dist/codebase-index/worker.js +1545 -238
  20. package/dist/codebase-index/writer-graph-helpers.d.ts +17 -5
  21. package/dist/codebase-index/writer-graph-reader.d.ts +24 -1
  22. package/dist/codebase-index/writer-ref-mapper.d.ts +3 -0
  23. package/dist/codebase-index/writer-schema.d.ts +15 -3
  24. package/dist/codebase-index/writer.d.ts +97 -4
  25. package/dist/exec.js +39 -2
  26. package/dist/format.js +6 -2
  27. package/dist/index.js +1901 -327
  28. package/dist/install.js +6 -2
  29. package/dist/json.js +51 -2
  30. package/dist/languages/index.js +6 -2
  31. package/dist/lint.js +6 -2
  32. package/dist/outdated.js +6 -2
  33. package/dist/pack.js +1899 -327
  34. package/dist/process-registry.d.ts +6 -0
  35. package/dist/process-registry.js +6 -2
  36. package/dist/ps-slash.js +10 -2
  37. package/dist/read.js +1551 -244
  38. package/dist/test.js +6 -2
  39. package/dist/tool-tier.js +1901 -327
  40. package/dist/typecheck.js +6 -2
  41. package/package.json +3 -3
  42. package/dist/codebase-index/refs-extractor.d.ts +0 -11
@@ -26,9 +26,10 @@
26
26
  * for the TUI status chip and the search/stats tools' gating.
27
27
  */
28
28
  import { type CircuitSnapshot } from './circuit-breaker.js';
29
+ import { type IncomingCallsResult, type OutgoingCallsResult } from './index-service.js';
29
30
  import { type ProjectIndexServerClientHealth, type ProjectIndexServerConnectionState, type ProjectIndexServerShutdownResult } from './project-server-client.js';
30
31
  import type { CodeMapGraph, IndexResult, IndexStats } from './schema.js';
31
- import type { FileGraphOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs, SymbolGraphOpArgs } from './worker-protocol.js';
32
+ import type { CallRefsOpArgs, FileGraphOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs, SymbolGraphOpArgs } from './worker-protocol.js';
32
33
  /** True once the first full-project index has completed (success or failure). */
33
34
  export declare function isIndexReady(): boolean;
34
35
  /**
@@ -112,6 +113,10 @@ export declare function packageGraphService(args: StatsOpArgs): Promise<CodeMapG
112
113
  export declare function fileGraphService(args: FileGraphOpArgs): Promise<CodeMapGraph>;
113
114
  /** Symbol dependency graph, served by the same per-project index process. */
114
115
  export declare function symbolGraphService(args: SymbolGraphOpArgs): Promise<CodeMapGraph>;
116
+ /** Incoming call sites for a named symbol (who calls/uses this symbol?). */
117
+ export declare function incomingCallsService(args: CallRefsOpArgs): Promise<IncomingCallsResult>;
118
+ /** Outgoing call sites for a named symbol (what does this symbol call/use?). */
119
+ export declare function outgoingCallsService(args: CallRefsOpArgs): Promise<OutgoingCallsResult>;
115
120
  /**
116
121
  * Stop this project's detached index server. Unlike
117
122
  * shutdownCodebaseIndexHost(), this intentionally affects every connected
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `codebase-incoming-calls` tool — find all callers/users of a symbol.
3
+ *
4
+ * Usage: codebase-incoming-calls({
5
+ * symbol: string, // function/method/type name to look up
6
+ * file?: string, // scope to one file when multiple symbols share a name
7
+ * limit?: number, // max results (default 50, max 200)
8
+ * })
9
+ *
10
+ * Returns: [{ symbol: { name, kind, file, line, signature }, callType, line }, ...]
11
+ *
12
+ * The query executes against the SQLite index's refs graph — it resolves the
13
+ * symbol name to IDs, then finds every ref edge pointing TO those IDs. The
14
+ * result carries the caller's full metadata so no second lookup is needed.
15
+ */
16
+ import type { Tool } from '@wrongstack/core/types';
17
+ import type { CallSite } from './schema.js';
18
+ export declare const codebaseIncomingCallsTool: Tool<IncomingCallsInput, IncomingCallsOutput>;
19
+ interface IncomingCallsInput {
20
+ symbol: string;
21
+ file?: string | undefined;
22
+ limit?: number | undefined;
23
+ }
24
+ interface IncomingCallsOutput {
25
+ symbol: string;
26
+ calls: CallSite[];
27
+ total: number;
28
+ /** Non-empty when the index blocked the query (not ready, indexing, failed). */
29
+ indexStatus?: string | undefined;
30
+ /** Advisory note when the symbol was not found in the index. */
31
+ note?: string | undefined;
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=codebase-incoming-calls-tool.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `codebase-outgoing-calls` tool — find all callees/dependencies of a symbol.
3
+ *
4
+ * Usage: codebase-outgoing-calls({
5
+ * symbol: string, // function/method/type name to look up
6
+ * file?: string, // scope to one file when multiple symbols share a name
7
+ * limit?: number, // max results (default 50, max 200)
8
+ * })
9
+ *
10
+ * Returns: [{ symbol: { name, kind, file, line, signature }, callType, line }, ...]
11
+ *
12
+ * The query executes against the SQLite index's refs graph — it resolves the
13
+ * symbol name to IDs, then finds every ref edge going FROM those IDs. The
14
+ * result carries the callee's full metadata so no second lookup is needed.
15
+ */
16
+ import type { Tool } from '@wrongstack/core/types';
17
+ import type { CallSite } from './schema.js';
18
+ export declare const codebaseOutgoingCallsTool: Tool<OutgoingCallsInput, OutgoingCallsOutput>;
19
+ interface OutgoingCallsInput {
20
+ symbol: string;
21
+ file?: string | undefined;
22
+ limit?: number | undefined;
23
+ }
24
+ interface OutgoingCallsOutput {
25
+ symbol: string;
26
+ calls: CallSite[];
27
+ total: number;
28
+ /** Non-empty when the index blocked the query (not ready, indexing, failed). */
29
+ indexStatus?: string | undefined;
30
+ /** Advisory note when the symbol was not found, or unresolved refs exist. */
31
+ note?: string | undefined;
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=codebase-outgoing-calls-tool.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Import extraction for languages without an AST parser.
3
+ *
4
+ * Deliberately imports only — no call or type references. An import statement
5
+ * has a rigid, line-anchored syntax that a regex reads correctly; a call site
6
+ * does not, and a regex "call graph" produces edges that look authoritative
7
+ * while being mostly wrong. Dependency edges are what the Code Atlas is built
8
+ * around, so extracting those well beats extracting everything badly.
9
+ *
10
+ * Languages with a real parser (TS/JS via the compiler API, Go and Python via
11
+ * their own `ast` modules) never reach this module.
12
+ */
13
+ import type { Ref, SymbolLang } from './schema.js';
14
+ /** Only the leading window is scanned, mirroring the generic symbol extractor. */
15
+ export declare const IMPORT_MAX_FILE_CHARS: number;
16
+ /** Upper bound on imports recorded per file. */
17
+ export declare const IMPORT_MAX_PER_FILE = 400;
18
+ /**
19
+ * The name a specifier refers to.
20
+ *
21
+ * Path-like and namespace-like specifiers need opposite treatment of the dot:
22
+ * in `engine/core.h` it introduces a file extension to strip, in
23
+ * `com.example.Helper` it is the segment separator. The presence of a path
24
+ * separator is what tells them apart.
25
+ */
26
+ export declare function lastSegment(specifier: string): string;
27
+ /** True when this language's imports are extracted here rather than by a parser. */
28
+ export declare function hasImportPatterns(lang: SymbolLang): boolean;
29
+ /**
30
+ * Extract `import` refs from source text. Never throws.
31
+ *
32
+ * Returned refs carry `fromId: 0`; the indexer rewrites it to the owning symbol.
33
+ */
34
+ export declare function extractImports(opts: {
35
+ content: string;
36
+ lang: SymbolLang;
37
+ maxImports?: number;
38
+ }): Ref[];
39
+ //# sourceMappingURL=import-extractor.d.ts.map
@@ -11,8 +11,8 @@
11
11
  * run on one event loop, so a pooled connection is both safe and substantially
12
12
  * cheaper than re-running schema/FTS drift checks for every edited file.
13
13
  */
14
- import type { CodeMapGraph, IndexResult, IndexStats } from './schema.js';
15
- import type { IndexOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs } from './worker-protocol.js';
14
+ import type { CallSite, CodeMapGraph, IndexResult, IndexStats } from './schema.js';
15
+ import type { CallRefsOpArgs, IndexOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs } from './worker-protocol.js';
16
16
  export interface ServiceHooks {
17
17
  signal?: AbortSignal | undefined;
18
18
  onProgress?: ((current: number, total: number) => void) | undefined;
@@ -33,4 +33,26 @@ export declare function fileGraphService(args: StatsOpArgs & {
33
33
  export declare function symbolGraphService(args: StatsOpArgs & {
34
34
  fileFilter: string;
35
35
  }): CodeMapGraph;
36
+ /** Result of an incoming calls query. */
37
+ export interface IncomingCallsResult {
38
+ calls: CallSite[];
39
+ symbolFound: boolean;
40
+ /** True when `file` was scoped but the name is ambiguous (other files define it too). */
41
+ ambiguous: boolean;
42
+ /** Total matching call sites before the limit was applied. */
43
+ totalMatches: number;
44
+ }
45
+ /** Result of an outgoing calls query. */
46
+ export interface OutgoingCallsResult {
47
+ calls: CallSite[];
48
+ symbolFound: boolean;
49
+ /** Number of refs whose target could not be resolved (to_id IS NULL). */
50
+ unresolvedCount: number;
51
+ /** Total matching call sites before the limit was applied. */
52
+ totalMatches: number;
53
+ }
54
+ /** Incoming call sites for a named symbol (who calls/uses this symbol?). */
55
+ export declare function incomingCallsService(args: CallRefsOpArgs): IncomingCallsResult;
56
+ /** Outgoing call sites for a named symbol (what does this symbol call/use?). */
57
+ export declare function outgoingCallsService(args: CallRefsOpArgs): OutgoingCallsResult;
36
58
  //# sourceMappingURL=index-service.d.ts.map
@@ -14,11 +14,13 @@
14
14
  * Ranking: Okapi BM25 / FTS5 (k1=1.5, b=0.75)
15
15
  */
16
16
  export { resolveProjectIndexDaemonAvailability, type ProjectIndexDaemonAvailability, } from './project-server-client.js';
17
- export { cancelPendingReindexes, checkCodebaseIndexServerHealth, codebaseIndexStats, enqueueReindex, ensureCodebaseIndexServer, fileGraphService, getIndexState, isIndexableFile, isIndexing, isIndexReady, onIndexStateChange, packageGraphService, runStartupIndex, searchCodebaseIndex, shutdownCodebaseIndexHost, shutdownCodebaseIndexServer, symbolGraphService, } from './background-indexer.js';
17
+ export { cancelPendingReindexes, checkCodebaseIndexServerHealth, codebaseIndexStats, enqueueReindex, ensureCodebaseIndexServer, fileGraphService, getIndexState, incomingCallsService, isIndexableFile, isIndexing, isIndexReady, onIndexStateChange, outgoingCallsService, packageGraphService, runStartupIndex, searchCodebaseIndex, shutdownCodebaseIndexHost, shutdownCodebaseIndexServer, symbolGraphService, } from './background-indexer.js';
18
18
  export { buildBm25Index, buildIndexableText, tokenise, } from './bm25.js';
19
19
  export type { CircuitSnapshot, CircuitState } from './circuit-breaker.js';
20
20
  export { CircuitOpenError, IndexCircuitBreaker, IndexTimeoutError, indexCircuitBreaker, resetIndexCircuitBreaker, } from './circuit-breaker.js';
21
21
  export { codebaseIndexTool } from './codebase-index-tool.js';
22
+ export { codebaseIncomingCallsTool } from './codebase-incoming-calls-tool.js';
23
+ export { codebaseOutgoingCallsTool } from './codebase-outgoing-calls-tool.js';
22
24
  export { codebaseSearchTool } from './codebase-search-tool.js';
23
25
  export { codebaseStatsTool } from './codebase-stats-tool.js';
24
26
  export { deadCodeScanTool, runDeadCodeScan } from './dead-code-scan.js';
@@ -28,7 +30,7 @@ export { detectLang, INDEXABLE_EXTENSIONS, isIndexablePath } from './languages.j
28
30
  export { internalKindToLspKind, lspKindToInternalKind, } from './lsp-kind.js';
29
31
  export type { ProjectIndexServerClientHealth, ProjectIndexServerConnectionState, ProjectIndexServerConnectionStatus, } from './project-server-client.js';
30
32
  export type { ProjectIndexServerActivity, ProjectIndexServerHealth, } from './project-server-protocol.js';
31
- export type { CodeMapGraph, FileMeta, FileSymbols, GraphEdge, GraphNode, IndexResult, IndexStats, SearchResult, Symbol, SymbolKind, SymbolLang, } from './schema.js';
33
+ export type { CallSite, CodeMapGraph, FileMeta, FileSymbols, GraphEdge, GraphNode, IndexResult, IndexStats, SearchResult, Symbol, SymbolKind, SymbolLang, } from './schema.js';
32
34
  export { SCHEMA_VERSION } from './schema.js';
33
35
  export { codebaseIndexDirOverride, IndexStore, resolveIndexDir } from './writer.js';
34
36
  //# sourceMappingURL=index.d.ts.map