@wrongstack/tools 0.305.0 → 0.306.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/_shell-pick.d.ts +4 -5
- package/dist/_util.d.ts +22 -5
- package/dist/audit.d.ts +0 -1
- package/dist/audit.js +135 -46
- package/dist/bash.js +61 -37
- package/dist/browser/index.js +29 -9
- package/dist/browser/types.d.ts +7 -1
- package/dist/builtin.js +1280 -728
- package/dist/codebase-index/codebase-search-tool.d.ts +5 -0
- package/dist/codebase-index/index.d.ts +1 -0
- package/dist/codebase-index/index.js +225 -153
- package/dist/codebase-index/project-server-endpoint.d.ts +1 -2
- package/dist/codebase-index/project-server.js +19 -20
- package/dist/diff.d.ts +5 -0
- package/dist/diff.js +78 -12
- package/dist/document.js +18 -6
- package/dist/edit.js +69 -16
- package/dist/exec.js +44 -22
- package/dist/fetch.js +13 -1
- package/dist/format.d.ts +4 -2
- package/dist/format.js +81 -31
- package/dist/glob.js +12 -4
- package/dist/grep.d.ts +2 -0
- package/dist/grep.js +15 -4
- package/dist/index.js +1357 -765
- package/dist/install.js +96 -37
- package/dist/kanban-tool-types.d.ts +6 -1
- package/dist/kanban.js +60 -0
- package/dist/languages/index.js +28 -13
- package/dist/lint.js +28 -13
- package/dist/logs.d.ts +0 -1
- package/dist/logs.js +44 -13
- package/dist/memory.d.ts +8 -0
- package/dist/memory.js +23 -3
- package/dist/mode.d.ts +1 -1
- package/dist/mode.js +3 -0
- package/dist/next-steps.d.ts +2 -3
- package/dist/next-steps.js +3 -3
- package/dist/outdated.d.ts +0 -3
- package/dist/outdated.js +89 -48
- package/dist/pack.js +1280 -728
- package/dist/plan.js +76 -3
- package/dist/process-registry.d.ts +8 -2
- package/dist/process-registry.js +28 -13
- package/dist/ps-slash.js +22 -12
- package/dist/read.js +10 -4
- package/dist/replace.d.ts +4 -0
- package/dist/replace.js +104 -7
- package/dist/search.d.ts +6 -0
- package/dist/search.js +47 -26
- package/dist/session-kanban.d.ts +25 -0
- package/dist/session-kanban.js +16 -0
- package/dist/skill.d.ts +6 -0
- package/dist/skill.js +9 -10
- package/dist/task.js +66 -2
- package/dist/test.js +28 -13
- package/dist/todo.js +64 -2
- package/dist/tool-icons.js +4 -2
- package/dist/tool-summary.d.ts +1 -1
- package/dist/tool-summary.js +76 -1
- package/dist/tool-tier.js +1280 -728
- package/dist/tree.js +9 -10
- package/dist/typecheck.d.ts +0 -2
- package/dist/typecheck.js +98 -31
- package/dist/write.js +58 -10
- package/package.json +4 -3
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { Tool } from '@wrongstack/core/types';
|
|
19
19
|
import type { SearchResult } from './schema.js';
|
|
20
|
+
/**
|
|
21
|
+
* Language ids the index understands. Single source for the `lang` enum here
|
|
22
|
+
* and the `langs` validation in codebase-index-tool.ts.
|
|
23
|
+
*/
|
|
24
|
+
export declare const INDEXABLE_LANG_IDS: readonly ['ts', 'tsx', 'js', 'jsx', 'go', 'py', 'rs', 'json', 'yaml'];
|
|
20
25
|
export declare const codebaseSearchTool: Tool<CodebaseSearchInput, CodebaseSearchOutput>;
|
|
21
26
|
interface CodebaseSearchInput {
|
|
22
27
|
query: string;
|
|
@@ -31,6 +31,7 @@ export { internalKindToLspKind, lspKindToInternalKind, } from './lsp-kind.js';
|
|
|
31
31
|
export type { ProjectIndexServerClientHealth, ProjectIndexServerConnectionState, ProjectIndexServerConnectionStatus, } from './project-server-client.js';
|
|
32
32
|
export type { ProjectIndexServerActivity, ProjectIndexServerHealth, } from './project-server-protocol.js';
|
|
33
33
|
export type { CallSite, CodeMapGraph, FileMeta, FileSymbols, GraphEdge, GraphNode, IndexResult, IndexStats, SearchResult, Symbol, SymbolKind, SymbolLang, } from './schema.js';
|
|
34
|
+
export { projectIndexServerEndpoint, projectIndexServerMetadataPath, } from './project-server-endpoint.js';
|
|
34
35
|
export { SCHEMA_VERSION } from './schema.js';
|
|
35
36
|
export { codebaseIndexDirOverride, IndexStore, resolveIndexDir } from './writer.js';
|
|
36
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2815,7 +2815,6 @@ import * as fs4 from "node:fs";
|
|
|
2815
2815
|
import * as os from "node:os";
|
|
2816
2816
|
import * as path5 from "node:path";
|
|
2817
2817
|
import { fileURLToPath } from "node:url";
|
|
2818
|
-
import { assertUnixSocketPathWithinLimit } from "@wrongstack/core/utils";
|
|
2819
2818
|
|
|
2820
2819
|
// src/codebase-index/writer.ts
|
|
2821
2820
|
import { expectDefined } from "@wrongstack/core/utils";
|
|
@@ -8492,6 +8491,160 @@ function ensureCodebaseIndexServer(options) {
|
|
|
8492
8491
|
}
|
|
8493
8492
|
|
|
8494
8493
|
// src/codebase-index/codebase-index-tool.ts
|
|
8494
|
+
import { ToolValidationError } from "@wrongstack/core/types";
|
|
8495
|
+
|
|
8496
|
+
// src/codebase-index/codebase-search-tool.ts
|
|
8497
|
+
import { toErrorMessage as toErrorMessage2 } from "@wrongstack/core/utils";
|
|
8498
|
+
var INDEXABLE_LANG_IDS = [
|
|
8499
|
+
"ts",
|
|
8500
|
+
"tsx",
|
|
8501
|
+
"js",
|
|
8502
|
+
"jsx",
|
|
8503
|
+
"go",
|
|
8504
|
+
"py",
|
|
8505
|
+
"rs",
|
|
8506
|
+
"json",
|
|
8507
|
+
"yaml"
|
|
8508
|
+
];
|
|
8509
|
+
var codebaseSearchTool = {
|
|
8510
|
+
name: "codebase-search",
|
|
8511
|
+
category: "Project",
|
|
8512
|
+
icon: "index",
|
|
8513
|
+
description: "Search code symbols using a fast SQLite+BM25 index, with optional LSP fallback. Prefer this before broad `tree`, `glob`, or `grep` exploration when finding code by name or concept. Use `grep` instead for exact text, regexes, unsupported content, or concrete usage sites. Set `preferLsp: true` for live precision when the LSP plugin is active (supersedes codebase-lsp-search).",
|
|
8514
|
+
usageHint: "FIRST CHOICE FOR INDEXABLE CODE UNDERSTANDING:\n\n- Call before broad `tree`, `glob`, or `grep` exploration when locating symbols, concepts, definitions, or candidate modules.\n- `kind` filter is very useful (e.g. only functions or only interfaces).\n- Combine with `file` filter to scope to a specific directory or module.\n- If `indexStatus` reports no persisted data, run `codebase-index` and retry.",
|
|
8515
|
+
permission: "auto",
|
|
8516
|
+
mutating: false,
|
|
8517
|
+
capabilities: ["fs.read"],
|
|
8518
|
+
// The index host has its own 30s read watchdog. Leave enough headroom for
|
|
8519
|
+
// worker teardown and structured timeout reporting.
|
|
8520
|
+
timeoutMs: 35e3,
|
|
8521
|
+
inputSchema: {
|
|
8522
|
+
type: "object",
|
|
8523
|
+
properties: {
|
|
8524
|
+
query: {
|
|
8525
|
+
type: "string",
|
|
8526
|
+
description: "Search query \u2014 searches symbol names, signatures, and doc comments"
|
|
8527
|
+
},
|
|
8528
|
+
kind: {
|
|
8529
|
+
type: "string",
|
|
8530
|
+
enum: [
|
|
8531
|
+
"class",
|
|
8532
|
+
"interface",
|
|
8533
|
+
"enum",
|
|
8534
|
+
"type",
|
|
8535
|
+
"function",
|
|
8536
|
+
"method",
|
|
8537
|
+
"var",
|
|
8538
|
+
"const",
|
|
8539
|
+
"let",
|
|
8540
|
+
"property",
|
|
8541
|
+
"parameter",
|
|
8542
|
+
"namespace",
|
|
8543
|
+
"object",
|
|
8544
|
+
"literal",
|
|
8545
|
+
"schema",
|
|
8546
|
+
"struct",
|
|
8547
|
+
"trait",
|
|
8548
|
+
"impl",
|
|
8549
|
+
"static",
|
|
8550
|
+
"mod"
|
|
8551
|
+
],
|
|
8552
|
+
description: "Filter by indexed symbol kind"
|
|
8553
|
+
},
|
|
8554
|
+
lang: {
|
|
8555
|
+
type: "string",
|
|
8556
|
+
enum: [...INDEXABLE_LANG_IDS],
|
|
8557
|
+
description: "Filter by indexed language"
|
|
8558
|
+
},
|
|
8559
|
+
lspKind: {
|
|
8560
|
+
type: "integer",
|
|
8561
|
+
description: "Filter by LSP SymbolKind number (e.g. 5=Class, 12=Function, 11=Interface, 10=Enum)"
|
|
8562
|
+
},
|
|
8563
|
+
file: {
|
|
8564
|
+
type: "string",
|
|
8565
|
+
description: "Filter to files matching this path substring"
|
|
8566
|
+
},
|
|
8567
|
+
limit: {
|
|
8568
|
+
type: "integer",
|
|
8569
|
+
description: "Maximum results to return (default 20, max 100)",
|
|
8570
|
+
minimum: 1,
|
|
8571
|
+
maximum: 100
|
|
8572
|
+
},
|
|
8573
|
+
preferLsp: {
|
|
8574
|
+
type: "boolean",
|
|
8575
|
+
description: "Prefer live LSP results over the index. Ignored unless the LSP plugin is active; when it is active and this is true, results come from live workspaceSymbol queries."
|
|
8576
|
+
}
|
|
8577
|
+
},
|
|
8578
|
+
required: ["query"]
|
|
8579
|
+
},
|
|
8580
|
+
async execute(input, ctx, execOpts) {
|
|
8581
|
+
const state = getIndexState();
|
|
8582
|
+
if (state.indexing && !state.ready) {
|
|
8583
|
+
return {
|
|
8584
|
+
results: [],
|
|
8585
|
+
total: 0,
|
|
8586
|
+
query: input.query,
|
|
8587
|
+
indexStatus: `Indexing in progress (${state.currentFile}/${state.totalFiles} files) \u2014 retry in a moment.`
|
|
8588
|
+
};
|
|
8589
|
+
}
|
|
8590
|
+
if (state.lastError) {
|
|
8591
|
+
const circuit = state.circuit;
|
|
8592
|
+
const retryHint = circuit.state === "open" ? `Indexing is paused (circuit open, retry in ${Math.ceil(circuit.cooldownRemainingMs / 1e3)}s); the user can run /codebase-reindex to retry now.` : "Try /codebase-reindex.";
|
|
8593
|
+
return {
|
|
8594
|
+
results: [],
|
|
8595
|
+
total: 0,
|
|
8596
|
+
query: input.query,
|
|
8597
|
+
indexStatus: `Index build failed: ${state.lastError}. ${retryHint}`
|
|
8598
|
+
};
|
|
8599
|
+
}
|
|
8600
|
+
const limit = Math.max(1, Math.min(Math.trunc(input.limit ?? 20), 100));
|
|
8601
|
+
let searched;
|
|
8602
|
+
try {
|
|
8603
|
+
searched = await searchCodebaseIndex(
|
|
8604
|
+
{
|
|
8605
|
+
projectRoot: ctx.projectRoot,
|
|
8606
|
+
indexDir: codebaseIndexDirOverride(ctx),
|
|
8607
|
+
query: input.query,
|
|
8608
|
+
kind: input.kind?.toLowerCase(),
|
|
8609
|
+
lang: input.lang?.toLowerCase(),
|
|
8610
|
+
file: input.file,
|
|
8611
|
+
lspKind: input.lspKind,
|
|
8612
|
+
limit
|
|
8613
|
+
},
|
|
8614
|
+
{ signal: execOpts?.signal }
|
|
8615
|
+
);
|
|
8616
|
+
} catch (err) {
|
|
8617
|
+
if (execOpts?.signal?.aborted) throw err;
|
|
8618
|
+
return {
|
|
8619
|
+
results: [],
|
|
8620
|
+
total: 0,
|
|
8621
|
+
query: input.query,
|
|
8622
|
+
indexStatus: `Index query failed: ${toErrorMessage2(err)}. Fall back to grep/glob for this lookup.`
|
|
8623
|
+
};
|
|
8624
|
+
}
|
|
8625
|
+
const { results, total } = searched;
|
|
8626
|
+
let hasPersistedIndex = state.ready || total > 0;
|
|
8627
|
+
if (!hasPersistedIndex) {
|
|
8628
|
+
try {
|
|
8629
|
+
const stats = await codebaseIndexStats(
|
|
8630
|
+
{ projectRoot: ctx.projectRoot, indexDir: codebaseIndexDirOverride(ctx) },
|
|
8631
|
+
{ signal: execOpts?.signal }
|
|
8632
|
+
);
|
|
8633
|
+
hasPersistedIndex = stats.totalFiles > 0 || stats.lastIndexed !== null;
|
|
8634
|
+
} catch {
|
|
8635
|
+
}
|
|
8636
|
+
}
|
|
8637
|
+
return {
|
|
8638
|
+
results,
|
|
8639
|
+
total,
|
|
8640
|
+
query: input.query,
|
|
8641
|
+
...hasPersistedIndex ? {} : { indexStatus: "No persisted index data found. Run codebase-index to build it." }
|
|
8642
|
+
};
|
|
8643
|
+
}
|
|
8644
|
+
};
|
|
8645
|
+
|
|
8646
|
+
// src/codebase-index/codebase-index-tool.ts
|
|
8647
|
+
var MAX_REPORTED_ERRORS = 20;
|
|
8495
8648
|
var codebaseIndexTool = {
|
|
8496
8649
|
name: "codebase-index",
|
|
8497
8650
|
category: "Project",
|
|
@@ -8517,12 +8670,23 @@ var codebaseIndexTool = {
|
|
|
8517
8670
|
},
|
|
8518
8671
|
langs: {
|
|
8519
8672
|
type: "array",
|
|
8520
|
-
items: { type: "string" },
|
|
8521
|
-
description:
|
|
8673
|
+
items: { type: "string", enum: [...INDEXABLE_LANG_IDS] },
|
|
8674
|
+
description: `Limit reindex to specific languages: ${INDEXABLE_LANG_IDS.join(", ")}`
|
|
8522
8675
|
}
|
|
8523
8676
|
}
|
|
8524
8677
|
},
|
|
8525
8678
|
async execute(input, ctx, execOpts) {
|
|
8679
|
+
if (input.langs) {
|
|
8680
|
+
const unknown = input.langs.filter(
|
|
8681
|
+
(lang) => !INDEXABLE_LANG_IDS.includes(lang)
|
|
8682
|
+
);
|
|
8683
|
+
if (unknown.length > 0) {
|
|
8684
|
+
throw new ToolValidationError({
|
|
8685
|
+
message: `codebase-index: unknown lang(s) ${unknown.map((l) => `"${l}"`).join(", ")}. Valid ids: ${INDEXABLE_LANG_IDS.join(", ")}.`,
|
|
8686
|
+
field: "langs"
|
|
8687
|
+
});
|
|
8688
|
+
}
|
|
8689
|
+
}
|
|
8526
8690
|
if (isIndexing()) {
|
|
8527
8691
|
return {
|
|
8528
8692
|
filesIndexed: 0,
|
|
@@ -8544,23 +8708,32 @@ var codebaseIndexTool = {
|
|
|
8544
8708
|
note: `Codebase indexing is paused after repeated failures (last: ${circuit.lastFailure ?? "unknown"}). Auto-retry possible in ${Math.ceil(circuit.cooldownRemainingMs / 1e3)}s; the user can run /codebase-reindex to retry immediately.`
|
|
8545
8709
|
};
|
|
8546
8710
|
}
|
|
8547
|
-
|
|
8711
|
+
const result = await runStartupIndex({
|
|
8548
8712
|
projectRoot: ctx.projectRoot,
|
|
8549
8713
|
force: input.force ?? false,
|
|
8550
8714
|
langs: input.langs,
|
|
8551
8715
|
indexDir: codebaseIndexDirOverride(ctx),
|
|
8552
8716
|
signal: execOpts?.signal
|
|
8553
8717
|
});
|
|
8718
|
+
if (result.errors.length > MAX_REPORTED_ERRORS) {
|
|
8719
|
+
const hidden = result.errors.length - MAX_REPORTED_ERRORS;
|
|
8720
|
+
return {
|
|
8721
|
+
...result,
|
|
8722
|
+
errors: [...result.errors.slice(0, MAX_REPORTED_ERRORS), `+${hidden} more`]
|
|
8723
|
+
};
|
|
8724
|
+
}
|
|
8725
|
+
return result;
|
|
8554
8726
|
}
|
|
8555
8727
|
};
|
|
8556
8728
|
|
|
8557
8729
|
// src/codebase-index/codebase-incoming-calls-tool.ts
|
|
8730
|
+
import { toErrorMessage as toErrorMessage3 } from "@wrongstack/core/utils";
|
|
8558
8731
|
var codebaseIncomingCallsTool = {
|
|
8559
8732
|
name: "codebase-incoming-calls",
|
|
8560
8733
|
category: "Project",
|
|
8561
8734
|
icon: "index",
|
|
8562
|
-
description: "Find all callers of a function, method, or symbol \u2014 who invokes or references it. Uses the codebase index ref graph for instant, exact results.
|
|
8563
|
-
usageHint: 'CALL THIS BEFORE REFACTORING OR CHANGING ANY FUNCTION:\n\n-
|
|
8735
|
+
description: "Find all callers of a function, method, or symbol \u2014 who invokes or references it. Uses the codebase index ref graph for instant, exact results. Prefer this over grep for change-impact checks when the index is available.",
|
|
8736
|
+
usageHint: 'CALL THIS BEFORE REFACTORING OR CHANGING ANY FUNCTION:\n\n- Prefer this over grep when the index is available; fall back to grep when the index is cold/unavailable or for dynamic dispatch the ref graph cannot see.\n- Call codebase-incoming-calls({ symbol: "funcName" }) before editing the symbol.\n- Returns exact files, line numbers, caller signatures, and call types in milliseconds.\n- Use `file` to disambiguate when multiple symbols share a name.\n- Combine with codebase-outgoing-calls to see what the symbol itself calls.\nIf the index is not built, run codebase-index first.',
|
|
8564
8737
|
permission: "auto",
|
|
8565
8738
|
mutating: false,
|
|
8566
8739
|
capabilities: ["fs.read"],
|
|
@@ -8612,16 +8785,27 @@ var codebaseIncomingCallsTool = {
|
|
|
8612
8785
|
}
|
|
8613
8786
|
const limit = Math.max(1, Math.min(Math.trunc(input.limit ?? 50), 200));
|
|
8614
8787
|
const transitive = input.transitive === true;
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8788
|
+
let serviced;
|
|
8789
|
+
try {
|
|
8790
|
+
serviced = await incomingCallsService2(
|
|
8791
|
+
{
|
|
8792
|
+
projectRoot: ctx.projectRoot,
|
|
8793
|
+
indexDir: codebaseIndexDirOverride(ctx),
|
|
8794
|
+
symbol: input.symbol,
|
|
8795
|
+
file: input.file,
|
|
8796
|
+
limit,
|
|
8797
|
+
transitive
|
|
8798
|
+
}
|
|
8799
|
+
);
|
|
8800
|
+
} catch (err) {
|
|
8801
|
+
return {
|
|
8619
8802
|
symbol: input.symbol,
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
}
|
|
8624
|
-
|
|
8803
|
+
calls: [],
|
|
8804
|
+
total: 0,
|
|
8805
|
+
indexStatus: `Index query failed: ${toErrorMessage3(err)}. Fall back to grep for this lookup.`
|
|
8806
|
+
};
|
|
8807
|
+
}
|
|
8808
|
+
const { calls, symbolFound, ambiguous, totalMatches } = serviced;
|
|
8625
8809
|
if (!symbolFound) {
|
|
8626
8810
|
let hasPersistedIndex = state.ready;
|
|
8627
8811
|
if (!hasPersistedIndex) {
|
|
@@ -8666,12 +8850,13 @@ var codebaseIncomingCallsTool = {
|
|
|
8666
8850
|
};
|
|
8667
8851
|
|
|
8668
8852
|
// src/codebase-index/codebase-outgoing-calls-tool.ts
|
|
8853
|
+
import { toErrorMessage as toErrorMessage4 } from "@wrongstack/core/utils";
|
|
8669
8854
|
var codebaseOutgoingCallsTool = {
|
|
8670
8855
|
name: "codebase-outgoing-calls",
|
|
8671
8856
|
category: "Project",
|
|
8672
8857
|
icon: "index",
|
|
8673
8858
|
description: "Find all functions/methods/symbols that a given symbol calls or depends on \u2014 its callees. Uses the codebase index ref graph for instant, exact results. Use this to understand a function's dependencies before modifying it.",
|
|
8674
|
-
usageHint: 'USE THIS TO UNDERSTAND A FUNCTION\'S DEPENDENCIES:\n\n- Call codebase-outgoing-calls({ symbol: "funcName" }) to see everything it calls.\n- Returns exact files, line numbers, callee signatures, and call types in milliseconds.\n- Use `file` to disambiguate when multiple symbols share a name.\n- Pair with codebase-incoming-calls for a complete impact picture: incoming = who calls you, outgoing = what you call.\nIf the index is not built, run codebase-index first.',
|
|
8859
|
+
usageHint: 'USE THIS TO UNDERSTAND A FUNCTION\'S DEPENDENCIES:\n\n- Prefer this over grep when the index is available; fall back to grep when the index is cold/unavailable or for dynamic dispatch the ref graph cannot see.\n- Call codebase-outgoing-calls({ symbol: "funcName" }) to see everything it calls.\n- Returns exact files, line numbers, callee signatures, and call types in milliseconds.\n- Use `file` to disambiguate when multiple symbols share a name.\n- Pair with codebase-incoming-calls for a complete impact picture: incoming = who calls you, outgoing = what you call.\nIf the index is not built, run codebase-index first.',
|
|
8675
8860
|
permission: "auto",
|
|
8676
8861
|
mutating: false,
|
|
8677
8862
|
capabilities: ["fs.read"],
|
|
@@ -8723,16 +8908,27 @@ var codebaseOutgoingCallsTool = {
|
|
|
8723
8908
|
}
|
|
8724
8909
|
const limit = Math.max(1, Math.min(Math.trunc(input.limit ?? 50), 200));
|
|
8725
8910
|
const transitive = input.transitive === true;
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8911
|
+
let serviced;
|
|
8912
|
+
try {
|
|
8913
|
+
serviced = await outgoingCallsService2(
|
|
8914
|
+
{
|
|
8915
|
+
projectRoot: ctx.projectRoot,
|
|
8916
|
+
indexDir: codebaseIndexDirOverride(ctx),
|
|
8917
|
+
symbol: input.symbol,
|
|
8918
|
+
file: input.file,
|
|
8919
|
+
limit,
|
|
8920
|
+
transitive
|
|
8921
|
+
}
|
|
8922
|
+
);
|
|
8923
|
+
} catch (err) {
|
|
8924
|
+
return {
|
|
8730
8925
|
symbol: input.symbol,
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
}
|
|
8735
|
-
|
|
8926
|
+
calls: [],
|
|
8927
|
+
total: 0,
|
|
8928
|
+
indexStatus: `Index query failed: ${toErrorMessage4(err)}. Fall back to grep for this lookup.`
|
|
8929
|
+
};
|
|
8930
|
+
}
|
|
8931
|
+
const { calls, symbolFound, unresolvedCount, totalMatches } = serviced;
|
|
8736
8932
|
if (!symbolFound) {
|
|
8737
8933
|
let hasPersistedIndex = state.ready;
|
|
8738
8934
|
if (!hasPersistedIndex) {
|
|
@@ -8776,132 +8972,6 @@ var codebaseOutgoingCallsTool = {
|
|
|
8776
8972
|
}
|
|
8777
8973
|
};
|
|
8778
8974
|
|
|
8779
|
-
// src/codebase-index/codebase-search-tool.ts
|
|
8780
|
-
var codebaseSearchTool = {
|
|
8781
|
-
name: "codebase-search",
|
|
8782
|
-
category: "Project",
|
|
8783
|
-
icon: "index",
|
|
8784
|
-
description: "Search code symbols using a fast SQLite+BM25 index, with optional LSP fallback. Prefer this before broad `tree`, `glob`, or `grep` exploration when finding code by name or concept. Set `preferLsp: true` for live precision when the LSP plugin is active (supersedes codebase-lsp-search).",
|
|
8785
|
-
usageHint: "FIRST CHOICE FOR INDEXABLE CODE UNDERSTANDING:\n\n- Call before broad `tree`, `glob`, or `grep` exploration when locating symbols, concepts, definitions, or candidate modules.\n- `kind` filter is very useful (e.g. only functions or only interfaces).\n- Combine with `file` filter to scope to a specific directory or module.\n- If `indexStatus` reports no persisted data, run `codebase-index` and retry.\nUse `grep` afterwards for exact text, regexes, unsupported content, or concrete usage sites.",
|
|
8786
|
-
permission: "auto",
|
|
8787
|
-
mutating: false,
|
|
8788
|
-
capabilities: ["fs.read"],
|
|
8789
|
-
// The index host has its own 30s read watchdog. Leave enough headroom for
|
|
8790
|
-
// worker teardown and structured timeout reporting.
|
|
8791
|
-
timeoutMs: 35e3,
|
|
8792
|
-
inputSchema: {
|
|
8793
|
-
type: "object",
|
|
8794
|
-
properties: {
|
|
8795
|
-
query: {
|
|
8796
|
-
type: "string",
|
|
8797
|
-
description: "Search query \u2014 searches symbol names, signatures, and doc comments"
|
|
8798
|
-
},
|
|
8799
|
-
kind: {
|
|
8800
|
-
type: "string",
|
|
8801
|
-
enum: [
|
|
8802
|
-
"class",
|
|
8803
|
-
"interface",
|
|
8804
|
-
"enum",
|
|
8805
|
-
"type",
|
|
8806
|
-
"function",
|
|
8807
|
-
"method",
|
|
8808
|
-
"var",
|
|
8809
|
-
"const",
|
|
8810
|
-
"let",
|
|
8811
|
-
"property",
|
|
8812
|
-
"parameter",
|
|
8813
|
-
"namespace",
|
|
8814
|
-
"object",
|
|
8815
|
-
"literal",
|
|
8816
|
-
"schema",
|
|
8817
|
-
"struct",
|
|
8818
|
-
"trait",
|
|
8819
|
-
"impl",
|
|
8820
|
-
"static",
|
|
8821
|
-
"mod"
|
|
8822
|
-
],
|
|
8823
|
-
description: "Filter by indexed symbol kind"
|
|
8824
|
-
},
|
|
8825
|
-
lang: {
|
|
8826
|
-
type: "string",
|
|
8827
|
-
enum: ["ts", "tsx", "js", "jsx", "go", "py", "rs", "json", "yaml"],
|
|
8828
|
-
description: "Filter by indexed language"
|
|
8829
|
-
},
|
|
8830
|
-
lspKind: {
|
|
8831
|
-
type: "integer",
|
|
8832
|
-
description: "Filter by LSP SymbolKind number (e.g. 5=Class, 12=Function, 11=Interface, 10=Enum)"
|
|
8833
|
-
},
|
|
8834
|
-
file: {
|
|
8835
|
-
type: "string",
|
|
8836
|
-
description: "Filter to files matching this path substring"
|
|
8837
|
-
},
|
|
8838
|
-
limit: {
|
|
8839
|
-
type: "integer",
|
|
8840
|
-
description: "Maximum results to return (default 20, max 100)",
|
|
8841
|
-
minimum: 1,
|
|
8842
|
-
maximum: 100
|
|
8843
|
-
},
|
|
8844
|
-
preferLsp: {
|
|
8845
|
-
type: "boolean",
|
|
8846
|
-
description: "Prefer live LSP results over the index. Index-only when the LSP plugin is not active. When the LSP plugin is active and this is true, results come from live workspaceSymbol queries."
|
|
8847
|
-
}
|
|
8848
|
-
},
|
|
8849
|
-
required: ["query"]
|
|
8850
|
-
},
|
|
8851
|
-
async execute(input, ctx, execOpts) {
|
|
8852
|
-
const state = getIndexState();
|
|
8853
|
-
if (state.indexing && !state.ready) {
|
|
8854
|
-
return {
|
|
8855
|
-
results: [],
|
|
8856
|
-
total: 0,
|
|
8857
|
-
query: input.query,
|
|
8858
|
-
indexStatus: `Indexing in progress (${state.currentFile}/${state.totalFiles} files) \u2014 retry in a moment.`
|
|
8859
|
-
};
|
|
8860
|
-
}
|
|
8861
|
-
if (state.lastError) {
|
|
8862
|
-
const circuit = state.circuit;
|
|
8863
|
-
const retryHint = circuit.state === "open" ? `Indexing is paused (circuit open, retry in ${Math.ceil(circuit.cooldownRemainingMs / 1e3)}s); the user can run /codebase-reindex to retry now.` : "Try /codebase-reindex.";
|
|
8864
|
-
return {
|
|
8865
|
-
results: [],
|
|
8866
|
-
total: 0,
|
|
8867
|
-
query: input.query,
|
|
8868
|
-
indexStatus: `Index build failed: ${state.lastError}. ${retryHint}`
|
|
8869
|
-
};
|
|
8870
|
-
}
|
|
8871
|
-
const limit = Math.max(1, Math.min(Math.trunc(input.limit ?? 20), 100));
|
|
8872
|
-
const { results, total } = await searchCodebaseIndex(
|
|
8873
|
-
{
|
|
8874
|
-
projectRoot: ctx.projectRoot,
|
|
8875
|
-
indexDir: codebaseIndexDirOverride(ctx),
|
|
8876
|
-
query: input.query,
|
|
8877
|
-
kind: input.kind?.toLowerCase(),
|
|
8878
|
-
lang: input.lang?.toLowerCase(),
|
|
8879
|
-
file: input.file,
|
|
8880
|
-
lspKind: input.lspKind,
|
|
8881
|
-
limit
|
|
8882
|
-
},
|
|
8883
|
-
{ signal: execOpts?.signal }
|
|
8884
|
-
);
|
|
8885
|
-
let hasPersistedIndex = state.ready || total > 0;
|
|
8886
|
-
if (!hasPersistedIndex) {
|
|
8887
|
-
try {
|
|
8888
|
-
const stats = await codebaseIndexStats(
|
|
8889
|
-
{ projectRoot: ctx.projectRoot, indexDir: codebaseIndexDirOverride(ctx) },
|
|
8890
|
-
{ signal: execOpts?.signal }
|
|
8891
|
-
);
|
|
8892
|
-
hasPersistedIndex = stats.totalFiles > 0 || stats.lastIndexed !== null;
|
|
8893
|
-
} catch {
|
|
8894
|
-
}
|
|
8895
|
-
}
|
|
8896
|
-
return {
|
|
8897
|
-
results,
|
|
8898
|
-
total,
|
|
8899
|
-
query: input.query,
|
|
8900
|
-
...hasPersistedIndex ? {} : { indexStatus: "No persisted index data found. Run codebase-index to build it." }
|
|
8901
|
-
};
|
|
8902
|
-
}
|
|
8903
|
-
};
|
|
8904
|
-
|
|
8905
8975
|
// src/codebase-index/codebase-stats-tool.ts
|
|
8906
8976
|
var codebaseStatsTool = {
|
|
8907
8977
|
name: "codebase-stats",
|
|
@@ -8995,9 +9065,9 @@ import * as path14 from "node:path";
|
|
|
8995
9065
|
var deadCodeScanTool = {
|
|
8996
9066
|
name: "dead-code-scan",
|
|
8997
9067
|
category: "Project",
|
|
8998
|
-
icon: "
|
|
9068
|
+
icon: "index",
|
|
8999
9069
|
description: "Scan TypeScript/JavaScript source files for exported symbols that appear unused anywhere in the project. Uses the codebase-index reference graph (import/call/type-ref edges) to compute transitive reachability from package.json entry points. Requires a built codebase-index (run `codebase-index` first if you get no results).",
|
|
9000
|
-
usageHint:
|
|
9070
|
+
usageHint: "SCANS ALL INDEXED FILES UNDER THE PROJECT ROOT:\n\n- `projectRoot` defaults to the current project root; `indexDir` overrides the resolved index location.\n- `entryPoints` is an array of file paths that AUGMENTS the auto-discovered entry points (package.json bin/main/exports/types plus conventional src/index.ts-style files) \u2014 it does not replace them.\n\nThe scan runs against the existing index; results are best-effort (dynamic imports, external consumers, and config-driven registration are invisible).",
|
|
9001
9071
|
permission: "auto",
|
|
9002
9072
|
mutating: false,
|
|
9003
9073
|
capabilities: ["fs.read"],
|
|
@@ -9489,6 +9559,8 @@ export {
|
|
|
9489
9559
|
onIndexStateChange,
|
|
9490
9560
|
outgoingCallsService2 as outgoingCallsService,
|
|
9491
9561
|
packageGraphService2 as packageGraphService,
|
|
9562
|
+
projectIndexServerEndpoint,
|
|
9563
|
+
projectIndexServerMetadataPath,
|
|
9492
9564
|
resetIndexCircuitBreaker,
|
|
9493
9565
|
resolveIndexDir,
|
|
9494
9566
|
resolveProjectIndexDaemonAvailability,
|
|
@@ -3,7 +3,7 @@ export declare const PROJECT_INDEX_SERVER_METADATA_FILE = "server.json";
|
|
|
3
3
|
/**
|
|
4
4
|
* Short directory name that owns the per-project Unix socket on Linux.
|
|
5
5
|
*
|
|
6
|
-
* The directory is created `0o700` by `
|
|
6
|
+
* The directory is created `0o700` by `bindProjectEndpoint`: on
|
|
7
7
|
* multi-user Linux `/tmp` the kernel's sticky bit otherwise lets a local
|
|
8
8
|
* attacker pre-bind a predictable socket name (project paths are guessable
|
|
9
9
|
* via the public `buildId` handshake), hijacking clients whose `bind()` hits
|
|
@@ -48,5 +48,4 @@ export declare function projectIndexServerKey(projectRoot: string, indexDir?: st
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function projectIndexServerEndpoint(projectRoot: string, indexDir?: string): string;
|
|
50
50
|
export declare function projectIndexServerMetadataPath(projectRoot: string, indexDir?: string): string;
|
|
51
|
-
export declare function ensureProjectIndexSocketDirectory(endpoint: string): void;
|
|
52
51
|
//# sourceMappingURL=project-server-endpoint.d.ts.map
|
|
@@ -2713,6 +2713,7 @@ import {
|
|
|
2713
2713
|
useDaemonPerfDefaults,
|
|
2714
2714
|
watchProjectTree
|
|
2715
2715
|
} from "@wrongstack/core/utils";
|
|
2716
|
+
import { bindProjectEndpoint } from "@wrongstack/persistence";
|
|
2716
2717
|
|
|
2717
2718
|
// src/codebase-index/indexer.ts
|
|
2718
2719
|
import { expectDefined as expectDefined5 } from "@wrongstack/core/utils";
|
|
@@ -7218,7 +7219,6 @@ import * as fs10 from "node:fs";
|
|
|
7218
7219
|
import * as os3 from "node:os";
|
|
7219
7220
|
import * as path13 from "node:path";
|
|
7220
7221
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7221
|
-
import { assertUnixSocketPathWithinLimit } from "@wrongstack/core/utils";
|
|
7222
7222
|
var PROJECT_INDEX_SERVER_PROTOCOL_VERSION = 1;
|
|
7223
7223
|
var PROJECT_INDEX_SERVER_METADATA_FILE = "server.json";
|
|
7224
7224
|
var PROJECT_INDEX_SERVER_SOCKET_DIR = `wsci-v${PROJECT_INDEX_SERVER_PROTOCOL_VERSION}`;
|
|
@@ -7260,12 +7260,6 @@ function projectIndexServerMetadataPath(projectRoot2, indexDir2) {
|
|
|
7260
7260
|
PROJECT_INDEX_SERVER_METADATA_FILE
|
|
7261
7261
|
);
|
|
7262
7262
|
}
|
|
7263
|
-
function ensureProjectIndexSocketDirectory(endpoint2) {
|
|
7264
|
-
if (process.platform !== "win32") {
|
|
7265
|
-
assertUnixSocketPathWithinLimit(endpoint2, "codebase-index");
|
|
7266
|
-
fs10.mkdirSync(path13.dirname(endpoint2), { recursive: true, mode: 448 });
|
|
7267
|
-
}
|
|
7268
|
-
}
|
|
7269
7263
|
|
|
7270
7264
|
// src/codebase-index/project-server-protocol.ts
|
|
7271
7265
|
var PROJECT_INDEX_SERVER_MAX_FRAME_CHARS = 64 * 1024 * 1024;
|
|
@@ -7877,27 +7871,32 @@ async function stop(_reason) {
|
|
|
7877
7871
|
}
|
|
7878
7872
|
await stopMemoryWatchdog();
|
|
7879
7873
|
}
|
|
7880
|
-
|
|
7881
|
-
server
|
|
7882
|
-
if (
|
|
7874
|
+
void (async () => {
|
|
7875
|
+
const bind = await bindProjectEndpoint({ server, endpoint, service: "codebase-index" });
|
|
7876
|
+
if (bind.outcome === "already-owned") {
|
|
7883
7877
|
process.exitCode = 0;
|
|
7884
7878
|
return;
|
|
7885
7879
|
}
|
|
7886
|
-
|
|
7880
|
+
if (bind.outcome === "failed") {
|
|
7881
|
+
process.stderr.write(`codebase-index server failed: ${bind.error.message}
|
|
7882
|
+
`);
|
|
7883
|
+
process.exitCode = 1;
|
|
7884
|
+
return;
|
|
7885
|
+
}
|
|
7886
|
+
if (bind.reclaimedStaleEndpoint) {
|
|
7887
|
+
process.stderr.write(`codebase-index server reclaimed stale endpoint ${endpoint}
|
|
7887
7888
|
`);
|
|
7888
|
-
process.exitCode = 1;
|
|
7889
|
-
});
|
|
7890
|
-
server.listen(endpoint, () => {
|
|
7891
|
-
if (process.platform !== "win32") {
|
|
7892
|
-
try {
|
|
7893
|
-
fs11.chmodSync(endpoint, 384);
|
|
7894
|
-
} catch {
|
|
7895
|
-
}
|
|
7896
7889
|
}
|
|
7890
|
+
server.on("error", (error) => {
|
|
7891
|
+
if (stopping) return;
|
|
7892
|
+
process.stderr.write(`codebase-index server error: ${error.message}
|
|
7893
|
+
`);
|
|
7894
|
+
process.exitCode = 1;
|
|
7895
|
+
});
|
|
7897
7896
|
writeMetadata();
|
|
7898
7897
|
markMetadataWritten?.();
|
|
7899
7898
|
scheduleIdleStop();
|
|
7900
|
-
});
|
|
7899
|
+
})();
|
|
7901
7900
|
process.once("SIGINT", () => void stop("SIGINT"));
|
|
7902
7901
|
process.once("SIGTERM", () => void stop("SIGTERM"));
|
|
7903
7902
|
//# sourceMappingURL=project-server.js.map
|
package/dist/diff.d.ts
CHANGED
|
@@ -12,7 +12,12 @@ interface DiffOutput {
|
|
|
12
12
|
diff: string;
|
|
13
13
|
files: string[];
|
|
14
14
|
truncated: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The format actually produced: 'unified' or 'stat' on the git path,
|
|
17
|
+
* 'dump' on the files-only line-numbered dump path.
|
|
18
|
+
*/
|
|
15
19
|
mode: string;
|
|
20
|
+
note?: string | undefined;
|
|
16
21
|
}
|
|
17
22
|
export declare const diffTool: Tool<DiffInput, DiffOutput>;
|
|
18
23
|
export {};
|