@oh-my-pi/pi-coding-agent 15.0.0 → 15.0.2

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 (165) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/examples/extensions/plan-mode.ts +0 -1
  3. package/package.json +10 -10
  4. package/scripts/build-binary.ts +5 -0
  5. package/src/autoresearch/helpers.ts +17 -0
  6. package/src/autoresearch/tools/log-experiment.ts +9 -17
  7. package/src/autoresearch/tools/run-experiment.ts +2 -17
  8. package/src/capability/skill.ts +7 -0
  9. package/src/cli/list-models.ts +1 -1
  10. package/src/cli/shell-cli.ts +3 -13
  11. package/src/cli/update-cli.ts +1 -1
  12. package/src/cli.ts +10 -29
  13. package/src/commands/commit.ts +10 -0
  14. package/src/commit/agentic/tools/propose-changelog.ts +8 -1
  15. package/src/commit/analysis/conventional.ts +8 -66
  16. package/src/commit/map-reduce/reduce-phase.ts +6 -65
  17. package/src/commit/pipeline.ts +2 -2
  18. package/src/commit/shared-llm.ts +89 -0
  19. package/src/config/config-file.ts +210 -0
  20. package/src/config/model-equivalence.ts +8 -11
  21. package/src/config/model-registry.ts +44 -3
  22. package/src/config/model-resolver.ts +1 -4
  23. package/src/config/settings-schema.ts +82 -1
  24. package/src/config/settings.ts +1 -1
  25. package/src/config.ts +3 -219
  26. package/src/discovery/claude-plugins.ts +19 -7
  27. package/src/edit/renderer.ts +7 -1
  28. package/src/eval/js/executor.ts +3 -0
  29. package/src/eval/js/shared/rewrite-imports.ts +2 -2
  30. package/src/eval/py/executor.ts +5 -0
  31. package/src/eval/py/runner.py +42 -11
  32. package/src/eval/py/runtime.ts +1 -0
  33. package/src/exa/factory.ts +2 -2
  34. package/src/exa/mcp-client.ts +74 -1
  35. package/src/exec/bash-executor.ts +5 -1
  36. package/src/export/html/template.generated.ts +1 -1
  37. package/src/export/html/template.js +0 -11
  38. package/src/extensibility/extensions/get-commands-handler.ts +77 -0
  39. package/src/extensibility/extensions/runner.ts +1 -1
  40. package/src/extensibility/extensions/types.ts +89 -223
  41. package/src/extensibility/hooks/types.ts +89 -314
  42. package/src/extensibility/plugins/legacy-pi-compat.ts +48 -31
  43. package/src/extensibility/shared-events.ts +343 -0
  44. package/src/extensibility/skills.ts +9 -0
  45. package/src/goals/index.ts +3 -0
  46. package/src/goals/runtime.ts +500 -0
  47. package/src/goals/state.ts +37 -0
  48. package/src/goals/tools/goal-tool.ts +237 -0
  49. package/src/hashline/anchors.ts +2 -2
  50. package/src/hashline/input.ts +2 -1
  51. package/src/hashline/parser.ts +27 -3
  52. package/src/hindsight/mental-models.ts +1 -1
  53. package/src/internal-urls/agent-protocol.ts +1 -20
  54. package/src/internal-urls/artifact-protocol.ts +1 -19
  55. package/src/internal-urls/docs-index.generated.ts +11 -12
  56. package/src/internal-urls/registry-helpers.ts +25 -0
  57. package/src/internal-urls/router.ts +8 -0
  58. package/src/internal-urls/types.ts +21 -0
  59. package/src/lsp/config.ts +15 -6
  60. package/src/lsp/defaults.json +6 -2
  61. package/src/main.ts +11 -2
  62. package/src/mcp/oauth-flow.ts +20 -0
  63. package/src/modes/acp/acp-agent.ts +327 -95
  64. package/src/modes/components/assistant-message.ts +14 -8
  65. package/src/modes/components/bash-execution.ts +24 -63
  66. package/src/modes/components/custom-message.ts +14 -40
  67. package/src/modes/components/eval-execution.ts +27 -57
  68. package/src/modes/components/execution-shared.ts +102 -0
  69. package/src/modes/components/hook-message.ts +17 -49
  70. package/src/modes/components/mcp-add-wizard.ts +26 -5
  71. package/src/modes/components/message-frame.ts +88 -0
  72. package/src/modes/components/model-selector.ts +1 -1
  73. package/src/modes/components/session-observer-overlay.ts +6 -2
  74. package/src/modes/components/session-selector.ts +1 -1
  75. package/src/modes/components/status-line/segments.ts +93 -8
  76. package/src/modes/components/status-line/types.ts +4 -0
  77. package/src/modes/components/status-line.ts +28 -10
  78. package/src/modes/components/tool-execution.ts +7 -8
  79. package/src/modes/controllers/command-controller-shared.ts +108 -0
  80. package/src/modes/controllers/command-controller.ts +13 -4
  81. package/src/modes/controllers/event-controller.ts +36 -7
  82. package/src/modes/controllers/extension-ui-controller.ts +3 -2
  83. package/src/modes/controllers/input-controller.ts +13 -0
  84. package/src/modes/controllers/mcp-command-controller.ts +56 -61
  85. package/src/modes/controllers/ssh-command-controller.ts +18 -57
  86. package/src/modes/interactive-mode.ts +624 -52
  87. package/src/modes/print-mode.ts +16 -86
  88. package/src/modes/rpc/host-uris.ts +235 -0
  89. package/src/modes/rpc/rpc-mode.ts +41 -88
  90. package/src/modes/rpc/rpc-types.ts +57 -0
  91. package/src/modes/runtime-init.ts +116 -0
  92. package/src/modes/theme/defaults/dark-poimandres.json +3 -0
  93. package/src/modes/theme/defaults/light-poimandres.json +3 -0
  94. package/src/modes/theme/theme.ts +24 -6
  95. package/src/modes/types.ts +14 -3
  96. package/src/modes/utils/context-usage.ts +13 -13
  97. package/src/modes/utils/ui-helpers.ts +10 -3
  98. package/src/plan-mode/approved-plan.ts +35 -1
  99. package/src/prompts/goals/goal-budget-limit.md +16 -0
  100. package/src/prompts/goals/goal-continuation.md +28 -0
  101. package/src/prompts/goals/goal-mode-active.md +23 -0
  102. package/src/prompts/system/plan-mode-active.md +5 -5
  103. package/src/prompts/system/plan-mode-tool-decision-reminder.md +1 -1
  104. package/src/prompts/tools/bash.md +6 -0
  105. package/src/prompts/tools/github.md +4 -4
  106. package/src/prompts/tools/goal.md +13 -0
  107. package/src/prompts/tools/hashline.md +101 -117
  108. package/src/prompts/tools/read.md +55 -36
  109. package/src/prompts/tools/resolve.md +6 -5
  110. package/src/sdk.ts +12 -5
  111. package/src/session/agent-session.ts +428 -106
  112. package/src/session/blob-store.ts +36 -3
  113. package/src/session/messages.ts +67 -2
  114. package/src/session/session-manager.ts +131 -12
  115. package/src/session/session-storage.ts +33 -15
  116. package/src/session/streaming-output.ts +309 -13
  117. package/src/slash-commands/builtin-registry.ts +18 -0
  118. package/src/ssh/ssh-executor.ts +5 -0
  119. package/src/system-prompt.ts +4 -2
  120. package/src/task/discovery.ts +5 -2
  121. package/src/task/executor.ts +19 -8
  122. package/src/task/index.ts +3 -0
  123. package/src/task/render.ts +21 -15
  124. package/src/task/types.ts +4 -0
  125. package/src/tools/ast-edit.ts +21 -120
  126. package/src/tools/ast-grep.ts +21 -119
  127. package/src/tools/bash-command-fixup.ts +47 -0
  128. package/src/tools/bash-interactive.ts +9 -1
  129. package/src/tools/bash.ts +66 -19
  130. package/src/tools/browser/attach.ts +3 -3
  131. package/src/tools/browser/launch.ts +81 -18
  132. package/src/tools/browser/registry.ts +1 -5
  133. package/src/tools/browser/render.ts +2 -2
  134. package/src/tools/browser/tab-supervisor.ts +51 -14
  135. package/src/tools/conflict-detect.ts +15 -4
  136. package/src/tools/eval.ts +12 -2
  137. package/src/tools/find.ts +20 -38
  138. package/src/tools/gh.ts +44 -10
  139. package/src/tools/index.ts +22 -11
  140. package/src/tools/inspect-image.ts +3 -10
  141. package/src/tools/job.ts +16 -7
  142. package/src/tools/output-meta.ts +202 -37
  143. package/src/tools/path-utils.ts +125 -2
  144. package/src/tools/read.ts +548 -237
  145. package/src/tools/render-utils.ts +92 -0
  146. package/src/tools/renderers.ts +2 -0
  147. package/src/tools/resolve.ts +72 -44
  148. package/src/tools/search.ts +120 -186
  149. package/src/tools/ssh.ts +3 -2
  150. package/src/tools/write.ts +64 -9
  151. package/src/utils/file-mentions.ts +1 -1
  152. package/src/utils/image-loading.ts +7 -3
  153. package/src/utils/image-resize.ts +32 -43
  154. package/src/vim/parser.ts +0 -17
  155. package/src/vim/render.ts +1 -1
  156. package/src/vim/types.ts +1 -1
  157. package/src/web/search/providers/anthropic.ts +5 -0
  158. package/src/web/search/providers/exa.ts +3 -0
  159. package/src/web/search/providers/gemini.ts +40 -95
  160. package/src/web/search/providers/jina.ts +5 -2
  161. package/src/web/search/providers/zai.ts +5 -2
  162. package/src/prompts/tools/exit-plan-mode.md +0 -6
  163. package/src/tools/exit-plan-mode.ts +0 -97
  164. package/src/utils/fuzzy.ts +0 -108
  165. package/src/utils/image-convert.ts +0 -27
