@oh-my-pi/pi-coding-agent 14.1.2 → 14.2.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 (130) hide show
  1. package/CHANGELOG.md +47 -2
  2. package/package.json +8 -8
  3. package/scripts/build-binary.ts +61 -0
  4. package/src/autoresearch/helpers.ts +10 -0
  5. package/src/autoresearch/index.ts +1 -11
  6. package/src/autoresearch/tools/init-experiment.ts +1 -10
  7. package/src/autoresearch/tools/log-experiment.ts +1 -11
  8. package/src/autoresearch/tools/run-experiment.ts +1 -10
  9. package/src/bun-imports.d.ts +6 -0
  10. package/src/cli/plugin-cli.ts +23 -45
  11. package/src/commit/agentic/tools/propose-commit.ts +1 -14
  12. package/src/commit/agentic/tools/split-commit.ts +1 -15
  13. package/src/commit/utils.ts +15 -1
  14. package/src/config/model-registry.ts +3 -3
  15. package/src/config/prompt-templates.ts +4 -12
  16. package/src/config/settings-schema.ts +27 -2
  17. package/src/config/settings.ts +1 -1
  18. package/src/dap/session.ts +8 -2
  19. package/src/discovery/claude-plugins.ts +61 -6
  20. package/src/discovery/codex.ts +2 -15
  21. package/src/discovery/gemini.ts +2 -15
  22. package/src/discovery/helpers.ts +40 -1
  23. package/src/discovery/opencode.ts +2 -15
  24. package/src/edit/apply-patch/index.ts +87 -0
  25. package/src/edit/apply-patch/parser.ts +174 -0
  26. package/src/edit/diff.ts +3 -14
  27. package/src/edit/index.ts +67 -3
  28. package/src/edit/modes/apply-patch.lark +19 -0
  29. package/src/edit/modes/apply-patch.ts +63 -0
  30. package/src/edit/modes/chunk.ts +6 -2
  31. package/src/edit/modes/hashline.ts +3 -3
  32. package/src/edit/modes/replace.ts +2 -13
  33. package/src/edit/read-file.ts +18 -0
  34. package/src/edit/renderer.ts +61 -33
  35. package/src/extensibility/extensions/compact-handler.ts +40 -0
  36. package/src/extensibility/extensions/runner.ts +11 -29
  37. package/src/extensibility/utils.ts +7 -1
  38. package/src/internal-urls/docs-index.generated.ts +9 -2
  39. package/src/lsp/client.ts +14 -5
  40. package/src/lsp/index.ts +53 -10
  41. package/src/lsp/render.ts +14 -2
  42. package/src/lsp/types.ts +2 -0
  43. package/src/main.ts +1 -0
  44. package/src/mcp/manager.ts +29 -48
  45. package/src/memories/index.ts +7 -1
  46. package/src/modes/acp/acp-agent.ts +3 -16
  47. package/src/modes/components/model-selector.ts +15 -24
  48. package/src/modes/components/plugin-settings.ts +16 -5
  49. package/src/modes/components/read-tool-group.ts +92 -9
  50. package/src/modes/components/settings-defs.ts +18 -0
  51. package/src/modes/components/settings-selector.ts +2 -6
  52. package/src/modes/components/tool-execution.ts +61 -28
  53. package/src/modes/controllers/event-controller.ts +3 -1
  54. package/src/modes/controllers/extension-ui-controller.ts +99 -150
  55. package/src/modes/controllers/selector-controller.ts +3 -12
  56. package/src/modes/interactive-mode.ts +4 -2
  57. package/src/modes/print-mode.ts +4 -22
  58. package/src/modes/rpc/rpc-mode.ts +18 -38
  59. package/src/modes/shared.ts +10 -1
  60. package/src/modes/utils/ui-helpers.ts +6 -2
  61. package/src/plan-mode/approved-plan.ts +5 -4
  62. package/src/prompts/system/subagent-system-prompt.md +4 -4
  63. package/src/prompts/system/subagent-user-prompt.md +2 -2
  64. package/src/prompts/system/system-prompt.md +208 -243
  65. package/src/prompts/tools/apply-patch.md +67 -0
  66. package/src/prompts/tools/ast-edit.md +18 -23
  67. package/src/prompts/tools/ast-grep.md +25 -32
  68. package/src/prompts/tools/bash.md +11 -23
  69. package/src/prompts/tools/debug.md +8 -22
  70. package/src/prompts/tools/find.md +0 -4
  71. package/src/prompts/tools/grep.md +3 -5
  72. package/src/prompts/tools/hashline.md +16 -10
  73. package/src/prompts/tools/python.md +10 -14
  74. package/src/prompts/tools/read.md +17 -24
  75. package/src/prompts/tools/task.md +57 -21
  76. package/src/prompts/tools/todo-write.md +45 -67
  77. package/src/session/agent-session.ts +4 -4
  78. package/src/session/session-manager.ts +15 -7
  79. package/src/session/streaming-output.ts +24 -0
  80. package/src/slash-commands/builtin-registry.ts +3 -14
  81. package/src/task/executor.ts +13 -34
  82. package/src/task/index.ts +82 -18
  83. package/src/task/simple-mode.ts +27 -0
  84. package/src/task/template.ts +17 -3
  85. package/src/task/types.ts +77 -30
  86. package/src/tools/ask.ts +2 -4
  87. package/src/tools/ast-edit.ts +41 -17
  88. package/src/tools/ast-grep.ts +8 -27
  89. package/src/tools/bash-skill-urls.ts +9 -7
  90. package/src/tools/bash.ts +66 -24
  91. package/src/tools/browser.ts +1 -1
  92. package/src/tools/fetch.ts +1 -14
  93. package/src/tools/file-recorder.ts +35 -0
  94. package/src/tools/find.ts +25 -29
  95. package/src/tools/gh-format.ts +12 -0
  96. package/src/tools/gh-renderer.ts +1 -8
  97. package/src/tools/gh.ts +6 -13
  98. package/src/tools/grep.ts +103 -59
  99. package/src/tools/jtd-to-json-schema.ts +16 -0
  100. package/src/tools/match-line-format.ts +20 -0
  101. package/src/tools/path-utils.ts +61 -5
  102. package/src/tools/plan-mode-guard.ts +6 -5
  103. package/src/tools/python.ts +1 -1
  104. package/src/tools/read.ts +1 -1
  105. package/src/tools/render-utils.ts +38 -6
  106. package/src/tools/renderers.ts +1 -0
  107. package/src/tools/resolve.ts +12 -3
  108. package/src/tools/ssh.ts +3 -11
  109. package/src/tools/submit-result.ts +1 -13
  110. package/src/tools/todo-write.ts +137 -103
  111. package/src/tools/vim.ts +1 -1
  112. package/src/tools/write.ts +2 -23
  113. package/src/tui/code-cell.ts +12 -7
  114. package/src/utils/edit-mode.ts +3 -2
  115. package/src/utils/git.ts +1 -1
  116. package/src/vim/engine.ts +41 -58
  117. package/src/web/scrapers/crates-io.ts +1 -14
  118. package/src/web/scrapers/types.ts +13 -0
  119. package/src/web/search/providers/base.ts +13 -0
  120. package/src/web/search/providers/brave.ts +2 -5
  121. package/src/web/search/providers/codex.ts +20 -24
  122. package/src/web/search/providers/gemini.ts +39 -1
  123. package/src/web/search/providers/jina.ts +2 -5
  124. package/src/web/search/providers/kagi.ts +3 -8
  125. package/src/web/search/providers/kimi.ts +3 -7
  126. package/src/web/search/providers/parallel.ts +3 -8
  127. package/src/web/search/providers/synthetic.ts +3 -7
  128. package/src/web/search/providers/tavily.ts +15 -11
  129. package/src/web/search/providers/utils.ts +36 -0
  130. package/src/web/search/providers/zai.ts +3 -7
