ticketpro-auto-setup 1.1.4 → 1.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.
@@ -3,10 +3,12 @@
3
3
  * npm 包: code-abyss (by telagod)
4
4
  * 支持: npx code-abyss --target claude|codex
5
5
  */
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
6
8
  import { spawn } from 'node:child_process';
7
9
  import ora from 'ora';
8
10
  import { execAsync } from '../utils/shell.js';
9
- import { getPlatform } from '../utils/platform.js';
11
+ import { getPlatform, getClaudeDir } from '../utils/platform.js';
10
12
  import { log } from '../utils/logger.js';
11
13
  /**
12
14
  * 安装 code-abyss(邪修道统 · 安全工程技能)
@@ -42,10 +44,13 @@ export async function installCodeAbyss(target) {
42
44
  async function runCodeAbyss(target, spinner) {
43
45
  const name = target === 'codex' ? 'code-abyss (Codex)' : 'code-abyss';
44
46
  const { npxCmd, npmCmd } = getPlatform();
45
- // 方式 1: npx -y code-abyss --target <target>
47
+ // 方式 1: npx -y code-abyss --target <target> -y
46
48
  spinner.text = `Installing code-abyss → ${target} (npx)...`;
47
49
  const result = await spawnCodeAbyss(npxCmd, ['-y', 'code-abyss', '--target', target, '-y']);
48
50
  if (result.success) {
51
+ if (target === 'claude') {
52
+ ensureCclineStatusLine();
53
+ }
49
54
  spinner.succeed(`code-abyss installed → ${target}`);
50
55
  return { name, success: true };
51
56
  }
@@ -58,6 +63,9 @@ async function runCodeAbyss(target, spinner) {
58
63
  spinner.text = `Running code-abyss → ${target} (global)...`;
59
64
  const execResult = await spawnCodeAbyss('code-abyss', ['--target', target, '-y']);
60
65
  if (execResult.success) {
66
+ if (target === 'claude') {
67
+ ensureCclineStatusLine();
68
+ }
61
69
  spinner.succeed(`code-abyss installed → ${target} (global)`);
62
70
  return { name, success: true };
63
71
  }
@@ -74,11 +82,11 @@ async function runCodeAbyss(target, spinner) {
74
82
  * 通过 spawn 执行 code-abyss,周期性向 stdin 写 "N\n" 自动跳过交互提示
75
83
  * - 不阻塞事件循环(spinner 可正常旋转)
76
84
  * - 跨平台(Windows/Linux/Mac)
77
- * - 丢弃 stdout/stderr 避免缓冲区溢出
85
+ * - 固定 cwd 到 home,避免 uv_cwd / getcwd 异常
78
86
  */
79
87
  function spawnCodeAbyss(command, args) {
80
88
  return new Promise((resolve) => {
81
- const { isWindows } = getPlatform();
89
+ const { isWindows, homeDir } = getPlatform();
82
90
  const timeout = 300_000; // 5 min
83
91
  // 用 shell -c 拼接命令字符串,避免 DEP0190 警告
84
92
  // (spawn 同时传 args + shell: true 会触发 Node 弃用警告)
@@ -86,6 +94,7 @@ function spawnCodeAbyss(command, args) {
86
94
  const shellArg = isWindows ? '/c' : '-c';
87
95
  const fullCmd = [command, ...args].join(' ');
88
96
  const child = spawn(shell, [shellArg, fullCmd], {
97
+ cwd: homeDir,
89
98
  env: { ...process.env, CI: 'true', FORCE_COLOR: '0' },
90
99
  stdio: ['pipe', 'pipe', 'pipe'],
91
100
  });
@@ -121,4 +130,56 @@ function spawnCodeAbyss(command, args) {
121
130
  });
122
131
  });
123
132
  }
133
+ /**
134
+ * 兜底确保 statusLine 指向 ccline。
135
+ * 某些环境下 code-abyss 可能因配置合并策略未写入该字段,
136
+ * 这里做最小补丁,不覆盖用户其它配置。
137
+ */
138
+ function ensureCclineStatusLine() {
139
+ try {
140
+ const claudeDir = getClaudeDir();
141
+ const settingsPath = path.join(claudeDir, 'settings.json');
142
+ // 兜底:如果 ~/.claude/ccline/ccline 不存在,但系统 PATH 有 ccline,
143
+ // 创建一个软链接到 ~/.claude/ccline/ccline,确保 statusLine 路径稳定可用。
144
+ const cclineDir = path.join(claudeDir, 'ccline');
145
+ const localCcline = path.join(cclineDir, 'ccline');
146
+ if (!fs.existsSync(localCcline)) {
147
+ const globalPath = '/usr/local/bin/ccline';
148
+ if (fs.existsSync(globalPath)) {
149
+ fs.mkdirSync(cclineDir, { recursive: true });
150
+ try {
151
+ fs.symlinkSync(globalPath, localCcline);
152
+ }
153
+ catch { /* ignore */ }
154
+ }
155
+ }
156
+ if (!fs.existsSync(settingsPath))
157
+ return;
158
+ let settings = {};
159
+ try {
160
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
161
+ }
162
+ catch {
163
+ return;
164
+ }
165
+ const desired = {
166
+ type: 'command',
167
+ command: '~/.claude/ccline/ccline',
168
+ padding: 0,
169
+ };
170
+ const current = settings.statusLine;
171
+ const hasCcline = current &&
172
+ typeof current === 'object' &&
173
+ typeof current.command === 'string' &&
174
+ current.command.includes('ccline');
175
+ if (!hasCcline) {
176
+ settings.statusLine = desired;
177
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
178
+ log.success('ccline statusLine patched in ~/.claude/settings.json');
179
+ }
180
+ }
181
+ catch {
182
+ // 静默兜底,不影响主流程
183
+ }
184
+ }
124
185
  //# sourceMappingURL=code-abyss.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ticketpro-auto-setup",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "TicketPro Auto Setup Wizard — 一键配置 Claude Code CLI / Codex CLI",
5
5
  "type": "module",
6
6
  "bin": {