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.
Files changed (222) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +82 -30
  3. package/assets/summary/debugging.png +0 -0
  4. package/assets/summary/editing.png +0 -0
  5. package/assets/summary/read.png +0 -0
  6. package/assets/summary/search-and-replace.png +0 -0
  7. package/assets/summary/search.png +0 -0
  8. package/assets/summary/settings.png +0 -0
  9. package/assets/summary/terminal.png +0 -0
  10. package/assets/summary/thumbs/debugging.png +0 -0
  11. package/assets/summary/thumbs/editing.png +0 -0
  12. package/assets/summary/thumbs/read.png +0 -0
  13. package/assets/summary/thumbs/search-and-replace.png +0 -0
  14. package/assets/summary/thumbs/search.png +0 -0
  15. package/assets/summary/thumbs/settings.png +0 -0
  16. package/assets/summary/thumbs/terminal.png +0 -0
  17. package/assets/summary/thumbs/user_terminal.png +0 -0
  18. package/assets/summary/user_terminal.png +0 -0
  19. package/dist/{chunk-4KUFOHWP.js → chunk-3E2NTWCN.js} +1 -1
  20. package/dist/chunk-7WCZOO5I.js +1 -0
  21. package/dist/chunk-CEX3VOJ7.js +2 -0
  22. package/dist/{chunk-2527OQ4Y.js → chunk-HMLH43ZS.js} +1 -1
  23. package/dist/chunk-LVWMWWWF.js +28 -0
  24. package/dist/{chunk-HKMBQLEK.js → chunk-QDLTO5PH.js} +1 -1
  25. package/dist/{chunk-Z3VC3S2T.js → chunk-QIK2E64R.js} +1 -1
  26. package/dist/chunk-T7CZIACQ.js +27 -0
  27. package/dist/chunk-VXD6FZP5.js +5 -0
  28. package/dist/entry-1.js +1 -1
  29. package/dist/entry-2.js +1 -1
  30. package/dist/entry-31.js +8 -7
  31. package/dist/entry-34.js +1 -1
  32. package/dist/entry-36.js +1 -1
  33. package/dist/entry-37.js +1 -1
  34. package/dist/entry-51.js +9 -10
  35. package/dist/entry-53.js +1 -1
  36. package/dist/entry-54.js +1 -1
  37. package/dist/entry-55.js +1 -1
  38. package/dist/entry-56.js +1 -1
  39. package/dist/entry-57.js +1 -1
  40. package/dist/entry-58.js +1 -1
  41. package/dist/entry-59.js +1 -1
  42. package/dist/entry-60.js +1 -0
  43. package/dist/entry-61.js +1 -1
  44. package/dist/entry-63.js +1 -1
  45. package/dist/entry-64.js +0 -1
  46. package/dist/entry-65.js +1 -1
  47. package/dist/entry-66.js +1 -1
  48. package/dist/entry-67.js +1 -1
  49. package/dist/entry-68.js +1 -1
  50. package/dist/entry-69.js +1 -0
  51. package/dist/entry-70.js +1 -1
  52. package/dist/entry-72.js +1 -1
  53. package/dist/entry-73.js +0 -1
  54. package/dist/entry-74.js +1 -1
  55. package/dist/entry-75.js +1 -315
  56. package/dist/entry-76.js +1 -30
  57. package/dist/entry-77.js +324 -2
  58. package/dist/entry-78.js +30 -1
  59. package/dist/entry-79.js +2 -1
  60. package/dist/entry-80.js +1 -3
  61. package/dist/entry-81.js +1 -3
  62. package/dist/entry-82.js +3 -1
  63. package/dist/entry-83.js +3 -1
  64. package/dist/entry-84.js +1 -1
  65. package/dist/entry-85.js +1 -0
  66. package/dist/entry-86.js +1 -0
  67. package/dist/pi-agent-ide.js +1 -1
  68. package/docs/agent-guides/apply.md +1 -1
  69. package/docs/agent-guides/debugger.md +1 -1
  70. package/docs/agent-guides/editing.md +4 -0
  71. package/docs/agent-guides/terminal.md +1 -1
  72. package/node_modules/pi-agent-doctor/package.json +1 -1
  73. package/node_modules/pi-agent-documentation/package.json +1 -1
  74. package/node_modules/pi-agent-filesystem/package.json +6 -6
  75. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  76. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  77. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  78. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  79. package/node_modules/pi-agent-ide-ast/package.json +10 -9
  80. package/node_modules/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  81. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  82. package/node_modules/pi-agent-ide-changes/package.json +7 -7
  83. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  84. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  85. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  86. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  87. package/node_modules/pi-agent-image/package.json +2 -2
  88. package/node_modules/pi-agent-invariant/package.json +1 -1
  89. package/node_modules/pi-agent-pdf/package.json +2 -2
  90. package/node_modules/pi-agent-read/package.json +7 -7
  91. package/node_modules/pi-agent-resource/package.json +1 -1
  92. package/node_modules/pi-agent-search/package.json +4 -4
  93. package/node_modules/pi-agent-search-text/package.json +14 -6
  94. package/node_modules/pi-agent-search-text/runtime/entry-54.js +1 -0
  95. package/node_modules/pi-agent-search-text/src/persisted-result.ts +9 -7
  96. package/node_modules/pi-agent-search-text/src/search-renderer.ts +10 -4
  97. package/node_modules/pi-agent-search-text/src/search-result.ts +8 -1
  98. package/node_modules/pi-agent-text/package.json +3 -3
  99. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  100. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  101. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  102. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  103. package/node_modules/pi-agent-text-editor/package.json +26 -26
  104. package/node_modules/pi-agent-text-editor/runtime/entry-75.js +0 -1
  105. package/node_modules/pi-agent-text-editor/runtime/entry-76.js +1 -0
  106. package/node_modules/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
  107. package/node_modules/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
  108. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
  109. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
  110. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
  111. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  112. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  113. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
  114. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
  115. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  116. package/node_modules/pi-agent-tool-call-interception/runtime/entry-80.js +1 -0
  117. package/node_modules/pi-agent-tool-ui/package.json +2 -2
  118. package/node_modules/pi-agent-tool-ui/runtime/entry-81.js +1 -0
  119. package/node_modules/pi-agent-web/package.json +7 -7
  120. package/node_modules/pi-agent-web-html/package.json +3 -3
  121. package/node_modules/pi-agent-web-image/package.json +4 -4
  122. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  123. package/node_modules/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  124. package/node_modules/pi-agent-web-text/package.json +4 -4
  125. package/node_modules/pi-agent-web-text/runtime/entry-86.js +2 -0
  126. package/package.json +35 -35
  127. package/src/api/plugin-protocol.ts +10 -4
  128. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +6 -6
  129. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  130. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  131. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  132. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  133. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  134. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  135. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  136. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  137. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-85.js +2 -0
  138. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  139. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-86.js +2 -0
  140. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-82.js +2 -0
  141. package/src/extensions/pi-agent-read/package.json +7 -7
  142. package/src/extensions/pi-agent-search/package.json +4 -4
  143. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -6
  144. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +1 -0
  145. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-54.js +1 -0
  146. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/persisted-result.ts +9 -7
  147. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +10 -4
  148. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +8 -1
  149. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  150. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  151. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  152. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  153. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-59.js +1 -0
  154. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-60.js +2 -0
  155. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  156. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-78.js +2 -0
  157. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
  158. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-79.js +2 -0
  159. package/src/extensions/pi-agent-text-editor/runtime/entry-75.js +0 -1
  160. package/src/extensions/pi-agent-text-editor/runtime/entry-76.js +1 -0
  161. package/src/extensions/pi-agent-text-editor/runtime/entry-77.js +2 -0
  162. package/src/extensions/pi-agent-text-editor/src/core/apply/prompt.ts +1 -1
  163. package/src/extensions/pi-agent-text-editor/src/core/apply/runtime.ts +20 -11
  164. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +52 -11
  165. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +7 -4
  166. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +24 -3
  167. package/src/plugins/pi-agent-ide-ast/package.json +10 -9
  168. package/src/plugins/pi-agent-ide-ast/src/search-presentation.ts +117 -0
  169. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +20 -2
  170. package/src/plugins/pi-agent-ide-changes/package.json +7 -7
  171. package/src/plugins/pi-agent-ide-debugger/index.ts +32 -10
  172. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +10 -1
  173. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +39 -0
  174. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +42 -5
  175. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  176. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  177. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  178. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  179. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +88 -9
  180. package/src/plugins/pi-agent-ide-terminal/src/screen-image.ts +6 -2
  181. package/src/plugins/pi-agent-ide-vision/index.ts +2 -1
  182. package/src/plugins/pi-agent-ide-vision/src/vision.ts +17 -3
  183. package/assets/gallery/apply-editing.png +0 -0
  184. package/assets/gallery/debugging.png +0 -0
  185. package/assets/gallery/read-web.png +0 -0
  186. package/assets/gallery/search-replace.png +0 -0
  187. package/assets/gallery/terminal.png +0 -0
  188. package/assets/gallery/tool-editing.png +0 -0
  189. package/dist/chunk-4LDOV7QS.js +0 -28
  190. package/dist/chunk-I6Y3W4X6.js +0 -27
  191. package/dist/chunk-YEQOQMU7.js +0 -5
  192. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-54.js +0 -2
  193. package/node_modules/pi-agent-text-editor/runtime/entry-60.js +0 -1
  194. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-76.js +0 -2
  195. package/node_modules/pi-agent-tool-call-interception/runtime/entry-78.js +0 -1
  196. package/node_modules/pi-agent-tool-ui/runtime/entry-79.js +0 -1
  197. package/node_modules/pi-agent-web/runtime/entry-80.js +0 -2
  198. package/node_modules/pi-agent-web-html/runtime/entry-81.js +0 -2
  199. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-81.js +0 -2
  200. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-82.js +0 -2
  201. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-80.js +0 -2
  202. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-54.js +0 -2
  203. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-55.js +0 -1
  204. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-76.js +0 -2
  205. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-77.js +0 -2
  206. package/src/extensions/pi-agent-text-editor/runtime/entry-59.js +0 -1
  207. package/src/extensions/pi-agent-text-editor/runtime/entry-60.js +0 -1
  208. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-53.js +0 -0
  209. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-55.js +0 -0
  210. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-56.js +0 -0
  211. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-57.js +0 -0
  212. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-58.js +0 -0
  213. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-59.js +0 -0
  214. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-77.js +0 -0
  215. /package/node_modules/{pi-agent-web-image → pi-agent-web}/runtime/entry-82.js +0 -0
  216. /package/node_modules/{pi-agent-web-pdf → pi-agent-web-html}/runtime/entry-83.js +0 -0
  217. /package/node_modules/{pi-agent-web-text → pi-agent-web-image}/runtime/entry-84.js +0 -0
  218. /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
  219. /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
  220. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-56.js +0 -0
  221. /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
  222. /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
