dsh-coding-enhanced 0.6.5 → 0.6.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.
- package/lib/client.js +23 -0
- package/lib/index.js +92 -19
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -117,6 +117,10 @@ window.__ModuleLoader__.load({
|
|
|
117
117
|
rewindConfirm: 'Withdraw turn {turn}? Turns {turn} through {latest} will be canceled in the model context, and the workspace will be restored to before turn {turn}.',
|
|
118
118
|
settingsFeatures: 'Change gate · time machine · handoff',
|
|
119
119
|
settingsGroupUpdates: 'Updates',
|
|
120
|
+
settingsAbout: 'About',
|
|
121
|
+
settingsAboutTitle: 'Coding Enhanced',
|
|
122
|
+
settingsAboutDesc: 'The DSH change gate: pre-write review, multi-turn withdraw, and a non-blocking review handoff. The full README lives on the plugin page and in the repository.',
|
|
123
|
+
settingsReadme: 'Open the full README',
|
|
120
124
|
settingsUpdates: 'Plugin updates',
|
|
121
125
|
settingsUpdatesDesc: 'Check npm for the latest release and install it from here.',
|
|
122
126
|
settingsCurrentVersion: 'Current version',
|
|
@@ -222,6 +226,10 @@ window.__ModuleLoader__.load({
|
|
|
222
226
|
rewindConfirm: '撤回第 {turn} 轮?第 {turn} 到第 {latest} 轮都会从模型上下文中撤销,工作区恢复到第 {turn} 轮开始前。',
|
|
223
227
|
settingsFeatures: '闸门 · 时间机器 · 交接',
|
|
224
228
|
settingsGroupUpdates: '更新',
|
|
229
|
+
settingsAbout: '关于',
|
|
230
|
+
settingsAboutTitle: 'Coding Enhanced',
|
|
231
|
+
settingsAboutDesc: 'DSH 变更闸门:写入前审查、多轮回退、非阻塞 review 交接。完整 README 在插件页和仓库里。',
|
|
232
|
+
settingsReadme: '打开完整 README',
|
|
225
233
|
settingsUpdates: '插件更新',
|
|
226
234
|
settingsUpdatesDesc: '检查 npm 最新版本,并在这里安装。',
|
|
227
235
|
settingsCurrentVersion: '当前版本',
|
|
@@ -359,6 +367,9 @@ window.__ModuleLoader__.load({
|
|
|
359
367
|
.ce-number:focus{border-color:var(--dsw-alias-state-business-primary,#4d6bfe);box-shadow:0 0 0 2px color-mix(in srgb,var(--dsw-alias-state-business-primary,#4d6bfe) 18%,transparent)}
|
|
360
368
|
.ce-number:disabled{opacity:.5}
|
|
361
369
|
.ce-number-unit{font-size:.78em;color:var(--dsw-alias-label-tertiary,#888)}
|
|
370
|
+
.ce-about .ce-row-desc{margin-top:.3em}
|
|
371
|
+
.ce-about-link{display:inline-flex;margin-top:.6em;font-size:.85em;font-weight:500;color:var(--dsw-alias-state-business-primary,#4d6bfe);text-decoration:none}
|
|
372
|
+
.ce-about-link:hover{text-decoration:underline}
|
|
362
373
|
.ce-update .ce-row{align-items:flex-start;gap:.8em}
|
|
363
374
|
.ce-update-actions{display:flex;gap:.4em;flex-wrap:wrap;justify-content:flex-end}
|
|
364
375
|
.ce-update-meta{margin-top:.35em;font-size:.76em;color:var(--dsw-alias-label-tertiary)}
|
|
@@ -1840,6 +1851,18 @@ div:has(> [data-detail-document]) > [data-plugin-config]{order:-1}
|
|
|
1840
1851
|
),
|
|
1841
1852
|
),
|
|
1842
1853
|
),
|
|
1854
|
+
React.createElement('div', { className: 'ce-group-title' }, typeof t === 'function' ? t('settingsAbout') : 'About'),
|
|
1855
|
+
React.createElement(
|
|
1856
|
+
'div',
|
|
1857
|
+
{ className: 'ce-card ce-about' },
|
|
1858
|
+
React.createElement('div', { className: 'ce-row-title' }, typeof t === 'function' ? t('settingsAboutTitle') : 'Coding Enhanced'),
|
|
1859
|
+
React.createElement('div', { className: 'ce-row-desc' }, typeof t === 'function' ? t('settingsAboutDesc') : 'The DSH change gate: pre-write review, multi-turn withdraw, and a non-blocking review handoff. The full README lives on the plugin page and in the repository.'),
|
|
1860
|
+
React.createElement(
|
|
1861
|
+
'a',
|
|
1862
|
+
{ className: 'ce-about-link', href: 'https://github.com/hello-2021/dsh-coding-enhanced#readme', target: '_blank', rel: 'noreferrer' },
|
|
1863
|
+
typeof t === 'function' ? t('settingsReadme') : 'Open the full README',
|
|
1864
|
+
),
|
|
1865
|
+
),
|
|
1843
1866
|
error !== null ? React.createElement('p', { className: 'ce-error' }, error) : null,
|
|
1844
1867
|
)
|
|
1845
1868
|
}
|
package/lib/index.js
CHANGED
|
@@ -58,15 +58,90 @@ const execOnce = (command, args, options) => new Promise((resolve, reject) => {
|
|
|
58
58
|
})
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
+
const readConfiguredRegistry = () => {
|
|
62
|
+
const files = [
|
|
63
|
+
path.join(os.homedir(), '.npmrc'),
|
|
64
|
+
path.join(path.dirname(path.dirname(PACKAGE_ROOT)), '.npmrc'),
|
|
65
|
+
]
|
|
66
|
+
for (const file of files) {
|
|
67
|
+
try {
|
|
68
|
+
for (const line of readFileSync(file, 'utf8').split(/\r?\n/)) {
|
|
69
|
+
const match = line.match(/^\s*registry\s*=\s*(\S+)\s*$/)
|
|
70
|
+
if (match !== null) return match[1]
|
|
71
|
+
}
|
|
72
|
+
} catch {
|
|
73
|
+
// ignore missing/unreadable npmrc
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return process.env.npm_config_registry
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const registryBases = () => {
|
|
80
|
+
const configured = readConfiguredRegistry()
|
|
81
|
+
return [...new Set([
|
|
82
|
+
configured,
|
|
83
|
+
'https://registry.npmjs.org',
|
|
84
|
+
'https://registry.npmmirror.com',
|
|
85
|
+
].filter((value) => typeof value === 'string' && value.length > 0))]
|
|
86
|
+
}
|
|
87
|
+
|
|
61
88
|
const latestNpmVersion = async () => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
const failures = []
|
|
90
|
+
for (const base of registryBases()) {
|
|
91
|
+
const url = `${base.replace(/\/+$/, '')}/dsh-coding-enhanced/latest`
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch(url, {
|
|
94
|
+
headers: { accept: 'application/vnd.npm.install-v1+json, application/json' },
|
|
95
|
+
signal: AbortSignal.timeout(12000),
|
|
96
|
+
})
|
|
97
|
+
if (response.ok !== true) throw new Error(`HTTP ${response.status}`)
|
|
98
|
+
const data = await response.json()
|
|
99
|
+
if (typeof data.version !== 'string' || data.version === '') throw new Error('no version in response')
|
|
100
|
+
return { version: data.version, registry: base }
|
|
101
|
+
} catch (error) {
|
|
102
|
+
failures.push(`${base} (${String(error)})`)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`No npm registry reachable. Tried: ${failures.join('; ')}`)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const findBundledPnpm = () => {
|
|
109
|
+
const candidates = []
|
|
110
|
+
if (typeof process.resourcesPath === 'string' && process.resourcesPath !== '') {
|
|
111
|
+
candidates.push(path.join(process.resourcesPath, 'app.asar', 'runtime', 'pnpm', 'bin', 'pnpm.cjs'))
|
|
112
|
+
candidates.push(path.join(process.resourcesPath, 'runtime', 'pnpm', 'bin', 'pnpm.cjs'))
|
|
113
|
+
}
|
|
114
|
+
candidates.push(path.join(path.dirname(process.execPath), '..', 'Resources', 'app.asar', 'runtime', 'pnpm', 'bin', 'pnpm.cjs'))
|
|
115
|
+
return candidates.find((candidate) => existsSync(candidate))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const installPackage = async (spec, profileDir) => {
|
|
119
|
+
const failures = []
|
|
120
|
+
try {
|
|
121
|
+
await execOnce('pnpm', ['add', spec], { cwd: profileDir })
|
|
122
|
+
return 'pnpm'
|
|
123
|
+
} catch (error) {
|
|
124
|
+
failures.push(String(error))
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
await execOnce('npm', ['install', spec, '--no-audit', '--no-fund'], { cwd: profileDir })
|
|
128
|
+
return 'npm'
|
|
129
|
+
} catch (error) {
|
|
130
|
+
failures.push(String(error))
|
|
131
|
+
}
|
|
132
|
+
const bundled = findBundledPnpm()
|
|
133
|
+
if (bundled !== undefined) {
|
|
134
|
+
try {
|
|
135
|
+
await execOnce(process.execPath, [bundled, 'add', spec], {
|
|
136
|
+
cwd: profileDir,
|
|
137
|
+
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
|
|
138
|
+
})
|
|
139
|
+
return 'dsh-bundled-pnpm'
|
|
140
|
+
} catch (error) {
|
|
141
|
+
failures.push(String(error))
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
throw new Error(failures.join(' | '))
|
|
70
145
|
}
|
|
71
146
|
|
|
72
147
|
const SURFACE_TYPES = new Set([
|
|
@@ -1913,8 +1988,8 @@ export function apply(ctx) {
|
|
|
1913
1988
|
|
|
1914
1989
|
const handleUpdateCheck = async () => {
|
|
1915
1990
|
try {
|
|
1916
|
-
const
|
|
1917
|
-
return ok({ current: PLUGIN_VERSION, latest, available: compareVersions(
|
|
1991
|
+
const check = await latestNpmVersion()
|
|
1992
|
+
return ok({ current: PLUGIN_VERSION, latest: check.version, registry: check.registry, available: compareVersions(check.version, PLUGIN_VERSION) > 0 })
|
|
1918
1993
|
} catch (error) {
|
|
1919
1994
|
return fail('update-check-failed', String(error))
|
|
1920
1995
|
}
|
|
@@ -1923,7 +1998,7 @@ export function apply(ctx) {
|
|
|
1923
1998
|
const handleUpdateInstall = async () => {
|
|
1924
1999
|
let latest
|
|
1925
2000
|
try {
|
|
1926
|
-
latest = await latestNpmVersion()
|
|
2001
|
+
latest = (await latestNpmVersion()).version
|
|
1927
2002
|
} catch (error) {
|
|
1928
2003
|
return fail('update-check-failed', String(error))
|
|
1929
2004
|
}
|
|
@@ -1936,14 +2011,11 @@ export function apply(ctx) {
|
|
|
1936
2011
|
}
|
|
1937
2012
|
const spec = `dsh-coding-enhanced@${latest}`
|
|
1938
2013
|
const profileName = path.basename(profileDir)
|
|
2014
|
+
let manager
|
|
1939
2015
|
try {
|
|
1940
|
-
await
|
|
1941
|
-
} catch (
|
|
1942
|
-
|
|
1943
|
-
await execOnce('npm', ['install', spec, '--no-audit', '--no-fund'], { cwd: profileDir })
|
|
1944
|
-
} catch (npmError) {
|
|
1945
|
-
return fail('update-failed', `Could not install ${spec}. Run \`pnpm add ${spec}\` in ${profileDir} and restart DSH. ${String(npmError)}`)
|
|
1946
|
-
}
|
|
2016
|
+
manager = await installPackage(spec, profileDir)
|
|
2017
|
+
} catch (error) {
|
|
2018
|
+
return fail('update-failed', `Could not install ${spec}. Run \`dsh plugin --profile ${profileName} add ${spec}\` and restart DSH. ${String(error)}`)
|
|
1947
2019
|
}
|
|
1948
2020
|
return ok({
|
|
1949
2021
|
updated: true,
|
|
@@ -1951,7 +2023,8 @@ export function apply(ctx) {
|
|
|
1951
2023
|
to: latest,
|
|
1952
2024
|
restart: true,
|
|
1953
2025
|
profile: profileName,
|
|
1954
|
-
|
|
2026
|
+
manager,
|
|
2027
|
+
command: manager === 'dsh-bundled-pnpm' ? `dsh-bundled pnpm add ${spec}` : `${manager} add ${spec}`,
|
|
1955
2028
|
})
|
|
1956
2029
|
}
|
|
1957
2030
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-coding-enhanced",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "The DSH change gate: queue AI edits before write, rewind turns with shadow-git snapshots, and hand review to a non-blocking waiter subagent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|