@oh-my-pi/pi-coding-agent 13.3.6 → 13.3.8

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 (68) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/package.json +9 -18
  3. package/scripts/format-prompts.ts +7 -172
  4. package/src/capability/mcp.ts +5 -0
  5. package/src/cli/args.ts +1 -0
  6. package/src/config/prompt-templates.ts +9 -55
  7. package/src/config/settings-schema.ts +24 -0
  8. package/src/discovery/builtin.ts +1 -0
  9. package/src/discovery/codex.ts +1 -2
  10. package/src/discovery/helpers.ts +0 -5
  11. package/src/discovery/mcp-json.ts +2 -0
  12. package/src/internal-urls/docs-index.generated.ts +1 -1
  13. package/src/lsp/client.ts +8 -0
  14. package/src/lsp/config.ts +2 -3
  15. package/src/lsp/index.ts +379 -99
  16. package/src/lsp/render.ts +21 -31
  17. package/src/lsp/types.ts +21 -8
  18. package/src/lsp/utils.ts +193 -1
  19. package/src/mcp/config-writer.ts +3 -0
  20. package/src/mcp/config.ts +1 -0
  21. package/src/mcp/oauth-flow.ts +3 -1
  22. package/src/mcp/types.ts +5 -0
  23. package/src/modes/components/settings-defs.ts +9 -0
  24. package/src/modes/components/status-line.ts +1 -1
  25. package/src/modes/controllers/mcp-command-controller.ts +6 -2
  26. package/src/modes/interactive-mode.ts +8 -1
  27. package/src/modes/theme/mermaid-cache.ts +4 -4
  28. package/src/modes/theme/theme.ts +33 -0
  29. package/src/prompts/system/custom-system-prompt.md +0 -10
  30. package/src/prompts/system/subagent-user-prompt.md +2 -0
  31. package/src/prompts/system/system-prompt.md +12 -9
  32. package/src/prompts/tools/ast-find.md +20 -0
  33. package/src/prompts/tools/ast-replace.md +21 -0
  34. package/src/prompts/tools/bash.md +2 -0
  35. package/src/prompts/tools/hashline.md +26 -8
  36. package/src/prompts/tools/lsp.md +22 -5
  37. package/src/prompts/tools/task.md +0 -1
  38. package/src/sdk.ts +11 -5
  39. package/src/session/agent-session.ts +293 -83
  40. package/src/system-prompt.ts +3 -34
  41. package/src/task/executor.ts +8 -7
  42. package/src/task/index.ts +8 -55
  43. package/src/task/template.ts +2 -4
  44. package/src/task/types.ts +0 -5
  45. package/src/task/worktree.ts +6 -2
  46. package/src/tools/ast-find.ts +316 -0
  47. package/src/tools/ast-replace.ts +294 -0
  48. package/src/tools/bash.ts +2 -1
  49. package/src/tools/browser.ts +2 -8
  50. package/src/tools/fetch.ts +55 -18
  51. package/src/tools/index.ts +8 -0
  52. package/src/tools/jtd-to-json-schema.ts +29 -13
  53. package/src/tools/path-utils.ts +34 -0
  54. package/src/tools/python.ts +2 -1
  55. package/src/tools/renderers.ts +4 -0
  56. package/src/tools/ssh.ts +2 -1
  57. package/src/tools/submit-result.ts +143 -44
  58. package/src/tools/todo-write.ts +34 -0
  59. package/src/tools/tool-timeouts.ts +29 -0
  60. package/src/utils/mime.ts +37 -14
  61. package/src/utils/prompt-format.ts +172 -0
  62. package/src/web/scrapers/arxiv.ts +12 -12
  63. package/src/web/scrapers/go-pkg.ts +2 -2
  64. package/src/web/scrapers/iacr.ts +17 -9
  65. package/src/web/scrapers/readthedocs.ts +3 -3
  66. package/src/web/scrapers/twitter.ts +11 -11
  67. package/src/web/scrapers/wikipedia.ts +4 -5
  68. package/src/utils/ignore-files.ts +0 -119
