@delta-infra/cli 1.0.26 → 1.0.27

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
@@ -4,7 +4,31 @@ Delta Infra 的命令行工具。
4
4
 
5
5
  ## 安装
6
6
 
7
- ### 方式一:直接下载 Binary(推荐)
7
+ ### 方式一:npx 一键安装(推荐)
8
+
9
+ ```bash
10
+ npx @delta-infra/cli@latest install
11
+ ```
12
+
13
+ 该命令会依次完成:
14
+ 1. **全局安装** `@delta-infra/cli`(含 Go 二进制)
15
+ 2. **安装 AI Skills** 到 `~/.agents/skills/`,自动适配 Claude Code、Codex、OpenCode、Cursor 等 AI 工具
16
+ 3. **初始化配置** `delta-cli config init`(交互式,非 TTY 跳过)
17
+ 4. **身份认证** `delta-cli auth login`(交互式,非 TTY 跳过)
18
+
19
+ AI Agent 也可以直接使用以下指令完成安装:
20
+
21
+ > 帮我安装 delta-cli:https://github.com/yzailab/delta-infra-cli
22
+
23
+ ### 卸载
24
+
25
+ ```bash
26
+ npx @delta-infra/cli@latest uninstall
27
+ ```
28
+
29
+ 清理全局包、AI Skills 和配置文件。
30
+
31
+ ### 方式二:直接下载 Binary
8
32
 
