universal-dev-standards 6.14.0-beta.12 → 6.14.0-beta.14
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/uds.js +8 -1
- package/bundled/hooks/validate-commit-msg.mjs +52 -9
- package/bundled/locales/zh-CN/CHANGELOG.md +3 -3
- package/bundled/locales/zh-CN/README.md +1 -1
- package/bundled/locales/zh-CN/SECURITY.md +1 -1
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +1 -1
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +3 -2
- package/bundled/locales/zh-TW/CHANGELOG.md +3 -3
- package/bundled/locales/zh-TW/README.md +1 -1
- package/bundled/locales/zh-TW/SECURITY.md +1 -1
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +1 -1
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +3 -2
- package/package.json +1 -1
- package/src/commands/audit.js +28 -1
- package/src/commands/check.js +72 -3
- package/src/commands/compile.js +37 -4
- package/src/commands/config.js +28 -19
- package/src/commands/init.js +59 -28
- package/src/commands/release-messages.js +228 -0
- package/src/commands/release.js +72 -72
- package/src/commands/update.js +125 -14
- package/src/compilers/claude-code-compiler.js +9 -1
- package/src/i18n/messages.js +84 -0
- package/src/installers/hooks-installer.js +1 -1
- package/src/mcp/server.js +9 -3
- package/src/prompts/init.js +17 -17
- package/src/reconciler/plan-executor.js +34 -4
- package/src/reconciler/recorded-versions.js +18 -0
- package/src/uninstallers/hook-uninstaller.js +9 -1
- package/src/uninstallers/skills-uninstaller.js +10 -3
- package/src/utils/build-manifest.js +1 -1
- package/src/utils/git-hooks.js +106 -4
- package/src/utils/integration-generator.js +75 -49
- package/src/utils/legacy-hook-migration.js +121 -2
- package/src/utils/spinner.js +14 -4
- package/standards-registry.json +7 -7
package/src/i18n/messages.js
CHANGED
|
@@ -260,6 +260,26 @@ export const messages = {
|
|
|
260
260
|
},
|
|
261
261
|
|
|
262
262
|
// Release Mode
|
|
263
|
+
// Prompts of the optional uds.project.yaml step of `uds init` (XSPEC-482 R13: they were English in every language).
|
|
264
|
+
projectContract: {
|
|
265
|
+
confirmCreate: 'Create uds.project.yaml (project command contract)?',
|
|
266
|
+
title: '📋 Project Command Contract (uds.project.yaml)',
|
|
267
|
+
intro1: 'Tell UDS how to run standard commands in this project (language-agnostic).',
|
|
268
|
+
intro2: 'Press Enter to accept a suggestion, or type your own. Leave blank to skip.',
|
|
269
|
+
detected: 'Detected suggestions:',
|
|
270
|
+
alreadyExists: 'uds.project.yaml already exists.',
|
|
271
|
+
keptSections: 'These sections are kept exactly as they are: {sections}.',
|
|
272
|
+
noOtherSections: 'It has no other sections.',
|
|
273
|
+
updateQuestion: 'Update the commands (test, lint, build, security) in the existing uds.project.yaml? {kept}',
|
|
274
|
+
replaceQuestion: 'The existing uds.project.yaml cannot be read as YAML, so none of its content can be kept. Replace the whole file?',
|
|
275
|
+
skippedKeeping: 'Skipped — keeping existing uds.project.yaml',
|
|
276
|
+
commandOptional: '{intent} command (optional):',
|
|
277
|
+
commandDefault: '{intent} command (default: {value}):',
|
|
278
|
+
noneEntered: 'No commands entered — uds.project.yaml not created.',
|
|
279
|
+
updated: '✔ uds.project.yaml updated (other sections kept as they were)',
|
|
280
|
+
created: '✔ uds.project.yaml created',
|
|
281
|
+
path: 'Path: {path}'
|
|
282
|
+
},
|
|
263
283
|
releaseMode: {
|
|
264
284
|
title: 'Release Mode:',
|
|
265
285
|
description: 'Choose release mode, affects how versions are published',
|
|
@@ -1146,6 +1166,14 @@ export const messages = {
|
|
|
1146
1166
|
hookWouldMigrate: '+ .husky/pre-commit: would replace the line an older UDS wrote (it asks npm to resolve the bare name "uds", which is not this project) with one that runs only the installed UDS CLI.',
|
|
1147
1167
|
hookLegacyKept: '⚠ .husky/pre-commit line {line} ("{text}") asks npm to resolve the bare name "uds", which on the npm registry is an unrelated package. UDS did not write this exact line, so it was left alone. Change it to "universal-dev-standards check" — it needs the UDS CLI installed in this project or on PATH.',
|
|
1148
1168
|
hookMigrateFailed: '⚠ Could not rewrite .husky/pre-commit: {error}. The line that asks npm for the bare name "uds" is still there — change it to "universal-dev-standards check".',
|
|
1169
|
+
hookNativeMigrated: '✓ .git/hooks/pre-commit: replaced the hook an older UDS wrote ({from}) with the current one. The old one ran the check with its errors thrown away and let every commit through; the new one stops a commit when `check --ci` reports an issue.',
|
|
1170
|
+
hookNativeWouldMigrate: '+ .git/hooks/pre-commit: would replace the hook an older UDS wrote ({from}) with the current one. The old one ran the check with its errors thrown away and let every commit through; the new one stops a commit when `check --ci` reports an issue.',
|
|
1171
|
+
hookNativeKept: '⚠ .git/hooks/pre-commit line {line} ("{text}") runs the UDS check and lets the commit through whatever it finds. The file is not exactly what UDS wrote, so it was left alone. Change that line to "universal-dev-standards check --ci" — it needs the UDS CLI installed in this project or on PATH.',
|
|
1172
|
+
hookHuskyCiMigrated: '✓ .husky/pre-commit: the UDS block now runs `check --ci`, so the hook stops a commit when the check finds an issue. (The block an earlier beta wrote ran `check` alone, which exits 0 even when a standard file was edited.)',
|
|
1173
|
+
hookHuskyCiWouldMigrate: '+ .husky/pre-commit: would change the UDS block to run `check --ci`, so the hook stops a commit when the check finds an issue. (The block an earlier beta wrote ran `check` alone, which exits 0 even when a standard file was edited.)',
|
|
1174
|
+
hookNativeFromLegacy: 'UDS 5.x to 6.13.1: `uds check 2>/dev/null || true`',
|
|
1175
|
+
hookNativeFromWithoutCi: 'UDS 6.14.0 betas: `check` without `--ci`',
|
|
1176
|
+
hookNativeFailed: '⚠ Could not rewrite .git/hooks/pre-commit: {error}. It still lets every commit through — replace its UDS check line with "universal-dev-standards check --ci".',
|
|
1149
1177
|
newerVersion: '(You have a newer version than the registry: {version})',
|
|
1150
1178
|
updateAvailable: 'Update available: {current} → {latest}',
|
|
1151
1179
|
// Files
|
|
@@ -1637,6 +1665,26 @@ export const messages = {
|
|
|
1637
1665
|
},
|
|
1638
1666
|
|
|
1639
1667
|
// Release Mode
|
|
1668
|
+
// `uds init` 選填 uds.project.yaml 步驟的提問(XSPEC-482 R13:原本每種語言都是英文)。
|
|
1669
|
+
projectContract: {
|
|
1670
|
+
confirmCreate: '要建立 uds.project.yaml(專案指令契約)嗎?',
|
|
1671
|
+
title: '📋 專案指令契約(uds.project.yaml)',
|
|
1672
|
+
intro1: '告訴 UDS 這個專案如何執行標準指令(與程式語言無關)。',
|
|
1673
|
+
intro2: '按 Enter 接受建議值,或自行輸入。留空代表略過。',
|
|
1674
|
+
detected: '偵測到的建議值:',
|
|
1675
|
+
alreadyExists: 'uds.project.yaml 已存在。',
|
|
1676
|
+
keptSections: '這些區段會原封不動保留:{sections}。',
|
|
1677
|
+
noOtherSections: '它沒有其他區段。',
|
|
1678
|
+
updateQuestion: '要更新現有 uds.project.yaml 裡的指令(test、lint、build、security)嗎?{kept}',
|
|
1679
|
+
replaceQuestion: '現有的 uds.project.yaml 無法當成 YAML 讀取,所以其中內容都無法保留。要整份取代嗎?',
|
|
1680
|
+
skippedKeeping: '已略過——保留現有的 uds.project.yaml',
|
|
1681
|
+
commandOptional: '{intent} 指令(選填):',
|
|
1682
|
+
commandDefault: '{intent} 指令(預設:{value}):',
|
|
1683
|
+
noneEntered: '沒有輸入任何指令——未建立 uds.project.yaml。',
|
|
1684
|
+
updated: '✔ uds.project.yaml 已更新(其他區段維持原樣)',
|
|
1685
|
+
created: '✔ 已建立 uds.project.yaml',
|
|
1686
|
+
path: '路徑:{path}'
|
|
1687
|
+
},
|
|
1640
1688
|
releaseMode: {
|
|
1641
1689
|
title: '發布模式:',
|
|
1642
1690
|
description: '選擇發布模式,影響版本如何發布',
|
|
@@ -2518,6 +2566,14 @@ export const messages = {
|
|
|
2518
2566
|
hookWouldMigrate: '+ .husky/pre-commit:將把舊版 UDS 寫入的那一行(它會請 npm 解析裸名稱 uds,而那不是本專案)換成只執行已安裝 UDS CLI 的寫法。',
|
|
2519
2567
|
hookLegacyKept: '⚠ .husky/pre-commit 第 {line} 行(「{text}」)會請 npm 解析裸名稱 uds,而它在 npm registry 上是不相干的套件。這一行不是 UDS 寫入的原樣,所以沒有動它。請自行改成 universal-dev-standards check——需要在本專案或 PATH 上已安裝 UDS CLI。',
|
|
2520
2568
|
hookMigrateFailed: '⚠ 無法改寫 .husky/pre-commit:{error}。請 npm 解析裸名稱 uds 的那一行仍在,請自行改成 universal-dev-standards check。',
|
|
2569
|
+
hookNativeMigrated: '✓ .git/hooks/pre-commit:已把舊版 UDS 寫入的掛鉤({from})換成現行版本。舊的會把檢查的錯誤丟掉、讓每個 commit 都通過;新的會在 `check --ci` 回報問題時擋下 commit。',
|
|
2570
|
+
hookNativeWouldMigrate: '+ .git/hooks/pre-commit:將把舊版 UDS 寫入的掛鉤({from})換成現行版本。舊的會把檢查的錯誤丟掉、讓每個 commit 都通過;新的會在 `check --ci` 回報問題時擋下 commit。',
|
|
2571
|
+
hookNativeKept: '⚠ .git/hooks/pre-commit 第 {line} 行(「{text}」)會執行 UDS 檢查,但不論查到什麼都讓 commit 通過。這個檔案不是 UDS 寫入的原樣,所以沒有動它。請自行把那一行改成 universal-dev-standards check --ci——需要在本專案或 PATH 上已安裝 UDS CLI。',
|
|
2572
|
+
hookHuskyCiMigrated: '✓ .husky/pre-commit:UDS 區塊現在執行 `check --ci`,檢查發現問題時掛鉤會擋下 commit。(較早的 beta 寫入的區塊只跑 `check`,標準檔被改了也回 0。)',
|
|
2573
|
+
hookHuskyCiWouldMigrate: '+ .husky/pre-commit:將把 UDS 區塊改成執行 `check --ci`,檢查發現問題時掛鉤會擋下 commit。(較早的 beta 寫入的區塊只跑 `check`,標準檔被改了也回 0。)',
|
|
2574
|
+
hookNativeFromLegacy: 'UDS 5.x 至 6.13.1:`uds check 2>/dev/null || true`',
|
|
2575
|
+
hookNativeFromWithoutCi: 'UDS 6.14.0 的 beta:`check` 沒帶 `--ci`',
|
|
2576
|
+
hookNativeFailed: '⚠ 無法改寫 .git/hooks/pre-commit:{error}。它仍會讓每個 commit 通過——請自行把其中的 UDS 檢查那一行換成 universal-dev-standards check --ci。',
|
|
2521
2577
|
newerVersion: '(你的版本比登錄庫更新:{version})',
|
|
2522
2578
|
updateAvailable: '有可用更新:{current} → {latest}',
|
|
2523
2579
|
// Files
|
|
@@ -3007,6 +3063,26 @@ export const messages = {
|
|
|
3007
3063
|
},
|
|
3008
3064
|
|
|
3009
3065
|
// Release Mode
|
|
3066
|
+
// `uds init` 可选的 uds.project.yaml 步骤的提问(XSPEC-482 R13:原本每种语言都是英文)。
|
|
3067
|
+
projectContract: {
|
|
3068
|
+
confirmCreate: '要创建 uds.project.yaml(项目命令契约)吗?',
|
|
3069
|
+
title: '📋 项目命令契约(uds.project.yaml)',
|
|
3070
|
+
intro1: '告诉 UDS 这个项目如何执行标准命令(与编程语言无关)。',
|
|
3071
|
+
intro2: '按 Enter 接受建议值,或自行输入。留空表示跳过。',
|
|
3072
|
+
detected: '检测到的建议值:',
|
|
3073
|
+
alreadyExists: 'uds.project.yaml 已存在。',
|
|
3074
|
+
keptSections: '这些区段会原封不动保留:{sections}。',
|
|
3075
|
+
noOtherSections: '它没有其他区段。',
|
|
3076
|
+
updateQuestion: '要更新现有 uds.project.yaml 里的命令(test、lint、build、security)吗?{kept}',
|
|
3077
|
+
replaceQuestion: '现有的 uds.project.yaml 无法当作 YAML 读取,所以其中内容都无法保留。要整份替换吗?',
|
|
3078
|
+
skippedKeeping: '已跳过——保留现有的 uds.project.yaml',
|
|
3079
|
+
commandOptional: '{intent} 命令(可选):',
|
|
3080
|
+
commandDefault: '{intent} 命令(默认:{value}):',
|
|
3081
|
+
noneEntered: '没有输入任何命令——未创建 uds.project.yaml。',
|
|
3082
|
+
updated: '✔ uds.project.yaml 已更新(其他区段保持原样)',
|
|
3083
|
+
created: '✔ 已创建 uds.project.yaml',
|
|
3084
|
+
path: '路径:{path}'
|
|
3085
|
+
},
|
|
3010
3086
|
releaseMode: {
|
|
3011
3087
|
title: '发布模式:',
|
|
3012
3088
|
description: '选择发布模式,影响版本如何发布',
|
|
@@ -3812,6 +3888,14 @@ export const messages = {
|
|
|
3812
3888
|
hookWouldMigrate: '+ .husky/pre-commit:将把旧版 UDS 写入的那一行(它会请 npm 解析裸名称 uds,而那不是本项目)换成只执行已安装 UDS CLI 的写法。',
|
|
3813
3889
|
hookLegacyKept: '⚠ .husky/pre-commit 第 {line} 行(“{text}”)会请 npm 解析裸名称 uds,而它在 npm registry 上是不相干的包。这一行不是 UDS 写入的原样,所以没有动它。请自行改成 universal-dev-standards check——需要在本项目或 PATH 上已安装 UDS CLI。',
|
|
3814
3890
|
hookMigrateFailed: '⚠ 无法改写 .husky/pre-commit:{error}。请 npm 解析裸名称 uds 的那一行仍在,请自行改成 universal-dev-standards check。',
|
|
3891
|
+
hookNativeMigrated: '✓ .git/hooks/pre-commit:已把旧版 UDS 写入的钩子({from})换成现行版本。旧的会把检查的错误丢掉、让每个 commit 都通过;新的会在 `check --ci` 报告问题时拦下 commit。',
|
|
3892
|
+
hookNativeWouldMigrate: '+ .git/hooks/pre-commit:将把旧版 UDS 写入的钩子({from})换成现行版本。旧的会把检查的错误丢掉、让每个 commit 都通过;新的会在 `check --ci` 报告问题时拦下 commit。',
|
|
3893
|
+
hookNativeKept: '⚠ .git/hooks/pre-commit 第 {line} 行(“{text}”)会执行 UDS 检查,但不论查到什么都让 commit 通过。这个文件不是 UDS 写入的原样,所以没有动它。请自行把那一行改成 universal-dev-standards check --ci——需要在本项目或 PATH 上已安装 UDS CLI。',
|
|
3894
|
+
hookHuskyCiMigrated: '✓ .husky/pre-commit:UDS 区块现在执行 `check --ci`,检查发现问题时钩子会拦下 commit。(较早的 beta 写入的区块只跑 `check`,标准文件被改了也返回 0。)',
|
|
3895
|
+
hookHuskyCiWouldMigrate: '+ .husky/pre-commit:将把 UDS 区块改成执行 `check --ci`,检查发现问题时钩子会拦下 commit。(较早的 beta 写入的区块只跑 `check`,标准文件被改了也返回 0。)',
|
|
3896
|
+
hookNativeFromLegacy: 'UDS 5.x 至 6.13.1:`uds check 2>/dev/null || true`',
|
|
3897
|
+
hookNativeFromWithoutCi: 'UDS 6.14.0 的 beta:`check` 没带 `--ci`',
|
|
3898
|
+
hookNativeFailed: '⚠ 无法改写 .git/hooks/pre-commit:{error}。它仍会让每个 commit 通过——请自行把其中的 UDS 检查那一行换成 universal-dev-standards check --ci。',
|
|
3815
3899
|
newerVersion: '(您有比注册表更新的版本:{version})',
|
|
3816
3900
|
updateAvailable: '有可用更新:{current} → {latest}',
|
|
3817
3901
|
// Files
|
|
@@ -57,7 +57,7 @@ export const hooksSourceDir = () => resolveDir(['hooks'], ['scripts', 'hooks']);
|
|
|
57
57
|
* (`matcher: { tool: Bash }`), which would be written into settings.json
|
|
58
58
|
* verbatim and never match anything.
|
|
59
59
|
*/
|
|
60
|
-
function normalizeMatcher(matcher) {
|
|
60
|
+
export function normalizeMatcher(matcher) {
|
|
61
61
|
if (typeof matcher === 'string') return matcher;
|
|
62
62
|
if (matcher && typeof matcher === 'object' && typeof matcher.tool === 'string') return matcher.tool;
|
|
63
63
|
return '';
|
package/src/mcp/server.js
CHANGED
|
@@ -123,6 +123,9 @@ export class McpServer {
|
|
|
123
123
|
switch (method) {
|
|
124
124
|
case 'initialize':
|
|
125
125
|
return this.handleInitialize(request);
|
|
126
|
+
case 'ping':
|
|
127
|
+
// MCP utility: a liveness check; the answer is an empty result (XSPEC-482 R14c).
|
|
128
|
+
return { jsonrpc: '2.0', id, result: {} }; // wire:mcp-ping
|
|
126
129
|
case 'tools/list':
|
|
127
130
|
return this.handleToolsList(request);
|
|
128
131
|
case 'tools/call':
|
|
@@ -252,12 +255,15 @@ export class McpServer {
|
|
|
252
255
|
result: toolResult,
|
|
253
256
|
};
|
|
254
257
|
} catch (err) {
|
|
258
|
+
// A tool that ran and failed (a file it needed is not there) answers with a RESULT marked `isError`, as MCP
|
|
259
|
+
// specifies for tool execution errors, so the model calling it can read the reason and go on. A JSON-RPC
|
|
260
|
+
// error is for a request the server could not take at all (XSPEC-482 R14c).
|
|
255
261
|
return {
|
|
256
262
|
jsonrpc: '2.0',
|
|
257
263
|
id,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
result: {
|
|
265
|
+
content: [{ type: 'text', text: err.message }],
|
|
266
|
+
isError: true, // wire:mcp-tool-error-is-a-result
|
|
261
267
|
},
|
|
262
268
|
};
|
|
263
269
|
}
|
package/src/prompts/init.js
CHANGED
|
@@ -1569,7 +1569,7 @@ export function mergeProjectConfigYaml(existing, commands) {
|
|
|
1569
1569
|
export async function promptProjectContractStep(projectPath) {
|
|
1570
1570
|
try {
|
|
1571
1571
|
const wantContract = await inquirerConfirm({
|
|
1572
|
-
message:
|
|
1572
|
+
message: t().projectContract.confirmCreate,
|
|
1573
1573
|
default: true
|
|
1574
1574
|
});
|
|
1575
1575
|
if (wantContract) {
|
|
@@ -1600,22 +1600,21 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1600
1600
|
existing = describeProjectConfig(existingText);
|
|
1601
1601
|
|
|
1602
1602
|
console.log();
|
|
1603
|
-
console.log(chalk.yellow(
|
|
1603
|
+
console.log(chalk.yellow(` ${t().projectContract.alreadyExists}`));
|
|
1604
1604
|
|
|
1605
1605
|
const kept = existing.sections.filter(name => name !== 'commands');
|
|
1606
|
+
const pc = t().projectContract;
|
|
1606
1607
|
const message = existing.readable
|
|
1607
|
-
? '
|
|
1608
|
-
(kept.
|
|
1609
|
-
|
|
1610
|
-
: 'It has no other sections.')
|
|
1608
|
+
? pc.updateQuestion.replace('{kept}', kept.length > 0
|
|
1609
|
+
? pc.keptSections.replace('{sections}', kept.join(', '))
|
|
1610
|
+
: pc.noOtherSections)
|
|
1611
1611
|
// Not YAML: nothing in it can be kept, so the question names the loss instead of hiding it.
|
|
1612
|
-
:
|
|
1613
|
-
'Replace the whole file?';
|
|
1612
|
+
: pc.replaceQuestion;
|
|
1614
1613
|
|
|
1615
1614
|
const overwrite = await inquirerConfirm({ message, default: false });
|
|
1616
1615
|
|
|
1617
1616
|
if (!overwrite) {
|
|
1618
|
-
console.log(chalk.gray(
|
|
1617
|
+
console.log(chalk.gray(` ${t().projectContract.skippedKeeping}`));
|
|
1619
1618
|
return false;
|
|
1620
1619
|
}
|
|
1621
1620
|
}
|
|
@@ -1624,13 +1623,14 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1624
1623
|
const hasAnySuggestion = Object.values(suggestions).some(v => v);
|
|
1625
1624
|
|
|
1626
1625
|
console.log();
|
|
1627
|
-
|
|
1628
|
-
console.log(chalk.
|
|
1629
|
-
console.log(chalk.gray(
|
|
1626
|
+
const pcm = t().projectContract;
|
|
1627
|
+
console.log(chalk.bold(pcm.title));
|
|
1628
|
+
console.log(chalk.gray(` ${pcm.intro1}`));
|
|
1629
|
+
console.log(chalk.gray(` ${pcm.intro2}`));
|
|
1630
1630
|
console.log();
|
|
1631
1631
|
|
|
1632
1632
|
if (hasAnySuggestion) {
|
|
1633
|
-
console.log(chalk.gray(
|
|
1633
|
+
console.log(chalk.gray(` ${pcm.detected}`));
|
|
1634
1634
|
for (const [intent, cmd] of Object.entries(suggestions)) {
|
|
1635
1635
|
if (cmd) console.log(chalk.gray(` ${intent}: ${cmd}`));
|
|
1636
1636
|
}
|
|
@@ -1644,7 +1644,7 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1644
1644
|
// A command the file already declares is the default, so Enter keeps it; the ecosystem guess only fills gaps.
|
|
1645
1645
|
const defaultVal = existing?.commands?.[intent] || suggestions[intent] || '';
|
|
1646
1646
|
const answer = await input({
|
|
1647
|
-
message: ` ${
|
|
1647
|
+
message: ` ${defaultVal ? pcm.commandDefault.replace('{intent}', intent).replace('{value}', defaultVal) : pcm.commandOptional.replace('{intent}', intent)}`,
|
|
1648
1648
|
default: defaultVal
|
|
1649
1649
|
});
|
|
1650
1650
|
commands[intent] = answer.trim();
|
|
@@ -1652,7 +1652,7 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1652
1652
|
|
|
1653
1653
|
const hasAnyCommand = Object.values(commands).some(v => v);
|
|
1654
1654
|
if (!hasAnyCommand) {
|
|
1655
|
-
console.log(chalk.gray(
|
|
1655
|
+
console.log(chalk.gray(` ${pcm.noneEntered}`));
|
|
1656
1656
|
return false;
|
|
1657
1657
|
}
|
|
1658
1658
|
|
|
@@ -1665,7 +1665,7 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1665
1665
|
writeFileSync(contractPath, content, 'utf-8');
|
|
1666
1666
|
|
|
1667
1667
|
console.log();
|
|
1668
|
-
console.log(chalk.green(merging ?
|
|
1669
|
-
console.log(chalk.gray(`
|
|
1668
|
+
console.log(chalk.green(` ${merging ? pcm.updated : pcm.created}`));
|
|
1669
|
+
console.log(chalk.gray(` ${pcm.path.replace('{path}', contractPath)}`));
|
|
1670
1670
|
return true;
|
|
1671
1671
|
}
|
|
@@ -436,6 +436,36 @@ function recordInstalledSet(manifest, kind, installResult) {
|
|
|
436
436
|
manifest[kind].names = mergeInstalledNames(manifest[kind].names, installResult);
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
/**
|
|
440
|
+
* The outcome of one skill or command action after its batch ran (XSPEC-482 R10).
|
|
441
|
+
*
|
|
442
|
+
* The batch installer answers once for all of them. The old code copied that one answer onto every action and gave
|
|
443
|
+
* no reason, so a read-only skills folder printed "8 failed" and then eight lines of "Unknown error" with neither a path nor a
|
|
444
|
+
* cause, and a skill that had installed fine was counted as failed too. Here each action is judged on its own: it fails when
|
|
445
|
+
* the installer recorded an error for its name (or for its whole agent), and the error says which path and why.
|
|
446
|
+
*
|
|
447
|
+
* @param {Object} action - plan action (category 'skill' or 'command')
|
|
448
|
+
* @param {Object} installResult - from installSkills/CommandsToMultipleAgents
|
|
449
|
+
* @param {'skill'|'command'} kind
|
|
450
|
+
* @returns {{ action: Object, success: boolean, error?: string }}
|
|
451
|
+
*/
|
|
452
|
+
export function judgeBatchAction(action, installResult, kind) {
|
|
453
|
+
const meta = action.details?.metadata;
|
|
454
|
+
const name = kind === 'skill' ? meta?.skillName : meta?.commandName;
|
|
455
|
+
const installs = (installResult.installations || []).filter(i => !meta?.agent || i.agent === meta.agent);
|
|
456
|
+
const reasons = [];
|
|
457
|
+
for (const inst of installs) {
|
|
458
|
+
if (inst.error) reasons.push(inst.error);
|
|
459
|
+
for (const e of inst.errors || []) {
|
|
460
|
+
if (e && e[kind] === name && e.error) reasons.push(e.error);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (reasons.length > 0) return { action, success: false, error: `${action.path}: ${reasons[0]}` };
|
|
464
|
+
if (installResult.success) return { action, success: true };
|
|
465
|
+
if (installs.some(i => (i.installed || []).includes(name))) return { action, success: true };
|
|
466
|
+
return { action, success: false, error: `${action.path}: the installer did not install ${kind} "${name}" and gave no reason` };
|
|
467
|
+
}
|
|
468
|
+
|
|
439
469
|
/**
|
|
440
470
|
* Batch execute skill installations.
|
|
441
471
|
*/
|
|
@@ -504,11 +534,11 @@ async function executeSkillBatch(projectPath, skillActions, manifest) {
|
|
|
504
534
|
}
|
|
505
535
|
|
|
506
536
|
for (const action of toInstall) {
|
|
507
|
-
results.push(
|
|
537
|
+
results.push(judgeBatchAction(action, installResult, 'skill')); // wire:skill-batch-names-its-failures
|
|
508
538
|
}
|
|
509
539
|
} catch (err) {
|
|
510
540
|
for (const action of toInstall) {
|
|
511
|
-
results.push({ action, success: false, error: err.message });
|
|
541
|
+
results.push({ action, success: false, error: `${action.path}: ${err.message}` });
|
|
512
542
|
}
|
|
513
543
|
}
|
|
514
544
|
}
|
|
@@ -594,11 +624,11 @@ async function executeCommandBatch(projectPath, commandActions, manifest) {
|
|
|
594
624
|
}
|
|
595
625
|
|
|
596
626
|
for (const action of toInstall) {
|
|
597
|
-
results.push(
|
|
627
|
+
results.push(judgeBatchAction(action, installResult, 'command'));
|
|
598
628
|
}
|
|
599
629
|
} catch (err) {
|
|
600
630
|
for (const action of toInstall) {
|
|
601
|
-
results.push({ action, success: false, error: err.message });
|
|
631
|
+
results.push({ action, success: false, error: `${action.path}: ${err.message}` });
|
|
602
632
|
}
|
|
603
633
|
}
|
|
604
634
|
}
|
|
@@ -29,3 +29,21 @@ export function alignRecordedVersions(manifest) {
|
|
|
29
29
|
}
|
|
30
30
|
return { manifest, changed };
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set `upstream.version` (and the date it was recorded) to the standards version this UDS ships (XSPEC-482 R6).
|
|
35
|
+
*
|
|
36
|
+
* The same reasoning as for skills and commands above: when a reconcile finds nothing to do, every standard file is exactly
|
|
37
|
+
* what this UDS ships, so the version recorded for the standards is the shipped one. Only a reconcile that EXECUTED a plan
|
|
38
|
+
* recorded it, so a project whose files were already current kept the version of the UDS that installed them; it surfaced
|
|
39
|
+
* once `uds init` left a project with nothing for the first `--apply` to do (the XSPEC-382 R5 end-to-end test seeds an old
|
|
40
|
+
* version and expects `--apply` to move it).
|
|
41
|
+
* @param {Object} manifest
|
|
42
|
+
* @returns {{ manifest: Object, changed: boolean }}
|
|
43
|
+
*/
|
|
44
|
+
export function alignUpstreamVersion(manifest) {
|
|
45
|
+
const shipped = getRepositoryInfo()?.standards?.version;
|
|
46
|
+
if (!shipped || !manifest?.upstream || manifest.upstream.version === shipped) return { manifest, changed: false };
|
|
47
|
+
manifest.upstream = { ...manifest.upstream, version: shipped, installed: new Date().toISOString().split('T')[0] };
|
|
48
|
+
return { manifest, changed: true };
|
|
49
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync, unlinkSync, readdirSync, rmdirSync } from 'fs';
|
|
2
2
|
import { join, basename } from 'path';
|
|
3
3
|
import { proveUnchanged, RECORD_KINDS, RECORDS_KEY, isRealDirectory } from '../core/install-records.js';
|
|
4
|
-
import { stripUdsHookBlock } from '../utils/git-hooks.js';
|
|
4
|
+
import { stripUdsHookBlock, classifyNativePreCommitHook } from '../utils/git-hooks.js';
|
|
5
5
|
import {
|
|
6
6
|
collectHookConfigs, standardsSourceDir, hooksSourceDir,
|
|
7
7
|
CODEX_HOOK_SCRIPT, GEMINI_HOOK_SCRIPT, AGY_HOOK_SCRIPT,
|
|
@@ -427,6 +427,14 @@ export function uninstallHook(projectPath, options = {}) {
|
|
|
427
427
|
if (!dryRun) unlinkSync(nativeHookPath);
|
|
428
428
|
result.removed.push(`.git/hooks/pre-commit (UDS native hook, file removed — ${proof.why})`);
|
|
429
429
|
result.deletedPaths.push('.git/hooks/pre-commit');
|
|
430
|
+
} else if (classifyNativePreCommitHook(content)) { // wire:uninstall-removes-known-native-hook
|
|
431
|
+
// XSPEC-482 R8: no install record (an older UDS wrote it, and old versions recorded nothing), but the file
|
|
432
|
+
// is byte for byte a hook UDS has written - the always-pass hook of 5.x to 6.13.1, or one of the later ones.
|
|
433
|
+
// Exact text is the proof; deleting only the matching lines used to leave a script behind that still
|
|
434
|
+
// printed "Pre-commit checks passed" and checked nothing.
|
|
435
|
+
if (!dryRun) unlinkSync(nativeHookPath);
|
|
436
|
+
result.removed.push('.git/hooks/pre-commit (UDS native hook, file removed - its text is exactly what UDS writes, so nothing of yours is in it)');
|
|
437
|
+
result.deletedPaths.push('.git/hooks/pre-commit');
|
|
430
438
|
} else if (!NATIVE_UDS_LINE.test(content) && !stripUdsHookBlock(content).removed) {
|
|
431
439
|
result.skipped.push('.git/hooks/pre-commit (no UDS lines found)');
|
|
432
440
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, rmSync, rmdirSync, readdirSync, unlinkSync } from 'fs';
|
|
2
|
-
import { dirname, join, relative, isAbsolute } from 'path';
|
|
2
|
+
import { dirname, join, relative, isAbsolute, resolve } from 'path';
|
|
3
3
|
import {
|
|
4
4
|
getSkillsDirForAgent,
|
|
5
5
|
getCommandsDirForAgent
|
|
@@ -148,10 +148,17 @@ function processInstallation(install, type, projectPath, manifest, options, resu
|
|
|
148
148
|
if (existsSync(marker)) rmSync(marker, { force: true });
|
|
149
149
|
}
|
|
150
150
|
// Folders UDS emptied, deepest first, then the installation folder itself.
|
|
151
|
+
// The installation folder is compared as a resolved path: `dir` carries the trailing slash the path table
|
|
152
|
+
// gives it (`.gemini/commands/`) and `dirname(file)` does not, so the old `d !== dir` was true for the
|
|
153
|
+
// installation folder itself. It was removed in this loop, `removeIfEmpty(dir)` below then found nothing to
|
|
154
|
+
// remove and answered "not gone": the line said "folder kept" for a folder that was deleted, and the tool's
|
|
155
|
+
// own parent (`.gemini/`, `.opencode/`) was never looked at, so an empty one stayed (XSPEC-482 R8).
|
|
156
|
+
const installDir = resolve(dir);
|
|
151
157
|
for (const d of [...touched].sort((a, b) => b.length - a.length)) {
|
|
152
|
-
if (d !==
|
|
158
|
+
if (resolve(d) !== installDir) removeIfEmpty(d);
|
|
153
159
|
}
|
|
154
|
-
|
|
160
|
+
removeIfEmpty(dir);
|
|
161
|
+
const gone = !existsSync(dir); // wire:uninstall-folder-removed-is-reported
|
|
155
162
|
// XSPEC-475 R5(d): the tool's own folder (`.claude/`, `.codex/` ...) that held only what UDS wrote is empty now; an
|
|
156
163
|
// empty `.claude/` left in the project is a trace of UDS. Only an EMPTY folder inside the project, never the project
|
|
157
164
|
// root, and never a user-level folder.
|
|
@@ -52,7 +52,7 @@ export function verifyManifest(manifest, gitTagCommit, options = {}) {
|
|
|
52
52
|
if (!manifest.commit) {
|
|
53
53
|
errors.push('manifest missing commit field');
|
|
54
54
|
} else if (manifest.commit !== gitTagCommit) {
|
|
55
|
-
errors.push(`commit mismatch: manifest has "${manifest.commit}",
|
|
55
|
+
errors.push(`commit mismatch: manifest has "${manifest.commit}", the current HEAD is "${gitTagCommit}"`);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const recorded = manifest.checksum?.package ?? null;
|
package/src/utils/git-hooks.js
CHANGED
|
@@ -189,16 +189,34 @@ export function hookRunsUdsCheck(content) {
|
|
|
189
189
|
* - Not installed: say what is missing and how to fix it, exit non-zero. It
|
|
190
190
|
* neither skips the check nor downloads anything.
|
|
191
191
|
*
|
|
192
|
-
* @param {{args?: string, hookFile?: string}} [opts]
|
|
192
|
+
* @param {{args?: string, hookFile?: string, ci?: boolean}} [opts]
|
|
193
193
|
* args — extra arguments to keep on the check command
|
|
194
194
|
* (e.g. `--standard checkin-standards`, which older UDS versions wrote).
|
|
195
195
|
* hookFile — the file the block is written into, named in the "blocked" message so
|
|
196
196
|
* it points at the file the adopter actually has (default `.husky/pre-commit`;
|
|
197
197
|
* the native hook passes `.git/hooks/pre-commit`).
|
|
198
|
+
* ci — call `check --ci` (default). A plain `uds check` prints "Some issues detected" and exits 0
|
|
199
|
+
* when a standard file was edited, so a hook that runs it never stops a commit for that
|
|
200
|
+
* (XSPEC-482 R3, found by the beta.12 macOS retest: tampered standard, `git commit` went
|
|
201
|
+
* through). `--ci` is the mode whose exit code says "issues". `ci: false` rebuilds the text
|
|
202
|
+
* UDS 6.14.0-beta.2 to beta.12 wrote, ONLY so that `uds update` can recognise it exactly
|
|
203
|
+
* (legacy-hook-migration.js); nothing writes that text any more.
|
|
198
204
|
* @returns {string} the block, LF line endings, ending with a newline
|
|
199
205
|
*/
|
|
200
|
-
export function buildPreCommitBlock({ args = '', hookFile = '.husky/pre-commit' } = {}) {
|
|
201
|
-
const cmd = args ? `${UDS_BIN_NAME} check ${args}` : `${UDS_BIN_NAME} check`;
|
|
206
|
+
export function buildPreCommitBlock({ args = '', hookFile = '.husky/pre-commit', ci = true } = {}) {
|
|
207
|
+
const cmd = args ? `${UDS_BIN_NAME} check ${args}` : `${UDS_BIN_NAME} check${ci ? ' --ci' : ''}`;
|
|
208
|
+
// When the check fails the commit is stopped; say so (the lines above it name the files), otherwise the
|
|
209
|
+
// reader sees a list of warnings and no sign that git refused the commit because of them.
|
|
210
|
+
const afterCheck = (ci && !args)
|
|
211
|
+
? [
|
|
212
|
+
' status=$?',
|
|
213
|
+
' if [ "$status" -ne 0 ]; then',
|
|
214
|
+
' echo "[UDS] This commit is blocked: the UDS check found the issues listed above." >&2',
|
|
215
|
+
' echo "[UDS] To put the standard files back, run the UDS CLI with: check --restore" >&2',
|
|
216
|
+
' fi',
|
|
217
|
+
' exit $status'
|
|
218
|
+
]
|
|
219
|
+
: [' exit $?'];
|
|
202
220
|
return [
|
|
203
221
|
UDS_HOOK_MARKER,
|
|
204
222
|
'# Runs the UDS CLI installed in this project (node_modules/.bin) or on PATH.',
|
|
@@ -208,7 +226,7 @@ export function buildPreCommitBlock({ args = '', hookFile = '.husky/pre-commit'
|
|
|
208
226
|
' PATH="$PWD/node_modules/.bin:$PATH"',
|
|
209
227
|
` if command -v ${UDS_BIN_NAME} >/dev/null 2>&1; then`,
|
|
210
228
|
` ${cmd}`,
|
|
211
|
-
|
|
229
|
+
...afterCheck,
|
|
212
230
|
' fi',
|
|
213
231
|
` echo "[UDS] Pre-commit check cannot run: the UDS CLI (${UDS_BIN_NAME}) is not installed." >&2`,
|
|
214
232
|
` echo "[UDS] Install it: npm install --save-dev ${UDS_BIN_NAME} (or: npm install -g ${UDS_BIN_NAME})" >&2`,
|
|
@@ -220,6 +238,90 @@ export function buildPreCommitBlock({ args = '', hookFile = '.husky/pre-commit'
|
|
|
220
238
|
].join('\n');
|
|
221
239
|
}
|
|
222
240
|
|
|
241
|
+
/**
|
|
242
|
+
* The whole `.git/hooks/pre-commit` file `uds init` writes for a project that has no package.json.
|
|
243
|
+
*
|
|
244
|
+
* Fail-closed (XSPEC-444 R1 class sweep): a linter that is installed and fails blocks the commit; one that is
|
|
245
|
+
* not installed is skipped. The UDS check is the block above, whose exit status stops the commit.
|
|
246
|
+
*
|
|
247
|
+
* @param {{ci?: boolean}} [opts] `ci: false` rebuilds the beta.2 to beta.12 text, for exact recognition only (see buildPreCommitBlock)
|
|
248
|
+
* @returns {string}
|
|
249
|
+
*/
|
|
250
|
+
export function buildNativePreCommitHook({ ci = true } = {}) {
|
|
251
|
+
return `#!/bin/sh
|
|
252
|
+
# UDS pre-commit hook
|
|
253
|
+
# Auto-generated by uds init
|
|
254
|
+
|
|
255
|
+
echo "Running UDS pre-commit checks..."
|
|
256
|
+
|
|
257
|
+
# Lint, when the language's linter is installed. A failing linter blocks the commit.
|
|
258
|
+
if [ -f pyproject.toml ] || [ -f requirements.txt ]; then
|
|
259
|
+
if python -m ruff --version >/dev/null 2>&1; then
|
|
260
|
+
python -m ruff check . || exit $?
|
|
261
|
+
fi
|
|
262
|
+
elif [ -f go.mod ]; then
|
|
263
|
+
if command -v go >/dev/null 2>&1; then
|
|
264
|
+
go vet ./... || exit $?
|
|
265
|
+
fi
|
|
266
|
+
elif [ -f Cargo.toml ]; then
|
|
267
|
+
if command -v cargo >/dev/null 2>&1; then
|
|
268
|
+
cargo clippy || exit $?
|
|
269
|
+
fi
|
|
270
|
+
fi
|
|
271
|
+
|
|
272
|
+
${buildPreCommitBlock({ hookFile: '.git/hooks/pre-commit', ci })}
|
|
273
|
+
echo "Pre-commit checks passed"
|
|
274
|
+
`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The `.git/hooks/pre-commit` that every UDS release from the 5.x line to 6.13.1 wrote (checked byte for byte
|
|
279
|
+
* against the file `universal-dev-standards@6.11.0` produces; the template did not change between those
|
|
280
|
+
* releases, `git log -S` on init.js). It runs `uds check 2>/dev/null || true`: the CLI that PATH happens to
|
|
281
|
+
* hold, errors thrown away, always "passed". Kept here as text so `uds update` and `uds uninstall` can tell
|
|
282
|
+
* "UDS wrote exactly this" from "someone edited it". Nothing writes it any more.
|
|
283
|
+
*/
|
|
284
|
+
export const LEGACY_NATIVE_HOOK_6_11 = `#!/bin/sh
|
|
285
|
+
# UDS pre-commit hook
|
|
286
|
+
# Auto-generated by uds init
|
|
287
|
+
|
|
288
|
+
echo "Running UDS pre-commit checks..."
|
|
289
|
+
|
|
290
|
+
# Run lint if available
|
|
291
|
+
if [ -f pyproject.toml ] || [ -f requirements.txt ]; then
|
|
292
|
+
python -m ruff check . 2>/dev/null || true
|
|
293
|
+
elif [ -f go.mod ]; then
|
|
294
|
+
go vet ./... 2>/dev/null || true
|
|
295
|
+
elif [ -f Cargo.toml ]; then
|
|
296
|
+
cargo clippy 2>/dev/null || true
|
|
297
|
+
fi
|
|
298
|
+
|
|
299
|
+
# UDS Standard Check
|
|
300
|
+
uds check 2>/dev/null || true
|
|
301
|
+
|
|
302
|
+
echo "Pre-commit checks passed"
|
|
303
|
+
`;
|
|
304
|
+
|
|
305
|
+
/** Line endings made LF, so a hook file saved with CRLF still compares equal to the text above. */
|
|
306
|
+
const lf = (text) => String(text).replace(/\r\n/g, '\n');
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Which hook text, if any, is `content` byte for byte (apart from line endings)?
|
|
310
|
+
* @returns {'legacy-6.11'|'without-ci'|'current'|null}
|
|
311
|
+
* legacy-6.11 — the always-pass hook of 5.x to 6.13.1;
|
|
312
|
+
* without-ci — the beta.2 to beta.12 hook, whose check cannot fail a commit;
|
|
313
|
+
* current — what this CLI writes;
|
|
314
|
+
* null — anything else: not provably UDS's.
|
|
315
|
+
*/
|
|
316
|
+
export function classifyNativePreCommitHook(content) {
|
|
317
|
+
if (typeof content !== 'string') return null;
|
|
318
|
+
const text = lf(content);
|
|
319
|
+
if (text === LEGACY_NATIVE_HOOK_6_11) return 'legacy-6.11';
|
|
320
|
+
if (text === buildNativePreCommitHook({ ci: false })) return 'without-ci';
|
|
321
|
+
if (text === buildNativePreCommitHook()) return 'current';
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
|
|
223
325
|
/**
|
|
224
326
|
* Remove the block buildPreCommitBlock() writes — from the marker line through
|
|
225
327
|
* the end-marker line, inclusive — and nothing else. A block whose end marker is
|