@dalehkx/quote-cli 0.3.9 → 0.3.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dalehkx/quote-cli",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "通用询报价 CLI 工具",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,7 +13,10 @@ const require = createRequire(import.meta.url);
13
13
  const { version } = require('../../package.json');
14
14
 
15
15
  const PKG = '@dalehkx/quote-cli';
16
- const SKILL_REPO = 'asdasas1212/quote-skill';
16
+ // 主:自托管 well-known 端点(GitHub Pages,不需要认证)
17
+ // 备:GitHub slug(公开仓库时可用,私有仓库需要登录)
18
+ const SKILL_URL = 'https://asdasas1212.github.io/agent-skills';
19
+ const SKILL_REPO_FALLBACK = 'asdasas1212/quote-skill';
17
20
  const isWindows = process.platform === 'win32';
18
21
 
19
22
  function execCmd(cmd, args, opts) {
@@ -85,35 +88,50 @@ async function stepInstallCli() {
85
88
  }
86
89
  }
87
90
 
91
+ function printAgentsLine(out) {
92
+ // 去掉 ANSI 控制码,找 "Installing to:" 那行
93
+ const clean = out.replace(/\x1b\[[0-9;]*[a-zA-Z]|\[?\?25[lh]/g, '');
94
+ const line = clean.split('\n').find(l => l.includes('Installing to:'));
95
+ if (line) console.log(' ', line.trim());
96
+ }
97
+
88
98
  async function stepInstallSkill() {
89
99
  process.stdout.write(' 正在安装 Skill...');
90
100
  try {
91
- // skills CLI 静默运行,不需要 TTY,跨平台支持所有 agent
92
- await runAsync('npx', ['-y', 'skills', 'add', SKILL_REPO, '-y', '-g'], { timeout: 60000 });
101
+ // 优先尝试自托管 URL(无需认证)
102
+ const out = await runAsync('npx', ['-y', 'skills', 'add', SKILL_URL, '-y', '-g'], { timeout: 60000 });
93
103
  console.log(' 完成');
104
+ printAgentsLine(out);
94
105
  } catch {
95
- // 网络不通时回退到从全局包复制到 Claude Code
96
- console.log('');
97
- process.stdout.write(' 网络不可用,回退到本地安装...');
98
- let skillSrc;
99
106
  try {
100
- const prefix = execFileSync('npm', ['prefix', '-g'], {
101
- stdio: ['ignore', 'pipe', 'pipe'],
102
- }).toString().trim();
103
- const candidates = [
104
- path.join(prefix, 'lib', 'node_modules', PKG, 'skill'),
105
- path.join(prefix, 'node_modules', PKG, 'skill'),
106
- ];
107
- skillSrc = candidates.find(p => fs.existsSync(p));
108
- } catch { /* ignore */ }
109
-
110
- if (skillSrc) {
111
- const claudeDest = path.join(os.homedir(), '.claude', 'skills', 'cass-quote');
112
- copyDir(skillSrc, claudeDest);
113
- console.log(` 完成 (仅 Claude Code)`);
114
- } else {
107
+ // 回退到 GitHub slug(公开仓库)
108
+ const out = await runAsync('npx', ['-y', 'skills', 'add', SKILL_REPO_FALLBACK, '-y', '-g'], { timeout: 60000 });
109
+ console.log(' 完成');
110
+ printAgentsLine(out);
111
+ } catch {
112
+ // 网络不通时回退到从全局包复制到 Claude Code
115
113
  console.log('');
116
- console.error(fmt(' ✗ 安装失败,请手动执行: npx skills add %s -y -g', SKILL_REPO));
114
+ process.stdout.write(' 网络不可用,回退到本地安装...');
115
+ let skillSrc;
116
+ try {
117
+ const prefix = execFileSync('npm', ['prefix', '-g'], {
118
+ stdio: ['ignore', 'pipe', 'pipe'],
119
+ }).toString().trim();
120
+ const candidates = [
121
+ path.join(prefix, 'lib', 'node_modules', PKG, 'skill'),
122
+ path.join(prefix, 'node_modules', PKG, 'skill'),
123
+ ];
124
+ skillSrc = candidates.find(p => fs.existsSync(p));
125
+ } catch { /* ignore */ }
126
+
127
+ if (skillSrc) {
128
+ const agentsDest = path.join(os.homedir(), '.agents', 'skills', 'cass-quote');
129
+ copyDir(skillSrc, agentsDest);
130
+ console.log(` 完成`);
131
+ } else {
132
+ console.log('');
133
+ console.error(` ✗ 安装失败,请手动执行: npx skills add ${SKILL_URL} -y -g`);
134
+ }
117
135
  }
118
136
  }
119
137
  }