@@ -0,0 +1,117 @@
1
+ import path from "node:path";
2
+ import { pathToFileURL } from "node:url";
3
+
4
+ import type {
5
+ SearchResultFile,
6
+ SearchResultLine,
7
+ SearchResultRange,
8
+ SearchToolDetails,
9
+ } from "pi-agent-search-text/result";
10
+
11
+ export interface AstSearchPresentationMatch {
12
+ readonly file: string;
13
+ readonly lines: string;
14
+ readonly range: {
15
+ readonly start: { readonly line: number; readonly column: number };
16
+ readonly end: { readonly line: number; readonly column: number };
17
+ };
18
+ }
19
+
20
+ /** Build ordinary grouped search presentation data without changing AST selection details. */
21
+ export function createAstSearchPresentation(
22
+ query: string,
23
+ matches: readonly AstSearchPresentationMatch[],
24
+ complete: boolean,
25
+ cwd: string,
26
+ sessionId: string,
27
+ ): SearchToolDetails {
28
+ const grouped = new Map<string, AstSearchPresentationMatch[]>();
29
+ for (const match of matches) {
30
+ const current = grouped.get(match.file) ?? [];
31
+ current.push(match);
32
+ grouped.set(match.file, current);
33
+ }
34
+ const files = [...grouped.entries()].map(([file, fileMatches]) =>
35
+ createFilePresentation(file, fileMatches, cwd),
36
+ );
37
+ return {
38
+ sessionId,
39
+ query,
40
+ matchCount: matches.length,
41
+ fileCount: files.length,
42
+ complete,
43
+ files,
44
+ };
45
+ }
46
+
47
+ function createFilePresentation(
48
+ file: string,
49
+ matches: readonly AstSearchPresentationMatch[],
50
+ cwd: string,
51
+ ): SearchResultFile {
52
+ const lines = new Map<
53
+ number,
54
+ { text: string; ranges: SearchResultRange[]; logicalMatchIds: string[] }
55
+ >();
56
+ matches.forEach((match, matchIndex) => {
57
+ const texts = match.lines.replace(/\r/gu, "").split("\n");
58
+ if (texts.at(-1) === "") texts.pop();
59
+ const logicalId = `${file}:${String(matchIndex)}`;
60
+ texts.forEach((text, index) => {
61
+ const lineNumber = match.range.start.line + index + 1;
62
+ const range = highlightedRange(match, text, index, texts.length);
63
+ if (range === undefined) return;
64
+ const current = lines.get(lineNumber) ?? { text, ranges: [], logicalMatchIds: [] };
65
+ current.ranges.push(range);
66
+ current.logicalMatchIds.push(logicalId);
67
+ lines.set(lineNumber, current);
68
+ });
69
+ });
70
+ const resultLines: SearchResultLine[] = [...lines.entries()]
71
+ .sort(([left], [right]) => left - right)
72
+ .map(([lineNumber, line]) => {
73
+ const ranges = mergeRanges(line.ranges);
74
+ return {
75
+ lineNumber,
76
+ text: line.text,
77
+ matchCount: ranges.length,
78
+ ranges,
79
+ logicalMatchIds: [...new Set(line.logicalMatchIds)],
80
+ };
81
+ });
82
+ const source = path.resolve(cwd, file);
83
+ return {
84
+ path: path.relative(cwd, source),
85
+ link: pathToFileURL(source).href,
86
+ matchCount: matches.length,
87
+ lines: resultLines,
88
+ };
89
+ }
90
+
91
+ function highlightedRange(
92
+ match: AstSearchPresentationMatch,
93
+ text: string,
94
+ index: number,
95
+ lineCount: number,
96
+ ): SearchResultRange | undefined {
97
+ const first = index === 0;
98
+ const last = index === lineCount - 1;
99
+ const from = first ? match.range.start.column : 0;
100
+ const to = last ? match.range.end.column : text.length;
101
+ if (to <= from) return undefined;
102
+ return { from: Math.min(from, text.length), to: Math.min(to, text.length) };
103
+ }
104
+
105
+ function mergeRanges(ranges: readonly SearchResultRange[]): SearchResultRange[] {
106
+ const sorted = [...ranges].sort((left, right) => left.from - right.from || left.to - right.to);
107
+ const merged: SearchResultRange[] = [];
108
+ for (const range of sorted) {
109
+ const previous = merged.at(-1);
110
+ if (previous === undefined || range.from > previous.to) {
111
+ merged.push(range);
112
+ } else {
113
+ merged[merged.length - 1] = { from: previous.from, to: Math.max(previous.to, range.to) };
114
+ }
115
+ }
116
+ return merged;
117
+ }
@@ -5,6 +5,9 @@ import path from "node:path";
5
5
  import type { SearchPluginApi, SearchSelectionMatch } from "pi-agent-search/api/search";
