agentworth 0.1.12 → 0.1.14

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/bin/agentworth.js CHANGED
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import path from 'node:path';
3
4
  import { run } from '../lib/resolver.js';
4
5
 
5
- const exitCode = run(process.argv.slice(2));
6
+ // Both npm bin entries ('agentworth' and 'agwt', see package.json) point at this same
7
+ // script -- process.argv[1] carries the name the shell actually resolved (the .bin
8
+ // symlink), which is how we tell the two invocations apart without a second script.
9
+ const invokedAs = path.basename(process.argv[1] || '').replace(/\.(js|cjs|mjs)$/, '');
10
+
11
+ const exitCode = run(process.argv.slice(2), { invokedAs });
6
12
  process.exit(exitCode);
package/lib/resolver.js CHANGED
@@ -77,11 +77,19 @@ export function getCacheDir(version, homeDir) {
77
77
  /**
78
78
  * Returns the expected native binary name for the target platform.
79
79
  *
80
+ * `invokedAs` selects between the two native binaries the release tarball ships
81
+ * (`agentworth` and its `agwt` alias, see apps/cli/Cargo.toml's two [[bin]] targets) --
82
+ * anything other than exactly 'agwt' resolves to the `agentworth` binary, so an
83
+ * unrecognized or missing invocation name still gets the primary binary rather than
84
+ * silently 404ing on a name nobody built.
85
+ *
80
86
  * @param {string} [platform=process.platform]
87
+ * @param {string} [invokedAs] - basename the launcher was invoked as ('agentworth' or 'agwt')
81
88
  * @returns {string}
82
89
  */
83
- export function getBinaryName(platform = process.platform) {
84
- return platform === 'win32' ? 'agentworth.exe' : 'agentworth';
90
+ export function getBinaryName(platform = process.platform, invokedAs) {
91
+ const base = invokedAs === 'agwt' ? 'agwt' : 'agentworth';
92
+ return platform === 'win32' ? `${base}.exe` : base;
85
93
  }
86
94
 
87
95
  /**
@@ -222,6 +230,7 @@ function pathBinaryMatchesVersion(binPath, expected) {
222
230
  * @param {string} [options.version]
223
231
  * @param {string} [options.homeDir]
224
232
  * @param {boolean} [options.silent=false]
233
+ * @param {string} [options.invokedAs] - 'agentworth' or 'agwt'; picks which extracted binary is returned
225
234
  * @returns {Promise<string>} Path to extracted binary
226
235
  */
227
236
  export async function downloadAndExtractBinary(options = {}) {
@@ -229,7 +238,7 @@ export async function downloadAndExtractBinary(options = {}) {
229
238
  const arch = options.arch || process.arch;
230
239
  const version = options.version || getPackageVersion();
231
240
  const targetTriple = getTargetTriple(platform, arch);
232
- const binName = getBinaryName(platform);
241
+ const binName = getBinaryName(platform, options.invokedAs);
233
242
 
234
243
  if (!targetTriple) {
235
244
  throw new Error(`Unsupported platform/architecture: ${platform}-${arch}`);
@@ -369,6 +378,7 @@ export function findPathBinary(binName = getBinaryName(), pathEnv = process.env.
369
378
  * @param {NodeJS.ProcessEnv} [options.env=process.env]
370
379
  * @param {string} [options.baseDir=__dirname]
371
380
  * @param {string} [options.homeDir]
381
+ * @param {string} [options.invokedAs] - 'agentworth' or 'agwt'; selects which native binary to look for
372
382
  * @returns {{ found: boolean, path?: string, source?: string, error?: string }}
373
383
  */
374
384
  export function resolveBinary(options = {}) {
@@ -378,7 +388,7 @@ export function resolveBinary(options = {}) {
378
388
  const env = options.env || process.env;
379
389
  const baseDir = options.baseDir || __dirname;
380
390
  const homeDir = options.homeDir || (env.HOME ? env.HOME : os.homedir());
381
- const binName = getBinaryName(platform);
391
+ const binName = getBinaryName(platform, options.invokedAs);
382
392
  const platformKey = getPlatformKey(platform, arch);
383
393
 
384
394
  // 1. Explicit environment variable override
@@ -510,11 +520,14 @@ export function formatMissingBinaryMessage(platformKey = getPlatformKey()) {
510
520
  '',
511
521
  'AgentWorth requires the native binary to run. You can install or build it via:',
512
522
  '',
513
- ' \x1b[36m• Build from local source:\x1b[0m',
514
- ' cargo build --release -p agentworth-cli',
523
+ ' \x1b[36m• Standalone install script:\x1b[0m',
524
+ ' curl -fsSL https://agentworth.dev/install.sh | sh',
525
+ '',
526
+ ' \x1b[36m• Cargo:\x1b[0m',
527
+ ' cargo install agentworth-cli',
515
528
  '',
516
- ' \x1b[36m• Install via Cargo:\x1b[0m',
517
- ' cargo install --path apps/cli',
529
+ ' \x1b[36m• Zero-install via npx:\x1b[0m',
530
+ ' npx -y agentworth',
518
531
  '',
519
532
  ' \x1b[36m• Download the release for your platform:\x1b[0m',
520
533
  ` https://github.com/unfoundbox-crew/agentworth/releases/latest`,
@@ -547,6 +560,7 @@ export function buildChildEnv(baseEnv, npmVersion) {
547
560
  *
548
561
  * @param {string[]} [argv=process.argv.slice(2)]
549
562
  * @param {Object} [options={}]
563
+ * @param {string} [options.invokedAs] - 'agentworth' or 'agwt'; which native binary to resolve
550
564
  * @returns {number} Exit code
551
565
  */
552
566
  export function run(argv = process.argv.slice(2), options = {}) {
@@ -562,7 +576,8 @@ export function run(argv = process.argv.slice(2), options = {}) {
562
576
  await downloadAndExtractBinary({
563
577
  platform: ${JSON.stringify(options.platform || process.platform)},
564
578
  arch: ${JSON.stringify(options.arch || process.arch)},
565
- homeDir: ${JSON.stringify(options.homeDir || (options.env && options.env.HOME) || '')}
579
+ homeDir: ${JSON.stringify(options.homeDir || (options.env && options.env.HOME) || '')},
580
+ invokedAs: ${JSON.stringify(options.invokedAs || '')}
566
581
  });
567
582
  `;
568
583
  const dlResult = spawnSync(process.execPath, ['--input-type=module', '-e', syncDownloadScript], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentworth",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Discover, normalize, and understand AI-agent histories locally.",
5
5
  "type": "module",
6
6
  "main": "./lib/resolver.js",