@@ -0,0 +1,67 @@
1
+ ## `apply_patch`
2
+
3
+ Use the `apply_patch` shell command to edit files.
4
+ Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:
5
+
6
+ *** Begin Patch
7
+ [ one or more file sections ]
8
+ *** End Patch
9
+
10
+ Within that envelope, you get a sequence of file operations.
11
+ You **MUST** include a header to specify the action you are taking.
12
+ Each operation starts with one of three headers:
13
+
14
+ *** Add File: <path> - create a new file. Every following line is a + line (the initial contents).
15
+ *** Delete File: <path> - remove an existing file. Nothing follows.
16
+ *** Update File: <path> - patch an existing file in place (optionally with a rename).
17
+
18
+ May be immediately followed by *** Move to: <new path> if you want to rename the file.
19
+ Then one or more "hunks", each introduced by @@ (optionally followed by a hunk header).
20
+ Within a hunk each line starts with:
21
+
22
+ For instructions on [context_before] and [context_after]:
23
+ - By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change's [context_after] lines in the second change's [context_before] lines.
24
+ - If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:
25
+ @@ class BaseClass
26
+ [3 lines of pre-context]
27
+ - [old_code]
28
+ + [new_code]
29
+ [3 lines of post-context]
30
+ - If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:
31
+
32
+ @@ class BaseClass
33
+ @@ def method():
34
+ [3 lines of pre-context]
35
+ - [old_code]
36
+ + [new_code]
37
+ [3 lines of post-context]
38
+
39
+ The full grammar definition is below:
40
+ Patch := Begin { FileOp } End
41
+ Begin := "*** Begin Patch" NEWLINE
42
+ End := "*** End Patch" NEWLINE
43
+ FileOp := AddFile | DeleteFile | UpdateFile
44
+ AddFile := "*** Add File: " path NEWLINE { "+" line NEWLINE }
45
+ DeleteFile := "*** Delete File: " path NEWLINE
46
+ UpdateFile := "*** Update File: " path NEWLINE [ MoveTo ] { Hunk }
47
+ MoveTo := "*** Move to: " newPath NEWLINE
48
+ Hunk := "@@" [ header ] NEWLINE { HunkLine } [ "*** End of File" NEWLINE ]
49
+ HunkLine := (" " | "-" | "+") text NEWLINE
50
+
51
+ A full patch can combine several operations:
52
+
53
+ *** Begin Patch
54
+ *** Add File: hello.txt
55
+ +Hello world
56
+ *** Update File: src/app.py
57
+ *** Move to: src/main.py
58
+ @@ def greet():
59
+ -print("Hi")
60
+ +print("Hello, world!")
61
+ *** Delete File: obsolete.txt
62
+ *** End Patch
63
+
64
+ It is important to remember:
65
+ - You must include a header with your intended action (Add/Delete/Update)
66
+ - You must prefix new lines with `+` even when creating a new file
67
+ - File references can only be relative, NEVER ABSOLUTE.
@@ -2,47 +2,42 @@ Performs structural AST-aware rewrites via native ast-grep.
2
2
 
3
3
  <instruction>
4
4
  - Use for codemods and structural rewrites where plain text replace is unsafe