@@ -0,0 +1,20 @@
1
+ Performs structural code search using AST matching via native ast-grep.
2
+
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, or glob patterns)
6
+ - `pattern` is required; `lang` is optional (`lang` is inferred per file extension when omitted)
7
+ - Use `selector` only for contextual pattern mode; otherwise provide a direct pattern
8
+ - Enable `include_meta` when metavariable captures are needed in output
9
+ </instruction>
10
+
11
+ <output>
12
+ - Returns grouped matches with file path, byte range, and line/column ranges
13
+ - Includes summary counts (`totalMatches`, `filesWithMatches`, `filesSearched`) and parse issues when present
14
+ </output>
15
+
16
+ <critical>
17
+ - `pattern` is required
18
+ - Set `lang` explicitly to constrain matching when path pattern spans mixed-language trees
19
+ - If exploration is broad/open-ended across subsystems, use Task tool with explore subagent first
20
+ </critical>
@@ -0,0 +1,21 @@
1
+ Performs structural AST-aware rewrites via native ast-grep.
2
+
3
+ <instruction>
4
+ - Use for codemods and structural rewrites where plain text replace is unsafe
5
+ - Narrow scope with `path` before replacing (`path` accepts files, directories, or glob patterns)
6
+ - `pattern` + `rewrite` are required; `lang` is optional only when all matched files resolve to a single language
7
+ - Keep `dry_run` enabled unless explicit apply intent is clear
8
+ - Use `max_files` and `max_replacements` as safety caps on broad rewrites
9
+ </instruction>
10
+
11
+ <output>
12
+ - Returns replacement summary, per-file replacement counts, and change previews
13
+ - Reports whether changes were applied or only previewed
14
+ - Includes parse issues when files cannot be processed
15
+ </output>
16
+
17
+ <critical>
18
+ - `pattern` + `rewrite` are required
19
+ - If the path pattern spans multiple languages, set `lang` explicitly for deterministic rewrites
20
+ - For one-off local text edits, prefer the Edit tool instead of AST replace
21
+ </critical>
@@ -35,6 +35,8 @@ You **MUST** use specialized tools instead of bash for ALL file operations:
35
35
  |`ls dir/`|`read(path="dir/")`|
36
36
  |`cat <<'EOF' > file`|`write(path="file", content="...")`|
37
37
  |`sed -i 's/old/new/' file`|`edit(path="file", edits=[...])`|
38
+ - If `ast_find` / `ast_replace` tools are available in the session, you **MUST** use them for structural code search/rewrites instead of bash `grep`/`sed`/`awk`/`perl` pipelines
39
+ - Bash is for command execution, not syntax-aware code transformation; prefer `ast_find` for discovery and `ast_replace` for codemods
38
40
  - You **MUST NOT** use Bash for these operations like read, grep, find, edit, write, where specialized tools exist.
39
41
  - You **MUST NOT** use `2>&1` | `2>/dev/null` pattern, stdout and stderr are already merged.
40
42
  - You **MUST NOT** use `| head -n 50` or `| tail -n 100` pattern, use `head` and `tail` parameters instead.
@@ -175,26 +175,44 @@ Good — include original `}` in the replaced range when replacement keeps `}`:
175
175
  Also apply the same rule to `);`, `],`, and `},` closers: if replacement includes the closer token, `end` must include the original closer line.
176
176
  </example>
177
177
 
178
- <example name="insert between siblings">
178
+ <example name="insert between sibling declarations">
179
179
  ```ts
180
- {{hlinefull 44 " \"build\": \"bun run compile\","}}
181
- {{hlinefull 45 " \"test\": \"bun test\""}}
180
+ {{hlinefull 44 "function x() {"}}
181
+ {{hlinefull 45 " runX();"}}
182
+ {{hlinefull 46 "}"}}
183
+ {{hlinefull 47 ""}}
184
+ {{hlinefull 48 "function y() {"}}
185
+ {{hlinefull 49 " runY();"}}
186
+ {{hlinefull 50 "}"}}
182
187
  ```
183
188
  ```
184
189
  {
185
190
  path: "…",
186
191
  edits: [{
187
192
  op: "prepend",
188
- pos: "{{hlineref 45 " \"test\": \"bun test\""}}",
189
- lines: [" \"lint\": \"biome check\","]
193
+ pos: "{{hlineref 48 "function y() {"}}",
194
+ lines: [
195
+ "function z() {",
196
+ " runZ();",
197
+ "}",
198
+ ""
199
+ ]
190
200
  }]
191
201
  }
192
202
  ```
193
203
  Result:
194
204
  ```ts
195
- {{hlinefull 44 " \"build\": \"bun run compile\","}}
196
- {{hlinefull 45 " \"lint\": \"biome check\","}}
197
- {{hlinefull 46 " \"test\": \"bun test\""}}
205
+ {{hlinefull 44 "function x() {"}}
206
+ {{hlinefull 45 " runX();"}}
207
+ {{hlinefull 46 "}"}}
208
+ {{hlinefull 47 ""}}
209
+ {{hlinefull 48 "function z() {"}}
210
+ {{hlinefull 49 " runZ();"}}
211
+ {{hlinefull 50 "}"}}
212
+ {{hlinefull 51 ""}}
213
+ {{hlinefull 52 "function y() {"}}
214
+ {{hlinefull 53 " runY();"}}
215
+ {{hlinefull 54 "}"}}
198
216
  ```
199
217
  </example>
200
218
 
@@ -1,16 +1,33 @@
1
1
  Interacts with Language Server Protocol servers for code intelligence.
2
2
 
3
3
  <operations>
