skillgauntlet 1.3.4 → 1.3.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.
@@ -20,7 +20,7 @@ import { renderResult } from '../lib/chart.js';
20
20
  import { makeProgress } from '../lib/progress.js';
21
21
  import { setLang, detectLang, errorText, t } from '../lib/i18n.js';
22
22
  import { resolveBin, backend, backendFor, usesOwnDeepseek, setNativeModels, HOSTS, checkModel, draftQueries, draftQuality, runTrial, requireHost, pingHost, setHostBin, binInstalled } from '../lib/trial.js';
23
- import { HOST_CLI, searchHost, installCommand, installHost, LOGIN, loginCommand } from '../lib/findhost.js';
23
+ import { HOST_CLI, searchHost, installCommand, installHost, userInstallDir, LOGIN, loginCommand } from '../lib/findhost.js';
24
24
  import { launchSpec } from '../lib/spawn.js';
25
25
  import { ensureTool } from '../lib/github.js';
26
26
  import { spawnSync as runLogin } from 'node:child_process';
@@ -71,6 +71,8 @@ async function fixMissingHost(hostId, err) {
71
71
  return true;
72
72
  }
73
73
  if (pick.install) {
74
+ const userDir = userInstallDir();
75
+ if (userDir) say(`\n${t('hostInstallUserDir', { dir: userDir })}`);
74
76
  say(`\n${t('hostInstalling', { host: label })}`);
75
77
  try { installHost(hostId); } catch (e) {
76
78
  say(t('hostInstallFailed', { why: e.message }));
package/lib/findhost.js CHANGED
@@ -73,11 +73,34 @@ export function searchHost(host, dirs = searchDirs()) {
73
73
  // Codewhale's package has an install script, and npm only runs install scripts it has been told to allow. The
74
74
  // allowance is given for this one command (--allow-scripts) rather than written into the user's npm config.
75
75
  const INSTALL_FLAGS = { codewhale: ' --allow-scripts=codewhale' };
76
- export const installCommand = (host) => (HOST_CLI[host]?.pkg ? `npm install -g ${HOST_CLI[host].pkg}${INSTALL_FLAGS[host] || ''}` : null);
76
+ // A system npm (Debian, Ubuntu, Fedora ...) keeps its global packages under /usr, which an ordinary user cannot write,
77
+ // so `npm install -g` ends in EACCES. Where that is so the install goes to the user's own ~/.local (its bin folder is
78
+ // already searched for host CLIs) and needs no sudo and no password. Asked once and remembered.
79
+ let prefixWritable = null;
80
+ export function npmPrefixWritable() {
81
+ if (prefixWritable !== null) return prefixWritable;
82
+ if (process.platform === 'win32') return (prefixWritable = true);
83
+ try {
84
+ const prefix = execSync('npm prefix -g', { encoding: 'utf8', timeout: 15000, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
85
+ const modules = path.join(prefix, 'lib', 'node_modules');
86
+ fs.accessSync(fs.existsSync(modules) ? modules : prefix, fs.constants.W_OK);
87
+ prefixWritable = true;
88
+ } catch { prefixWritable = false; }
89
+ return prefixWritable;
90
+ }
91
+ export const userPrefix = () => path.join(os.homedir(), '.local');
92
+ // The folder the host will be installed into when the system one is not writable, else null.
93
+ export const userInstallDir = ({ writable = npmPrefixWritable() } = {}) => (writable ? null : userPrefix());
94
+
95
+ export function installCommand(host, { writable = npmPrefixWritable() } = {}) {
96
+ if (!HOST_CLI[host]?.pkg) return null;
97
+ const base = `npm install -g ${HOST_CLI[host].pkg}${INSTALL_FLAGS[host] || ''}`;
98
+ return writable ? base : `${base} --prefix "${userPrefix()}"`;
99
+ }
77
100
 
78
101
  // Runs the npm install with its output on the user's terminal. Throws with a short reason on failure.
79
- export function installHost(host, run = (cmd) => execSync(cmd, { stdio: 'inherit' })) {
80
- const cmd = installCommand(host);
102
+ export function installHost(host, run = (cmd) => execSync(cmd, { stdio: 'inherit' }), opts = {}) {
103
+ const cmd = installCommand(host, opts);
81
104
  if (!cmd) throw new Error('no installer for this host');
82
105
  try { run(cmd); } catch (err) { throw new Error(String(err.message || err).split(/\r?\n/)[0]); }
83
106
  }
package/lib/i18n.js CHANGED
@@ -167,6 +167,7 @@ const MESSAGES = {
167
167
  prNeedsReview: '没有自动合并,已转给维护者审核(常见原因:GitHub 账号注册不满 30 天,或今天已提交超过 5 条)。你不需要再做什么:{url}',
168
168
  prTimeout: '等了 {m} 分钟还没合并,PR 还在:{url},之后随时在浏览器里看。',
169
169
  toolSudo: '这一步要用管理员权限安装:下面可能会让你输入这台电脑的登录密码(输入时不会显示字符,输完按回车)。',
170
+ hostInstallUserDir: '这台电脑的 npm 全局目录你没有写权限(装到系统目录要 sudo),所以会装到你自己的目录:{dir},不需要 sudo 和密码。',
170
171
  modelUnknown: '{host} 的模型清单里没有“{model}”。它现在支持:{list}。请重新选一个,或选“默认模型”。',
171
172
  updateAvail: '有新版本 {latest}(你现在用的是 {current})。',
172
173
  updateQ: '要更新吗?',
@@ -599,6 +600,7 @@ const MESSAGES = {
599
600
  prNeedsReview: 'It was not merged automatically and has gone to a maintainer for review (common reasons: the GitHub account is under 30 days old, or more than 5 submissions today). You need do nothing more: {url}',
600
601
  prTimeout: 'Waited {m} minutes and it is not merged yet. The pull request is still there: {url}; look any time in the browser.',
601
602
  toolSudo: 'This install needs administrator rights: you may be asked for this computer\'s password below (nothing is shown as you type; press enter when done).',
603
+ hostInstallUserDir: 'You cannot write to this computer\'s global npm folder (installing there needs sudo), so it is installed into your own folder instead: {dir}. No sudo or password is needed.',
602
604
  modelUnknown: '{host} does not list a model called "{model}". It currently supports: {list}. Pick another, or choose the default model.',
603
605
  updateAvail: 'A newer version {latest} is available (you are on {current}).',
604
606
  updateQ: 'Update?',
@@ -1079,6 +1081,7 @@ Layer 0 always runs first: it is free, and it disqualifies most problems before
1079
1081
  prNeedsReview: '自動マージされず、メンテナーのレビューに回りました(主な理由:GitHub アカウントが作成 30 日未満、または本日 5 件を超える提出)。これ以上の操作は不要です:{url}',
1080
1082
  prTimeout: '{m} 分待ちましたがまだマージされていません。プルリクエストは残っています:{url}。いつでもブラウザで確認できます。',
1081
1083
  toolSudo: 'このインストールには管理者権限が必要です。このコンピューターのパスワードの入力を求められることがあります(入力中は何も表示されません。入力後に Enter)。',
1084
+ hostInstallUserDir: 'このコンピューターのグローバル npm フォルダには書き込めません(sudo が必要)。代わりにあなた自身のフォルダ {dir} にインストールします。sudo もパスワードも不要です。',
1082
1085
  modelUnknown: '{host} のモデル一覧に「{model}」はありません。現在対応:{list}。別のものを選ぶか、既定のモデルを選んでください。',
1083
1086
  updateAvail: '新しいバージョン {latest} があります(現在は {current})。',
1084
1087
  updateQ: '更新しますか?',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillgauntlet",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Check an agent skill before you install it: context cost, permission surface, code risk, instruction hijacking, description quality, trigger rate and gain.",
5
5
  "type": "module",
6
6
  "bin": {