9
33
  从 [GitHub Releases](https://github.com/yzailab/delta-infra-cli/releases) 下载对应平台的压缩包(以下使用 `latest` 指向最新版):
10
34
 
@@ -30,7 +54,7 @@ Remove-Item -Path delta-cli.zip
30
54
  # 将 delta-cli.exe 放到 PATH 中的目录
31
55
  ```
32
56
 
33
- ### 方式二:一键安装脚本(国内用户推荐)
57
+ ### 方式三:一键安装脚本(国内用户推荐)
34
58
 
35
59
  安装脚本会自动尝试国内 npm 镜像(npmmirror),失败后再回退到 npm 官方源:
36
60
 
@@ -42,7 +66,7 @@ curl -L https://raw.githubusercontent.com/yzailab/delta-infra-cli/main/install.s
42
66
  Invoke-RestMethod -Uri https://raw.githubusercontent.com/yzailab/delta-infra-cli/main/install.ps1 | Invoke-Expression
43
67
  ```
44
68
 
45
- ### 方式三:npm
69
+ ### 方式四:npm
46
70
 
47
71
  ```bash
48
72
  npm install -g @delta-infra/cli
@@ -74,7 +98,7 @@ DELTA_CLI_ARCHIVE=/path/to/delta-cli-linux-amd64.tar.gz npm install -g @delta-in
74
98
  | `DELTA_CLI_FATAL_ON_ERROR` | 安装失败时退出码非 0(默认警告,用于调试)。 |
75
99
  | `DELTA_CLI_DOWNLOAD_TIMEOUT` | 单个下载源最大等待时间(毫秒,默认 120000)。 |
76
100
 
77
- ### 方式四:Go Install
101
+ ### 方式五:Go Install
78
102
 
79
103
  ```bash
80
104
  go install github.com/delta-infra/delta-infra-cli/cmd/delta-cli@latest
package/checksums.txt CHANGED
@@ -1,5 +1,5 @@
1
- 110cb296b55737119c1a0338af0c659e7c4707fe5de634697fa7ef0bcf098a25 delta-cli-darwin-amd64.tar.gz
2
- 50ed88ad864a6c1e6775c79d08977c8682e122f109e5aed3fe6abfa0452a0c26 delta-cli-darwin-arm64.tar.gz
3
- 11a43205c93dfa12e57543171c810dac20f08bdb4bf91a38c510a8989f65f806 delta-cli-linux-amd64.tar.gz
4
- 90e8f18aec87969d1b9a48ff4e74ea2eef25ef0681ee7fbb50f085a4fd2d92e1 delta-cli-linux-arm64.tar.gz
5
- b2a18ddff838feea1c3325a8c287c5e0c209f221085883c12b0f0ede75276e70 delta-cli-windows-amd64.zip
1
+ 5e91055b7ece427c10b3110250deba8ae5e36558179c7d5bc8b40ad33756848a delta-cli-darwin-amd64.tar.gz
2
+ 714633afc4617b421edf796a36aa458c28dea8dde73ad5b72a78fae82594ad25 delta-cli-darwin-arm64.tar.gz
3
+ 8c60b6eab2f3d7737cce12392bc8f5a976d2e03e45d810537afe962fa6f8e6bd delta-cli-linux-amd64.tar.gz
4
+ 773efdfbe622e2ef72900af61aaaf3c394ac55e4fcb06e430545db27e0a84f97 delta-cli-linux-arm64.tar.gz
5
+ a2746bae82332f8fe330644f39edda2ec1702c847b75e255d01630782df9388c delta-cli-windows-amd64.zip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delta-infra/cli",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Delta Sandbox CLI",
5
5
  "bin": {
6
6
  "delta-cli": "scripts/run.js"
@@ -11,6 +11,7 @@
11
11
  "files": [
12
12
  "checksums.txt",
13
13
  "scripts/install.js",
14
+ "scripts/install-wizard.js",
14
15
  "scripts/run.js",
15
16
  "skills/delta-sandbox/SKILL.md",
16
17
  "skills/delta-sandbox/references/",
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { execFileSync } = require('child_process');
5
+ const readline = require('readline');
6
+
7
+ const PKG = '@delta-infra/cli';
8
+ const SKILL_NAMES = ['delta-sandbox', 'delta-shared'];
9
+ const CONFIG_DIR = path.join(osHomedir(), '.delta-infra');
10
+
11
+ function osHomedir() {
12
+ return process.env.HOME ||
13
+ process.env.USERPROFILE ||
14
+ (process.env.HOMEDRIVE && process.env.HOMEPATH && process.env.HOMEDRIVE + process.env.HOMEPATH) ||
15
+ '/root';
16
+ }
17
+
18
+ function log(msg) { console.log('[delta-cli]', msg); }
19
+
20
+ function run(cmd, args, opts) {
21
+ execFileSync(cmd, args, { stdio: 'inherit', timeout: 120000, ...opts });
22
+ }
23
+
24
+ function runSilent(cmd, args) {
25
+ return execFileSync(cmd, args, { stdio: 'pipe', timeout: 30000 }).toString().trim();
26
+ }
27
+
28
+ function isInstalledGlobally() {
29
+ try {
30
+ const out = runSilent('npm', ['list', '-g', PKG, '--depth=0']);
31
+ return out.includes(PKG);
32
+ } catch { return false; }
33
+ }
34
+
35
+ function promptYesNo(question) {
36
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
37
+ return new Promise((resolve) => {
38
+ rl.question(`${question} [y/N] `, (answer) => {
39
+ rl.close();
40
+ resolve(answer.trim().toLowerCase() === 'y');
41
+ });
42
+ });
43
+ }
44
+
45
+ async function stepInstallGlobally() {
46
+ if (isInstalledGlobally()) {
47
+ log(`${PKG} is already installed globally.`);
48
+ return;
49
+ }
50
+ log('Installing', PKG, 'globally...');
51
+ run('npm', ['install', '-g', PKG]);
52
+ log('Global install complete.');
53
+ }
54
+
55
+ async function stepInstallSkills() {
56
+ log('Installing AI skills for delta-sandbox...');
57
+ try {
58
+ run('npx', ['-y', 'skills', 'add', 'yzailab/delta-infra-cli', '-y', '-g']);
59
+ log('AI skills installed.');
60
+ } catch {
61
+ log('Warning: skill install failed. You can retry:');
62
+ log(' npx skills add yzailab/delta-infra-cli -y -g');
63
+ }
64
+ }
65
+
66
+ function stepConfigInit() {
67
+ log('Run the following to initialize configuration:');
68
+ log(' delta-cli config init');
69
+ }
70
+
71
+ function stepAuthLogin() {
72
+ log('Run the following to authenticate:');
73
+ log(' delta-cli auth login');
74
+ }
75
+
76
+ async function stepUninstallPackage() {
77
+ if (!isInstalledGlobally()) {
78
+ log(`${PKG} is not installed globally.`);
79
+ return;
80
+ }
81
+ log('Removing', PKG, 'globally...');
82
+ run('npm', ['uninstall', '-g', PKG]);
83
+ log('Package removed.');
84
+ }
85
+
86
+ async function stepUninstallSkills() {
87
+ log('Removing AI skills...');
88
+ try {
89
+ run('npx', ['-y', 'skills', 'remove', ...SKILL_NAMES, '-g']);
90
+ log('AI skills removed.');
91
+ } catch {
92
+ log('Warning: skill removal failed. You can retry:');
93
+ log(` npx skills remove ${SKILL_NAMES.join(' ')} -g`);
94
+ }
95
+ }
96
+
97
+ function stepRemoveConfig() {
98
+ if (!fs.existsSync(CONFIG_DIR)) {
99
+ log('No config directory found.');
100
+ return;
101
+ }
102
+ log('Removing config directory:', CONFIG_DIR);
103
+ fs.rmSync(CONFIG_DIR, { recursive: true, force: true });
104
+ log('Config removed.');
105
+ }
106
+
107
+ async function doInstall() {
108
+ const isInteractive = !!process.stdin.isTTY;
109
+
110
+ log('Setting up Delta Sandbox CLI...\n');
111
+
112
+ stepInstallGlobally();
113
+ stepInstallSkills();
114
+
115
+ if (isInteractive) {
116
+ stepConfigInit();
117
+ stepAuthLogin();
118
+ log('\nSetup complete! You can now use delta-cli.');
119
+ } else {
120
+ log('\nNon-interactive mode: config and auth skipped.');
121
+ log('To complete setup, manually run:');
122
+ log(' delta-cli config init');
123
+ log(' delta-cli auth login');
124
+ }
125
+ }
126
+
127
+ async function doUninstall() {
128
+ const isInteractive = !!process.stdin.isTTY;
129
+
130
+ log('Uninstalling Delta Sandbox CLI...\n');
131
+
132
+ if (isInteractive) {
133
+ const ok = await promptYesNo('This will remove the global package, AI skills, and config. Continue?');
134
+ if (!ok) {
135
+ log('Uninstall cancelled.');
136
+ process.exit(0);
137
+ }
138
+ }
139
+
140
+ stepRemoveConfig();
141
+ stepUninstallSkills();
142
+ stepUninstallPackage();
143
+
144
+ log('\nUninstall complete.');
145
+ }
146
+
147
+ function main() {
148
+ const subcommand = process.argv[2];
149
+ if (subcommand === 'uninstall') {
150
+ doUninstall().catch((e) => {
151
+ console.error('[delta-cli] Uninstall failed:', e.message);
152
+ process.exit(1);
153
+ });
154
+ } else {
155
+ doInstall().catch((e) => {
156
+ console.error('[delta-cli] Install failed:', e.message);
157
+ process.exit(1);
158
+ });
159
+ }
160
+ }
161
+
162
+ main();
@@ -362,6 +362,12 @@ function handleError(err) {
362
362
  }
363
363
 
364
364
  if (require.main === module) {
365
+ // npx exec 上下文中跳过 postinstall 二进制下载
366
+ // run.js 在需要时会设置 DELTA_CLI_RUN=true 再次调用
367
+ if (process.env.npm_command === 'exec' && !process.env.DELTA_CLI_RUN) {
368
+ console.log('[delta-cli] postinstall skipped (npx exec context).');
369
+ process.exit(0);
370
+ }
365
371
  install({ allowSkip: true }).catch(handleError);
366
372
  }
367
373
 
package/scripts/run.js CHANGED
@@ -1,60 +1,39 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const { spawn } = require('child_process');
5
- const { install } = require('./install');
4
+ const { execFileSync } = require('child_process');
6
5
 
7
6
  const binary = path.join(
8
- __dirname,
9
- '..',
10
- 'bin',
7
+ __dirname, '..', 'bin',
11
8
  process.platform === 'win32' ? 'delta-cli.exe' : 'delta-cli'
12
9
  );
13
10
 
14
- async function ensureBinary() {
15
- if (fs.existsSync(binary)) {
16
- return;
17
- }
18
- console.error('[delta-cli] Binary not found, attempting to install...');
19
- await install({ allowSkip: false, fatal: true });
20
- if (!fs.existsSync(binary)) {
21
- throw new Error('Binary is still missing after install attempt.');
22
- }
11
+ const args = process.argv.slice(2);
12
+
13
+ if (args[0] === 'install' || args[0] === 'uninstall') {
14
+ require('./install-wizard');
15
+ process.exit(0);
23
16
  }
24
17
 
25
- async function main() {
18
+ if (!fs.existsSync(binary)) {
19
+ console.error('[delta-cli] Binary not found, installing...');
26
20
  try {
27
- await ensureBinary();
28
- } catch (err) {
29
- console.error('[delta-cli] Could not install binary:', err.message);
30
- console.error('Set DELTA_CLI_ARCHIVE to a local archive path, or reinstall the package.');
21
+ execFileSync(process.execPath, [path.join(__dirname, 'install.js')], {
22
+ env: { ...process.env, DELTA_CLI_RUN: 'true' },
23
+ stdio: 'inherit',
24
+ });
25
+ } catch (e) {
26
+ console.error('[delta-cli] Could not install binary:', e.message);
31
27
  process.exit(1);
32
28
  }
33
-
34
- const child = spawn(binary, process.argv.slice(2), {
35
- stdio: 'inherit',
36
- windowsHide: true,
37
- });
38
-
39
- child.on('error', (err) => {
40
- console.error('[delta-cli] Failed to start:', err.message);
29
+ if (!fs.existsSync(binary)) {
30
+ console.error('[delta-cli] Binary still missing after install attempt.');
41
31
  process.exit(1);
42
- });
43
-
44
- child.on('close', (code, signal) => {
45
- if (code !== null && code !== undefined) {
46
- process.exit(code);
47
- }
48
- if (signal) {
49
- try {
50
- process.kill(process.pid, signal);
51
- } catch {
52
- process.exit(1);
53
- }
54
- } else {
55
- process.exit(1);
56
- }
57
- });
32
+ }
58
33
  }
59
34
 
60
- main();
35
+ try {
36
+ execFileSync(binary, args, { stdio: 'inherit' });
37
+ } catch (e) {
38
+ process.exit(e.status || 1);
39
+ }