@companion-ai/feynman 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companion-ai/feynman",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Research-first CLI agent built on Pi and alphaXiv",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,14 +5,40 @@ import { fileURLToPath } from "node:url";
5
5
 
6
6
  const here = dirname(fileURLToPath(import.meta.url));
7
7
  const appRoot = resolve(here, "..");
8
- const piPackageRoot = resolve(appRoot, "node_modules", "@mariozechner", "pi-coding-agent");
8
+
9
+ function findNodeModules() {
10
+ let dir = appRoot;
11
+ while (dir !== dirname(dir)) {
12
+ const nm = resolve(dir, "node_modules");
13
+ if (existsSync(nm)) return nm;
14
+ dir = dirname(dir);
15
+ }
16
+ return resolve(appRoot, "node_modules");
17
+ }
18
+
19
+ const nodeModules = findNodeModules();
20
+
21
+ function findPackageRoot(packageName) {
22
+ const candidate = resolve(nodeModules, packageName);
23
+ if (existsSync(resolve(candidate, "package.json"))) return candidate;
24
+ return null;
25
+ }
26
+
27
+ const piPackageRoot = findPackageRoot("@mariozechner/pi-coding-agent");
28
+ const piTuiRoot = findPackageRoot("@mariozechner/pi-tui");
29
+ const piAiRoot = findPackageRoot("@mariozechner/pi-ai");
30
+
31
+ if (!piPackageRoot) {
32
+ console.warn("[feynman] pi-coding-agent not found, skipping patches");
33
+ process.exit(0);
34
+ }
35
+
9
36
  const packageJsonPath = resolve(piPackageRoot, "package.json");
10
37
  const cliPath = resolve(piPackageRoot, "dist", "cli.js");
11
38
  const bunCliPath = resolve(piPackageRoot, "dist", "bun", "cli.js");
12
39
  const interactiveModePath = resolve(piPackageRoot, "dist", "modes", "interactive", "interactive-mode.js");
13
40
  const interactiveThemePath = resolve(piPackageRoot, "dist", "modes", "interactive", "theme", "theme.js");
14
- const piTuiRoot = resolve(appRoot, "node_modules", "@mariozechner", "pi-tui");
15
- const editorPath = resolve(piTuiRoot, "dist", "components", "editor.js");
41
+ const editorPath = piTuiRoot ? resolve(piTuiRoot, "dist", "components", "editor.js") : null;
16
42
  const workspaceRoot = resolve(appRoot, ".feynman", "npm", "node_modules");
17
43
  const webAccessPath = resolve(workspaceRoot, "pi-web-access", "index.ts");
18
44
  const sessionSearchIndexerPath = resolve(
@@ -85,7 +111,7 @@ if (existsSync(interactiveThemePath)) {
85
111
  writeFileSync(interactiveThemePath, themeSource, "utf8");
86
112
  }
87
113
 
88
- if (existsSync(editorPath)) {
114
+ if (editorPath && existsSync(editorPath)) {
89
115
  let editorSource = readFileSync(editorPath, "utf8");
90
116
  const importOriginal =
91
117
  'import { getSegmenter, isPunctuationChar, isWhitespaceChar, truncateToWidth, visibleWidth } from "../utils.js";';
@@ -250,9 +276,9 @@ if (existsSync(sessionSearchIndexerPath)) {
250
276
  }
251
277
  }
252
278
 
253
- const oauthPagePath = resolve(appRoot, "node_modules", "@mariozechner", "pi-ai", "dist", "utils", "oauth", "oauth-page.js");
279
+ const oauthPagePath = piAiRoot ? resolve(piAiRoot, "dist", "utils", "oauth", "oauth-page.js") : null;
254
280
 
255
- if (existsSync(oauthPagePath)) {
281
+ if (oauthPagePath && existsSync(oauthPagePath)) {
256
282
  let source = readFileSync(oauthPagePath, "utf8");
257
283
  const piLogo = 'const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800" aria-hidden="true"><path fill="#fff" fill-rule="evenodd" d="M165.29 165.29 H517.36 V400 H400 V517.36 H282.65 V634.72 H165.29 Z M282.65 282.65 V400 H400 V282.65 Z"/><path fill="#fff" d="M517.36 400 H634.72 V634.72 H517.36 Z"/></svg>`;';
258
284
  if (source.includes(piLogo)) {