@oh-my-pi/pi-coding-agent 15.5.10 → 15.5.11

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.
@@ -4,6 +4,8 @@ import * as path from "node:path";
4
4
  import * as url from "node:url";
5
5
  import { isCompiledBinary } from "@oh-my-pi/pi-utils";
6
6
 
7
+ const IS_COMPILED_BINARY = isCompiledBinary();
8
+
7
9
  // Canonical scope for in-process pi packages. Plugins published against any of
8
10
  // the aliased scopes below (mariozechner's original publish, earendil-works'
9
11
  // fork, or the canonical @oh-my-pi scope itself) are remapped to this scope and
@@ -14,10 +16,9 @@ import { isCompiledBinary } from "@oh-my-pi/pi-utils";
14
16
  const CANONICAL_PI_SCOPE = "@oh-my-pi";
15
17
 
16
18
  // Scopes that have historically been used to publish (or alias) the same set
17
- // of internal pi-* packages. `@oh-my-pi` is intentionally included so that
18
- // direct imports of the canonical name still flow through `Bun.resolveSync`
19
- // against the host binary, avoiding a duplicate copy being pulled in from a
20
- // plugin's own node_modules tree at install time.
19
+ // of internal pi-* packages. `@oh-my-pi` is intentionally included so direct
20
+ // canonical imports still pass through the same host-bundled package resolution
21
+ // path instead of pulling a duplicate copy from plugin node_modules.
21
22
  const PI_SCOPE_ALIASES = ["oh-my-pi", "mariozechner", "earendil-works"] as const;
22
23
 
23
24
  // Internal pi-* package basenames bundled inside the omp binary.
@@ -58,17 +59,20 @@ const resolvedSpecifierFallbacks = new Map<string, string>();
58
59
  const TYPEBOX_SPECIFIER = "@sinclair/typebox";
59
60
  const TYPEBOX_SPECIFIER_FILTER = /^@sinclair\/typebox$/;
60
61
 
