universal-dev-standards 5.1.0-beta.7 → 5.1.1

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.
Files changed (116) hide show
  1. package/README.md +6 -0
  2. package/bin/uds.js +2 -0
  3. package/bundled/ai/standards/checkin-standards.ai.yaml +18 -0
  4. package/bundled/ai/standards/test-governance.ai.yaml +12 -0
  5. package/bundled/ai/standards/testing.ai.yaml +14 -0
  6. package/bundled/ai/standards/translation-lifecycle-standards.ai.yaml +145 -0
  7. package/bundled/core/checkin-standards.md +21 -2
  8. package/bundled/core/test-governance.md +3 -0
  9. package/bundled/core/testing-standards.md +25 -2
  10. package/bundled/core/translation-lifecycle-standards.md +162 -0
  11. package/bundled/locales/zh-CN/CHANGELOG.md +50 -3
  12. package/bundled/locales/zh-CN/README.md +1 -1
  13. package/bundled/locales/zh-CN/core/anti-hallucination.md +22 -3
  14. package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +192 -0
  15. package/bundled/locales/zh-CN/core/capability-declaration.md +123 -0
  16. package/bundled/locales/zh-CN/core/checkin-standards.md +22 -3
  17. package/bundled/locales/zh-CN/core/circuit-breaker.md +106 -0
  18. package/bundled/locales/zh-CN/core/dual-phase-output.md +103 -0
  19. package/bundled/locales/zh-CN/core/failure-source-taxonomy.md +99 -0
  20. package/bundled/locales/zh-CN/core/frontend-design-standards.md +289 -0
  21. package/bundled/locales/zh-CN/core/health-check-standards.md +144 -0
  22. package/bundled/locales/zh-CN/core/immutability-first.md +96 -0
  23. package/bundled/locales/zh-CN/core/packaging-standards.md +224 -0
  24. package/bundled/locales/zh-CN/core/recovery-recipe-registry.md +146 -0
  25. package/bundled/locales/zh-CN/core/retry-standards.md +131 -0
  26. package/bundled/locales/zh-CN/core/security-decision.md +104 -0
  27. package/bundled/locales/zh-CN/core/skill-standard-alignment-check.md +112 -0
  28. package/bundled/locales/zh-CN/core/standard-admission-criteria.md +104 -0
  29. package/bundled/locales/zh-CN/core/standard-lifecycle-management.md +116 -0
  30. package/bundled/locales/zh-CN/core/test-governance.md +14 -3
  31. package/bundled/locales/zh-CN/core/testing-standards.md +26 -3
  32. package/bundled/locales/zh-CN/core/timeout-standards.md +117 -0
  33. package/bundled/locales/zh-CN/core/token-budget.md +108 -0
  34. package/bundled/locales/zh-CN/core/translation-lifecycle-standards.md +159 -0
  35. package/bundled/locales/zh-TW/CHANGELOG.md +50 -3
  36. package/bundled/locales/zh-TW/README.md +1 -1
  37. package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +8 -0
  38. package/bundled/locales/zh-TW/core/capability-declaration.md +111 -0
  39. package/bundled/locales/zh-TW/core/checkin-standards.md +24 -3
  40. package/bundled/locales/zh-TW/core/circuit-breaker.md +111 -0
  41. package/bundled/locales/zh-TW/core/dual-phase-output.md +132 -0
  42. package/bundled/locales/zh-TW/core/failure-source-taxonomy.md +146 -0
  43. package/bundled/locales/zh-TW/core/frontend-design-standards.md +460 -0
  44. package/bundled/locales/zh-TW/core/health-check-standards.md +144 -0
  45. package/bundled/locales/zh-TW/core/immutability-first.md +159 -0
  46. package/bundled/locales/zh-TW/core/recovery-recipe-registry.md +146 -0
  47. package/bundled/locales/zh-TW/core/retry-standards.md +140 -0
  48. package/bundled/locales/zh-TW/core/security-decision.md +120 -0
  49. package/bundled/locales/zh-TW/core/skill-standard-alignment-check.md +112 -0
  50. package/bundled/locales/zh-TW/core/standard-admission-criteria.md +104 -0
  51. package/bundled/locales/zh-TW/core/standard-lifecycle-management.md +116 -0
  52. package/bundled/locales/zh-TW/core/test-governance.md +14 -3
  53. package/bundled/locales/zh-TW/core/testing-standards.md +31 -0
  54. package/bundled/locales/zh-TW/core/timeout-standards.md +117 -0
  55. package/bundled/locales/zh-TW/core/token-budget.md +143 -0
  56. package/bundled/locales/zh-TW/core/translation-lifecycle-standards.md +159 -0
  57. package/bundled/locales/zh-TW/skills/ac-coverage-assistant/SKILL.md +1 -0
  58. package/bundled/locales/zh-TW/skills/adr-assistant/SKILL.md +1 -0
  59. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +1 -0
  60. package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +1 -0
  61. package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +1 -0
  62. package/bundled/locales/zh-TW/skills/api-design-assistant/SKILL.md +1 -0
  63. package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +1 -0
  64. package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +1 -0
  65. package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +1 -0
  66. package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +1 -0
  67. package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +1 -0
  68. package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +1 -0
  69. package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +1 -0
  70. package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +1 -0
  71. package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +1 -0
  72. package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +1 -0
  73. package/bundled/locales/zh-TW/skills/database-assistant/SKILL.md +1 -0
  74. package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +1 -0
  75. package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +1 -0
  76. package/bundled/locales/zh-TW/skills/documentation-guide/SKILL.md +1 -0
  77. package/bundled/locales/zh-TW/skills/durable-execution-assistant/SKILL.md +1 -0
  78. package/bundled/locales/zh-TW/skills/e2e-assistant/SKILL.md +1 -0
  79. package/bundled/locales/zh-TW/skills/forward-derivation/SKILL.md +1 -0
  80. package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +1 -0
  81. package/bundled/locales/zh-TW/skills/methodology-system/SKILL.md +1 -0
  82. package/bundled/locales/zh-TW/skills/metrics-dashboard-assistant/SKILL.md +1 -0
  83. package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +1 -0
  84. package/bundled/locales/zh-TW/skills/observability-assistant/SKILL.md +1 -0
  85. package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +1 -0
  86. package/bundled/locales/zh-TW/skills/process-automation/SKILL.md +1 -0
  87. package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +1 -0
  88. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +1 -0
  89. package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +1 -0
  90. package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +1 -0
  91. package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +1 -0
  92. package/bundled/locales/zh-TW/skills/retrospective-assistant/SKILL.md +1 -0
  93. package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +1 -0
  94. package/bundled/locales/zh-TW/skills/runbook-assistant/SKILL.md +1 -0
  95. package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +1 -0
  96. package/bundled/locales/zh-TW/skills/security-scan-assistant/SKILL.md +1 -0
  97. package/bundled/locales/zh-TW/skills/slo-assistant/SKILL.md +1 -0
  98. package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +1 -0
  99. package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +1 -0
  100. package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +1 -0
  101. package/bundled/skills/ai-collaboration-standards/SKILL.md +1 -0
  102. package/bundled/skills/ai-friendly-architecture/SKILL.md +1 -0
  103. package/bundled/skills/ai-instruction-standards/SKILL.md +1 -0
  104. package/bundled/skills/documentation-guide/SKILL.md +1 -0
  105. package/bundled/skills/error-code-guide/SKILL.md +1 -0
  106. package/bundled/skills/git-workflow-guide/SKILL.md +1 -0
  107. package/bundled/skills/logging-guide/SKILL.md +1 -0
  108. package/bundled/skills/project-structure-guide/SKILL.md +1 -0
  109. package/bundled/skills/testing-guide/SKILL.md +1 -0
  110. package/package.json +5 -4
  111. package/src/commands/check.js +6 -0
  112. package/src/commands/init.js +6 -0
  113. package/src/commands/update.js +6 -0
  114. package/src/utils/detect-self-adoption.js +173 -0
  115. package/src/utils/directory-mapper.js +2 -2
  116. package/standards-registry.json +15 -4
