create-agentuity 1.0.62 → 1.0.64

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.js +54 -12
  2. package/package.json +2 -2
package/bin.js CHANGED
@@ -1,24 +1,66 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from 'node:child_process';
3
+ import { realpathSync } from 'node:fs';
3
4
  import { createRequire } from 'node:module';
5
+ import { fileURLToPath } from 'node:url';
4
6
 
5
7
  const require = createRequire(import.meta.url);
6
8
  const pkg = require('./package.json');
7
9
 
8
- // Determine the dist-tag based on create-agentuity version
9
- // Prerelease versions (e.g., 2.0.0-beta.1) should use @next
10
- // Stable versions should use @latest
11
- function getDistTag(version) {
12
- // Check for prerelease identifiers: alpha, beta, rc, canary, next, etc.
10
+ /**
11
+ * Derive the @agentuity/cli version specifier from the create-agentuity version.
12
+ *
13
+ * Since create-agentuity and @agentuity/cli are published in lockstep with
14
+ * identical version numbers, we use the exact version to ensure compatibility.
15
+ *
16
+ * This matters when users pin a specific version, e.g.:
17
+ * bun create agentuity@^1.0.0 → should use @agentuity/cli@1.0.x, not @latest
18
+ * bun create agentuity@2.0.0 → should use @agentuity/cli@2.0.0
19
+ * bun create agentuity → uses @latest create-agentuity, gets matching CLI
20
+ *
21
+ * Prerelease versions use their dist-tag instead:
22
+ * - Beta versions (-beta.) → @beta
23
+ * - Other prereleases (-alpha., -rc., etc.) → @next
24
+ *
25
+ * @param {string} version - The create-agentuity package version
26
+ * @returns {string} Version specifier for @agentuity/cli (e.g. "1.0.63", "beta", "next")
27
+ */
28
+ export function getCliVersionSpecifier(version) {
29
+ // Check for beta prerelease first
30
+ if (/-beta\./.test(version)) {
31
+ return 'beta';
32
+ }
33
+ // Check for other prerelease identifiers: alpha, rc, canary, next, etc.
13
34
  if (/-([a-zA-Z]+)/.test(version)) {
14
35
  return 'next';
15
36
  }
16
- return 'latest';
37
+ // Stable versions: use the exact version to ensure major version compatibility
38
+ return version;
17
39
  }
18
40
 
19
- const distTag = getDistTag(pkg.version);
20
- const args = process.argv.slice(2);
21
- const result = spawnSync('bunx', [`@agentuity/cli@${distTag}`, 'create', ...args], {
22
- stdio: 'inherit',
23
- });
24
- process.exit(result.status || 0);
41
+ // Only run when executed directly, not when imported for testing.
42
+ // When bunx runs this script, it creates a symlink (e.g. ~/.bun/bin/create-agentuity)
43
+ // pointing to the real file. process.argv[1] is the symlink path while import.meta.url
44
+ // resolves to the real path, so we must resolve symlinks before comparing.
45
+ function checkIsMain() {
46
+ const scriptPath = fileURLToPath(import.meta.url);
47
+ if (typeof Bun !== 'undefined') {
48
+ return Bun.main === scriptPath;
49
+ }
50
+ try {
51
+ return realpathSync(process.argv[1]) === scriptPath;
52
+ } catch {
53
+ return process.argv[1] === scriptPath;
54
+ }
55
+ }
56
+
57
+ const isMain = checkIsMain();
58
+
59
+ if (isMain) {
60
+ const cliVersion = getCliVersionSpecifier(pkg.version);
61
+ const args = process.argv.slice(2);
62
+ const result = spawnSync('bunx', [`@agentuity/cli@${cliVersion}`, 'create', ...args], {
63
+ stdio: 'inherit',
64
+ });
65
+ process.exit(result.status || 0);
66
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-agentuity",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Agentuity employees and contributors",
6
6
  "description": "Create a new Agentuity project",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "scripts": {
12
12
  "build": "echo 'No build required'",
13
- "test": "echo 'No tests for create-agentuity (CLI wrapper)'"
13
+ "test": "bun test bin.test.js"
14
14
  },
15
15
  "files": [
16
16
  "bin.js"