@whyshu/argent 0.1.23 → 0.1.25

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/bin/argent.mjs CHANGED
@@ -218,6 +218,19 @@ function runCli(bin, args, { cwd = '', env = {} } = {}) {
218
218
 
219
219
  function inherit_stdout() { return !JSON_OUT }
220
220
 
221
+
222
+ /** desktop profile 的依赖安装器:ARGENT_PNPM → 宿主自带 pnpm → PATH 上的 pnpm */
223
+ function resolvePnpm() {
224
+ const cands = [
225
+ process.env.ARGENT_PNPM,
226
+ '/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/pnpm/bin/pnpm.mjs',
227
+ ].filter(Boolean)
228
+ for (const c of cands) { if (existsSync(c)) return { cmd: process.execPath, args: [c] } }
229
+ const which = spawnSync('pnpm', ['--version'], { encoding: 'utf8' })
230
+ if (which.status === 0) return { cmd: 'pnpm', args: [] }
231
+ return null
232
+ }
233
+
221
234
  async function updateCommand(sub) {
222
235
  if (sub !== 'check' && sub !== 'run') {
223
236
  console.error('用法:argent update check|run [--to <version>] [--yes] [--registry <url>] [--dsh-home <dir>] [--target <dir>] [--json] [--dry-run]');
@@ -252,7 +265,7 @@ async function updateCommand(sub) {
252
265
  const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx'
253
266
  const common = ['--yes', `@whyshu/argent@${targetVersion}`]
254
267
  const installArgs = [...common, 'runtime', 'install', '--target', opts.target, '--skills-target', opts.skillsTarget]
255
- const healthArgs = [...common, 'health', '--dsh-home', opts.dshHome, '--json', '--dsh-bin', opts.dshBin]
268
+ const healthArgs = [...common, 'health', '--dsh-home', opts.dshHome, '--profile', opts.profile, '--json', '--dsh-bin', opts.dshBin]
256
269
  if (DRY_RUN) {
257
270
  print({ ok: true, dryRun: true, current, targetVersion, dshBin: opts.dshBin, commands: [
258
271
  [npx, ...installArgs].join(' '),
@@ -282,14 +295,27 @@ async function updateCommand(sub) {
282
295
  if (existsSync(src)) { mkdirSync(dirname(join(backupDir, f)), { recursive: true }); cpSync(src, join(backupDir, f)) }
283
296
  }
284
297
  const env = { NPM_CONFIG_REGISTRY: opts.registry }
298
+ let eng = null
285
299
  try {
286
300
  runCli(npx, installArgs, { env })
287
301
  // 不调用 setup:setup 会重建 profile,可能丢掉客户现有 bundles/依赖结构(2026-10-22 实测)。
288
302
  const prof = updateProfilePluginVersions({ dshHome: opts.dshHome, profile: opts.profile, versions: PUBLISHED_BUNDLE_VERSIONS })
289
303
  if (!prof.ok) throw new Error(`更新 profile 插件版本失败:${prof.message}`)
290
304
  // 方案 C · P3:runtime 换完必须重写契约文件(否则壳仍按旧 engineDir/版本读)
291
- const eng = writeEngineContract(profileDir, { repo: opts.repo })
292
- runCli(opts.dshBin, ['plugin', '--profile', opts.profile, 'install'], { env: { ...env, DSH_HOME: opts.dshHome }, cwd: opts.dshHome })
305
+ eng = writeEngineContract(profileDir, { repo: opts.repo, target: opts.target })
306
+ // ⚠️ dsh CLI **拒绝管理 desktop profile**("managed exclusively by the Electron application")
307
+ // ⇒ desktop 必须由宿主自己的 pnpm 装依赖(2026-11-02 实测:`dsh plugin --profile desktop install` 直接 exit 1)。
308
+ if (opts.profile === 'desktop') {
309
+ const ws = join(profileDir, 'pnpm-workspace.yaml')
310
+ if (!existsSync(ws)) {
311
+ writeFileSync(ws, 'packages:\n - .\nnodeLinker: hoisted\nautoInstallPeers: false\nallowBuilds:\n protobufjs: true\n')
312
+ }
313
+ const pnpm = resolvePnpm()
314
+ if (!pnpm) throw new Error('desktop profile 需要 pnpm:设置 ARGENT_PNPM,或确保 PATH 上有 pnpm')
315
+ runCli(pnpm.cmd, pnpm.args.concat(['install', '--reporter=append-only']), { cwd: profileDir, env })
316
+ } else {
317
+ runCli(opts.dshBin, ['plugin', '--profile', opts.profile, 'install'], { env: { ...env, DSH_HOME: opts.dshHome }, cwd: opts.dshHome })
318
+ }
293
319
  runCli(npx, healthArgs, { env })
294
320
  } catch (e) {
295
321
  console.error(`❌ 更新失败:${e.message}`)
package/lib/index.mjs CHANGED
@@ -138,14 +138,19 @@ export function engineRoot({ env = process.env, launcherLib = dirname(fileURLToP
138
138
  * 优先级:本地仓库(开发联调)→ npm 包 `engine/` → 已物化 runtime(~/.argent-dsh)。
139
139
  * 找不到就返回 ok:false —— 由调用方决定写空值还是报错,⛔ 不要在这里编一个路径。
140
140
  */
141
- export function engineInfo({ repo = repoRoot(), env = process.env } = {}) {
141
+ export function engineInfo({ repo = repoRoot(), target = process.env.ARGENT_RUNTIME_TARGET, env = process.env } = {}) {
142
142
  const valid = (d) => Boolean(d) && existsSync(join(d, 'VERSION')) && existsSync(join(d, 'core', 'lib', 'argent-datadir.mjs'));
143
143
  const cands = [];
144
- if (valid(repo)) cands.push({ dir: repo, source: 'repo' });
144
+ // ① 显式 runtime 目标(update run --target):客户机上**唯一稳定**的引擎位置
145
+ if (valid(target)) cands.push({ dir: target, source: 'target' });
146
+ // ② 本地仓库(开发联调):必须真的是 git 检出,⛔ 不要把 npx 缓存里的包当"仓库"
147
+ if (valid(repo) && existsSync(join(repo, '.git'))) cands.push({ dir: repo, source: 'repo' });
148
+ // ③ 已物化 runtime(默认 ~/.argent-dsh)
149
+ const runtime = join(homedir(), '.argent-dsh');
150
+ if (valid(runtime)) cands.push({ dir: runtime, source: 'runtime' });
151
+ // ④ 最后才是 npm 包(npx 缓存路径,随时会被清 —— 只作兜底)
145
152
  const pkg = engineRoot({ env });
146
153
  if (valid(pkg)) cands.push({ dir: pkg, source: 'package' });
147
- const runtime = env.ARGENT_RUNTIME_TARGET || join(homedir(), '.argent-dsh');
148
- if (valid(runtime)) cands.push({ dir: runtime, source: 'runtime' });
149
154
  for (const c of cands) {
150
155
  let version = '';
151
156
  try { version = readFileSync(join(c.dir, 'VERSION'), 'utf8').trim(); } catch { /* 保留空串 */ }
@@ -163,8 +168,8 @@ export function engineContract(dir) {
163
168
  }
164
169
 
165
170
  /** 写 `<profile>/argent.json`:宿主壳只读这个文件,不再猜引擎在哪(方案 C · P1) */
166
- export function writeEngineContract(dir, { repo = repoRoot(), env = process.env } = {}) {
167
- const info = engineInfo({ repo, env });
171
+ export function writeEngineContract(dir, { repo = repoRoot(), target = process.env.ARGENT_RUNTIME_TARGET, env = process.env } = {}) {
172
+ const info = engineInfo({ repo, target, env });
168
173
  const payload = {
169
174
  engineDir: info.ok ? info.dir : '',
170
175
  engineVersion: info.ok ? info.version : '',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyshu/argent",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Argent 启动器:一条命令启动「打包好的 dsh + Argent 插件/角色预设」,并管理本机 runner 常驻。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@deepseek-ai/dsh": "0.2.1-rc.2",
18
- "@whyshu/argent-engine": "0.8.0-rc.9"
18
+ "@whyshu/argent-engine": "0.8.0-rc.10"
19
19
  },
20
20
  "files": [
21
21
  "bin/",