5
- - Narrow scope with `path` before replacing (`path` accepts files, directories, glob patterns, or comma-separated path lists; use `glob` for an additional filter relative to `path`)
6
- - Default to language-scoped rewrites in mixed repositories: set `lang` and keep `path`/`glob` narrow
7
- - Treat parse issues as a scoping or pattern-shape signal: tighten `path`/`lang`, or rewrite the pattern into valid syntax before retrying
8
- - Metavariables captured in each rewrite pattern (`$A`, `$$$ARGS`) are substituted into that entry's rewrite template
9
- - For variadic captures (arguments, fields, statement lists), use `$$$NAME` (not `$$NAME`)
10
- - Rewrite patterns must parse as valid AST for the target language; if a method or declaration does not parse standalone, wrap it in valid context or switch to a contextual `sel`
11
- - If ast-grep reports `Multiple AST nodes are detected`, the rewrite pattern is not a single parseable node; wrap method snippets in valid context (for example `class $_ { }`) and use `sel` to rewrite the inner node
12
- - When using contextual `sel`, the match and replacement target the selected node, not the outer wrapper you used to make the pattern parse
13
- - For TypeScript declarations and methods, prefer patterns that tolerate annotations you do not care about, e.g. `async function $NAME($$$ARGS): $_ { $$$BODY }` or `class $_ { method($ARG: $_): $_ { $$$BODY } }`
14
- - Metavariables must be the sole content of an AST node; partial-text metavariables like `prefix$VAR` or `"hello $NAME"` do NOT work in patterns or rewrites
15
- - To delete matched code, use an empty `out` string: `{"pat":"console.log($$$)","out":""}`
16
- - Each matched rewrite is a 1:1 structural substitution; you cannot split one capture into multiple nodes or merge multiple captures into one node
5
+ - `path` accepts a comma-separated list in addition to file/dir/glob
6
+ - Set `lang` explicitly in mixed-language trees for deterministic rewrites
7
+ - Metavariables captured in `pat` (`$A`, `$$$ARGS`) are substituted into that entry's `out` template
8
+ - **Patterns match AST structure, not text.** `$NAME` = one node (captured); `$_` = one without binding; `$$$NAME` = zero-or-more (lazy — stops at next matchable element); `$$$` = zero-or-more without binding. Use `$$$NAME`, **NOT** `$$NAME` — the two-dollar form is invalid. Metavariable names are UPPERCASE and **MUST** be the whole AST node — partial text like `prefix$VAR` or `"hello $NAME"` does NOT work
9
+ - When the same metavariable appears twice, both occurrences **MUST** match identical code (`$A == $A` matches `x == x`, not `x == y`)
10
+ - Rewrite patterns **MUST** parse as a single valid AST node. For method fragments or body snippets that don't parse standalone, wrap in context (e.g. `class $_ { … }`) and set `sel` to target the inner node — match and replacement target the selected node, not the wrapper. If ast-grep reports `Multiple AST nodes are detected`, wrap and use `sel`
11
+ - For TS declarations/methods, tolerate unknown annotations: `async function $NAME($$$ARGS): $_ { $$$BODY }` or `class $_ { method($ARG: $_): $_ { $$$BODY } }`
12
+ - Delete matched code with empty `out`: `{"pat":"console.log($$$)","out":""}`
13
+ - Each rewrite is a 1:1 structural substitution cannot split one capture across multiple nodes or merge multiple captures into one
17
14
  </instruction>
18
15
 
19
16
  <output>
20
- - Returns replacement summary, per-file replacement counts, and change diffs
21
- - Includes parse issues when files cannot be processed
17
+ - Replacement summary, per-file replacement counts, and change diffs
18
+ - Parse issues when files cannot be processed
22
19
  </output>
23
20
 
24
21
  <examples>
25
22
  - Rename a call site across a directory:
26
23
  `{"ops":[{"pat":"oldApi($$$ARGS)","out":"newApi($$$ARGS)"}],"lang":"typescript","path":"src/"}`
27
- - Delete all matching calls (empty `out` removes the matched node):
24
+ - Delete matching calls (empty `out` removes the node):
28
25
  `{"ops":[{"pat":"console.log($$$ARGS)","out":""}],"lang":"typescript","path":"src/"}`
29
- - Rewrite an import source path:
26
+ - Rewrite import source path:
30
27
  `{"ops":[{"pat":"import { $$$IMPORTS } from \"old-package\"","out":"import { $$$IMPORTS } from \"new-package\""}],"lang":"typescript","path":"src/"}`
31
28
  - Modernize to optional chaining (same metavariable enforces identity):
32
29
  `{"ops":[{"pat":"$A && $A()","out":"$A?.()"}],"lang":"typescript","path":"src/"}`
33
30
  - Swap two arguments using captures:
34
31
  `{"ops":[{"pat":"assertEqual($A, $B)","out":"assertEqual($B, $A)"}],"lang":"typescript","path":"tests/"}`
35
- - Rename a TypeScript function declaration while tolerating any return type annotation:
32
+ - Rename a function declaration while tolerating any return type annotation:
36
33
  `{"ops":[{"pat":"async function fetchData($$$ARGS): $_ { $$$BODY }","out":"async function loadData($$$ARGS): $_ { $$$BODY }"}],"sel":"function_declaration","lang":"typescript","path":"src/api.ts"}`
37
- - Rewrite a TypeScript method body fragment by wrapping it in parseable context and selecting the method node:
34
+ - Rewrite a method body fragment by wrapping in parseable context and selecting the method:
38
35
  `{"ops":[{"pat":"class $_ { async execute($INPUT: $_) { $$$BEFORE; const $PARSED = $_.parse($INPUT); $$$AFTER } }","out":"class $_ { async execute($INPUT: $_) { $$$BEFORE; const $PARSED = $SCHEMA.parse($INPUT); $$$AFTER } }"}],"sel":"method_definition","lang":"typescript","path":"src/tools/todo.ts"}`
39
- - Convert Python print calls to logging:
36
+ - Python — convert print calls to logging:
40
37
  `{"ops":[{"pat":"print($$$ARGS)","out":"logger.info($$$ARGS)"}],"lang":"python","path":"src/"}`
41
38
  </examples>
42
39
 
43
40
  <critical>
44
- - `ops` **MUST** contain at least one concrete `{ pat, out }` entry
45
- - If the path pattern spans multiple languages, set `lang` explicitly for deterministic rewrites
46
- - Parse issues mean the rewrite request is malformed or mis-scoped; do not assume a clean no-op until the pattern parses successfully
47
- - For one-off local text edits, prefer the Edit tool instead of AST edit
41
+ - Parse issues mean the rewrite is malformed or mis-scoped fix the pattern before assuming a clean no-op
42
+ - For one-off local text edits, prefer the Edit tool
48
43
  </critical>
@@ -1,54 +1,47 @@
1
1
  Performs structural code search using AST matching via native ast-grep.
2
2
 
3
3
  <instruction>