6
6
 
7
7
  import type { SearchRequest, SearchResolver } from "pi-agent-search/api/search";
8
+ import { renderSearchResult } from "pi-agent-search-text/rendering";
9
+
10
+ import { createAstSearchPresentation } from "./search-presentation.js";
8
11
 
9
12
  interface AstGrepMatch {
10
13
  readonly text: string;
@@ -24,6 +27,7 @@ export function createAstSearchResolver(
24
27
  ): SearchResolver {
25
28
  return {
26
29
  id: "ast",
30
+ renderResult: renderSearchResult as SearchResolver["renderResult"],
27
31
  async tryResolve(request, context) {
28
32
  if (!request.query.startsWith("ast:")) {
29
33
  return { kind: "not-handled" };
@@ -65,6 +69,13 @@ export function createAstSearchResolver(
65
69
  })),
66
70
  complete: selected.complete,
67
71
  sessionId: session.id,
72
+ presentation: createAstSearchPresentation(
73
+ request.query,
74
+ selected.raw,
75
+ selected.complete,
76
+ context.cwd,
77
+ session.id,
78
+ ),
68
79
  },
69
80
  };
70
81
  },
@@ -74,10 +85,14 @@ export function createAstSearchResolver(
74
85
  readonly sessionId: string;
75
86
  readonly matches: readonly AstGrepMatch[];
76
87
  readonly complete: boolean;
88
+ readonly presentation: unknown;
77
89
  };