61
- // In-process compat shim paths. In dev `import.meta.dir` is the source folder of
62
- // this file, so the dev branches resolve to the real `.ts` source. In compiled
63
- // binaries `import.meta.dir` collapses to `/$bunfs/root`, so the runtime cannot
64
- // recover the source layout that way; instead, each shim file is registered as
65
- // a `--compile` entrypoint in `scripts/build-binary.ts`, which Bun emits into
66
- // bunfs at a deterministic `--root`-relative path with a `.js` extension. The
67
- // literals below must stay in sync with that listing if either path drifts,
68
- // every legacy plugin loading the shim fails with a missing-module error in
69
- // release builds (without affecting `bun test`/dev).
70
- const TYPEBOX_SHIM_PATH = isCompiledBinary()
71
- ? "/$bunfs/root/packages/coding-agent/src/extensibility/typebox.js"
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`
72
76
  : path.resolve(import.meta.dir, "../typebox.ts");
73
77
 
74
78
  // Legacy extensions historically imported `Type` (and `Static`/`TSchema`) from
@@ -79,11 +83,37 @@ const TYPEBOX_SHIM_PATH = isCompiledBinary()
79
83
  // plus the borrowed `Type` runtime from the Zod-backed TypeBox shim. Subpath
80
84
  // imports such as `@oh-my-pi/pi-ai/utils/oauth` continue to resolve directly
81
85
  // against the bundled pi-ai package.
82
- const LEGACY_PI_AI_SHIM_PATH = isCompiledBinary()
83
- ? "/$bunfs/root/packages/coding-agent/src/extensibility/legacy-pi-ai-shim.js"
86
+ const LEGACY_PI_AI_SHIM_PATH = IS_COMPILED_BINARY
87
+ ? `${BUNFS_PACKAGE_ROOT}/coding-agent/src/extensibility/legacy-pi-ai-shim.js`
84
88
  : path.resolve(import.meta.dir, "../legacy-pi-ai-shim.ts");
89
+
90
+ // The coding-agent's own `./src/index.ts` cannot be listed as an extra
91
+ // `bun --compile` entrypoint alongside the CLI entry without breaking binary
92
+ // startup (issue #1474 follow-up). Legacy `@(scope)/pi-coding-agent` root
93
+ // imports therefore resolve through a sibling shim whose distinct file path
94
+ // 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`
97
+ : path.resolve(import.meta.dir, "../legacy-pi-coding-agent-shim.ts");
98
+
99
+ // Package-root overrides. Shim entries are always applied because they replace
100
+ // (or augment) the canonical surface even in non-compiled installs. The bunfs
101
+ // entries are added only in compiled-binary mode — in dev / source-link /
102
+ // installed-package mode the canonical specifier resolves cleanly through
103
+ // `Bun.resolveSync`, and hardcoding a relative source-tree path would break
104
+ // installs where the bundled packages live at `node_modules/@oh-my-pi/pi-*`
105
+ // rather than `packages/*`.
85
106
  const LEGACY_PI_PACKAGE_ROOT_OVERRIDES: Record<string, string> = {
86
107
  [`${CANONICAL_PI_SCOPE}/pi-ai`]: LEGACY_PI_AI_SHIM_PATH,
108
+ [`${CANONICAL_PI_SCOPE}/pi-coding-agent`]: LEGACY_PI_CODING_AGENT_SHIM_PATH,
109
+ ...(IS_COMPILED_BINARY
110
+ ? {
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`,
115
+ }
116
+ : {}),
87
117
  };
88
118
 
89
119
  let isLegacyPiSpecifierShimInstalled = false;
@@ -297,14 +327,20 @@ function resolveLegacyPiSpecifier(args: { path: string; importer: string }): { p
297
327
  return { path: resolveCanonicalPiSpecifier(remappedSpecifier) };
298
328
  } catch {
299
329
  // Fallback for compiled binary mode: the bundled packages live inside
300
- // /$bunfs/root and aren't reachable by filesystem resolution. Try the
301
- // original (pre-remap) specifier against the importing file's directory,
302
- // which resolves to the plugin's installed peer dep.
330
+ // /$bunfs/root and aren't reachable by filesystem resolution. Prefer the
331
+ // canonical specifier against the importing file's directory when the
332
+ // plugin installed @oh-my-pi peer deps, then try the original legacy
333
+ // specifier for plugins that still vendor only @mariozechner or
334
+ // @earendil-works peer deps.
303
335
  const importerDir = path.dirname(args.importer);
304
336
  try {
305
- return { path: Bun.resolveSync(args.path, importerDir) };
337
+ return { path: Bun.resolveSync(remappedSpecifier, importerDir) };
306
338
  } catch {
307
- return undefined;
339
+ try {
340
+ return { path: Bun.resolveSync(args.path, importerDir) };
341
+ } catch {
342
+ return undefined;
343
+ }
308
344
  }
309
345
  }
310
346
  }
@@ -356,3 +392,8 @@ export function installLegacyPiSpecifierShim(): void {
356
392
  },
357
393
  });
358
394
  }
395
+
396
+ /** Test seam: clears the memoized canonical specifier resolutions. */
397
+ export function __resetLegacyPiResolutionCache(): void {
398
+ resolvedSpecifierFallbacks.clear();
399
+ }
package/src/index.ts CHANGED
@@ -40,8 +40,11 @@ export * from "./session/agent-session";
40
40
  // Auth and model registry
41
41
  export * from "./session/auth-storage";
42
42
  export * from "./session/messages";
43
+ export * from "./session/redis-session-storage";
43
44
  export * from "./session/session-dump-format";
44
45
  export * from "./session/session-manager";
46
+ export * from "./session/session-storage";
47
+ export * from "./session/sql-session-storage";
45
48
  export * from "./task/executor";
46
49
  export type * from "./task/types";
47
50
  // Tools (detail types and utilities)