universal-dev-standards 6.14.0-beta.5 → 6.14.0-beta.7
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/README.md +13 -3
- package/bin/uds.js +32 -7
- package/bundled/ai/options/code-review/pr-review.ai.yaml +20 -1
- package/bundled/ai/standards/code-review.ai.yaml +15 -2
- package/bundled/ai/standards/commit-message.ai.yaml +6 -2
- package/bundled/ai/standards/developer-memory.ai.yaml +12 -2
- package/bundled/ai/standards/full-coverage-testing.ai.yaml +44 -6
- package/bundled/ai/standards/open-work-tracking.ai.yaml +191 -11
- package/bundled/ai/standards/pipeline-security-gates.ai.yaml +48 -3
- package/bundled/ai/standards/project-context-memory.ai.yaml +12 -2
- package/bundled/core/code-review-checklist.md +20 -2
- package/bundled/core/developer-memory.md +12 -2
- package/bundled/core/full-coverage-testing.md +44 -4
- package/bundled/core/open-work-tracking.md +156 -16
- package/bundled/core/pipeline-security-gates.md +63 -0
- package/bundled/core/project-context-memory.md +10 -2
- package/bundled/locales/zh-CN/CHANGELOG.md +75 -3
- package/bundled/locales/zh-CN/README.md +1 -1
- package/bundled/locales/zh-CN/SECURITY.md +1 -1
- package/bundled/locales/zh-CN/adoption/ADOPTION-GUIDE.md +13 -4
- package/bundled/locales/zh-CN/adoption/STATIC-DYNAMIC-GUIDE.md +7 -1
- package/bundled/locales/zh-CN/adoption/checklists/enterprise.md +7 -1
- package/bundled/locales/zh-CN/adoption/checklists/minimal.md +13 -3
- package/bundled/locales/zh-CN/adoption/checklists/recommended.md +7 -1
- package/bundled/locales/zh-CN/core/code-review-checklist.md +17 -0
- package/bundled/locales/zh-CN/core/developer-memory.md +9 -0
- package/bundled/locales/zh-CN/core/full-coverage-testing.md +48 -8
- package/bundled/locales/zh-CN/core/pipeline-security-gates.md +64 -4
- package/bundled/locales/zh-CN/core/project-context-memory.md +5 -0
- package/bundled/locales/zh-CN/docs/AVAILABLE-STANDARDS.md +70 -0
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +5 -4
- package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +25 -23
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +15 -12
- package/bundled/locales/zh-CN/docs/USAGE-MODES-COMPARISON.md +6 -6
- package/bundled/locales/zh-CN/docs/WINDOWS-GUIDE.md +7 -1
- package/bundled/locales/zh-CN/docs/user/GETTING-STARTED.md +44 -0
- package/bundled/locales/zh-CN/options/code-review/pr-review.md +13 -2
- package/bundled/locales/zh-TW/CHANGELOG.md +75 -3
- package/bundled/locales/zh-TW/README.md +1 -1
- package/bundled/locales/zh-TW/SECURITY.md +1 -1
- package/bundled/locales/zh-TW/adoption/ADOPTION-GUIDE.md +13 -4
- package/bundled/locales/zh-TW/adoption/STATIC-DYNAMIC-GUIDE.md +7 -1
- package/bundled/locales/zh-TW/adoption/checklists/enterprise.md +7 -1
- package/bundled/locales/zh-TW/adoption/checklists/minimal.md +13 -3
- package/bundled/locales/zh-TW/adoption/checklists/recommended.md +7 -1
- package/bundled/locales/zh-TW/core/code-review-checklist.md +17 -0
- package/bundled/locales/zh-TW/core/developer-memory.md +9 -0
- package/bundled/locales/zh-TW/core/full-coverage-testing.md +48 -8
- package/bundled/locales/zh-TW/core/open-work-tracking.md +90 -14
- package/bundled/locales/zh-TW/core/pipeline-security-gates.md +64 -4
- package/bundled/locales/zh-TW/core/project-context-memory.md +5 -0
- package/bundled/locales/zh-TW/docs/AVAILABLE-STANDARDS.md +70 -0
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +5 -4
- package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +25 -23
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +15 -12
- package/bundled/locales/zh-TW/docs/USAGE-MODES-COMPARISON.md +6 -6
- package/bundled/locales/zh-TW/docs/WINDOWS-GUIDE.md +7 -1
- package/bundled/locales/zh-TW/docs/user/GETTING-STARTED.md +44 -0
- package/bundled/locales/zh-TW/options/code-review/pr-review.md +13 -2
- package/bundled/skills/SKILL_NAMING.md +9 -0
- package/bundled/templates/gates/check-anti-fake-tests.mjs +305 -5
- package/package.json +3 -1
- package/src/commands/audit.js +9 -2
- package/src/commands/check.js +17 -0
- package/src/commands/deps.js +31 -1
- package/src/commands/init.js +41 -21
- package/src/commands/open-work.js +65 -6
- package/src/commands/simulate.js +20 -8
- package/src/commands/skills.js +59 -33
- package/src/commands/spec.js +14 -8
- package/src/commands/update.js +106 -66
- package/src/core/manifest.js +12 -10
- package/src/core/marketplace-sentinel.js +5 -0
- package/src/core/open-work-config.js +103 -0
- package/src/core/project-config.js +58 -38
- package/src/flows/init-flow.js +10 -0
- package/src/i18n/messages.js +264 -60
- package/src/installers/skills-installer.js +3 -1
- package/src/prompts/init.js +148 -13
- package/src/reconciler/backup-locations.js +75 -0
- package/src/reconciler/backup-manager.js +29 -45
- package/src/reconciler/index.js +62 -8
- package/src/utils/available-standards-report.js +144 -0
- package/src/utils/available-standards.js +216 -0
- package/src/utils/commit-message-judge.js +137 -0
- package/src/utils/copier.js +5 -4
- package/src/utils/deps-applicability.js +25 -0
- package/src/utils/friction-detector.js +27 -0
- package/src/utils/installed-names-ownership.js +114 -0
- package/src/utils/open-work-tracking.mjs +919 -48
- package/src/utils/sdd-header.js +65 -0
- package/src/utils/skill-frontmatter.js +102 -0
- package/src/utils/skill-name-collision.js +169 -0
- package/src/utils/skills-install-paths.js +114 -0
- package/src/utils/skills-installer.js +63 -105
- package/src/utils/standard-validator.js +98 -27
- package/src/utils/transient-fs.js +113 -0
- package/src/vibe/micro-spec.js +15 -0
- package/standards-registry.json +9 -9
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Printing for the "available upstream, not installed" findings (XSPEC-458 R2, R3, R5).
|
|
3
|
+
*
|
|
4
|
+
* Everything here reads `getAvailableStandards()` and prints; none of it changes a plan, a verdict,
|
|
5
|
+
* an exit code or a score. (The one exception is `resolveAddStandardRequest`, which sets a non-zero
|
|
6
|
+
* exit code for a bad `--add-standard` id — that is its whole job.)
|
|
7
|
+
*
|
|
8
|
+
* @module utils/available-standards-report
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { t } from '../i18n/messages.js';
|
|
13
|
+
import { getAvailableStandards, judgeAddStandard } from './available-standards.js';
|
|
14
|
+
|
|
15
|
+
const CATEGORY_ORDER = ['reference', 'skill'];
|
|
16
|
+
|
|
17
|
+
function fill(template, values) {
|
|
18
|
+
return Object.entries(values).reduce((text, [key, value]) => text.replaceAll(`{${key}}`, String(value)), template);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function breakdown(byCategory) {
|
|
22
|
+
return Object.entries(byCategory)
|
|
23
|
+
.sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
|
|
24
|
+
.map(([category, count]) => `${category} ${count}`)
|
|
25
|
+
.join(', ');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* `uds update --plan` / `--apply`: the section itself, or (apply) its count and the commands.
|
|
30
|
+
* Always printed — "none" is said out loud, because silence reads as "this step did not run".
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} manifest - The manifest the plan was computed from (a standard chosen with
|
|
33
|
+
* --add-standard is already in it, so it is not listed as still available)
|
|
34
|
+
* @param {{phase: 'plan'|'apply'}} opts
|
|
35
|
+
*/
|
|
36
|
+
export function printAvailableStandardsSection(manifest, { phase }) {
|
|
37
|
+
const msg = t().availableStandards;
|
|
38
|
+
const { offered, notOffered, notOfferedByCategory } = getAvailableStandards(manifest);
|
|
39
|
+
|
|
40
|
+
console.log();
|
|
41
|
+
if (offered.length === 0) {
|
|
42
|
+
console.log(chalk.gray(msg.none));
|
|
43
|
+
} else if (phase === 'apply') {
|
|
44
|
+
console.log(chalk.cyan(fill(msg.applySummary, { count: offered.length })));
|
|
45
|
+
console.log(chalk.gray(` ${msg.applyHint}`));
|
|
46
|
+
} else {
|
|
47
|
+
console.log(chalk.cyan(fill(msg.title, { count: offered.length })));
|
|
48
|
+
const categories = [...new Set([...CATEGORY_ORDER, ...offered.map(s => s.category)])];
|
|
49
|
+
for (const category of categories) {
|
|
50
|
+
const group = offered.filter(s => s.category === category);
|
|
51
|
+
if (group.length === 0) continue;
|
|
52
|
+
console.log(chalk.bold(` ${fill(msg.categoryLine, { category, count: group.length })}`));
|
|
53
|
+
for (const std of group) {
|
|
54
|
+
console.log(` ${chalk.green(std.id)} ${chalk.gray(`— ${std.description}`)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
console.log(chalk.gray(` ${msg.installHint}`));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (notOffered.length > 0) {
|
|
61
|
+
console.log(chalk.gray(fill(msg.othersLine, { count: notOffered.length, breakdown: breakdown(notOfferedByCategory) })));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `uds check`: one line, never part of the verdict. */
|
|
66
|
+
export function printAvailableStandardsCheckLine(manifest) {
|
|
67
|
+
const msg = t().availableStandards;
|
|
68
|
+
const { offered } = getAvailableStandards(manifest);
|
|
69
|
+
if (offered.length === 0) {
|
|
70
|
+
console.log(chalk.gray(msg.checkNone));
|
|
71
|
+
} else {
|
|
72
|
+
console.log(chalk.cyan(fill(msg.checkLine, { count: offered.length })));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* `--add-standard` belongs to the reconciliation (`--plan` / `--apply`). Any other mode would take the
|
|
78
|
+
* flag and quietly not use it, so those combinations are refused, in words.
|
|
79
|
+
*
|
|
80
|
+
* @param {Object} options - Parsed `uds update` options
|
|
81
|
+
* @returns {string|null} The message to print, or null when the flags are compatible
|
|
82
|
+
*/
|
|
83
|
+
export function findAddStandardConflict(options) {
|
|
84
|
+
const msg = t().availableStandards;
|
|
85
|
+
if (!options.plan && !options.apply && !options.force) return msg.addNeedsMode;
|
|
86
|
+
const clashes = [
|
|
87
|
+
['rollback', '--rollback'], ['claudeTarget', '--claude-target'], ['withHooks', '--with-hooks'],
|
|
88
|
+
['syncRefs', '--sync-refs'], ['integrationsOnly', '--integrations-only']
|
|
89
|
+
];
|
|
90
|
+
for (const [key, flag] of clashes) {
|
|
91
|
+
if (options[key]) return fill(msg.addCannotCombine, { flag });
|
|
92
|
+
}
|
|
93
|
+
if (options.plan && options.skills) return fill(msg.addCannotCombine, { flag: '--plan --skills' });
|
|
94
|
+
if (options.plan && options.commands) return fill(msg.addCannotCombine, { flag: '--plan --commands' });
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Judge every `--add-standard <id>`, say what is wrong with the ones that are, and return what is
|
|
100
|
+
* left to install. A bad id is never ignored: it prints the problem, sets a non-zero exit code and
|
|
101
|
+
* stops the run (`proceed: false`) before anything is planned or written.
|
|
102
|
+
*
|
|
103
|
+
* @param {Object} manifest
|
|
104
|
+
* @param {string[]} ids
|
|
105
|
+
* @returns {{proceed: boolean, ids: string[], alreadyInstalled: string[]}}
|
|
106
|
+
*/
|
|
107
|
+
export function resolveAddStandardRequest(manifest, ids) {
|
|
108
|
+
const msg = t().availableStandards;
|
|
109
|
+
const toAdd = [];
|
|
110
|
+
const alreadyInstalled = [];
|
|
111
|
+
let failed = false;
|
|
112
|
+
|
|
113
|
+
for (const id of [...new Set(ids)]) {
|
|
114
|
+
const judged = judgeAddStandard(id, manifest);
|
|
115
|
+
switch (judged.status) {
|
|
116
|
+
case 'add':
|
|
117
|
+
toAdd.push(id);
|
|
118
|
+
break;
|
|
119
|
+
case 'installed':
|
|
120
|
+
alreadyInstalled.push(id);
|
|
121
|
+
console.log(chalk.gray(fill(msg.addAlreadyInstalled, { id })));
|
|
122
|
+
break;
|
|
123
|
+
case 'unknown':
|
|
124
|
+
failed = true;
|
|
125
|
+
console.log(chalk.red(fill(msg.addUnknown, { id })));
|
|
126
|
+
for (const near of judged.closest) console.log(chalk.gray(` ${near}`));
|
|
127
|
+
break;
|
|
128
|
+
case 'other-means':
|
|
129
|
+
failed = true;
|
|
130
|
+
console.log(chalk.red(fill(msg.addOtherMeans, { id, category: judged.entry.category })));
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
failed = true;
|
|
134
|
+
console.log(chalk.red(fill(msg.addNoSource, { id, format: manifest.format || 'ai' })));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (failed) {
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
console.log();
|
|
141
|
+
return { proceed: false, ids: [], alreadyInstalled };
|
|
142
|
+
}
|
|
143
|
+
return { proceed: true, ids: toAdd, alreadyInstalled };
|
|
144
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Available-but-not-installed standards (XSPEC-458 R1).
|
|
3
|
+
*
|
|
4
|
+
* ONE definition, used by three commands. `uds update` (the old path's "new standards" list,
|
|
5
|
+
* `--plan`/`--apply`'s "available upstream" section, `--add-standard`), `uds check`'s one-line
|
|
6
|
+
* count and `uds audit --friction` all ask this module and nothing else. Before this existed the
|
|
7
|
+
* old path had its own copy inside update.js and the reconciler path had none: `--apply` printed
|
|
8
|
+
* a green "everything is up to date" for a project that was missing a standard UDS ships.
|
|
9
|
+
*
|
|
10
|
+
* What counts as "available but not installed"
|
|
11
|
+
* --------------------------------------------
|
|
12
|
+
* A registry standard that
|
|
13
|
+
* 1. is in a category `uds init` installs (reference, skill — see OFFERED_CATEGORIES),
|
|
14
|
+
* 2. has a source file in the project's `manifest.format` (a skill-only entry has none), and
|
|
15
|
+
* 3. is not already in `manifest.standards` (matched by file name, so an ID-format entry
|
|
16
|
+
* and a path-format entry such as `ai/standards/x.ai.yaml` both count as installed).
|
|
17
|
+
* That is exactly the set the old `checkNewStandards()` computed; it now calls this.
|
|
18
|
+
*
|
|
19
|
+
* What does NOT count, and is reported instead of being dropped (`notOffered`)
|
|
20
|
+
* ----------------------------------------------------------------------------
|
|
21
|
+
* Every other registry category (core, testing, security, deployment, operations, extension,
|
|
22
|
+
* integration, template). `uds init` has never installed them, so for a project they are not
|
|
23
|
+
* "new upstream" — they were never in the offer. Why, per category, is in CATEGORY_NOTES.
|
|
24
|
+
* They are still returned (with a reason) so no command can silently pretend they do not exist.
|
|
25
|
+
*
|
|
26
|
+
* Manifest fields that look like they should matter, and do not (measured 2026-10-07):
|
|
27
|
+
* - `level` — a manifest written by 6.11.0 carries it only as a leftover snapshot inside
|
|
28
|
+
* `integrationConfigs[<file>].level`; no code reads it to decide what to install, the generator
|
|
29
|
+
* never reads `config.level`, and the registry's level system is a deprecated stub (registry.js).
|
|
30
|
+
* DEAD.
|
|
31
|
+
* - `profile` — appears nowhere in the CLI or in any manifest. DEAD (it does not exist).
|
|
32
|
+
* - `contentMode` — LIVE, but only for how the integration file (CLAUDE.md) is rendered
|
|
33
|
+
* (minimal vs index). It never decides which standards are installed.
|
|
34
|
+
* None of the three enters this computation, on purpose.
|
|
35
|
+
*
|
|
36
|
+
* @module utils/available-standards
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
import { basename } from 'path';
|
|
40
|
+
import { getAllStandards, getStandardSource } from './registry.js';
|
|
41
|
+
|
|
42
|
+
/** Categories `uds init` installs into `.standards/`. Must match installers/standards-installer.js. */
|
|
43
|
+
export const OFFERED_CATEGORIES = Object.freeze(['reference', 'skill']);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Categories whose registry entry is not a plain standard file under `.standards/`: they are
|
|
47
|
+
* installed by other means (a language/locale option, a per-tool integration file, a template
|
|
48
|
+
* copy), so `--add-standard` does not install them.
|
|
49
|
+
*/
|
|
50
|
+
export const INSTALLED_BY_OTHER_MEANS = Object.freeze(['extension', 'integration', 'template']);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Why each category outside OFFERED_CATEGORIES is not offered. Written down so the exclusion is a
|
|
54
|
+
* visible decision, not a filter nobody can explain. (Rendered in docs/user/CLI-REFERENCE and the
|
|
55
|
+
* R1 section of the update guide; keep in step with them.)
|
|
56
|
+
*/
|
|
57
|
+
export const CATEGORY_NOTES = Object.freeze({
|
|
58
|
+
core: 'added to the registry after the installer\'s reference/skill filter was written; never installed by init',
|
|
59
|
+
testing: 'same as core: added later, never installed by init',
|
|
60
|
+
security: 'same as core: added later, never installed by init',
|
|
61
|
+
deployment: 'same as core: added later, never installed by init',
|
|
62
|
+
operations: 'same as core: added later, never installed by init',
|
|
63
|
+
extension: 'installed by a language/framework/locale choice at init, not as a standard',
|
|
64
|
+
integration: 'a per-tool integration file, installed through the AI-tool choice at init',
|
|
65
|
+
template: 'a document template to copy, not a standard file'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* File names (basenames) of the standards a manifest already lists.
|
|
70
|
+
* Handles both legacy path entries ("ai/standards/foo.ai.yaml") and ID entries ("foo").
|
|
71
|
+
* Option paths are skipped: they live under `.standards/options/` and are not standards.
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} manifest
|
|
74
|
+
* @param {Array} [registryStandards]
|
|
75
|
+
* @returns {Set<string>}
|
|
76
|
+
*/
|
|
77
|
+
export function installedStandardFileNames(manifest, registryStandards = getAllStandards()) {
|
|
78
|
+
const format = manifest.format || 'ai';
|
|
79
|
+
const names = new Set();
|
|
80
|
+
for (const s of (manifest.standards || [])) {
|
|
81
|
+
if (typeof s !== 'string') continue;
|
|
82
|
+
if (s.includes('/options/') || s.startsWith('options/')) continue;
|
|
83
|
+
if (!s.includes('/') && !s.includes('.')) {
|
|
84
|
+
const entry = registryStandards.find(r => r.id === s);
|
|
85
|
+
if (entry) {
|
|
86
|
+
const sourcePath = getStandardSource(entry, format);
|
|
87
|
+
if (sourcePath) names.add(basename(sourcePath));
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
names.add(basename(s));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return names;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* One line of description: the first sentence, cut to `max` characters.
|
|
98
|
+
* @param {string} description
|
|
99
|
+
* @param {number} [max]
|
|
100
|
+
* @returns {string}
|
|
101
|
+
*/
|
|
102
|
+
export function oneLineDescription(description, max = 100) {
|
|
103
|
+
const text = String(description || '').replace(/\s+/g, ' ').trim();
|
|
104
|
+
const firstSentence = text.split(/(?<=[.。])\s/)[0] || text;
|
|
105
|
+
const cut = firstSentence.length > max ? `${firstSentence.slice(0, max - 1).trimEnd()}…` : firstSentence;
|
|
106
|
+
return cut;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @typedef {Object} AvailableStandard
|
|
111
|
+
* @property {string} id
|
|
112
|
+
* @property {string} category
|
|
113
|
+
* @property {string} description One line.
|
|
114
|
+
* @property {string} source Registry source path in the project's format (what the manifest records).
|
|
115
|
+
* @property {string} name File name under `.standards/`.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The single definition of "available but not installed".
|
|
120
|
+
*
|
|
121
|
+
* @param {Object} manifest
|
|
122
|
+
* @returns {{
|
|
123
|
+
* offered: AvailableStandard[],
|
|
124
|
+
* notOffered: Array<AvailableStandard & {reason: string, addable: boolean}>,
|
|
125
|
+
* notOfferedByCategory: Object<string, number>
|
|
126
|
+
* }}
|
|
127
|
+
*/
|
|
128
|
+
export function getAvailableStandards(manifest) {
|
|
129
|
+
const format = manifest.format || 'ai';
|
|
130
|
+
const registryStandards = getAllStandards();
|
|
131
|
+
const installed = installedStandardFileNames(manifest, registryStandards);
|
|
132
|
+
|
|
133
|
+
const offered = [];
|
|
134
|
+
const notOffered = [];
|
|
135
|
+
for (const std of registryStandards) {
|
|
136
|
+
const source = getStandardSource(std, format);
|
|
137
|
+
if (!source) continue; // skill-only entry: no file to install
|
|
138
|
+
const name = basename(source);
|
|
139
|
+
if (installed.has(name)) continue;
|
|
140
|
+
|
|
141
|
+
const item = { id: std.id, category: std.category, description: oneLineDescription(std.description), source, name };
|
|
142
|
+
if (OFFERED_CATEGORIES.includes(std.category)) {
|
|
143
|
+
offered.push(item);
|
|
144
|
+
} else {
|
|
145
|
+
notOffered.push({
|
|
146
|
+
...item,
|
|
147
|
+
reason: CATEGORY_NOTES[std.category] || 'category not installed by init',
|
|
148
|
+
addable: !INSTALLED_BY_OTHER_MEANS.includes(std.category)
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const notOfferedByCategory = {};
|
|
154
|
+
for (const n of notOffered) notOfferedByCategory[n.category] = (notOfferedByCategory[n.category] || 0) + 1;
|
|
155
|
+
return { offered, notOffered, notOfferedByCategory };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Plain edit distance, enough for "did you mean". */
|
|
159
|
+
function editDistance(a, b) {
|
|
160
|
+
const prev = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
161
|
+
for (let i = 1; i <= a.length; i++) {
|
|
162
|
+
let diagonal = prev[0];
|
|
163
|
+
prev[0] = i;
|
|
164
|
+
for (let j = 1; j <= b.length; j++) {
|
|
165
|
+
const above = prev[j];
|
|
166
|
+
prev[j] = a[i - 1] === b[j - 1] ? diagonal : 1 + Math.min(diagonal, above, prev[j - 1]);
|
|
167
|
+
diagonal = above;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return prev[b.length];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The registry ids nearest to `id` (substring matches first, then by edit distance).
|
|
175
|
+
* @param {string} id
|
|
176
|
+
* @param {number} [limit]
|
|
177
|
+
* @returns {string[]}
|
|
178
|
+
*/
|
|
179
|
+
export function closestStandardIds(id, limit = 5) {
|
|
180
|
+
const needle = String(id || '').toLowerCase();
|
|
181
|
+
const scored = getAllStandards().map(s => {
|
|
182
|
+
const candidate = s.id.toLowerCase();
|
|
183
|
+
const contains = needle.length >= 3 && (candidate.includes(needle) || needle.includes(candidate));
|
|
184
|
+
return { id: s.id, score: (contains ? 0 : 1000) + editDistance(needle, candidate) };
|
|
185
|
+
});
|
|
186
|
+
scored.sort((x, y) => x.score - y.score || x.id.localeCompare(y.id));
|
|
187
|
+
return scored.slice(0, limit).map(s => s.id);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Judge one `--add-standard <id>` request against a manifest.
|
|
192
|
+
*
|
|
193
|
+
* status:
|
|
194
|
+
* 'add' installable now; `source` is what goes into manifest.standards
|
|
195
|
+
* 'installed' already in manifest.standards (not an error)
|
|
196
|
+
* 'unknown' not a registry id; `closest` lists the nearest ids
|
|
197
|
+
* 'other-means' a registry id, but installed through language/integration/template choices
|
|
198
|
+
* 'no-source' a registry id with no file in the project's format
|
|
199
|
+
*
|
|
200
|
+
* @param {string} id
|
|
201
|
+
* @param {Object} manifest
|
|
202
|
+
* @returns {{status: string, id: string, entry?: Object, source?: string, closest?: string[]}}
|
|
203
|
+
*/
|
|
204
|
+
export function judgeAddStandard(id, manifest) {
|
|
205
|
+
const format = manifest.format || 'ai';
|
|
206
|
+
const registryStandards = getAllStandards();
|
|
207
|
+
const entry = registryStandards.find(s => s.id === id);
|
|
208
|
+
if (!entry) return { status: 'unknown', id, closest: closestStandardIds(id) };
|
|
209
|
+
if (INSTALLED_BY_OTHER_MEANS.includes(entry.category)) return { status: 'other-means', id, entry };
|
|
210
|
+
const source = getStandardSource(entry, format);
|
|
211
|
+
if (!source) return { status: 'no-source', id, entry };
|
|
212
|
+
if (installedStandardFileNames(manifest, registryStandards).has(basename(source))) {
|
|
213
|
+
return { status: 'installed', id, entry, source };
|
|
214
|
+
}
|
|
215
|
+
return { status: 'add', id, entry, source };
|
|
216
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Judge a commit message against the commit-message standard, in this process.
|
|
3
|
+
* // implements XSPEC-456 R2
|
|
4
|
+
*
|
|
5
|
+
* `uds simulate -s commit-message` used to pipe the message into `npx commitlint`. That needs the
|
|
6
|
+
* network the first time (npx downloads the tool), needs a commitlint config in the project, and
|
|
7
|
+
* interpolates the message into a shell string. In a project with no commitlint config the tool refuses
|
|
8
|
+
* to run at all, and the old code printed that refusal as "Simulation Failed" - the same answer for a
|
|
9
|
+
* compliant message and a non-compliant one, which is the one thing a simulator must not do.
|
|
10
|
+
*
|
|
11
|
+
* Here the verdict comes from the standard's own rules, read from the installed standard file
|
|
12
|
+
* (`.standards/commit-message.ai.yaml`):
|
|
13
|
+
*
|
|
14
|
+
* - the header shape `<type>(<scope>): <subject>` from `format.template` (scope optional, as the
|
|
15
|
+
* standard's component list says);
|
|
16
|
+
* - the allowed types, from the commit-message option files installed next to the standard
|
|
17
|
+
* (`.standards/options/`, files whose `meta.parent` is `commit-message`); the Conventional Commits
|
|
18
|
+
* set when none are installed;
|
|
19
|
+
* - rule `scope-lowercase` and rule `subject-max-length`, using the `validator` pattern the standard gives.
|
|
20
|
+
*
|
|
21
|
+
* What it does NOT judge is returned in `notChecked`, so a pass never reads as more than it is: rules
|
|
22
|
+
* with no machine-checkable pattern (imperative mood, one logical change per commit) and the language
|
|
23
|
+
* option.
|
|
24
|
+
*
|
|
25
|
+
* @module utils/commit-message-judge
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import fs from 'fs';
|
|
29
|
+
import path from 'path';
|
|
30
|
+
import * as yaml from 'js-yaml';
|
|
31
|
+
|
|
32
|
+
/** Used only when no commit-message option file is installed. The Conventional Commits type set. */
|
|
33
|
+
export const FALLBACK_TYPES = ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert'];
|
|
34
|
+
|
|
35
|
+
/** `type(scope)!: subject` - scope and the breaking-change mark are optional. */
|
|
36
|
+
const HEADER = /^(?<type>[A-Za-z][A-Za-z0-9-]*)(?:\((?<scope>[^()]*)\))?(?<bang>!)?: (?<subject>\S.*)$/;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The commit types the project's installed option files allow. An option file belongs to this standard when
|
|
40
|
+
* its `meta.parent` is `commit-message`. Installed projects keep option files flat in `.standards/options/`
|
|
41
|
+
* (`english.ai.yaml`); a checkout of UDS itself nests them (`.standards/options/commit-message/`). Both are read.
|
|
42
|
+
* @param {string} standardsDir - `<project>/.standards`
|
|
43
|
+
* @returns {{ types: string[], source: string }}
|
|
44
|
+
*/
|
|
45
|
+
export function allowedCommitTypes(standardsDir) {
|
|
46
|
+
const found = new Set();
|
|
47
|
+
const optionsDir = path.join(standardsDir, 'options');
|
|
48
|
+
for (const dir of [optionsDir, path.join(optionsDir, 'commit-message')]) {
|
|
49
|
+
let names = [];
|
|
50
|
+
try {
|
|
51
|
+
names = fs.readdirSync(dir).filter((n) => n.endsWith('.ai.yaml'));
|
|
52
|
+
} catch {
|
|
53
|
+
continue; // this layout is not present
|
|
54
|
+
}
|
|
55
|
+
for (const name of names) {
|
|
56
|
+
try {
|
|
57
|
+
const doc = yaml.load(fs.readFileSync(path.join(dir, name), 'utf-8'));
|
|
58
|
+
if (doc?.meta?.parent !== 'commit-message') continue;
|
|
59
|
+
for (const entry of doc.types || []) {
|
|
60
|
+
if (entry && typeof entry.type === 'string') found.add(entry.type);
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
// an unreadable option file contributes nothing
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (found.size === 0) return { types: FALLBACK_TYPES, source: 'the Conventional Commits set, because no commit-message option file is installed' };
|
|
68
|
+
return { types: [...found], source: '.standards/options' };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The `validator` pattern of a rule in the standard, as a RegExp, or null when there is none. */
|
|
72
|
+
function ruleValidator(standardConfig, ruleId) {
|
|
73
|
+
const rule = (standardConfig?.standard?.rules || []).find((r) => r && r.id === ruleId);
|
|
74
|
+
if (!rule || typeof rule.validator !== 'string') return null;
|
|
75
|
+
try {
|
|
76
|
+
return new RegExp(rule.validator);
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param {Object} standardConfig - the parsed commit-message standard
|
|
84
|
+
* @param {string} input - the commit message (only the first line is the header)
|
|
85
|
+
* @param {{ standardsDir: string }} context
|
|
86
|
+
* @returns {{ verdict: 'pass' | 'fail', findings: string[], checked: string[], notChecked: string[] }}
|
|
87
|
+
*/
|
|
88
|
+
export function judgeCommitMessage(standardConfig, input, { standardsDir }) {
|
|
89
|
+
const findings = [];
|
|
90
|
+
const checked = [];
|
|
91
|
+
const notChecked = [];
|
|
92
|
+
|
|
93
|
+
const header = String(input).replace(/\r\n/g, '\n').split('\n')[0];
|
|
94
|
+
const match = HEADER.exec(header);
|
|
95
|
+
|
|
96
|
+
checked.push('header format <type>(<scope>): <subject>');
|
|
97
|
+
if (!match) {
|
|
98
|
+
findings.push('The first line is not in the form <type>(<scope>): <subject> (scope is optional).');
|
|
99
|
+
} else {
|
|
100
|
+
const { type, scope, subject } = match.groups;
|
|
101
|
+
const { types, source } = allowedCommitTypes(standardsDir);
|
|
102
|
+
|
|
103
|
+
checked.push(`type is one of: ${types.join(', ')} (from ${source})`);
|
|
104
|
+
if (!types.includes(type)) {
|
|
105
|
+
findings.push(`Type "${type}" is not one of: ${types.join(', ')}.`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (scope !== undefined) {
|
|
109
|
+
const scopeRule = ruleValidator(standardConfig, 'scope-lowercase');
|
|
110
|
+
if (scopeRule) {
|
|
111
|
+
checked.push('rule scope-lowercase');
|
|
112
|
+
if (scope === '' || !scopeRule.test(scope)) {
|
|
113
|
+
findings.push(`Scope "${scope}" breaks rule scope-lowercase (use lowercase letters, digits and dashes, starting with a letter).`);
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
notChecked.push('rule scope-lowercase (this copy of the standard gives no pattern for it)');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (subject.trim() === '') findings.push('The subject is empty.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const lengthRule = ruleValidator(standardConfig, 'subject-max-length');
|
|
124
|
+
if (lengthRule) {
|
|
125
|
+
checked.push('rule subject-max-length');
|
|
126
|
+
if (!lengthRule.test(header)) {
|
|
127
|
+
findings.push(`The subject line is ${header.length} characters, which breaks rule subject-max-length.`);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
notChecked.push('rule subject-max-length (this copy of the standard gives no pattern for it)');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
notChecked.push('rule imperative-mood (the standard gives no machine-checkable pattern)');
|
|
134
|
+
notChecked.push('rule no-mixed-changes and the commit language option');
|
|
135
|
+
|
|
136
|
+
return { verdict: findings.length === 0 ? 'pass' : 'fail', findings, checked, notChecked };
|
|
137
|
+
}
|
package/src/utils/copier.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, copyFileSync, readFileSync } from 'fs';
|
|
2
|
+
import { copyFileSyncRetrying } from './transient-fs.js';
|
|
2
3
|
import { dirname, join, basename } from 'path';
|
|
3
4
|
import { fileURLToPath } from 'url';
|
|
4
5
|
import { downloadStandard, downloadIntegration } from './github.js';
|
|
@@ -54,8 +55,8 @@ export function isExtensionPath(sourcePath) {
|
|
|
54
55
|
*/
|
|
55
56
|
export async function copyExtension(sourcePath, targetDir, projectPath) {
|
|
56
57
|
try {
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
58
|
+
const packagedSource = getSourcePath(sourcePath);
|
|
59
|
+
if (!packagedSource) {
|
|
59
60
|
return failure(
|
|
60
61
|
`Extension file not found in the installed package: ${sourcePath} (extension files are never downloaded; reinstall or upgrade universal-dev-standards)`,
|
|
61
62
|
ERROR_CODES.FILE_NOT_FOUND,
|
|
@@ -67,7 +68,7 @@ export async function copyExtension(sourcePath, targetDir, projectPath) {
|
|
|
67
68
|
if (!existsSync(targetFolder)) {
|
|
68
69
|
mkdirSync(targetFolder, { recursive: true });
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
copyFileSyncRetrying(packagedSource, targetFile);
|
|
71
72
|
return success(targetFile, { source: 'local', sourcePath, targetFile });
|
|
72
73
|
} catch (error) {
|
|
73
74
|
return failure(
|
|
@@ -124,7 +125,7 @@ export async function copyStandard(sourcePath, targetDir, projectPath) {
|
|
|
124
125
|
// Try local copy first (bundled or repo)
|
|
125
126
|
const source = getSourcePath(sourcePath);
|
|
126
127
|
if (source) {
|
|
127
|
-
|
|
128
|
+
copyFileSyncRetrying(source, targetFile);
|
|
128
129
|
return success(targetFile, {
|
|
129
130
|
source: 'local',
|
|
130
131
|
sourcePath,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When `uds deps --if-present` is allowed to say "not applicable" instead of failing.
|
|
3
|
+
* // implements XSPEC-456 R6
|
|
4
|
+
*
|
|
5
|
+
* `uds deps` exits 1 when there is no package.json, on purpose: a check that examined nothing must not
|
|
6
|
+
* be able to show a pass (the same rule as `clean` in utils/dependency-resolution.js). That makes it
|
|
7
|
+
* awkward in a shared script that also runs in .NET, Python or Go projects, where callers ended up
|
|
8
|
+
* writing `if [ -f package.json ]` around it. `--if-present` is that guard made part of the command
|
|
9
|
+
* AND visible: the run says nothing was checked, in words, and exits 0.
|
|
10
|
+
*
|
|
11
|
+
* @module utils/deps-applicability
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { existsSync } from 'fs';
|
|
15
|
+
import { join } from 'path';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} root - Directory `uds deps` would examine
|
|
19
|
+
* @param {boolean} ifPresent - Whether `--if-present` was given
|
|
20
|
+
* @returns {'no-package-json' | null} Why the run is not applicable, or null when it must be run
|
|
21
|
+
*/
|
|
22
|
+
export function notApplicableReason(root, ifPresent) {
|
|
23
|
+
if (ifPresent && !existsSync(join(root, 'package.json'))) return 'no-package-json';
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
@@ -15,6 +15,8 @@ import { join } from 'path';
|
|
|
15
15
|
import { compareFileHash, hasFileHashes, computeFileHash } from './hasher.js';
|
|
16
16
|
import { SUPPORTED_AI_TOOLS } from '../core/constants.js';
|
|
17
17
|
import { getAllStandards, getStandardSource } from './registry.js';
|
|
18
|
+
import { getAvailableStandards } from './available-standards.js';
|
|
19
|
+
import { t } from '../i18n/messages.js';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Run friction detection on a UDS installation
|
|
@@ -39,9 +41,34 @@ export function detectFrictions(projectPath, manifest) {
|
|
|
39
41
|
const orphaned = detectOrphanedFiles(projectPath, manifest);
|
|
40
42
|
frictions.push(...orphaned);
|
|
41
43
|
|
|
44
|
+
// Type 4: Standards UDS ships that this project does not have (LOW severity, XSPEC-458 R5).
|
|
45
|
+
// One finding, not one per standard. It is information: `audit --score` does not read frictions,
|
|
46
|
+
// so this cannot move a score.
|
|
47
|
+
frictions.push(...detectAvailableStandards(manifest));
|
|
48
|
+
|
|
42
49
|
return frictions;
|
|
43
50
|
}
|
|
44
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Standards UDS ships (and `uds init` installs) that this project's manifest does not list.
|
|
54
|
+
* @param {Object} manifest
|
|
55
|
+
* @returns {Array}
|
|
56
|
+
*/
|
|
57
|
+
function detectAvailableStandards(manifest) {
|
|
58
|
+
const { offered } = getAvailableStandards(manifest);
|
|
59
|
+
if (offered.length === 0) return [];
|
|
60
|
+
|
|
61
|
+
const msg = t().availableStandards;
|
|
62
|
+
const shown = offered.slice(0, 5).map(s => s.id).join(', ');
|
|
63
|
+
return [{
|
|
64
|
+
standard: msg.frictionStandard.replace('{count}', offered.length),
|
|
65
|
+
type: 'not-installed',
|
|
66
|
+
severity: 'LOW',
|
|
67
|
+
diff: offered.length > 5 ? `${shown}, …` : shown,
|
|
68
|
+
suggestion: msg.frictionSuggestion
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
|
|
45
72
|
/**
|
|
46
73
|
* Detect standards files that were modified by the user
|
|
47
74
|
* @param {string} projectPath
|