@locusai/cli 0.21.8 → 0.21.10

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 (2) hide show
  1. package/bin/locus.js +48 -16
  2. package/package.json +2 -2
package/bin/locus.js CHANGED
@@ -2261,7 +2261,21 @@ function loadRegistry() {
2261
2261
  const raw = readFileSync5(registryPath, "utf-8");
2262
2262
  const parsed = JSON.parse(raw);
2263
2263
  if (typeof parsed === "object" && parsed !== null && "packages" in parsed && typeof parsed.packages === "object") {
2264
- return parsed;
2264
+ const registry = parsed;
2265
+ let pruned = false;
2266
+ for (const key of Object.keys(registry.packages)) {
2267
+ if (!key.startsWith(PACKAGE_SCOPE)) {
2268
+ delete registry.packages[key];
2269
+ pruned = true;
2270
+ }
2271
+ }
2272
+ if (pruned) {
2273
+ const tmp = `${registryPath}.tmp`;
2274
+ writeFileSync5(tmp, `${JSON.stringify(registry, null, 2)}
2275
+ `, "utf-8");
2276
+ renameSync(tmp, registryPath);
2277
+ }
2278
+ return registry;
2265
2279
  }
2266
2280
  return { packages: {} };
2267
2281
  } catch {
@@ -2277,19 +2291,26 @@ function saveRegistry(registry) {
2277
2291
  }
2278
2292
  function resolvePackageBinary(packageName) {
2279
2293
  const fullName = normalizePackageName(packageName);
2280
- const binPath = join7(getPackagesDir(), "node_modules", ".bin", fullName);
2294
+ const binName = fullName.includes("/") ? fullName.split("/").pop() : fullName;
2295
+ const binPath = join7(getPackagesDir(), "node_modules", ".bin", binName);
2281
2296
  return existsSync7(binPath) ? binPath : null;
2282
2297
  }
2283
2298
  function normalizePackageName(input) {
2284
- if (input.startsWith("@")) {
2299
+ if (input.startsWith(SCOPED_PREFIX)) {
2285
2300
  return input;
2286
2301
  }
2287
- if (input.startsWith("locus-")) {
2288
- return input;
2302
+ return `${SCOPED_PREFIX}${input}`;
2303
+ }
2304
+ function extractShortName(packageName) {
2305
+ if (packageName.startsWith(SCOPED_PREFIX)) {
2306
+ return packageName.slice(SCOPED_PREFIX.length);
2289
2307
  }
2290
- return `locus-${input}`;
2308
+ return packageName;
2291
2309
  }
2292
- var init_registry = () => {};
2310
+ var PACKAGE_SCOPE = "@locusai", SCOPED_PREFIX;
2311
+ var init_registry = __esm(() => {
2312
+ SCOPED_PREFIX = `${PACKAGE_SCOPE}/locus-`;
2313
+ });
2293
2314
 
2294
2315
  // src/commands/pkg.ts
2295
2316
  var exports_pkg = {};
@@ -2316,6 +2337,7 @@ ${bold2("Installed packages:")}
2316
2337
  for (const entry of entries) {
2317
2338
  const { name, version, manifest } = entry;
2318
2339
  const displayName = manifest.displayName || name;
2340
+ const shortName = extractShortName(name);
2319
2341
  process.stderr.write(` ${bold2(cyan2(displayName))} ${dim2(`v${version}`)}
2320
2342
  `);
2321
2343
  if (manifest.description) {
@@ -2326,7 +2348,7 @@ ${bold2("Installed packages:")}
2326
2348
  process.stderr.write(` Commands: ${manifest.commands.map((c) => green(c)).join(", ")}
2327
2349
  `);
2328
2350
  }
2329
- process.stderr.write(` Run: ${bold2(`locus pkg ${name.replace(/^locus-/, "")} --help`)}
2351
+ process.stderr.write(` Run: ${bold2(`locus pkg ${shortName} --help`)}
2330
2352
  `);
2331
2353
  process.stderr.write(`
2332
2354
  `);
@@ -2375,18 +2397,25 @@ async function pkgCommand(args, _flags) {
2375
2397
  process.exit(1);
2376
2398
  return;
2377
2399
  }
2378
- const binaryPath = entry.binaryPath;
2400
+ let binaryPath = entry.binaryPath;
2379
2401
  if (!binaryPath || !existsSync8(binaryPath)) {
2380
- process.stderr.write(`${red2("✗")} Binary for ${bold2(packageName)} not found on disk.
2402
+ const resolved = resolvePackageBinary(packageName);
2403
+ if (resolved) {
2404
+ binaryPath = resolved;
2405
+ entry.binaryPath = resolved;
2406
+ saveRegistry(registry);
2407
+ } else {
2408
+ process.stderr.write(`${red2("✗")} Binary for ${bold2(packageName)} not found on disk.
2381
2409
  `);
2382
- if (binaryPath) {
2383
- process.stderr.write(` Expected: ${dim2(binaryPath)}
2410
+ if (binaryPath) {
2411
+ process.stderr.write(` Expected: ${dim2(binaryPath)}
2384
2412
  `);
2385
- }
2386
- process.stderr.write(` Try reinstalling: ${bold2(`locus install ${packageInput} --upgrade`)}
2413
+ }
2414
+ process.stderr.write(` Try reinstalling: ${bold2(`locus install ${packageInput} --upgrade`)}
2387
2415
  `);
2388
- process.exit(1);
2389
- return;
2416
+ process.exit(1);
2417
+ return;
2418
+ }
2390
2419
  }
2391
2420
  const remainingArgs = args.slice(1);
2392
2421
  const exitCode = await spawnPackageBinary(binaryPath, remainingArgs);
@@ -2631,6 +2660,7 @@ ${yellow2("⚠")} No binary found for ${bold2(packageName)} in node_modules/.bi
2631
2660
  registry.packages[packageName] = entry;
2632
2661
  saveRegistry(registry);
2633
2662
  const verb = existing ? "upgraded" : "installed";
2663
+ const shortName = extractShortName(packageName);
2634
2664
  process.stderr.write(`
2635
2665
  ${green("✓")} Package ${verb} successfully!
2636
2666
 
@@ -2647,6 +2677,8 @@ ${green("✓")} Package ${verb} successfully!
2647
2677
  process.stderr.write(` Binary: ${dim2(binaryPath)}
2648
2678
  `);
2649
2679
  }
2680
+ process.stderr.write(` Run: ${bold2(`locus pkg ${shortName} --help`)}
2681
+ `);
2650
2682
  process.stderr.write(`
2651
2683
  `);
2652
2684
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/cli",
3
- "version": "0.21.8",
3
+ "version": "0.21.10",
4
4
  "description": "GitHub-native AI engineering assistant",
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,7 +36,7 @@
36
36
  "license": "MIT",
37
37
  "dependencies": {},
38
38
  "devDependencies": {
39
- "@locusai/sdk": "^0.21.8",
39
+ "@locusai/sdk": "^0.21.10",
40
40
  "@types/bun": "latest",
41
41
  "typescript": "^5.8.3"
42
42
  },