@oh-my-pi/pi-coding-agent 15.5.13 → 15.5.15

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 (39) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/types/config/model-registry.d.ts +1 -1
  3. package/dist/types/config/models-config-schema.d.ts +2 -0
  4. package/dist/types/config/settings-schema.d.ts +1 -10
  5. package/dist/types/eval/__tests__/llm-bridge.test.d.ts +1 -0
  6. package/dist/types/eval/llm-bridge.d.ts +25 -0
  7. package/dist/types/export/html/template.generated.d.ts +1 -1
  8. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +15 -0
  9. package/dist/types/modes/theme/theme.d.ts +2 -1
  10. package/dist/types/session/agent-session.d.ts +2 -0
  11. package/dist/types/tools/index.d.ts +0 -1
  12. package/package.json +8 -8
  13. package/src/config/model-registry.ts +89 -5
  14. package/src/config/models-config-schema.ts +1 -1
  15. package/src/config/settings-schema.ts +1 -10
  16. package/src/eval/__tests__/llm-bridge.test.ts +297 -0
  17. package/src/eval/js/shared/prelude.txt +8 -0
  18. package/src/eval/js/tool-bridge.ts +4 -0
  19. package/src/eval/llm-bridge.ts +181 -0
  20. package/src/eval/py/prelude.py +52 -31
  21. package/src/export/html/template.generated.ts +1 -1
  22. package/src/export/html/template.js +0 -13
  23. package/src/extensibility/plugins/legacy-pi-compat.ts +60 -23
  24. package/src/internal-urls/docs-index.generated.ts +3 -4
  25. package/src/main.ts +4 -0
  26. package/src/modes/components/model-selector.ts +119 -22
  27. package/src/modes/components/status-line/presets.ts +1 -0
  28. package/src/modes/components/status-line/segments.ts +23 -0
  29. package/src/modes/interactive-mode.ts +22 -87
  30. package/src/modes/theme/theme.ts +7 -0
  31. package/src/prompts/tools/eval.md +2 -0
  32. package/src/session/agent-session.ts +19 -0
  33. package/src/session/session-manager.ts +47 -0
  34. package/src/tools/eval.ts +24 -48
  35. package/src/tools/index.ts +0 -4
  36. package/src/tools/renderers.ts +0 -2
  37. package/dist/types/tools/calculator.d.ts +0 -77
  38. package/src/prompts/tools/calculator.md +0 -10
  39. package/src/tools/calculator.ts +0 -541
@@ -1227,17 +1227,6 @@
1227
1227
  return html;
1228
1228
  }
1229
1229
 