78
90
 
79
91
  if (result.matches.length === 0) {
80
- return { content: [{ type: "text", text: "No AST matches found." }], details: result };
92
+ return {
93
+ content: [{ type: "text", text: "No AST matches found." }],
94
+ details: result.presentation,
95
+ };
81
96
  }
82
97
 
83
98
  const lines = result.matches.flatMap((match, index) => [
@@ -93,7 +108,10 @@ export function createAstSearchResolver(
93
108
  lines.push("Result limit reached.");
94
109
  }
95
110
 
96
- return { content: [{ type: "text", text: lines.join("\n") }], details: result };
111
+ return {
112
+ content: [{ type: "text", text: lines.join("\n") }],
113
+ details: result.presentation,
114
+ };
97
115
  },
98
116
  };
99
117
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-ide-changes",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
@@ -13,12 +13,12 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "diff": "^9.0.0",
16
- "pi-agent-doctor": "0.6.1",
17
- "pi-agent-documentation": "0.6.1",
18
- "pi-agent-invariant": "0.6.1",
19
- "pi-agent-read": "0.6.1",
20
- "pi-agent-text": "0.6.1",
21
- "pi-agent-text-editor": "0.6.1"
16
+ "pi-agent-doctor": "0.6.3",
17
+ "pi-agent-documentation": "0.6.3",
18
+ "pi-agent-invariant": "0.6.3",
19
+ "pi-agent-read": "0.6.3",
20
+ "pi-agent-text": "0.6.3",
21
+ "pi-agent-text-editor": "0.6.3"
22
22
  },
