mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-12-04 21:16:05 +00:00
The `find` tool matched path patterns through folders above the search
path. With the project in `/tmp/src/app`:
```
/tmp/src/app/src/a.ts
/tmp/src/app/lib/b.ts
/tmp/src/app/test/c.ts
```
`find { pattern: "src/**/*.ts" }` returned all three files.
**Cause:** fd matches `--full-path` globs against the absolute path, so
`find` put `**/` in front of path patterns. `**/src/**/*.ts` matched
`/tmp/src/app/lib/b.ts` through the parent folder `/tmp/src/`. Windows
had the same bug: its minimatch fallback also matched the absolute path.
**Fix:** path patterns are now relative to the search path, as grep's
`glob` has been since #11895.
- POSIX: the pattern is prefixed with the search path, glob-escaped (`\
* ? [ ] { }`), and passed to fd. fd's smart case would look at the whole
pattern, so a search path such as `/home/User/...` would make `src/b.ts`
case-sensitive. `find` now passes `--ignore-case` when the user's
pattern is all lowercase.
- Windows: minimatch matches the path relative to the search path.
Absolute patterns are still matched against the absolute path.
| Pattern | Before | After |
|---|---|---|
| `src/**/*.ts`, project in `~/src/app` | every `.ts` file | `src/a.ts`
|
| `src/*.ts` with `pkg/src/d.ts` present | `src/a.ts`, `pkg/src/d.ts` |
`src/a.ts` |
| `**/src/*.ts` | both | both |
| `*.ts` | file names at any depth | unchanged |
| absolute, `./src/*.ts`, Windows `src\*.ts` | worked | unchanged |
**Behavior change:** `src/*.ts` no longer finds `pkg/src/d.ts`;
`**/src/*.ts` does. This is the common glob convention (shell, ripgrep,
Node's `glob`) and matches grep's `glob`, so both tools now give the
same results for the same glob. Before, they disagreed. #11895 rejected
the old any-depth behavior for grep because it also matches lookalike
folders (#10418). find's `pattern` and grep's `glob` descriptions now
use the same, shorter wording: relative to the search directory, e.g.
`src/**/*.ts`; without `/`, e.g. `*.ts`, it matches file names at any
depth.
The gondolin example's `matchesToolGlob`, used for both find and grep,
also tried `**/` + pattern. It now anchors too and drops a leading `./`,
like the built-in tools.
**Testing**
- New `test/suite/regressions/12066-find-ancestor-glob.test.ts`: a
parent folder named `src`, anchored patterns vs. a leading `**/`, glob
characters in the search path, case handling with an upper-case search
path, and a symlinked search path (junction on Windows). 4 of its 5
tests fail on main.
- The find suites (3302, 3303, 6104), `test/tools.test.ts` and the other
find-related tests pass. `npm run check` passes.
- Windows: ran the bundled tool with Windows Node 26 and fd 10.5.0 on
`C:`, 32 cases: the cases above, backslash and `.\` patterns, absolute
`C:\` and `C:/` patterns, a lower-case drive letter, a folder named
`w[1]{x,y}`, case handling, a junction, the #3302 cases, and the result
limit. All pass. Against main, 5 of them fail.
fixes #12066
This PR is AI-generated.
|
||
|---|---|---|
| .. | ||
| extensions | ||
| sdk | ||
| README.md | ||
| rpc-client.ts | ||
| rpc-extension-ui.ts | ||
| tsconfig.json | ||
Examples
Example code for the pi-coding-agent SDK, process integration, and extensions.
CLI integration
rpc-client.ts uses the typed RpcClient to run Pi in a child process, stream events, and wait for the run to settle.
Build the coding-agent package before running it from a repository checkout:
node examples/rpc-client.ts "Explain this repository"
Directories
sdk/
Programmatic usage via createAgentSession(). Shows how to customize models, prompts, tools, extensions, and session management.
extensions/
Example extensions demonstrating:
- Lifecycle event handlers (tool interception, safety gates, context modifications)
- Custom tools (todo lists, questions, subagents, output truncation)
- Commands and keyboard shortcuts
- Custom UI (footers, headers, editors, overlays)
- Git integration (checkpoints, auto-commit)
- System prompt modifications and custom compaction
- External integrations (SSH, file watchers, system theme sync)
- Custom providers (Anthropic with custom streaming, GitLab Duo)