ticketpro-auto-setup 1.1.5 → 1.1.6

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.
@@ -7,7 +7,7 @@ import fs from 'node:fs';
7
7
  import path from 'node:path';
8
8
  import { spawn } from 'node:child_process';
9
9
  import ora from 'ora';
10
- import { execAsync } from '../utils/shell.js';
10
+ import { execAsync, execCommand } from '../utils/shell.js';
11
11
  import { getPlatform, getClaudeDir } from '../utils/platform.js';
12
12
  import { log } from '../utils/logger.js';
13
13
  /**
@@ -133,26 +133,13 @@ function spawnCodeAbyss(command, args) {
133
133
  /**
134
134
  * 兜底确保 statusLine 指向 ccline。
135
135
  * 某些环境下 code-abyss 可能因配置合并策略未写入该字段,
136
- * 这里做最小补丁,不覆盖用户其它配置。
136
+ * 或写入了 ~/.claude/ccline/ccline 但该路径实际不存在(例如 nvm 全局安装)。
137
137
  */
138
138
  function ensureCclineStatusLine() {
139
139
  try {
140
+ const { homeDir } = getPlatform();
140
141
  const claudeDir = getClaudeDir();
141
142
  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
143
  if (!fs.existsSync(settingsPath))
157
144
  return;
158
145
  let settings = {};
@@ -162,20 +149,46 @@ function ensureCclineStatusLine() {
162
149
  catch {
163
150
  return;
164
151
  }
165
- const desired = {
166
- type: 'command',
167
- command: '~/.claude/ccline/ccline',
168
- padding: 0,
169
- };
152
+ const cclineDir = path.join(claudeDir, 'ccline');
153
+ const localCcline = path.join(cclineDir, 'ccline');
154
+ // 动态解析全局 ccline 路径(兼容 nvm: ~/.nvm/.../bin/ccline
155
+ let resolvedGlobal = '';
156
+ const whichResult = execCommand('command -v ccline', { cwd: homeDir, timeout: 5000 });
157
+ if (whichResult.success) {
158
+ resolvedGlobal = whichResult.stdout.split('\n').pop()?.trim() ?? '';
159
+ }
160
+ // 如果本地路径不存在,但全局 ccline 存在,创建软链接到本地稳定路径
161
+ if (!fs.existsSync(localCcline) && resolvedGlobal && fs.existsSync(resolvedGlobal)) {
162
+ fs.mkdirSync(cclineDir, { recursive: true });
163
+ try {
164
+ fs.symlinkSync(resolvedGlobal, localCcline);
165
+ log.success(`ccline linked: ${localCcline} -> ${resolvedGlobal}`);
166
+ }
167
+ catch {
168
+ // ignore
169
+ }
170
+ }
170
171
  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;
172
+ const currentCommand = current && typeof current === 'object' && typeof current.command === 'string'
173
+ ? current.command
174
+ : '';
175
+ const localCmd = '~/.claude/ccline/ccline';
176
+ const fallbackCmd = resolvedGlobal && fs.existsSync(resolvedGlobal) ? resolvedGlobal : localCmd;
177
+ // 需要补丁的条件:
178
+ // 1) 没有 statusLine
179
+ // 2) statusLine 不是 ccline
180
+ // 3) statusLine 指向本地 ccline 但本地文件不存在(坏链路)
181
+ const needPatch = !currentCommand ||
182
+ !currentCommand.includes('ccline') ||
183
+ (currentCommand.includes('~/.claude/ccline/ccline') && !fs.existsSync(localCcline));
184
+ if (needPatch) {
185
+ settings.statusLine = {
186
+ type: 'command',
187
+ command: fs.existsSync(localCcline) ? localCmd : fallbackCmd,
188
+ padding: 0,
189
+ };
177
190
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
178
- log.success('ccline statusLine patched in ~/.claude/settings.json');
191
+ log.success(`ccline statusLine patched: ${settings.statusLine.command}`);
179
192
  }
180
193
  }
181
194
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ticketpro-auto-setup",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "TicketPro Auto Setup Wizard — 一键配置 Claude Code CLI / Codex CLI",
5
5
  "type": "module",
6
6
  "bin": {