@@ -1,108 +0,0 @@
1
- // Fuzzy search. Matches if all query characters appear in order (not necessarily consecutive).
2
- // Lower score = better match.
3
-
4
- export interface FuzzyMatch {
5
- matches: boolean;
6
- score: number;
7
- }
8
-
9
- export function fuzzyMatch(query: string, text: string): FuzzyMatch {
10
- const queryLower = query.toLowerCase();
11
- const textLower = text.toLowerCase();
12
-
13
- if (queryLower.length === 0) {
14
- return { matches: true, score: 0 };
15
- }
16
-
17
- if (queryLower.length > textLower.length) {
18
- return { matches: false, score: 0 };
19
- }
20
-
21
- let queryIndex = 0;
22
- let score = 0;
23
- let lastMatchIndex = -1;
24
- let consecutiveMatches = 0;
25
-
26
- for (let i = 0; i < textLower.length && queryIndex < queryLower.length; i++) {
27
- if (textLower[i] === queryLower[queryIndex]) {
28
- const isWordBoundary = i === 0 || /[\s\-_./]/.test(textLower[i - 1]!);
29
-
30
- // Reward consecutive character matches (e.g., typing "foo" matches "foobar" better than "f_o_o")
31
- if (lastMatchIndex === i - 1) {
32
- consecutiveMatches++;
33
- score -= consecutiveMatches * 5;
34
- } else {
35
- consecutiveMatches = 0;
36
- // Penalize gaps between matched characters
37
- if (lastMatchIndex >= 0) {
38
- score += (i - lastMatchIndex - 1) * 2;
39
- }
40
- }
41
-
42
- // Reward matches at word boundaries (start of words are more likely intentional targets)
43
- if (isWordBoundary) {
44
- score -= 10;
45
- }
46
-
47
- // Slight penalty for matches later in the string (prefer earlier matches)
48
- score += i * 0.1;
49
-
50
- lastMatchIndex = i;
51
- queryIndex++;
52
- }
53
- }
54
-
55
- // Not all query characters were found in order
56
- if (queryIndex < queryLower.length) {
57
- return { matches: false, score: 0 };
58
- }
59
-
60
- return { matches: true, score };
61
- }
62
-
63
- // Filter and sort items by fuzzy match quality (best matches first)
64
- // Supports space-separated tokens: all tokens must match, sorted by match count then score
65
- export function fuzzyFilter<T>(items: T[], query: string, getText: (item: T) => string): T[] {
66
- if (!query.trim()) {
67
- return items;
68
- }
69
-
70
- // Split query into tokens
71
- const tokens = query
72
- .trim()
73
- .split(/\s+/)
74
- .filter(t => t.length > 0);
75
-
76
- if (tokens.length === 0) {
77
- return items;
78
- }
79
-
80
- const results: { item: T; totalScore: number }[] = [];
81
-
82
- for (const item of items) {
83
- const text = getText(item);
84
- let totalScore = 0;
85
- let allMatch = true;
86
-
87
- // Check each token against the text - ALL must match
88
- for (const token of tokens) {
89
- const match = fuzzyMatch(token, text);
90
- if (match.matches) {
91
- totalScore += match.score;
92
- } else {
93
- allMatch = false;
94
- break;
95
- }
96
- }
97
-
98
- // Only include if all tokens match
99
- if (allMatch) {
100
- results.push({ item, totalScore });
101
- }
102
- }
103
-
104
- // Sort by score (asc, lower is better)
105
- results.sort((a, b) => a.totalScore - b.totalScore);
106
-
107
- return results.map(r => r.item);
108
- }
@@ -1,27 +0,0 @@
1
- import { ImageFormat, PhotonImage } from "@oh-my-pi/pi-natives";
2
-
3
- /**
4
- * Convert image to PNG format for terminal display.
5
- * Kitty graphics protocol requires PNG format (f=100).
6
- */
7
- export async function convertToPng(
8
- base64Data: string,
9
- mimeType: string,
10
- ): Promise<{ data: string; mimeType: string } | null> {
11
- // Already PNG, no conversion needed
12
- if (mimeType === "image/png") {
13
- return { data: base64Data, mimeType };
14
- }
15
-
16
- try {
17
- const image = await PhotonImage.parse(new Uint8Array(Buffer.from(base64Data, "base64")));
18
- const pngBuffer = await image.encode(ImageFormat.PNG, 100);
19
- return {
20
- data: Buffer.from(pngBuffer).toBase64(),
21
- mimeType: "image/png",
22
- };
23
- } catch {
24
- // Conversion failed
25
- return null;
26
- }
27
- }