@murongg/aah-cli 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -10,6 +10,20 @@ npm install -g @murongg/aah-cli
10
10
 
11
11
  The npm package has its own standalone CLI version and downloads the matching prebuilt native binary from the `cli-vX.Y.Z` GitHub Release during installation.
12
12
 
13
+ On macOS or Linux, you can install the standalone Release binary without npm:
14
+
15
+ ```bash
16
+ curl -fsSL https://raw.githubusercontent.com/murongg/ai-accounts-hub/main/scripts/install-aah.sh | sh
17
+ ```
18
+
19
+ Pin a version or install into another directory:
20
+
21
+ ```bash
22
+ curl -fsSL https://raw.githubusercontent.com/murongg/ai-accounts-hub/main/scripts/install-aah.sh -o install-aah.sh
23
+ AAH_VERSION=0.1.3 sh install-aah.sh
24
+ AAH_INSTALL_DIR=/usr/local/bin sh install-aah.sh
25
+ ```
26
+
13
27
  Publishing from GitHub Actions requires the repository secret `NPM_TOKEN` to be an npm Automation token when the npm account has publish 2FA enabled. A regular publish token will fail with `EOTP` because CI cannot provide a one-time password.
14
28
 
15
29
  ## Usage
@@ -31,12 +45,18 @@ TUI shortcuts:
31
45
  Run script-friendly commands:
32
46
 
33
47
  ```bash
48
+ aah add --provider codex
34
49
  aah list
35
50
  aah current
36
51
  aah refresh
52
+ aah upgrade
37
53
  aah switch --provider codex user@example.com
38
54
  ```
39
55
 
56
+ `aah add --provider ...` starts the provider's login flow, stores the account in the managed account pool, and leaves the current active CLI account unchanged.
57
+
58
+ `aah upgrade` checks the latest `cli-vX.Y.Z` release, auto-detects how the CLI was installed, and upgrades in place when safe. On older installs that do not have install metadata yet, it may print a one-line manual upgrade command instead of upgrading directly.
59
+
40
60
  Filter by provider:
41
61
 
42
62
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@murongg/aah-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Standalone AI Accounts Hub CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,6 +32,50 @@ export function releaseTagForVersion(version) {
32
32
  return `cli-v${version}`;
33
33
  }
34
34
 
35
+ export function installMetadataPathForEnv(env = process.env, platform = process.platform) {
36
+ if (platform === "win32") {
37
+ const appData = env.APPDATA;
38
+ if (!appData) {
39
+ throw new Error("APPDATA is required on Windows");
40
+ }
41
+ return path.join(appData, "aah", "cli-install.json");
42
+ }
43
+
44
+ const home = env.HOME ?? os.homedir();
45
+ const configRoot = env.XDG_CONFIG_HOME ?? path.join(home, ".config");
46
+ return path.join(configRoot, "aah", "cli-install.json");
47
+ }
48
+
49
+ export function detectPackageManagerFromEnv(env = process.env) {
50
+ const userAgent = env.npm_config_user_agent ?? "";
51
+ if (userAgent.startsWith("pnpm/")) {
52
+ return "pnpm";
53
+ }
54
+ if (userAgent.startsWith("yarn/")) {
55
+ return "yarn";
56
+ }
57
+ if (userAgent.startsWith("bun/")) {
58
+ return "bun";
59
+ }
60
+ return "npm";
61
+ }
62
+
63
+ export function writeInstallMetadata(packageRoot, env = process.env, platform = process.platform) {
64
+ const metadataPath = installMetadataPathForEnv(env, platform);
65
+ const binaryPath = binaryPathForPackage(packageRoot, platform);
66
+ const metadata = {
67
+ schema_version: 1,
68
+ install_method: "package-manager",
69
+ package_manager: detectPackageManagerFromEnv(env),
70
+ package_name: "@murongg/aah-cli",
71
+ binary_path: binaryPath,
72
+ installed_at: new Date().toISOString(),
73
+ };
74
+
75
+ fs.mkdirSync(path.dirname(metadataPath), { recursive: true });
76
+ fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2));
77
+ }
78
+
35
79
  function download(url, targetPath) {
36
80
  return new Promise((resolve, reject) => {
37
81
  https
@@ -80,6 +124,8 @@ async function main() {
80
124
  if (process.platform !== "win32") {
81
125
  fs.chmodSync(binaryPath, 0o755);
82
126
  }
127
+
128
+ writeInstallMetadata(packageRoot);
83
129
  }
84
130
 
85
131
  if (process.argv[1] && import.meta.url === new URL(process.argv[1], "file:").href) {