23
23
  "pi": {
24
24
  "extensions": [
@@ -33,7 +33,10 @@ import {
33
33
  renderDebugCall,
34
34
  renderDebugResult,
35
35
  } from "#src/plugins/pi-agent-ide-debugger/src/renderer.js";
36
- import { debuggerSnapshotFromResult } from "#src/plugins/pi-agent-ide-debugger/src/ui.js";
36
+ import {
37
+ debuggerEvaluationFromResult,
38
+ debuggerSnapshotFromResult,
39
+ } from "#src/plugins/pi-agent-ide-debugger/src/ui.js";
37
40
  import { debuggerProcessProvider } from "#src/plugins/pi-agent-ide-debugger/src/process-provider.js";
38
41
  import { agentIdeProcessRegistry } from "#src/plugins/pi-agent-ide-processes/src/registry.js";
39
42
 
@@ -70,6 +73,7 @@ interface DebugToolDetails {
70
73
  import {
71
74
  DebugSessionManager,
72
75
  renderDebugSession,
76
+ type DebugEvaluation,
73
77
  type DebugSession,
74
78
  } from "#src/plugins/pi-agent-ide-debugger/src/session-manager.js";
75
79
 
@@ -136,9 +140,11 @@ export default async function registerDebugger(pi: ExtensionAPI): Promise<void>
136
140
  ],
137
141
  }),
138
142
  ]);
143
+ const retainedManager = takeReloadResource("debugger") as DebugSessionManager | undefined;
139
144
  const manager =
140
- (takeReloadResource("debugger") as DebugSessionManager | undefined) ??
141
- new DebugSessionManager();
145
+ retainedManager !== undefined && typeof retainedManager.evaluate === "function"
146
+ ? retainedManager
147
+ : new DebugSessionManager();
142
148
  const deletedSnapshots = new Map<string, ReturnType<DebugSessionManager["snapshot"]>>();
143
149
  const readResolver = createDebugResourceResolver(manager, "debugger-source");
144
150
  const editorResolver = createDebugResourceResolver(manager, "debugger-input");
@@ -231,11 +237,19 @@ export default async function registerDebugger(pi: ExtensionAPI): Promise<void>
231
237
  if (parameters.path !== session.source || parameters.anchor !== undefined) {
232
238
  throw new Error("Debug commands target the session resource without an anchor");
233
239
  }
234
- await executeSessionCommand(manager, session, parameters.text, context.signal);
240
+ const evaluation = await executeSessionCommand(
241
+ manager,
242
+ session,
243
+ parameters.text,
244
+ context.signal,
245
+ );
235
246
  return {
236
247
  source: session.source,
237
- summary: renderDebugSession(session),
238
- data: debugActionData(manager, session, parameters.text),
248
+ summary:
249
+ evaluation === undefined
250
+ ? renderDebugSession(session)
251
+ : `${evaluation.expression} = ${evaluation.result}${evaluation.type === undefined ? "" : ` (${evaluation.type})`}`,
252
+ data: debugActionData(manager, session, parameters.text, evaluation),
239
253
  };
