universal-dev-standards 6.14.0-beta.7 → 6.14.0-beta.9
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/bundled/locales/zh-CN/CHANGELOG.md +41 -3
- package/bundled/locales/zh-CN/README.md +1 -1
- package/bundled/locales/zh-CN/SECURITY.md +1 -1
- package/bundled/locales/zh-TW/CHANGELOG.md +41 -3
- package/bundled/locales/zh-TW/README.md +1 -1
- package/bundled/locales/zh-TW/SECURITY.md +1 -1
- package/package.json +1 -1
- package/src/commands/check.js +5 -4
- package/src/commands/hitl.js +3 -0
- package/src/commands/list.js +12 -3
- package/src/commands/mcp.js +2 -3
- package/src/commands/quickstart.js +29 -13
- package/src/commands/release.js +41 -17
- package/src/commands/spec-split.js +30 -17
- package/src/commands/spec.js +41 -13
- package/src/commands/uninstall.js +2 -2
- package/src/commands/update.js +11 -10
- package/src/hitl/manager.js +4 -2
- package/src/i18n/messages.js +57 -3
- package/src/mcp/__tests__/server.test.js +0 -1
- package/src/mcp/server.js +16 -4
- package/src/uninstallers/skills-uninstaller.js +83 -16
- package/src/uninstallers/standards-uninstaller.js +56 -7
- package/src/utils/agents-installer.js +10 -17
- package/src/utils/prompt-closed.js +18 -0
- package/standards-registry.json +32 -7
|
@@ -227,7 +227,7 @@ async function gatherPreview(projectPath, manifest, categories, includeUserLevel
|
|
|
227
227
|
preview.integrations = await uninstallIntegrations(projectPath, manifest, { dryRun: true });
|
|
228
228
|
}
|
|
229
229
|
if (categories.includes('standards')) {
|
|
230
|
-
preview.standards = uninstallStandards(projectPath, { dryRun: true });
|
|
230
|
+
preview.standards = uninstallStandards(projectPath, { dryRun: true, manifest });
|
|
231
231
|
}
|
|
232
232
|
if (categories.includes('hooks')) {
|
|
233
233
|
// Nothing is deleted yet in a preview, so folders are judged against what the
|
|
@@ -267,7 +267,7 @@ async function executeUninstall(projectPath, manifest, categories, options) {
|
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
269
|
if (categories.includes('standards')) {
|
|
270
|
-
results.standards = uninstallStandards(projectPath);
|
|
270
|
+
results.standards = uninstallStandards(projectPath, { manifest });
|
|
271
271
|
}
|
|
272
272
|
if (categories.includes('hooks')) {
|
|
273
273
|
// After everything else, so a folder that only held UDS files is empty by now.
|
package/src/commands/update.js
CHANGED
|
@@ -1707,29 +1707,30 @@ async function offerErrorExitGate(projectPath, options) {
|
|
|
1707
1707
|
const src = join(getRepoRoot(), 'templates', 'gates', 'check-error-exit.mjs');
|
|
1708
1708
|
if (!existsSync(src)) return; // 範本沒出貨——沉默,不要假裝提供了
|
|
1709
1709
|
|
|
1710
|
-
|
|
1711
|
-
console.log(chalk.
|
|
1712
|
-
console.log(chalk.gray(
|
|
1713
|
-
console.log(chalk.gray(
|
|
1714
|
-
console.log(chalk.gray('
|
|
1715
|
-
console.log(chalk.gray(
|
|
1710
|
+
const m = t().commands.update.errorExitOffer;
|
|
1711
|
+
console.log(chalk.bold(m.title));
|
|
1712
|
+
console.log(chalk.gray(m.guards));
|
|
1713
|
+
console.log(chalk.gray(m.drift));
|
|
1714
|
+
console.log(chalk.gray(m.willWrite.replace('{kb}', String(Math.round(readFileSync(src, 'utf-8').length / 1024)))));
|
|
1715
|
+
console.log(chalk.gray(m.exit2a));
|
|
1716
|
+
console.log(chalk.gray(m.exit2b));
|
|
1716
1717
|
console.log();
|
|
1717
1718
|
|
|
1718
1719
|
const ok = await confirmOrFail({
|
|
1719
|
-
message:
|
|
1720
|
+
message: m.question,
|
|
1720
1721
|
defaultValue: false, // 🔴 預設不寫。沉默不是同意。
|
|
1721
1722
|
options
|
|
1722
1723
|
});
|
|
1723
1724
|
if (!ok) {
|
|
1724
|
-
console.log(chalk.gray(
|
|
1725
|
+
console.log(chalk.gray(m.skipped));
|
|
1725
1726
|
console.log();
|
|
1726
1727
|
return;
|
|
1727
1728
|
}
|
|
1728
1729
|
|
|
1729
1730
|
mkdirSync(dirname(dest), { recursive: true });
|
|
1730
1731
|
writeFileSync(dest, readFileSync(src, 'utf-8'), 'utf-8');
|
|
1731
|
-
console.log(chalk.green(
|
|
1732
|
-
console.log(chalk.gray(
|
|
1732
|
+
console.log(chalk.green(m.written));
|
|
1733
|
+
console.log(chalk.gray(m.next));
|
|
1733
1734
|
console.log();
|
|
1734
1735
|
}
|
|
1735
1736
|
|
package/src/hitl/manager.js
CHANGED
|
@@ -40,8 +40,10 @@ export class HitlManager {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
async _promptUser(operation, riskLevel, context) {
|
|
43
|
-
// Check if we are in non-interactive mode
|
|
44
|
-
|
|
43
|
+
// Check if we are in non-interactive mode: CI, a declared non-interactive run, or no terminal to answer on.
|
|
44
|
+
// A prompt with no terminal never gets an answer; @inquirer/prompts then lets the process end with exit code 0 and a
|
|
45
|
+
// stack trace, which `uds hitl check` callers read as "approved". No one to ask means blocked, as in CI.
|
|
46
|
+
if (process.env.CI || process.env.UDS_NON_INTERACTIVE || !process.stdin.isTTY) {
|
|
45
47
|
console.log(chalk.yellow(''));
|
|
46
48
|
console.log(chalk.yellow('HITL Checkpoint triggered in non-interactive mode.'));
|
|
47
49
|
console.log(chalk.gray(` Operation: ${operation}`));
|
package/src/i18n/messages.js
CHANGED
|
@@ -728,7 +728,7 @@ export const messages = {
|
|
|
728
728
|
errorLevelRange: 'Error: Level must be 1, 2, or 3',
|
|
729
729
|
showingLevel: 'Showing Level',
|
|
730
730
|
errorUnknownCategory: 'Error: Unknown category',
|
|
731
|
-
validCategories: 'Valid categories:
|
|
731
|
+
validCategories: 'Valid categories:',
|
|
732
732
|
category: 'Category',
|
|
733
733
|
appliesTo: 'Applies to',
|
|
734
734
|
totalSummary: 'standards',
|
|
@@ -779,6 +779,12 @@ export const messages = {
|
|
|
779
779
|
|
|
780
780
|
// check command
|
|
781
781
|
check: {
|
|
782
|
+
errorExitGate: {
|
|
783
|
+
missing: ' ⚠ [error-exit] No single-exit check for error messages (scripts/check-error-exit.mjs).',
|
|
784
|
+
why1: ' This gate stops every caller from turning an error response into its own human-readable string —',
|
|
785
|
+
why2: ' the first one is the implementation; from the second on they drift apart, and the screen shows only "Bad Request".',
|
|
786
|
+
howTo: ' To install it: `uds update` shows its content and asks before writing it.',
|
|
787
|
+
},
|
|
782
788
|
title: 'Universal Documentation Standards - Check',
|
|
783
789
|
// Basic status
|
|
784
790
|
standardsInitialized: '✓ Standards initialized',
|
|
@@ -1099,6 +1105,18 @@ export const messages = {
|
|
|
1099
1105
|
|
|
1100
1106
|
// update command
|
|
1101
1107
|
update: {
|
|
1108
|
+
errorExitOffer: {
|
|
1109
|
+
title: ' Single exit for error messages (gate)',
|
|
1110
|
+
guards: ' It guards against: every caller turning an error response into its own human-readable string.',
|
|
1111
|
+
drift: ' The first one is the implementation; from the second on they drift apart, and the screen shows only "Bad Request".',
|
|
1112
|
+
willWrite: ' Will write: scripts/check-error-exit.mjs (plain Node, no dependencies, {kb}KB)',
|
|
1113
|
+
exit2a: ' Once written it exits 2 until you fill in its CONFIG — on purpose:',
|
|
1114
|
+
exit2b: ' a gate that quietly passes in a new repo cannot be told apart from one that is not installed.',
|
|
1115
|
+
question: 'Write this gate to scripts/check-error-exit.mjs?',
|
|
1116
|
+
skipped: ' Skipped. `uds check` will remind you again, but will not write it by itself.',
|
|
1117
|
+
written: ' ✓ Wrote scripts/check-error-exit.mjs',
|
|
1118
|
+
next: ' Next: fill in the CONFIG at the top of the file, then wire it into your CI or pre-commit.',
|
|
1119
|
+
},
|
|
1102
1120
|
title: 'Universal Documentation Standards - Update',
|
|
1103
1121
|
// CLI update
|
|
1104
1122
|
cliUpdateAvailable: '⚡ New CLI version available!',
|
|
@@ -2083,7 +2101,7 @@ export const messages = {
|
|
|
2083
2101
|
errorLevelRange: '錯誤:等級必須是 1、2 或 3',
|
|
2084
2102
|
showingLevel: '顯示等級',
|
|
2085
2103
|
errorUnknownCategory: '錯誤:未知類別',
|
|
2086
|
-
validCategories: '有效類別:
|
|
2104
|
+
validCategories: '有效類別:',
|
|
2087
2105
|
category: '類別',
|
|
2088
2106
|
appliesTo: '適用於',
|
|
2089
2107
|
totalSummary: '項標準',
|
|
@@ -2134,6 +2152,12 @@ export const messages = {
|
|
|
2134
2152
|
|
|
2135
2153
|
// check command
|
|
2136
2154
|
check: {
|
|
2155
|
+
errorExitGate: {
|
|
2156
|
+
missing: ' ⚠ [error-exit] 沒有錯誤訊息單一出口檢查(scripts/check-error-exit.mjs)。',
|
|
2157
|
+
why1: ' 這道閘門防的是「每個呼叫端各自把錯誤回應拼成給人看的字串」——',
|
|
2158
|
+
why2: ' 第一處是實作,第二處開始就會各寫各的,而畫面上只剩一句 Bad Request。',
|
|
2159
|
+
howTo: ' 要裝的話:`uds update` 會顯示內容並徵求同意後寫入。',
|
|
2160
|
+
},
|
|
2137
2161
|
title: '通用文件標準 - 檢查',
|
|
2138
2162
|
// Basic status
|
|
2139
2163
|
standardsInitialized: '✓ 標準已初始化',
|
|
@@ -2449,6 +2473,18 @@ export const messages = {
|
|
|
2449
2473
|
|
|
2450
2474
|
// update command
|
|
2451
2475
|
update: {
|
|
2476
|
+
errorExitOffer: {
|
|
2477
|
+
title: ' 錯誤訊息單一出口閘門',
|
|
2478
|
+
guards: ' 防的是:每個呼叫端各自把錯誤回應拼成給人看的字串。',
|
|
2479
|
+
drift: ' 第一處是實作,第二處開始就會各寫各的,而畫面上只剩一句 Bad Request。',
|
|
2480
|
+
willWrite: ' 要寫入:scripts/check-error-exit.mjs(純 Node、零相依、{kb}KB)',
|
|
2481
|
+
exit2a: ' 寫入後它會 exit 2 直到你填好 CONFIG——那是刻意的,',
|
|
2482
|
+
exit2b: ' 一支在新 repo 裡靜靜回綠的閘門跟一支沒裝的無從分辨。',
|
|
2483
|
+
question: '要把這道閘門寫進 scripts/check-error-exit.mjs 嗎?',
|
|
2484
|
+
skipped: ' 跳過。`uds check` 之後會再提醒,但不會自己寫進去。',
|
|
2485
|
+
written: ' ✓ 已寫入 scripts/check-error-exit.mjs',
|
|
2486
|
+
next: ' 下一步:填好檔頭的 CONFIG,然後把它接進你的 CI 或 pre-commit。',
|
|
2487
|
+
},
|
|
2452
2488
|
title: '通用文件標準 - 更新',
|
|
2453
2489
|
// CLI update
|
|
2454
2490
|
cliUpdateAvailable: '⚡ 有新的 CLI 版本可用!',
|
|
@@ -3360,7 +3396,7 @@ export const messages = {
|
|
|
3360
3396
|
errorLevelRange: '错误:等级必须是 1、2 或 3',
|
|
3361
3397
|
showingLevel: '显示等级',
|
|
3362
3398
|
errorUnknownCategory: '错误:未知类别',
|
|
3363
|
-
validCategories: '有效类别:
|
|
3399
|
+
validCategories: '有效类别:',
|
|
3364
3400
|
category: '类别',
|
|
3365
3401
|
appliesTo: '适用于',
|
|
3366
3402
|
totalSummary: '项标准',
|
|
@@ -3505,6 +3541,12 @@ export const messages = {
|
|
|
3505
3541
|
|
|
3506
3542
|
// check command
|
|
3507
3543
|
check: {
|
|
3544
|
+
errorExitGate: {
|
|
3545
|
+
missing: ' ⚠ [error-exit] 没有错误信息单一出口检查(scripts/check-error-exit.mjs)。',
|
|
3546
|
+
why1: ' 这道闸门防的是「每个调用端各自把错误响应拼成给人看的字符串」——',
|
|
3547
|
+
why2: ' 第一处是实现,第二处开始就会各写各的,而界面上只剩一句 Bad Request。',
|
|
3548
|
+
howTo: ' 要装的话:`uds update` 会显示内容并征求同意后写入。',
|
|
3549
|
+
},
|
|
3508
3550
|
title: '通用文档标准 - 检查',
|
|
3509
3551
|
// Basic status
|
|
3510
3552
|
standardsInitialized: '✓ 标准已初始化',
|
|
@@ -3721,6 +3763,18 @@ export const messages = {
|
|
|
3721
3763
|
|
|
3722
3764
|
// update command
|
|
3723
3765
|
update: {
|
|
3766
|
+
errorExitOffer: {
|
|
3767
|
+
title: ' 错误信息单一出口闸门',
|
|
3768
|
+
guards: ' 防的是:每个调用端各自把错误响应拼成给人看的字符串。',
|
|
3769
|
+
drift: ' 第一处是实现,第二处开始就会各写各的,而界面上只剩一句 Bad Request。',
|
|
3770
|
+
willWrite: ' 要写入:scripts/check-error-exit.mjs(纯 Node、零依赖、{kb}KB)',
|
|
3771
|
+
exit2a: ' 写入后它会 exit 2 直到你填好 CONFIG——那是刻意的,',
|
|
3772
|
+
exit2b: ' 一支在新 repo 里静静回绿的闸门跟一支没装的无从分辨。',
|
|
3773
|
+
question: '要把这道闸门写进 scripts/check-error-exit.mjs 吗?',
|
|
3774
|
+
skipped: ' 跳过。`uds check` 之后会再提醒,但不会自己写进去。',
|
|
3775
|
+
written: ' ✓ 已写入 scripts/check-error-exit.mjs',
|
|
3776
|
+
next: ' 下一步:填好文件头的 CONFIG,然后把它接进你的 CI 或 pre-commit。',
|
|
3777
|
+
},
|
|
3724
3778
|
title: '通用文档标准 - 更新',
|
|
3725
3779
|
// CLI update
|
|
3726
3780
|
cliUpdateAvailable: '⚡ 新 CLI 版本可用!',
|
package/src/mcp/server.js
CHANGED
|
@@ -10,8 +10,21 @@ import { fileURLToPath } from 'url';
|
|
|
10
10
|
|
|
11
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Where the files UDS ships (ai/standards/, templates/) are.
|
|
15
|
+
*
|
|
16
|
+
* This file is `<cli>/src/mcp/server.js`, so `<cli>` is two levels up. A published package carries the shipped
|
|
17
|
+
* files in `<cli>/bundled/`; a repository checkout carries them one level above `<cli>`. (It used to climb four
|
|
18
|
+
* levels, which lands outside the repository and, in an installed package, outside the package: every tool that
|
|
19
|
+
* reads a shipped file failed with ENOENT, and the unit tests never saw it because they replace the file system.)
|
|
20
|
+
*
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
export function resolveUdsRepoRoot() {
|
|
24
|
+
const cliRoot = resolve(__dirname, '../..');
|
|
25
|
+
const bundled = join(cliRoot, 'bundled');
|
|
26
|
+
return existsSync(join(bundled, 'ai')) ? bundled : resolve(cliRoot, '..');
|
|
27
|
+
}
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* Required DESIGN.md sections per frontend-design-standards.
|
|
@@ -29,9 +42,8 @@ const REQUIRED_DESIGN_SECTIONS = [
|
|
|
29
42
|
|
|
30
43
|
export class McpServer {
|
|
31
44
|
constructor(options = {}) {
|
|
32
|
-
this.udsRoot = options.udsRoot || process.cwd();
|
|
33
45
|
// For reading UDS bundled files, always use UDS_REPO_ROOT
|
|
34
|
-
this.udsRepoRoot = options.udsRepoRoot ||
|
|
46
|
+
this.udsRepoRoot = options.udsRepoRoot || resolveUdsRepoRoot();
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
/**
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { existsSync, rmSync } from 'fs';
|
|
1
|
+
import { existsSync, rmSync, rmdirSync, readdirSync, unlinkSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
2
3
|
import {
|
|
3
4
|
getSkillsDirForAgent,
|
|
4
|
-
getCommandsDirForAgent
|
|
5
|
-
getAgentsDirForAgent,
|
|
6
|
-
getWorkflowsDirForAgent
|
|
5
|
+
getCommandsDirForAgent
|
|
7
6
|
} from '../config/ai-agent-paths.js';
|
|
7
|
+
import { computeFileHash } from '../utils/hasher.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Uninstall skills
|
|
10
|
+
* Uninstall skills and commands
|
|
11
|
+
*
|
|
12
|
+
* Skills and commands go into folders the adopter shares with other things
|
|
13
|
+
* (`.claude/skills/` holds their own skills too; `init` says so where it writes
|
|
14
|
+
* them). So this removes only what UDS can PROVE it wrote and nobody has changed
|
|
15
|
+
* since: a record in the manifest (`skillHashes` / `commandHashes`) plus a
|
|
16
|
+
* matching content hash. The same rule `uds uninstall` already applies to hook
|
|
17
|
+
* scripts and integration files. A file with no record, or edited since, is
|
|
18
|
+
* kept and said so. A folder UDS emptied is removed; a folder that still holds
|
|
19
|
+
* something else is left alone.
|
|
20
|
+
*
|
|
21
|
+
* This used to `rmSync` the whole skills folder, which took the adopter's own
|
|
22
|
+
* skills with it.
|
|
23
|
+
*
|
|
11
24
|
* @param {string} projectPath - Project root path
|
|
12
25
|
* @param {Object} manifest - Parsed manifest object
|
|
13
26
|
* @param {Object} options - { dryRun, includeUserLevel }
|
|
@@ -26,30 +39,52 @@ export function uninstallSkills(projectPath, manifest, options = {}) {
|
|
|
26
39
|
// Process skill installations
|
|
27
40
|
const skillInstalls = manifest?.skills?.installations || [];
|
|
28
41
|
for (const install of skillInstalls) {
|
|
29
|
-
processInstallation(install, 'skills', projectPath, options, result);
|
|
42
|
+
processInstallation(install, 'skills', projectPath, manifest, options, result);
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
// Process command installations
|
|
33
46
|
const cmdInstalls = manifest?.commands?.installations || [];
|
|
34
47
|
for (const install of cmdInstalls) {
|
|
35
|
-
processInstallation(install, 'commands', projectPath, options, result);
|
|
48
|
+
processInstallation(install, 'commands', projectPath, manifest, options, result);
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
return result;
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
|
-
*
|
|
55
|
+
* The files the manifest says UDS wrote into one installation's folder.
|
|
56
|
+
* Skill records are keyed `<agent>/<level>/<skill>/<file>`; command records
|
|
57
|
+
* `<agent>/<file>` (they carry no level).
|
|
58
|
+
* @returns {Array<{ rel: string, hash: string }>} path inside the folder (forward slashes) and recorded hash
|
|
43
59
|
*/
|
|
44
|
-
function
|
|
60
|
+
function recordedFiles(manifest, type, agent, level) {
|
|
61
|
+
const table = (type === 'skills' ? manifest?.skillHashes : manifest?.commandHashes) || {};
|
|
62
|
+
const prefix = type === 'skills' ? `${agent}/${level}/` : `${agent}/`;
|
|
63
|
+
return Object.entries(table)
|
|
64
|
+
.filter(([key]) => key.startsWith(prefix))
|
|
65
|
+
.map(([key, info]) => ({ rel: key.slice(prefix.length), hash: info && info.hash }));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Remove `dir` if nothing is left in it. Returns whether it is gone. */
|
|
69
|
+
function removeIfEmpty(dir) {
|
|
70
|
+
try {
|
|
71
|
+
if (readdirSync(dir).length > 0) return false;
|
|
72
|
+
rmdirSync(dir);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Process a single skill/command installation for removal
|
|
81
|
+
*/
|
|
82
|
+
function processInstallation(install, type, projectPath, manifest, options, result) {
|
|
45
83
|
const { dryRun = false, includeUserLevel = false } = options;
|
|
46
84
|
const { agent, level } = install;
|
|
47
85
|
|
|
48
86
|
// Determine directory getter
|
|
49
|
-
const getDirFn = type === 'skills' ? getSkillsDirForAgent :
|
|
50
|
-
type === 'commands' ? getCommandsDirForAgent :
|
|
51
|
-
type === 'agents' ? getAgentsDirForAgent :
|
|
52
|
-
getWorkflowsDirForAgent;
|
|
87
|
+
const getDirFn = type === 'skills' ? getSkillsDirForAgent : getCommandsDirForAgent;
|
|
53
88
|
|
|
54
89
|
const dir = getDirFn(agent, level || 'project', projectPath);
|
|
55
90
|
if (!dir) {
|
|
@@ -71,14 +106,46 @@ function processInstallation(install, type, projectPath, options, result) {
|
|
|
71
106
|
return;
|
|
72
107
|
}
|
|
73
108
|
|
|
109
|
+
const records = recordedFiles(manifest, type, agent, level || 'project');
|
|
110
|
+
if (records.length === 0) {
|
|
111
|
+
result.skipped.push(`${label} — kept ${dir}: the manifest records no file UDS wrote there, so UDS cannot prove which are its own`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const toRemove = [];
|
|
116
|
+
const changed = [];
|
|
117
|
+
for (const { rel, hash } of records) {
|
|
118
|
+
const file = join(dir, ...rel.split('/'));
|
|
119
|
+
if (!existsSync(file)) continue;
|
|
120
|
+
const now = computeFileHash(file);
|
|
121
|
+
if (now && hash && now.hash === hash) toRemove.push(file);
|
|
122
|
+
else changed.push(rel);
|
|
123
|
+
}
|
|
124
|
+
|
|
74
125
|
if (dryRun) {
|
|
75
|
-
result.removed.push(`${label} → ${dir}`);
|
|
126
|
+
result.removed.push(`${label} → ${dir} (${toRemove.length} file(s) UDS wrote)`);
|
|
127
|
+
if (changed.length > 0) result.skipped.push(`${label} — would keep ${changed.length} file(s) changed since UDS wrote them`);
|
|
76
128
|
return;
|
|
77
129
|
}
|
|
78
130
|
|
|
79
131
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
132
|
+
const touched = new Set();
|
|
133
|
+
for (const file of toRemove) {
|
|
134
|
+
unlinkSync(file);
|
|
135
|
+
touched.add(dirname(file));
|
|
136
|
+
}
|
|
137
|
+
// UDS's own bookkeeping for the folder (written by the skills installer, never hashed): go with the last of its files.
|
|
138
|
+
if (changed.length === 0) {
|
|
139
|
+
const marker = join(dir, '.manifest.json');
|
|
140
|
+
if (existsSync(marker)) rmSync(marker, { force: true });
|
|
141
|
+
}
|
|
142
|
+
// Folders UDS emptied, deepest first, then the installation folder itself.
|
|
143
|
+
for (const d of [...touched].sort((a, b) => b.length - a.length)) {
|
|
144
|
+
if (d !== dir) removeIfEmpty(d);
|
|
145
|
+
}
|
|
146
|
+
const gone = removeIfEmpty(dir);
|
|
147
|
+
result.removed.push(`${label} → ${dir} (${toRemove.length} file(s) UDS wrote${gone ? '' : '; folder kept: it still holds files that are not UDS\'s'})`);
|
|
148
|
+
if (changed.length > 0) result.skipped.push(`${label} — kept ${changed.length} file(s) changed since UDS wrote them`);
|
|
82
149
|
} catch (error) {
|
|
83
150
|
result.errors.push(`${label} — ${error.message}`);
|
|
84
151
|
}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readdirSync, rmdirSync, unlinkSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { classifyStandardsFiles, computeFileHash } from '../utils/hasher.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Uninstall .standards/
|
|
6
|
+
* Uninstall the files UDS wrote into .standards/
|
|
7
|
+
*
|
|
8
|
+
* `.standards/` is a folder the adopter may add files to (UDS's own docs invite
|
|
9
|
+
* teams to), so this removes only what UDS can PROVE it wrote and nobody has
|
|
10
|
+
* changed since: a file the manifest records (`fileHashes`, or `provenance`)
|
|
11
|
+
* whose content still matches its recorded hash. A file with no record, or edited
|
|
12
|
+
* since, is kept and said so. The manifest goes last, and the folder only when
|
|
13
|
+
* nothing else is in it. The same rule `uds uninstall` applies to skills, hook
|
|
14
|
+
* scripts and integration files.
|
|
15
|
+
*
|
|
16
|
+
* This used to `rmSync` the whole folder, which took the adopter's own files
|
|
17
|
+
* with it.
|
|
18
|
+
*
|
|
6
19
|
* @param {string} projectPath - Project root path
|
|
7
|
-
* @param {Object} options - { dryRun: boolean }
|
|
20
|
+
* @param {Object} options - { dryRun: boolean, manifest: Object } (the manifest says which files UDS wrote)
|
|
8
21
|
* @returns {Object} { removed: string[], skipped: string[], errors: string[] }
|
|
9
22
|
*/
|
|
10
23
|
export function uninstallStandards(projectPath, options = {}) {
|
|
11
|
-
const { dryRun = false } = options;
|
|
24
|
+
const { dryRun = false, manifest = null } = options;
|
|
12
25
|
const result = { removed: [], skipped: [], errors: [] };
|
|
13
26
|
const standardsDir = join(projectPath, '.standards');
|
|
14
27
|
|
|
@@ -16,18 +29,54 @@ export function uninstallStandards(projectPath, options = {}) {
|
|
|
16
29
|
result.skipped.push('.standards/ (not found)');
|
|
17
30
|
return result;
|
|
18
31
|
}
|
|
32
|
+
if (!manifest) {
|
|
33
|
+
result.skipped.push('.standards/ — kept: there is no manifest to say which files UDS wrote');
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const census = classifyStandardsFiles(projectPath, manifest);
|
|
38
|
+
const toRemove = [];
|
|
39
|
+
const changed = [];
|
|
40
|
+
for (const rel of census.udsOwned) {
|
|
41
|
+
const record = manifest.fileHashes && manifest.fileHashes[rel];
|
|
42
|
+
const file = join(projectPath, ...rel.split('/'));
|
|
43
|
+
if (record && record.hash) {
|
|
44
|
+
const now = computeFileHash(file);
|
|
45
|
+
if (!now || now.hash !== record.hash) { changed.push(rel); continue; }
|
|
46
|
+
}
|
|
47
|
+
toRemove.push(file);
|
|
48
|
+
}
|
|
49
|
+
const notUds = [...census.foreign, ...census.unknown];
|
|
50
|
+
const kept = [...changed, ...notUds];
|
|
51
|
+
const manifestFile = join(standardsDir, 'manifest.json');
|
|
52
|
+
const count = toRemove.length + (existsSync(manifestFile) ? 1 : 0);
|
|
53
|
+
|
|
54
|
+
const describe = (wholeFolderGone) => `.standards/ (${count} file(s) UDS wrote${wholeFolderGone ? '' : '; folder kept: it still holds files that are not UDS\'s'})`;
|
|
55
|
+
const keptNote = `.standards/ — kept ${kept.length} file(s) UDS did not write or that changed since: ${kept.slice(0, 5).join(', ')}${kept.length > 5 ? ', ...' : ''}`;
|
|
19
56
|
|
|
20
57
|
if (dryRun) {
|
|
21
|
-
result.removed.push(
|
|
58
|
+
result.removed.push(describe(kept.length === 0));
|
|
59
|
+
if (kept.length > 0) result.skipped.push(keptNote);
|
|
22
60
|
return result;
|
|
23
61
|
}
|
|
24
62
|
|
|
25
63
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
64
|
+
for (const file of toRemove) unlinkSync(file);
|
|
65
|
+
if (existsSync(manifestFile)) unlinkSync(manifestFile);
|
|
66
|
+
removeEmptyFolders(standardsDir);
|
|
67
|
+
result.removed.push(describe(!existsSync(standardsDir)));
|
|
68
|
+
if (kept.length > 0) result.skipped.push(keptNote);
|
|
28
69
|
} catch (error) {
|
|
29
70
|
result.errors.push(`.standards/ — ${error.message}`);
|
|
30
71
|
}
|
|
31
72
|
|
|
32
73
|
return result;
|
|
33
74
|
}
|
|
75
|
+
|
|
76
|
+
/** Remove every folder under `dir` that is empty, deepest first, then `dir` itself if it ends up empty. */
|
|
77
|
+
function removeEmptyFolders(dir) {
|
|
78
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
79
|
+
if (entry.isDirectory()) removeEmptyFolders(join(dir, entry.name));
|
|
80
|
+
}
|
|
81
|
+
if (readdirSync(dir).length === 0) rmdirSync(dir);
|
|
82
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
11
11
|
import { dirname, join, basename } from 'path';
|
|
12
12
|
import { fileURLToPath } from 'url';
|
|
13
|
+
import * as yaml from 'js-yaml';
|
|
13
14
|
import {
|
|
14
15
|
getAgentConfig,
|
|
15
16
|
getAgentsDirForAgent,
|
|
@@ -83,28 +84,20 @@ export function getAgentContent(agentName) {
|
|
|
83
84
|
* @returns {Object} Parsed frontmatter fields
|
|
84
85
|
*/
|
|
85
86
|
export function parseAgentFrontmatter(content) {
|
|
86
|
-
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
87
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
87
88
|
if (!frontmatterMatch) {
|
|
88
89
|
return {};
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (value.startsWith('[') && value.endsWith(']')) {
|
|
100
|
-
frontmatter[key] = value.slice(1, -1).split(',').map(s => s.trim().replace(/"/g, ''));
|
|
101
|
-
} else {
|
|
102
|
-
frontmatter[key] = value.trim();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
92
|
+
// The agent files are YAML: `description: |` is a block, `expertise:` is a list. A line-by-line `key: value`
|
|
93
|
+
// reader saw the description as the single character `|` and dropped every list, so `uds agent list` and
|
|
94
|
+
// `uds agent info` showed an empty description and no expertise, tools or skills.
|
|
95
|
+
try {
|
|
96
|
+
const parsed = yaml.load(frontmatterMatch[1]);
|
|
97
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
98
|
+
} catch {
|
|
99
|
+
return {};
|
|
105
100
|
}
|
|
106
|
-
|
|
107
|
-
return frontmatter;
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Did a prompt end because nothing could answer it?
|
|
3
|
+
* // implements XSPEC-471 R4 (the interactive commands found without an acceptance step)
|
|
4
|
+
*
|
|
5
|
+
* `@inquirer/prompts` rejects with `ExitPromptError` when stdin is not a terminal and ends (CI, a pipe, a process
|
|
6
|
+
* started by another program) and when the person presses Ctrl+C. A command that does not catch it prints a Node
|
|
7
|
+
* stack trace, and the process still ends with exit code 0: a run that did nothing looks like a success.
|
|
8
|
+
* `uds update` and `uds uninstall` catch it for themselves; this is the same test for the other commands.
|
|
9
|
+
*
|
|
10
|
+
* Detect by what the prompt did, not by probing `process.stdin.isTTY`: isTTY is a proxy for "somebody can answer",
|
|
11
|
+
* and a wrapped or mocked stdin answers fine with isTTY unset.
|
|
12
|
+
*
|
|
13
|
+
* @param {unknown} err
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export function isPromptClosed(err) {
|
|
17
|
+
return err?.name === 'ExitPromptError' || /force closed the prompt/i.test(err?.message || '');
|
|
18
|
+
}
|
package/standards-registry.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"version": "6.14.0-beta.
|
|
3
|
+
"version": "6.14.0-beta.9",
|
|
4
4
|
"lastUpdated": "2026-05-13",
|
|
5
5
|
"description": "Standards registry for universal-dev-standards with integrated skills and AI-optimized formats",
|
|
6
6
|
"formats": {
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"standards": {
|
|
59
59
|
"name": "universal-dev-standards",
|
|
60
60
|
"url": "https://github.com/AsiaOstrich/universal-dev-standards",
|
|
61
|
-
"version": "6.14.0-beta.
|
|
61
|
+
"version": "6.14.0-beta.9"
|
|
62
62
|
},
|
|
63
63
|
"skills": {
|
|
64
64
|
"name": "universal-dev-standards",
|
|
65
65
|
"url": "https://github.com/AsiaOstrich/universal-dev-standards",
|
|
66
66
|
"localPath": "skills",
|
|
67
67
|
"rawUrl": "https://raw.githubusercontent.com/AsiaOstrich/universal-dev-standards/main/skills",
|
|
68
|
-
"version": "6.14.0-beta.
|
|
68
|
+
"version": "6.14.0-beta.9",
|
|
69
69
|
"note": "Skills are now included in the main repository under skills/"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
@@ -691,6 +691,31 @@
|
|
|
691
691
|
"name": "Template",
|
|
692
692
|
"description": "Document templates for specific purposes. Use as starting point for project documents.",
|
|
693
693
|
"adoptionMethod": "Copy and customize"
|
|
694
|
+
},
|
|
695
|
+
"core": {
|
|
696
|
+
"name": "Core Standard",
|
|
697
|
+
"description": "Core development standards that apply across projects: governance, agent behavior, observability, workflow discipline. Not installed by uds init.",
|
|
698
|
+
"adoptionMethod": "Install by id with uds update --apply --add-standard"
|
|
699
|
+
},
|
|
700
|
+
"testing": {
|
|
701
|
+
"name": "Testing Standard",
|
|
702
|
+
"description": "Standards for specific kinds of tests and test hygiene: contract, property-based, smoke, replay, flaky-test management and others. Not installed by uds init.",
|
|
703
|
+
"adoptionMethod": "Install by id with uds update --apply --add-standard"
|
|
704
|
+
},
|
|
705
|
+
"security": {
|
|
706
|
+
"name": "Security Standard",
|
|
707
|
+
"description": "Security standards for operations, containers, static analysis and supply-chain attestation. Not installed by uds init.",
|
|
708
|
+
"adoptionMethod": "Install by id with uds update --apply --add-standard"
|
|
709
|
+
},
|
|
710
|
+
"deployment": {
|
|
711
|
+
"name": "Deployment Standard",
|
|
712
|
+
"description": "Standards for what must be known and checked before a release goes out: quality manifest and release readiness gate. Not installed by uds init.",
|
|
713
|
+
"adoptionMethod": "Install by id with uds update --apply --add-standard"
|
|
714
|
+
},
|
|
715
|
+
"operations": {
|
|
716
|
+
"name": "Operations Standard",
|
|
717
|
+
"description": "Standards for running a system after it is released, such as disaster recovery drills. Not installed by uds init.",
|
|
718
|
+
"adoptionMethod": "Install by id with uds update --apply --add-standard"
|
|
694
719
|
}
|
|
695
720
|
},
|
|
696
721
|
"standards": [
|
|
@@ -2309,7 +2334,7 @@
|
|
|
2309
2334
|
"id": "license-compliance",
|
|
2310
2335
|
"name": "License Compliance Standards",
|
|
2311
2336
|
"nameZh": "授權合規標準",
|
|
2312
|
-
"version": "6.14.0-beta.
|
|
2337
|
+
"version": "6.14.0-beta.9",
|
|
2313
2338
|
"source": {
|
|
2314
2339
|
"human": "core/license-compliance.md",
|
|
2315
2340
|
"ai": "ai/standards/license-compliance.ai.yaml"
|
|
@@ -2321,7 +2346,7 @@
|
|
|
2321
2346
|
"id": "verification-oracle",
|
|
2322
2347
|
"name": "Verification Oracle Standards",
|
|
2323
2348
|
"nameZh": "驗證 Oracle 標準",
|
|
2324
|
-
"version": "6.14.0-beta.
|
|
2349
|
+
"version": "6.14.0-beta.9",
|
|
2325
2350
|
"source": {
|
|
2326
2351
|
"human": "core/verification-oracle.md",
|
|
2327
2352
|
"ai": "ai/standards/verification-oracle.ai.yaml"
|
|
@@ -2333,7 +2358,7 @@
|
|
|
2333
2358
|
"id": "model-provenance",
|
|
2334
2359
|
"name": "Model Provenance Policy Standards",
|
|
2335
2360
|
"nameZh": "模型來源政策標準",
|
|
2336
|
-
"version": "6.14.0-beta.
|
|
2361
|
+
"version": "6.14.0-beta.9",
|
|
2337
2362
|
"source": {
|
|
2338
2363
|
"human": "core/model-provenance.md",
|
|
2339
2364
|
"ai": "ai/standards/model-provenance.ai.yaml"
|
|
@@ -2345,7 +2370,7 @@
|
|
|
2345
2370
|
"id": "resource-cost-boundary",
|
|
2346
2371
|
"name": "Resource / Cost Boundary Declaration Standards",
|
|
2347
2372
|
"nameZh": "資源/成本邊界宣告標準",
|
|
2348
|
-
"version": "6.14.0-beta.
|
|
2373
|
+
"version": "6.14.0-beta.9",
|
|
2349
2374
|
"source": {
|
|
2350
2375
|
"human": "core/resource-cost-boundary.md",
|
|
2351
2376
|
"ai": "ai/standards/resource-cost-boundary.ai.yaml"
|