1230
- function renderCalc(name, args, result, ctx) {
1231
- let html = toolHead('calc');
1232
- const exprs = args.expressions || (args.expression ? [args.expression] : []);
1233
- for (const e of exprs) html += codeBlock(String(e), 'plaintext');
1234
- if (result) {
1235
- const output = ctx.getResultText();
1236
- if (output) html += formatExpandableOutput(output, 6);
1237
- }
1238
- return html;
1239
- }
1240
-
1241
1230
  function renderJob(name, args, result, ctx) {
1242
1231
  const badges = [];
1243
1232
  const pollIds = Array.isArray(args.poll) ? args.poll : Array.isArray(args.jobs) ? args.jobs : Array.isArray(args.jobIds) ? args.jobIds : [];
@@ -1558,8 +1547,6 @@
1558
1547
  yield: renderYield,
1559
1548
  report_finding: renderReportFinding,
1560
1549
  report_tool_issue: renderReportToolIssue,
1561
- calc: renderCalc,
1562
- calculator: renderCalc,
1563
1550
  await: renderJob,
1564
1551
  poll: renderJob,
1565
1552
  cancel_job: renderJob,
@@ -59,20 +59,57 @@ const resolvedSpecifierFallbacks = new Map<string, string>();
59
59
  const TYPEBOX_SPECIFIER = "@sinclair/typebox";
60
60
  const TYPEBOX_SPECIFIER_FILTER = /^@sinclair\/typebox$/;
61
61
 
62
- // Compat shim paths owned by this package. The dev branch resolves the sibling
63
- // source file via `import.meta.dir` (works in monorepo, source-link, and
64
- // node_modules installs alike, since each install layout ships the shim next
65
- // to this file). The compiled-binary branch points at the `--root`-relative
66
- // bunfs path produced by `scripts/build-binary.ts`; every shim listed below
67
- // must be registered there as an explicit `--compile` entrypoint or release
68
- // builds fail with missing-module errors. Non-shim bundled packages are
69
- // resolved via `Bun.resolveSync` (see `resolveCanonicalPiSpecifier`), so they
70
- // keep working in installed-package mode where the on-disk layout differs from
71
- // the monorepo source tree.
72
- const BUNFS_PACKAGE_ROOT = "/$bunfs/root/packages";
73
-
74
- const TYPEBOX_SHIM_PATH = IS_COMPILED_BINARY
75
- ? `${BUNFS_PACKAGE_ROOT}/coding-agent/src/extensibility/typebox.js`
62
+ // Compat shim and bundled-package paths used in compiled-binary mode. The shim
63
+ // paths must point at files that ship inside the bunfs root; in dev /
64
+ // source-link / installed-package mode the canonical specifier resolves via
65
+ // `Bun.resolveSync` so only the shim files need explicit paths there.
66
+ //
67
+ // `BUNFS_PACKAGE_ROOT` is derived from `import.meta.dir` rather than hardcoded
68
+ // as `/$bunfs/root/packages` so the prefix stays platform-native: on Windows
69
+ // the bunfs mount appears as `<drive>:\~BUN\root\…` (see oven-sh/bun#15766),
70
+ // and a hardcoded POSIX literal would normalize to `\$bunfs\root\…` and fail
71
+ // to resolve. Compiled Bun modules currently report the bunfs root itself from
72
+ // `import.meta.dir`, so appending `packages` lands on the `--root ../..`
73
+ // package directory used by `scripts/build-binary.ts`.
74
+ //
75
+ // Every shim listed below must also be registered as an explicit `--compile`
76
+ // entrypoint in `scripts/build-binary.ts` or release builds fail with
77
+ // missing-module errors. Non-shim bundled packages are resolved via
78
+ // `Bun.resolveSync` (see `resolveCanonicalPiSpecifier`) outside compiled mode,
79
+ // so they keep working when on-disk layout differs from the monorepo tree.
80
+ /**
81
+ * Compute the bunfs package root from the compiled binary's `import.meta.dir`
82
+ * (or any stand-in supplied by tests). Bun 1.3 reports the bunfs mount root
83
+ * (`/$bunfs/root` or `<drive>:\~BUN\root`) for imported modules as well as the
84
+ * entrypoint, so the normal path is `<root>/packages`.
85
+ *
86
+ * The suffix branch preserves correctness if a future Bun release switches to
87
+ * module-specific `import.meta.dir` values inside compiled binaries, matching
88
+ * the source layout:
89
+ * `<bunfs>/packages/coding-agent/src/extensibility/plugins`.
90
+ *
91
+ * Exported for tests; production callers use `BUNFS_PACKAGE_ROOT` below.
92
+ */
93
+ export function __computeBunfsPackageRoot(metaDir: string, pathImpl: typeof path = path): string {
94
+ const pluginsDirSuffix = pathImpl.join("packages", "coding-agent", "src", "extensibility", "plugins");
95
+ const normalizedMetaDir = pathImpl.normalize(metaDir);
96
+ if (normalizedMetaDir.endsWith(pluginsDirSuffix)) {
97
+ return pathImpl.resolve(metaDir, "..", "..", "..", "..");
98
+ }
99
+ return pathImpl.join(metaDir, "packages");
100
+ }
101
+
102
+ const BUNFS_PACKAGE_ROOT = IS_COMPILED_BINARY ? __computeBunfsPackageRoot(import.meta.dir) : null;
103
+
104
+ function bunfsPath(...segments: string[]): string {
105
+ if (!BUNFS_PACKAGE_ROOT) {
106
+ throw new Error("bunfsPath is only valid in compiled-binary mode");
107
+ }
108
+ return path.join(BUNFS_PACKAGE_ROOT, ...segments);
109
+ }
110
+
111
+ const TYPEBOX_SHIM_PATH = BUNFS_PACKAGE_ROOT
112
+ ? bunfsPath("coding-agent", "src", "extensibility", "typebox.js")
76
113
  : path.resolve(import.meta.dir, "../typebox.ts");
77
114
 
78
115
  // Legacy extensions historically imported `Type` (and `Static`/`TSchema`) from
@@ -83,8 +120,8 @@ const TYPEBOX_SHIM_PATH = IS_COMPILED_BINARY
83
120
  // plus the borrowed `Type` runtime from the Zod-backed TypeBox shim. Subpath
84
121
  // imports such as `@oh-my-pi/pi-ai/utils/oauth` continue to resolve directly
85
122
  // against the bundled pi-ai package.
86
- const LEGACY_PI_AI_SHIM_PATH = IS_COMPILED_BINARY
87
- ? `${BUNFS_PACKAGE_ROOT}/coding-agent/src/extensibility/legacy-pi-ai-shim.js`
123
+ const LEGACY_PI_AI_SHIM_PATH = BUNFS_PACKAGE_ROOT
124
+ ? bunfsPath("coding-agent", "src", "extensibility", "legacy-pi-ai-shim.js")
88
125
  : path.resolve(import.meta.dir, "../legacy-pi-ai-shim.ts");
89
126
 
90
127
  // The coding-agent's own `./src/index.ts` cannot be listed as an extra
@@ -92,8 +129,8 @@ const LEGACY_PI_AI_SHIM_PATH = IS_COMPILED_BINARY
92
129
  // startup (issue #1474 follow-up). Legacy `@(scope)/pi-coding-agent` root
93
130
  // imports therefore resolve through a sibling shim whose distinct file path
94
131
  // avoids that collision while re-exporting the canonical package surface.
95
- const LEGACY_PI_CODING_AGENT_SHIM_PATH = IS_COMPILED_BINARY
96
- ? `${BUNFS_PACKAGE_ROOT}/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.js`
132
+ const LEGACY_PI_CODING_AGENT_SHIM_PATH = BUNFS_PACKAGE_ROOT
133
+ ? bunfsPath("coding-agent", "src", "extensibility", "legacy-pi-coding-agent-shim.js")
97
134
  : path.resolve(import.meta.dir, "../legacy-pi-coding-agent-shim.ts");
98
135
 
99
136
  // Package-root overrides. Shim entries are always applied because they replace
@@ -106,12 +143,12 @@ const LEGACY_PI_CODING_AGENT_SHIM_PATH = IS_COMPILED_BINARY
106
143
  const LEGACY_PI_PACKAGE_ROOT_OVERRIDES: Record<string, string> = {
107
144
  [`${CANONICAL_PI_SCOPE}/pi-ai`]: LEGACY_PI_AI_SHIM_PATH,
108
145
  [`${CANONICAL_PI_SCOPE}/pi-coding-agent`]: LEGACY_PI_CODING_AGENT_SHIM_PATH,
109
- ...(IS_COMPILED_BINARY
146
+ ...(BUNFS_PACKAGE_ROOT
110
147
  ? {
111
- [`${CANONICAL_PI_SCOPE}/pi-agent-core`]: `${BUNFS_PACKAGE_ROOT}/agent/src/index.js`,
112
- [`${CANONICAL_PI_SCOPE}/pi-natives`]: `${BUNFS_PACKAGE_ROOT}/natives/native/index.js`,
113
- [`${CANONICAL_PI_SCOPE}/pi-tui`]: `${BUNFS_PACKAGE_ROOT}/tui/src/index.js`,
114
- [`${CANONICAL_PI_SCOPE}/pi-utils`]: `${BUNFS_PACKAGE_ROOT}/utils/src/index.js`,
148
+ [`${CANONICAL_PI_SCOPE}/pi-agent-core`]: bunfsPath("agent", "src", "index.js"),
149
+ [`${CANONICAL_PI_SCOPE}/pi-natives`]: bunfsPath("natives", "native", "index.js"),
150
+ [`${CANONICAL_PI_SCOPE}/pi-tui`]: bunfsPath("tui", "src", "index.js"),
151
+ [`${CANONICAL_PI_SCOPE}/pi-utils`]: bunfsPath("utils", "src", "index.js"),
115
152
  }
116
153
  : {}),
117
154
  };