240
254
  },
241
255
  });
@@ -263,7 +277,7 @@ export default async function registerDebugger(pi: ExtensionAPI): Promise<void>
263
277
  },
264
278
  });
265
279
  api.describe(
266
- 'For debug:<session> resources, insert performs debugger actions without changing source text. On a debug source, insert "breakpoint" at an anchor. On the session, insert start, continue, step over, step into, or step out. Delete removes a breakpoint or terminates the session.',
280
+ 'For debug:<session> resources, insert performs debugger actions without changing source text. On a debug source, insert "breakpoint" at an anchor. On the session, insert start, continue, step over, step into, step out, or evaluate <expression>. Delete removes a breakpoint or terminates the session.',
267
281
  );
268
282
  for (const tool of ["insert", "delete"] as const) {
269
283
  api.addToolRenderer({
@@ -314,7 +328,8 @@ export default async function registerDebugger(pi: ExtensionAPI): Promise<void>
314
328
  renderResult(result, options, theme) {
315
329
  const snapshot = debuggerSnapshotFromResult(result.details);
316
330
  if (snapshot === undefined) throw new Error("Debugger result is missing its session");
317
- return renderDebugResult(snapshot, options.expanded, theme);
331
+ const evaluation = debuggerEvaluationFromResult(result.details);
332
+ return renderDebugResult(snapshot, options.expanded, theme, evaluation);
318
333
  },
319
334
  });
320
335
  }