4
- - `definition`: Go to symbol definition file path + position
5
- - `references`: Find all referenceslist of locations (file + position)
4
+ - `diagnostics`: Get errors/warnings for file, glob, or entire workspace (no file)
5
+ - `definition`: Go to symbol definition file path + position + 3-line source context
6
+ - `type_definition`: Go to symbol type definition → file path + position + 3-line source context
7
+ - `implementation`: Find concrete implementations → file path + position + 3-line source context
8
+ - `references`: Find references → locations with 3-line source context (first 50), remaining location-only
6
9
  - `hover`: Get type info and documentation → type signature + docs
7
- - `symbols`: List symbols in file, or search workspace (with query, no file) → names, kinds, locations
8
- - `rename`: Rename symbol across codebase → confirmation of changes
9
- - `diagnostics`: Get errors/warnings for file, or check entire project (no file) list with severity + message
10
+ - `symbols`: List symbols in file, or search workspace (with query, no file)
11
+ - `rename`: Rename symbol across codebase → preview or apply edits
12
+ - `code_actions`: List available quick-fixes/refactors/import actions; apply one when `apply: true` and `query` matches title or index
13
+ - `status`: Show active language servers
10
14
  - `reload`: Restart the language server
11
15
  </operations>
12
16
 
17
+ <parameters>
18
+ - `file`: File path; for diagnostics it may be a glob pattern (e.g., `src/**/*.ts`)
19
+ - `line`: 1-indexed line number for position-based actions
20
+ - `symbol`: Substring on the target line used to resolve column automatically
21
+ - `occurrence`: 1-indexed match index when `symbol` appears multiple times on the same line
22
+ - `query`: Symbol search query, code-action kind filter (list mode), or code-action selector (apply mode)
23
+ - `new_name`: Required for rename
24
+ - `apply`: Apply edits for rename/code_actions (default true for rename, list mode for code_actions unless explicitly true)
25
+ - `timeout`: Request timeout in seconds (clamped to 5-60, default 20)
26
+ </parameters>
27
+
13
28
  <caution>
14
29
  - Requires running LSP server for target language
15
30
  - Some operations require file to be saved to disk
31
+ - Diagnostics glob mode samples up to 20 files per request to avoid long-running stalls on broad patterns
32
+ - When `symbol` is provided for position-based actions, missing symbols or out-of-bounds `occurrence` values return an explicit error instead of silently falling back
16
33
  </caution>
@@ -12,7 +12,6 @@ Subagents lack your conversation history. Every decision, file content, and user
12
12
  - `.id`: CamelCase, max 32 chars
13
13
  - `.description`: UI display only — subagent never sees it
14
14
  - `.assignment`: Complete self-contained instructions. One-liners PROHIBITED; missing acceptance criteria = too vague.
15
- - `.skills`: Skill names to preload
16
15
  - `context`: Shared background prepended to every assignment. Session-specific info only.
17
16
  - `schema`: JTD schema for expected output. Format lives here — **MUST NOT** be duplicated in assignments.
18
17
  - `tasks`: Tasks to execute in parallel.
package/src/sdk.ts CHANGED
@@ -144,8 +144,6 @@ export interface CreateAgentSessionOptions {
144
144
 
145
145
  /** Skills. Default: discovered from multiple locations */
146
146
  skills?: Skill[];
147
- /** Skills to inline into the system prompt instead of listing available skills. */
148
- preloadedSkills?: Skill[];
149
147
  /** Rules. Default: discovered from multiple locations */
150
148
  rules?: Rule[];
151
149
  /** Context files (AGENTS.md content). Default: discovered walking up from cwd */
@@ -1128,7 +1126,6 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1128
1126
  const defaultPrompt = await buildSystemPromptInternal({
1129
1127
  cwd,
1130
1128
  skills,
1131
- preloadedSkills: options.preloadedSkills,
1132
1129
  contextFiles,
1133
1130
  tools,
1134
1131
  toolNames,
@@ -1147,7 +1144,6 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1147
1144
  return await buildSystemPromptInternal({
1148
1145
  cwd,
1149
1146
  skills,
1150
- preloadedSkills: options.preloadedSkills,
1151
1147
  contextFiles,
1152
1148
  tools,
1153
1149
  toolNames,
@@ -1299,7 +1295,17 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1299
1295
  return key;
1300
1296
  },
1301
1297
  cursorExecHandlers,
1302
- transformToolCallArguments: obfuscator?.hasSecrets() ? args => obfuscator!.deobfuscateObject(args) : undefined,
1298
+ transformToolCallArguments: (args, _toolName) => {
1299
+ let result = args;
1300
+ const maxTimeout = settings.get("tools.maxTimeout");
1301
+ if (maxTimeout > 0 && typeof result.timeout === "number") {
1302
+ result = { ...result, timeout: Math.min(result.timeout, maxTimeout) };
1303
+ }
1304
+ if (obfuscator?.hasSecrets()) {
1305
+ result = obfuscator.deobfuscateObject(result);
1306
+ }
1307
+ return result;
1308
+ },
1303
1309
  intentTracing: !!intentField,
1304
1310
  });
1305
1311
  cursorEventEmitter = event => agent.emitExternalEvent(event);