4
- - Use this when syntax shape matters more than raw text (calls, declarations, specific language constructs)
5
- - Prefer a precise `path` scope to keep results targeted and deterministic (`path` accepts files, directories, glob patterns, or comma-separated path lists; use `glob` for an additional filter relative to `path`)
6
- - Default to language-scoped search in mixed repositories: pair `path` + `glob` + explicit `lang` to avoid parse-noise from non-source files
7
- - `pat` is required and must include at least one non-empty AST pattern; `lang` is optional (`lang` is inferred per file extension when omitted)
8
- - Multiple patterns run in one native pass; results are merged and then `offset`/`limit` are applied to the combined match set
9
- - Use `sel` only for contextual pattern mode; otherwise provide direct patterns
10
- - In contextual pattern mode, results are returned for the selected node (`sel`), not the outer wrapper used to make the pattern parse
11
- - For variadic captures (arguments, fields, statement lists), use `$$$NAME` (not `$$NAME`)
12
- - Patterns must parse as a single valid AST node for the target language; if a bare pattern fails, wrap it in valid context or use `sel`
13
- - If ast-grep reports `Multiple AST nodes are detected`, your pattern is not a single parseable node; wrap method snippets in valid context (for example `class $_ { }`) and use `sel` to target the inner node
14
- - Patterns match AST structure, not text whitespace/formatting differences are ignored
15
- - When the same metavariable appears multiple times, all occurrences must match identical code
16
- - For TypeScript declarations and methods, prefer shapes that tolerate annotations you do not care about, e.g. `async function $NAME($$$ARGS): $_ { $$$BODY }` or `class $_ { method($ARG: $_): $_ { $$$BODY } }` instead of omitting annotations entirely
17
- - Metavariables must be the sole content of an AST node; partial-text metavariables like `prefix$VAR`, `"hello $NAME"`, or `a $OP b` do NOT work — match the whole node instead
18
- - `$$$` captures are lazy (non-greedy): they stop when the next element in the pattern can match; place the most specific node after `$$$` to control where capture ends
19
- - `$_` is a non-capturing wildcard (matches any single node without binding); use it when you need to tolerate a node but don't need its value
20
- - Search the right declaration form before concluding absence: top-level function, class method, and variable-assigned function are different AST shapes
21
- - If you only need to prove a symbol exists, prefer a looser contextual search such as `pat: ["executeBash"]` with `sel: "identifier"`
4
+ - Use when syntax shape matters more than raw text (calls, declarations, specific language constructs)
5
+ - `path` accepts a comma-separated list in addition to file/dir/glob
6
+ - Set `lang` explicitly in mixed-language trees to avoid parse noise from non-source files
7
+ - Multiple patterns in `pat` run in one native pass, merged, then `offset`/`limit` applied
8
+ - **Patterns match AST structure, not text** whitespace/formatting is ignored
9
+ - `$NAME` captures one node; `$_` matches one without binding; `$$$NAME` captures zero-or-more (lazy stops at next matchable element); `$$$` matches zero-or-more without binding. Use `$$$NAME`, **NOT** `$$NAME` — the two-dollar form is invalid and produces a parse error
10
+ - Metavariable names are UPPERCASE and must be the whole AST node — partial-text like `prefix$VAR`, `"hello $NAME"`, or `a $OP b` does NOT work; match the whole node instead
11
+ - When the same metavariable appears twice, both occurrences **MUST** match identical code (`$A == $A` matches `x == x`, not `x == y`)
12
+ - Patterns **MUST** parse as a single valid AST node for the target language. For method fragments or body snippets that don't parse standalone, wrap in valid context (e.g. `class $_ { … }`) and set `sel` to target the inner node — results return for the selected node, not the outer wrapper. If ast-grep reports `Multiple AST nodes are detected`, the pattern isn't a single parseable node — wrap and use `sel`
13
+ - C++ qualified calls used as expression statements need the statement semicolon in the pattern: use `ns::doThing($ARG);`, `$CALLEE($ARG)`, or wrap a statement snippet and select `call_expression`. Without `;`, tree-sitter-cpp may parse `ns::doThing($ARG)` as declaration-like syntax and return no matches
14
+ - For TS declarations/methods, tolerate unknown annotations: `async function $NAME($$$ARGS): $_ { $$$BODY }` or `class $_ { method($ARG: $_): $_ { $$$BODY } }`
15
+ - Declaration forms are structurally distinct top-level `function foo`, class method `foo()`, and `const foo = () => {}` are different AST shapes; search the right form before concluding absence
16
+ - Loosest existence check: `pat: ["executeBash"]` with `sel: "identifier"`
22
17
  </instruction>
23
18
 
24
19
  <output>
25
- - Returns grouped matches with file path, byte range, line/column ranges, and metavariable captures
26
- - Includes summary counts (`totalMatches`, `filesWithMatches`, `filesSearched`) and parse issues when present
20
+ - Grouped matches with file path, byte range, line/column ranges, metavariable captures
21
+ - Summary counts (`totalMatches`, `filesWithMatches`, `filesSearched`) and parse issues when present
27
22
  </output>
28
23
 
29
24
  <examples>
30
- - Find all console logging calls in one pass (multi-pattern, scoped):
25
+ - Multi-pattern scoped search:
31
26
  `{"pat":["console.log($$$)","console.error($$$)"],"lang":"typescript","path":"src/"}`
32
- - Find all named imports from a specific package:
27
+ - Named imports from a specific package (quoted string inside pattern):
33
28
  `{"pat":["import { $$$IMPORTS } from \"react\""],"lang":"typescript","path":"src/"}`
34
- - Match arrow functions assigned to a const (different AST shape than function declarations):
29
+ - Arrow functions assigned to a const (distinct AST from function declarations):
35
30
  `{"pat":["const $NAME = ($$$ARGS) => $BODY"],"lang":"typescript","path":"src/utils/"}`
36
- - Match any method call on an object using wildcard `$_` (ignores method name):
31
+ - Method call on any object, ignoring method name with `$_`:
37
32
  `{"pat":["logger.$_($$$ARGS)"],"lang":"typescript","path":"src/"}`
38
- - Contextual pattern with selector — match only the identifier `foo`, not the whole call:
33
+ - Contextual pattern with selector — match the identifier `foo`, not the whole call:
39
34
  `{"pat":["foo()"],"sel":"identifier","lang":"typescript","path":"src/utils.ts"}`
40
- - Match a TypeScript function declaration without caring about its exact return type:
35
+ - Match a function declaration while tolerating any return type annotation (`sel` targets the inner node):
41
36
  `{"pat":["async function processItems($$$ARGS): $_ { $$$BODY }"],"sel":"function_declaration","lang":"typescript","path":"src/worker.ts"}`
