@cortexkit/aft-opencode 0.2.0 → 0.4.1

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 (76) hide show
  1. package/dist/bridge.d.ts +8 -0
  2. package/dist/bridge.d.ts.map +1 -1
  3. package/dist/bridge.js +45 -2
  4. package/dist/bridge.js.map +1 -1
  5. package/dist/config.d.ts +2 -0
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +17 -0
  8. package/dist/config.js.map +1 -1
  9. package/dist/downloader.d.ts.map +1 -1
  10. package/dist/downloader.js +51 -15
  11. package/dist/downloader.js.map +1 -1
  12. package/dist/index.d.ts +4 -3
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +73 -15
  15. package/dist/index.js.map +1 -1
  16. package/dist/metadata-store.d.ts +29 -0
  17. package/dist/metadata-store.d.ts.map +1 -0
  18. package/dist/metadata-store.js +53 -0
  19. package/dist/metadata-store.js.map +1 -0
  20. package/dist/normalize-schemas.d.ts +16 -0
  21. package/dist/normalize-schemas.d.ts.map +1 -0
  22. package/dist/normalize-schemas.js +45 -0
  23. package/dist/normalize-schemas.js.map +1 -0
  24. package/dist/patch-parser.d.ts +33 -0
  25. package/dist/patch-parser.d.ts.map +1 -0
  26. package/dist/patch-parser.js +247 -0
  27. package/dist/patch-parser.js.map +1 -0
  28. package/dist/platform.d.ts +21 -0
  29. package/dist/platform.d.ts.map +1 -0
  30. package/dist/platform.js +31 -0
  31. package/dist/platform.js.map +1 -0
  32. package/dist/pool.d.ts.map +1 -1
  33. package/dist/pool.js +14 -5
  34. package/dist/pool.js.map +1 -1
  35. package/dist/resolver.d.ts.map +1 -1
  36. package/dist/resolver.js +6 -9
  37. package/dist/resolver.js.map +1 -1
  38. package/dist/tools/ast.d.ts.map +1 -1
  39. package/dist/tools/ast.js +179 -89
  40. package/dist/tools/ast.js.map +1 -1
  41. package/dist/tools/hoisted.d.ts +26 -0
  42. package/dist/tools/hoisted.d.ts.map +1 -0
  43. package/dist/tools/hoisted.js +852 -0
  44. package/dist/tools/hoisted.js.map +1 -0
  45. package/dist/tools/imports.d.ts.map +1 -1
  46. package/dist/tools/imports.js +41 -21
  47. package/dist/tools/imports.js.map +1 -1
  48. package/dist/tools/lsp.d.ts +1 -2
  49. package/dist/tools/lsp.d.ts.map +1 -1
  50. package/dist/tools/lsp.js +45 -110
  51. package/dist/tools/lsp.js.map +1 -1
  52. package/dist/tools/navigation.d.ts.map +1 -1
  53. package/dist/tools/navigation.js +25 -10
  54. package/dist/tools/navigation.js.map +1 -1
  55. package/dist/tools/permissions.d.ts +8 -0
  56. package/dist/tools/permissions.d.ts.map +1 -0
  57. package/dist/tools/permissions.js +50 -0
  58. package/dist/tools/permissions.js.map +1 -0
  59. package/dist/tools/reading.d.ts +1 -1
  60. package/dist/tools/reading.d.ts.map +1 -1
  61. package/dist/tools/reading.js +170 -54
  62. package/dist/tools/reading.js.map +1 -1
  63. package/dist/tools/refactoring.d.ts.map +1 -1
  64. package/dist/tools/refactoring.js +73 -24
  65. package/dist/tools/refactoring.js.map +1 -1
  66. package/dist/tools/safety.d.ts.map +1 -1
  67. package/dist/tools/safety.js +38 -11
  68. package/dist/tools/safety.js.map +1 -1
  69. package/dist/tools/structure.d.ts.map +1 -1
  70. package/dist/tools/structure.js +70 -20
  71. package/dist/tools/structure.js.map +1 -1
  72. package/package.json +7 -7
  73. package/dist/tools/editing.d.ts +0 -7
  74. package/dist/tools/editing.d.ts.map +0 -1
  75. package/dist/tools/editing.js +0 -150
  76. package/dist/tools/editing.js.map +0 -1