@@ -465,8 +480,13 @@ async function executeSessionCommand(
465
480
  session: DebugSession,
466
481
  command: string,
467
482
  signal?: AbortSignal,
468
- ): Promise<void> {
469
- switch (command.trim().toLowerCase()) {
483
+ ): Promise<DebugEvaluation | undefined> {
484
+ const trimmed = command.trim();
485
+ const evaluation = /^evaluate\s+(.+)$/isu.exec(trimmed);
486
+ if (evaluation !== null) {
487
+ return await manager.evaluate(session, evaluation[1] as string, signal);
488
+ }
489
+ switch (trimmed.toLowerCase()) {
470
490
  case "start": {
471
491
  await manager.start(session, signal);
472
492
  return;
@@ -517,6 +537,7 @@ function debugActionData(
517
537
  manager: DebugSessionManager,
518
538
  session: DebugSession,
519
539
  command: string,
540
+ evaluation?: DebugEvaluation,
520
541
  ): Readonly<Record<string, unknown>> {
521
542
  return {
522
543
  kind: "debug-command",
@@ -529,6 +550,7 @@ function debugActionData(
529
550
  verified,
530
551
  })),
531
552
  ...(session.stop === undefined ? {} : { stop: session.stop }),
553
+ ...(evaluation === undefined ? {} : { evaluation }),
532
554
  snapshot: manager.snapshot(session),
533
555
  };
534
556
  }
@@ -4,6 +4,7 @@ import type { Theme, ThemeColor } from "@earendil-works/pi-coding-agent";
4
4
  import { Text, type Component } from "@earendil-works/pi-tui";
5
5
 
6
6
  import type {
7
+ DebugEvaluation,
7
8
  DebugSessionSnapshot,
8
9
  DebugSessionStatus,
9
10
  DebugStop,
@@ -43,8 +44,15 @@ export function renderDebugResult(
43
44
  snapshot: DebugSessionSnapshot,
44
45
  expanded: boolean,
45
46
  theme: DebugTheme,
47
+ evaluation?: DebugEvaluation,
46
48
  ): Component {
47
- return new Text(debugResultLines(snapshot, expanded, theme).join("\n"), 0, 0);
49
+ const lines = debugResultLines(snapshot, expanded, theme);
50
+ if (evaluation !== undefined) {
51
+ lines.unshift(
52
+ `${theme.fg("accent", evaluation.expression)} ${theme.fg("muted", "=")} ${theme.fg("toolOutput", evaluation.result)}${evaluation.type === undefined ? "" : theme.fg("dim", ` ${evaluation.type}`)}`,
53
+ );
54
+ }
55
+ return new Text(lines.join("\n"), 0, 0);
48
56
  }
49
57
 
50
58
  /** Render one compact live session for the below-editor activity widget. */
@@ -122,6 +130,7 @@ function actionLabel(action: string): string {
122
130
  if (normalized === "step over") return "↷ step over";
123
131
  if (normalized === "step into") return "↓ step into";
124
132
  if (normalized === "step out") return "↑ step out";
133
+ if (normalized.startsWith("evaluate ")) return `◆ ${action.trim().slice("evaluate ".length)}`;
125
134
  if (normalized.startsWith("breakpoint ")) return `● add ${normalized}`;
126
135
  if (normalized.startsWith("delete-breakpoint ")) {
127
136
  return `○ remove breakpoint · ${normalized.slice("delete-breakpoint ".length)}`;
@@ -68,6 +68,13 @@ export interface DebugFrame {
68
68
  readonly source?: { readonly path?: string; readonly name?: string };
69
69
  }
70
70
 
71
+ export interface DebugEvaluation {
72
+ readonly expression: string;
73
+ readonly result: string;
74
+ readonly type?: string;
75
+ readonly variablesReference: number;
76
+ }
77
+
71
78
  export interface DebugSourceLine {
72
79
  readonly lineNumber: number;
73
80
  readonly content: string;
@@ -130,6 +137,11 @@ interface ScopesBody {
130
137
  interface VariablesBody {
131
138
  readonly variables?: readonly DebugVariable[];
132
139
  }
140
+ interface EvaluateBody {
141
+ readonly result?: string;
142
+ readonly type?: string;
143
+ readonly variablesReference?: number;
144
+ }
133
145
  interface SetBreakpointsBody {
134
146
  readonly breakpoints?: readonly { readonly verified?: boolean; readonly line?: number }[];
135
147
  }
@@ -363,6 +375,33 @@ export class DebugSessionManager {
363
375
  return session;
364
376
  }
365
377
 
378
+ /** Evaluate one expression in the currently selected stopped frame. */
379
+ async evaluate(
380
+ session: DebugSession,
381
+ expression: string,
382
+ signal?: AbortSignal,
383
+ ): Promise<DebugEvaluation> {
384
+ if (session.status !== "stopped" || session.stop?.frame === undefined) {
385
+ throw new Error(`Cannot evaluate while session is ${session.status}`);
386
+ }
387
+ const trimmed = expression.trim();
388
+ if (trimmed.length === 0) throw new Error("Debug evaluation requires an expression");
389
+ const response = await requiredClient(session).request<EvaluateBody>(
390
+ "evaluate",
391
+ { expression: trimmed, frameId: session.stop.frame.id, context: "repl" },
392
+ { signal },
393
+ );
394
+ if (typeof response.result !== "string") {
395
+ throw new Error("Debug adapter returned no evaluation result");
396
+ }
397
+ return {
398
+ expression: trimmed,
399
+ result: response.result,
400
+ variablesReference: response.variablesReference ?? 0,
401
+ ...(response.type === undefined ? {} : { type: response.type }),
402
+ };
403
+ }
404
+
366
405
  /** Terminate an owned debuggee and remove its session. */
367
406
  async delete(source: string, signal?: AbortSignal): Promise<void> {
368
407
  const session = this.get(source);
@@ -1,14 +1,51 @@
1
- import type { DebugSessionSnapshot } from "#src/plugins/pi-agent-ide-debugger/src/session-manager.js";
1
+ import type {
2
+ DebugEvaluation,
3
+ DebugSessionSnapshot,
4
+ } from "#src/plugins/pi-agent-ide-debugger/src/session-manager.js";
2
5
 
3
6
  /** Extract one immutable snapshot from a debugger semantic-action receipt. */
4
7
  export function debuggerSnapshotFromResult(details: unknown): DebugSessionSnapshot | undefined {
8
+ const semantic = semanticActionFromResult(details);
9
+ if (semantic === undefined) return undefined;
10
+ const snapshot = semantic.snapshot;
11
+ return typeof snapshot === "object" && snapshot !== null
12
+ ? (snapshot as DebugSessionSnapshot)
13
+ : undefined;
14
+ }
15
+
16
+ /** Extract an evaluation result from a debugger semantic-action receipt. */
17
+ export function debuggerEvaluationFromResult(details: unknown): DebugEvaluation | undefined {
18
+ const semantic = semanticActionFromResult(details);
19
+ if (semantic === undefined) return undefined;
20
+ const evaluation = semantic.evaluation;
21
+ if (
22
+ typeof evaluation !== "object" ||
23
+ evaluation === null ||
24
+ !("expression" in evaluation) ||
25
+ typeof evaluation.expression !== "string" ||
26
+ !("result" in evaluation) ||
27
+ typeof evaluation.result !== "string" ||
28
+ !("variablesReference" in evaluation) ||
29
+ typeof evaluation.variablesReference !== "number"
30
+ ) {
31
+ return undefined;
32
+ }
33
+ return {
34
+ expression: evaluation.expression,
35
+ result: evaluation.result,
36
+ variablesReference: evaluation.variablesReference,
37
+ ...("type" in evaluation && typeof evaluation.type === "string"
38
+ ? { type: evaluation.type }
39
+ : {}),
40
+ };
41
+ }
42
+
43
+ function semanticActionFromResult(details: unknown): Readonly<Record<string, unknown>> | undefined {
5
44
  if (typeof details !== "object" || details === null) return undefined;
6
45
  const metadata = (details as { readonly metadata?: unknown }).metadata;
7
46
  if (typeof metadata !== "object" || metadata === null) return undefined;
8
47
  const semantic = (metadata as { readonly semanticAction?: unknown }).semanticAction;
9
- if (typeof semantic !== "object" || semantic === null) return undefined;
10
- const snapshot = (semantic as { readonly snapshot?: unknown }).snapshot;
11
- return typeof snapshot === "object" && snapshot !== null
12
- ? (snapshot as DebugSessionSnapshot)
48
+ return typeof semantic === "object" && semantic !== null
49
+ ? (semantic as Readonly<Record<string, unknown>>)
13
50
  : undefined;
14
51
  }
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-formatter",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.6.1"
6
+ "pi-agent-doctor": "0.6.3"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "peerDependencies": {
14
14
  "@earendil-works/pi-coding-agent": "*",
15
- "pi-agent-ide": "0.6.1"
15
+ "pi-agent-ide": "0.6.3"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "pi-agent-ide": {
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-languages",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.6.1"
6
+ "pi-agent-doctor": "0.6.3"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-ide-lint",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.6.1",
7
- "pi-agent-invariant": "0.6.1",
8
- "pi-agent-read": "0.6.1",
9
- "pi-agent-resource": "0.6.1",
10
- "pi-agent-text": "0.6.1"
6
+ "pi-agent-doctor": "0.6.3",
7
+ "pi-agent-invariant": "0.6.3",
8
+ "pi-agent-read": "0.6.3",
9
+ "pi-agent-resource": "0.6.3",
10
+ "pi-agent-text": "0.6.3"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@earendil-works/pi-coding-agent": "*",
19
- "pi-agent-ide": "0.6.1"
19
+ "pi-agent-ide": "0.6.3"
20
20
  },
21
21
  "peerDependenciesMeta": {
22
22
  "pi-agent-ide": {
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-ide-lsp",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "cross-spawn": "^7.0.6",
7
- "pi-agent-doctor": "0.6.1",
8
- "pi-agent-invariant": "0.6.1",
9
- "pi-agent-read": "0.6.1",
10
- "pi-agent-resource": "0.6.1",
11
- "pi-agent-search": "0.6.1",
12
- "pi-agent-text": "0.6.1",
13
- "pi-agent-text-editor": "0.6.1",
7
+ "pi-agent-doctor": "0.6.3",
8
+ "pi-agent-invariant": "0.6.3",
9
+ "pi-agent-read": "0.6.3",
10
+ "pi-agent-resource": "0.6.3",
11
+ "pi-agent-search": "0.6.3",
12
+ "pi-agent-text": "0.6.3",
13
+ "pi-agent-text-editor": "0.6.3",
14
14
  "vscode-jsonrpc": "^9.0.0",
15
15
  "vscode-uri": "^3.1.0"
16
16
  },
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "*",
24
- "pi-agent-ide": "0.6.1"
24
+ "pi-agent-ide": "0.6.3"
25
25
  },
26
26
  "peerDependenciesMeta": {
27
27
  "pi-agent-ide": {