loopengine 0.0.16 → 0.0.17
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/dist/cli.js +21 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
// doc comments, or the README's "Define your first agent"), so using
|
|
6
6
|
// that convention doesn't mean memorizing its shape and hand-writing it
|
|
7
7
|
// every time.
|
|
8
|
+
import { realpathSync } from 'node:fs';
|
|
8
9
|
import { access, mkdir, writeFile } from 'node:fs/promises';
|
|
9
10
|
import path from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
10
12
|
const NAME_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
11
13
|
export class AgentNameError extends Error {
|
|
12
14
|
}
|
|
@@ -167,8 +169,23 @@ async function main() {
|
|
|
167
169
|
console.error(' loopengine add-subagent <parent> <name>');
|
|
168
170
|
process.exitCode = 1;
|
|
169
171
|
}
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
// A package-manager shim (npx, node_modules/.bin) invokes this file
|
|
173
|
+
// through a symlink, not its real path — process.argv[1] is the
|
|
174
|
+
// symlink's path, while Node resolves import.meta.url to the real path
|
|
175
|
+
// when loading an ES module. Comparing the raw argv[1] against the
|
|
176
|
+
// resolved module URL fails in exactly that case and main() silently
|
|
177
|
+
// never runs — realpath argv[1] first so both sides are resolved. (Same
|
|
178
|
+
// bug, same fix, as create-loopengine's own cli.ts — see its git history
|
|
179
|
+
// for the live symlink repro, and skillgarden's CLI before that.)
|
|
180
|
+
function isMain() {
|
|
181
|
+
if (!process.argv[1])
|
|
182
|
+
return false;
|
|
183
|
+
try {
|
|
184
|
+
return realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
174
189
|
}
|
|
190
|
+
if (isMain())
|
|
191
|
+
main();
|