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
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
//
|
|
8
8
|
// What it finds, in the test files of any project (no test framework is assumed):
|
|
9
9
|
// no-assertion a test whose body contains nothing that can fail
|
|
10
|
-
// tautology a test whose only assertions can never fail (expect(true).toBe(true))
|
|
10
|
+
// tautology a test whose only assertions can never fail (expect(true).toBe(true)), or whose
|
|
11
|
+
// expected value is not independent of the code under test (XSPEC-470): the
|
|
12
|
+
// assertion calls the same function with the same arguments on both sides, or
|
|
13
|
+
// recomputes the expected value from the same input with reduce/map/filter.
|
|
14
|
+
// (JavaScript/TypeScript only; other languages are a reviewer's judgment call.)
|
|
11
15
|
// all-skipped a test file in which every test is skipped or marked todo
|
|
12
16
|
//
|
|
13
17
|
// Written into your project by `uds init` (XSPEC-444 R5). It is YOURS: edit it, or replace
|
|
@@ -814,12 +818,254 @@ const countMatches = (re, s) => {
|
|
|
814
818
|
return n;
|
|
815
819
|
};
|
|
816
820
|
|
|
821
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
822
|
+
// Expected values that are not independent of the code under test (XSPEC-470 R1)
|
|
823
|
+
//
|
|
824
|
+
// An oracle is the source that says what the right answer is (UDS `verification-oracle`).
|
|
825
|
+
// A test whose expected value is produced by the code under test — or by the same logic re-typed
|
|
826
|
+
// in the test — has the implementation as its own oracle, so it cannot disagree with it. Two
|
|
827
|
+
// shapes are mechanical enough to judge from text, and they are the only ones judged here:
|
|
828
|
+
//
|
|
829
|
+
// same-call expect(total(items)).toBe(total(items)) same function, same arguments, both sides
|
|
830
|
+
// recomputed expect(total(items)).toBe(items.reduce(...)) expected value is built from the same
|
|
831
|
+
// input with reduce / map / flatMap / filter
|
|
832
|
+
// by a callback that uses nothing but its own
|
|
833
|
+
// parameters (and pure built-ins), holds no
|
|
834
|
+
// literal and is not just `(x) => x` / `({ ...x })`.
|
|
835
|
+
// Only the text of the assertion is read: a name set
|
|
836
|
+
// on an earlier line is not looked through.
|
|
837
|
+
//
|
|
838
|
+
// Left alone on purpose, because they cannot be told from a sound test by reading the text:
|
|
839
|
+
// a lookup in a fixed table expect(priceOf(ids)).toEqual(ids.map((id) => KNOWN_PRICES[id]))
|
|
840
|
+
// a pick by a literal expect(activeOf(users)).toEqual(users.filter((u) => u.id === 2))
|
|
841
|
+
// a call inside the call expect(render(now())).toBe(render(now())) (two now() are two values)
|
|
842
|
+
// expect(parse(serialize(rows))).toEqual(rows.map((r) => r)) (a round trip)
|
|
843
|
+
// a property of the result expect(sortUsers(users).length).toBe(users.filter((u) => u.name).length)
|
|
844
|
+
// a callback that only returns expect(clone(input)).toEqual(input.map((x) => x)) (a copy, no logic)
|
|
845
|
+
// or shallow-copies its input expect(clone(users)).toEqual(users.map((u) => ({ ...u })))
|
|
846
|
+
// or rebuilds a destructured expect(clone(pairs)).toEqual(pairs.map(([k, v]) => [k, v]))
|
|
847
|
+
// parameter in the same shape
|
|
848
|
+
// a name set on an earlier line const before = items.map((i) => i.price); freezeCart(items);
|
|
849
|
+
// expect(pricesOf(items)).toEqual(before) (before / after)
|
|
850
|
+
// Everything else (a hand-rolled loop, a helper that re-derives the answer, a snapshot taken from
|
|
851
|
+
// the implementation's own output) is a reviewer's question, not this script's: when it cannot be
|
|
852
|
+
// decided from the text, it is NOT reported. A false alarm teaches people to switch the scanner off.
|
|
853
|
+
// Deliberately narrow: JavaScript/TypeScript matchers toBe / toEqual / toStrictEqual, chai
|
|
854
|
+
// to.equal / to.eql, node assert.equal / strictEqual / deepEqual / deepStrictEqual.
|
|
855
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
856
|
+
|
|
857
|
+
/** A test named like this compares two calls ON PURPOSE (determinism, caching, identity): not judged. */
|
|
858
|
+
const DELIBERATE_COMPARISON_NAME = /determinis|idempot|\bsame\b|identical|\bstable\b|stability|consisten|\bcach(?:e|es|ed|ing)\b|memo|singleton|twice|repeat|\bagain\b|reuse|reference|identity|\bpure\b|決定|確定性|相同|一致|同一|冪等|快取|重複|兩次|不變/i;
|
|
859
|
+
|
|
860
|
+
const SKIP_WORDS = new Set(['true', 'false', 'null', 'undefined', 'this', 'new', 'typeof', 'void', 'await', 'async', 'function', 'return']);
|
|
861
|
+
|
|
862
|
+
/** Top-level (bracket-depth 0) comma-separated pieces of `ns[from, to)`, as [start, end) pairs. */
|
|
863
|
+
function topLevelPieces(ns, from, to) {
|
|
864
|
+
const out = [];
|
|
865
|
+
let depth = 0;
|
|
866
|
+
let begin = from;
|
|
867
|
+
for (let i = from; i < to; i++) {
|
|
868
|
+
const ch = ns[i];
|
|
869
|
+
if (ch === '(' || ch === '[' || ch === '{') depth++;
|
|
870
|
+
else if (ch === ')' || ch === ']' || ch === '}') depth--;
|
|
871
|
+
else if (ch === ',' && depth === 0) { out.push([begin, i]); begin = i + 1; }
|
|
872
|
+
}
|
|
873
|
+
out.push([begin, to]);
|
|
874
|
+
return out.filter(([a, b]) => ns.slice(a, b).trim() !== '');
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** Canonical form for "is this the same expression?": no `await`, no spacing, no trailing comma. */
|
|
878
|
+
const canonicalExpr = (s) => s
|
|
879
|
+
.replace(/^\s*await\s+/, '')
|
|
880
|
+
.replace(/\s+/g, ' ')
|
|
881
|
+
.replace(/\s*([(),.\[\]])\s*/g, '$1')
|
|
882
|
+
.replace(/,\)/g, ')')
|
|
883
|
+
.trim()
|
|
884
|
+
.replace(/,$/, '');
|
|
885
|
+
|
|
886
|
+
/** Does this canonical expression call something with at least one argument (and is not a `new` expression)? */
|
|
887
|
+
const callsWithArguments = (expr) => !/^new\b/.test(expr) && /[A-Za-z_$][\w$]*\(['"`\w$\[{(-]/.test(expr);
|
|
888
|
+
|
|
889
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
890
|
+
|
|
891
|
+
/** If `ns` (canonical, strings blanked) is exactly `callee(args)` (nothing after it), the identifier paths used in args. */
|
|
892
|
+
function callInputs(ns) {
|
|
893
|
+
const m = /^([A-Za-z_$][\w$.]*)\(/.exec(ns);
|
|
894
|
+
if (!m || /^new\b/.test(ns)) return null;
|
|
895
|
+
const open = m[0].length - 1;
|
|
896
|
+
const close = matchClose(ns, open);
|
|
897
|
+
if (close === -1) return null;
|
|
898
|
+
// Something after the call (`.length`, `.name`, `[0]`) means the value under test is a property of the result,
|
|
899
|
+
// not the result: the expected value on the other side is then not "the same computation", and which of the
|
|
900
|
+
// two is right cannot be read from the text. Not judged.
|
|
901
|
+
if (ns.slice(close + 1) !== '') return null;
|
|
902
|
+
const args = ns.slice(open + 1, close);
|
|
903
|
+
const paths = new Set();
|
|
904
|
+
const re = /(?<![\w$.])([A-Za-z_$][\w$]*(?:(?:\?\.|\.)[A-Za-z_$][\w$]*)*)(?!\w|\$)(?!\()/g;
|
|
905
|
+
let p;
|
|
906
|
+
while ((p = re.exec(args)) !== null) if (!SKIP_WORDS.has(p[1])) paths.add(p[1]);
|
|
907
|
+
return [...paths];
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/** Words that can appear in a callback body without naming anything outside it. */
|
|
911
|
+
const CALLBACK_KEYWORDS = new Set(['return', 'if', 'else', 'typeof', 'void', 'in', 'of', 'instanceof', 'const', 'let', 'var', 'for', 'while', 'do', 'switch', 'case', 'break', 'continue', 'default']);
|
|
912
|
+
/** Built-ins that compute from their arguments only, so using them does not bring in anything from outside the callback. */
|
|
913
|
+
const CALLBACK_GLOBALS = new Set(['Math', 'Number', 'String', 'Boolean', 'Array', 'Object', 'JSON', 'Infinity', 'NaN', 'parseInt', 'parseFloat']);
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Is this callback "the same logic re-typed in the test"? Only when it is self-contained: it uses nothing but
|
|
917
|
+
* its own parameters (so it cannot be looking an answer up in a table, a constant or a helper the test brings in)
|
|
918
|
+
* and it holds no literal (a literal inside the callback is knowledge the test author supplied: `u.id === 2`,
|
|
919
|
+
* `x * 2`, `'abc'`, `/re/`). Anything else is not decidable from text, and what is not decidable is not reported.
|
|
920
|
+
* @param {string} arg the callback as written (strings blanked), e.g. `(s, i) => s + i.price`
|
|
921
|
+
*/
|
|
922
|
+
function isSelfContainedCallback(arg) {
|
|
923
|
+
let params;
|
|
924
|
+
let body;
|
|
925
|
+
const arrow = /^(?:async\s*)?(?:\(([^()]*)\)|([A-Za-z_$][\w$]*))\s*=>\s*([\s\S]*)$/.exec(arg.trim());
|
|
926
|
+
const fn = /^(?:async\s*)?function\s*[A-Za-z_$]*\s*\(([^()]*)\)\s*\{([\s\S]*)\}$/.exec(arg.trim());
|
|
927
|
+
if (arrow) {
|
|
928
|
+
params = arrow[1] ?? arrow[2];
|
|
929
|
+
body = arrow[3].trim();
|
|
930
|
+
if (body.startsWith('{')) {
|
|
931
|
+
const close = matchClose(body, 0);
|
|
932
|
+
if (close !== body.length - 1) return false;
|
|
933
|
+
body = body.slice(1, close);
|
|
934
|
+
}
|
|
935
|
+
} else if (fn) {
|
|
936
|
+
params = fn[1];
|
|
937
|
+
body = fn[2];
|
|
938
|
+
} else {
|
|
939
|
+
return false; // a named function, or a shape not understood: not judged
|
|
940
|
+
}
|
|
941
|
+
if (params.includes('=')) return false; // default values can call anything
|
|
942
|
+
// A callback that only hands its parameter back (`(r) => r`, `x => { return x; }`) computes nothing, so
|
|
943
|
+
// there is no logic in it that could be "the same as the implementation".
|
|
944
|
+
const only = body.replace(/^\s*return\b/, '').replace(/[;\s]+$/g, '').replace(/^\s*\(\s*|\s*\)\s*$/g, '').trim();
|
|
945
|
+
// A destructured parameter put straight back into the same shape (`([k, v]) => [k, v]`, `({ a, b }) => ({ a, b })`)
|
|
946
|
+
// is a copy as well: the body is the parameter list itself.
|
|
947
|
+
if (/[{[]/.test(params) && only.replace(/\s+/g, '') === params.replace(/\s+/g, '')) return false;
|
|
948
|
+
if (!/[{[]/.test(params)) {
|
|
949
|
+
// A shallow copy of the parameter (`{ ...u }`, `[...u]`) is a copy, not logic: the same family as the identity callback.
|
|
950
|
+
const copied = /^[{[]\s*\.\.\.\s*([A-Za-z_$][\w$]*)\s*[}\]]$/.exec(only);
|
|
951
|
+
if (copied && new RegExp(`(?<![\\w$])${escapeRe(copied[1])}(?![\\w$])`).test(params)) return false;
|
|
952
|
+
if (/^[A-Za-z_$][\w$]*$/.test(only) && new RegExp(`(?<![\\w$])${escapeRe(only)}(?![\\w$])`).test(params)) return false;
|
|
953
|
+
}
|
|
954
|
+
if (/['"`]/.test(body)) return false; // a string literal (their contents are blanked, their quotes are not)
|
|
955
|
+
if (/(?<![\w$.])\d|(?<=\.)\d/.test(body)) return false; // a number literal
|
|
956
|
+
if (/(?:^|[(,=:[!&|?{};>+\-*%<~^]|\breturn\b)\s*\//.test(body)) return false; // a regex literal
|
|
957
|
+
if (/\b(?:true|false|null|undefined)\b/.test(body)) return false; // a keyword literal
|
|
958
|
+
if (/\b(?:this|arguments|new|await|yield|function)\b|=>/.test(body)) return false; // outside state, or a nested function
|
|
959
|
+
const known = new Set([...params.matchAll(/[A-Za-z_$][\w$]*/g)].map((m) => m[0]));
|
|
960
|
+
for (const d of body.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g)) known.add(d[1]);
|
|
961
|
+
for (const id of body.matchAll(/(?<![\w$.])(?<!\?\.)([A-Za-z_$][\w$]*)/g)) {
|
|
962
|
+
const name = id[1];
|
|
963
|
+
if (!known.has(name) && !CALLBACK_KEYWORDS.has(name) && !CALLBACK_GLOBALS.has(name)) return false; // something from outside the callback
|
|
964
|
+
}
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/** Is `rhs` the input `x` run through reduce / map / flatMap / filter by a callback that re-types the logic (see above)? */
|
|
969
|
+
function recomputesFrom(rhs, x) {
|
|
970
|
+
const X = escapeRe(x).replace(/\\\./g, '(?:\\?\\.|\\.)');
|
|
971
|
+
const source = `(?:${X}|\\[\\.\\.\\.${X}\\]|Object\\.(?:values|keys|entries)\\(${X}\\)|Array\\.from\\(${X}\\))`;
|
|
972
|
+
const verb = '(?:reduce|reduceRight|map|flatMap|filter)(?:<[^>()]*>)?\\(';
|
|
973
|
+
const re = new RegExp(`(?<![\\w$.])${source}(?:\\?\\.|\\.)${verb}`, 'g');
|
|
974
|
+
for (const m of rhs.matchAll(re)) {
|
|
975
|
+
const open = m.index + m[0].length - 1;
|
|
976
|
+
const close = matchClose(rhs, open);
|
|
977
|
+
if (close === -1) continue;
|
|
978
|
+
const [callback] = topLevelPieces(rhs, open + 1, close);
|
|
979
|
+
if (callback && isSelfContainedCallback(rhs.slice(callback[0], callback[1]))) return true;
|
|
980
|
+
}
|
|
981
|
+
return false;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* The assertions in one test body whose expected value is not independent.
|
|
986
|
+
* @param {string} ncBody the body with comments blanked (strings intact)
|
|
987
|
+
* @param {string} nsBody the same body with comments AND string contents blanked (same offsets)
|
|
988
|
+
* @param {string} testName
|
|
989
|
+
* @returns {{ form: 'same-call'|'recomputed', offset: number }[]}
|
|
990
|
+
*/
|
|
991
|
+
export function findNonIndependentExpectations(ncBody, nsBody, testName = '') {
|
|
992
|
+
const hits = [];
|
|
993
|
+
const judge = (lhsFrom, lhsTo, rhsFrom, rhsTo, offset) => {
|
|
994
|
+
const rawL = canonicalExpr(ncBody.slice(lhsFrom, lhsTo));
|
|
995
|
+
const rawR = canonicalExpr(ncBody.slice(rhsFrom, rhsTo));
|
|
996
|
+
if (rawL === rawR && !callsWithArguments(rawL)) return; // `x` against `x`: the literal rule above counts it
|
|
997
|
+
// same-call is judged on the text as written. A name set earlier (`const before = snapshot(x)`) holds the
|
|
998
|
+
// value from an EARLIER moment: `expect(snapshot(x)).toEqual(before)` after an action asks "did it change?",
|
|
999
|
+
// which is a real question. Only two calls inside one statement cannot differ in time.
|
|
1000
|
+
if (rawL === rawR && callsWithArguments(rawL)) {
|
|
1001
|
+
// Another call inside the expression (`render(now())`, `total(load())`) may return something different the
|
|
1002
|
+
// second time, so the two sides are not known to be the same value: not judged.
|
|
1003
|
+
const callCount = (canonicalExpr(nsBody.slice(lhsFrom, lhsTo)).match(/[A-Za-z_$][\w$]*\(/g) || []).length;
|
|
1004
|
+
const hasNew = /\bnew\b/.test(canonicalExpr(nsBody.slice(lhsFrom, lhsTo)));
|
|
1005
|
+
if (callCount <= 1 && !hasNew && !DELIBERATE_COMPARISON_NAME.test(testName)) hits.push({ form: 'same-call', offset });
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
// Only the text of the assertion itself is read. A name set on an earlier line (`const before = items.map(...)`)
|
|
1009
|
+
// holds a value from an EARLIER moment, and what happened in between (`freezeCart(items)`, `users.push(x)`)
|
|
1010
|
+
// is exactly what such a test is asking about, so a name is never expanded here (same-call reads it the same way).
|
|
1011
|
+
const l = { ns: canonicalExpr(nsBody.slice(lhsFrom, lhsTo)) };
|
|
1012
|
+
const r = { ns: canonicalExpr(nsBody.slice(rhsFrom, rhsTo)) };
|
|
1013
|
+
// Same guard as same-call: another call (or `new`) inside the call under test (`parse(serialize(rows))`) is a
|
|
1014
|
+
// round trip or a pipeline, not the implementation's own arithmetic typed again. Not judged.
|
|
1015
|
+
if ((l.ns.match(/[A-Za-z_$][\w$]*\(/g) || []).length > 1 || /\bnew\b/.test(l.ns)) return;
|
|
1016
|
+
const inputs = callInputs(l.ns);
|
|
1017
|
+
if (inputs && inputs.some((x) => recomputesFrom(r.ns, x))) hits.push({ form: 'recomputed', offset });
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
const expectRe = /(?<![.\w$])expect\s*\(/g;
|
|
1021
|
+
let m;
|
|
1022
|
+
while ((m = expectRe.exec(nsBody)) !== null) {
|
|
1023
|
+
const open = m.index + m[0].length - 1;
|
|
1024
|
+
const close = matchClose(nsBody, open);
|
|
1025
|
+
if (close === -1) continue;
|
|
1026
|
+
const after = /^\s*\.\s*(?:(?:toBe|toEqual|toStrictEqual)|to\s*\.\s*(?:deep\s*\.\s*)?(?:equal|equals|eql))\s*\(/.exec(nsBody.slice(close + 1, close + 60));
|
|
1027
|
+
if (!after) continue; // `.not.`, `.resolves`, `.toThrow`, ... are not judged
|
|
1028
|
+
const mOpen = close + 1 + after[0].length - 1;
|
|
1029
|
+
const mClose = matchClose(nsBody, mOpen);
|
|
1030
|
+
if (mClose === -1) continue;
|
|
1031
|
+
const [first] = topLevelPieces(nsBody, mOpen + 1, mClose);
|
|
1032
|
+
if (!first) continue;
|
|
1033
|
+
judge(open + 1, close, first[0], first[1], m.index);
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
const assertRe = /(?<![.\w$])assert\s*\.\s*(?:equal|strictEqual|deepEqual|deepStrictEqual)\s*\(/g;
|
|
1037
|
+
while ((m = assertRe.exec(nsBody)) !== null) {
|
|
1038
|
+
const open = m.index + m[0].length - 1;
|
|
1039
|
+
const close = matchClose(nsBody, open);
|
|
1040
|
+
if (close === -1) continue;
|
|
1041
|
+
const pieces = topLevelPieces(nsBody, open + 1, close);
|
|
1042
|
+
if (pieces.length < 2) continue;
|
|
1043
|
+
judge(pieces[0][0], pieces[0][1], pieces[1][0], pieces[1][1], m.index);
|
|
1044
|
+
}
|
|
1045
|
+
return hits;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* The independence detectors, by language family. `count` is what analyzeTestText subtracts from the
|
|
1050
|
+
* assertions it credits; `find` says which assertions and why. Passed in (not read from a global) so a
|
|
1051
|
+
* test can hand the scanner a weakened set and watch the self-test and the samples catch it.
|
|
1052
|
+
*/
|
|
1053
|
+
export const INDEPENDENCE_DETECTORS = Object.freeze({
|
|
1054
|
+
count: (family, ncBody, nsBody, testName) => (family === 'js' ? findNonIndependentExpectations(ncBody, nsBody, testName).length : 0),
|
|
1055
|
+
find: (family, ncBody, nsBody, testName) => (family === 'js' ? findNonIndependentExpectations(ncBody, nsBody, testName) : [])
|
|
1056
|
+
});
|
|
1057
|
+
|
|
1058
|
+
const FORM_DETAIL = {
|
|
1059
|
+
'same-call': 'the expected value is the same call as the code under test (same function, same arguments)',
|
|
1060
|
+
recomputed: 'the expected value is recomputed from the same input as the code under test (reduce/map/filter with a callback that uses only its own parameters), so it is not an independent oracle'
|
|
1061
|
+
};
|
|
1062
|
+
|
|
817
1063
|
/**
|
|
818
1064
|
* Analyze one test file's text.
|
|
819
1065
|
* @returns {{ family: string|null, cases: number, skipped: number, unparsed: number,
|
|
820
1066
|
* findings: { rule: string, line: number|null, name: string, detail: string }[] }}
|
|
821
1067
|
*/
|
|
822
|
-
export function analyzeTestText(text, ext, extraAssertion = []) {
|
|
1068
|
+
export function analyzeTestText(text, ext, extraAssertion = [], detectors = INDEPENDENCE_DETECTORS) {
|
|
823
1069
|
const family = FAMILY_BY_EXT[ext] || null;
|
|
824
1070
|
const rules = family && FAMILY_RULES[family];
|
|
825
1071
|
if (!rules) return { family: null, cases: 0, skipped: 0, unparsed: 0, findings: [] };
|
|
@@ -836,11 +1082,25 @@ export function analyzeTestText(text, ext, extraAssertion = []) {
|
|
|
836
1082
|
for (const re of extraAssertion) tokens += countMatches(re, nsBody);
|
|
837
1083
|
let taut = 0;
|
|
838
1084
|
for (const re of rules.taut) taut += countMatches(re, ncBody);
|
|
1085
|
+
const regexTaut = taut;
|
|
1086
|
+
taut += detectors.count(family, ncBody, nsBody, c.name);
|
|
839
1087
|
const real = Math.max(0, tokens - taut) + c.credit;
|
|
840
1088
|
if (real > 0) continue;
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1089
|
+
if (taut === 0) {
|
|
1090
|
+
findings.push({ rule: 'no-assertion', line: lineOf(c.idx), name: c.name, detail: 'the body contains nothing that can fail an assertion' });
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
const hits = detectors.find(family, ncBody, nsBody, c.name);
|
|
1094
|
+
const forms = [...new Set(hits.map((h) => h.form))];
|
|
1095
|
+
const finding = { rule: 'tautology', line: lineOf(c.idx), name: c.name, detail: 'its only assertion(s) can never fail' };
|
|
1096
|
+
if (forms.length > 0) {
|
|
1097
|
+
const parts = forms.map((f) => FORM_DETAIL[f]);
|
|
1098
|
+
if (regexTaut > 0) parts.unshift('an assertion that can never fail');
|
|
1099
|
+
finding.detail = `its only assertion(s) are not independent of the code under test: ${parts.join('; ')} (see verification-oracle)`;
|
|
1100
|
+
finding.forms = forms;
|
|
1101
|
+
finding.assertions = hits.map((h) => ({ line: lineOf(c.bodyStart + h.offset), form: h.form }));
|
|
1102
|
+
}
|
|
1103
|
+
findings.push(finding);
|
|
844
1104
|
}
|
|
845
1105
|
if (cases.length > 0 && skipped === cases.length) {
|
|
846
1106
|
findings.push({ rule: 'all-skipped', line: null, name: '(file)', detail: `every test in this file is skipped or todo (${skipped})` });
|
|
@@ -860,6 +1120,46 @@ const SELF_TEST = [
|
|
|
860
1120
|
{ ext: 'js', rules: [], text: "it('adds', () => { expect(add(1, 2)).toBe(3); });\ntest('t', async () => { await expect(f()).rejects.toThrow(); });\n" },
|
|
861
1121
|
{ ext: 'js', rules: ['all-skipped'], text: "it.skip('a', () => { expect(1).toBe(2); });\nit.todo('b');\n" },
|
|
862
1122
|
{ ext: 'js', rules: ['no-assertion'], text: "it('commented out', () => {\n // expect(a).toBe(b);\n const s = \"expect(a).toBe(b)\";\n});\n" },
|
|
1123
|
+
// XSPEC-470: an expected value that is not independent of the code under test.
|
|
1124
|
+
{ ext: 'js', rules: ['tautology'], text: "it('totals', () => { expect(calculateTotal(items)).toBe(calculateTotal(items)); });\n" },
|
|
1125
|
+
{ ext: 'js', rules: ['tautology'], text: "it('totals', () => { expect(calculateTotal(items)).toBe(items.reduce((s, i) => s + i.price, 0)); });\n" },
|
|
1126
|
+
{ ext: 'js', rules: ['tautology'], text: "it('names', () => { expect(namesOf(users)).toEqual(users.map((u) => u.name)); });\n" },
|
|
1127
|
+
// A name set on an earlier line is a value from an earlier moment: never looked through (XSPEC-470, third review).
|
|
1128
|
+
{ ext: 'js', rules: [], text: "it('totals', () => {\n const expected = items.reduce((s, i) => s + i.price, 0);\n expect(calculateTotal(items)).toBe(expected);\n});\n" },
|
|
1129
|
+
{ ext: 'js', rules: [], text: "it('freezing changes no price', () => {\n const before = items.map((i) => i.price);\n freezeCart(items);\n expect(pricesOf(items)).toEqual(before);\n});\n" },
|
|
1130
|
+
{ ext: 'js', rules: [], text: "it('pushing a user keeps the old names', () => {\n const result = users.map((u) => u.name);\n users.push(extra);\n expect(namesOf(users)).toEqual(result);\n});\n" },
|
|
1131
|
+
{ ext: 'js', rules: [], text: "it('totals', () => { expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15); });\n" },
|
|
1132
|
+
{ ext: 'js', rules: [], text: "it('totals', () => { expect(calculateTotal(a)).toBe(calculateTotal(b)); });\n" },
|
|
1133
|
+
{ ext: 'js', rules: [], text: "it('totals', () => { expect(calculateTotal(cart)).toBe(items.reduce((s, i) => s + i.price, 0)); });\n" },
|
|
1134
|
+
{ ext: 'js', rules: [], text: "it('is deterministic', () => { expect(calculateTotal(items)).toBe(calculateTotal(items)); });\n" },
|
|
1135
|
+
{ ext: 'js', rules: [], text: "it('changes nothing', () => {\n const before = snapshot(dir);\n preview(dir);\n expect(snapshot(dir)).toEqual(before);\n});\n" },
|
|
1136
|
+
{ ext: 'js', rules: [], text: "it('totals', () => { expect(calculateTotal(items)).toBe(calculateTotal(items)); expect(calculateTotal([])).toBe(0); });\n" },
|
|
1137
|
+
{ ext: 'js', rules: [], text: "it('totals', () => { expect(calculateTotal(first)).not.toBe(calculateTotal(first)); });\n" },
|
|
1138
|
+
// XSPEC-470: look-alikes the rule must let through (the false alarms the first review measured).
|
|
1139
|
+
{ ext: 'js', rules: [], text: "it('prices', () => { expect(priceOf(ids)).toEqual(ids.map((id) => KNOWN_PRICES[id])); });\n" },
|
|
1140
|
+
{ ext: 'js', rules: [], text: "it('active', () => { expect(activeOf(users)).toEqual(users.filter((u) => u.id === 2)); });\n" },
|
|
1141
|
+
{ ext: 'js', rules: [], text: "it('renders', () => { expect(render(now())).toBe(render(now())); });\n" },
|
|
1142
|
+
// XSPEC-470: the second review's false alarms, and the neighbours of both rounds (all must stay silent).
|
|
1143
|
+
{ ext: 'js', rules: [], text: "it('round trip', () => { expect(parse(serialize(rows))).toEqual(rows.map((r) => r)); });\n" },
|
|
1144
|
+
{ ext: 'js', rules: [], text: "it('round trip, callback computes', () => { expect(parse(serialize(rows))).toEqual(rows.map((r) => r.id)); });\n" },
|
|
1145
|
+
{ ext: 'js', rules: [], text: "it('identity callback', () => { expect(clone(input)).toEqual(input.map((x) => x)); });\n" },
|
|
1146
|
+
{ ext: 'js', rules: [], text: "it('shallow copy callback', () => { expect(clone(users)).toEqual(users.map((u) => ({ ...u }))); });\n" },
|
|
1147
|
+
{ ext: 'js', rules: [], text: "it('pairs put back', () => { expect(clone(pairs)).toEqual(pairs.map(([k, v]) => [k, v])); });\n" },
|
|
1148
|
+
{ ext: 'js', rules: [], text: "it('rows put back', () => { expect(clone(rows)).toEqual(rows.map(({ a, b }) => ({ a, b }))); });\n" },
|
|
1149
|
+
{ ext: 'js', rules: ['tautology'], text: "it('expected value wrapped', () => { expect(total(items)).toBe(Number(items.reduce((s, i) => s + i.price, 0))); });\n" },
|
|
1150
|
+
{ ext: 'js', rules: ['tautology'], text: "it('pairs swapped', () => { expect(flip(pairs)).toEqual(pairs.map(([k, v]) => [v, k])); });\n" },
|
|
1151
|
+
{ ext: 'js', rules: [], text: "it('shallow copy callback, block', () => { expect(clone(users)).toEqual(users.map((u) => { return { ...u }; })); });\n" },
|
|
1152
|
+
{ ext: 'js', rules: [], text: "it('property of the result', () => { expect(sortUsers(users).length).toBe(users.filter((u) => u.name).length); });\n" },
|
|
1153
|
+
{ ext: 'js', rules: [], text: "it('helper outside the callback', () => { expect(calculateTotal(items)).toBe(items.reduce((s, i) => s + priceOf(i), 0)); });\n" },
|
|
1154
|
+
{ ext: 'js', rules: [], text: "it('literal in the callback', () => { expect(doubled(xs)).toEqual(xs.map((x) => x * 2)); });\n" },
|
|
1155
|
+
{ ext: 'js', rules: [], text: "it('constant outside the callback', () => { expect(calculateTotal(items)).toBe(items.reduce((s, i) => s + i.price * TAX_RATE, 0)); });\n" },
|
|
1156
|
+
{ ext: 'js', rules: [], text: "it('new inside the call', () => { expect(render(new Date())).toBe(render(new Date())); });\n" },
|
|
1157
|
+
// ...and what must still be named after the narrowing.
|
|
1158
|
+
{ ext: 'js', rules: ['tautology'], text: "it('active', () => { assert.deepStrictEqual(activeOf(accounts), accounts.filter((a) => a.active)); });\n" },
|
|
1159
|
+
{ ext: 'js', rules: ['tautology'], text: "it('names', () => { expect(namesOf(users)).toEqual(users.map(({ name }) => name)); });\n" },
|
|
1160
|
+
{ ext: 'js', rules: ['tautology'], text: "it('destructured reduce', () => { expect(calculateTotal(items)).toBe(items.reduce((s, { price }) => s + price, 0)); });\n" },
|
|
1161
|
+
{ ext: 'js', rules: ['tautology'], text: "it('function expression', () => { expect(calculateTotal(items)).toBe(items.reduce(function (s, i) { return s + i.price; }, 0)); });\n" },
|
|
1162
|
+
{ ext: 'js', rules: ['tautology'], text: "it('block arrow', () => { expect(calculateTotal(items)).toBe(items.reduce((s, i) => { return s + i.qty * i.price; }, 0)); });\n" },
|
|
863
1163
|
{ ext: 'py', rules: ['no-assertion'], text: "def test_nothing():\n x = 1\n pass\n" },
|
|
864
1164
|
{ ext: 'py', rules: ['tautology'], text: "def test_true():\n assert True\n" },
|
|
865
1165
|
{ ext: 'py', rules: [], text: "def test_ok():\n assert add(1, 2) == 3\n\n\ndef test_raises():\n with pytest.raises(ValueError):\n f()\n" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "universal-dev-standards",
|
|
3
|
-
"version": "6.14.0-beta.
|
|
3
|
+
"version": "6.14.0-beta.8",
|
|
4
4
|
"description": "CLI tool for adopting Universal Development Standards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"documentation",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"check:bundle-parity": "node scripts/check-bundle-parity.mjs",
|
|
59
59
|
"prepack": "node scripts/prepack.mjs",
|
|
60
60
|
"check:reachability": "node scripts/check-module-reachability.mjs",
|
|
61
|
+
"check:orphan-matrix": "node scripts/check-standards-orphan-matrix.mjs",
|
|
62
|
+
"check:plugin-manifest": "node scripts/check-plugin-manifest.mjs",
|
|
61
63
|
"check:command-existence": "node scripts/check-command-existence.mjs",
|
|
62
64
|
"check:effect-boundary": "node scripts/check-effect-boundary.mjs",
|
|
63
65
|
"check:effect-boundary:self-test": "node scripts/check-effect-boundary.mjs --self-test"
|
package/src/commands/audit.js
CHANGED
|
@@ -298,7 +298,9 @@ function outputTerminal(auditResult, msg) {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
// Report hint
|
|
301
|
-
|
|
301
|
+
// The available-standards finding is not feedback for UDS (see handleReport), so it alone does not earn the hint.
|
|
302
|
+
const reportable = totalFindings - (auditResult.frictions || []).filter(f => f.type === 'not-installed').length;
|
|
303
|
+
if (reportable > 0 && !auditResult._isReport) {
|
|
302
304
|
console.log();
|
|
303
305
|
console.log(chalk.gray('Submit feedback: uds audit --report'));
|
|
304
306
|
}
|
|
@@ -382,6 +384,9 @@ async function handleReport(auditResult, options, msg) {
|
|
|
382
384
|
|
|
383
385
|
if (auditResult.frictions) {
|
|
384
386
|
for (const friction of auditResult.frictions) {
|
|
387
|
+
// "N available standards not installed" is this project's choice to make, not a defect in a UDS
|
|
388
|
+
// standard: it is not feedback for the maintainers, and `--report --yes` would file it as one.
|
|
389
|
+
if (friction.type === 'not-installed') continue;
|
|
385
390
|
findings.push({
|
|
386
391
|
name: `[Friction] ${friction.standard} — ${friction.type}`,
|
|
387
392
|
value: { type: 'friction', data: friction },
|
|
@@ -391,7 +396,9 @@ async function handleReport(auditResult, options, msg) {
|
|
|
391
396
|
}
|
|
392
397
|
|
|
393
398
|
if (findings.length === 0) {
|
|
394
|
-
|
|
399
|
+
// Not "no issues": the audit above may have listed the available-standards finding, which is not sent.
|
|
400
|
+
const heldBack = (auditResult.frictions || []).some(f => f.type === 'not-installed');
|
|
401
|
+
console.log(chalk.gray(heldBack ? t().availableStandards.reportHeldBack : (msg.noFindings || 'No findings to report.')));
|
|
395
402
|
return;
|
|
396
403
|
}
|
|
397
404
|
|
package/src/commands/check.js
CHANGED
|
@@ -50,6 +50,9 @@ import { runTestChangeCheck } from '../utils/test-change-check.js';
|
|
|
50
50
|
import { runTestQualityGates } from '../utils/gate-scripts.js';
|
|
51
51
|
import { pruneForeignSkillHashes, skillIssuesOf } from '../utils/skill-hash-ownership.js';
|
|
52
52
|
import { pruneForeignCommandHashes, projectCommandHashes, commandIssuesOf } from '../utils/command-hash-ownership.js';
|
|
53
|
+
import { printAvailableStandardsCheckLine } from '../utils/available-standards-report.js';
|
|
54
|
+
import { printDoubleInstallWarning } from '../utils/skills-install-paths.js';
|
|
55
|
+
import { printSkillNameCollisionWarning } from '../utils/skill-name-collision.js';
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
* Display the summary of file integrity status
|
|
@@ -536,9 +539,23 @@ export async function checkCommand(options = {}) {
|
|
|
536
539
|
// Skills status
|
|
537
540
|
const { missingSkills, missingCommands } = displaySkillsStatus(manifest, projectPath, msg);
|
|
538
541
|
|
|
542
|
+
// XSPEC-462 R2: the project has UDS skills AND the UDS plugin is installed, so each skill shows up twice.
|
|
543
|
+
// One warning, information only: it is not part of `allGood` below, so it changes neither the verdict nor
|
|
544
|
+
// the exit code. It says nothing when either side is missing or the plugin record cannot be read.
|
|
545
|
+
printDoubleInstallWarning(projectPath, getMarketplaceSkillsInfo());
|
|
546
|
+
|
|
547
|
+
// XSPEC-465 R1: a personal skill (~/.claude/skills/) with the same name as a UDS skill in this project wins
|
|
548
|
+
// silently. One warning, information only (not part of `allGood`): same verdict and exit code with or without
|
|
549
|
+
// it. It reads the personal folder every run; it cannot see the enterprise level, so no warning is not proof.
|
|
550
|
+
printSkillNameCollisionWarning(projectPath);
|
|
551
|
+
|
|
539
552
|
// Coverage report
|
|
540
553
|
displayCoverageReport(manifest, msg, common, projectPath);
|
|
541
554
|
|
|
555
|
+
// XSPEC-458 R5: one line about standards UDS ships that this project does not have. Information only:
|
|
556
|
+
// it is not part of `allGood` below, so it can change neither the verdict nor the exit code.
|
|
557
|
+
printAvailableStandardsCheckLine(manifest);
|
|
558
|
+
|
|
542
559
|
// XSPEC-178: Full coverage compliance check
|
|
543
560
|
checkFullCoverageCompliance(manifest, projectPath);
|
|
544
561
|
|
package/src/commands/hitl.js
CHANGED
|
@@ -7,16 +7,19 @@ const MAX_OP_LENGTH = 500;
|
|
|
7
7
|
export async function hitlCommand(options) {
|
|
8
8
|
if (!options.op) {
|
|
9
9
|
console.error(chalk.red('Error: --op <operation> is required'));
|
|
10
|
+
process.exit(2); // not 0: a caller that reads the exit code must not take a missing question for "allowed"
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const op = String(options.op).trim();
|
|
14
15
|
if (op.length === 0) {
|
|
15
16
|
console.error(chalk.red('Error: --op must not be empty'));
|
|
17
|
+
process.exit(2);
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
20
|
if (op.length > MAX_OP_LENGTH) {
|
|
19
21
|
console.error(chalk.red(`Error: --op must be ≤ ${MAX_OP_LENGTH} characters (got ${op.length})`));
|
|
22
|
+
process.exit(2);
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
22
25
|
|
package/src/commands/init.js
CHANGED
|
@@ -14,10 +14,13 @@ import { runInitFlow } from '../flows/init-flow.js';
|
|
|
14
14
|
import { installStandards } from '../installers/standards-installer.js';
|
|
15
15
|
import { installIntegrations, generateUniversalAgentsMd } from '../installers/integration-installer.js';
|
|
16
16
|
import { installSkills, installCommands } from '../installers/skills-installer.js';
|
|
17
|
+
import { printSkillNameCollisionWarning } from '../utils/skill-name-collision.js';
|
|
18
|
+
import { printDoubleInstallWarning } from '../utils/skills-install-paths.js';
|
|
17
19
|
import { writeFinalManifest } from '../installers/manifest-installer.js';
|
|
18
20
|
import {
|
|
19
21
|
getInstalledSkillsInfo,
|
|
20
22
|
getProjectInstalledSkillsInfo,
|
|
23
|
+
getMarketplaceSkillsInfo,
|
|
21
24
|
getAgentConfig,
|
|
22
25
|
getAgentDisplayName
|
|
23
26
|
} from '../utils/github.js';
|
|
@@ -364,6 +367,28 @@ export async function initCommand(options) {
|
|
|
364
367
|
}
|
|
365
368
|
persistRecorder(projectPath, installRecorder);
|
|
366
369
|
|
|
370
|
+
// 4.9. XSPEC-465 R1: tell the adopter now if a personal skill of theirs has the same name as a UDS skill
|
|
371
|
+
// that was just installed (the personal one wins, with no error). Information only: it does not change
|
|
372
|
+
// what was installed or the exit code.
|
|
373
|
+
if ((combinedResults?.skills?.length ?? 0) > 0) {
|
|
374
|
+
// XSPEC-468 R1: skills now go into the project by default, so a project whose owner already has the UDS
|
|
375
|
+
// plugin would list every skill twice. Same warning `uds check` prints (XSPEC-462 R2); information only,
|
|
376
|
+
// it changes neither what was installed nor the exit code.
|
|
377
|
+
printDoubleInstallWarning(projectPath, getMarketplaceSkillsInfo());
|
|
378
|
+
printSkillNameCollisionWarning(projectPath);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// 4.95. XSPEC-468 R1: the adopter asked for the plugin by name, so no skill file was written. Say so at the
|
|
382
|
+
// end, where they look for the skills, and say where they come from and what the other way would do.
|
|
383
|
+
if (config.skillsConfig.location === 'marketplace') {
|
|
384
|
+
console.log();
|
|
385
|
+
console.log(chalk.cyan(msg.skillsFromPluginTitle));
|
|
386
|
+
for (const line of msg.skillsFromPluginLines) {
|
|
387
|
+
console.log(chalk.gray(` ${line}`));
|
|
388
|
+
}
|
|
389
|
+
console.log();
|
|
390
|
+
}
|
|
391
|
+
|
|
367
392
|
// 5. Setup Pre-commit Hook
|
|
368
393
|
await setupHuskyHook(projectPath);
|
|
369
394
|
|
|
@@ -741,30 +766,21 @@ function buildNonInteractiveConfig(options, detected, projectPath) {
|
|
|
741
766
|
return Boolean(config?.supportsSkills && config?.skills);
|
|
742
767
|
});
|
|
743
768
|
const hasSkillsCompatibleTool = skillsCapableTools.length > 0;
|
|
744
|
-
//
|
|
745
|
-
//
|
|
746
|
-
//
|
|
747
|
-
//
|
|
748
|
-
//
|
|
749
|
-
//
|
|
750
|
-
//
|
|
751
|
-
//
|
|
752
|
-
//
|
|
753
|
-
//
|
|
754
|
-
|
|
755
|
-
// nobody is left with a successful init and an empty directory.
|
|
756
|
-
const reachesMarketplace = t => {
|
|
757
|
-
const c = getAgentConfig(t);
|
|
758
|
-
return Boolean(c?.supportsMarketplace || c?.fallbackSkillsPath);
|
|
759
|
-
};
|
|
760
|
-
const onlySkillsCompatibleTools =
|
|
761
|
-
hasSkillsCompatibleTool && aiToolsNormalized.every(reachesMarketplace);
|
|
769
|
+
// XSPEC-468 R1: with no --skills-location, skills go INTO THE PROJECT (the main path, XSPEC-462).
|
|
770
|
+
// This used to pick 'marketplace' whenever every detected tool could reach Claude's plugin, which left
|
|
771
|
+
// `uds init --yes` with no `.claude/skills/` at all and told a new user to go and install a plugin: the
|
|
772
|
+
// opposite of the recommendation printed by `uds skills`. The plugin is still there for anyone who asks
|
|
773
|
+
// for it by name (`--skills-location marketplace`), and the plugin's limits are printed, not hidden.
|
|
774
|
+
//
|
|
775
|
+
// Two cases keep their old answer, and they are knowledge, not default:
|
|
776
|
+
// - tools were detected and none of them can take skills -> 'none' (nothing to install, said below);
|
|
777
|
+
// - nothing was detected at all -> 'project' with Claude Code's own project folder (the historical
|
|
778
|
+
// guess; see `noToolDetected` below).
|
|
779
|
+
const noToolDetected = aiToolsNormalized.length === 0;
|
|
762
780
|
|
|
763
781
|
let skillsLocationFlag = options.skillsLocation;
|
|
764
782
|
if (!skillsLocationFlag) {
|
|
765
|
-
skillsLocationFlag = hasSkillsCompatibleTool
|
|
766
|
-
? (onlySkillsCompatibleTools ? 'marketplace' : 'project')
|
|
767
|
-
: 'none';
|
|
783
|
+
skillsLocationFlag = (noToolDetected || hasSkillsCompatibleTool) ? 'project' : 'none';
|
|
768
784
|
}
|
|
769
785
|
|
|
770
786
|
// A detected tool that can take skills and is getting none must SAY SO. The worst
|
|
@@ -839,6 +855,10 @@ function buildNonInteractiveConfig(options, detected, projectPath) {
|
|
|
839
855
|
// `installSkills()` takes its legacy branch, and every tool's skills land in
|
|
840
856
|
// `.claude/skills/` — see the block above for what that measured.
|
|
841
857
|
skillsInstallationsForYes = skillsCapableTools.map(agent => ({ agent, level: location }));
|
|
858
|
+
// Nothing detected: name Claude Code's folder explicitly. Leaving the list empty sent the install down
|
|
859
|
+
// the legacy branch of `installSkills()`, which does not take the locale (so `--locale zh-tw` in a
|
|
860
|
+
// project with no tool marker would have installed English and said nothing).
|
|
861
|
+
if (noToolDetected) skillsInstallationsForYes = [{ agent: 'claude-code', level: location }];
|
|
842
862
|
|
|
843
863
|
// 🔴 Detected tools, none of which can take skills, is NOT the same as "no tools
|
|
844
864
|
// detected". The first is knowledge — install nothing and say why. The second is
|
package/src/commands/list.js
CHANGED
|
@@ -8,6 +8,14 @@ import {
|
|
|
8
8
|
import { readManifest, isInitialized } from '../utils/copier.js';
|
|
9
9
|
import { t, getLanguage, setLanguage, isLanguageExplicitlySet } from '../i18n/messages.js';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The order the listing shows its categories in. A category the registry holds standards for but that is not named
|
|
13
|
+
* here is still listed (after these, under its own key): the "Total" line counts every standard in the registry, so a
|
|
14
|
+
* category that was left out of the display used to make the total larger than the list (82 of 163 standards were
|
|
15
|
+
* counted and never shown, and `--category core` was refused as unknown).
|
|
16
|
+
*/
|
|
17
|
+
const CATEGORY_ORDER = ['skill', 'reference', 'core', 'testing', 'security', 'deployment', 'operations', 'extension', 'integration', 'template'];
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* List command - displays available standards
|
|
13
21
|
* @param {Object} options - Command options
|
|
@@ -44,7 +52,8 @@ export function listCommand(options) {
|
|
|
44
52
|
const categoryInfo = getCategoryInfo(category);
|
|
45
53
|
if (!categoryInfo) {
|
|
46
54
|
console.log(chalk.red(`${msg.errorUnknownCategory} '${category}'`));
|
|
47
|
-
|
|
55
|
+
const valid = CATEGORY_ORDER.filter((c) => getCategoryInfo(c));
|
|
56
|
+
console.log(chalk.gray(`${msg.validCategories} ${valid.join(', ')}`));
|
|
48
57
|
process.exit(1);
|
|
49
58
|
}
|
|
50
59
|
standards = getStandardsByCategory(category);
|
|
@@ -65,13 +74,13 @@ export function listCommand(options) {
|
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
// Display each category
|
|
68
|
-
const categoryOrder = [
|
|
77
|
+
const categoryOrder = [...CATEGORY_ORDER, ...Object.keys(grouped).filter((c) => !CATEGORY_ORDER.includes(c))];
|
|
69
78
|
|
|
70
79
|
for (const cat of categoryOrder) {
|
|
71
80
|
if (!grouped[cat] || grouped[cat].length === 0) continue;
|
|
72
81
|
|
|
73
82
|
const catInfo = getCategoryInfo(cat);
|
|
74
|
-
console.log(chalk.yellow.bold(`${catInfo
|
|
83
|
+
console.log(chalk.yellow.bold(`${catInfo?.name ?? cat} (${grouped[cat].length})`));
|
|
75
84
|
|
|
76
85
|
for (const std of grouped[cat]) {
|
|
77
86
|
const name = std.skillName
|
package/src/commands/mcp.js
CHANGED
|
@@ -16,9 +16,8 @@ export function mcpCommand(program) {
|
|
|
16
16
|
mcp
|
|
17
17
|
.command('serve')
|
|
18
18
|
.description('Start MCP Design Standards Server (stdio transport)')
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
const server = new McpServer({ udsRoot: options.root });
|
|
19
|
+
.action(() => {
|
|
20
|
+
const server = new McpServer();
|
|
22
21
|
server.start();
|
|
23
22
|
// Log to stderr only — stdout is reserved for MCP JSON-RPC messages
|
|
24
23
|
process.stderr.write('UDS MCP Design Standards Server started (stdio)\n');
|