@@ -0,0 +1,173 @@
1
+ /**
2
+ * UDS Self-Adoption Detection
3
+ *
4
+ * Detect whether the current working directory is the UDS source repo itself.
5
+ * When detected, adoption-oriented CLI commands (update / check / init) MUST
6
+ * refuse to run — otherwise the CLI would overwrite source-of-truth
7
+ * `.standards/` with its own npm-bundled copy (DEC-044 / XSPEC-071).
8
+ *
9
+ * Detection uses three independent heuristics. ANY one being true is
10
+ * sufficient, but each is validated to reduce false positives:
11
+ *
12
+ * 1. `uds-manifest.json` in cwd whose `project === "Universal Development
13
+ * Standards"` (strong signal — bundled manifests are adopter-named).
14
+ * 2. `cli/package.json` in cwd whose `name === "universal-dev-standards"`
15
+ * (strong signal — only the UDS source repo ships this package).
16
+ * 3. `.uds-source-repo` marker file in cwd (explicit opt-in marker).
17
+ *
18
+ * The three signals are OR-combined: any single hit is enough. A consumer
19
+ * (adopter project) will hit none of them even if they installed UDS.
20
+ *
21
+ * Related:
22
+ * - DEC-044: UDS Self-Adoption Bug
23
+ * - XSPEC-071: UDS Self-Adoption Protection
24
+ */
25
+
26
+ import { existsSync, readFileSync } from 'fs';
27
+ import { join } from 'path';
28
+
29
+ /**
30
+ * Indicator returned when detection matches, useful for diagnostics.
31
+ *
32
+ * @typedef {Object} SelfAdoptionResult
33
+ * @property {boolean} isSelfAdoption - True when cwd is UDS source repo
34
+ * @property {string[]} signals - Names of heuristics that matched
35
+ */
36
+
37
+ /**
38
+ * Check whether `uds-manifest.json` at `cwd` identifies UDS source repo.
39
+ */
40
+ function hasSourceManifest(cwd) {
41
+ const manifestPath = join(cwd, 'uds-manifest.json');
42
+ if (!existsSync(manifestPath)) return false;
43
+ try {
44
+ const content = readFileSync(manifestPath, 'utf8');
45
+ const manifest = JSON.parse(content);
46
+ return manifest?.project === 'Universal Development Standards';
47
+ } catch {
48
+ // Malformed JSON: fall back to "not matched" rather than throwing;
49
+ // the file alone is not strong enough proof without verified content.
50
+ return false;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Check whether `cli/package.json` at `cwd` identifies UDS source repo.
56
+ */
57
+ function hasSourceCliPackage(cwd) {
58
+ const pkgPath = join(cwd, 'cli', 'package.json');
59
+ if (!existsSync(pkgPath)) return false;
60
+ try {
61
+ const content = readFileSync(pkgPath, 'utf8');
62
+ const pkg = JSON.parse(content);
63
+ return pkg?.name === 'universal-dev-standards';
64
+ } catch {
65
+ return false;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Check whether the explicit marker file exists.
71
+ */
72
+ function hasSourceMarker(cwd) {
73
+ return existsSync(join(cwd, '.uds-source-repo'));
74
+ }
75
+
76
+ /**
77
+ * Detect UDS self-adoption situation.
78
+ *
79
+ * @param {string} [cwd=process.cwd()] - Directory to inspect
80
+ * @returns {boolean} True when cwd is (likely) the UDS source repo
81
+ */
82
+ export function detectSelfAdoption(cwd = process.cwd()) {
83
+ return detectSelfAdoptionDetailed(cwd).isSelfAdoption;
84
+ }
85
+
86
+ /**
87
+ * Detect UDS self-adoption and return detailed signal breakdown.
88
+ *
89
+ * @param {string} [cwd=process.cwd()] - Directory to inspect
90
+ * @returns {SelfAdoptionResult} Detection outcome with matched signals
91
+ */
92
+ export function detectSelfAdoptionDetailed(cwd = process.cwd()) {
93
+ const signals = [];
94
+ if (hasSourceManifest(cwd)) signals.push('uds-manifest.json');
95
+ if (hasSourceCliPackage(cwd)) signals.push('cli/package.json');
96
+ if (hasSourceMarker(cwd)) signals.push('.uds-source-repo');
97
+ return {
98
+ isSelfAdoption: signals.length > 0,
99
+ signals
100
+ };
101
+ }
102
+
103
+ /**
104
+ * Bilingual refuse message shown when self-adoption is detected and
105
+ * `--force` is not passed. Kept inline (not in i18n bundle) to avoid
106
+ * taking a translation dependency for a fail-safe error path.
107
+ *
108
+ * @param {string} commandName - e.g. 'update' / 'check' / 'init'
109
+ * @returns {string[]} Lines to print
110
+ */
111
+ export function formatSelfAdoptionRefuseMessage(commandName) {
112
+ return [
113
+ `偵測到 UDS source repo。此指令(uds ${commandName})僅供採用專案使用。`,
114
+ 'Source repo 維護請使用 scripts/bump-version.sh 或 npm run docs:sync。',
115
+ '詳見 DEC-044。',
116
+ '',
117
+ `Detected UDS source repo. This command (uds ${commandName}) is for`,
118
+ 'adopter projects only. For source-repo maintenance use',
119
+ 'scripts/bump-version.sh or npm run docs:sync. See DEC-044.',
120
+ '',
121
+ 'Override with --force if you know what you are doing',
122
+ '(若確定要執行可加上 --force 旗標繞過).'
123
+ ];
124
+ }
125
+
126
+ /**
127
+ * Warning printed when `--force` bypasses the self-adoption guard.
128
+ *
129
+ * @param {string} commandName
130
+ * @returns {string[]} Lines to print
131
+ */
132
+ export function formatSelfAdoptionForceWarning(commandName) {
133
+ return [
134
+ `警告:偵測到 UDS source repo,但 --force 已指定,繼續執行 uds ${commandName}。`,
135
+ `Warning: UDS source repo detected; --force was passed, continuing uds ${commandName}.`,
136
+ '若非預期操作,請立即 Ctrl+C 並改用 scripts/bump-version.sh。',
137
+ 'If unintended, abort now (Ctrl+C) and use scripts/bump-version.sh.'
138
+ ];
139
+ }
140
+
141
+ /**
142
+ * Guard helper — prints refuse message and exits with non-zero code when
143
+ * cwd is the UDS source repo and `--force` was not supplied.
144
+ *
145
+ * Does nothing when not self-adoption, or when `--force` is set (in which
146
+ * case a warning is printed but execution proceeds).
147
+ *
148
+ * @param {string} commandName - CLI command being invoked (for message)
149
+ * @param {Object} [options] - Caller options; inspected for `force`
150
+ * @param {string} [cwd=process.cwd()]
151
+ * @returns {boolean} True if command should continue (caller keeps running)
152
+ */
153
+ export function guardAgainstSelfAdoption(commandName, options = {}, cwd = process.cwd()) {
154
+ const { isSelfAdoption, signals } = detectSelfAdoptionDetailed(cwd);
155
+ if (!isSelfAdoption) return true;
156
+
157
+ const force = Boolean(options && options.force);
158
+ if (force) {
159
+ for (const line of formatSelfAdoptionForceWarning(commandName)) {
160
+ console.warn(line);
161
+ }
162
+ console.warn(`Matched signals: ${signals.join(', ')}`);
163
+ return true;
164
+ }
165
+
166
+ for (const line of formatSelfAdoptionRefuseMessage(commandName)) {
167
+ console.error(line);
168
+ }
169
+ console.error(`Matched signals: ${signals.join(', ')}`);
170
+ process.exit(1);
171
+ // Unreachable, but for tests that stub process.exit:
172
+ return false;
173
+ }
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import { readdirSync } from 'fs';
12
- import { join, relative } from 'path';
12
+ import { join, relative, basename } from 'path';
13
13
 
14
14
  /**
15
15
  * Default mappings from standard IDs to directory glob patterns.
@@ -84,7 +84,7 @@ export function mapStandardsToDirectories(projectPath, customMappings = {}) {
84
84
  const matchedDirs = [];
85
85
 
86
86
  for (const dir of projectDirs) {
87
- const dirName = dir.split('/').pop();
87
+ const dirName = basename(dir);
88
88
  if (patterns.includes(dirName)) {
89
89
  matchedDirs.push(dir);
90
90
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "version": "5.1.0-beta.7",
3
+ "version": "5.1.1",
4
4
  "lastUpdated": "2026-04-16",
5
5
  "description": "Standards registry for universal-dev-standards with integrated skills and AI-optimized formats",
6
6
  "formats": {
@@ -58,14 +58,14 @@
58
58
  "standards": {
59
59
  "name": "universal-dev-standards",
60
60
  "url": "https://github.com/AsiaOstrich/universal-dev-standards",
61
- "version": "5.1.0-beta.7"
61
+ "version": "5.1.1"
62
62
  },
63
63
  "skills": {
64
64
  "name": "universal-dev-standards",
65
65
  "url": "https://github.com/AsiaOstrich/universal-dev-standards",
66
66
  "localPath": "skills",
67
67
  "rawUrl": "https://raw.githubusercontent.com/AsiaOstrich/universal-dev-standards/main/skills",
68
- "version": "5.1.0-beta.7",
68
+ "version": "5.1.1",
69
69
  "note": "Skills are now included in the main repository under skills/"
70
70
  }
71
71
  },
@@ -2040,6 +2040,17 @@
2040
2040
  },
2041
2041
  "category": "core",
2042
2042
  "description": "Skills must anchor to a Standard; Standards may exist without a Skill. Orphan-skill detection workflow (DEC-043 Wave 1 Governance Meta, XSPEC-070, trial)."
2043
+ },
2044
+ {
2045
+ "id": "translation-lifecycle-standards",
2046
+ "name": "Translation Lifecycle Standards",
2047
+ "nameZh": "翻譯生命週期標準",
2048
+ "source": {
2049
+ "human": "core/translation-lifecycle-standards.md",
2050
+ "ai": "ai/standards/translation-lifecycle-standards.ai.yaml"
2051
+ },
2052
+ "category": "core",
2053
+ "description": "MISSING vs OUTDATED distinction, semver-aware severity (PATCH/MINOR/MAJOR), and automation integration (pre-commit hook, release gate) for multi-locale documentation"
2043
2054
  }
2044
2055
  ]
2045
- }
2056
+ }