universal-dev-standards 6.14.0-beta.6 → 6.14.0-beta.8
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 +30 -6
- 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/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 +78 -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 +4 -3
- package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +25 -23
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +13 -11
- 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 +78 -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 +4 -3
- package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +25 -23
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +13 -11
- 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/hitl.js +3 -0
- package/src/commands/init.js +41 -21
- package/src/commands/list.js +12 -3
- package/src/commands/mcp.js +2 -3
- package/src/commands/open-work.js +65 -6
- package/src/commands/quickstart.js +29 -13
- package/src/commands/release.js +41 -17
- package/src/commands/skills.js +19 -33
- package/src/commands/spec-split.js +28 -16
- package/src/commands/spec.js +34 -13
- package/src/commands/uninstall.js +2 -2
- package/src/commands/update.js +61 -61
- package/src/core/open-work-config.js +103 -0
- package/src/flows/init-flow.js +10 -0
- package/src/hitl/manager.js +4 -2
- package/src/i18n/messages.js +240 -63
- package/src/installers/skills-installer.js +3 -1
- package/src/mcp/__tests__/server.test.js +0 -1
- package/src/mcp/server.js +16 -4
- package/src/prompts/init.js +148 -13
- package/src/reconciler/index.js +42 -5
- 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/available-standards-report.js +144 -0
- package/src/utils/available-standards.js +216 -0
- package/src/utils/copier.js +5 -4
- package/src/utils/friction-detector.js +27 -0
- package/src/utils/open-work-tracking.mjs +919 -48
- package/src/utils/prompt-closed.js +18 -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/transient-fs.js +113 -0
- package/standards-registry.json +34 -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
|
+
}
|
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,
|
|
@@ -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
|