@aiwayds/dsh-opentui 0.18.1 → 0.18.3
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/CHANGELOG.md +33 -0
- package/bin/lib/launcher.mjs +1 -1
- package/dist/client/index.js +1892 -622
- package/dist/locales/en.json +14 -16
- package/dist/locales/zh-CN.json +14 -16
- package/package.json +6 -1
- package/scripts/lib/upgrade-plan.mjs +120 -37
- package/scripts/upgrade.mjs +234 -32
package/dist/locales/en.json
CHANGED
|
@@ -542,25 +542,22 @@
|
|
|
542
542
|
"overlay.ask.approvalTitle": "⚠ Approval: {name}",
|
|
543
543
|
"overlay.ask.allow": "allow",
|
|
544
544
|
"overlay.ask.reject": "reject",
|
|
545
|
-
"overlay.ask.question": "Question",
|
|
546
|
-
"overlay.ask.questionProgress": "Question ({index}/{total})",
|
|
547
|
-
"overlay.ask.checkedOption": "[x] {option}",
|
|
548
|
-
"overlay.ask.uncheckedOption": "[ ] {option}",
|
|
549
545
|
"overlay.ask.reviewRow": "⏎ Review answers",
|
|
550
|
-
"overlay.ask.spaceToggle": "space: toggle",
|
|
551
|
-
"overlay.ask.prevQuestion": "Previous question",
|
|
552
|
-
"overlay.ask.nextQuestion": "Next question",
|
|
553
|
-
"overlay.ask.toggleOption": "Toggle option",
|
|
554
|
-
"overlay.ask.title": "{title}: {prompt}",
|
|
555
546
|
"overlay.ask.reviewTitle": "Review answers",
|
|
556
|
-
"overlay.ask.reviewDescription": "←: edit · enter: submit",
|
|
557
547
|
"overlay.ask.submitRow": "⏎ Submit answers",
|
|
558
|
-
"overlay.ask.
|
|
559
|
-
"overlay.ask.
|
|
560
|
-
"overlay.ask.
|
|
561
|
-
"overlay.ask.
|
|
562
|
-
"overlay.ask.
|
|
563
|
-
"overlay.ask.
|
|
548
|
+
"overlay.ask.recommended": "Recommended",
|
|
549
|
+
"overlay.ask.inputPlaceholder": "Type something.",
|
|
550
|
+
"overlay.ask.unanswered": "not answered",
|
|
551
|
+
"overlay.ask.esc.back": "esc: back to options",
|
|
552
|
+
"overlay.ask.esc.prevQuestion": "esc: previous question",
|
|
553
|
+
"overlay.ask.esc.review": "esc: back to question",
|
|
554
|
+
"overlay.ask.esc.decline": "esc: decline",
|
|
555
|
+
"overlay.ask.overflow": "↑↓ {count} more",
|
|
556
|
+
"overlay.ask.queued": "{count} more waiting",
|
|
557
|
+
"overlay.ask.footer.options": "↑↓ move 1-9 pick ⏎ confirm {esc}",
|
|
558
|
+
"overlay.ask.footer.multi": "↑↓ move space toggle ⏎ confirm {esc}",
|
|
559
|
+
"overlay.ask.footer.input": "⏎ confirm {esc}",
|
|
560
|
+
"overlay.ask.footer.review": "↑↓ move ⏎ edit {esc}",
|
|
564
561
|
"overlay.lastrequest.round": "round {n}",
|
|
565
562
|
"overlay.palette.more": "… {count} more",
|
|
566
563
|
"overlay.palette.moreAbove": "… {count} more above",
|
|
@@ -869,6 +866,7 @@
|
|
|
869
866
|
"dialog.sessionList.deleteFailed": "Failed to delete session: {error}",
|
|
870
867
|
"dialog.sessionList.hint.currentDirectory": "current directory",
|
|
871
868
|
"dialog.sessionList.hint.allProjects": "all projects",
|
|
869
|
+
"transcript.ask.declined": "declined",
|
|
872
870
|
"transcript.loading": "Loading session history…",
|
|
873
871
|
"transcript.pending.queue.paused": "⏸ Paused #{order} · {text}",
|
|
874
872
|
"transcript.pending.queue.waiting": "⏸ Queued #{order} · {text}",
|
package/dist/locales/zh-CN.json
CHANGED
|
@@ -542,25 +542,22 @@
|
|
|
542
542
|
"overlay.ask.approvalTitle": "⚠ 审批:{name}",
|
|
543
543
|
"overlay.ask.allow": "允许",
|
|
544
544
|
"overlay.ask.reject": "拒绝",
|
|
545
|
-
"overlay.ask.question": "问题",
|
|
546
|
-
"overlay.ask.questionProgress": "问题({index}/{total})",
|
|
547
|
-
"overlay.ask.checkedOption": "[x] {option}",
|
|
548
|
-
"overlay.ask.uncheckedOption": "[ ] {option}",
|
|
549
545
|
"overlay.ask.reviewRow": "⏎ 查看答案",
|
|
550
|
-
"overlay.ask.spaceToggle": "space 切换",
|
|
551
|
-
"overlay.ask.prevQuestion": "上一个问题",
|
|
552
|
-
"overlay.ask.nextQuestion": "下一个问题",
|
|
553
|
-
"overlay.ask.toggleOption": "切换选项",
|
|
554
|
-
"overlay.ask.title": "{title}:{prompt}",
|
|
555
546
|
"overlay.ask.reviewTitle": "确认答案",
|
|
556
|
-
"overlay.ask.reviewDescription": "← 编辑 · enter 提交",
|
|
557
547
|
"overlay.ask.submitRow": "⏎ 提交答案",
|
|
558
|
-
"overlay.ask.
|
|
559
|
-
"overlay.ask.
|
|
560
|
-
"overlay.ask.
|
|
561
|
-
"overlay.ask.
|
|
562
|
-
"overlay.ask.
|
|
563
|
-
"overlay.ask.
|
|
548
|
+
"overlay.ask.recommended": "推荐",
|
|
549
|
+
"overlay.ask.inputPlaceholder": "输入自定义答案…",
|
|
550
|
+
"overlay.ask.unanswered": "未回答",
|
|
551
|
+
"overlay.ask.esc.back": "esc:返回选项",
|
|
552
|
+
"overlay.ask.esc.prevQuestion": "esc:上一个问题",
|
|
553
|
+
"overlay.ask.esc.review": "esc:返回问题",
|
|
554
|
+
"overlay.ask.esc.decline": "esc:放弃回答",
|
|
555
|
+
"overlay.ask.overflow": "↑↓ 还有 {count} 行",
|
|
556
|
+
"overlay.ask.queued": "还有 {count} 个待回答",
|
|
557
|
+
"overlay.ask.footer.options": "↑↓ 移动 1-9 选择 ⏎ 确认 {esc}",
|
|
558
|
+
"overlay.ask.footer.multi": "↑↓ 移动 space 切换 ⏎ 确认 {esc}",
|
|
559
|
+
"overlay.ask.footer.input": "⏎ 确认 {esc}",
|
|
560
|
+
"overlay.ask.footer.review": "↑↓ 移动 ⏎ 编辑 {esc}",
|
|
564
561
|
"overlay.lastrequest.round": "第 {n} 轮",
|
|
565
562
|
"overlay.palette.more": "… 还有 {count} 项",
|
|
566
563
|
"overlay.palette.moreAbove": "… 上方还有 {count} 项",
|
|
@@ -869,6 +866,7 @@
|
|
|
869
866
|
"dialog.sessionList.deleteFailed": "删除会话失败:{error}",
|
|
870
867
|
"dialog.sessionList.hint.currentDirectory": "当前目录",
|
|
871
868
|
"dialog.sessionList.hint.allProjects": "所有项目",
|
|
869
|
+
"transcript.ask.declined": "已拒绝",
|
|
872
870
|
"transcript.loading": "加载会话历史…",
|
|
873
871
|
"transcript.pending.queue.paused": "⏸ 已暂停 #{order} · {text}",
|
|
874
872
|
"transcript.pending.queue.waiting": "⏸ 排队等待 #{order} · {text}",
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwayds/dsh-opentui",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/fan56/dsh-opentui.git",
|
|
8
|
+
"directory": "packages/shell"
|
|
9
|
+
},
|
|
5
10
|
"type": "module",
|
|
6
11
|
"bin": {
|
|
7
12
|
"dsh-opentui": "bin/dsh-opentui.mjs"
|
|
@@ -16,6 +16,14 @@ import { compareVersions, parseVersion, resolveEffectivePin } from './provision-
|
|
|
16
16
|
|
|
17
17
|
export const OFFICIAL_REGISTRY = 'https://registry.npmjs.org'
|
|
18
18
|
|
|
19
|
+
// Identities of the .npmrc files the upgrade command reads, least specific
|
|
20
|
+
// first. They are labels, not paths: the caller turns them into real paths and
|
|
21
|
+
// keeps them in the resolved registry so the install rule can tell npm's own
|
|
22
|
+
// file (~/.npmrc) from the ones npm never reads.
|
|
23
|
+
export const NPMRC_HOME = '~/.npmrc'
|
|
24
|
+
export const NPMRC_DSH_HOME = '$DSH_HOME/.npmrc'
|
|
25
|
+
export const NPMRC_PROFILE = '<profile>/.npmrc'
|
|
26
|
+
|
|
19
27
|
// ---------------------------------------------------------------------------
|
|
20
28
|
// Registry resolution
|
|
21
29
|
// ---------------------------------------------------------------------------
|
|
@@ -36,19 +44,23 @@ function stripTrailingSlashes(value) {
|
|
|
36
44
|
return String(value).replace(/\/+$/, '')
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
/** Last `registry=` line across all
|
|
47
|
+
/** Last `registry=` line across all files wins: later files override earlier
|
|
40
48
|
* ones, and inside one file the last assignment wins, which is how npm's
|
|
41
|
-
* own config layering behaves.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
* own config layering behaves. Returns the value together with the identity
|
|
50
|
+
* of the file it came from, so the install rule can tell npm's own file from
|
|
51
|
+
* the ones npm never reads. */
|
|
52
|
+
function registryFromNpmrcFiles(npmrcFiles) {
|
|
53
|
+
let found = null
|
|
54
|
+
for (const file of npmrcFiles) {
|
|
55
|
+
if (typeof file?.text !== 'string') continue
|
|
56
|
+
let value = ''
|
|
57
|
+
for (const line of file.text.split(/\r?\n/)) {
|
|
47
58
|
const match = /^\s*registry\s*=\s*(.+)$/i.exec(line)
|
|
48
59
|
if (!match) continue
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
60
|
+
const parsed = cleanRegistryValue(match[1])
|
|
61
|
+
if (parsed) value = parsed
|
|
51
62
|
}
|
|
63
|
+
if (value) found = { registry: value, path: file.path }
|
|
52
64
|
}
|
|
53
65
|
return found
|
|
54
66
|
}
|
|
@@ -57,25 +69,57 @@ function registryFromNpmrcTexts(npmrcTexts) {
|
|
|
57
69
|
* Where the `npm view` query should go.
|
|
58
70
|
*
|
|
59
71
|
* Priority: DSH_UPGRADE_REGISTRY (explicit operator override) -> the npmrc
|
|
60
|
-
*
|
|
72
|
+
* files the caller read, last one winning -> the public registry.
|
|
61
73
|
*
|
|
62
|
-
* `
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
74
|
+
* `npmrcFiles` is a list of `{ path, text }` where `path` names the file
|
|
75
|
+
* (`~/.npmrc`, `$DSH_HOME/.npmrc`, `<profile>/.npmrc`): this module does no
|
|
76
|
+
* IO, and the caller decides which files apply (user, DSH home, profile).
|
|
77
|
+
* `sourcePath` is that identity (or `env` / `default`); `source` stays the
|
|
78
|
+
* coarse bucket callers already print. The returned registry never ends with
|
|
79
|
+
* `/` so argv and string comparisons stay canonical.
|
|
66
80
|
*
|
|
67
|
-
* @param {{ env?: Record<string, string|undefined>,
|
|
68
|
-
*
|
|
81
|
+
* @param {{ env?: Record<string, string|undefined>,
|
|
82
|
+
* npmrcFiles?: Array<{ path: string, text: string }> }} [input]
|
|
83
|
+
* @returns {{ registry: string, source: 'env'|'npmrc'|'default', sourcePath: string }}
|
|
69
84
|
*/
|
|
70
|
-
export function resolveRegistry({ env = {},
|
|
85
|
+
export function resolveRegistry({ env = {}, npmrcFiles = [] } = {}) {
|
|
71
86
|
const rawEnv = env && typeof env === 'object' ? env.DSH_UPGRADE_REGISTRY : undefined
|
|
72
87
|
const fromEnv = typeof rawEnv === 'string' ? stripTrailingSlashes(cleanRegistryValue(rawEnv)) : ''
|
|
73
|
-
if (fromEnv) return { registry: fromEnv, source: 'env' }
|
|
88
|
+
if (fromEnv) return { registry: fromEnv, source: 'env', sourcePath: 'env' }
|
|
89
|
+
|
|
90
|
+
const fromNpmrc = registryFromNpmrcFiles(Array.isArray(npmrcFiles) ? npmrcFiles : [])
|
|
91
|
+
if (fromNpmrc) {
|
|
92
|
+
const registry = stripTrailingSlashes(fromNpmrc.registry)
|
|
93
|
+
// An unnamed text cannot be attributed to npm's own file, so it is
|
|
94
|
+
// forwarded explicitly: over-specifying is harmless, under-specifying
|
|
95
|
+
// sends the install to a different registry than the query used.
|
|
96
|
+
const named = typeof fromNpmrc.path === 'string' && fromNpmrc.path !== ''
|
|
97
|
+
const sourcePath = named ? fromNpmrc.path : 'npmrc'
|
|
98
|
+
return { registry, source: 'npmrc', sourcePath }
|
|
99
|
+
}
|
|
74
100
|
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
return { registry: OFFICIAL_REGISTRY, source: 'default', sourcePath: 'default' }
|
|
102
|
+
}
|
|
77
103
|
|
|
78
|
-
|
|
104
|
+
/**
|
|
105
|
+
* argv for `npm i -g <pkg>@<target>`.
|
|
106
|
+
*
|
|
107
|
+
* npm reads `~/.npmrc` (plus the project and global files) itself, so a
|
|
108
|
+
* registry that came from there is already what this install resolves: passing
|
|
109
|
+
* it again would only override per-scope / per-package configuration the user
|
|
110
|
+
* wrote. Every other source is invisible to npm — `DSH_UPGRADE_REGISTRY` is
|
|
111
|
+
* this command's own variable, and `$DSH_HOME/.npmrc` / `<profile>/.npmrc` are
|
|
112
|
+
* files npm never looks at — so the install must be told explicitly, or the
|
|
113
|
+
* version query hits the mirror while the install goes to the default
|
|
114
|
+
* registry.
|
|
115
|
+
*
|
|
116
|
+
* @param {{ pkg: string, target: string, registry: string, sourcePath: string }} input
|
|
117
|
+
* @returns {string[]}
|
|
118
|
+
*/
|
|
119
|
+
export function buildSelfInstallArgs({ pkg, target, registry, sourcePath } = {}) {
|
|
120
|
+
const args = ['i', '-g', `${pkg}@${target}`]
|
|
121
|
+
if (sourcePath !== NPMRC_HOME) args.push('--registry', registry)
|
|
122
|
+
return args
|
|
79
123
|
}
|
|
80
124
|
|
|
81
125
|
/**
|
|
@@ -268,11 +312,18 @@ function entryVersion(entry) {
|
|
|
268
312
|
|
|
269
313
|
/** The name -> entry map of an override document. Both shapes are accepted
|
|
270
314
|
* because the reader that feeds provisioning returns the inner map while the
|
|
271
|
-
* command works with the whole document; `packages` wins when both exist.
|
|
315
|
+
* command works with the whole document; `packages` wins when both exist.
|
|
316
|
+
* Entries parseOverrides could not interpret are carried in `raw` and are
|
|
317
|
+
* folded back in here: to a pin decision they are simply entries that lose
|
|
318
|
+
* (invalid), which is exactly what this map represented before `raw` existed. */
|
|
272
319
|
function overridePackageMap(overrides) {
|
|
273
320
|
if (!isPlainObject(overrides)) return {}
|
|
274
|
-
if (isPlainObject(overrides.packages)) return overrides
|
|
275
|
-
|
|
321
|
+
if (!isPlainObject(overrides.packages)) return overrides
|
|
322
|
+
const packages = overrides.packages
|
|
323
|
+
if (!isPlainObject(overrides.raw)) return packages
|
|
324
|
+
const merged = { ...overrides.raw }
|
|
325
|
+
for (const [name, entry] of Object.entries(packages)) merged[name] = entry
|
|
326
|
+
return merged
|
|
276
327
|
}
|
|
277
328
|
|
|
278
329
|
/**
|
|
@@ -280,16 +331,25 @@ function overridePackageMap(overrides) {
|
|
|
280
331
|
* is unusable (bad JSON, not an object, no usable `packages` object) — the
|
|
281
332
|
* caller maps null to "no overrides", never to an error.
|
|
282
333
|
*
|
|
283
|
-
* A single malformed entry (no version string)
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
334
|
+
* A single malformed entry (no version string) does not fail the file, and it
|
|
335
|
+
* is NOT dropped either: it lands in `raw` verbatim. The command rewrites the
|
|
336
|
+
* whole `packages` map after every upgrade, so dropping an entry it cannot
|
|
337
|
+
* interpret would silently delete a hand-written pin. Uninterpretable means
|
|
338
|
+
* "this module cannot use it" (pickEffectivePin ignores it), not "the user did
|
|
339
|
+
* not mean it".
|
|
340
|
+
*
|
|
341
|
+
* Interpreted entries keep their shape — a string stays a string, an object
|
|
342
|
+
* keeps its metadata (`shippedPin`, `updatedAt`) — so a read/serialize round
|
|
343
|
+
* trip does not destroy fields this module does not interpret. Neither
|
|
344
|
+
* `version` nor the entry's semver validity is enforced here (pickEffectivePin
|
|
345
|
+
* judges validity, so a bad version can still be reported and cleaned up).
|
|
290
346
|
*
|
|
291
347
|
* @param {string} text
|
|
292
|
-
* @returns {{
|
|
348
|
+
* @returns {{
|
|
349
|
+
* version: number,
|
|
350
|
+
* packages: Record<string, string|{version: string}>,
|
|
351
|
+
* raw: Record<string, unknown>,
|
|
352
|
+
* } | null}
|
|
293
353
|
*/
|
|
294
354
|
export function parseOverrides(text) {
|
|
295
355
|
let doc
|
|
@@ -302,14 +362,18 @@ export function parseOverrides(text) {
|
|
|
302
362
|
if (!isPlainObject(doc.packages)) return null
|
|
303
363
|
|
|
304
364
|
const packages = {}
|
|
365
|
+
const raw = {}
|
|
305
366
|
for (const [name, entry] of Object.entries(doc.packages)) {
|
|
306
367
|
if (name === '') continue
|
|
307
368
|
const version = entryVersion(entry)
|
|
308
|
-
if (version === null || version === '')
|
|
369
|
+
if (version === null || version === '') {
|
|
370
|
+
raw[name] = entry
|
|
371
|
+
continue
|
|
372
|
+
}
|
|
309
373
|
packages[name] = typeof entry === 'string' ? version : { ...entry, version }
|
|
310
374
|
}
|
|
311
375
|
|
|
312
|
-
return { version: Number.isInteger(doc.version) ? doc.version : 1, packages }
|
|
376
|
+
return { version: Number.isInteger(doc.version) ? doc.version : 1, packages, raw }
|
|
313
377
|
}
|
|
314
378
|
|
|
315
379
|
/**
|
|
@@ -318,15 +382,34 @@ export function parseOverrides(text) {
|
|
|
318
382
|
* every upgrade and lives in a directory users inspect and diff; insertion
|
|
319
383
|
* order must not leak into the bytes.
|
|
320
384
|
*
|
|
321
|
-
*
|
|
385
|
+
* `raw` (from parseOverrides) is written back into `packages` under its
|
|
386
|
+
* original name and value, and is never emitted as a key of its own: that is
|
|
387
|
+
* what makes a rewrite lossless for entries the parser could not interpret.
|
|
388
|
+
* An interpreted entry always wins over a raw one with the same name.
|
|
389
|
+
*
|
|
390
|
+
* @param {{ packages?: Record<string, unknown>, raw?: Record<string, unknown>, [key: string]: unknown }} obj
|
|
322
391
|
* @returns {string}
|
|
323
392
|
*/
|
|
324
393
|
export function serializeOverrides(obj) {
|
|
325
394
|
if (!isPlainObject(obj)) throw new TypeError('serializeOverrides: expected a plain object')
|
|
326
395
|
const packages = isPlainObject(obj.packages) ? obj.packages : {}
|
|
396
|
+
const raw = isPlainObject(obj.raw) ? obj.raw : {}
|
|
397
|
+
|
|
398
|
+
const merged = {}
|
|
399
|
+
for (const [name, entry] of Object.entries(raw)) {
|
|
400
|
+
if (!Object.prototype.hasOwnProperty.call(packages, name)) merged[name] = entry
|
|
401
|
+
}
|
|
402
|
+
for (const [name, entry] of Object.entries(packages)) merged[name] = entry
|
|
403
|
+
|
|
327
404
|
const sorted = {}
|
|
328
|
-
for (const name of Object.keys(
|
|
329
|
-
|
|
405
|
+
for (const name of Object.keys(merged).sort()) sorted[name] = merged[name]
|
|
406
|
+
|
|
407
|
+
// Everything but `raw` is document metadata and passes through untouched.
|
|
408
|
+
const document = {}
|
|
409
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
410
|
+
if (key !== 'raw') document[key] = value
|
|
411
|
+
}
|
|
412
|
+
return `${JSON.stringify({ ...document, packages: sorted }, null, 2)}\n`
|
|
330
413
|
}
|
|
331
414
|
|
|
332
415
|
/**
|