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
package/src/prompts/init.js
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync, readFileSync, writeFileSync, readdirSync } from 'fs';
|
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import os from 'os';
|
|
6
|
+
import * as yaml from 'js-yaml';
|
|
6
7
|
import { t, setLanguage, detectLanguage } from '../i18n/messages.js';
|
|
7
8
|
import {
|
|
8
9
|
getAgentConfig,
|
|
@@ -169,7 +170,7 @@ export async function promptSkillsInstallLocation(selectedTools = []) {
|
|
|
169
170
|
// Show Marketplace info for Claude Code (not as a selectable option)
|
|
170
171
|
if (hasClaudeCode) {
|
|
171
172
|
console.log();
|
|
172
|
-
console.log(chalk.yellow(` 💡 ${marketplaceMsg.claudeCodeTip
|
|
173
|
+
console.log(chalk.yellow(` 💡 ${marketplaceMsg.claudeCodeTip}`));
|
|
173
174
|
console.log(chalk.white(' /plugin install universal-dev-standards@asia-ostrich'));
|
|
174
175
|
console.log(chalk.gray(` → ${msg.choices.marketplace}`));
|
|
175
176
|
}
|
|
@@ -195,10 +196,12 @@ export async function promptSkillsInstallLocation(selectedTools = []) {
|
|
|
195
196
|
value: `${tool}:user`
|
|
196
197
|
});
|
|
197
198
|
|
|
198
|
-
// Project level option
|
|
199
|
+
// Project level option. Pre-selected (XSPEC-468 R1): the project way is the main path, so pressing Enter
|
|
200
|
+
// installs the skills into the project. Deselect everything to skip them (for example, to use the plugin).
|
|
199
201
|
choices.push({
|
|
200
202
|
name: `${chalk.blue(displayName)} - ${msg.choices.projectLevel} ${chalk.gray(`(${config.skills.project})`)}`,
|
|
201
|
-
value: `${tool}:project
|
|
203
|
+
value: `${tool}:project`,
|
|
204
|
+
checked: true
|
|
202
205
|
});
|
|
203
206
|
}
|
|
204
207
|
|
|
@@ -1427,8 +1430,22 @@ export function suggestCommands(projectPath) {
|
|
|
1427
1430
|
return { test: '', lint: '', build: '', security: '' };
|
|
1428
1431
|
}
|
|
1429
1432
|
|
|
1433
|
+
/**
|
|
1434
|
+
* A command as it is written after `key: ` in YAML. Plain when plain is safe; single-quoted (the form that
|
|
1435
|
+
* has no escape sequences, so a Windows path survives) when the text would otherwise change meaning.
|
|
1436
|
+
* @param {string} command
|
|
1437
|
+
* @returns {string}
|
|
1438
|
+
*/
|
|
1439
|
+
function yamlCommandScalar(command) {
|
|
1440
|
+
const text = command.trim();
|
|
1441
|
+
const needsQuotes = /^[\s'"[\]{}&*!|>%@`,?#-]|: | #|:$/.test(text);
|
|
1442
|
+
return needsQuotes ? `'${text.replaceAll("'", "''")}'` : text;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1430
1445
|
/**
|
|
1431
1446
|
* Generate uds.project.yaml content from a commands map.
|
|
1447
|
+
* This writes a NEW file. To change the commands of an existing file without losing its other sections,
|
|
1448
|
+
* use `mergeProjectConfigYaml`.
|
|
1432
1449
|
* @param {{ test?: string, lint?: string, build?: string, security?: string }} commands
|
|
1433
1450
|
* @returns {string}
|
|
1434
1451
|
*/
|
|
@@ -1436,12 +1453,111 @@ export function generateProjectConfigYaml(commands) {
|
|
|
1436
1453
|
const lines = ['version: "1"', '', 'commands:'];
|
|
1437
1454
|
for (const [intent, cmd] of Object.entries(commands)) {
|
|
1438
1455
|
if (cmd && cmd.trim()) {
|
|
1439
|
-
lines.push(` ${intent}: ${cmd
|
|
1456
|
+
lines.push(` ${intent}: ${yamlCommandScalar(cmd)}`);
|
|
1440
1457
|
}
|
|
1441
1458
|
}
|
|
1442
1459
|
return lines.join('\n') + '\n';
|
|
1443
1460
|
}
|
|
1444
1461
|
|
|
1462
|
+
/**
|
|
1463
|
+
* What an existing uds.project.yaml holds, as far as the wizard needs it: the names of its top-level sections
|
|
1464
|
+
* and the commands it already declares. `readable: false` means the text is not YAML (or not a mapping), so
|
|
1465
|
+
* nothing in it can be kept apart from the whole file.
|
|
1466
|
+
*
|
|
1467
|
+
* @param {string} text
|
|
1468
|
+
* @returns {{ readable: boolean, sections: string[], commands: Record<string, string> }}
|
|
1469
|
+
*/
|
|
1470
|
+
export function describeProjectConfig(text) {
|
|
1471
|
+
let doc;
|
|
1472
|
+
try {
|
|
1473
|
+
doc = yaml.load(text);
|
|
1474
|
+
} catch {
|
|
1475
|
+
return { readable: false, sections: [], commands: {} };
|
|
1476
|
+
}
|
|
1477
|
+
if (doc === null || doc === undefined) return { readable: true, sections: [], commands: {} };
|
|
1478
|
+
if (typeof doc !== 'object' || Array.isArray(doc)) return { readable: false, sections: [], commands: {} };
|
|
1479
|
+
const commands = {};
|
|
1480
|
+
if (doc.commands && typeof doc.commands === 'object' && !Array.isArray(doc.commands)) {
|
|
1481
|
+
for (const [k, v] of Object.entries(doc.commands)) commands[k] = v === null || v === undefined ? '' : String(v);
|
|
1482
|
+
}
|
|
1483
|
+
return { readable: true, sections: Object.keys(doc), commands };
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Change the command keys of an existing uds.project.yaml and leave every other byte of it alone
|
|
1488
|
+
* (XSPEC-468 R5). The wizard used to rewrite the whole file from `generateProjectConfigYaml`, which dropped
|
|
1489
|
+
* `open_work:` (the place an adopter declares what `uds open-work` needs, XSPEC-460/461), `custom:`, comments,
|
|
1490
|
+
* and anything else the wizard does not ask about.
|
|
1491
|
+
*
|
|
1492
|
+
* Works on the text, not on a parsed copy: a parse-and-dump would keep the data and lose the comments, the
|
|
1493
|
+
* order and the quoting. Only lines of the top-level `commands:` block that name one of the given intents
|
|
1494
|
+
* are replaced (with their indented continuation lines); an intent that is not there yet is added at the end
|
|
1495
|
+
* of that block; with no `commands:` block at all one is appended to the end of the file. An intent whose
|
|
1496
|
+
* value already equals the new one is not touched. Blank commands are skipped.
|
|
1497
|
+
*
|
|
1498
|
+
* @param {string} existing - current file text
|
|
1499
|
+
* @param {Record<string, string>} commands - intent -> command
|
|
1500
|
+
* @returns {string} the new file text
|
|
1501
|
+
*/
|
|
1502
|
+
export function mergeProjectConfigYaml(existing, commands) {
|
|
1503
|
+
const eol = existing.includes('\r\n') ? '\r\n' : '\n';
|
|
1504
|
+
const endsWithNewline = /\n$/.test(existing);
|
|
1505
|
+
const lines = existing.split(/\r?\n/);
|
|
1506
|
+
if (endsWithNewline) lines.pop();
|
|
1507
|
+
const current = describeProjectConfig(existing).commands;
|
|
1508
|
+
const wanted = Object.entries(commands)
|
|
1509
|
+
.filter(([, cmd]) => cmd && cmd.trim())
|
|
1510
|
+
.filter(([intent, cmd]) => current[intent] !== cmd.trim());
|
|
1511
|
+
if (wanted.length === 0) return existing;
|
|
1512
|
+
|
|
1513
|
+
const entryLine = (indent, intent, cmd) => `${indent}${intent}: ${yamlCommandScalar(cmd)}`;
|
|
1514
|
+
const headIdx = lines.findIndex(l => /^commands\s*:/.test(l));
|
|
1515
|
+
|
|
1516
|
+
if (headIdx === -1) {
|
|
1517
|
+
if (lines.length > 0 && lines[lines.length - 1].trim() !== '') lines.push('');
|
|
1518
|
+
lines.push('commands:');
|
|
1519
|
+
for (const [intent, cmd] of wanted) lines.push(entryLine(' ', intent, cmd));
|
|
1520
|
+
return lines.join(eol) + eol;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
const inlineValue = lines[headIdx].replace(/^commands\s*:/, '').replace(/\s+#.*$/, '').trim();
|
|
1524
|
+
if (inlineValue) {
|
|
1525
|
+
// `commands: {test: x}` written on one line: turn it into a block that keeps the keys it had.
|
|
1526
|
+
const merged = { ...current };
|
|
1527
|
+
for (const [intent, cmd] of wanted) merged[intent] = cmd.trim();
|
|
1528
|
+
const block = ['commands:', ...Object.entries(merged).filter(([, c]) => c).map(([i, c]) => entryLine(' ', i, c))];
|
|
1529
|
+
lines.splice(headIdx, 1, ...block);
|
|
1530
|
+
return lines.join(eol) + eol;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
// The block runs until the next line that starts in column 0 (a section, or a comment about one).
|
|
1534
|
+
let end = headIdx + 1;
|
|
1535
|
+
while (end < lines.length && (lines[end].trim() === '' || /^\s/.test(lines[end]))) end++;
|
|
1536
|
+
while (end > headIdx + 1 && lines[end - 1].trim() === '') end--; // blank lines after the block are not in it
|
|
1537
|
+
|
|
1538
|
+
const firstKey = lines.slice(headIdx + 1, end).find(l => l.trim() !== '' && !l.trim().startsWith('#'));
|
|
1539
|
+
const indent = firstKey ? firstKey.match(/^\s*/)[0] : ' ';
|
|
1540
|
+
|
|
1541
|
+
for (const [intent, cmd] of wanted) {
|
|
1542
|
+
const keyLine = new RegExp(`^${indent}${intent.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*:`);
|
|
1543
|
+
let at = -1;
|
|
1544
|
+
for (let i = headIdx + 1; i < end; i++) {
|
|
1545
|
+
if (keyLine.test(lines[i])) { at = i; break; }
|
|
1546
|
+
}
|
|
1547
|
+
if (at === -1) {
|
|
1548
|
+
lines.splice(end, 0, entryLine(indent, intent, cmd));
|
|
1549
|
+
end += 1;
|
|
1550
|
+
continue;
|
|
1551
|
+
}
|
|
1552
|
+
// The old value may continue on deeper-indented lines (a block scalar): they go with it.
|
|
1553
|
+
let stop = at + 1;
|
|
1554
|
+
while (stop < end && (lines[stop].trim() === '' ? false : lines[stop].match(/^\s*/)[0].length > indent.length)) stop++;
|
|
1555
|
+
lines.splice(at, stop - at, entryLine(indent, intent, cmd));
|
|
1556
|
+
end -= (stop - at) - 1;
|
|
1557
|
+
}
|
|
1558
|
+
return lines.join(eol) + eol;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1445
1561
|
/**
|
|
1446
1562
|
* Wraps promptProjectCommandContract with an initial confirm prompt.
|
|
1447
1563
|
* Used as the optional Step 13 in the init flow so the whole step can be
|
|
@@ -1475,15 +1591,28 @@ export async function promptProjectContractStep(projectPath) {
|
|
|
1475
1591
|
export async function promptProjectCommandContract(projectPath) {
|
|
1476
1592
|
const contractPath = join(projectPath, 'uds.project.yaml');
|
|
1477
1593
|
|
|
1478
|
-
// If already exists, ask
|
|
1594
|
+
// If it already exists, ask before touching it. XSPEC-468 R5: the question says exactly what will change.
|
|
1595
|
+
// The wizard only manages the command keys; every other section (`open_work:`, `custom:`, ...) stays.
|
|
1596
|
+
let existingText = null;
|
|
1597
|
+
let existing = null;
|
|
1479
1598
|
if (existsSync(contractPath)) {
|
|
1599
|
+
existingText = readFileSync(contractPath, 'utf-8');
|
|
1600
|
+
existing = describeProjectConfig(existingText);
|
|
1601
|
+
|
|
1480
1602
|
console.log();
|
|
1481
1603
|
console.log(chalk.yellow(' uds.project.yaml already exists.'));
|
|
1482
1604
|
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1605
|
+
const kept = existing.sections.filter(name => name !== 'commands');
|
|
1606
|
+
const message = existing.readable
|
|
1607
|
+
? 'Update the commands (test, lint, build, security) in the existing uds.project.yaml? ' +
|
|
1608
|
+
(kept.length > 0
|
|
1609
|
+
? `These sections are kept exactly as they are: ${kept.join(', ')}.`
|
|
1610
|
+
: 'It has no other sections.')
|
|
1611
|
+
// Not YAML: nothing in it can be kept, so the question names the loss instead of hiding it.
|
|
1612
|
+
: 'The existing uds.project.yaml cannot be read as YAML, so none of its content can be kept. ' +
|
|
1613
|
+
'Replace the whole file?';
|
|
1614
|
+
|
|
1615
|
+
const overwrite = await inquirerConfirm({ message, default: false });
|
|
1487
1616
|
|
|
1488
1617
|
if (!overwrite) {
|
|
1489
1618
|
console.log(chalk.gray(' Skipped — keeping existing uds.project.yaml'));
|
|
@@ -1512,7 +1641,8 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1512
1641
|
const commands = {};
|
|
1513
1642
|
|
|
1514
1643
|
for (const intent of intents) {
|
|
1515
|
-
|
|
1644
|
+
// A command the file already declares is the default, so Enter keeps it; the ecosystem guess only fills gaps.
|
|
1645
|
+
const defaultVal = existing?.commands?.[intent] || suggestions[intent] || '';
|
|
1516
1646
|
const answer = await input({
|
|
1517
1647
|
message: ` ${intent} command${defaultVal ? ` (default: ${defaultVal})` : ' (optional)'}:`,
|
|
1518
1648
|
default: defaultVal
|
|
@@ -1526,11 +1656,16 @@ export async function promptProjectCommandContract(projectPath) {
|
|
|
1526
1656
|
return false;
|
|
1527
1657
|
}
|
|
1528
1658
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1659
|
+
// An existing, readable file is edited in place (XSPEC-468 R5); a new file, or one that is not YAML at all
|
|
1660
|
+
// and that the user agreed to replace, is written whole.
|
|
1661
|
+
const merging = existing?.readable === true;
|
|
1662
|
+
const content = merging
|
|
1663
|
+
? mergeProjectConfigYaml(existingText, commands)
|
|
1664
|
+
: generateProjectConfigYaml(commands);
|
|
1665
|
+
writeFileSync(contractPath, content, 'utf-8');
|
|
1531
1666
|
|
|
1532
1667
|
console.log();
|
|
1533
|
-
console.log(chalk.green(' ✔ uds.project.yaml created'));
|
|
1668
|
+
console.log(chalk.green(merging ? ' ✔ uds.project.yaml updated (other sections kept as they were)' : ' ✔ uds.project.yaml created'));
|
|
1534
1669
|
console.log(chalk.gray(` Path: ${contractPath}`));
|
|
1535
1670
|
return true;
|
|
1536
1671
|
}
|
package/src/reconciler/index.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* const rollbackResult = rollbackLast(projectPath);
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { readManifest, writeManifest, needsMigration } from '../core/manifest.js';
|
|
24
|
+
import { readManifest, writeManifest, needsMigration, migrateStandardsPathsToIds } from '../core/manifest.js';
|
|
25
25
|
import { migrateAndBackfill } from './manifest-migrator.js';
|
|
26
26
|
import { calculateDesiredState } from './desired-state-calculator.js';
|
|
27
27
|
import { scanActualState, legacyDiscovery } from './actual-state-scanner.js';
|
|
@@ -133,12 +133,40 @@ function reconcileFileHashes(manifest, verifiedPristine) {
|
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A copy of `manifest` with extra standards listed (XSPEC-458 R3, `uds update --add-standard`).
|
|
138
|
+
*
|
|
139
|
+
* The reconciler treats a file under `.standards/` that the manifest does not list as surplus and
|
|
140
|
+
* deletes it, so a standard the user picks has to be in the manifest the plan is computed from AND
|
|
141
|
+
* in the manifest the executor writes back. Both are this copy. The manifest ON DISK is not touched
|
|
142
|
+
* here: the backup the executor takes holds the old one, which is what lets one `--rollback` take
|
|
143
|
+
* the standard out again.
|
|
144
|
+
*
|
|
145
|
+
* The list is put through the same normalisation `readManifest` applies on every read (registry ids
|
|
146
|
+
* sorted, option paths after them). That is not tidiness: the integration blocks (CLAUDE.md,
|
|
147
|
+
* AGENTS.md) are generated from this list, and their text depends on its order. Generated from an
|
|
148
|
+
* un-normalised copy, the block would differ from what the next run expects of the manifest as
|
|
149
|
+
* written, and `--plan` would still show "migrate block" after a successful `--apply`.
|
|
150
|
+
*
|
|
151
|
+
* @param {Object} manifest
|
|
152
|
+
* @param {string[]} [ids] - Registry ids to add
|
|
153
|
+
* @returns {Object}
|
|
154
|
+
*/
|
|
155
|
+
export function withAddedStandards(manifest, ids = []) {
|
|
156
|
+
if (!manifest || ids.length === 0) return manifest;
|
|
157
|
+
const listed = new Set(manifest.standards || []);
|
|
158
|
+
const added = ids.filter(id => !listed.has(id));
|
|
159
|
+
if (added.length === 0) return manifest;
|
|
160
|
+
return { ...manifest, standards: migrateStandardsPathsToIds([...(manifest.standards || []), ...added]) };
|
|
161
|
+
}
|
|
162
|
+
|
|
136
163
|
export async function reconcile(projectPath, options = {}) {
|
|
137
|
-
const { force = false, backup = true, onAction } = options;
|
|
164
|
+
const { force = false, backup = true, onAction, addStandards = [] } = options;
|
|
138
165
|
const errors = [];
|
|
139
166
|
|
|
140
167
|
// Step 1: Get manifest (migrate if needed, or discover from legacy)
|
|
141
|
-
const { manifest, migrationErrors } = await getManifest(projectPath);
|
|
168
|
+
const { manifest: diskManifest, migrationErrors } = await getManifest(projectPath);
|
|
169
|
+
const manifest = withAddedStandards(diskManifest, addStandards);
|
|
142
170
|
if (migrationErrors.length > 0) errors.push(...migrationErrors);
|
|
143
171
|
if (!manifest) {
|
|
144
172
|
return {
|
|
@@ -173,6 +201,13 @@ export async function reconcile(projectPath, options = {}) {
|
|
|
173
201
|
// Writing it here first would put the hash correction into the backup's "before" copy, so a rollback
|
|
174
202
|
// could not give back the manifest byte for byte (XSPEC-454 R1).
|
|
175
203
|
if (hashFix && reconciliationPlan.actions.length === 0) writeManifest(effectiveManifest, projectPath);
|
|
204
|
+
// XSPEC-458 R3: a chosen standard whose file is already on disk, byte for byte, produces no action —
|
|
205
|
+
// and with no action the executor never writes the manifest, so the choice would be lost and the next
|
|
206
|
+
// run would call that file surplus. Record it. (Nothing but the manifest changes, so there is no
|
|
207
|
+
// file for a backup to protect.)
|
|
208
|
+
if (addStandards.length > 0 && !hashFix && manifest !== diskManifest && reconciliationPlan.actions.length === 0) {
|
|
209
|
+
writeManifest(effectiveManifest, projectPath);
|
|
210
|
+
}
|
|
176
211
|
|
|
177
212
|
// Step 5: Execute plan
|
|
178
213
|
if (reconciliationPlan.actions.length === 0) {
|
|
@@ -217,10 +252,12 @@ export async function reconcile(projectPath, options = {}) {
|
|
|
217
252
|
* }>}
|
|
218
253
|
*/
|
|
219
254
|
export async function plan(projectPath, options = {}) {
|
|
220
|
-
const { force = false } = options;
|
|
255
|
+
const { force = false, addStandards = [] } = options;
|
|
221
256
|
const errors = [];
|
|
222
257
|
|
|
223
|
-
const { manifest, migrationErrors } = await getManifest(projectPath);
|
|
258
|
+
const { manifest: diskManifest, migrationErrors } = await getManifest(projectPath);
|
|
259
|
+
// XSPEC-458 R3: `--plan --add-standard X` plans from the manifest as it would be with X listed.
|
|
260
|
+
const manifest = withAddedStandards(diskManifest, addStandards);
|
|
224
261
|
if (migrationErrors.length > 0) errors.push(...migrationErrors);
|
|
225
262
|
if (!manifest) {
|
|
226
263
|
return {
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { existsSync, rmSync } from 'fs';
|
|
1
|
+
import { existsSync, rmSync, rmdirSync, readdirSync, unlinkSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
2
3
|
import {
|
|
3
4
|
getSkillsDirForAgent,
|
|
4
|
-
getCommandsDirForAgent
|
|
5
|
-
getAgentsDirForAgent,
|
|
6
|
-
getWorkflowsDirForAgent
|
|
5
|
+
getCommandsDirForAgent
|
|
7
6
|
} from '../config/ai-agent-paths.js';
|
|
7
|
+
import { computeFileHash } from '../utils/hasher.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Uninstall skills
|
|
10
|
+
* Uninstall skills and commands
|
|
11
|
+
*
|
|
12
|
+
* Skills and commands go into folders the adopter shares with other things
|
|
13
|
+
* (`.claude/skills/` holds their own skills too; `init` says so where it writes
|
|
14
|
+
* them). So this removes only what UDS can PROVE it wrote and nobody has changed
|
|
15
|
+
* since: a record in the manifest (`skillHashes` / `commandHashes`) plus a
|
|
16
|
+
* matching content hash. The same rule `uds uninstall` already applies to hook
|
|
17
|
+
* scripts and integration files. A file with no record, or edited since, is
|
|
18
|
+
* kept and said so. A folder UDS emptied is removed; a folder that still holds
|
|
19
|
+
* something else is left alone.
|
|
20
|
+
*
|
|
21
|
+
* This used to `rmSync` the whole skills folder, which took the adopter's own
|
|
22
|
+
* skills with it.
|
|
23
|
+
*
|
|
11
24
|
* @param {string} projectPath - Project root path
|
|
12
25
|
* @param {Object} manifest - Parsed manifest object
|
|
13
26
|
* @param {Object} options - { dryRun, includeUserLevel }
|
|
@@ -26,30 +39,52 @@ export function uninstallSkills(projectPath, manifest, options = {}) {
|
|
|
26
39
|
// Process skill installations
|
|
27
40
|
const skillInstalls = manifest?.skills?.installations || [];
|
|
28
41
|
for (const install of skillInstalls) {
|
|
29
|
-
processInstallation(install, 'skills', projectPath, options, result);
|
|
42
|
+
processInstallation(install, 'skills', projectPath, manifest, options, result);
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
// Process command installations
|
|
33
46
|
const cmdInstalls = manifest?.commands?.installations || [];
|
|
34
47
|
for (const install of cmdInstalls) {
|
|
35
|
-
processInstallation(install, 'commands', projectPath, options, result);
|
|
48
|
+
processInstallation(install, 'commands', projectPath, manifest, options, result);
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
return result;
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
|
-
*
|
|
55
|
+
* The files the manifest says UDS wrote into one installation's folder.
|
|
56
|
+
* Skill records are keyed `<agent>/<level>/<skill>/<file>`; command records
|
|
57
|
+
* `<agent>/<file>` (they carry no level).
|
|
58
|
+
* @returns {Array<{ rel: string, hash: string }>} path inside the folder (forward slashes) and recorded hash
|
|
43
59
|
*/
|
|
44
|
-
function
|
|
60
|
+
function recordedFiles(manifest, type, agent, level) {
|
|
61
|
+
const table = (type === 'skills' ? manifest?.skillHashes : manifest?.commandHashes) || {};
|
|
62
|
+
const prefix = type === 'skills' ? `${agent}/${level}/` : `${agent}/`;
|
|
63
|
+
return Object.entries(table)
|
|
64
|
+
.filter(([key]) => key.startsWith(prefix))
|
|
65
|
+
.map(([key, info]) => ({ rel: key.slice(prefix.length), hash: info && info.hash }));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Remove `dir` if nothing is left in it. Returns whether it is gone. */
|
|
69
|
+
function removeIfEmpty(dir) {
|
|
70
|
+
try {
|
|
71
|
+
if (readdirSync(dir).length > 0) return false;
|
|
72
|
+
rmdirSync(dir);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Process a single skill/command installation for removal
|
|
81
|
+
*/
|
|
82
|
+
function processInstallation(install, type, projectPath, manifest, options, result) {
|
|
45
83
|
const { dryRun = false, includeUserLevel = false } = options;
|
|
46
84
|
const { agent, level } = install;
|
|
47
85
|
|
|
48
86
|
// Determine directory getter
|
|
49
|
-
const getDirFn = type === 'skills' ? getSkillsDirForAgent :
|
|
50
|
-
type === 'commands' ? getCommandsDirForAgent :
|
|
51
|
-
type === 'agents' ? getAgentsDirForAgent :
|
|
52
|
-
getWorkflowsDirForAgent;
|
|
87
|
+
const getDirFn = type === 'skills' ? getSkillsDirForAgent : getCommandsDirForAgent;
|
|
53
88
|
|
|
54
89
|
const dir = getDirFn(agent, level || 'project', projectPath);
|
|
55
90
|
if (!dir) {
|
|
@@ -71,14 +106,46 @@ function processInstallation(install, type, projectPath, options, result) {
|
|
|
71
106
|
return;
|
|
72
107
|
}
|
|
73
108
|
|
|
109
|
+
const records = recordedFiles(manifest, type, agent, level || 'project');
|
|
110
|
+
if (records.length === 0) {
|
|
111
|
+
result.skipped.push(`${label} — kept ${dir}: the manifest records no file UDS wrote there, so UDS cannot prove which are its own`);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const toRemove = [];
|
|
116
|
+
const changed = [];
|
|
117
|
+
for (const { rel, hash } of records) {
|
|
118
|
+
const file = join(dir, ...rel.split('/'));
|
|
119
|
+
if (!existsSync(file)) continue;
|
|
120
|
+
const now = computeFileHash(file);
|
|
121
|
+
if (now && hash && now.hash === hash) toRemove.push(file);
|
|
122
|
+
else changed.push(rel);
|
|
123
|
+
}
|
|
124
|
+
|
|
74
125
|
if (dryRun) {
|
|
75
|
-
result.removed.push(`${label} → ${dir}`);
|
|
126
|
+
result.removed.push(`${label} → ${dir} (${toRemove.length} file(s) UDS wrote)`);
|
|
127
|
+
if (changed.length > 0) result.skipped.push(`${label} — would keep ${changed.length} file(s) changed since UDS wrote them`);
|
|
76
128
|
return;
|
|
77
129
|
}
|
|
78
130
|
|
|
79
131
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
132
|
+
const touched = new Set();
|
|
133
|
+
for (const file of toRemove) {
|
|
134
|
+
unlinkSync(file);
|
|
135
|
+
touched.add(dirname(file));
|
|
136
|
+
}
|
|
137
|
+
// UDS's own bookkeeping for the folder (written by the skills installer, never hashed): go with the last of its files.
|
|
138
|
+
if (changed.length === 0) {
|
|
139
|
+
const marker = join(dir, '.manifest.json');
|
|
140
|
+
if (existsSync(marker)) rmSync(marker, { force: true });
|
|
141
|
+
}
|
|
142
|
+
// Folders UDS emptied, deepest first, then the installation folder itself.
|
|
143
|
+
for (const d of [...touched].sort((a, b) => b.length - a.length)) {
|
|
144
|
+
if (d !== dir) removeIfEmpty(d);
|
|
145
|
+
}
|
|
146
|
+
const gone = removeIfEmpty(dir);
|
|
147
|
+
result.removed.push(`${label} → ${dir} (${toRemove.length} file(s) UDS wrote${gone ? '' : '; folder kept: it still holds files that are not UDS\'s'})`);
|
|
148
|
+
if (changed.length > 0) result.skipped.push(`${label} — kept ${changed.length} file(s) changed since UDS wrote them`);
|
|
82
149
|
} catch (error) {
|
|
83
150
|
result.errors.push(`${label} — ${error.message}`);
|
|
84
151
|
}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readdirSync, rmdirSync, unlinkSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { classifyStandardsFiles, computeFileHash } from '../utils/hasher.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Uninstall .standards/
|
|
6
|
+
* Uninstall the files UDS wrote into .standards/
|
|
7
|
+
*
|
|
8
|
+
* `.standards/` is a folder the adopter may add files to (UDS's own docs invite
|
|
9
|
+
* teams to), so this removes only what UDS can PROVE it wrote and nobody has
|
|
10
|
+
* changed since: a file the manifest records (`fileHashes`, or `provenance`)
|
|
11
|
+
* whose content still matches its recorded hash. A file with no record, or edited
|
|
12
|
+
* since, is kept and said so. The manifest goes last, and the folder only when
|
|
13
|
+
* nothing else is in it. The same rule `uds uninstall` applies to skills, hook
|
|
14
|
+
* scripts and integration files.
|
|
15
|
+
*
|
|
16
|
+
* This used to `rmSync` the whole folder, which took the adopter's own files
|
|
17
|
+
* with it.
|
|
18
|
+
*
|
|
6
19
|
* @param {string} projectPath - Project root path
|
|
7
|
-
* @param {Object} options - { dryRun: boolean }
|
|
20
|
+
* @param {Object} options - { dryRun: boolean, manifest: Object } (the manifest says which files UDS wrote)
|
|
8
21
|
* @returns {Object} { removed: string[], skipped: string[], errors: string[] }
|
|
9
22
|
*/
|
|
10
23
|
export function uninstallStandards(projectPath, options = {}) {
|
|
11
|
-
const { dryRun = false } = options;
|
|
24
|
+
const { dryRun = false, manifest = null } = options;
|
|
12
25
|
const result = { removed: [], skipped: [], errors: [] };
|
|
13
26
|
const standardsDir = join(projectPath, '.standards');
|
|
14
27
|
|
|
@@ -16,18 +29,54 @@ export function uninstallStandards(projectPath, options = {}) {
|
|
|
16
29
|
result.skipped.push('.standards/ (not found)');
|
|
17
30
|
return result;
|
|
18
31
|
}
|
|
32
|
+
if (!manifest) {
|
|
33
|
+
result.skipped.push('.standards/ — kept: there is no manifest to say which files UDS wrote');
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const census = classifyStandardsFiles(projectPath, manifest);
|
|
38
|
+
const toRemove = [];
|
|
39
|
+
const changed = [];
|
|
40
|
+
for (const rel of census.udsOwned) {
|
|
41
|
+
const record = manifest.fileHashes && manifest.fileHashes[rel];
|
|
42
|
+
const file = join(projectPath, ...rel.split('/'));
|
|
43
|
+
if (record && record.hash) {
|
|
44
|
+
const now = computeFileHash(file);
|
|
45
|
+
if (!now || now.hash !== record.hash) { changed.push(rel); continue; }
|
|
46
|
+
}
|
|
47
|
+
toRemove.push(file);
|
|
48
|
+
}
|
|
49
|
+
const notUds = [...census.foreign, ...census.unknown];
|
|
50
|
+
const kept = [...changed, ...notUds];
|
|
51
|
+
const manifestFile = join(standardsDir, 'manifest.json');
|
|
52
|
+
const count = toRemove.length + (existsSync(manifestFile) ? 1 : 0);
|
|
53
|
+
|
|
54
|
+
const describe = (wholeFolderGone) => `.standards/ (${count} file(s) UDS wrote${wholeFolderGone ? '' : '; folder kept: it still holds files that are not UDS\'s'})`;
|
|
55
|
+
const keptNote = `.standards/ — kept ${kept.length} file(s) UDS did not write or that changed since: ${kept.slice(0, 5).join(', ')}${kept.length > 5 ? ', ...' : ''}`;
|
|
19
56
|
|
|
20
57
|
if (dryRun) {
|
|
21
|
-
result.removed.push(
|
|
58
|
+
result.removed.push(describe(kept.length === 0));
|
|
59
|
+
if (kept.length > 0) result.skipped.push(keptNote);
|
|
22
60
|
return result;
|
|
23
61
|
}
|
|
24
62
|
|
|
25
63
|
try {
|
|
26
|
-
|
|
27
|
-
|
|
64
|
+
for (const file of toRemove) unlinkSync(file);
|
|
65
|
+
if (existsSync(manifestFile)) unlinkSync(manifestFile);
|
|
66
|
+
removeEmptyFolders(standardsDir);
|
|
67
|
+
result.removed.push(describe(!existsSync(standardsDir)));
|
|
68
|
+
if (kept.length > 0) result.skipped.push(keptNote);
|
|
28
69
|
} catch (error) {
|
|
29
70
|
result.errors.push(`.standards/ — ${error.message}`);
|
|
30
71
|
}
|
|
31
72
|
|
|
32
73
|
return result;
|
|
33
74
|
}
|
|
75
|
+
|
|
76
|
+
/** Remove every folder under `dir` that is empty, deepest first, then `dir` itself if it ends up empty. */
|
|
77
|
+
function removeEmptyFolders(dir) {
|
|
78
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
79
|
+
if (entry.isDirectory()) removeEmptyFolders(join(dir, entry.name));
|
|
80
|
+
}
|
|
81
|
+
if (readdirSync(dir).length === 0) rmdirSync(dir);
|
|
82
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync, statSync } from 'fs';
|
|
11
11
|
import { dirname, join, basename } from 'path';
|
|
12
12
|
import { fileURLToPath } from 'url';
|
|
13
|
+
import * as yaml from 'js-yaml';
|
|
13
14
|
import {
|
|
14
15
|
getAgentConfig,
|
|
15
16
|
getAgentsDirForAgent,
|
|
@@ -83,28 +84,20 @@ export function getAgentContent(agentName) {
|
|
|
83
84
|
* @returns {Object} Parsed frontmatter fields
|
|
84
85
|
*/
|
|
85
86
|
export function parseAgentFrontmatter(content) {
|
|
86
|
-
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
87
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
87
88
|
if (!frontmatterMatch) {
|
|
88
89
|
return {};
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (value.startsWith('[') && value.endsWith(']')) {
|
|
100
|
-
frontmatter[key] = value.slice(1, -1).split(',').map(s => s.trim().replace(/"/g, ''));
|
|
101
|
-
} else {
|
|
102
|
-
frontmatter[key] = value.trim();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
92
|
+
// The agent files are YAML: `description: |` is a block, `expertise:` is a list. A line-by-line `key: value`
|
|
93
|
+
// reader saw the description as the single character `|` and dropped every list, so `uds agent list` and
|
|
94
|
+
// `uds agent info` showed an empty description and no expertise, tools or skills.
|
|
95
|
+
try {
|
|
96
|
+
const parsed = yaml.load(frontmatterMatch[1]);
|
|
97
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
|
|
98
|
+
} catch {
|
|
99
|
+
return {};
|
|
105
100
|
}
|
|
106
|
-
|
|
107
|
-
return frontmatter;
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
/**
|