42
- - Match a TypeScript method body fragment by wrapping it in parseable context and selecting the method node:
37
+ - Match a method body fragment by wrapping in parseable context and selecting the method:
43
38
  `{"pat":["class $_ { async execute($INPUT: $_) { $$$BEFORE; const $PARSED = $_.parse($INPUT); $$$AFTER } }"],"sel":"method_definition","lang":"typescript","path":"src/tools/todo.ts"}`
44
39
  - Loosest existence check for a symbol in one file:
45
40
  `{"pat":["processItems"],"sel":"identifier","lang":"typescript","path":"src/worker.ts"}`
46
41
  </examples>
47
42
 
48
43
  <critical>
49
- - `pat` is required
50
- - Set `lang` explicitly to constrain matching when path pattern spans mixed-language trees
51
- - Avoid repo-root AST scans when the target is language-specific; narrow `path` first
52
- - Treat parse issues as query failure, not evidence of absence: repair the pattern or tighten `path`/`glob`/`lang` before concluding "no matches"
53
- - If exploration is broad/open-ended across subsystems, use Task tool with explore subagent first
44
+ - Avoid repo-root AST scans when the target is language-specific — narrow `path` first
45
+ - Parse issues are query failure, not evidence of absence: repair the pattern or tighten `path`/`glob`/`lang` before concluding "no matches"
46
+ - For broad/open-ended exploration across subsystems, use Task tool with explore subagent first
54
47
  </critical>
@@ -2,44 +2,34 @@ Executes bash command in shell session for terminal operations like git, bun, ca
2
2
 
3
3
  <instruction>
4
4
  - You **MUST** use `cwd` parameter to set working directory instead of `cd dir && …`
5
- - Prefer `env: { NAME: "…" }` for multiline, quote-heavy, or untrusted values instead of inlining them into shell syntax; reference them from the command as `$NAME`
5
+ - Prefer `env: { NAME: "…" }` for multiline, quote-heavy, or untrusted values; reference them as `$NAME`
6
6
  - Quote variable expansions like `"$NAME"` to preserve exact content and avoid shell parsing bugs
7
- - PTY mode is opt-in: set `pty: true` only when command expects a real terminal (for example `sudo`, `ssh` where you need input from the user); default is `false`
7
+ - PTY mode is opt-in: set `pty: true` only when the command needs a real terminal (e.g. `sudo`, `ssh` requiring user input); default is `false`
8
8
  - You **MUST** use `;` only when later commands should run regardless of earlier failures