@@ -1,103 +1,219 @@
1
+ import { readdir } from "node:fs/promises";
2
+ import { extname, join, resolve } from "node:path";
1
3
  import { tool } from "@opencode-ai/plugin";
2
- import { queryLspHints } from "../lsp.js";
4
+ /** File extensions that aft_outline supports via tree-sitter or markdown parser */
5
+ const OUTLINE_EXTENSIONS = new Set([
6
+ ".ts",
7
+ ".tsx",
8
+ ".js",
9
+ ".jsx",
10
+ ".mjs",
11
+ ".cjs",
12
+ ".rs",
13
+ ".go",
14
+ ".py",
15
+ ".rb",
16
+ ".c",
17
+ ".cpp",
18
+ ".h",
19
+ ".hpp",
20
+ ".cs",
21
+ ".java",
22
+ ".kt",
23
+ ".scala",
24
+ ".swift",
25
+ ".lua",
26
+ ".ex",
27
+ ".exs",
28
+ ".hs",
29
+ ".sol",
30
+ ".nix",
31
+ ".md",
32
+ ".mdx",
33
+ ".css",
34
+ ".html",
35
+ ".json",
36
+ ".yaml",
37
+ ".yml",
38
+ ".sh",
39
+ ".bash",
40
+ ]);
3
41
  const z = tool.schema;
4
42
  /**
5
- * Tool definitions for code reading commands: outline and zoom.
43
+ * Tool definitions for code reading commands: outline + zoom.
6
44
  */
