pi-agent-ide 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +82 -30
- package/assets/summary/debugging.png +0 -0
- package/assets/summary/editing.png +0 -0
- package/assets/summary/read.png +0 -0
- package/assets/summary/search-and-replace.png +0 -0
- package/assets/summary/search.png +0 -0
- package/assets/summary/settings.png +0 -0
- package/assets/summary/terminal.png +0 -0
- package/assets/summary/thumbs/debugging.png +0 -0
- package/assets/summary/thumbs/editing.png +0 -0
- package/assets/summary/thumbs/read.png +0 -0
- package/assets/summary/thumbs/search-and-replace.png +0 -0
- package/assets/summary/thumbs/search.png +0 -0
- package/assets/summary/thumbs/settings.png +0 -0
- package/assets/summary/thumbs/terminal.png +0 -0
- package/assets/summary/thumbs/user_terminal.png +0 -0
- package/assets/summary/user_terminal.png +0 -0
- package/dist/{chunk-4KUFOHWP.js → chunk-3E2NTWCN.js} +1 -1
- package/dist/chunk-7WCZOO5I.js +1 -0
- package/dist/chunk-CEX3VOJ7.js +2 -0
- package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
- package/dist/chunk-LVWMWWWF.js +28 -0
- package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
- package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
- package/dist/chunk-T7CZIACQ.js +27 -0
- package/dist/chunk-VXD6FZP5.js +5 -0
- package/dist/entry-1.js +1 -1
- package/dist/entry-2.js +1 -1
- package/dist/entry-31.js +8 -7
- package/dist/entry-34.js +1 -1
- package/dist/entry-36.js +1 -1
- package/dist/entry-37.js +1 -1
- package/dist/entry-51.js +9 -10
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-55.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-59.js +1 -1
- package/dist/entry-60.js +1 -0
- package/dist/entry-61.js +1 -1
- package/dist/entry-63.js +1 -1
- package/dist/entry-64.js +0 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-67.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-69.js +1 -0
- package/dist/entry-70.js +1 -1
- package/dist/entry-72.js +1 -1
- package/dist/entry-73.js +0 -1
- package/dist/entry-74.js +1 -1
- package/dist/entry-75.js +1 -315
- package/dist/entry-76.js +1 -30
- package/dist/entry-77.js +324 -2
- package/dist/entry-78.js +30 -1
- package/dist/entry-79.js +2 -1
- package/dist/entry-80.js +1 -3
- package/dist/entry-81.js +1 -3
- package/dist/entry-82.js +3 -1
- package/dist/entry-83.js +3 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -0
- package/dist/entry-86.js +1 -0
- package/dist/pi-agent-ide.js +1 -1
- package/docs/agent-guides/apply.md +1 -1
- package/docs/agent-guides/debugger.md +1 -1
- package/docs/agent-guides/editing.md +4 -0
- package/docs/agent-guides/terminal.md +1 -1
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +6 -6
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +10 -9
- package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
- package/node_modules/pi-agent-ide-changes/package.json +7 -7
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-search/package.json +4 -4
- package/node_modules/pi-agent-search-text/package.json +14 -6
- package/node_modules/pi-agent-search-text/runtime/entry-54.js +1 -0
- package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
- package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
- package/node_modules/pi-agent-text/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
- package/node_modules/pi-agent-text-editor/package.json +26 -26
- package/node_modules/pi-agent-text-editor/runtime/entry-75.js +0 -1
- package/node_modules/pi-agent-text-editor/runtime/entry-76.js +1 -0
- package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
- package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
- package/node_modules/pi-agent-tool-ui/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +3 -3
- package/node_modules/pi-agent-web-image/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/package.json +4 -4
- package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
- package/node_modules/pi-agent-web-text/package.json +4 -4
- package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
- package/package.json +35 -35
- package/src/api/plugin-protocol.ts +10 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-85.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-86.js +2 -0
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-search/package.json +4 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -6
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-54.js +1 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
- package/src/extensions/pi-agent-text-editor/package.json +26 -26
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +1 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
- package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +2 -0
- package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
- package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
- package/src/plugins/pi-agent-ide-ast/package.json +10 -9
- package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
- package/src/plugins/pi-agent-ide-changes/package.json +7 -7
- package/src/plugins/pi-agent-ide-debugger/index.ts +32 -10
- package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
- package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +88 -9
- package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
- package/src/plugins/pi-agent-ide-vision/index.ts +2 -1
- package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
- package/assets/gallery/apply-editing.png +0 -0
- package/assets/gallery/debugging.png +0 -0
- package/assets/gallery/read-web.png +0 -0
- package/assets/gallery/search-replace.png +0 -0
- package/assets/gallery/terminal.png +0 -0
- package/assets/gallery/tool-editing.png +0 -0
- package/dist/chunk-4LDOV7QS.js +0 -28
- package/dist/chunk-I6Y3W4X6.js +0 -27
- package/dist/chunk-YEQOQMU7.js +0 -5
- package/node_modules/pi-agent-text-anchor-constant/runtime/entry-54.js +0 -2
- package/node_modules/pi-agent-text-editor/runtime/entry-60.js +0 -1
- package/node_modules/pi-agent-text-editor-renderer/runtime/entry-76.js +0 -2
- package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +0 -1
- package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +0 -1
- package/node_modules/pi-agent-web/runtime/entry-80.js +0 -2
- package/node_modules/pi-agent-web-html/runtime/entry-81.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-81.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +0 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-54.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +0 -1
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-76.js +0 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-77.js +0 -2
- package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
- package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +0 -1
- /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-53.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-55.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-56.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
- /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-58.js +0 -0
- /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
- /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-77.js +0 -0
- /package/node_modules/{pi-agent-web-image → pi-agent-web}/runtime/entry-82.js +0 -0
- /package/node_modules/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/node_modules/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-83.js +0 -0
- /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-84.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-56.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
- /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-58.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.3 — 2026-09-27
|
|
4
|
+
|
|
5
|
+
### Editing
|
|
6
|
+
|
|
7
|
+
- Keep explicitly supplied trailing newlines when appending after an unfinished final line, and reject empty inserts without changing the file.
|
|
8
|
+
- Add optional blank-line separation for standalone insert and linewise Apply so separate blocks do not join neighboring paragraphs.
|
|
9
|
+
|
|
10
|
+
## 0.6.2 — 2026-09-18
|
|
11
|
+
|
|
12
|
+
### Debugging and terminals
|
|
13
|
+
|
|
14
|
+
- Let agents evaluate expressions in the selected stopped debugger frame and show the result directly in the debugger UI.
|
|
15
|
+
- Add timed image sequences for live terminal resources, including configurable duration, frame interval, and scale.
|
|
16
|
+
|
|
17
|
+
### Search and vision
|
|
18
|
+
|
|
19
|
+
- Render structural AST search results with the same grouped files, match highlighting, context, and compact expansion behavior as ordinary text search, while preserving exact `SEARCH#` references for agents.
|
|
20
|
+
- Route Agent IDE-owned Linux application windows through native Linux capture under WSL instead of treating their PIDs as Windows-host processes.
|
|
21
|
+
|
|
3
22
|
## 0.6.1 — 2026-09-17
|
|
4
23
|
|
|
5
24
|
### Progressive guidance
|
package/README.md
CHANGED
|
@@ -6,15 +6,27 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">Give your Pi agent a real IDE: one semantic interface for understanding, changing, running, debugging, and observing software.</p>
|
|
8
8
|
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
<div align="center">
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/pi-agent-ide)
|
|
12
|
+
[](https://www.npmjs.com/package/pi-agent-ide)
|
|
13
|
+
[](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml)
|
|
14
|
+
[](./LICENSE)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
|
|
20
|
+
[](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml)
|
|
21
|
+
[](https://github.com/alexshpunt/pi-agent-ide/actions/workflows/ci.yml)
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div align="center">
|
|
26
|
+
|
|
27
|
+
[](https://huggingface.co/spaces/alexshpunt/benchmark-explorer?card=harness%3Api-agent-ide%40latest)
|
|
28
|
+
|
|
29
|
+
</div>
|
|
18
30
|
|
|
19
31
|
## Summary
|
|
20
32
|
|
|
@@ -35,10 +47,22 @@ The interfaces are designed to combine. A search result can become an edit selec
|
|
|
35
47
|
|
|
36
48
|
Views change how the same resource is presented. The agent can request source structure, editable anchors, diagnostics, an image, a sequence, or another supported projection without learning a separate tool for every source.
|
|
37
49
|
|
|
50
|
+
<div align="center">
|
|
51
|
+
|
|
52
|
+
[](assets/summary/read.png)
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
38
56
|
### Find anything through `search`
|
|
39
57
|
|
|
40
58
|
`search` provides one interface for paths, exact text, regular expressions, AST patterns, symbols, references, code relationships, process discovery, and retained terminal output. Results are reusable guarded references, so the agent can find an intended target once and pass that selection directly to `read` or an editing tool.
|
|
41
59
|
|
|
60
|
+
<div align="center">
|
|
61
|
+
|
|
62
|
+
[](assets/summary/search.png)
|
|
63
|
+
|
|
64
|
+
</div>
|
|
65
|
+
|
|
42
66
|
### Express edits as intentions
|
|
43
67
|
|
|
44
68
|
Editing uses direct semantic operations:
|
|
@@ -52,14 +76,40 @@ Editing uses direct semantic operations:
|
|
|
52
76
|
|
|
53
77
|
Independent edits can be submitted together as a tool-call batch. Conditional and multi-file work uses Apply, a code mode that exposes the same guarded operations through transactional JavaScript. Diffing and staging are first-class tools too.
|
|
54
78
|
|
|
79
|
+
<div align="center">
|
|
80
|
+
|
|
81
|
+
[](assets/summary/editing.png)
|
|
82
|
+
|
|
83
|
+
</div>
|
|
84
|
+
|
|
55
85
|
Selections can come from exact text, anchors, search results, AST matches, or language-server symbols. Stale, ambiguous, and failed operations do not apply silently. If one selection method is a poor fit, the agent can recover through another without throwing away the rest of its work.
|
|
56
86
|
|
|
57
|
-
|
|
87
|
+
<div align="center">
|
|
88
|
+
|
|
89
|
+
[](assets/summary/search-and-replace.png)
|
|
90
|
+
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
### Run through persistent terminal sessions
|
|
58
94
|
|
|
59
95
|
The terminal is a first-class cross-platform interface. The agent can run commands, keep interactive sessions and background tasks alive across turns and extension reloads, read retained output, send exact input or named keys, and inspect terminal applications through images and sequences.
|
|
60
96
|
|
|
97
|
+
<div align="center">
|
|
98
|
+
|
|
99
|
+
[](assets/summary/terminal.png)
|
|
100
|
+
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
### Debug programs interactively
|
|
104
|
+
|
|
61
105
|
Debugger sessions use the same resource model. The agent can set breakpoints, inspect stack frames and variables, evaluate expressions, step through execution, and return to a running session later.
|
|
62
106
|
|
|
107
|
+
<div align="center">
|
|
108
|
+
|
|
109
|
+
[](assets/summary/debugging.png)
|
|
110
|
+
|
|
111
|
+
</div>
|
|
112
|
+
|
|
63
113
|
### See the environment
|
|
64
114
|
|
|
65
115
|
The agent can render websites as images, observe changing interfaces over time, and inspect windows opened by its own processes. Arbitrary windows and full displays require separate explicit opt-in settings. Images can be downscaled, limited to normalized regions, or divided into grid cells so the model receives the useful area instead of every source pixel.
|
|
@@ -78,11 +128,17 @@ Filesystem and HTTP reads, resource views, content converters, search backends,
|
|
|
78
128
|
|
|
79
129
|
A person can see the agent's edits, diffs, diagnostics, running processes, debugger state, and failures. Bounded presentation keeps live output readable without discarding the underlying result. Guarded snapshots and first-class undo make mistakes visible and recovery inexpensive.
|
|
80
130
|
|
|
131
|
+
<div align="center">
|
|
132
|
+
|
|
133
|
+
[](assets/summary/user_terminal.png)
|
|
134
|
+
|
|
135
|
+
</div>
|
|
136
|
+
|
|
81
137
|
### Work across languages and platforms
|
|
82
138
|
|
|
83
139
|
Built-in debugger recipes cover C, C++, C#, Dart, Elixir, Go, Java, JavaScript, Julia, Kotlin, Lua, PHP, PowerShell, Python, R, Ruby, Rust, shell scripts, Swift, TypeScript, and Zig. Formatting, linting, AST, language-server, and debugger support follows the tools and configuration available in each project.
|
|
84
140
|
|
|
85
|
-
Windows and WSL are first-class supported environments alongside Linux. Run doctor to see the exact capabilities available on the current machine.
|
|
141
|
+
Windows and WSL are first-class supported environments alongside Linux. Run `/pi-agent-ide-doctor` to see the exact capabilities available on the current machine.
|
|
86
142
|
|
|
87
143
|
### Built through data-driven development
|
|
88
144
|
|
|
@@ -128,17 +184,7 @@ Doctor reports the effective project, global, and built-in mappings, their sourc
|
|
|
128
184
|
|
|
129
185
|
Doctor shows its report before changing anything. If project evidence points to a different installed tool, it can write a project-only override under `.pi/pi-agent-ide/`. It never changes global or built-in configuration. Native files such as `eslint.config.js`, `.clang-format`, and `pyproject.toml` remain unchanged.
|
|
130
186
|
|
|
131
|
-
Run doctor again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
|
|
132
|
-
|
|
133
|
-
## Gallery
|
|
134
|
-
|
|
135
|
-
| Read and guarded tool editing | Transactional Apply |
|
|
136
|
-
| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
137
|
-
|  |  |
|
|
138
|
-
| Web reading | Search and replace |
|
|
139
|
-
|  |  |
|
|
140
|
-
| Background processes | Source-level debugging |
|
|
141
|
-
|  |  |
|
|
187
|
+
Run `/pi-agent-ide-doctor` again after installing or changing project tools. For configuration paths, precedence, and command flags, see [Configuration](./docs/configuration.md#doctor).
|
|
142
188
|
|
|
143
189
|
## Customization
|
|
144
190
|
|
|
@@ -148,6 +194,12 @@ Pi Agent IDE follows Pi's permissive, YOLO-style default: the agent can use the
|
|
|
148
194
|
- [File hooks](./docs/user-hooks.md) can inspect, change, or deny reads and edits.
|
|
149
195
|
- [Extensions](./docs/extensions.md) can add or replace protocols, resolvers, views, anchors, search backends, and other behavior.
|
|
150
196
|
|
|
197
|
+
<div align="center">
|
|
198
|
+
|
|
199
|
+
[](assets/summary/settings.png)
|
|
200
|
+
|
|
201
|
+
</div>
|
|
202
|
+
|
|
151
203
|
## Feedback and contributions
|
|
152
204
|
|
|
153
205
|
Pi Agent IDE is used actively in real development, but I can only reproduce the models, tools, environments, and workflows available to me. Everyone works differently, and I cannot find or cover every case on my own.
|
|
@@ -156,14 +208,14 @@ If something breaks, behaves badly, or does not fit your workflow, please [open
|
|
|
156
208
|
|
|
157
209
|
## Documentation
|
|
158
210
|
|
|
159
|
-
| Document | Contents
|
|
160
|
-
| ------------------------------------------ |
|
|
161
|
-
| [Tools and workflow](./docs/tools.md) | Read, vision, search, editing, anchors, and feedback
|
|
162
|
-
| [Architecture](./docs/architecture.md) | Module boundaries, protocols, and the umbrella extension
|
|
163
|
-
| [Configuration](./docs/configuration.md) | Run doctor
|
|
164
|
-
| [File hooks](./docs/user-hooks.md) | Inspect, change, or deny reads and edits
|
|
165
|
-
| [Writing extensions](./docs/extensions.md) | Add resolvers, views, anchors, search backends, and IDE plugins
|
|
166
|
-
| [Development](./docs/development.md) | Work from a checkout, test, and run modular mode
|
|
211
|
+
| Document | Contents |
|
|
212
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------ |
|
|
213
|
+
| [Tools and workflow](./docs/tools.md) | Read, vision, search, editing, anchors, and feedback |
|
|
214
|
+
| [Architecture](./docs/architecture.md) | Module boundaries, protocols, and the umbrella extension |
|
|
215
|
+
| [Configuration](./docs/configuration.md) | Run `/pi-agent-ide-doctor`, configure project tools and search, or disable built-ins |
|
|
216
|
+
| [File hooks](./docs/user-hooks.md) | Inspect, change, or deny reads and edits |
|
|
217
|
+
| [Writing extensions](./docs/extensions.md) | Add resolvers, views, anchors, search backends, and IDE plugins |
|
|
218
|
+
| [Development](./docs/development.md) | Work from a checkout, test, and run modular mode |
|
|
167
219
|
|
|
168
220
|
## License
|
|
169
221
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as A,f as E}from"./chunk-T7I2VX3J.js";import{d as q}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as T}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as O}from"./chunk-6CZO43OH.js";import{a as b,b as N}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{e as m,f as h,g as w,h as P,i as k,l as y}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as C}from"./chunk-
|
|
1
|
+
import{e as A,f as E}from"./chunk-T7I2VX3J.js";import{d as q}from"./chunk-FEDVTZJG.js";import"./chunk-O6LE42GK.js";import"./chunk-NNCZYO4Q.js";import{d as T}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as O}from"./chunk-6CZO43OH.js";import{a as b,b as N}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{e as m,f as h,g as w,h as P,i as k,l as y}from"./chunk-NTYXZ3EL.js";import"./chunk-5VSE5X5R.js";import{a as C}from"./chunk-QDLTO5PH.js";import{a as I,b as v}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import W from"node:path";var M="diagnostics",_=T({kind:"code-view",label:"Diagnostics"});async function S(r){E(r,[await A({id:"diagnostics",description:"Diagnostic resources, readiness, and verification",triggers:[{tool:"read",resourcePrefixes:["diagnostics:"]}]})]);let n,t=l((c,f,e)=>{if(n===void 0)throw new Error("IDE diagnostics are not connected");return n(c,{cwd:f,...e})},"collect"),s={protocol:I,apiVersion:4,id:"diagnostics",setup(c){n=c.readDiagnostics}},o=new WeakMap,i=new WeakMap,a=new WeakMap,d=new WeakMap,V={protocol:b,apiVersion:N,id:"diagnostics",setup(c){c.addResolver({resolver:H(t,i),renderResult:_});let f=y();c.addView({view:"diagnostics",priority:100,presenter:j(t,d)}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let g=e.state.content[0],u=i.get(g);return u&&o.set(e.request,u),f(e)}return e.state?.contentKind==="text"&&e.request.views?.includes("diagnostics")&&a.set(e.request,e.state.text),{kind:"continue",context:e}}}),c.addHandler({stage:"post-read",handler(e){let g=o.get(e.request);if(g&&e.result)return{kind:"continue",context:{...e,result:{...e.result,details:{...e.result.details,diagnosticCheck:g}}}};let u=a.get(e.request),D=u&&d.get(u),p=e.result,R=p?.content[0];return!D||!p||R?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:{...e,result:{...p,content:[{...R,text:`${D}
|
|
2
2
|
${R.text}`},...p.content.slice(1)]}}}}}),c.describe('diagnostics:<path> \u2014 lint and language-server diagnostics. views: ["diagnostics"] \u2014 diagnostics alongside source text. Results identify their reporting tool and readiness; pending results and snapshots are not completed checks.')}};await Promise.all([C(r,s),O(r,V)])}l(S,"registerDiagnostics");function H(r,n){return{id:"diagnostics",tryResolve(t,s){return Promise.resolve(L(t,s.cwd,r,n,{signal:s.signal,...s.audience==="script"&&{mode:"complete"}}))}}}l(H,"createDiagnosticResolver");function L(r,n,t,s,o){let i;try{i=m(r,M,n)}catch(a){return{kind:"failed",error:a}}return i===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:h(M,i),async read(){let a=await t(i,n,o),d=w(i,a.content,a.results);return s.set(d,d.diagnosticCheck),[d]}}}}l(L,"resolveDiagnosticSource");function j(r,n){return{id:"diagnostics",async present(t,s){if(s.purpose!=="read"||!W.isAbsolute(t.source))return t;let o=s.audience==="script"&&!s.requestedViews?.includes("diagnostics");if(o&&q(t.source))return t;let i=await r(t.source,s.cwd,{signal:s.signal,...s.audience==="script"&&{mode:o?"snapshot":"complete"}}).catch(a=>{if(s.signal?.throwIfAborted(),!o)throw a});if(i===void 0||o&&i.content!==t.content)return t;if(i.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,k(i.results)),P(t,i.results)}}}l(j,"createDiagnosticPresenter");export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-EI7MMDWY.js";import f from"node:path";import{pathToFileURL as p}from"node:url";function g(e,t){let o=new Map;for(let r of e){let n=o.get(r.source)??[];n.push(r),o.set(r.source,n)}let i=new Set,a=e.length,s=[...o].sort(([r,n],[h,u])=>u.length-n.length||r.localeCompare(h));for(let[r,n]of s){if(a<=t)break;i.add(r),a-=n.length}return{files:[...o].sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>{if(!i.has(r))return{kind:"detailed",source:r,matches:n};let h=new Map;for(let u of n)h.set(u.lineText,(h.get(u.lineText)??0)+1);return{kind:"compacted",source:r,matchCount:n.length,uniqueLineCount:h.size,groups:o.size===1?[...h].sort(([u,y],[b,C])=>C-y||u.localeCompare(b)).slice(0,t).map(([u,y])=>({text:u,matchCount:y})):[]}})}}c(g,"planSearchPresentation");function F(e,t,o,i,a,s=50){let r=g(t,s).files.map(n=>n.kind==="detailed"?x(n.source,n.matches,i):{path:S(n.source,i),link:p(n.source).href,matchCount:n.matchCount,uniqueLineCount:n.uniqueLineCount,groups:n.groups,lines:[]});return{...a!==void 0&&{sessionId:a},query:e,matchCount:t.length,fileCount:r.length,complete:o,files:r}}c(F,"createSearchToolDetails");function I(e){if(!d(e)||typeof e.query!="string"||!m(e.matchCount)||!m(e.fileCount)||typeof e.complete!="boolean"||e.sessionId!==void 0&&typeof e.sessionId!="string"||!Array.isArray(e.files)||!e.files.every(R))return!1;let t=e.files;return e.fileCount===t.length&&e.matchCount===t.reduce((o,i)=>o+i.matchCount,0)}c(I,"isSearchToolDetails");function x(e,t,o){let i=new Map;for(let s of t){let l=i.get(s.lineNumber);if(l!==void 0&&l.text!==s.lineText)throw new Error(`Search results disagree about line ${String(s.lineNumber)} in ${e}.`);let r=l??{lineNumber:s.lineNumber,text:s.lineText,ranges:[]};r.ranges.push({from:s.startColumn,to:s.endColumn}),i.set(s.lineNumber,r)}let a=[...i.values()].sort((s,l)=>s.lineNumber-l.lineNumber).map(s=>{let l=[...s.ranges].sort((r,n)=>r.from-n.from||r.to-n.to);return{lineNumber:s.lineNumber,text:s.text,matchCount:l.length,ranges:l}});return{path:S(e,o),link:p(e).href,matchCount:t.length,lines:a}}c(x,"createSearchResultFile");function R(e){if(!d(e)||typeof e.path!="string"||typeof e.link!="string"||!m(e.matchCount)||!Array.isArray(e.lines)||!e.lines.every(M))return!1;let t=e.lines,o=e.groups,i=new Set(t.flatMap(a=>a.logicalMatchIds??[]));return(o===void 0||Array.isArray(o)&&o.every(a=>d(a)&&typeof a.text=="string"&&m(a.matchCount)))&&(e.uniqueLineCount===void 0||m(e.uniqueLineCount))&&(t.length===0||(i.size>0?i.size===e.matchCount:e.matchCount===t.reduce((a,s)=>a+s.matchCount,0)))}c(R,"isSearchResultFile");function M(e){return d(e)&&Number.isSafeInteger(e.lineNumber)&&e.lineNumber>=1&&typeof e.text=="string"&&m(e.matchCount)&&Array.isArray(e.ranges)&&e.ranges.length===e.matchCount&&(e.logicalMatchIds===void 0||Array.isArray(e.logicalMatchIds)&&e.logicalMatchIds.every(t=>typeof t=="string"))&&e.ranges.every(t=>k(t,e.text))}c(M,"isSearchResultLine");function k(e,t){return d(e)&&Number.isSafeInteger(e.from)&&Number.isSafeInteger(e.to)&&e.from>=0&&e.to>e.from&&e.to<=t.length}c(k,"isSearchResultRange");function d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}c(d,"isRecord");function m(e){return Number.isSafeInteger(e)&&e>=0}c(m,"isCount");function S(e,t){let o=f.relative(t,e);return o.length>0&&!o.startsWith("..")&&!f.isAbsolute(o)?o:e}c(S,"displaySource");export{g as a,F as b,I as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as R}from"./chunk-7WCZOO5I.js";import{t as y,u as T}from"./chunk-5VSE5X5R.js";import{a as x}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import L from"node:path";import{keyText as D}from"@earendil-works/pi-coding-agent";import{Text as F,truncateToWidth as f,visibleWidth as u,wrapTextWithAnsi as O}from"@earendil-works/pi-tui";function $(e){return e.replaceAll("\u27E6","").replaceAll("\u27E7","")}l($,"sourceText");function w(e,t){let{files:r,...n}=e,a=$(t);return{...n,storedFiles:r.map(({lines:s,...o})=>({...o,lines:s.map(i=>{let d=[i.lineNumber,y(i.text,a),i.ranges];return i.logicalMatchIds===void 0?d:[...d,i.logicalMatchIds]})}))}}l(w,"compactSearchDetails");function C(e,t){if("files"in e)return e;let{storedFiles:r,...n}=e,a=$(t);return{...n,files:r.map(({lines:s,...o})=>({...o,lines:s.map(([i,d,c,m])=>({lineNumber:i,text:T(d,a),ranges:c,matchCount:c.length,...m===void 0?{}:{logicalMatchIds:m}}))}))}}l(C,"restoreSearchDetails");var M=new WeakMap,g=12,W={".ts":{label:"TS",color:"accent"},".tsx":{label:"TX",color:"accent"},".js":{label:"JS",color:"warning"},".jsx":{label:"JX",color:"warning"},".json":{label:"{}",color:"warning"},".md":{label:"MD",color:"mdHeading"},".py":{label:"PY",color:"accent"},".rs":{label:"RS",color:"accent"},".go":{label:"GO",color:"accent"},".css":{label:"CS",color:"accent"},".html":{label:"<>",color:"accent"}};function Z(e,t,r,n){if(typeof e.details=="object"){let o=M.get(e.details);o===void 0&&(o=C(e.details,e.content.flatMap(i=>i.type==="text"?[i.text]:[]).join(`
|
|
2
|
+
`)),M.set(e.details,o)),e={...e,details:o}}if(t.isPartial||n.isError||!R(e.details)){let o=e.content[0],i=o?.type==="text"?o.text:"",d=n.isError?"error":t.isPartial?"dim":"toolOutput";return new F(r.fg(d,i),0,0)}let s=(n.lastComponent instanceof S?n.lastComponent:void 0)??new S(e.details,r,t.expanded);return s.update(e.details,r,t.expanded),s}l(Z,"renderSearchResult");var S=class{constructor(t,r,n){this.details=t;this.theme=r;this.expanded=n}static{l(this,"SearchResultPanel")}cached;update(t,r,n){this.details===t&&this.theme===r&&this.expanded===n||(this.details=t,this.theme=r,this.expanded=n,this.invalidate())}render(t){if(this.cached?.width===t)return this.cached.lines;if(t<4){let c=[f(k(this.details),Math.max(1,t))];return this.cached={width:t,lines:c},c}let r=t-2,n=v(this.details,this.expanded),a=G(this.details.files),s=n.flatMap(c=>A(c,r,a,this.theme)),o=P(s,this.expanded,r,this.theme),i=[I(this.details,r,this.theme),...o];i.push(this.theme.fg("borderMuted",`\u2570${"\u2500".repeat(r)}\u256F`));let d=i.map(c=>f(c,t));return this.cached={width:t,lines:d},d}invalidate(){this.cached=void 0}};function v(e,t){let r=e.files.length===0?[{kind:"empty"}]:e.files.flatMap(o=>[{kind:"file",file:o},...o.uniqueLineCount===void 0?o.lines.map(i=>({kind:"line",file:o,line:i})):[{kind:"summary",text:`${String(o.uniqueLineCount)} unique line texts \xB7 search this path with a narrower query`},...(o.groups??[]).map(i=>({kind:"summary",text:`\xD7${String(i.matchCount)} ${i.text}`}))]]);if(t||r.length<=g)return r;let n=r.slice(0,g-1);for(;n.at(-1)?.kind==="file";)n.pop();let a=new Set(n.flatMap(o=>o.kind==="line"?o.line.logicalMatchIds??[]:[])),s=a.size>0?a.size:n.reduce((o,i)=>o+(i.kind==="line"?i.line.matchCount:0),0);return[...n,{kind:"omitted",matches:Math.max(0,e.matchCount-s)}]}l(v,"searchViewport");function P(e,t,r,n){if(t||e.length<=g)return e;let a=`${D("app.tools.expand")} to expand`,s=h(n.fg("dim",` \u2026 output truncated \xB7 ${a}`),r,n);return[...e.slice(0,g-1),s]}l(P,"compactRenderedRows");function A(e,t,r,n){if(e.kind==="file")return[h(B(e.file,t,n),t,n,!0)];if(e.kind==="line")return j(e.line,t,r,n);if(e.kind==="summary")return[h(n.fg("dim",` ${p(e.text)}`),t,n)];if(e.kind==="omitted"){let a=`${D("app.tools.expand")} to expand`;return[h(n.fg("dim",` \u2026 ${String(e.matches)} more ${b(e.matches,"match","matches")} \xB7 ${a}`),t,n)]}return[h(n.fg("dim"," No matches found"),t,n)]}l(A,"renderPanelRow");function B(e,t,r){let n=N(e.path,r),a=r.fg("accent",r.bold(String(e.matchCount))),s=u(n)+u(a)+4,o=Math.max(1,t-s),i=H(e.path,o),d=q(i,e.link,r),c=` ${n} ${d}`,m=" ".repeat(Math.max(1,t-u(c)-u(a)-1));return f(`${c}${m}${a} `,t)}l(B,"renderFileHeader");function j(e,t,r,n){let a=String(e.lineNumber).padStart(r),s=` ${n.fg("dim",a)} ${n.fg("borderMuted","\u2502")} `,o=Math.max(1,t-u(s)-1),i=O(E(e,n),o),d=" ".repeat(u(s));return i.map((c,m)=>h(`${m===0?s:d}${c}`,t,n))}l(j,"renderMatchLine");function E(e,t){let r="",n=0;for(let a of e.ranges){a.from>n&&(r+=t.fg("toolOutput",p(e.text.slice(n,a.from))));let s=p(e.text.slice(a.from,a.to));r+=t.bg("selectedBg",t.fg("accent",t.bold(s))),n=a.to}return n<e.text.length&&(r+=t.fg("toolOutput",p(e.text.slice(n)))),r}l(E,"renderHighlightedLine");function I(e,t,r){let n=l(o=>r.fg("borderMuted",o),"frame"),a=f(` ${k(e)} `,Math.max(0,t-1),""),s="\u2500".repeat(Math.max(0,t-u(a)-1));return`${n("\u256D\u2500")}${r.fg("accent",a)}${n(`${s}\u256E`)}`}l(I,"renderTopBorder");function k(e){return e.matchCount===0?"No matches":`${`${String(e.matchCount)}${e.complete?"":"+"}`} ${b(e.matchCount,"match","matches")} in ${String(e.fileCount)} ${b(e.fileCount,"file","files")}`}l(k,"searchSummary");function h(e,t,r,n=!1){let a=f(e,t),s=`${a}${" ".repeat(Math.max(0,t-u(a)))}`,o=n?r.bg("selectedBg",s):s,i=r.fg("borderMuted","\u2502");return`${i}${o}${i}`}l(h,"framed");function N(e,t){let r=L.extname(e).toLowerCase(),n=W[r]??{label:"\u25C7 ",color:r.length===0?"muted":"accent"};return t.fg(n.color,t.bold(n.label))}l(N,"fileBadge");function q(e,t,r){let n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),a=n===-1?"":e.slice(0,n+1),s=n===-1?e:e.slice(n+1),o=r.fg("muted",a)+r.underline(r.fg("accent",s));return t.includes("\x07")||t.includes("\x1B")?o:`\x1B]8;;${t}\x07${o}\x1B]8;;\x07`}l(q,"fileLink");function H(e,t){return u(e)<=t?e:t<=1?"\u2026":`\u2026${e.slice(-(t-1))}`}l(H,"truncatePath");function p(e){let t="";for(let r of e){if(r===" "){t+=" ".repeat(4);continue}let n=x(r.codePointAt(0));t+=n<32||n===127?"\uFFFD":r}return t}l(p,"safeText");function G(e){let t=1;for(let r of e)for(let n of r.lines)t=Math.max(t,n.lineNumber);return Math.max(3,String(t).length)}l(G,"maximumLineNumberWidth");function b(e,t,r){return e===1?t:r}l(b,"plural");export{w as a,Z as b,S as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as j,m as M}from"./chunk-FEDVTZJG.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-
|
|
1
|
+
import{a as j,m as M}from"./chunk-FEDVTZJG.js";import{a as _}from"./chunk-L7JMDDSD.js";import{a as N,b as O}from"./chunk-O6LE42GK.js";import"./chunk-S3ZPXWX7.js";import"./chunk-5VSE5X5R.js";import{a as C,b as R,c as A,d as $,g as F}from"./chunk-QIK2E64R.js";import{a as k}from"./chunk-ZC65Z3CK.js";import{a as c}from"./chunk-EI7MMDWY.js";var h=[],y=[],P=[];function b(n,t,e){if(t.some(i=>i.name===e))throw new Error(`[pi-agent-ide] ${n} "${e}" is already registered. Use a unique name.`)}c(b,"assertUniqueName");function q(n){let t=new Set;for(let e of n){let i=`${e.kind}:${e.name}`;if(t.has(i))throw new Error(`[pi-agent-ide] ${e.kind} "${e.name}" is registered twice by one plugin.`);switch(t.add(i),e.kind){case"compiler":{b(e.kind,y,e.name);break}case"formatter":{b(e.kind,h,e.name);break}case"linter":{b(e.kind,P,e.name);break}}}for(let e of n)switch(e.kind){case"compiler":{y.push(e);break}case"formatter":{h.push(e);break}case"linter":{P.push(e);break}}}c(q,"registerTools");async function L(n,t){let e=[];for(let i of n)try{await i.detect(t)&&e.push(i)}catch(o){console.error(`[pi-agent-ide] detect failed for "${i.name}":`,o)}return e.sort((i,o)=>o.priority-i.priority),H(e),e}c(L,"filterActive");function H(n){let t=new Map;for(let e of n)for(let i of e.extensions){let o=`${i}@${e.priority}`,a=t.get(o);if(a!==void 0)throw new Error(`[pi-agent-ide] priority conflict: tools "${a}" and "${e.name}" both claim "${i}" at priority ${e.priority}.`);t.set(o,e.name)}}c(H,"assertNoPriorityConflicts");async function G(n){let[t,e]=await Promise.all([L(h,n),L(y.filter(i=>i.syntaxOnly===!0),n)]);return{ctx:n,formatters:t,compilers:e,linters:[]}}c(G,"warmupFormatting");function T(){h.length=0,y.length=0,P.length=0}c(T,"resetRegistry");import{readFile as D}from"node:fs/promises";import g from"node:path";var v=class{constructor(t,e={}){this.sources=t;this.options=e}static{c(this,"DiagnosticStore")}files=new Map;dirty=new Set;sent=new Map;queue=[];running=0;disposed=!1;changeListeners=new Set;onDidChange(t){return this.changeListeners.add(t),()=>this.changeListeners.delete(t)}schedule(t,e,{cwd:i}){this.disposed||this.ensure(t,e,i)}async read(t,{cwd:e,mode:i,signal:o}){o?.throwIfAborted(),this.assertActive();let a=g.resolve(e,t),s=await D(a,"utf8");this.assertActive();let r=this.ensure(a,s,e);i==="complete"?await this.waitComplete(r,o):i!=="snapshot"&&await K(Promise.all(r.jobs),this.options.readWaitMs??5e3),o?.throwIfAborted(),this.assertActive();let d=await D(a,"utf8");this.assertActive();let l=this.ensure(a,d,e);if(i==="complete"&&l!==r)throw Object.assign(new Error("File changed during diagnostics"),{code:"DIAGNOSTICS_STALE"});return{filePath:a,content:l.content,results:[...l.results.values()]}}async waitComplete(t,e){let i=e?AbortSignal.any([e,t.controller.signal]):t.controller.signal;i.throwIfAborted();let o=[];await new Promise((a,s)=>{let r=c(m=>s(Object.assign(new Error(m),{code:m,details:[...t.results.values()]})),"fail"),d=c(()=>{let m=[...t.results.values()];m.some(w=>w.status==="unavailable")?r("DIAGNOSTICS_UNAVAILABLE"):m.every(w=>w.status==="ready")&&a()},"check"),l=c(()=>s(i.reason),"abort"),f=this.onDidChange(d),u=setTimeout(()=>r("DIAGNOSTICS_TIMEOUT"),this.options.checkTimeoutMs??3e4);i.addEventListener("abort",l,{once:!0});let p=c(()=>{clearTimeout(u),f(),i.removeEventListener("abort",l)},"cleanup");Promise.resolve().then(d),o.push(p)}).finally(()=>{for(let a of o)a()})}async takeNotifications(t){let e=[];for(let i of[...this.dirty]){if(i.cwd!==g.resolve(t)||(this.dirty.delete(i),!await this.isCurrent(i)))continue;let o=[...i.results.values()].filter(d=>d.status!=="pending"&&d.status!=="unavailable"&&d.diagnostics.length>0),a=this.key(i.filePath,i.cwd),s=JSON.stringify(o);if(this.sent.get(a)===s||(this.sent.set(a,s),o.length===0))continue;let r=o.map(d=>{let l=["error","warning","info","hint"].flatMap(f=>{let u=d.diagnostics.filter(p=>p.severity===f).length;return u>0?[`${u} ${f}`]:[]});return`${d.source} ${l.join(", ")}${d.status==="snapshot"?" (snapshot; completion unknown)":d.status==="unversioned"?" (unversioned)":""}`}).join("; ");e.push({filePath:g.relative(t,i.filePath),results:o,text:`${JSON.stringify(g.relative(t,i.filePath))}: ${r}.`})}return e}dispose(){this.disposed=!0,this.changeListeners.clear();for(let t of this.files.values())t.controller.abort();this.files.clear(),this.dirty.clear(),this.sent.clear(),this.pump()}key(t,e){return JSON.stringify([g.resolve(e),g.resolve(e,t)])}ensure(t,e,i){let o=this.key(t,i),a=this.files.get(o);if(a?.content===e)return a;a?.controller.abort(),a&&this.dirty.delete(a);let s={cwd:g.resolve(i),filePath:g.resolve(i,t),content:e,controller:new AbortController,results:new Map,jobs:[],publications:new Map};this.files.set(o,s),this.sources.length===0&&s.results.set("diagnostics",{source:"diagnostics",status:"unavailable",diagnostics:[],reason:"No diagnostic sources registered"}),this.dirty.add(s);for(let r of this.sources){s.results.set(r.id,{source:r.id,status:"pending",diagnostics:[]});let d=new Promise(l=>{this.queue.push(async()=>{try{await this.check(s,r)}finally{l()}})});s.jobs.push(d)}return queueMicrotask(()=>this.pump()),s}pump(){for(;this.running<(this.options.concurrency??4)&&this.queue.length>0;){let t=this.queue.shift();if(!t)break;this.running++,t().finally(()=>{this.running--,this.pump()})}}active(t){return!this.disposed&&!t.controller.signal.aborted}assertActive(){if(this.disposed)throw new Error("Diagnostics session has ended")}async isCurrent(t){if(!this.active(t))return!1;let e=await D(t.filePath,"utf8").catch(()=>{});return this.active(t)&&e===t.content}async publish(t,e,i){let o=(t.publications.get(e)??0)+1;if(t.publications.set(e,o),!await this.isCurrent(t)||t.publications.get(e)!==o)return;let a={...i,source:i.source??e};if(JSON.stringify(t.results.get(e))===JSON.stringify(a))return;t.results.set(e,a),this.dirty.add(t);let s=[...t.results.values()].some(r=>r.status!=="pending"&&r.status!=="unavailable"&&r.diagnostics.length>0);s||this.sent.delete(this.key(t.filePath,t.cwd));for(let r of this.changeListeners)r(t.cwd,s)}async check(t,e){if(!await this.isCurrent(t))return;let i=new AbortController,o=AbortSignal.any([i.signal,t.controller.signal]);if(o.aborted)return;let a,s;try{let r=new Promise((l,f)=>{s=c(()=>f(o.reason),"onAbort"),o.addEventListener("abort",s,{once:!0}),a=setTimeout(()=>i.abort(new Error("Diagnostic check timed out")),this.options.checkTimeoutMs??3e4)}),d=await Promise.race([e.diagnose(t.filePath,{cwd:t.cwd,content:t.content,signal:o,publish:c(l=>{o.aborted||this.publish(t,e.id,l)},"publish")}),r]);await this.publish(t,e.id,d)}catch(r){await this.publish(t,e.id,{status:"unavailable",diagnostics:[],reason:r instanceof Error?r.message:String(r)})}finally{clearTimeout(a),s&&o.removeEventListener("abort",s)}}};async function K(n,t){let e;try{await Promise.race([n,new Promise(i=>{e=setTimeout(i,t)})])}finally{clearTimeout(e)}}c(K,"waitAtMost");function V(){let n=new Map,t=[],e=new v(t),i=Promise.resolve();return{diagnostics:e,registerPlugin(o){if(o.id.trim().length===0)return Promise.reject(new Error("Plugin ID must not be empty"));let a=n.get(o.id);if(a!==void 0)return a;let s=i.then(async()=>{let r=[],d=[],l=!0,f={addTool(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);Z(u),r.push(u)},addDiagnosticSource(u){if(!l)throw new Error(`Plugin ${o.id} setup is already complete`);tt(u),d.push(u)},readDiagnostics(u,p){return e.read(u,p)}};try{await o.setup(f)}catch(u){throw l=!1,u}l=!1,Q(t,d),q(r),t.push(...d)});return n.set(o.id,s),i=s.catch(()=>{}),s.catch(()=>{n.delete(o.id)}),s},async waitForPendingPlugins(){await Promise.all(n.values())}}}c(V,"createIdeCore");function Q(n,t){let e=new Set(n.map(i=>i.id));for(let i of t){if(e.has(i.id))throw new Error(`Diagnostic source ${i.id} is already registered`);e.add(i.id)}}c(Q,"assertUniqueDiagnosticSources");function Z(n){if(!U(n))throw new TypeError("IDE tool must be an object");let t=n.kind,e=t==="compiler"?n.compile:t==="formatter"?n.format:t==="linter"?n.lint:void 0;if(e===void 0||typeof e!="function"||typeof n.detect!="function"||typeof n.name!="string"||n.name.trim().length===0||typeof n.priority!="number"||!Number.isFinite(n.priority)||!Array.isArray(n.extensions)||n.extensions.length===0||n.extensions.some(i=>typeof i!="string"||i.length===0))throw new TypeError("Invalid pi-agent-ide tool contribution")}c(Z,"assertIdeTool");function tt(n){if(!U(n)||typeof n.id!="string"||n.id.trim().length===0||typeof n.diagnose!="function")throw new TypeError("Invalid pi-agent-ide diagnostic source contribution")}c(tt,"assertDiagnosticSource");function U(n){return typeof n=="object"&&n!==null}c(U,"isRecord");function J(n,t,e=console.error){let i=new Map,o=!1,a=Promise.resolve();return{schedule(s){if(o||i.has(s))return;let r=setTimeout(()=>{i.delete(s),a=a.then(async()=>{o||await n(s)}).catch(e)},t);i.set(s,r)},dispose(){o=!0;for(let s of i.values())clearTimeout(s);i.clear()}}}c(J,"createDiagnosticDelivery");import{Text as Y}from"@earendil-works/pi-tui";var S="ide-diagnostic-summary";function W(n){return{filePath:n.filePath,sources:n.results.map(t=>{let e={error:0,warning:0,info:0,hint:0};for(let i of t.diagnostics)e[i.severity]++;return{source:t.source,status:t.status,counts:e}})}}c(W,"diagnosticEntryData");function E(n,t,e=!1){return{render(i){let o=n.sources.filter(r=>r.status!=="pending"&&r.status!=="unavailable"&&Object.values(r.counts).some(d=>d>0));if(o.length===0)return[];let a=o.map(r=>`${x(r.counts,t)} ${t.fg("dim",`(${I(r.source)})`)}`+(r.status==="ready"?"":` \xB7 ${t.fg("dim",r.status)}`)).join(" \xB7 "),s=[`${t.fg("accent","Diagnostics")} ${t.fg("toolTitle",I(n.filePath))} \xB7 ${a}`];if(e)for(let r of o)s.push(` ${t.fg("dim",I(r.source))} \xB7 ${x(r.counts,t)} \xB7 ${t.fg("dim",r.status)}`);return new Y(s.join(`
|
|
2
2
|
`),0,0).render(i)},invalidate(){}}}c(E,"renderDiagnosticEntry");function B(n){n.registerEntryRenderer(S,(t,e,i)=>{let o=k(t.data);return"files"in o?et(o.files,i,e.expanded):E(o,i,e.expanded)})}c(B,"registerDiagnosticEntryRenderer");function et(n,t,e=!1){return{render(i){let o=n.filter(d=>d.sources.some(l=>l.status!=="pending"&&l.status!=="unavailable"&&Object.values(l.counts).some(f=>f>0)));if(o.length===1&&o[0])return E(o[0],t,e).render(i);if(o.length===0)return[];let a={error:0,warning:0,info:0,hint:0},s=new Set;for(let d of o)for(let l of d.sources)if(!(l.status==="pending"||l.status==="unavailable")){s.add(l.source);for(let f of["error","warning","info","hint"])a[f]+=l.counts[f]}let r=new Y(`${t.fg("accent","Diagnostics")} \xB7 ${o.length} files \xB7 ${x(a,t)} \xB7 ${s.size} tools`,0,0).render(i);return e?[...r,...o.flatMap(d=>E(d,t,!0).render(i))]:r},invalidate(){}}}c(et,"renderDiagnosticBatch");function x(n,t){return["error","warning","info","hint"].filter(e=>n[e]>0).map(e=>{let i=n[e],o=e==="info"||i===1?e:`${e}s`,a=i>0&&(e==="error"||e==="warning")?e:"muted";return t.fg(a,`${i} ${o}`)}).join(", ")}c(x,"renderCounts");function I(n){return n.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}c(I,"plain");import X from"node:path";async function z(n){if(!X.isAbsolute(n.resourceSource))return{formatting:{status:"unavailable"}};let t;try{let e=await G({cwd:n.cwd}),i=X.extname(n.resourceSource).toLowerCase(),o=c(d=>d.extensions.includes(i)||d.extensions.includes("*"),"matches"),a=e.compilers.find(o);if(a&&(await a.compile({filePath:n.resourceSource},e.ctx)).syntaxErrors.length>0)return{formatting:{status:"skipped-syntax"}};let s=e.formatters.find(o);if(!s)return{formatting:{status:"unavailable"}};t=s.name;let r=await s.format({filePath:n.resourceSource},e.ctx);return r.formatter===null?{formatting:{status:"unavailable"}}:(t=r.formatter??s.name,{formatting:{status:r.ok?r.edits>0?"changed":"unchanged":"failed",formatter:t},...r.ok?{diffStatuses:[{text:`Formatted (${t})`,tone:"success",formatter:t}]}:{diffStatuses:[{text:`Formatting failed (${t})`,tone:"error"}]}})}catch{return{diffStatuses:[{text:"Formatting failed",tone:"error"}],formatting:{status:"failed",...t===void 0?{}:{formatter:t}}}}}c(z,"runIdePostEditGate");import it from"node:path";async function nt(n){T();let t=V();B(n);let e=n.events.on($,s=>{if(!F(s))throw new Error("Invalid pi-agent-ide plugin registration request");s.accept(t.registerPlugin(s.plugin))});n.on("session_shutdown",()=>{e(),t.diagnostics.dispose(),T()}),M(n,{id:"pi-agent-ide",handler:c(s=>n.getFlag("pi-agent-ide-no-post-processing")===!0?Promise.resolve({formatting:{status:"disabled"}}):z(s),"handler")}),n.events.emit(A,{protocol:C,apiVersion:4}),await _(n,{protocol:N,apiVersion:O,id:"ide-diagnostics",setup(s){s.onDidEdit(r=>{n.getFlag("pi-agent-ide-no-post-processing")===!0||r.postProcessing==="deferred"||it.isAbsolute(r.resourceSource)&&j(()=>t.diagnostics.schedule(r.resourceSource,r.after.content,{cwd:r.cwd}))})}});let i=!1,o=J(async s=>{let r=await t.diagnostics.takeNotifications(s);i||r.length===0||(n.sendMessage({customType:"ide-diagnostics",display:!1,content:`File diagnostics:
|
|
3
3
|
${r.map(d=>d.text).join(`
|
|
4
4
|
`)}`},{triggerTurn:!0,deliverAs:"steer"}),n.appendEntry(S,{files:r.map(W)}))},n.getFlag("pi-agent-ide-no-diagnostic-buffer")===!0?0:5e3),a=t.diagnostics.onDidChange((s,r)=>{r&&o.schedule(s)});n.on("session_shutdown",()=>{i=!0,o.dispose(),a()}),await t.waitForPendingPlugins()}c(nt,"registerPiAgentIde");export{nt as default};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import{a as se,b as ae,c as le}from"./chunk-ESPNEJHK.js";import{a as oe}from"./chunk-M5IVSCR2.js";import{e as Y,f as K}from"./chunk-T7I2VX3J.js";import{a as te}from"./chunk-L7JMDDSD.js";import{a as Q,b as ee}from"./chunk-O6LE42GK.js";import{b as E}from"./chunk-VCTK4JSN.js";import"./chunk-YHUTTZC6.js";import{a as Z}from"./chunk-6CZO43OH.js";import{a as z,b as J}from"./chunk-OBNING2A.js";import"./chunk-S3ZPXWX7.js";import{a as ie}from"./chunk-ZTYWHL2F.js";import{a as ne,b as re}from"./chunk-7UGNGK7Y.js";import"./chunk-5VSE5X5R.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import Be from"node:path";import{stripVTControlCharacters as qe}from"node:util";import{truncateLine as Ve}from"@earendil-works/pi-coding-agent";import{Text as S}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as ue,DEFAULT_MAX_LINES as ce,formatSize as He,truncateTail as Ge}from"@earendil-works/pi-coding-agent";function D(t){return Ge(t,{maxBytes:ue-4096,maxLines:ce-32})}l(D,"terminalOutputTail");function $(t){let e=D(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.waitReason===void 0?void 0:`next: Read ${t.source} to inspect it, then use write or insert to send input.`,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
|
|
2
|
+
`)}
|
|
3
|
+
output:${r.length===0?" (empty)":`
|
|
4
|
+
${r}`}`;let i=e.truncatedBy==="lines"?`${ce} line output budget`:`${He(ue)} output budget`,s=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
output:
|
|
7
|
+
${s}${r.length===0?"":`
|
|
8
|
+
${r}`}`}l($,"formatAgentTerminalSnapshot");var Xe=500;function de(t,e,n,r,i){let s=e?"background":"wait",o=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${k(n)} \xB7 ${s}`)}`;return new S(`${o}
|
|
9
|
+
${i.fg("accent",N(r.family))} ${t}`,0,0)}l(de,"renderRunCall");function me(t,e,n){let r=e.map(i=>` ${n.fg("dim",i)}`);return r.push(n.fg("success",t==="delete"?"\u2713 stopped":"\u2713 sent")),new S(r.join(`
|
|
10
|
+
`),0,0)}l(me,"renderTerminalActionResult");function C(t,e,n,r,i){let s=[ze(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&s.push(...r.map(o=>` ${i.fg("dim",o)}`)),new S(s.join(`
|
|
11
|
+
`),0,0)}l(C,"renderTerminalAction");function x(t,e,n,r){let i=ge(t,E,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),new S(i.join(`
|
|
12
|
+
`),0,0)}l(x,"renderTerminalResult");function pe(t,e,n){if(e===!0?e="full":e===!1&&(e="compact"),e==="disabled"){if(!(t.status!==void 0&&!["running","completed"].includes(t.status)||t.exitCode!==void 0&&t.exitCode!==0||t.error!==void 0))return new S(P(t,(u,c)=>n.fg(u,c)),0,0);let o=A(t.output??"",E),a=[...o.omission===void 0?[]:[` ${n.fg("muted",o.omission)}`],...o.lines.map(u=>` ${n.fg("dim",u)}`),...t.error===void 0?[]:[` ${n.fg("error",t.error)}`],P(t,(u,c)=>n.fg(u,c))];return new S(a.join(`
|
|
13
|
+
`),0,0)}if(e==="full"){let s=ge(t,Number.POSITIVE_INFINITY,n).slice(2);return new S(s.join(`
|
|
14
|
+
`),0,0)}let r=A(t.output??"",E),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(s=>` ${n.fg("dim",s)}`)];return i.push(P(t,(s,o)=>n.fg(s,o))),new S(i.join(`
|
|
15
|
+
`),0,0)}l(pe,"renderRunResult");function fe(t,e){let n=l((o,a)=>e?.fg(o,a)??a,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${k(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",N(t.shellFamily))} ${O(t.command,84)}`],s=Ye(t.output,2);return s.length>0&&i.push(...s.map(o=>` ${n("dim",O(o,90))}`)),i.push(P(t,n)),i.join(`
|
|
16
|
+
`)}l(fe,"renderActiveTerminal");function ge(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",s=t.cwd===void 0?"workspace":k(t.cwd),o=t.shellFamily??"posix",a=[`${n.fg("accent",r)} ${n.fg("muted",`\xB7 ${s} \xB7 ${i}`)}`,`${n.fg("accent",N(o))} ${t.command??""}`],u=A(t.output??"",e);return u.omission!==void 0&&a.push(` ${n.fg("muted",u.omission)}`),u.lines.length>0&&a.push(...u.lines.map(c=>` ${n.fg("dim",c)}`)),a.push(P(t,(c,d)=>n.fg(c,d))),a}l(ge,"terminalCardLines");function Ye(t,e){return A(t,e).lines}l(Ye,"outputTail");function A(t,e){let n=D(qe(t).replaceAll("\r","")),r=n.content.split(`
|
|
17
|
+
`).map(u=>Ve(u.trimEnd(),Xe).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,s=Math.max(0,r.length-i),o=Math.max(0,n.totalLines-n.outputLines),a=s+o;return{lines:r.slice(s),...n.truncated||a>0?{omission:a>0?`\u2026 ${a} earlier lines`:"\u2026 earlier output omitted"}:{}}}l(A,"outputWindow");function P(t,e){let n=t.status??"running",r=Ke(n),i=n==="completed"?"success":n==="running"?"accent":"error",s=[`${r} ${n}`,Je(t.elapsedMs??0)];return t.waitReason!==void 0&&s.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&s.push(`reason ${t.completionReason}`),t.exitCode!==void 0?s.push(`exit ${t.exitCode}`):t.signal!==void 0&&s.push(`signal ${t.signal}`),e(i,s.join(" \xB7 "))}l(P,"statusLine");function Ke(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}l(Ke,"statusIcon");function N(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}l(N,"promptMarker");function ze(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":k(t.cwd),i=t.background===!0?"background":"wait",s=O(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${s}`)}`}l(ze,"terminalIdentity");function k(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${Be.sep}`))?`~${t.slice(e.length)}`:t}l(k,"shortCwd");function O(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}l(O,"oneLine");function Je(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}l(Je,"formatElapsed");function he(t){return{id:"terminal",onDidChange:l(e=>t.onDidChange(e),"onDidChange"),list:l(()=>t.list().filter(e=>e.status==="running"||e.status==="stopping").map(e=>({source:e.source,kind:"terminal",title:e.shell.toLocaleLowerCase(),description:e.command,status:e.status==="stopping"?"stopping":"running",...e.pid===void 0?{}:{pid:e.pid,owned:!0},renderSummary:l(n=>fe(e,n).split(`
|
|
18
|
+
`),"renderSummary"),renderDetail:l(n=>x(e,!0,n),"renderDetail"),sendInput:l(n=>t.write(e.source,n),"sendInput"),stop:l(()=>t.delete(e.source),"stop")})),"list")}}l(he,"terminalProcessProvider");import{setTimeout as nt}from"node:timers/promises";var Ze="#d8dee9",W="#111418",Qe=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function F(t,e,n,r=1){let i=t.get(e);if(i===void 0)throw new Error(`Unknown terminal session ${e}`);await i.screenReady;let{createCanvas:s}=await import("@napi-rs/canvas"),o=Math.max(0,Math.min(i.rows-1,n?.start??0)),a=Math.max(1,Math.min(i.rows-o,n?.count??i.rows)),u=i.cols*9+24,c=a*18+24,d=s(Math.max(1,Math.round(u*r)),Math.max(1,Math.round(c*r))),m=d.getContext("2d");m.scale(r,r),m.fillStyle=W,m.fillRect(0,0,d.width,d.height),m.textBaseline="top";let p=i.screen.buffer.active,f=Math.max(0,p.baseY);for(let g=0;g<a;g+=1){let b=p.getLine(f+o+g);if(b!==void 0)for(let w=0;w<i.cols;w+=1){let v=b.getCell(w);v===void 0||v.getWidth()===0||et(m,v,w,g)}}return i.status==="running"&&p.cursorY>=o&&p.cursorY<o+a&&(m.fillStyle="rgba(216, 222, 233, 0.75)",m.fillRect(12+p.cursorX*9,12+(p.cursorY-o)*18+18-2,9,2)),d.toBuffer("image/png").toString("base64")}l(F,"renderTerminalScreen");function et(t,e,n,r){let i=ye(e,"foreground"),s=ye(e,"background");e.isInverse()&&([i,s]=[s,i]);let o=12+n*9,a=12+r*18;s!==W&&(t.fillStyle=s,t.fillRect(o,a,9*Math.max(1,e.getWidth()),18));let u=e.getChars();u.length!==0&&(t.font=`${e.isBold()?"bold ":""}14px monospace`,t.fillStyle=i,t.fillText(u,o,a),e.isUnderline()&&t.fillRect(o,a+18-2,9*Math.max(1,e.getWidth()),1))}l(et,"drawCell");function ye(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?Ze:W;let i=n?t.isFgRGB():t.isBgRGB(),s=n?t.getFgColor():t.getBgColor();return i?`#${s.toString(16).padStart(6,"0")}`:tt(s)}l(ye,"cellColor");function tt(t){let e=Qe[t];if(e!==void 0)return e;if(t>=232){let a=8+(t-232)*10;return we(a,a,a)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),s=n%6,o=l(a=>a===0?0:55+a*40,"channel");return we(o(r),o(i),o(s))}l(tt,"ansiColor");function we(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}l(we,"rgb");var j="\0pi-terminal-write\0",H="\0pi-terminal-keys\0";function rt(t){let e=t?.find(u=>u==="image"||u==="sequence"||u.startsWith("image:")||u.startsWith("sequence:"));if(e===void 0)return;let n=e.indexOf(":"),r=n<0?e:e.slice(0,n),i=new Map;if(n>=0)for(let u of e.slice(n+1).split(",")){let[c,d,m]=u.split("=");if(c===void 0||d===void 0||m!==void 0||d.length===0)throw new Error(`Invalid terminal ${r} view parameter: ${u}`);if(c!=="duration"&&c!=="interval"&&c!=="scale")throw new Error(`Unsupported terminal ${r} view parameter: ${c}`);let p=Number(d);if(!Number.isFinite(p))throw new Error(`Terminal ${c} must be a number`);i.set(c,p)}let s=i.get("duration")??2,o=i.get("interval")??.5,a=i.get("scale")??1;if(!(a>0&&a<=1))throw new Error("Terminal image scale must be greater than 0 and at most 1");if(r==="sequence"){if(!(s>0&&s<=10))throw new Error("Terminal sequence duration must be greater than 0 and at most 10 seconds");if(!(o>0))throw new Error("Terminal sequence interval must be greater than 0 seconds");if(Math.floor(s/o)+1>20)throw new Error("Terminal sequence capture is limited to 20 frames")}return{mode:r,duration:s,interval:o,scale:a}}l(rt,"parseTerminalVisualView");async function xe(t,e){let n=new Map,r=new Map,i={protocol:z,apiVersion:J,id:"terminal",setup(o){o.addResolver({resolver:it(e),preserveTruncatedOutput:!0,renderResult(a,u,c){let d=a.details,m=d.source===void 0?void 0:e.get(d.source),p=m===void 0?{}:e.snapshot(m);return x(m===void 0?p:{...p,output:e.screenTail(m).join(`
|
|
19
|
+
`)},u.expanded,c,"read terminal")}}),o.addHandler({stage:"pre-read",async handler(a){let u=a.request.path;if(u===void 0||!y(u))return{kind:"continue",context:a};let c;try{c=rt(a.request.views)}catch(m){return{kind:"return",result:U(u,m instanceof Error?m.message:String(m))}}if(c===void 0)return{kind:"continue",context:a};let d=e.get(u);if(d===void 0)return{kind:"return",result:U(u,`Unknown terminal session ${u}`)};try{e.markInspected(u);let m=c.mode==="image"?1:Math.floor(c.duration/c.interval)+1,p=[];for(let f=0;f<m;f+=1){a.resolverContext.signal?.throwIfAborted(),f>0&&await nt(c.interval*1e3,void 0,{signal:a.resolverContext.signal});let g=await F(e,u,void 0,c.scale);p.push({type:"image",data:g,mimeType:"image/png"})}return{kind:"return",result:{content:p,details:{source:d.source,resolvedBy:"terminal",frames:m,mode:c.mode}}}}catch(m){return{kind:"return",result:U(u,m instanceof Error?m.message:String(m))}}}}),o.describe("shell:<session> \u2014 terminal status and a bounded output tail with a full-log path when truncated. image and parameterized sequence views return the virtual terminal screen as ordered PNG frames.")}},s={protocol:Q,apiVersion:ee,id:"terminal",setup(o){o.addResolver({resolver:ot(e)}),o.tool("write").addHandler({stage:"text-pre-edit",handler:l(async a=>(Se(a.input,e,n),await Te(a.input,e,r),st(a,j)),"handler")}),o.tool("insert").addHandler({stage:"text-pre-edit",handler:l(async a=>(await Te(a.input,e,r),Se(a.input,e,n),at(a)),"handler")});for(let a of["write","insert","delete"])o.addToolRenderer({tool:a,matches:l((u,c)=>dt(u,c),"matches"),renderCall(u,c,d){let m=u,p=typeof m.path=="string"?e.get(m.path):void 0,f=d.state;return p!==void 0&&(f.snapshot=e.snapshot(p)),C(f.snapshot??{},a,be(a,m),[],c)},renderResult(u,c,d){let m=ct(u.details);return me(m.action,m.changedLines,d)}});o.describe("For shell:<session> resources, write sends exact terminal input, insert sends named keys at end, and delete terminates and removes the session. replace is unsupported."),o.tool("write").describe("When path is shell:<session>, send content exactly as terminal input without adding Enter."),o.tool("insert").describe("When path is shell:<session>, omit anchor or use end, keep before false, and put whitespace- or comma-separated named keys and chords such as Enter, Ctrl+C, Ctrl+Left, Ctrl+Shift+Left, Up, or Backspace in text. Use Unix caret forms such as ^C and ^U for control characters.")}};await Promise.all([Z(t,i),te(t,s)]),t.on("tool_result",async(o,a)=>{if(!T(o.input))return;let u=o.input.path;if(o.toolName==="replace"&&typeof u=="string"&&y(u))return{content:[{type:"text",text:`replace is unsupported for ${u}; use write for text, insert for keys, or delete to terminate and remove the session.`}],details:o.details,isError:!0};if(o.toolName==="delete"&&typeof u=="string"&&y(u)){let X=e.get(u);if(X===void 0)return;let je=e.snapshot(X);return e.delete(u).then(()=>({content:[{type:"text",text:`Deleted terminal session ${u}.`}],details:{source:u,deleted:!0,snapshot:je,action:"delete",input:"session",changedLines:[]},isError:!1}),_=>({content:[{type:"text",text:_ instanceof Error?_.message:String(_)}],details:{source:u,deleted:!1},isError:!0}))}if(o.toolName!=="write"&&o.toolName!=="insert"||o.isError)return;let c=o.input.path;if(typeof c!="string"||!y(c))return;let d=e.get(c);if(d===void 0)return;let m=r.get(c)??e.screenRows(d);r.delete(c);let p=n.get(c)??d.outputStart+d.output.length;n.delete(c),await e.waitForOutputAfter(d,p);let f=e.snapshot(d),g=o.toolName,b=be(g,o.input),w=e.screenChangeRegion(d,m,6),v=[{type:"text",text:`Sent ${b} to ${d.source}.`}];return a.model?.input.includes("image")===!0&&v.push({type:"image",data:await F(e,c,{start:w.startRow,count:w.lines.length}),mimeType:"image/png"}),{content:v,details:{source:d.source,action:g,status:d.status,snapshot:f,input:b,changedLines:w.lines},isError:o.isError}})}l(xe,"registerTerminalResources");function it(t){return{id:"terminal",async tryResolve(e){if(!y(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,async read(){t.markInspected(n.source);let r=t.snapshot(n);return[{type:"text",text:lt(r)}]}}}}}}l(it,"createReadResolver");function ot(t){return{id:"terminal-input",async tryResolve(e){if(!y(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,skipPostEdit:!0,async read(){return[{type:"text",text:"terminal input"}]},async write(r){let i=ut(r),s=i.indexOf(j),o=i.indexOf(H);if(s>=0){t.write(n.source,i.slice(s+j.length));return}if(o>=0){t.sendKeys(n.source,i.slice(o+H.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}l(ot,"createInputResolver");function st(t,e){return!T(t.input)||!Re(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}l(st,"transformWriteInput");function at(t){if(!T(t.input)||!Re(t.input.path))return t;if(t.input.before===!0)throw new Error("Shell keys can only be inserted after the active input position");return{...t,input:{...t.input,anchor:"end",before:!1,text:`${H}${typeof t.input.text=="string"?t.input.text:""}`}}}l(at,"transformInsertInput");function lt(t){return $(t)}l(lt,"formatSnapshot");function ut(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}l(ut,"singleText");function U(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}l(U,"failure");function y(t){return/^shell:[a-f\d]{12}$/u.test(t)}l(y,"isShellSource");function Re(t){return typeof t=="string"&&y(t)}l(Re,"isShellSourceValue");function ct(t){if(!T(t)||!T(t.snapshot))throw new TypeError("Invalid terminal action result");let e=t.snapshot,n=t.action;if(n!=="write"&&n!=="insert"&&n!=="delete")throw new TypeError("Invalid terminal action");return{source:typeof t.source=="string"?t.source:"shell:unknown",action:n,input:typeof t.input=="string"?t.input:"",changedLines:Array.isArray(t.changedLines)?t.changedLines.filter(r=>typeof r=="string"):[],snapshot:{...typeof e.shell=="string"?{shell:e.shell}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.background=="boolean"?{background:e.background}:{},...typeof e.status=="string"?{status:e.status}:{}}}}l(ct,"terminalActionDetails");async function Te(t,e,n){if(!T(t)||typeof t.path!="string"||!y(t.path))return;let r=e.get(t.path);r!==void 0&&await r.screenReady,r!==void 0&&n.set(t.path,e.screenRows(r))}l(Te,"rememberScreen");function Se(t,e,n){if(!T(t)||typeof t.path!="string"||!y(t.path))return;let r=e.get(t.path);r!==void 0&&n.set(t.path,r.outputStart+r.output.length)}l(Se,"rememberOutputEnd");function be(t,e){if(t==="delete")return"session";let n=t==="write"?e.content:e.text,r=typeof n=="string"?n:"";return t==="write"?`text ${JSON.stringify(r)}`:`keys ${r}`}l(be,"terminalInputLabel");function dt(t,e){if(!T(t))return!1;if(e==="call")return typeof t.path=="string"&&y(t.path);let n=t.details;return T(n)&&typeof n.source=="string"&&y(n.source)}l(dt,"isTerminalRenderValue");function T(t){return typeof t=="object"&&t!==null}l(T,"isRecord");async function Ee(t,e){await ie(t,{protocol:ne,apiVersion:re,id:"terminal",setup(r){r.addResolver({resolver:mt(e),priority:100}),r.describe("path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.")}})}l(Ee,"registerTerminalSearch");function mt(t){return{id:"terminal",async tryResolve(e){if(e.path===void 0||!e.path.startsWith("shell:"))return{kind:"not-handled"};let n=t.get(e.path);if(n===void 0)return{kind:"failed",error:new Error(`Unknown terminal session ${e.path}`)};let r=t.snapshot(n),i=pt(r,e);return{kind:"resolved",payload:{snapshot:r,query:e.query,matches:i}}},format(e){let n=G(e),r=n.matches.map(i=>`${n.snapshot.source}:${i.lineNumber}: ${i.lineText}`);return{content:[{type:"text",text:r.length===0?`No matches in ${n.snapshot.source}`:`${r.join(`
|
|
20
|
+
`)}
|
|
21
|
+
|
|
22
|
+
${r.length} match${r.length===1?"":"es"} in ${n.snapshot.source}`}],details:{source:n.snapshot.source,payload:n}}},renderResult(e,n,r){let i=e.details,s=q(i)?G(i.payload):G(void 0),o=C(s.snapshot,"search",JSON.stringify(s.query),s.matches.slice(-6).map(a=>`${a.lineNumber}: ${a.lineText}`),r);return new B(o,n.expanded===!0,r)}}}l(mt,"terminalSearchResolver");var ve=12,B=class{constructor(e,n,r){this.content=e;this.expanded=n;this.theme=r}static{l(this,"TerminalSearchPanel")}render(e){let n=this.content.render(e);if(this.expanded||n.length<=ve)return n;let r=ve-1;return[...n.slice(0,r),this.theme.fg("muted",`\u2026 ${String(n.length-r)} visual rows omitted \xB7 ctrl+o to expand`)]}invalidate(){this.content.invalidate()}};function pt(t,e){let n=e.caseSensitive===!0?e.query:e.query.toLocaleLowerCase();if(n.length===0)return[];let r=[],i=e.limit??100;for(let[s,o]of t.output.replaceAll("\r","").split(`
|
|
23
|
+
`).entries()){let a=e.caseSensitive===!0?o:o.toLocaleLowerCase(),u=0;for(;r.length<i;){let c=a.indexOf(n,u);if(c<0)break;let d=c+n.length;(e.wholeWord!==!0||ft(a,c,d))&&r.push({source:t.source,lineNumber:s+1,startColumn:c,endColumn:d,matchedText:o.slice(c,d),lineText:o}),u=Math.max(d,c+1)}if(r.length>=i)break}return r}l(pt,"findTerminalMatches");function ft(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}l(ft,"isWordBoundary");function G(t){if(!gt(t))throw new TypeError("Invalid terminal search result");return t}l(G,"parsePayload");function gt(t){return q(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&q(t.snapshot)&&typeof t.snapshot.source=="string"}l(gt,"isTerminalSearchPayload");function q(t){return typeof t=="object"&&t!==null}l(q,"isRecord");import{spawn as ht}from"node:child_process";import{closeSync as yt,mkdirSync as wt,openSync as Tt,rmSync as St,writeSync as bt}from"node:fs";import xt from"node:os";import Pe from"node:path";import{createRequire as Rt}from"node:module";import{randomUUID as vt}from"node:crypto";import{stripVTControlCharacters as Et}from"node:util";var Ce=Rt(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),$e=1e6,Pt=100,$t=30,At=2e3,L=class{static{l(this,"TerminalSessionManager")}#a;#e=new Map;#t=new Set;#r=new Set;#i=new Map;#o=!1;constructor(e=Lt){this.#a=e}onDidChange(e){return this.#t.add(e),()=>this.#t.delete(e)}onDidComplete(e){return this.#r.add(e),()=>this.#r.delete(e)}list(){return[...this.#e.values()].sort((e,n)=>n.startedAt-e.startedAt).map(e=>this.snapshot(e))}get(e){return this.#e.get(It(e))}snapshot(e,n=Date.now()){return{id:e.id,source:e.source,command:e.command,cwd:e.cwd,shell:e.shell.displayName,shellFamily:e.shell.family,...e.process===void 0?{}:{pid:e.process.pid},background:e.background,status:e.status,...e.waitReason===void 0?{}:{waitReason:e.waitReason},...e.completionReason===void 0?{}:{completionReason:e.completionReason},lastActivityAt:e.lastActivityAt,idleMs:Math.max(0,n-e.lastActivityAt),startedAt:e.startedAt,...e.endedAt===void 0?{}:{endedAt:e.endedAt},elapsedMs:(e.endedAt??n)-e.startedAt,...e.exitCode===void 0?{}:{exitCode:e.exitCode},...e.signal===void 0?{}:{signal:e.signal},...e.error===void 0?{}:{error:e.error},output:e.output,outputStart:e.outputStart,outputEnd:e.outputStart+e.output.length,truncated:e.outputStart>0,fullOutputPath:e.fullOutputPath,cols:e.cols,rows:e.rows}}start(e){if(this.#o)throw new Error("Terminal session manager is closed");let n=this.#a();if(!/^[a-f\d]{12}$/u.test(n)||this.#e.has(n))throw new Error("Terminal session IDs must be unique 12-character hexadecimal values");let r=Wt(n);this.#i.set(n,Tt(r,"a",384));let i=e.cols??Pt,s=e.rows??$t,o=kt(i,s),a=l(p=>{},"resolveCompletion"),u=new Promise(p=>{a=p}),c={id:n,source:`shell:${n}`,command:e.command,background:e.background,cwd:e.cwd,shell:e.shell,startedAt:Date.now(),lastActivityAt:Date.now(),cols:i,rows:s,fullOutputPath:r,screen:o,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:u,resolveCompletion:a,completionDelivered:!1},d;try{let p=Ce("node-pty"),f={name:"xterm-256color",cols:i,rows:s,cwd:e.cwd,env:_t(Mt())};d=p.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],f)}catch(p){let f={...c,status:"failed",endedAt:Date.now(),error:Nt(p)};return this.#e.set(n,f),this.#s(n),a(f),queueMicrotask(()=>this.#l(f)),f}let m={...c,process:d};return this.#e.set(n,m),d.onData(p=>this.#u(m,p)),d.onExit(({exitCode:p,signal:f})=>{R(m.status)||(m.endedAt=Date.now(),m.exitCode=p,f!==0&&(m.signal=f),m.status=m.status==="stopping"?"stopped":p===0?"completed":"failed",(p===124||p===137)&&(m.completionReason="timeout"),this.#s(m.id),m.resolveCompletion(m),this.#n(m),this.#l(m))}),this.#n(m),m}async wait(e,n){let r=this.required(e);return R(r.status)?r:n?.aborted===!0?(await this.stop(r.source,"cancelled"),r):await new Promise((i,s)=>{let o=l(()=>{this.stop(r.source,"cancelled").then(i,s)},"onAbort");n?.addEventListener("abort",o,{once:!0}),r.completion.then(a=>{n?.removeEventListener("abort",o),i(a)},s)})}async waitForForeground(e,n){let r=this.required(e);if(R(r.status))return{session:r};let i=n.interactiveDelayMs??3e3;return await new Promise(s=>{let o=!1,a,u=l(p=>{o||(p!==void 0&&R(r.status)&&(p=void 0),o=!0,clearTimeout(d),clearInterval(m),n.signal?.removeEventListener("abort",c),p!==void 0&&(r.background=!0,p!=="aborted"&&(r.waitReason=p),this.#n(r)),s({session:r,...p===void 0?{}:{reason:p}}))},"finish"),c=l(()=>u("aborted"),"onAbort"),d=setTimeout(()=>u("timeout"),n.timeoutMs),m=setInterval(()=>{if(!Ct(r)){a=void 0;return}a??=Date.now(),Date.now()-a>=i&&u("interactive")},Math.min(100,Math.max(10,i/2)));n.signal?.addEventListener("abort",c,{once:!0}),n.signal?.aborted===!0&&c(),r.completion.then(()=>u())})}async waitForOutputAfter(e,n){let r=Date.now()+300,i=n,s;for(;Date.now()<r;){let o=e.outputStart+e.output.length;if(o!==i)i=o,s=Date.now(),await e.screenReady;else if(s!==void 0&&Date.now()-s>=40)return;await V(10)}await e.screenReady}screenRows(e){let n=e.screen.buffer.active;return Array.from({length:e.rows},(r,i)=>(n.getLine(n.baseY+i)?.translateToString(!0)??"").trimEnd())}screenChangeRegion(e,n,r=6){let i=this.screenRows(e),s=Math.max(1,Math.min(e.rows,r)),o=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(s/2)),a=-1;for(let d=0;d<=e.rows-s;d+=1){let m=0;for(let p=d;p<d+s;p+=1){let f=n[p]??"",g=i[p]??"",b=g.length>0&&!n.includes(g),w=f.length>0&&g.length===0;f!==g&&(b||w)&&(m+=1)}m>a&&(a=m,o=d)}let u=e.screen.buffer.active;return{lines:i.slice(o,o+s).map((d,m)=>{if(o+m!==u.cursorY)return d;let f=d.padEnd(u.cursorX," ");return`${f.slice(0,u.cursorX)}\u258C${f.slice(u.cursorX)}`}),startRow:o}}screenChangeWindow(e,n,r=6){return this.screenChangeRegion(e,n,r).lines}screenTail(e,n=e.rows){let r=e.screen.buffer.active,i=Math.max(0,r.baseY),s=[];for(let o=0;o<e.rows;o+=1){let a=r.getLine(i+o)?.translateToString(!0).trimEnd();a!==void 0&&a.length>0&&s.push(a)}return s.slice(-Math.max(0,n))}markInspected(e){let n=this.required(e);n.status==="running"&&(n.lastActivityAt=Date.now(),this.#n(n))}write(e,n){this.requiredRunning(e).process?.write(n)}sendKeys(e,n){this.requiredRunning(e).process?.write(Dt(n))}async stop(e,n="stopped"){let r=this.required(e);return R(r.status)||(r.status="stopping",this.#n(r),await Ae(r,!1),await Promise.race([r.completion.then(()=>!0),V(At).then(()=>!1)])||(await Ae(r,!0),await Promise.race([r.completion,V(1e3)])),R(r.status)||(r.status=n,r.endedAt=Date.now(),this.#s(r.id),r.resolveCompletion(r),this.#l(r)),n==="cancelled"&&(r.status="cancelled"),this.#n(r)),r}async delete(e){let n=this.required(e);n.completionDelivered=!0,await this.stop(n.source),n.screen.dispose(),this.#s(n.id),St(n.fullOutputPath,{force:!0}),this.#e.delete(n.id),this.#n(n)}async screenLines(e){let n=this.required(e);await n.screenReady;let r=n.screen.buffer.active,i=[],s=Math.max(0,r.baseY);for(let o=s;o<s+n.rows;o+=1)i.push(r.getLine(o)?.translateToString(!0)??"");return i}cursor(e){let n=this.required(e);return{x:n.screen.buffer.active.cursorX,y:n.screen.buffer.active.cursorY}}async dispose(){if(!this.#o){this.#o=!0,await Promise.all([...this.#e.values()].filter(e=>!R(e.status)).map(e=>this.stop(e.source)));for(let e of this.#e.values())e.screen.dispose(),this.#s(e.id);this.#t.clear(),this.#r.clear()}}required(e){let n=this.get(e);if(n===void 0)throw new Error(`Unknown terminal session ${e}`);return n}requiredRunning(e){let n=this.required(e);if(n.status!=="running")throw new Error(`Terminal session ${n.source} is ${n.status}; input is unavailable`);return n}#u(e,n){e.lastActivityAt=Date.now();let r=Et(n),i=this.#i.get(e.id);if(i!==void 0&&bt(i,r),e.output+=r,e.output.length>$e){let s=e.output.length-$e;e.output=e.output.slice(s),e.outputStart+=s}e.screenReady=e.screenReady.then(()=>new Promise(s=>{e.screen.write(n,s)})),this.#n(e)}#s(e){let n=this.#i.get(e);n!==void 0&&(yt(n),this.#i.delete(e))}#n(e){for(let n of this.#t)n(e)}#l(e){for(let n of this.#r)n(e)}};function Ct(t){if(t.status!=="running")return!1;let e=t.screen.buffer.active,n=e.getLine(e.baseY+e.cursorY)?.translateToString(!0).trimEnd()??"";return/\[[^\]\n]{1,20}(?:\/[^\]\n]{1,20})+\]\s*[:?>]?\s*$/iu.test(n)||/(?:choose|select|enter|password|confirm|continue|proceed)[^\n]{0,60}[:?]\s*$/iu.test(n)||/^(?:❯|›)\s+\S/u.test(n)}l(Ct,"looksInteractive");function kt(t,e){let{Terminal:n}=Ce("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}l(kt,"createScreen");function Lt(){return vt().replaceAll("-","").slice(0,12)}l(Lt,"defaultSessionId");function It(t){return t.startsWith("shell:")?t.slice(6):t}l(It,"normalizeSessionId");function R(t){return t!=="running"&&t!=="stopping"}l(R,"isTerminalStatus");function Mt(){return process.env}l(Mt,"processEnvironment");function _t(t){return{...Object.fromEntries(Object.entries(t).filter(e=>e[1]!==void 0)),PAGER:"cat",GIT_PAGER:"cat",SYSTEMD_PAGER:"cat",GH_PAGER:"cat"}}l(_t,"cleanEnvironment");function Dt(t){return t.split(/[\s,]+/u).filter(Boolean).map(Ot).join("")}l(Dt,"encodeTerminalKeys");function Ot(t){if(/^\^[?@A-Z[\\\]^_]$/iu.test(t)){let d=t.slice(1).toUpperCase();return d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31)}let e=t.toLowerCase().split("+"),n=e.pop()??"",r=new Set(e);if([...r].some(d=>!["ctrl","control","alt","meta","shift"].includes(d)))throw new Error(`Unsupported terminal key ${t}`);let i=r.has("ctrl")||r.has("control"),s=r.has("alt")||r.has("meta"),o=r.has("shift");if(i&&n.length===1&&/[a-z@[\\\]^_?]/u.test(n)){let d=n.toUpperCase(),m=d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31);return s?`\x1B${m}`:m}let a={enter:"\r",tab:" ",escape:"\x1B",esc:"\x1B",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",delete:"\x1B[3~"};if(!i&&!s&&!o&&a[n]!==void 0)return a[n];if(s&&!i&&!o&&a[n]!==void 0)return`\x1B${a[n]}`;let c={up:"A",down:"B",right:"C",left:"D",home:"H",end:"F"}[n];if(c!==void 0)return!i&&!s&&!o?`\x1B[${c}`:`\x1B[1;${1+(o?1:0)+(s?2:0)+(i?4:0)}${c}`;if(s&&!i&&n.length===1)return`\x1B${o?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}l(Ot,"encodeTerminalKey");async function Ae(t,e){let n=t.process;if(n!==void 0){if(globalThis.process.platform!=="win32")try{globalThis.process.kill(-n.pid,e?"SIGKILL":"SIGTERM");return}catch{try{n.kill(e?"SIGKILL":"SIGTERM")}catch{}return}await new Promise(r=>{let i=ht("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}l(Ae,"terminateProcessTree");function V(t){return new Promise(e=>setTimeout(e,t))}l(V,"delay");function Nt(t){return t instanceof Error?t.message:String(t)}l(Nt,"errorMessage");function Wt(t){let e=Pe.join(xt.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return wt(e,{recursive:!0,mode:448}),Pe.join(e,`${t}.log`)}l(Wt,"createOutputLog");import Ft from"node:os";import ke from"node:path";function Le(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",s=ke.win32.basename(i).toLowerCase();return s==="cmd"||s==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:l(o=>["/d","/s","/c",o],"commandArgs")}:{executable:i,displayName:s.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:l(o=>["-NoLogo","-NoProfile","-Command",o],"commandArgs")}}let n=e.SHELL?.trim()||Ft.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=ke.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:l(i=>["-c",i],"commandArgs")}}l(Le,"resolveShellProfile");function Ie(t){switch(t.family){case"powershell":return"Write PowerShell syntax. Use PowerShell cmdlets, `$env:NAME` for environment variables, and `;` or pipelines to compose commands.";case"cmd":return"Write Command Prompt syntax. Use `%NAME%` for environment variables and `&&` to chain successful commands.";case"posix":return`Write ${t.displayName} syntax. Use POSIX-style paths, \`$NAME\` for environment variables, and \`&&\` or pipelines to compose commands.`}}l(Ie,"shellSyntaxGuidance");import Me from"node:path";import{stripVTControlCharacters as Ut}from"node:util";import{defineTool as jt}from"@earendil-works/pi-coding-agent";import{Type as h}from"typebox";import{Text as Ht}from"@earendil-works/pi-tui";var Gt=h.Object({command:h.String({minLength:1,description:"Command written in the syntax of the configured system shell"}),background:h.Optional(h.Boolean({description:"Return immediately while the terminal session continues. Defaults to false."})),timeoutSeconds:h.Optional(h.Number({minimum:.1,maximum:86400,description:"Maximum foreground wait in seconds before returning the live session as background. Defaults to 60."})),cwd:h.Optional(h.String({description:"Working directory. Relative paths resolve from the current workspace."})),cols:h.Optional(h.Integer({minimum:20,maximum:300,description:"Virtual terminal width in cells"})),rows:h.Optional(h.Integer({minimum:5,maximum:120,description:"Virtual terminal height in cells"}))},{additionalProperties:!1});function _e(t,e,n,r,i="compact"){let s=process.platform==="win32"?"powershell":"bash";t.registerTool(jt({name:s,label:n.displayName,promptSnippet:`Execute ${n.displayName} commands in synchronous or background terminal sessions`,promptGuidelines:[`Do not use ${s} commands or scripts to edit files. Use Apply or the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`],description:`Use ${s} to execute a command in the user's configured ${n.displayName} shell (${n.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions are treated as potentially stale after two minutes and wake an idle agent for inspection. Sessions survive extension reloads and keep the same shell: source. Output uses the shared Read limits, keeps the tail, and links a complete log file when truncated. ${Ie(n)}`,parameters:Gt,async execute(o,a,u,c,d){r.bind(d);let m=a.cwd===void 0?d.cwd:Me.resolve(d.cwd,a.cwd),p=e.start({command:a.command,background:a.background??!1,cwd:m,shell:n,...a.cols===void 0?{}:{cols:a.cols},...a.rows===void 0?{}:{rows:a.rows}});if(a.background===!0&&p.status!=="failed")return await Bt(e,p,c),p.status!=="running"&&(p.completionDelivered=!0),I(e.snapshot(p));if(p.status==="failed")return I(e.snapshot(p));let f=await e.waitForForeground(p.source,{signal:u,timeoutMs:(a.timeoutSeconds??60)*1e3});return f.reason==="aborted"&&r.notifyWaitTransition(f.session),I(e.snapshot(f.session))},renderCall(o,a,u){if((u.expanded?"full":i)==="disabled")return new Ht(a.fg("toolTitle",s),0,0);let d=typeof o.command=="string"?o.command:"",m=typeof o.cwd=="string"?Me.resolve(process.cwd(),o.cwd):process.cwd();return de(d,o.background===!0,m,n,a)},renderResult(o,a,u){return pe(o.details,a.expanded?"full":i,u)}}))}l(_e,"registerTerminalTools");function I(t){return{content:[{type:"text",text:$(t)}],details:t,isError:t.status==="failed"||t.status==="lost"}}l(I,"terminalResult");async function Bt(t,e,n){await new Promise(r=>{let i=!1,s,o=l(()=>{},"unsubscribe"),a=l(()=>{i||(i=!0,clearTimeout(s),o(),r())},"finish"),u=l(()=>{let c=t.snapshot(e);n?.(I(c)),(Ut(c.output).replaceAll("\r","").split(`
|
|
24
|
+
`).filter(m=>m.length>0).length>=E||c.status!=="running")&&a()},"publish");o=t.onDidChange(c=>{c.id===e.id&&u()}),s=setTimeout(a,2e3),u()})}l(Bt,"captureInitialBackgroundPreview");import{Box as De,Container as Oe}from"@earendil-works/pi-tui";var qt=120,Vt=12e4,M=class{constructor(e,n,r=Vt){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:s},o)=>{let a=Ne(i.details)?i.details:void 0,u=new Oe;a!==void 0&&u.addChild(x(a,s,o,"stale \xB7 inspect session"));let c=new De(1,1,d=>o.bg("toolPendingBg",d));return c.addChild(u),c}),e.registerMessageRenderer("terminal-completion",(i,{expanded:s},o)=>{let a=new Oe;for(let c of Xt(i.details))a.addChild(x(c,s,o));let u=new De(1,1,c=>o.bg("toolSuccessBg",c));return u.addChild(a),u}),this.#u=[n.onDidChange(i=>this.#s(i)),n.onDidComplete(i=>{this.#l(i.id),i.background&&this.#c(i)})]}static{l(this,"TerminalUi")}#a=new Map;#e;#t=new Map;#r=new Set;#i;#o=!1;#u;bind(e){this.#i=e}onAgentSettled(e){this.#i=e;for(let n of[...this.#r]){this.#r.delete(n);let r=this.manager.get(n);r!==void 0&&this.#s(r,!0)}}notifyWaitTransition(e){let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-wait-transition",display:!1,content:`Terminal wait ended; ${n.source} is still running in background. Read it to inspect output, then use write or insert to send input.`,details:n},{triggerTurn:!0,deliverAs:"steer"})}dispose(){this.#o=!0,this.#e!==void 0&&clearTimeout(this.#e),this.#e=void 0,this.#a.clear();for(let e of this.#t.values())clearTimeout(e);this.#t.clear(),this.#r.clear(),this.#i=void 0;for(let e of this.#u)e()}#s(e,n=!1){if(this.#l(e.id),this.#o||!e.background||e.status!=="running")return;let r=this.manager.snapshot(e),i=Math.max(0,this.staleIntervalMs-r.idleMs);if(n&&i===0){this.#n(e);return}this.#t.set(e.id,setTimeout(()=>this.#n(e),i))}#n(e){if(this.#t.delete(e.id),this.#o||e.status!=="running"||!e.background)return;if(this.#i?.isIdle()!==!0){this.#r.add(e.id);return}let n=this.manager.snapshot(e);this.pi.sendMessage({customType:"terminal-stale",display:!0,content:Kt(n),details:n},{triggerTurn:!0,deliverAs:"followUp"}),this.#t.set(e.id,setTimeout(()=>this.#n(e),this.staleIntervalMs))}#l(e){let n=this.#t.get(e);n!==void 0&&clearTimeout(n),this.#t.delete(e),this.#r.delete(e)}#c(e){this.#o||e.completionDelivered||(this.#a.set(e.id,e),this.#e===void 0&&(this.#e=setTimeout(()=>{this.#e=void 0;let n=[...this.#a.values()].filter(i=>!i.completionDelivered);if(this.#a.clear(),this.#o||n.length===0)return;for(let i of n)i.completionDelivered=!0;let r=n.map(i=>this.manager.snapshot(i));this.pi.sendMessage({customType:"terminal-completion",display:!0,content:Yt(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"})},qt)))}};function Xt(t){return!Fe(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(Ne)}l(Xt,"completionSnapshots");function Ne(t){return Fe(t)&&typeof t.id=="string"&&typeof t.source=="string"&&typeof t.command=="string"&&typeof t.cwd=="string"&&typeof t.shell=="string"&&typeof t.background=="boolean"&&typeof t.status=="string"&&typeof t.startedAt=="number"&&typeof t.elapsedMs=="number"&&typeof t.output=="string"}l(Ne,"isTerminalSessionSnapshot");function Yt(t){return`${t.length===1?"Background terminal completed:":"Background terminals completed:"}
|
|
25
|
+
${t.map(n=>{let r=n.exitCode===void 0?"":`, exit ${n.exitCode}`,i=n.completionReason===void 0?"":`, reason ${n.completionReason}`,s=n.output.trimEnd().slice(-2e3);return`- ${n.source}: ${n.status}${r}${i}, ${We(n.elapsedMs)}
|
|
26
|
+
${s||"(no output)"}`}).join(`
|
|
27
|
+
`)}`}l(Yt,"formatCompletionMessage");function Kt(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${We(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
|
|
28
|
+
${e||"(no output)"}`}l(Kt,"formatStaleMessage");function We(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}l(We,"formatElapsed");function Fe(t){return typeof t=="object"&&t!==null}l(Fe,"isRecord");function Ue(t){return t==="full"||t==="disabled"?t:"compact"}l(Ue,"toolPresentation");async function zt(t,e){K(t,[await Y({id:"terminal",description:"Foreground and background commands, shell resources, and processes",triggers:[{tool:"bash"},...["read","write","insert","delete"].map(o=>({tool:o,resourcePrefixes:["shell:","process:"]}))]})]);let n=ae("terminal")??new L,r=Le(),i=new M(t,n),s=oe(t).add(he(n));await Promise.all([xe(t,n),Ee(t,n)]),_e(t,n,r,i,Ue(e?.preferences["ui.terminal"])),t.on("session_start",(o,a)=>i.bind(a)),t.on("agent_settled",(o,a)=>i.onAgentSettled(a)),t.on("session_shutdown",async o=>{if(i.dispose(),s(),o.reason!=="quit"){se("terminal",n);return}le("terminal",n),await n.dispose()})}l(zt,"registerTerminal");export{zt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u,d as a,e as c}from"./chunk-
|
|
1
|
+
import{c as u,d as a,e as c}from"./chunk-QIK2E64R.js";import{a as t}from"./chunk-EI7MMDWY.js";function f(o,r){let s=t(()=>{let e,i={plugin:r,accept(g){if(e!==void 0)throw new Error(`Plugin ${r.id} registration was accepted more than once`);e=g}};return o.events.emit(a,i),e},"announce"),n=t(()=>{},"unsubscribe");n=o.events.on(u,e=>{if(!c(e))throw new Error("Invalid pi-agent-ide core readiness event");let i=s();if(i===void 0)throw new Error("pi-agent-ide core announced readiness without accepting the plugin");n(),i.catch(()=>{})}),o.on("session_shutdown",n);let d=s();if(d!==void 0)return n(),d}t(f,"connectIdePlugin");export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-EI7MMDWY.js";var t="pi-agent-ide",r=4,s="pi-agent-ide/core/ready",a="pi-agent-ide/plugin/register";function d(e){return n(e)&&e.protocol===t&&e.apiVersion===4}o(d,"isIdeCoreReady");function i(e){return n(e)&&e.protocol===t&&e.apiVersion===4&&typeof e.id=="string"&&e.id.length>0&&typeof e.setup=="function"}o(i,"isIdePlugin");function c(e){return n(e)&&i(e.plugin)&&typeof e.accept=="function"}o(c,"isIdePluginRegistrationRequest");function n(e){return typeof e=="object"&&e!==null}o(n,"
|
|
1
|
+
import{a as o}from"./chunk-EI7MMDWY.js";var t="pi-agent-ide",r=4,s="pi-agent-ide/core/ready",a="pi-agent-ide/plugin/register";function d(e){return n(e)&&e.protocol===t&&e.apiVersion===4}o(d,"isIdeCoreReady");function i(e){return n(e)&&e.protocol===t&&e.apiVersion===4&&typeof e.id=="string"&&e.id.length>0&&typeof e.setup=="function"}o(i,"isIdePlugin");function c(e){return n(e)&&i(e.plugin)&&typeof e.accept=="function"}o(c,"isIdePluginRegistrationRequest");function n(e){return typeof e=="object"&&e!==null}o(n,"isUnknownRecord");export{t as a,r as b,s as c,a as d,d as e,i as f,c as g};
|