aws-runtime-bridge 1.9.51 → 1.9.55
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/package/acode/README.md +26 -0
- package/package/acode/dist/built-in-file-tools.d.ts +11 -0
- package/package/acode/dist/built-in-file-tools.d.ts.map +1 -1
- package/package/acode/dist/built-in-file-tools.js +4 -2
- package/package/acode/dist/built-in-symbols-tool.d.ts +7 -0
- package/package/acode/dist/built-in-symbols-tool.d.ts.map +1 -0
- package/package/acode/dist/built-in-symbols-tool.js +117 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-bash.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-c-sharp.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-c.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-cpp.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-go.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-java.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-javascript.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-jsx.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-lua.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-php.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-python.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-ruby.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-rust.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-tsx.wasm +0 -0
- package/package/acode/dist/grammars/grammars/tree-sitter-typescript.wasm +0 -0
- package/package/acode/dist/index.d.ts +7 -0
- package/package/acode/dist/index.d.ts.map +1 -1
- package/package/acode/dist/index.js +8 -0
- package/package/acode/dist/parsers/ast-cache.d.ts +33 -0
- package/package/acode/dist/parsers/ast-cache.d.ts.map +1 -0
- package/package/acode/dist/parsers/ast-cache.js +76 -0
- package/package/acode/dist/parsers/language-detector.d.ts +7 -0
- package/package/acode/dist/parsers/language-detector.d.ts.map +1 -0
- package/package/acode/dist/parsers/language-detector.js +44 -0
- package/package/acode/dist/parsers/language-queries.d.ts +5 -0
- package/package/acode/dist/parsers/language-queries.d.ts.map +1 -0
- package/package/acode/dist/parsers/language-queries.js +640 -0
- package/package/acode/dist/parsers/symbol-extractor.d.ts +8 -0
- package/package/acode/dist/parsers/symbol-extractor.d.ts.map +1 -0
- package/package/acode/dist/parsers/symbol-extractor.js +164 -0
- package/package/acode/dist/parsers/tree-sitter-loader.d.ts +18 -0
- package/package/acode/dist/parsers/tree-sitter-loader.d.ts.map +1 -0
- package/package/acode/dist/parsers/tree-sitter-loader.js +64 -0
- package/package/acode/dist/parsers/types.d.ts +61 -0
- package/package/acode/dist/parsers/types.d.ts.map +1 -0
- package/package/acode/dist/parsers/types.js +7 -0
- package/package/acode/dist/runtime.d.ts.map +1 -1
- package/package/acode/dist/runtime.js +75 -20
- package/package/acode/dist/sub-agent-manager.d.ts +16 -0
- package/package/acode/dist/sub-agent-manager.d.ts.map +1 -1
- package/package/acode/dist/sub-agent-manager.js +196 -15
- package/package/acode/dist/types.d.ts +1 -1
- package/package/acode/dist/types.d.ts.map +1 -1
- package/package/acode/package.json +4 -1
- package/package/aws-client-agent-mcp/dist/agent-client.test.js +64 -50
- package/package/aws-client-agent-mcp/dist/agent-client.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +3 -12
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.js +192 -115
- package/package/aws-client-agent-mcp/dist/mcp-server.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js +38 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-store.js +7 -7
- package/package/aws-client-agent-mcp/dist/memory-store.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-store.test.js +22 -0
- package/package/aws-client-agent-mcp/dist/memory-store.test.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/memory-tools.js +3 -2
- package/package/aws-client-agent-mcp/dist/memory-tools.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts +24 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts.map +1 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.js +61 -2
- package/package/aws-client-agent-mcp/dist/websocket-client.js.map +1 -1
- package/package/aws-client-agent-mcp/dist/websocket-client.test.js +54 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.test.js.map +1 -1
- package/package.json +5 -3
package/package/acode/README.md
CHANGED
|
@@ -86,3 +86,29 @@ prompt or tool call. Hook errors are reported as runtime `error` events and are
|
|
|
86
86
|
otherwise fail-open so extension failures do not crash the session. The
|
|
87
87
|
`modify` decision value is reserved for a future prompt/tool-argument mutation
|
|
88
88
|
API and is not applied by the current runtime.
|
|
89
|
+
|
|
90
|
+
## Code symbols (tree-sitter)
|
|
91
|
+
|
|
92
|
+
ACode bundles tree-sitter for AST-based code analysis, exposed via the
|
|
93
|
+
`symbols` built-in tool. Supports 13 languages: TypeScript (incl. TSX),
|
|
94
|
+
JavaScript (incl. JSX), Python, Go, Rust, Java, C, C++, C#, Ruby, PHP, Lua,
|
|
95
|
+
Bash.
|
|
96
|
+
|
|
97
|
+
Three modes:
|
|
98
|
+
- `definitions` — find symbol declarations (functions, classes, methods, etc.)
|
|
99
|
+
- `references` — find symbol usages within a single file
|
|
100
|
+
- `outline` — return the full symbol structure of a file
|
|
101
|
+
|
|
102
|
+
ASTs are cached in-memory (LRU, 100 files) keyed by path + mtime + size.
|
|
103
|
+
Grammar WASM files are lazy-loaded on first use of each language.
|
|
104
|
+
|
|
105
|
+
Grammar WASM files live in `grammars/`. To refresh them after a
|
|
106
|
+
`web-tree-sitter` upgrade:
|
|
107
|
+
|
|
108
|
+
node scripts/fetch-grammars.mjs
|
|
109
|
+
|
|
110
|
+
To add a new language:
|
|
111
|
+
1. Add an entry to `scripts/fetch-grammars.mjs`
|
|
112
|
+
2. Run the script
|
|
113
|
+
3. Add extension mapping in `parsers/language-detector.ts`
|
|
114
|
+
4. Add query patterns in `parsers/language-queries.ts`
|
|
@@ -26,5 +26,16 @@ export interface AgentFileChangeRecord {
|
|
|
26
26
|
afterContent: string | null;
|
|
27
27
|
}
|
|
28
28
|
export type OnAgentFileChange = (record: AgentFileChangeRecord) => void | Promise<void>;
|
|
29
|
+
export interface ResolvedWorkspaceTarget {
|
|
30
|
+
workspaceRoot: string;
|
|
31
|
+
requestedPath: string;
|
|
32
|
+
targetPath: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function ensureInsideWorkspace(workspaceRoot: string, targetPath: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* 解析内置文件工具目标路径。
|
|
37
|
+
* 主流程:同时校验请求路径与 realpath 工作区边界,防止绝对路径、`..` 与符号链接目录穿透。
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveWorkspaceTarget(workingDirectory: string, rawFilePath: string): Promise<ResolvedWorkspaceTarget>;
|
|
29
40
|
export declare function createBuiltInFileTools(workingDirectory: string, agentId?: string, onFileChange?: OnAgentFileChange): ACodeBuiltInTool[];
|
|
30
41
|
//# sourceMappingURL=built-in-file-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-in-file-tools.d.ts","sourceRoot":"","sources":["../src/built-in-file-tools.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"built-in-file-tools.d.ts","sourceRoot":"","sources":["../src/built-in-file-tools.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,kCAAkC,CAAC;AAkC1C,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACjC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,CACL,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,gCAAgC,GACzC,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAExF,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAkHD,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,CAOR;AA+DD;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,uBAAuB,CAAC,CAgClC;AAw8BD,wBAAgB,sBAAsB,CACpC,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,iBAAiB,GAC/B,gBAAgB,EAAE,CAWpB"}
|
|
@@ -3,6 +3,7 @@ import { promises as fs, createReadStream } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import readline from "node:readline";
|
|
5
5
|
import { runShellCommand, } from "./builtins/shellCommandRunner.js";
|
|
6
|
+
import { symbolsTool } from "./built-in-symbols-tool.js";
|
|
6
7
|
// ── read_file pagination & truncation constants ──────────────────────────────
|
|
7
8
|
const DEFAULT_READ_LIMIT = 2000;
|
|
8
9
|
const MAX_LINE_LENGTH = 2000;
|
|
@@ -123,7 +124,7 @@ async function isBinaryFile(filePath) {
|
|
|
123
124
|
await handle.close();
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
|
-
function ensureInsideWorkspace(workspaceRoot, targetPath) {
|
|
127
|
+
export function ensureInsideWorkspace(workspaceRoot, targetPath) {
|
|
127
128
|
const resolvedTargetPath = path.resolve(targetPath);
|
|
128
129
|
const relativePath = path.relative(workspaceRoot, resolvedTargetPath);
|
|
129
130
|
if (relativePath.startsWith("..") || path.isAbsolute(relativePath)) {
|
|
@@ -179,7 +180,7 @@ async function ensureWritableTarget(workspaceRoot, targetPath) {
|
|
|
179
180
|
* 解析内置文件工具目标路径。
|
|
180
181
|
* 主流程:同时校验请求路径与 realpath 工作区边界,防止绝对路径、`..` 与符号链接目录穿透。
|
|
181
182
|
*/
|
|
182
|
-
async function resolveWorkspaceTarget(workingDirectory, rawFilePath) {
|
|
183
|
+
export async function resolveWorkspaceTarget(workingDirectory, rawFilePath) {
|
|
183
184
|
const requestedRoot = path.resolve(String(workingDirectory || "").trim());
|
|
184
185
|
const workspaceRoot = await fs.realpath(requestedRoot);
|
|
185
186
|
const workspaceStat = await fs.stat(workspaceRoot);
|
|
@@ -960,5 +961,6 @@ export function createBuiltInFileTools(workingDirectory, agentId, onFileChange)
|
|
|
960
961
|
deleteFileTool(workingDirectory, onFileChange),
|
|
961
962
|
grepTool(workingDirectory),
|
|
962
963
|
bashTool(workingDirectory, resolvedAgentId),
|
|
964
|
+
symbolsTool(workingDirectory),
|
|
963
965
|
];
|
|
964
966
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ACodeBuiltInTool } from "./built-in-file-tools.js";
|
|
2
|
+
/**
|
|
3
|
+
* symbols 工具入口:参数校验 → 调 extractor → 标准化输出。
|
|
4
|
+
* 不直接操作 tree-sitter API,所有解析逻辑在 parsers/ 里。
|
|
5
|
+
*/
|
|
6
|
+
export declare function symbolsTool(workingDirectory: string): ACodeBuiltInTool;
|
|
7
|
+
//# sourceMappingURL=built-in-symbols-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in-symbols-tool.d.ts","sourceRoot":"","sources":["../src/built-in-symbols-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,0BAA0B,CAAC;AAkB7E;;;GAGG;AACH,wBAAgB,WAAW,CAAC,gBAAgB,EAAE,MAAM,GAAG,gBAAgB,CA8DtE"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { extractSymbols } from "./parsers/symbol-extractor.js";
|
|
2
|
+
const SYMBOLS_TOOL_DESCRIPTION = "Query code symbols (definitions, references, outline) by parsing file AST via tree-sitter. " +
|
|
3
|
+
"Unlike grep (text matching), this tool understands syntax structure — no false positives from " +
|
|
4
|
+
"comments/strings, and it knows whether 'foo' is a function, class, variable, or method. " +
|
|
5
|
+
"Supports 13 languages: TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, C#, Ruby, PHP, " +
|
|
6
|
+
"Lua, Bash. Single-file scope (no cross-file reference resolution). " +
|
|
7
|
+
"Falls back to grep for files in unsupported languages.\n\n" +
|
|
8
|
+
"When to use `symbols` vs `grep`:\n" +
|
|
9
|
+
"- Use `symbols` when you need to find function/class/method **declarations** or their " +
|
|
10
|
+
"**type-aware usages** in supported languages. It avoids false positives from comments/strings.\n" +
|
|
11
|
+
"- Use `grep` for: cross-file text search, unsupported languages (e.g., Markdown, YAML), " +
|
|
12
|
+
"searching non-symbol patterns (TODOs, log strings, config values), or when `symbols` returns " +
|
|
13
|
+
"\"unsupported language\".";
|
|
14
|
+
/**
|
|
15
|
+
* symbols 工具入口:参数校验 → 调 extractor → 标准化输出。
|
|
16
|
+
* 不直接操作 tree-sitter API,所有解析逻辑在 parsers/ 里。
|
|
17
|
+
*/
|
|
18
|
+
export function symbolsTool(workingDirectory) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "builtin",
|
|
21
|
+
toolName: "symbols",
|
|
22
|
+
exposedName: "symbols",
|
|
23
|
+
description: SYMBOLS_TOOL_DESCRIPTION,
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
path: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Workspace-relative file path to analyze. Must be a single file (not a directory).",
|
|
30
|
+
},
|
|
31
|
+
mode: {
|
|
32
|
+
type: "string",
|
|
33
|
+
enum: ["definitions", "references", "outline"],
|
|
34
|
+
description: "Query mode: " +
|
|
35
|
+
"'definitions' finds symbol declarations matching pattern/kind " +
|
|
36
|
+
"(e.g., function/class/method declarations); " +
|
|
37
|
+
"'references' finds all usages of symbols matching pattern " +
|
|
38
|
+
"(e.g., calls, type annotations, assignments); " +
|
|
39
|
+
"'outline' returns the full symbol structure of the file " +
|
|
40
|
+
"(ignores pattern/kind filters).",
|
|
41
|
+
},
|
|
42
|
+
pattern: {
|
|
43
|
+
type: "string",
|
|
44
|
+
description: "Optional regex to filter symbol names (case-sensitive by default; use (?i) prefix for case-insensitive). " +
|
|
45
|
+
"In 'outline' mode this is ignored. " +
|
|
46
|
+
"Example: '^getUser' matches getUserById, getUserByEmail.",
|
|
47
|
+
},
|
|
48
|
+
kind: {
|
|
49
|
+
type: "string",
|
|
50
|
+
enum: ["function", "class", "method", "variable", "import", "all"],
|
|
51
|
+
description: "Symbol kind filter. 'all' (default) returns all kinds. " +
|
|
52
|
+
"Note: not all languages distinguish all kinds (e.g., Bash has no 'class').",
|
|
53
|
+
},
|
|
54
|
+
max_results: {
|
|
55
|
+
type: "number",
|
|
56
|
+
description: "Maximum number of symbols to return. Default 100.",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ["path", "mode"],
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
},
|
|
62
|
+
async execute(args) {
|
|
63
|
+
const filePath = readStringArg(args, ["path"], "path");
|
|
64
|
+
const mode = readModeArg(args);
|
|
65
|
+
const pattern = readOptionalStringArg(args, ["pattern"]);
|
|
66
|
+
const kind = readKindArg(args);
|
|
67
|
+
const maxResults = readOptionalPositiveIntegerArg(args, ["max_results"], 100);
|
|
68
|
+
return extractSymbols(workingDirectory, filePath, mode, {
|
|
69
|
+
pattern,
|
|
70
|
+
kind,
|
|
71
|
+
maxResults,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// ── 参数读取辅助(与 built-in-file-tools.ts 保持风格一致) ────────────────
|
|
77
|
+
function readStringArg(args, names, label) {
|
|
78
|
+
for (const name of names) {
|
|
79
|
+
const v = args[name];
|
|
80
|
+
if (typeof v === "string")
|
|
81
|
+
return v;
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`${label} is required`);
|
|
84
|
+
}
|
|
85
|
+
function readOptionalStringArg(args, names) {
|
|
86
|
+
for (const name of names) {
|
|
87
|
+
const v = args[name];
|
|
88
|
+
if (typeof v === "string" && v.trim())
|
|
89
|
+
return v;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
function readModeArg(args) {
|
|
94
|
+
const v = args.mode;
|
|
95
|
+
if (v === "definitions" || v === "references" || v === "outline")
|
|
96
|
+
return v;
|
|
97
|
+
throw new Error(`mode must be one of: definitions, references, outline`);
|
|
98
|
+
}
|
|
99
|
+
function readKindArg(args) {
|
|
100
|
+
const v = args.kind;
|
|
101
|
+
if (v === undefined || v === null || v === "all")
|
|
102
|
+
return "all";
|
|
103
|
+
if (v === "function" || v === "class" || v === "method" ||
|
|
104
|
+
v === "variable" || v === "import" || v === "error") {
|
|
105
|
+
return v;
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`kind must be one of: function, class, method, variable, import, all`);
|
|
108
|
+
}
|
|
109
|
+
function readOptionalPositiveIntegerArg(args, names, fallback) {
|
|
110
|
+
for (const name of names) {
|
|
111
|
+
const v = args[name];
|
|
112
|
+
const num = typeof v === "number" ? v : typeof v === "string" ? Number(v) : NaN;
|
|
113
|
+
if (Number.isFinite(num) && num > 0)
|
|
114
|
+
return Math.floor(num);
|
|
115
|
+
}
|
|
116
|
+
return fallback;
|
|
117
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -9,4 +9,11 @@ export * from './sub-agent-types.js';
|
|
|
9
9
|
export * from './sub-agent-store.js';
|
|
10
10
|
export * from './sub-agent-manager.js';
|
|
11
11
|
export * from './sub-agent-tools.js';
|
|
12
|
+
export * from './parsers/types.js';
|
|
13
|
+
export * from './parsers/tree-sitter-loader.js';
|
|
14
|
+
export * from './parsers/ast-cache.js';
|
|
15
|
+
export * from './parsers/language-detector.js';
|
|
16
|
+
export * from './parsers/language-queries.js';
|
|
17
|
+
export * from './parsers/symbol-extractor.js';
|
|
18
|
+
export * from './built-in-symbols-tool.js';
|
|
12
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC"}
|
|
@@ -9,3 +9,11 @@ export * from './sub-agent-types.js';
|
|
|
9
9
|
export * from './sub-agent-store.js';
|
|
10
10
|
export * from './sub-agent-manager.js';
|
|
11
11
|
export * from './sub-agent-tools.js';
|
|
12
|
+
// tree-sitter symbols 工具
|
|
13
|
+
export * from './parsers/types.js';
|
|
14
|
+
export * from './parsers/tree-sitter-loader.js';
|
|
15
|
+
export * from './parsers/ast-cache.js';
|
|
16
|
+
export * from './parsers/language-detector.js';
|
|
17
|
+
export * from './parsers/language-queries.js';
|
|
18
|
+
export * from './parsers/symbol-extractor.js';
|
|
19
|
+
export * from './built-in-symbols-tool.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Tree } from "web-tree-sitter";
|
|
2
|
+
/**
|
|
3
|
+
* AST 缓存:LRU + mtime/size 失效。
|
|
4
|
+
*
|
|
5
|
+
* 设计要点:
|
|
6
|
+
* - cache key 用 path + mtimeMs + size 三重校验,mtime 秒级精度不够时 size 兜底
|
|
7
|
+
* - LRU 用 JS Map 的插入顺序语义实现:命中时 delete+set 让它变最新
|
|
8
|
+
* - tree-sitter 的 Tree 是 WASM 对象,必须显式 tree.delete(),不归 V8 GC 管
|
|
9
|
+
* - capacity 默认 100,淘汰最旧时调 tree.delete() 释放 WASM 内存
|
|
10
|
+
*/
|
|
11
|
+
export declare class AstCache {
|
|
12
|
+
private map;
|
|
13
|
+
private readonly capacity;
|
|
14
|
+
constructor(capacity?: number);
|
|
15
|
+
/**
|
|
16
|
+
* 取缓存。mtimeMs 或 size 不匹配则视为 stale,删除并返回 null。
|
|
17
|
+
*/
|
|
18
|
+
get(absolutePath: string, mtimeMs: number, size: number): Tree | null;
|
|
19
|
+
/**
|
|
20
|
+
* 存缓存。若 key 已存在则覆盖(旧 tree 释放)。
|
|
21
|
+
* 超容量时淘汰最旧(Map 的 keys().next().value)。
|
|
22
|
+
*/
|
|
23
|
+
set(absolutePath: string, tree: Tree, language: string, mtimeMs: number, size: number): void;
|
|
24
|
+
/** 主动失效:删除并释放 tree */
|
|
25
|
+
invalidate(absolutePath: string): void;
|
|
26
|
+
/** 清空所有缓存并释放所有 tree */
|
|
27
|
+
clear(): void;
|
|
28
|
+
/** 当前缓存条目数(测试用) */
|
|
29
|
+
size(): number;
|
|
30
|
+
}
|
|
31
|
+
/** 进程级单例,容量 100 */
|
|
32
|
+
export declare const astCache: AstCache;
|
|
33
|
+
//# sourceMappingURL=ast-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-cache.d.ts","sourceRoot":"","sources":["../../src/parsers/ast-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAS5C;;;;;;;;GAQG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,GAAG,CAAiC;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,QAAQ,SAAM;IAK1B;;OAEG;IACH,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAerE;;;OAGG;IACH,GAAG,CACD,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,IAAI;IAgBP,sBAAsB;IACtB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAQtC,uBAAuB;IACvB,KAAK,IAAI,IAAI;IAOb,mBAAmB;IACnB,IAAI,IAAI,MAAM;CAGf;AAED,mBAAmB;AACnB,eAAO,MAAM,QAAQ,UAAoB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST 缓存:LRU + mtime/size 失效。
|
|
3
|
+
*
|
|
4
|
+
* 设计要点:
|
|
5
|
+
* - cache key 用 path + mtimeMs + size 三重校验,mtime 秒级精度不够时 size 兜底
|
|
6
|
+
* - LRU 用 JS Map 的插入顺序语义实现:命中时 delete+set 让它变最新
|
|
7
|
+
* - tree-sitter 的 Tree 是 WASM 对象,必须显式 tree.delete(),不归 V8 GC 管
|
|
8
|
+
* - capacity 默认 100,淘汰最旧时调 tree.delete() 释放 WASM 内存
|
|
9
|
+
*/
|
|
10
|
+
export class AstCache {
|
|
11
|
+
constructor(capacity = 100) {
|
|
12
|
+
this.map = new Map();
|
|
13
|
+
if (capacity < 1)
|
|
14
|
+
throw new Error(`capacity must be >= 1, got ${capacity}`);
|
|
15
|
+
this.capacity = capacity;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 取缓存。mtimeMs 或 size 不匹配则视为 stale,删除并返回 null。
|
|
19
|
+
*/
|
|
20
|
+
get(absolutePath, mtimeMs, size) {
|
|
21
|
+
const entry = this.map.get(absolutePath);
|
|
22
|
+
if (!entry)
|
|
23
|
+
return null;
|
|
24
|
+
if (entry.mtimeMs !== mtimeMs || entry.size !== size) {
|
|
25
|
+
// stale:删除并释放 tree
|
|
26
|
+
entry.tree.delete();
|
|
27
|
+
this.map.delete(absolutePath);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
// LRU 提升:delete + set 让它变最新
|
|
31
|
+
this.map.delete(absolutePath);
|
|
32
|
+
this.map.set(absolutePath, entry);
|
|
33
|
+
return entry.tree;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 存缓存。若 key 已存在则覆盖(旧 tree 释放)。
|
|
37
|
+
* 超容量时淘汰最旧(Map 的 keys().next().value)。
|
|
38
|
+
*/
|
|
39
|
+
set(absolutePath, tree, language, mtimeMs, size) {
|
|
40
|
+
const existing = this.map.get(absolutePath);
|
|
41
|
+
if (existing) {
|
|
42
|
+
existing.tree.delete();
|
|
43
|
+
this.map.delete(absolutePath);
|
|
44
|
+
}
|
|
45
|
+
this.map.set(absolutePath, { tree, language, mtimeMs, size });
|
|
46
|
+
while (this.map.size > this.capacity) {
|
|
47
|
+
const oldestKey = this.map.keys().next().value;
|
|
48
|
+
if (oldestKey === undefined)
|
|
49
|
+
break;
|
|
50
|
+
const oldest = this.map.get(oldestKey);
|
|
51
|
+
oldest?.tree.delete();
|
|
52
|
+
this.map.delete(oldestKey);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** 主动失效:删除并释放 tree */
|
|
56
|
+
invalidate(absolutePath) {
|
|
57
|
+
const entry = this.map.get(absolutePath);
|
|
58
|
+
if (entry) {
|
|
59
|
+
entry.tree.delete();
|
|
60
|
+
this.map.delete(absolutePath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** 清空所有缓存并释放所有 tree */
|
|
64
|
+
clear() {
|
|
65
|
+
for (const entry of this.map.values()) {
|
|
66
|
+
entry.tree.delete();
|
|
67
|
+
}
|
|
68
|
+
this.map.clear();
|
|
69
|
+
}
|
|
70
|
+
/** 当前缓存条目数(测试用) */
|
|
71
|
+
size() {
|
|
72
|
+
return this.map.size;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** 进程级单例,容量 100 */
|
|
76
|
+
export const astCache = new AstCache(100);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-detector.d.ts","sourceRoot":"","sources":["../../src/parsers/language-detector.ts"],"names":[],"mappings":"AAqCA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
/**
|
|
3
|
+
* 文件扩展名 → tree-sitter language 名映射。
|
|
4
|
+
*
|
|
5
|
+
* tsx/jsx 单独映射,因为 tree-sitter-typescript 包内
|
|
6
|
+
* 同时提供 typescript 和 tsx 两个 grammar(同理 javascript 包内含 jsx)。
|
|
7
|
+
* loader 按 language 名加载对应的 wasm 文件。
|
|
8
|
+
*/
|
|
9
|
+
const EXTENSION_MAP = {
|
|
10
|
+
".ts": "typescript",
|
|
11
|
+
".tsx": "tsx",
|
|
12
|
+
".mts": "typescript",
|
|
13
|
+
".cts": "typescript",
|
|
14
|
+
".js": "javascript",
|
|
15
|
+
".jsx": "jsx",
|
|
16
|
+
".mjs": "javascript",
|
|
17
|
+
".cjs": "javascript",
|
|
18
|
+
".py": "python",
|
|
19
|
+
".go": "go",
|
|
20
|
+
".rs": "rust",
|
|
21
|
+
".java": "java",
|
|
22
|
+
".c": "c",
|
|
23
|
+
".h": "c",
|
|
24
|
+
".cpp": "cpp",
|
|
25
|
+
".cc": "cpp",
|
|
26
|
+
".cxx": "cpp",
|
|
27
|
+
".hpp": "cpp",
|
|
28
|
+
".hxx": "cpp",
|
|
29
|
+
".cs": "c-sharp",
|
|
30
|
+
".rb": "ruby",
|
|
31
|
+
".php": "php",
|
|
32
|
+
".lua": "lua",
|
|
33
|
+
".sh": "bash",
|
|
34
|
+
".bash": "bash",
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 根据文件扩展名检测 tree-sitter language 名。
|
|
38
|
+
* 大小写不敏感(扩展名统一转小写后查表)。
|
|
39
|
+
* 未知扩展名返回 null。
|
|
40
|
+
*/
|
|
41
|
+
export function detectLanguage(filePath) {
|
|
42
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
43
|
+
return EXTENSION_MAP[ext] ?? null;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-queries.d.ts","sourceRoot":"","sources":["../../src/parsers/language-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0oBpD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAgB9D,CAAC;AAEF,+BAA+B;AAC/B,eAAO,MAAM,mBAAmB,UAAgC,CAAC"}
|