7
45
  export function readingTools(ctx) {
8
46
  return {
9
47
  aft_outline: {
10
- description: "Get a structural outline of a source file — lists all top-level symbols with their kind, name, line range, and visibility. Use this to understand file structure before editing. " +
11
- "Supports single file (via 'file') or multiple files in one call (via 'files' array).\n" +
48
+ description: "Get a structural outline of a source file, multiple files, or an entire directory — lists all top-level symbols with their kind, name, line range, and visibility. Use this to understand file structure before editing.\n" +
12
49
  "Each entry includes 'name', 'kind' (function/class/struct/heading/etc), 'range', 'signature', and 'members' (nested children like methods in classes or sub-headings in markdown).\n" +
13
- "For Markdown files (.md, .mdx): returns heading hierarchy — h1/h2/h3 as nested symbols with section ranges covering all content until the next same-level heading.",
50
+ "For Markdown files (.md, .mdx): returns heading hierarchy — h1/h2/h3 as nested symbols with section ranges covering all content until the next same-level heading.\n\n" +
51
+ "Provide 'filePath', 'files', or 'directory'. Priority: directory > files > filePath. If multiple provided, highest-priority wins.\n" +
52
+ "Supported languages: TypeScript, JavaScript, TSX, Python, Rust, Go, Ruby, C, C++, C#, Java, Kotlin, Scala, Swift, Lua, Elixir, Haskell, Solidity, Nix, Markdown, CSS, HTML, JSON, YAML, Bash.\n" +
53
+ "Directory mode skips commonly ignored directories (node_modules, .git, dist, build, target, __pycache__, venv, vendor, coverage, etc.) and dot-prefixed directories.\n\n" +
54
+ "Returns: Single file { entries: [{ name, kind, range, signature?, exported, members }] }. Multi-file/directory { results: [{ file, ok, entries? }] }.",
14
55
  args: {
15
- file: z
56
+ filePath: z
16
57
  .string()
17
58
  .optional()
18
- .describe("Path to a single source file to outline (relative to project root or absolute)"),
59
+ .describe("Path to a single file to outline (ignored if 'files' or 'directory' is also provided)"),
19
60
  files: z
20
61
  .array(z.string())
21
62
  .optional()
22
- .describe("Array of file paths to outline in one call returns per-file results"),
63
+ .describe("Array of file paths to outline in one call (ignored if 'directory' is also provided)"),
64
+ // The 200-file cap is intentionally only in .describe() — not in the main description —
65
+ // because it's a parameter-level detail. The cap is silent (no warning on truncation).
66
+ directory: z
67
+ .string()
68
+ .optional()
69
+ .describe("Path to a directory — outlines all source files under it recursively (capped at 200 files, takes priority over 'filePath' and 'files')"),
23
70
  },
24
71
  execute: async (args, context) => {
25
72
  const bridge = ctx.pool.getBridge(context.directory);
73
+ const filesArg = Array.isArray(args.files) ? args.files : undefined;
74
+ if (!args.filePath && !filesArg?.length && !args.directory) {
75
+ throw new Error("Provide exactly one of 'filePath', 'files', or 'directory'");
76
+ }
77
+ // Directory mode: discover source files recursively and batch outline
78
+ if (typeof args.directory === "string") {
79
+ const dirPath = resolve(context.directory, args.directory);
80
+ const files = await discoverSourceFiles(dirPath);
81
+ if (files.length === 0) {
82
+ return JSON.stringify({
83
+ success: false,
84
+ message: `No source files found under ${args.directory}`,
85
+ });
86
+ }
87
+ const response = await bridge.send("outline", { files });
88
+ return JSON.stringify(response);
89
+ }
26
90
  if (Array.isArray(args.files) && args.files.length > 0) {
27
91
  const response = await bridge.send("outline", { files: args.files });
28
92
  return JSON.stringify(response);
29
93
  }
30
- const response = await bridge.send("outline", { file: args.file });
94
+ const response = await bridge.send("outline", { file: args.filePath });
31
95
  return JSON.stringify(response);
32
96
  },
33
97
  },
34
98
  aft_zoom: {
35
- description: "Deep-inspect symbols or read arbitrary line ranges from a source file.\n" +
36
- "Returns full source, surrounding context lines, and call-graph annotations (calls_out, called_by) for code symbols.\n" +
37
- "Supports three access patterns:\n" +
38
- "- 'symbol': Inspect a named symbol (function, class, type, or markdown heading)\n" +
39
- "- 'symbols': Inspect multiple symbols in one call — returns an array of results\n" +
40
- "- 'start_line' + 'end_line': Read arbitrary line range (1-based) without needing a symbol name\n" +
41
- "For Markdown: use heading text as symbol name (e.g. symbol='Architecture') to read entire section.",
99
+ description: `Inspect code symbols with call-graph annotations. Returns the full source of named symbols with what they call and what calls them.
100
+
101
+ Use this when you need to understand a specific function, class, or type in detail — not for reading entire files (use read for that).
102
+
103
+ **Modes:**
104
+
105
+ 1. **Inspect symbol** pass filePath + symbol
106
+ Returns full source + call graph annotations.
107
+ Example: { "filePath": "src/app.ts", "symbol": "handleRequest" }
108
+
109
+ 2. **Inspect multiple symbols** — pass filePath + symbols array
110
+ Returns multiple symbols in one call.
111
+ Example: { "filePath": "src/app.ts", "symbols": ["Config", "createApp"] }
112
+
113
+ 3. **Read line range with context** — pass filePath + startLine + endLine
114
+ Returns lines with context_before and context_after.
115
+ Example: { "filePath": "src/app.ts", "startLine": 50, "endLine": 100 }
116
+
117
+ For Markdown files, use heading text as symbol name (e.g., symbol: "Architecture").
118
+
119
+ Mode priority: symbols array > single symbol > line range.
120
+
121
+ Returns: Symbol mode { name, kind, range, content, context_before, context_after, annotations: { calls_out, called_by } }. Multi-symbol mode returns an array of these. Line-range mode returns { content, context_before, context_after, start_line, end_line }.`,
42
122
  args: {
43
- file: z.string().describe("Path to the source file containing the symbol"),
123
+ filePath: z.string().describe("Path to file (absolute or relative to project root)"),
44
124
  symbol: z.string().optional().describe("Name of a single symbol to inspect"),
45
125
  symbols: z
46
126
  .array(z.string())
47
127
  .optional()
48
- .describe("Array of symbol names to inspect in one call — returns results for each"),
49
- context_lines: z
128
+ .describe("Array of symbol names to inspect in one call"),
129
+ startLine: z.number().optional().describe("1-based start line for line-range mode"),
130
+ endLine: z
50
131
  .number()
51
132
  .optional()
52
- .describe("Number of lines of context to include above and below the symbol (default: 3)"),
53
- scope: z
54
- .string()
55
- .optional()
56
- .describe("Qualified scope to disambiguate symbols with the same name (e.g. 'ClassName.method')"),
57
- start_line: z.number().optional().describe("Start line (1-based) for line-range read mode"),
58
- end_line: z
133
+ .describe("1-based end line for line-range mode (inclusive, required with startLine)"),
134
+ contextLines: z
59
135
  .number()
60
136
  .optional()
61
- .describe("End line (1-based, inclusive) for line-range read mode"),
137
+ .describe("Lines of context before/after the requested range or symbol (default: 3)"),
62
138
  },
63
139
  execute: async (args, context) => {
64
140
  const bridge = ctx.pool.getBridge(context.directory);
65
- // Batch symbols mode: zoom into multiple symbols in one call
141
+ const file = args.filePath;
142
+ // Multi-symbol mode: make separate zoom calls in parallel and combine results
66
143
  if (Array.isArray(args.symbols) && args.symbols.length > 0) {
67
- const results = await Promise.all(args.symbols.map(async (sym) => {
68
- const params = { file: args.file, symbol: sym };
69
- if (args.context_lines !== undefined)
70
- params.context_lines = Number(args.context_lines);
71
- if (args.scope !== undefined)
72
- params.scope = args.scope;
73
- const hints = await queryLspHints(ctx.client, sym);
74
- if (hints)
75
- params.lsp_hints = hints;
144
+ const results = await Promise.all(args.symbols.map((sym) => {
145
+ const params = { file, symbol: sym };
146
+ if (args.contextLines !== undefined)
147
+ params.context_lines = args.contextLines;
76
148
  return bridge.send("zoom", params);
77
149
  }));
78
150
  return JSON.stringify(results);
79
151
  }
80
152
  // Single symbol or line-range mode
81
- const params = { file: args.file };
82
- if (args.symbol !== undefined)
153
+ const params = { file };
154
+ if (typeof args.symbol === "string")
83
155
  params.symbol = args.symbol;
84
- if (args.context_lines !== undefined)
85
- params.context_lines = Number(args.context_lines);
86
- if (args.scope !== undefined)
87
- params.scope = args.scope;
88
- if (args.start_line !== undefined)
89
- params.start_line = Number(args.start_line);
90
- if (args.end_line !== undefined)
91
- params.end_line = Number(args.end_line);
92
- if (args.symbol) {
93
- const hints = await queryLspHints(ctx.client, args.symbol);
94
- if (hints)
95
- params.lsp_hints = hints;
96
- }
97
- const response = await bridge.send("zoom", params);
98
- return JSON.stringify(response);
156
+ if (args.startLine !== undefined)
157
+ params.start_line = args.startLine;
158
+ if (args.endLine !== undefined)
159
+ params.end_line = args.endLine;
160
+ if (args.contextLines !== undefined)
161
+ params.context_lines = args.contextLines;
162
+ const data = await bridge.send("zoom", params);
163
+ return JSON.stringify(data);
99
164
  },
100
165
  },
101
166
  };
102
167
  }
168
+ /** Recursively discover source files under a directory, skipping common noise directories */
169
+ const SKIP_DIRS = new Set([
170
+ "node_modules",
171
+ ".git",
172
+ "dist",
173
+ "build",
174
+ "out",
175
+ ".next",
176
+ ".nuxt",
177
+ "target",
178
+ "__pycache__",
179
+ ".venv",
180
+ "venv",
181
+ "vendor",
182
+ ".turbo",
183
+ "coverage",
184
+ ".nyc_output",
185
+ ".cache",
186
+ ]);
187
+ async function discoverSourceFiles(dir, maxFiles = 200) {
188
+ const files = [];
189
+ async function walk(current) {
190
+ if (files.length >= maxFiles)
191
+ return;
192
+ let entries;
193
+ try {
194
+ entries = await readdir(current, { withFileTypes: true });
195
+ }
196
+ catch {
197
+ return; // permission denied, not a directory, etc.
198
+ }
199
+ for (const entry of entries) {
200
+ if (files.length >= maxFiles)
201
+ return;
202
+ if (entry.isDirectory()) {
203
+ if (!SKIP_DIRS.has(entry.name) && !entry.name.startsWith(".")) {
204
+ await walk(join(current, entry.name));
205
+ }
206
+ }
207
+ else if (entry.isFile()) {
208
+ const ext = extname(entry.name).toLowerCase();
209
+ if (OUTLINE_EXTENSIONS.has(ext)) {
210
+ files.push(join(current, entry.name));
211
+ }
212
+ }
213
+ }
214
+ }
215
+ await walk(dir);
216
+ files.sort();
217
+ return files;
218
+ }
103
219
  //# sourceMappingURL=reading.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reading.js","sourceRoot":"","sources":["../../src/tools/reading.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,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AI,QAAQ;gBAAE,OAAO;YAErC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC9D,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;gBAC9C,IAAI,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,CAAC;IACb,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"refactoring.d.ts","sourceRoot":"","sources":["../../src/tools/refactoring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAyEnF"}
1
+ {"version":3,"file":"refactoring.d.ts","sourceRoot":"","sources":["../../src/tools/refactoring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAYjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA4HnF"}
@@ -1,5 +1,6 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
2
  import { queryLspHints } from "../lsp.js";
3
+ import { askEditPermission, permissionDeniedResponse, resolveAbsolutePath, resolveRelativePattern, resolveRelativePatterns, workspacePattern, } from "./permissions.js";
3
4
  const z = tool.schema;
4
5
  /**
5
6
  * Tool definitions for refactoring commands: move_symbol, extract_function, inline_symbol.
@@ -7,50 +8,98 @@ const z = tool.schema;
7
8
  export function refactoringTools(ctx) {
8
9
  return {
9
10
  aft_refactor: {
10
- description: "Workspace-wide refactoring operations that update imports and references across files.\n" +
11
+ description: "Workspace-wide refactoring operations that update imports and references across files.\n\n" +
11
12
  "Ops:\n" +
12
- "- 'move': Move a symbol to another file, updating all imports workspace-wide. Needs 'symbol', 'destination'. Creates a checkpoint before mutating.\n" +
13
- "- 'extract': Extract a line range into a new function with auto-detected parameters. Needs 'name', 'start_line', 'end_line' (all 1-based). Supports TS/JS/TSX and Python.\n" +
14
- "- 'inline': Replace a function call with the function's body, substituting args for params. Needs 'symbol', 'call_site_line' (1-based). Validates single-return constraint.\n" +
15
- "All ops need 'file'. Use dry_run to preview.",
13
+ "- 'move': Move a top-level symbol to another file, updating all imports workspace-wide. Requires 'symbol', 'destination'. Creates a checkpoint before mutating. Only works on top-level exports (not nested functions or class methods).\n" +
14
+ " Note: This moves code symbols between files. To rename/move an entire file, use aft_move instead.\n" +
15
+ "- 'extract': Extract a line range into a new function with auto-detected parameters. Requires 'name', 'startLine', 'endLine' (1-based, both inclusive). Supports TS/JS/TSX and Python.\n" +
16
+ "- 'inline': Replace a function call with the function's body, substituting args for params. Requires 'symbol', 'callSiteLine' (1-based). Validates single-return constraint.\n\n" +
17
+ "Each op requires specific parameters — see parameter descriptions for requirements.\n\n" +
18
+ "All ops need 'filePath'. Use dryRun to preview before applying.\n\n" +
19
+ "Returns: move dry-run { ok, dry_run, diffs }; move apply { ok, files_modified, consumers_updated, checkpoint_name, results }. extract returns { file, name, parameters, return_type, syntax_valid, formatted, ... }. inline returns { file, symbol, call_context, substitutions, conflicts, syntax_valid, formatted, ... }.",
20
+ // Parameters are Zod-optional because different ops need different subsets.
21
+ // Runtime guards below validate per-op requirements and give clear errors.
16
22
  args: {
17
23
  op: z.enum(["move", "extract", "inline"]).describe("Refactoring operation"),
18
- file: z.string().describe("Path to the source file"),
24
+ filePath: z
25
+ .string()
26
+ .describe("Path to the source file (absolute or relative to project root)"),
19
27
  symbol: z
20
28
  .string()
21
29
  .optional()
22
- .describe("Symbol name (move: symbol to move, inline: function to inline)"),
30
+ .describe("Symbol name required for 'move' and 'inline' ops"),
23
31
  // move
24
- destination: z
25
- .string()
26
- .optional()
27
- .describe("Destination file path (move op will be created if needed)"),
32
+ destination: z.string().optional().describe("Target file path — required for 'move' op"),
33
+ // scope disambiguates overloaded top-level names, NOT nested symbols.
34
+ // "Only works on top-level exports" in the description is correct — scope selects
35
+ // among multiple top-level symbols that share a name, not class methods.
28
36
  scope: z
29
37
  .string()
30
38
  .optional()
31
- .describe("Disambiguation scope when multiple symbols share the same name (move op)"),
39
+ .describe("Disambiguation scope for 'move' op — when multiple top-level symbols share the same name, specify the containing scope to disambiguate (e.g. 'MyClass'). Does NOT enable access to nested symbols or class methods."),
32
40
  // extract
33
- name: z.string().optional().describe("Name for the new extracted function (extract op)"),
34
- start_line: z.number().describe("First line of range to extract, 1-based (extract op)"),
35
- end_line: z.number().describe("Last line of range, exclusive, 1-based (extract op)"),
41
+ name: z.string().optional().describe("New function name required for 'extract' op"),
42
+ startLine: z.number().optional().describe("1-based start line required for 'extract' op"),
43
+ // endLine is inclusive from the agent's perspective; the execute function adds +1
44
+ // because the Rust backend expects exclusive end. This is intentional — do not document.
45
+ endLine: z
46
+ .number()
47
+ .optional()
48
+ .describe("1-based end line (inclusive) — required for 'extract' op"),
36
49
  // inline
37
- call_site_line: z
50
+ callSiteLine: z
38
51
  .number()
39
- .describe("Line where the call expression is located, 1-based (inline op)"),
52
+ .optional()
53
+ .describe("1-based call site line — required for 'inline' op"),
40
54
  // common
41
- dry_run: z.boolean().optional().describe("Preview as diff without modifying files"),
55
+ dryRun: z
56
+ .boolean()
57
+ .optional()
58
+ .describe("Preview changes as diff without modifying files (default: false)"),
42
59
  },
43
60
  execute: async (args, context) => {
44
61
  const bridge = ctx.pool.getBridge(context.directory);
45
62
  const op = args.op;
63
+ const isDryRun = args.dryRun === true;
64
+ if ((op === "move" || op === "inline") && typeof args.symbol !== "string") {
65
+ throw new Error(`'symbol' is required for '${op}' op`);
66
+ }
67
+ if (op === "move" && typeof args.destination !== "string") {
68
+ throw new Error("'destination' is required for 'move' op");
69
+ }
70
+ if (op === "extract") {
71
+ if (typeof args.name !== "string")
72
+ throw new Error("'name' is required for 'extract' op");
73
+ if (args.startLine === undefined)
74
+ throw new Error("'startLine' is required for 'extract' op");
75
+ if (args.endLine === undefined)
76
+ throw new Error("'endLine' is required for 'extract' op");
77
+ }
78
+ if (op === "inline" && args.callSiteLine === undefined) {
79
+ throw new Error("'callSiteLine' is required for 'inline' op");
80
+ }
81
+ if (!isDryRun) {
82
+ const filePath = resolveAbsolutePath(context, args.filePath);
83
+ const patterns = op === "move"
84
+ ? resolveRelativePatterns(context, [
85
+ workspacePattern(context),
86
+ args.filePath,
87
+ ...(typeof args.destination === "string" ? [args.destination] : []),
88
+ ])
89
+ : [resolveRelativePattern(context, args.filePath)];
90
+ const metadata = patterns.length === 1 ? { filepath: filePath } : {};
91
+ const permissionError = await askEditPermission(context, patterns, metadata);
92
+ if (permissionError)
93
+ return permissionDeniedResponse(permissionError);
94
+ }
46
95
  const commandMap = {
47
96
  move: "move_symbol",
48
97
  extract: "extract_function",
49
98
  inline: "inline_symbol",
50
99
  };
51
- const params = { file: args.file };
52
- if (args.dry_run !== undefined)
53
- params.dry_run = args.dry_run;
100
+ const params = { file: args.filePath };
101
+ if (args.dryRun !== undefined)
102
+ params.dry_run = args.dryRun;
54
103
  switch (op) {
55
104
  case "move":
56
105
  params.symbol = args.symbol;
@@ -60,12 +109,12 @@ export function refactoringTools(ctx) {
60
109
  break;
61
110
  case "extract":
62
111
  params.name = args.name;
63
- params.start_line = Number(args.start_line);
64
- params.end_line = Number(args.end_line);
112
+ params.start_line = Number(args.startLine);
113
+ params.end_line = Number(args.endLine) + 1; // Agent uses inclusive, Rust expects exclusive
65
114
  break;
66
115
  case "inline":
67
116
  params.symbol = args.symbol;
68
- params.call_site_line = Number(args.call_site_line);
117
+ params.call_site_line = Number(args.callSiteLine);
69
118
  break;
70
119
  }
71
120
  const hints = await queryLspHints(ctx.client, (args.symbol ?? args.name));
@@ -1 +1 @@
1
- {"version":3,"file":"refactoring.js","sourceRoot":"","sources":["../../src/tools/refactoring.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;AAEtB;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAkB;IACjD,OAAO;QACL,YAAY,EAAE;YACZ,WAAW,EACT,0FAA0F;gBAC1F,QAAQ;gBACR,sJAAsJ;gBACtJ,6KAA6K;gBAC7K,+KAA+K;gBAC/K,8CAA8C;YAChD,IAAI,EAAE;gBACJ,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;gBAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;gBACpD,MAAM,EAAE,CAAC;qBACN,MAAM,EAAE;qBACR,QAAQ,EAAE;qBACV,QAAQ,C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ceRoot":"","sources":["../../src/tools/safety.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA6C9E"}
1
+ {"version":3,"file":"safety.d.ts","sourceRoot":"","sources":["../../src/tools/safety.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAWjD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA6E9E"}
@@ -1,4 +1,5 @@
1
1
  import { tool } from "@opencode-ai/plugin";
2
+ import { askEditPermission, permissionDeniedResponse, resolveAbsolutePath, resolveRelativePattern, workspacePattern, } from "./permissions.js";
2
3
  const z = tool.schema;
3
4
  /**
4
5
  * Tool definitions for safety & recovery commands: undo, edit_history,
@@ -7,20 +8,27 @@ const z = tool.schema;
7
8
  export function safetyTools(ctx) {
8
9
  return {
9
10
  aft_safety: {
10
- description: "File safety and recovery operations.\n" +
11
+ description: "File safety and recovery operations.\n\n" +
12
+ "IMPORTANT: All backups are in-memory only — lost if the AFT process restarts. Per-file undo stack is capped at 20 entries (oldest evicted).\n\n" +
11
13
  "Ops:\n" +
12
- "- 'undo': Undo the last edit to a file. Needs 'file'.\n" +
13
- "- 'history': List all edit snapshots for a file. Needs 'file'.\n" +
14
- "- 'checkpoint': Save a named snapshot of tracked files. Needs 'name', optional 'files' array.\n" +
15
- "- 'restore': Restore files to a checkpoint state. Needs 'name'.\n" +
16
- "- 'list': List all available checkpoints.\n" +
17
- "Use checkpoint before risky multi-file changes. Use undo for quick single-file rollback.\n" +
18
- "Note: backups are in-memory (lost on restart). Per-file undo stack is capped at 20 entries (oldest evicted).",
14
+ "- 'undo': Undo the last edit to a file. Requires 'filePath'. Note: pops from the undo stack (irreversible, no redo). Use 'history' to inspect before undoing.\n" +
15
+ "- 'history': List all edit snapshots for a file. Requires 'filePath'.\n" +
16
+ "- 'checkpoint': Save a named snapshot of tracked files. Requires 'name'. Optional 'files' to snapshot specific files only.\n" +
17
+ "- 'restore': Restore files to a previously saved checkpoint. Requires 'name'.\n" +
18
+ "- 'list': List all available named checkpoints. No extra params needed.\n\n" +
19
+ "Each op requires specific parameters see parameter descriptions for requirements.\n\n" +
20
+ "Use checkpoint before risky multi-file changes. Use undo for quick single-file rollback.\n\n" +
21
+ "Returns: undo { path, backup_id }. history { file, entries }. checkpoint { ok, name }. restore { ok, name }. list { checkpoints }.",
22
+ // Parameters are Zod-optional because different ops need different subsets.
23
+ // Runtime guards below validate per-op requirements and give clear errors.
19
24
  args: {
20
25
  op: z
21
26
  .enum(["undo", "history", "checkpoint", "restore", "list"])
22
27
  .describe("Safety operation"),
23
- file: z.string().optional().describe("File path (required for undo, history)"),
28
+ filePath: z
29
+ .string()
30
+ .optional()
31
+ .describe("File path (required for undo, history). Absolute or relative to project root"),
24
32
  name: z.string().optional().describe("Checkpoint name (required for checkpoint, restore)"),
25
33
  files: z
26
34
  .array(z.string())
@@ -30,6 +38,25 @@ export function safetyTools(ctx) {
30
38
  execute: async (args, context) => {
31
39
  const bridge = ctx.pool.getBridge(context.directory);
32
40
  const op = args.op;
41
+ if ((op === "undo" || op === "history") && typeof args.filePath !== "string") {
42
+ throw new Error(`'filePath' is required for '${op}' op`);
43
+ }
44
+ if ((op === "checkpoint" || op === "restore") && typeof args.name !== "string") {
45
+ throw new Error(`'name' is required for '${op}' op`);
46
+ }
47
+ if (op === "undo" && typeof args.filePath === "string") {
48
+ const filePath = resolveAbsolutePath(context, args.filePath);
49
+ const permissionError = await askEditPermission(context, [resolveRelativePattern(context, args.filePath)], { filepath: filePath });
50
+ if (permissionError)
51
+ return permissionDeniedResponse(permissionError);
52
+ }
53
+ if (op === "restore") {
54
+ const permissionError = await askEditPermission(context, [workspacePattern(context)], {
55
+ checkpoint: args.name,
56
+ });
57
+ if (permissionError)
58
+ return permissionDeniedResponse(permissionError);
59
+ }
33
60
  const commandMap = {
34
61
  undo: "undo",
35
62
  history: "edit_history",
@@ -38,8 +65,8 @@ export function safetyTools(ctx) {
38
65
  list: "list_checkpoints",
39
66
  };
40
67
  const params = {};
41
- if (args.file !== undefined)
42
- params.file = args.file;
68
+ if (args.filePath !== undefined)
69
+ params.file = args.filePath;
43
70
  if (args.name !== undefined)
44
71
  params.name = args.name;
45
72
  if (args.files !== undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"safety.js","sourceRoot":"","sources":["../../src/tools/safety.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG3C,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAkB;IAC5C,OAAO;QACL,UAAU,EAAE;YACV,WAAW,EACT,wCAAwC;gBACxC,QAAQ;gBACR,yDAAyD;gBACzD,kEAAkE;gBAClE,iGAAiG;gBACjG,mEAAmE;gBACnE,6CAA6C;gBAC7C,4FAA4F;gBAC5F,8GAA8G;YAChH,IAAI,EAAE;gBACJ,EAAE,EAAE,CAAC;qBACF,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;qBAC1D,QAAQ,CAAC,kBAAkB,CAAC;gBAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;gBAC9E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;gBAC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AAI,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAC7D,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;oBAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;gBACrD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;oBAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBACxD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;gBAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/tools/structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAqGjF"}
1
+ {"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../src/tools/structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAUjD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAkKjF"}