9
- - `skill://` URIs are auto-resolved to filesystem paths before execution
10
- - `python skill://my-skill/scripts/init.py` runs the script from the skill directory
11
- - `skill://<name>/<relative-path>` resolves within the skill's base directory
12
- - Internal URLs are also auto-resolved to filesystem paths before execution.
9
+ - Internal URIs (`skill://`, `agent://`, etc.) are auto-resolved to filesystem paths. Examples: `python skill://my-skill/scripts/init.py` runs the skill script; `skill://<name>/<relative-path>` resolves within the skill directory.
13
10
  {{#if asyncEnabled}}
14
11
  - Use `async: true` for long-running commands when you don't need immediate output; the call returns a background job ID and the result is delivered automatically as a follow-up.
15
12
  {{/if}}
16
13
  {{#if autoBackgroundEnabled}}
17
- - Long-running non-PTY bash commands may auto-background after about {{autoBackgroundThresholdSeconds}}s and continue as background jobs automatically.
14
+ - Long-running non-PTY commands may auto-background after ~{{autoBackgroundThresholdSeconds}}s and continue as background jobs.
18
15
  {{/if}}
19
16
  {{#if asyncEnabled}}
17
+ - Inspect background jobs with `read jobs://` (`read jobs://<job-id>` for detail). To wait for results, call `poll` — do NOT poll `read jobs://` in a loop or yield and hope for delivery.
20
18
  {{else}}
21
19
  {{#if autoBackgroundEnabled}}
22
- - Auto-backgrounded jobs use the same background-job pipeline as explicit async execution.
23
- {{/if}}
24
- {{/if}}
25
- {{#if asyncEnabled}}
26
- - Use `read jobs://` to inspect all background jobs and `read jobs://<job-id>` for detailed status/output when needed.
27
- - When you need to wait for async results before continuing, call `poll` — it blocks until jobs complete. Do NOT poll `read jobs://` in a loop or yield and hope for delivery.
28
- {{else}}
29
- {{#if autoBackgroundEnabled}}
30
- - If a command auto-backgrounds, use `read jobs://` to inspect jobs and `poll` when you need to wait for completion instead of polling in a loop.
20
+ - For auto-backgrounded jobs, inspect with `read jobs://` and call `poll` to wait — do NOT poll in a loop.
31
21
  {{/if}}
32
22
  {{/if}}
33
23
  </instruction>
34
24
 
35
25
  <output>
36
- Returns the output, and an exit code from command execution.
37
- - If output truncated, full output can be retrieved from `artifact://<id>`, linked in metadata
26
+ Returns output and exit code.
27
+ - Truncated output is retrievable from `artifact://<id>` (linked in metadata)
38
28
  - Exit codes shown on non-zero exit
39
29
  </output>
40
30
 
41
31
  <critical>
42
- You **MUST** use specialized tools instead of bash for ALL file operations:
32
+ You **MUST NOT** use bash for file operations where specialized tools exist:
43
33
 
44
34
  |Instead of (WRONG)|Use (CORRECT)|
45
35
  |---|---|
@@ -52,11 +42,9 @@ You **MUST** use specialized tools instead of bash for ALL file operations:
52
42
  |`ls dir/`|`read(path="dir/")`|
53
43
  |`cat <<'EOF' > file`|`write(path="file", content="…")`|
54
44
  |`sed -i 's/old/new/' file`|`edit(path="file", edits=[…])`|
55
-
56
45
  {{#if hasAstEdit}}|`sed -i 's/oldFn(/newFn(/' src/*.ts`|`ast_edit({ops:[{pat:"oldFn($$$A)", out:"newFn($$$A)"}], path:"src/"})`|{{/if}}
57
46
  {{#if hasAstGrep}}- You **MUST** use `ast_grep` for structural code search instead of bash `grep`/`awk`/`perl` pipelines{{/if}}
58
47
  {{#if hasAstEdit}}- You **MUST** use `ast_edit` for structural rewrites instead of bash `sed`/`awk`/`perl` pipelines{{/if}}
59
- - You **MUST NOT** use Bash for these operations like read, grep, find, edit, write, where specialized tools exist.
60
- - You **MUST NOT** use `2>&1` | `2>/dev/null` pattern, stdout and stderr are already merged.
61
- - You **MUST NOT** use `| head -n 50` or `| tail -n 100` pattern, use `head` and `tail` parameters instead.
48
+ - You **MUST NOT** use `2>&1` or `2>/dev/null` stdout and stderr are already merged
49
+ - You **MUST NOT** use `| head -n 50` or `| tail -n 100` use `head`/`tail` parameters instead
62
50
  </critical>
@@ -1,33 +1,19 @@
1
1
  Provides debugger access through the Debug Adapter Protocol (DAP). Use this to launch or attach debuggers, set breakpoints, step through execution, inspect threads/stack/variables, evaluate expressions, capture program output, and interrupt hung programs.
2
2
 
3
3
  <instruction>
4
- - Prefer this over bash when you need program state, breakpoints, stepping, thread inspection, or to interrupt a running process.
5
- - `action: "launch"` starts a debugger session for a program or script. `program` is required. `adapter` is optional; when omitted, the tool selects an installed adapter from the target path and workspace.
6
- - `action: "attach"` connects to an existing process. Provide `pid` for local process attach or `port` for adapters that support remote attach. Use `adapter` to force a specific debugger.
7
- - Breakpoints:
8
- - Source breakpoints: `set_breakpoint` / `remove_breakpoint` with `file` + `line`
9
- - Function breakpoints: `set_breakpoint` / `remove_breakpoint` with `function`
10
- - Optional `condition` adds a conditional breakpoint expression
11
- - Flow control:
12
- - `continue` resumes execution and waits briefly to see whether the program stops or keeps running
13
- - `step_over`, `step_in`, `step_out` perform single-step execution
14
- - `pause` interrupts a running program so you can inspect the current state
15
- - Inspection:
16
- - `threads` lists threads
17
- - `stack_trace` returns frames for the current stopped thread
18
- - `scopes` requires `frame_id` or a current stopped frame
19
- - `variables` requires `variable_ref` or `scope_id`
20
- - `evaluate` requires `expression`; use `context: "repl"` for raw debugger commands when the adapter supports them
21
- - `output` returns captured stdout/stderr/console output from the debuggee and adapter
22
- - `sessions` lists tracked debug sessions
23
- - `terminate` ends the active debug session
24
- - Timeouts apply to individual debugger requests, not the full session lifetime.
4
+ - Prefer over bash for program state, breakpoints, stepping, thread inspection, or interrupting a running process.
5
+ - `action: "launch"` starts a session; `program` is required, `adapter` optional (auto-selected from target path and workspace).
6
+ - `action: "attach"` connects to an existing process: `pid` for local attach, `port` for remote attach (where the adapter supports it), `adapter` to force a specific debugger.
7
+ - **Breakpoints**: `set_breakpoint`/`remove_breakpoint` with source (`file`+`line`) or function (`function`); optional `condition` for conditional breakpoints.
8
+ - **Flow control**: `continue` (resumes; briefly waits to observe whether the program stops or keeps running), `step_over`/`step_in`/`step_out` (single-step), `pause` (interrupt a running program so you can inspect state).
9
+ - **Inspect**: `threads` (list), `stack_trace` (frames for current stopped thread), `scopes` (needs `frame_id` or a current stopped frame), `variables` (needs `variable_ref` or `scope_id`), `evaluate` (needs `expression`; `context: "repl"` for raw debugger commands when the adapter supports them), `output` (captured stdout/stderr/console), `sessions` (tracked debug sessions), `terminate`.
10
+ - Timeouts apply per-request, not to the full session lifetime.
25
11
  </instruction>
26
12
 
27
13
  <caution>
28
14
  - Only one active debug session is supported at a time.
29
15
  - Some adapters require a launched session to receive `configurationDone` before the target actually runs; if the tool says configuration is pending, set breakpoints and then call `continue`.
30
- - Adapter availability depends on local binaries. Common built-ins are `gdb`, `lldb-dap`, `python -m debugpy.adapter`, and `dlv dap`.
16
+ - Adapter availability depends on local binaries. Common built-ins: `gdb`, `lldb-dap`, `python -m debugpy.adapter`, `dlv dap`.
31
17
  </caution>
32
18
 
33
19
  <example name="launch and inspect hang">
@@ -1,10 +1,6 @@
1
1
  Finds files using fast pattern matching that works with any codebase size.
2
2
 
3
3
  <instruction>
4
- - Pattern includes the search path: `src/**/*.ts`, `lib/*.json`, `**/*.md`
5
- - You may provide comma-separated path lists, for example `apps/,packages/,phases/`
6
- - Simple patterns like `*.ts` automatically search recursively from cwd
7
- - Includes hidden files by default (use `hidden: false` to exclude)
8
4
  - You **SHOULD** perform multiple searches in parallel when potentially useful
9
5
  </instruction>
10
6
 
@@ -2,11 +2,9 @@ Searches files using powerful regex matching.
2
2
 
3
3
  <instruction>
4
4
  - Supports full regex syntax (e.g., `log.*Error`, `function\\s+\\w+`); literal braces need escaping (`interface\\{\\}` for `interface{}` in Go)
5
- - `path` may be a file, directory, glob path, or comma-separated path list; pair it with `glob` when you need an additional relative file filter
6
- - Filter files with `glob` (e.g., `*.js`, `**/*.tsx`) or `type` (e.g., `js`, `py`, `rust`)
7
- - Respects `.gitignore` by default; set `gitignore: false` to include ignored files
8
- - For cross-line patterns like `struct \\{[\\s\\S]*?field`, set `multiline: true` if needed
9
- - If the pattern contains a literal `\n`, multiline defaults to true
5
+ - `path` also accepts comma-separated path lists; pair with `glob` when you need a relative file filter in addition to `type`
6
+ - For cross-line patterns like `struct \\{[\\s\\S]*?field`, set `multiline: true`
7
+ - If the pattern contains a literal `\n`, `multiline` defaults to true automatically
10
8
  </instruction>
11
9
 
12
10
  <output>
@@ -16,11 +16,12 @@ Read the file first. Copy anchors exactly from the latest `read` output. After a
16
16
  **`loc` values**
17
17
  - `"append"` / `"prepend"` — insert at end/start of file
18
18
  - `{ append: "N#ID" }` / `{ prepend: "N#ID" }` — insert after/before anchored line
19
- - `{ range: { pos: "N#ID", end: "N#ID" } }` — replace inclusive range of lines `pos..end` with new content
20
- </operations>
19
+ - `{ range: { pos: "N#ID", end: "N#ID" } }` — replace inclusive range `pos..end` with new content (set `pos == end` for single-line replace)
20
+ </operations>
21
21
 
22
22
  <examples>
23
23
  All examples below reference the same file:
24
+
24
25
  ```ts title="a.ts"
25
26
  {{hline 1 "// @ts-ignore"}}
26
27
  {{hline 2 "const timeout = 5000;"}}
@@ -44,6 +45,7 @@ All examples below reference the same file:
44
45
 
45
46
  <example name="replace a block body">
46
47
  Replace only the catch body. Do not target the shared boundary line `} catch (err) {`.
48
+
47
49
  ```
48
50
  {
49
51
  edits: [{
@@ -60,6 +62,7 @@ Replace only the catch body. Do not target the shared boundary line `} catch (er
60
62
 
61
63
  <example name="replace whole block including closing brace">
62
64
  Replace the entire body of `alpha`, including its closing `}`. `end` **MUST** be {{href 7 "}"}} because `content` includes `}`.
65
+
63
66
  ```
64
67
  {
65
68
  edits: [{
@@ -73,10 +76,13 @@ Replace the entire body of `alpha`, including its closing `}`. `end` **MUST** be
73
76
  }]
74
77
  }
75
78
  ```
76
- **Wrong**: using `end: {{href 6 "\tlog();"}}` with the same content — line 7 (`}`) survives the replacement AND content emits `}`, producing two closing braces.
79
+
80
+ **Wrong**: `end: {{href 6 "\tlog();"}}` with the same content — line 7 (`}`) survives AND content emits `}`, producing two closing braces.
77
81
  </example>
78
82
 
79
83
  <example name="replace one line">
84
+ Single-line replace uses `pos == end`.
85
+
80
86
  ```
81
87
  {
82
88
  edits: [{
@@ -102,6 +108,7 @@ Replace the entire body of `alpha`, including its closing `}`. `end` **MUST** be
102
108
 
103
109
  <example name="insert before sibling">
104
110
  When adding a sibling declaration, prefer `prepend` on the next declaration.
111
+
105
112
  ```
106
113
  {
107
114
  edits: [{
@@ -120,12 +127,11 @@ When adding a sibling declaration, prefer `prepend` on the next declaration.
120
127
  </examples>
121
128
 
122
129
  <critical>
123
- - Make the minimum exact edit. Do not rewrite nearby code unless the consumed range requires it.
124
- - Use anchors exactly as `N#ID` from the latest `read` output.
130
+ - Make the minimum exact edit. Do not rewrite nearby code unless the range requires it.
131
+ - Copy anchors exactly as `N#ID` from the latest `read` output.
125
132
  - `range` requires both `pos` and `end`.
126
- - When your replacement `content` ends with a closing delimiter (`}`, `*/`, `)`, `]`), verify `end` includes the original line carrying that delimiter. If `end` stops one line too early, the original delimiter survives and your content adds a second copy.
127
- - **Self-check**: compare the last line of `content` with the line immediately after `end` in the file. If they match (e.g., both are `}`), extend `end` to include that line.
128
- - For a range, either replace only the body or replace the whole range. Do not split range boundaries.
133
+ - **Closing-delimiter check**: when your replacement `content` ends with a closing delimiter (`}`, `*/`, `)`, `]`), compare it against the line immediately after `end` in the file. If they match, extend `end` to include that line otherwise the original delimiter survives and `content` adds a second copy.
134
+ - For a range, replace only the body or the whole range don't split range boundaries.
129
135
  - `content` must be literal file content with matching indentation. If the file uses tabs, use real tabs.
130
- - You **MUST NOT** use this tool to reformat or clean up unrelated code. **ALWAYS** use project-specific tooling like linters or code formatters which are much more efficient and reliable.
131
- </critical>
136
+ - You **MUST NOT** use this tool to reformat or clean up unrelated code use project-specific linters or code formatters instead.
137
+ </critical>
@@ -1,15 +1,11 @@
1
1
  Runs Python cells sequentially in persistent IPython kernel.
2
2
 
3
3
  <instruction>
4
- Kernel persists across calls and cells; **imports, variables, and functions survive—use this.**
5
- **Work incrementally:**
6
- - You **SHOULD** use one logical step per cell (imports, define function, test it, use it)
7
- - You **SHOULD** pass multiple small cells in one call
8
- - You **SHOULD** define small functions you can reuse and debug individually
9
- - You **MUST** put workflow explanations in assistant message or cell title
10
- **When something fails:**
11
- - Errors tell you which cell failed (e.g., "Cell 3 failed")
12
- - You **SHOULD** resubmit only the fixed cell (or fixed cell + remaining cells)
4
+ Kernel persists across calls and cells; **imports, variables, and functions survive use this.**
5
+
6
+ **Work incrementally:** one logical step per cell (imports, define, test, use). Pass multiple small cells in one call. Define small reusable functions you can debug individually. You **MUST** put workflow explanations in the assistant message or cell title — never inside cell code.
7
+
8
+ **On failure:** errors identify the failing cell (e.g., "Cell 3 failed"). Resubmit only the fixed cell (or fixed cell + remaining cells).
13
9
  </instruction>
14
10
 
15
11
  {{#if categories.length}}
@@ -35,21 +31,21 @@ User sees output like Jupyter notebook; rich displays render fully:
35
31
  - `display(HTML(…))` → rendered HTML
36
32
  - `display(Markdown(…))` → formatted markdown
37
33
  - `plt.show()` → inline figures
38
- **You will see object repr** (e.g., `<IPython.core.display.JSON object>`). Trust `display()`; you **MUST NOT** assume user sees only repr.
34
+
35
+ **You will see object repr** (e.g., `<IPython.core.display.JSON object>`). Trust `display()`; you **MUST NOT** assume the user sees only the repr.
39
36
  </output>
40
37
 
41
38
  <caution>
42
- - Per-call mode uses fresh kernel each call
43
- - You **MUST** use `reset: true` to clear state when session mode active
39
+ - Per-call mode uses a fresh kernel each call
40
+ - You **MUST** use `reset: true` to clear state when session mode is active
44
41
  </caution>
45
42
 
46
43
  <critical>
47
44
  - You **MUST** use `run()` for shell commands; you **MUST NOT** use raw `subprocess`
48
45
  </critical>
49
46
 
50
- <example name="good">
47
+ <example name="multiple small cells">
51
48
  ```python
52
- # Multiple small cells
53
49
  cells: [
54
50
  {"title": "imports", "code": "import json\nfrom pathlib import Path"},
55
51
  {"title": "parse helper", "code": "def parse_config(path):\n return json.loads(Path(path).read_text())"},
@@ -1,13 +1,13 @@
1
1
  Reads the content at the specified path or URL.
2
2
 
3
3
  <instruction>
4
- The `read` tool is a multi-purpose tool that can be used to inspect all kinds of files and URLs.
4
+ The `read` tool is multi-purpose inspects files, directories, archives, SQLite databases, and URLs.
5
5
  - You **MUST** parallelize reads when exploring related files
6
6
 
7
7
  ## Parameters
8
- - `path` -- file path or URL (required)
9
- - `sel` -- optional selector for line ranges or raw mode
10
- - `timeout` -- seconds, for URLs only
8
+ - `path` file path or URL (required)
9
+ - `sel` optional selector for line ranges or raw mode
10
+ - `timeout` seconds, for URLs only
11
11
 
12
12
  ## Selectors
13
13
 
@@ -22,42 +22,35 @@ Max {{DEFAULT_MAX_LINES}} lines per call.
22
22
 
23
23
  # Filesystem
24
24
  {{#if IS_HASHLINE_MODE}}
25
- - If reading from FS, result will be prefixed with anchors: `41#ZZ:def alpha():`
25
+ - Reading from FS returns lines prefixed with anchors: `41#ZZ:def alpha():`
26
26
  {{else}}
27
- {{#if IS_LINE_NUMBER_MODE}}
28
- - If reading from FS, result will be prefixed with line numbers: `41:def alpha():`
29
- {{/if}}
27
+ {{#if IS_LINE_NUMBER_MODE}}
28
+ - Reading from FS returns lines prefixed with line numbers: `41:def alpha():`
29
+ {{/if}}
30
30
  {{/if}}
31
31
 
32
32
  # Inspection
33
- When used with a PDF, Word, PowerPoint, Excel, RTF, EPUB, or Jupyter notebook file, the tool will return the extracted text.
34
- It can also be used to inspect images.
33
+ Extracts text from PDF, Word, PowerPoint, Excel, RTF, EPUB, and Jupyter notebook files. Can inspect images.
35
34
 
36
35
  # Directories & Archives
37
- When used against a directory, or an archive root, the tool will return a list of directory entries within.
38
- - Formats: `.tar`, `.tar.gz`, `.tgz`, and `.zip`.
39
- - Use `archive.ext:path/inside/archive` to read or list archive contents
36
+ Directories and archive roots return a list of entries. Supports `.tar`, `.tar.gz`, `.tgz`, `.zip`. Use `archive.ext:path/inside/archive` to read contents.
40
37
 
41
38
  # SQLite Databases
42
- When used against a SQLite database (`.sqlite`, `.sqlite3`, `.db`, `.db3`), returns structured database content.
39
+ For `.sqlite`, `.sqlite3`, `.db`, `.db3`:
43
40
  - `file.db` — list tables with row counts
44
- - `file.db:table` — table schema + sample rows
41
+ - `file.db:table` — schema + sample rows
45
42
  - `file.db:table:key` — single row by primary key
46
43
  - `file.db:table?limit=50&offset=100` — paginated rows
47
44
  - `file.db:table?where=status='active'&order=created:desc` — filtered rows
48
45
  - `file.db?q=SELECT …` — read-only SELECT query
49
46
 
50
47
  # URLs
51
- - Extract information from web pages, GitHub issues/PRs, Stack Overflow, Wikipedia, Reddit, NPM, arXiv, technical blogs, RSS/Atom feeds, JSON endpoints
52
- - `sel="raw"` for untouched HTML or debugging
53
- - `timeout` to override the default request timeout
48
+ Extracts content from web pages, GitHub issues/PRs, Stack Overflow, Wikipedia, Reddit, NPM, arXiv, RSS/Atom feeds, JSON endpoints, and similar text-based resources. Use `sel="raw"` for untouched HTML; `timeout` to override the default request timeout.
54
49
  </instruction>
55
50
 
56
51
  <critical>
57
- - You **MUST** use `read` instead of bash for ALL file reading: `cat`, `head`, `tail`, `less`, `more` are FORBIDDEN.
58
- - You **MUST** use `read` instead of `ls` for directory listings.
59
- - You **MUST** use `read` instead of shelling out to `tar` or `unzip` for supported archive reads.
60
- - You **MUST** always include the `path` parameter, NEVER call `read` with empty arguments `{}`.
61
- - When reading specific line ranges, use `sel`: `read(path="file", sel="L50-L150")` not `cat -n file | sed`.
62
- - You **MAY** use `sel` with URL reads; the tool will paginate the cached fetched output.
52
+ - You **MUST** use `read` (never bash `cat`/`head`/`tail`/`less`/`more`/`ls`/`tar`/`unzip`) for all file, directory, and archive reads.
53
+ - You **MUST** always include the `path` parameter; never call with `{}`.
54
+ - For specific line ranges, use `sel`: `read(path="file", sel="L50-L150")` not `cat -n file | sed`.
55
+ - You **MAY** use `sel` with URL reads; the tool paginates cached fetched output.
63
56
  </critical>