indusagi-coding-agent 0.1.54 → 0.1.55

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.55] - Latest Release
4
+
5
+ ### Changed
6
+ - **Version Bump**: Updated package version to `0.1.55`.
7
+
8
+ ### Notes
9
+ - Package name remains **`indusagi-coding-agent`** (unchanged).
10
+ - Bin shims unchanged — `indus` and `indusagi` both resolve to `dist/cli.js`.
11
+ - Install with `npm install -g indusagi-coding-agent` once published.
12
+
3
13
  ## [0.1.54] - Latest Release
4
14
 
5
15
  ### Changed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indusagi-coding-agent",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "description": "Terminal-first TypeScript coding agent built on the indusagi framework package.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -2,7 +2,15 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
- const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
5
+ // Allow override via env or CLI arg so this script can patch a specific loader
6
+ // (e.g. the global install at /opt/homebrew/lib/node_modules/...).
7
+ // sudo node patch-indusagi-react-host.mjs /opt/homebrew/lib/node_modules/indusagi-coding-agent
8
+ const rootDir = resolve(
9
+ process.argv[2] ||
10
+ process.env.INDUSAGI_PATCH_ROOT ||
11
+ dirname(fileURLToPath(import.meta.url)),
12
+ process.argv[2] || process.env.INDUSAGI_PATCH_ROOT ? "." : "..",
13
+ );
6
14
  const originalUrlImport = 'import { pathToFileURL } from "node:url";';
7
15
  const patchedUrlImport = 'import { fileURLToPath, pathToFileURL } from "node:url";';
8
16
 
@@ -105,7 +113,13 @@ const patchedCandidateRootsLegacyBadOrder = `function candidatePackageRoots() {
105
113
  return [...roots];
106
114
  }`;
107
115
 
108
- const patchedCandidateRoots = `function candidatePackageRoots() {
116
+ // Previously-shipped patched form (no realpath of argv[1]). Triggered the
117
+ // "Objects are not valid as a React child (found: object with keys
118
+ // {$$typeof, type, key, props, _owner, _store})" error when the CLI was run
119
+ // from a global bin shim and the user's cwd contained a foreign React (e.g.
120
+ // React 19, whose elements have no `ref` field). Two header-comment variants
121
+ // are recognised because the comment text drifted between source revisions.
122
+ const patchedCandidateRootsLegacyV2 = `function candidatePackageRoots() {
109
123
  const roots = new Set();
110
124
  const addCandidate = (candidate) => {
111
125
  if (!candidate) {
@@ -128,6 +142,69 @@ const patchedCandidateRoots = `function candidatePackageRoots() {
128
142
  return [...roots];
129
143
  }`;
130
144
 
145
+ // Same shape, but built from the .ts source comment ("still work"). This is
146
+ // what shipped in indusagi@0.12.30.
147
+ const patchedCandidateRootsLegacyV2_alt = `function candidatePackageRoots() {
148
+ const roots = new Set();
149
+ const addCandidate = (candidate) => {
150
+ if (!candidate) {
151
+ return;
152
+ }
153
+ const root = findPackageRoot(candidate);
154
+ if (root) {
155
+ roots.add(root);
156
+ }
157
+ };
158
+ // Prefer the consumer package's React/Ink. The indusvx package root is a
159
+ // last-resort fallback so dev runs from inside this repo still work.
160
+ const packageRoot = fileURLToPath(new URL("../../..", import.meta.url));
161
+ addCandidate(process.env.INDUSAGI_REACT_HOST_ROOT);
162
+ addCandidate(process.argv[1] ? path.dirname(process.argv[1]) : undefined);
163
+ addCandidate(process.env.INIT_CWD);
164
+ addCandidate(process.cwd());
165
+ addCandidate(packageRoot);
166
+ return [...roots];
167
+ }`;
168
+
169
+ const patchedCandidateRoots = `function candidatePackageRoots() {
170
+ const roots = new Set();
171
+ const addCandidate = (candidate) => {
172
+ if (!candidate) {
173
+ return;
174
+ }
175
+ const root = findPackageRoot(candidate);
176
+ if (root) {
177
+ roots.add(root);
178
+ }
179
+ };
180
+ // When the CLI is invoked via a global bin symlink (e.g.
181
+ // /opt/homebrew/bin/indusagi -> .../indusagi-coding-agent/dist/cli.js),
182
+ // argv[1] sits in a bin/ directory with no package.json above it. Follow
183
+ // the symlink to find the real consumer package root, otherwise we fall
184
+ // through to process.cwd() and may pick up a foreign React (e.g. React 19,
185
+ // whose elements have keys {$$typeof, type, key, props, _owner, _store} —
186
+ // note: no \`ref\`) from the user's project, while Ink uses the bundled
187
+ // React 18. That mismatch produces "Objects are not valid as a React
188
+ // child (found: object with keys {$$typeof, type, key, props, _owner, _store})".
189
+ const __argv1 = process.argv[1];
190
+ let __argv1Real;
191
+ if (__argv1) {
192
+ try { __argv1Real = fs.realpathSync(__argv1); }
193
+ catch { __argv1Real = __argv1; }
194
+ }
195
+ // Prefer the consumer package's React/Ink so we never load a second copy
196
+ // alongside the host. The indusvx package root is a last-resort fallback
197
+ // for dev runs from inside this repo.
198
+ const packageRoot = fileURLToPath(new URL("../../..", import.meta.url));
199
+ addCandidate(process.env.INDUSAGI_REACT_HOST_ROOT);
200
+ addCandidate(__argv1Real ? path.dirname(__argv1Real) : undefined);
201
+ addCandidate(__argv1 ? path.dirname(__argv1) : undefined);
202
+ addCandidate(process.env.INIT_CWD);
203
+ addCandidate(process.cwd());
204
+ addCandidate(packageRoot);
205
+ return [...roots];
206
+ }`;
207
+
131
208
  if (!loaderPath) {
132
209
  console.warn("[patch-indusagi-react-host] Skipping patch because an indusagi react-host loader could not be found.");
133
210
  process.exit(0);
@@ -143,11 +220,15 @@ if (!next.includes(patchedUrlImport)) {
143
220
  next = next.replace(originalUrlImport, patchedUrlImport);
144
221
  }
145
222
 
146
- if (next.includes(patchedCandidateRootsLegacyBadOrder)) {
223
+ if (next.includes(patchedCandidateRootsLegacyV2)) {
224
+ next = next.replace(patchedCandidateRootsLegacyV2, patchedCandidateRoots);
225
+ } else if (next.includes(patchedCandidateRootsLegacyV2_alt)) {
226
+ next = next.replace(patchedCandidateRootsLegacyV2_alt, patchedCandidateRoots);
227
+ } else if (next.includes(patchedCandidateRootsLegacyBadOrder)) {
147
228
  next = next.replace(patchedCandidateRootsLegacyBadOrder, patchedCandidateRoots);
148
229
  } else if (next.includes(patchedCandidateRootsLegacy)) {
149
230
  next = next.replace(patchedCandidateRootsLegacy, patchedCandidateRoots);
150
- } else if (!next.includes('process.env.INDUSAGI_REACT_HOST_ROOT')) {
231
+ } else if (!next.includes('__argv1Real')) {
151
232
  if (next.includes(originalCandidateRoots)) {
152
233
  next = next.replace(originalCandidateRoots, patchedCandidateRoots);
153
234
  } else if (next.includes(originalCandidateRootsV2)) {