universal-dev-standards 6.14.0-beta.12 → 6.14.0-beta.13
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 +112 -13
- 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/bin/uds.js
CHANGED
|
@@ -233,7 +233,8 @@ program
|
|
|
233
233
|
.option('--apply', 'Apply exactly the plan --plan prints (plain `uds update` does not); with --skills/--commands it does the reconciliation AND that scope, not only the scope')
|
|
234
234
|
.option('--force', 'Force update all files, ignoring hash comparison')
|
|
235
235
|
.option('--prune', 'Delete .standards/ files UDS wrote but no longer ships (listed without this flag; never touches files UDS did not write)')
|
|
236
|
-
.option('--rollback', 'Rollback to the most recent backup')
|
|
236
|
+
.option('--rollback', 'Rollback to the most recent backup (with the series of updates that follow from it)')
|
|
237
|
+
.option('--from <backup>', 'With --rollback: restore this one backup instead of the most recent series (the id --rollback prints, or its folder name); use it for a backup an older UDS made')
|
|
237
238
|
.option('--add-standard <id>', 'With --plan or --apply: also install this standard UDS ships and the project lacks, and record it in the manifest (repeatable; `uds update --plan` lists what is available)', (value, previous) => [...previous, value], [])
|
|
238
239
|
.option('--claude-target <target>', 'Switch an existing install to a different Claude Code integration target: project (CLAUDE.md) or local (CLAUDE.local.md) — moves the UDS block, keeps your content, no reinstall')
|
|
239
240
|
.option('--locale <locale>', 'Override locale for skills install (zh-tw, zh-cn, en); also reads .uds/install.yaml + UDS_LOCALE env')
|
|
@@ -308,11 +309,17 @@ program
|
|
|
308
309
|
console.error(result.error);
|
|
309
310
|
process.exit(1);
|
|
310
311
|
}
|
|
312
|
+
// What was left out goes to stderr in a dry run, so stdout stays the JSON it has always been.
|
|
313
|
+
const note = result.dryRun ? console.error : console.log;
|
|
311
314
|
if (result.dryRun) {
|
|
312
315
|
console.log(JSON.stringify(result.config, null, 2));
|
|
313
316
|
} else {
|
|
314
317
|
console.log(`Compiled ${result.compiledCount} enforcement standard(s) for ${options.target}`);
|
|
315
318
|
}
|
|
319
|
+
for (const s of result.skipped || []) note(` Skipped ${s.id}: ${s.why}`);
|
|
320
|
+
if ((result.skipped || []).length > 0) {
|
|
321
|
+
note(' Install the hook scripts with \'uds update --with-hooks\' (or \'uds init --with-hooks\'), then compile again.');
|
|
322
|
+
}
|
|
316
323
|
});
|
|
317
324
|
|
|
318
325
|
program
|
|
@@ -23,30 +23,73 @@
|
|
|
23
23
|
* @see docs/specs/SPEC-HOOKS-001-core-standard-hooks.md (REQ-1)
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
27
|
+
import { join } from 'node:path';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Used only when the project has no commit-message option file: the Conventional Commits set. Same list `uds simulate
|
|
31
|
+
* -s commit-message` falls back to (FALLBACK_TYPES in cli/src/utils/commit-message-judge.js).
|
|
32
|
+
*/
|
|
33
|
+
const FALLBACK_TYPES = [
|
|
34
|
+
'feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert',
|
|
29
35
|
];
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
37
|
+
/**
|
|
38
|
+
* The commit types the project allows: those listed by the commit-message option files installed in
|
|
39
|
+
* `.standards/options/` (a file whose `meta.parent` is `commit-message`), or the fallback set when there are none.
|
|
40
|
+
*
|
|
41
|
+
* XSPEC-482 R12: this was a fixed list that lacked `security`, so `uds simulate` (which reads these same files) passed
|
|
42
|
+
* `security(auth): rotate keys` and this hook refused it. The two now read one source. The hook has no YAML parser
|
|
43
|
+
* to lean on (it runs in the adopter's project with no dependencies), so it reads the two things it needs line by line:
|
|
44
|
+
* the `parent:` of the `meta:` block and the `- type:` entries under `types:`.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} [root] - the project root; defaults to $CLAUDE_PROJECT_DIR or the working directory
|
|
47
|
+
* @returns {string[]}
|
|
48
|
+
*/
|
|
49
|
+
export function allowedTypes(root = process.env.CLAUDE_PROJECT_DIR || process.cwd()) {
|
|
50
|
+
const found = new Set();
|
|
51
|
+
const optionsDir = join(root, '.standards', 'options');
|
|
52
|
+
for (const dir of [optionsDir, join(optionsDir, 'commit-message')]) {
|
|
53
|
+
if (!existsSync(dir)) continue;
|
|
54
|
+
let names = [];
|
|
55
|
+
try { names = readdirSync(dir).filter((n) => n.endsWith('.ai.yaml')); } catch { continue; }
|
|
56
|
+
for (const name of names) {
|
|
57
|
+
let text = '';
|
|
58
|
+
try { text = readFileSync(join(dir, name), 'utf-8').replace(/\r\n/g, '\n'); } catch { continue; }
|
|
59
|
+
if (!/^\s+parent:\s*["']?commit-message["']?\s*$/m.test(text)) continue;
|
|
60
|
+
const lines = text.split('\n');
|
|
61
|
+
const start = lines.findIndex((l) => /^types:\s*$/.test(l));
|
|
62
|
+
if (start === -1) continue;
|
|
63
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
64
|
+
if (/^\S/.test(lines[i]) && !lines[i].startsWith('#')) break; // next top-level key
|
|
65
|
+
const m = /^\s*-\s+type:\s*["']?([^"'#\s][^"'#]*?)["']?\s*(?:#.*)?$/.exec(lines[i]);
|
|
66
|
+
if (m) found.add(m[1]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return found.size > 0 ? [...found] : FALLBACK_TYPES;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const escapeRe = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
34
74
|
|
|
35
75
|
/**
|
|
36
76
|
* Validate a commit message against Conventional Commits format.
|
|
37
77
|
* @param {string} msg - The commit message to validate
|
|
78
|
+
* @param {string[]} [types] - the allowed types (default: the project's, see allowedTypes)
|
|
38
79
|
* @returns {boolean} true if valid
|
|
39
80
|
*/
|
|
40
|
-
export function validateCommitMessage(msg) {
|
|
81
|
+
export function validateCommitMessage(msg, types = allowedTypes()) {
|
|
41
82
|
if (!msg || typeof msg !== 'string') return false;
|
|
42
|
-
|
|
83
|
+
// `type(scope)!: subject`: scope and the breaking-change mark are optional, as in `uds simulate`.
|
|
84
|
+
const pattern = new RegExp(`^(${types.map(escapeRe).join('|')})(\\(.+\\))?!?:\\s.+`, 'u');
|
|
85
|
+
return pattern.test(msg.trim());
|
|
43
86
|
}
|
|
44
87
|
|
|
45
88
|
// CLI mode.
|
|
46
89
|
function complain(msg) {
|
|
47
90
|
console.error(`❌ Invalid commit message format: "${msg}"`);
|
|
48
91
|
console.error(` Expected: <type>(<scope>): <subject>`);
|
|
49
|
-
console.error(` Valid types: ${
|
|
92
|
+
console.error(` Valid types: ${allowedTypes().join(', ')}`);
|
|
50
93
|
}
|
|
51
94
|
|
|
52
95
|
/**
|
|
@@ -15,7 +15,7 @@ status: current
|
|
|
15
15
|
|
|
16
16
|
> **语言**: [English](../../README.md) | [繁體中文](../zh-TW/README.md) | 简体中文
|
|
17
17
|
|
|
18
|
-
**版本**: 6.14.0-beta.
|
|
18
|
+
**版本**: 6.14.0-beta.13 (Pre-release) | **发布日期**: 2026-10-10 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
|
|
19
19
|
|
|
20
20
|
语言无关、框架无关的软件项目文档标准。通过 AI 原生工作流,确保不同技术栈之间的一致性、质量和可维护性。
|
|
21
21
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# UDS 功能参考手册
|
|
2
2
|
|
|
3
3
|
> Universal Development Standards - 完整功能文档
|
|
4
|
-
> Auto-generated | Last updated: 2026-10-
|
|
4
|
+
> Auto-generated | Last updated: 2026-10-13
|
|
5
5
|
|
|
6
6
|
**Language**: [English](../../../docs/reference/FEATURE-REFERENCE.md) | [繁體中文](../../zh-TW/docs/FEATURE-REFERENCE.md) | 简体中文
|
|
7
7
|
|
|
@@ -155,7 +155,8 @@
|
|
|
155
155
|
| `--apply` | Apply exactly the plan --plan prints (plain `uds update` does not); with --skills/--commands it does the reconciliation AND that scope, not only the scope |
|
|
156
156
|
| `--force` | Force update all files, ignoring hash comparison |
|
|
157
157
|
| `--prune` | Delete .standards/ files UDS wrote but no longer ships (listed without this flag; never touches files UDS did not write) |
|
|
158
|
-
| `--rollback` | Rollback to the most recent backup |
|
|
158
|
+
| `--rollback` | Rollback to the most recent backup (with the series of updates that follow from it) |
|
|
159
|
+
| `--from` | With --rollback: restore this one backup instead of the most recent series (the id --rollback prints, or its folder name); use it for a backup an older UDS made |
|
|
159
160
|
| `--add-standard` | With --plan or --apply: also install this standard UDS ships and the project lacks, and record it in the manifest (repeatable; `uds update --plan` lists what is available) |
|
|
160
161
|
| `--claude-target` | Switch an existing install to a different Claude Code integration target: project (CLAUDE.md) or local (CLAUDE.local.md) — moves the UDS block, keeps your content, no reinstall |
|
|
161
162
|
| `--locale` | Override locale for skills install (zh-tw, zh-cn, en); also reads .uds/install.yaml + UDS_LOCALE env |
|
|
@@ -15,7 +15,7 @@ status: current
|
|
|
15
15
|
|
|
16
16
|
> **語言**: [English](../../README.md) | 繁體中文 | [简体中文](../zh-CN/README.md)
|
|
17
17
|
|
|
18
|
-
**版本**: 6.14.0-beta.
|
|
18
|
+
**版本**: 6.14.0-beta.13 (Pre-release) | **發布日期**: 2026-10-10 | **授權**: [雙重授權](../../LICENSE) (CC BY 4.0 + MIT)
|
|
19
19
|
|
|
20
20
|
語言無關、框架無關的軟體專案文件標準。透過 AI 原生工作流,確保不同技術堆疊之間的一致性、品質和可維護性。
|
|
21
21
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# UDS 功能參考手冊
|
|
2
2
|
|
|
3
3
|
> Universal Development Standards - 完整功能文件
|
|
4
|
-
> Auto-generated | Last updated: 2026-10-
|
|
4
|
+
> Auto-generated | Last updated: 2026-10-13
|
|
5
5
|
|
|
6
6
|
**Language**: [English](../../../docs/reference/FEATURE-REFERENCE.md) | 繁體中文 | [简体中文](../../zh-CN/docs/FEATURE-REFERENCE.md)
|
|
7
7
|
|
|
@@ -155,7 +155,8 @@
|
|
|
155
155
|
| `--apply` | Apply exactly the plan --plan prints (plain `uds update` does not); with --skills/--commands it does the reconciliation AND that scope, not only the scope |
|
|
156
156
|
| `--force` | Force update all files, ignoring hash comparison |
|
|
157
157
|
| `--prune` | Delete .standards/ files UDS wrote but no longer ships (listed without this flag; never touches files UDS did not write) |
|
|
158
|
-
| `--rollback` | Rollback to the most recent backup |
|
|
158
|
+
| `--rollback` | Rollback to the most recent backup (with the series of updates that follow from it) |
|
|
159
|
+
| `--from` | With --rollback: restore this one backup instead of the most recent series (the id --rollback prints, or its folder name); use it for a backup an older UDS made |
|
|
159
160
|
| `--add-standard` | With --plan or --apply: also install this standard UDS ships and the project lacks, and record it in the manifest (repeatable; `uds update --plan` lists what is available) |
|
|
160
161
|
| `--claude-target` | Switch an existing install to a different Claude Code integration target: project (CLAUDE.md) or local (CLAUDE.local.md) — moves the UDS block, keeps your content, no reinstall |
|
|
161
162
|
| `--locale` | Override locale for skills install (zh-tw, zh-cn, en); also reads .uds/install.yaml + UDS_LOCALE env |
|
package/package.json
CHANGED
package/src/commands/audit.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import chalk from 'chalk';
|
|
15
|
-
import { checkbox, input } from '@inquirer/prompts';
|
|
15
|
+
import { checkbox, input, confirm } from '@inquirer/prompts';
|
|
16
16
|
import { createRequire } from 'node:module';
|
|
17
17
|
import { existsSync, readFileSync } from 'node:fs';
|
|
18
18
|
import { resolve as resolvePath } from 'node:path';
|
|
@@ -465,6 +465,33 @@ async function handleReport(auditResult, options, msg) {
|
|
|
465
465
|
|
|
466
466
|
const issue = formatIssueContent(filteredResult, userComments);
|
|
467
467
|
|
|
468
|
+
// XSPEC-482 R14g: what is about to be sent is shown in full, and sent only after a yes. The interactive path used to go
|
|
469
|
+
// from "your comments" straight to a public issue under the user's GitHub account, so the person never saw the text
|
|
470
|
+
// they were sending. `--yes` (CI, scripts) stays as it was, and a dry run already prints the same text.
|
|
471
|
+
if (!isDryRun && !submitAll) {
|
|
472
|
+
console.log();
|
|
473
|
+
console.log(chalk.bold(msg.reviewBeforeSend || 'This is the report that will be sent:'));
|
|
474
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
475
|
+
console.log(chalk.cyan(`Title: ${issue.title}`));
|
|
476
|
+
console.log(chalk.cyan(`Labels: ${issue.labels.join(', ')}`));
|
|
477
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
478
|
+
console.log(issue.body);
|
|
479
|
+
console.log(chalk.gray('─'.repeat(40)));
|
|
480
|
+
let send = false;
|
|
481
|
+
try {
|
|
482
|
+
send = await confirm({
|
|
483
|
+
message: msg.confirmSend || `Send this report as a public issue to ${REPO}?`, // wire:audit-report-confirms
|
|
484
|
+
default: false
|
|
485
|
+
});
|
|
486
|
+
} catch (err) {
|
|
487
|
+
if (!(err && err.name === 'ExitPromptError')) throw err;
|
|
488
|
+
}
|
|
489
|
+
if (!send) {
|
|
490
|
+
console.log(chalk.yellow(msg.notSent || 'Not sent. Nothing was submitted.'));
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
468
495
|
if (isDryRun) {
|
|
469
496
|
console.log();
|
|
470
497
|
console.log(chalk.bold(msg.dryRunNotice || 'Dry run — no issue created'));
|
package/src/commands/check.js
CHANGED
|
@@ -315,6 +315,37 @@ function displayAdoptionStatus(manifest, msg, common, repoInfo, standardsUpdate)
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
/**
|
|
319
|
+
* `uds check --json` (without --standard / --i18n): run the whole check with its text held back, then print one JSON
|
|
320
|
+
* document. Held back means console output and anything written to stdout while it runs (a spinner, a warning from a
|
|
321
|
+
* helper); what the check decides is read from the report the main body fills in. The exit code is the one the text mode
|
|
322
|
+
* would give (`--ci` and a non-compliant project: 1).
|
|
323
|
+
* @param {Object} options
|
|
324
|
+
*/
|
|
325
|
+
async function checkAsJson(options) {
|
|
326
|
+
const report = { initialized: null, compliant: null };
|
|
327
|
+
const realWrite = process.stdout.write.bind(process.stdout);
|
|
328
|
+
const quiet = () => true;
|
|
329
|
+
const saved = { log: console.log, info: console.info, warn: console.warn };
|
|
330
|
+
process.stdout.write = quiet;
|
|
331
|
+
console.log = console.info = console.warn = () => {};
|
|
332
|
+
try {
|
|
333
|
+
await checkCommand({ ...options, _report: report });
|
|
334
|
+
} finally {
|
|
335
|
+
process.stdout.write = realWrite;
|
|
336
|
+
console.log = saved.log;
|
|
337
|
+
console.info = saved.info;
|
|
338
|
+
console.warn = saved.warn;
|
|
339
|
+
}
|
|
340
|
+
const completed = report.compliant !== null;
|
|
341
|
+
console.log(JSON.stringify({
|
|
342
|
+
success: report.compliant === true,
|
|
343
|
+
initialized: report.initialized,
|
|
344
|
+
completed,
|
|
345
|
+
...report
|
|
346
|
+
}, null, 2));
|
|
347
|
+
}
|
|
348
|
+
|
|
318
349
|
/**
|
|
319
350
|
* Check command - verify adoption status
|
|
320
351
|
* @param {Object} options - Command options
|
|
@@ -376,9 +407,20 @@ export async function checkCommand(options = {}) {
|
|
|
376
407
|
return;
|
|
377
408
|
}
|
|
378
409
|
|
|
410
|
+
// XSPEC-482 R9: `--json` is documented as "Output result in JSON format" and used to be honoured only together with
|
|
411
|
+
// `--standard` / `--i18n`; on its own it printed the human text. The checks below run unchanged with their text held
|
|
412
|
+
// back, and what they found is printed as one JSON document.
|
|
413
|
+
if (options.json && !options._report) {
|
|
414
|
+
await checkAsJson(options); // wire:check-json-prints-json
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
|
|
379
418
|
// Phase 0: Initialization
|
|
380
419
|
const context = initializeCheckContext(projectPath);
|
|
381
|
-
if (!context)
|
|
420
|
+
if (!context) {
|
|
421
|
+
if (options._report) options._report.initialized = false;
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
382
424
|
|
|
383
425
|
const { manifest, msg, common, repoInfo } = context;
|
|
384
426
|
|
|
@@ -389,7 +431,10 @@ export async function checkCommand(options = {}) {
|
|
|
389
431
|
// XSPEC-342 R1:先問 npm 最新,判斷「已裝標準」是否落後(離線則跳過,不誤用 CLI bundled 版本)。
|
|
390
432
|
// fetchLatestVersion 有 60s 模組級快取,故此處與下方 checkCliVersion 共兩次呼叫只打一次網路。
|
|
391
433
|
let standardsUpdate = null;
|
|
392
|
-
|
|
434
|
+
// XSPEC-482 R14e: UDS_NO_UPDATE_CHECK=1 is the documented switch for "do not ask the npm registry"; `check` asked
|
|
435
|
+
// anyway (and wrote ~/.uds/update-check.json) unless --offline was also given. The variable now counts as --offline here.
|
|
436
|
+
const offline = options.offline || process.env.UDS_NO_UPDATE_CHECK === '1'; // wire:check-honours-no-update-check
|
|
437
|
+
if (!offline) {
|
|
393
438
|
standardsUpdate = await checkForUpdates(manifest.upstream.version, {
|
|
394
439
|
checkBeta: manifest.upstream.version.includes('-')
|
|
395
440
|
});
|
|
@@ -399,7 +444,7 @@ export async function checkCommand(options = {}) {
|
|
|
399
444
|
displayAdoptionStatus(manifest, msg, common, repoInfo, standardsUpdate);
|
|
400
445
|
|
|
401
446
|
// Check for CLI updates from npm registry (unless --offline)
|
|
402
|
-
if (!
|
|
447
|
+
if (!offline) {
|
|
403
448
|
await checkCliVersion(repoInfo.standards.version);
|
|
404
449
|
}
|
|
405
450
|
|
|
@@ -592,6 +637,30 @@ export async function checkCommand(options = {}) {
|
|
|
592
637
|
integrationBlockStatus.missing.length === 0 &&
|
|
593
638
|
integrationBlockStatus.noMarkers.length === 0 &&
|
|
594
639
|
integrationBlockStatus.ambiguous.length === 0;
|
|
640
|
+
if (options._report) {
|
|
641
|
+
Object.assign(options._report, {
|
|
642
|
+
initialized: true,
|
|
643
|
+
compliant: allGood,
|
|
644
|
+
version: manifest.upstream?.version ?? null,
|
|
645
|
+
installed: manifest.upstream?.installed ?? null,
|
|
646
|
+
files: {
|
|
647
|
+
unchanged: fileStatus.unchanged.length,
|
|
648
|
+
modified: fileStatus.modified,
|
|
649
|
+
missing: fileStatus.missing,
|
|
650
|
+
retired: fileStatus.retired || []
|
|
651
|
+
},
|
|
652
|
+
skillIssues: skillIssues.length,
|
|
653
|
+
commandIssues: commandIssues.length,
|
|
654
|
+
integrationBlocks: {
|
|
655
|
+
modified: integrationBlockStatus.modified,
|
|
656
|
+
missing: integrationBlockStatus.missing,
|
|
657
|
+
noMarkers: integrationBlockStatus.noMarkers,
|
|
658
|
+
ambiguous: integrationBlockStatus.ambiguous
|
|
659
|
+
},
|
|
660
|
+
testChangeBlocked: !!testChange.blocked,
|
|
661
|
+
testGatesBlocked: !!testGates.blocked
|
|
662
|
+
});
|
|
663
|
+
}
|
|
595
664
|
if (allGood) {
|
|
596
665
|
console.log(chalk.green(msg.projectCompliant));
|
|
597
666
|
} else {
|
package/src/commands/compile.js
CHANGED
|
@@ -12,6 +12,7 @@ import { existsSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from
|
|
|
12
12
|
import { join } from 'path';
|
|
13
13
|
import { load } from 'js-yaml';
|
|
14
14
|
import { ClaudeCodeCompiler } from '../compilers/claude-code-compiler.js';
|
|
15
|
+
import { mergeHookArray, normalizeMatcher } from '../installers/hooks-installer.js';
|
|
15
16
|
|
|
16
17
|
const COMPILERS = {
|
|
17
18
|
'claude-code': ClaudeCodeCompiler,
|
|
@@ -37,6 +38,17 @@ function parseStandard(filePath) {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* An entry an earlier `uds compile` wrote with an object matcher (`{ "tool": "Bash" }`) is brought to the string form.
|
|
43
|
+
* Only entries that run a UDS hook script (`node scripts/hooks/...`) are touched; any other entry is returned as it is.
|
|
44
|
+
*/
|
|
45
|
+
function repairUdsMatcher(entry) {
|
|
46
|
+
const command = entry && entry.hooks && entry.hooks[0] && entry.hooks[0].command;
|
|
47
|
+
if (typeof command !== 'string' || !command.startsWith('node scripts/hooks/')) return entry;
|
|
48
|
+
if (typeof entry.matcher === 'string' || entry.matcher === undefined) return entry;
|
|
49
|
+
return { ...entry, matcher: normalizeMatcher(entry.matcher) };
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
/**
|
|
41
53
|
* Compile enforcement standards into target-specific hook configurations.
|
|
42
54
|
*
|
|
@@ -72,10 +84,22 @@ export function compileStandards(projectPath, options = {}) {
|
|
|
72
84
|
.map((f) => parseStandard(join(standardsDir, f)))
|
|
73
85
|
.filter(Boolean);
|
|
74
86
|
|
|
87
|
+
// Only a standard whose hook script is really in the project is compiled. A settings.json entry for a script that
|
|
88
|
+
// is not there makes the tool fail on every call of that event (XSPEC-482 R4c); `uds init --with-hooks` /
|
|
89
|
+
// `uds update --with-hooks` skip such a standard and say so, and so does this.
|
|
90
|
+
const skipped = [];
|
|
91
|
+
const present = standards.filter((s) => {
|
|
92
|
+
if (s.enforcement == null) return true;
|
|
93
|
+
const script = s.enforcement.hook_script;
|
|
94
|
+
if (typeof script === 'string' && script && existsSync(join(projectPath, script))) return true; // wire:compile-skips-missing-script
|
|
95
|
+
skipped.push({ id: s.id || s._file, why: `hook script not found: ${script ?? '(none declared)'}` });
|
|
96
|
+
return false;
|
|
97
|
+
});
|
|
98
|
+
|
|
75
99
|
// Compile
|
|
76
100
|
const compiler = new CompilerClass();
|
|
77
|
-
const config = compiler.compile(
|
|
78
|
-
const compiledCount = compiler.filterEnforceable(
|
|
101
|
+
const config = compiler.compile(present);
|
|
102
|
+
const compiledCount = compiler.filterEnforceable(present).length;
|
|
79
103
|
|
|
80
104
|
// Write output (unless dry-run)
|
|
81
105
|
if (!options.dryRun && compiledCount > 0) {
|
|
@@ -96,8 +120,16 @@ export function compileStandards(projectPath, options = {}) {
|
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
|
|
99
|
-
// Merge hooks
|
|
100
|
-
|
|
123
|
+
// Merge hooks the way `uds update --with-hooks` does (XSPEC-482 R4a): the project's own entries, on the same event
|
|
124
|
+
// or not, stay exactly as they are, and an entry UDS already wrote is not written twice. This used to replace the
|
|
125
|
+
// whole array of every event the standards touched, which deleted a user's own hook on that event.
|
|
126
|
+
settings.hooks = settings.hooks || {};
|
|
127
|
+
for (const [event, entries] of Object.entries(settings.hooks)) {
|
|
128
|
+
settings.hooks[event] = (entries || []).map(repairUdsMatcher);
|
|
129
|
+
}
|
|
130
|
+
for (const [event, incoming] of Object.entries(config.hooks)) {
|
|
131
|
+
settings.hooks[event] = mergeHookArray(settings.hooks[event] || [], incoming); // wire:compile-merges-hooks
|
|
132
|
+
}
|
|
101
133
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
|
102
134
|
}
|
|
103
135
|
|
|
@@ -105,6 +137,7 @@ export function compileStandards(projectPath, options = {}) {
|
|
|
105
137
|
success: true,
|
|
106
138
|
config,
|
|
107
139
|
compiledCount,
|
|
140
|
+
skipped,
|
|
108
141
|
dryRun: !!options.dryRun,
|
|
109
142
|
};
|
|
110
143
|
}
|
package/src/commands/config.js
CHANGED
|
@@ -1053,6 +1053,34 @@ export async function runProjectConfiguration(options) {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
|
+
// Release-config.yaml first, manifest second (XSPEC-482 R1). The order matters: when the file cannot be
|
|
1057
|
+
// written, the manifest must not already say "manual" with no release-config.yaml beside it (the half state
|
|
1058
|
+
// beta.12 left). So a failure here stops before the manifest is touched.
|
|
1059
|
+
try {
|
|
1060
|
+
if (newOptions.release_mode && newOptions.release_mode !== 'ci-cd') {
|
|
1061
|
+
const { generateReleaseConfig } = await import('../utils/release-config.js');
|
|
1062
|
+
const yaml = await import('js-yaml'); // js-yaml 5 has no default export (XSPEC-482 R1) // wire:config-release-config-yaml
|
|
1063
|
+
const releaseConfigData = generateReleaseConfig(newOptions.release_mode);
|
|
1064
|
+
const releaseConfigPath = join(projectPath, '.standards', 'release-config.yaml');
|
|
1065
|
+
mkdirSync(join(projectPath, '.standards'), { recursive: true });
|
|
1066
|
+
writeFileSync(releaseConfigPath, yaml.dump(releaseConfigData), 'utf-8');
|
|
1067
|
+
} else if (newOptions.release_mode === 'ci-cd') {
|
|
1068
|
+
const releaseConfigPath = join(projectPath, '.standards', 'release-config.yaml');
|
|
1069
|
+
try {
|
|
1070
|
+
if (existsSync(releaseConfigPath)) {
|
|
1071
|
+
unlinkSync(releaseConfigPath);
|
|
1072
|
+
}
|
|
1073
|
+
} catch {
|
|
1074
|
+
// Ignore deletion errors — file may already be removed
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
} catch (error) {
|
|
1078
|
+
spinner.fail(msgObj.updatingConfig);
|
|
1079
|
+
console.error(chalk.red(`release-config.yaml: ${error.message}`));
|
|
1080
|
+
console.error(chalk.yellow(t('config.releaseConfigWriteFailed', 'The configuration was not changed (manifest left as it was).')));
|
|
1081
|
+
process.exit(1);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1056
1084
|
// Update manifest
|
|
1057
1085
|
manifest.format = newFormat;
|
|
1058
1086
|
manifest.options = newOptions;
|
|
@@ -1078,25 +1106,6 @@ export async function runProjectConfiguration(options) {
|
|
|
1078
1106
|
|
|
1079
1107
|
writeManifest(manifest, projectPath);
|
|
1080
1108
|
|
|
1081
|
-
// Generate or remove release-config.yaml based on release mode
|
|
1082
|
-
if (newOptions.release_mode && newOptions.release_mode !== 'ci-cd') {
|
|
1083
|
-
const { generateReleaseConfig } = await import('../utils/release-config.js');
|
|
1084
|
-
const yaml = (await import('js-yaml')).default;
|
|
1085
|
-
const releaseConfigData = generateReleaseConfig(newOptions.release_mode);
|
|
1086
|
-
const releaseConfigPath = join(projectPath, '.standards', 'release-config.yaml');
|
|
1087
|
-
mkdirSync(join(projectPath, '.standards'), { recursive: true });
|
|
1088
|
-
writeFileSync(releaseConfigPath, yaml.dump(releaseConfigData), 'utf-8');
|
|
1089
|
-
} else if (newOptions.release_mode === 'ci-cd') {
|
|
1090
|
-
const releaseConfigPath = join(projectPath, '.standards', 'release-config.yaml');
|
|
1091
|
-
try {
|
|
1092
|
-
if (existsSync(releaseConfigPath)) {
|
|
1093
|
-
unlinkSync(releaseConfigPath);
|
|
1094
|
-
}
|
|
1095
|
-
} catch {
|
|
1096
|
-
// Ignore deletion errors — file may already be removed
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
1109
|
spinner.succeed(msgObj.configUpdated);
|
|
1101
1110
|
|
|
1102
1111
|
// Summary
|