@ryuenn3123/agentic-senior-core 4.4.0 → 5.2.0

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 (201) hide show
  1. package/.agents/plugins/agentic-senior-core/plugin.json +3 -0
  2. package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
  3. package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
  4. package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
  5. package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
  6. package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
  7. package/.agents/rules/agentic-senior-core.md +131 -0
  8. package/.claude-plugin/marketplace.json +17 -0
  9. package/.claude-plugin/plugin.json +17 -0
  10. package/.clinerules/agentic-senior-core.md +94 -0
  11. package/.codex-plugin/plugin.json +24 -0
  12. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  13. package/.devin-plugin/plugin.json +13 -0
  14. package/.github/copilot-instructions.md +94 -0
  15. package/.github/plugin/marketplace.json +20 -0
  16. package/.github/plugin/plugin.json +16 -0
  17. package/.kiro/steering/agentic-senior-core.md +94 -0
  18. package/.openclaw/skills/asc/SKILL.md +23 -0
  19. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  20. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  21. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  22. package/.windsurf/rules/agentic-senior-core.md +94 -0
  23. package/AGENTS.md +126 -127
  24. package/CONTRIBUTING.md +93 -63
  25. package/README.md +190 -110
  26. package/__init__.py +61 -0
  27. package/bin/agentic-senior-core.js +42 -41
  28. package/commands/asc-audit.md +1 -0
  29. package/commands/asc-audit.toml +2 -0
  30. package/commands/asc-help.md +9 -0
  31. package/commands/asc-help.toml +2 -0
  32. package/commands/asc-refactor.md +1 -0
  33. package/commands/asc-refactor.toml +2 -0
  34. package/commands/asc-review.md +1 -0
  35. package/commands/asc-review.toml +2 -0
  36. package/gemini-extension.json +10 -0
  37. package/hooks/copilot-hooks.json +21 -0
  38. package/hooks/hooks.json +31 -0
  39. package/hooks/session-start.js +36 -0
  40. package/hooks/subagent-start.js +38 -0
  41. package/lib/cli/commands/adapter.mjs +109 -0
  42. package/lib/cli/commands/clean.mjs +63 -0
  43. package/lib/cli/commands/status.mjs +94 -0
  44. package/package.json +43 -60
  45. package/plugin.yaml +16 -0
  46. package/scripts/uninstall.js +38 -0
  47. package/skills/asc/SKILL.md +16 -0
  48. package/skills/asc-audit/SKILL.md +28 -0
  49. package/skills/asc-refactor/SKILL.md +35 -0
  50. package/skills/asc-review/SKILL.md +54 -0
  51. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  52. package/.agent-context/prompts/bootstrap-design.md +0 -63
  53. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  54. package/.agent-context/prompts/init-project.md +0 -60
  55. package/.agent-context/prompts/refactor.md +0 -38
  56. package/.agent-context/prompts/review-code.md +0 -31
  57. package/.agent-context/review-checklists/architecture-review.md +0 -57
  58. package/.agent-context/review-checklists/pr-checklist.md +0 -134
  59. package/.agent-context/rules/api-docs.md +0 -24
  60. package/.agent-context/rules/api-versioning.md +0 -16
  61. package/.agent-context/rules/architecture.md +0 -38
  62. package/.agent-context/rules/background-jobs.md +0 -17
  63. package/.agent-context/rules/config-and-flags.md +0 -16
  64. package/.agent-context/rules/database-design.md +0 -18
  65. package/.agent-context/rules/docker-runtime.md +0 -17
  66. package/.agent-context/rules/error-handling.md +0 -16
  67. package/.agent-context/rules/event-driven.md +0 -16
  68. package/.agent-context/rules/frontend-architecture.md +0 -54
  69. package/.agent-context/rules/microservices.md +0 -16
  70. package/.agent-context/rules/migrations.md +0 -16
  71. package/.agent-context/rules/observability.md +0 -16
  72. package/.agent-context/rules/performance.md +0 -16
  73. package/.agent-context/rules/realtime.md +0 -16
  74. package/.agent-context/rules/resilience.md +0 -18
  75. package/.agent-context/rules/security.md +0 -18
  76. package/.agent-context/rules/testing.md +0 -16
  77. package/.agent-context/state/README.md +0 -25
  78. package/.agent-context/state/architecture-map.md +0 -40
  79. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  80. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  81. package/.agent-context/state/benchmark-thresholds.json +0 -10
  82. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  83. package/.agent-context/state/dependency-map.md +0 -41
  84. package/.agent-context/state/memory-adapter-contract.json +0 -52
  85. package/.agent-context/state/memory-schema-v1.json +0 -88
  86. package/GEMINI.md +0 -1
  87. package/benchmarks/README.md +0 -60
  88. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  89. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  90. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  91. package/lib/cli/adaptive-context/catalog.mjs +0 -394
  92. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  93. package/lib/cli/adaptive-context/implications.mjs +0 -44
  94. package/lib/cli/adaptive-context.mjs +0 -151
  95. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  96. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  97. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  98. package/lib/cli/backup.mjs +0 -210
  99. package/lib/cli/commands/context.mjs +0 -140
  100. package/lib/cli/commands/init/project-context.mjs +0 -60
  101. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  102. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  103. package/lib/cli/commands/init.mjs +0 -654
  104. package/lib/cli/commands/launch.mjs +0 -76
  105. package/lib/cli/commands/optimize.mjs +0 -284
  106. package/lib/cli/commands/rollback.mjs +0 -64
  107. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  108. package/lib/cli/commands/upgrade.mjs +0 -451
  109. package/lib/cli/compiler.mjs +0 -187
  110. package/lib/cli/constants.mjs +0 -136
  111. package/lib/cli/detector/constants.mjs +0 -135
  112. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  113. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  114. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  115. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  116. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  117. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  118. package/lib/cli/detector/design-evidence.mjs +0 -25
  119. package/lib/cli/detector/stack-detection.mjs +0 -243
  120. package/lib/cli/detector/ui-signals.mjs +0 -150
  121. package/lib/cli/detector/workspace-scan.mjs +0 -177
  122. package/lib/cli/detector.mjs +0 -23
  123. package/lib/cli/init-detection-flow.mjs +0 -48
  124. package/lib/cli/init-options.mjs +0 -237
  125. package/lib/cli/init-selection.mjs +0 -29
  126. package/lib/cli/memory-continuity.mjs +0 -537
  127. package/lib/cli/preflight.mjs +0 -76
  128. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  129. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  130. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  131. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  132. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  133. package/lib/cli/project-scaffolder.mjs +0 -29
  134. package/lib/cli/rollback.mjs +0 -66
  135. package/lib/cli/token-optimization.mjs +0 -401
  136. package/lib/cli/utils/filesystem.mjs +0 -81
  137. package/lib/cli/utils/managed-surface.mjs +0 -280
  138. package/lib/cli/utils/prompting.mjs +0 -44
  139. package/lib/cli/utils.mjs +0 -479
  140. package/mcp.json +0 -134
  141. package/scripts/adaptive-context/fixtures.mjs +0 -183
  142. package/scripts/adaptive-context-benchmark.mjs +0 -9
  143. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  144. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  145. package/scripts/benchmark-gate.mjs +0 -121
  146. package/scripts/benchmark-intelligence.mjs +0 -33
  147. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  148. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  149. package/scripts/bump-version.mjs +0 -103
  150. package/scripts/clean-local-artifacts.mjs +0 -78
  151. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  152. package/scripts/context-triggered-audit.mjs +0 -391
  153. package/scripts/detection-benchmark.mjs +0 -127
  154. package/scripts/docs-quality-drift-report.mjs +0 -358
  155. package/scripts/documentation-boundary-audit.mjs +0 -305
  156. package/scripts/explain-on-demand-audit.mjs +0 -427
  157. package/scripts/forbidden-content-check.mjs +0 -123
  158. package/scripts/frontend-usability-audit.mjs +0 -243
  159. package/scripts/generate-sbom.mjs +0 -61
  160. package/scripts/governance-weekly-report.mjs +0 -466
  161. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  162. package/scripts/llm-judge/constants.mjs +0 -66
  163. package/scripts/llm-judge/diff-collection.mjs +0 -74
  164. package/scripts/llm-judge/prompting.mjs +0 -78
  165. package/scripts/llm-judge/providers.mjs +0 -111
  166. package/scripts/llm-judge/verdict.mjs +0 -134
  167. package/scripts/llm-judge.mjs +0 -200
  168. package/scripts/memory-continuity-benchmark.mjs +0 -322
  169. package/scripts/quality-trend-report.mjs +0 -289
  170. package/scripts/release-gate/audit-checks.mjs +0 -441
  171. package/scripts/release-gate/constants.mjs +0 -53
  172. package/scripts/release-gate/runtime.mjs +0 -63
  173. package/scripts/release-gate/static-checks.mjs +0 -182
  174. package/scripts/release-gate.mjs +0 -42
  175. package/scripts/rules-guardian-audit.mjs +0 -580
  176. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  177. package/scripts/sync-thin-adapters.mjs +0 -72
  178. package/scripts/token-optimization-benchmark.mjs +0 -252
  179. package/scripts/ui-design-judge/constants.mjs +0 -13
  180. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  181. package/scripts/ui-design-judge/git-input.mjs +0 -134
  182. package/scripts/ui-design-judge/prompting.mjs +0 -52
  183. package/scripts/ui-design-judge/providers.mjs +0 -102
  184. package/scripts/ui-design-judge/reporting.mjs +0 -183
  185. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  186. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  187. package/scripts/ui-design-judge.mjs +0 -319
  188. package/scripts/ui-rubric-calibration.mjs +0 -35
  189. package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
  190. package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
  191. package/scripts/validate/audits/file-size.mjs +0 -158
  192. package/scripts/validate/audits/reflection-citations.mjs +0 -130
  193. package/scripts/validate/audits/release-bundle.mjs +0 -135
  194. package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
  195. package/scripts/validate/config.mjs +0 -501
  196. package/scripts/validate/coverage-checks.mjs +0 -446
  197. package/scripts/validate/file-structure.mjs +0 -158
  198. package/scripts/validate/markdown-content.mjs +0 -109
  199. package/scripts/validate/project-metadata.mjs +0 -166
  200. package/scripts/validate/utils.mjs +0 -52
  201. package/scripts/validate.mjs +0 -267
@@ -1,252 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * token-optimization-benchmark.mjs
5
- *
6
- * Measures token-estimate reduction between baseline commands and
7
- * native optimized command variants. If RTK is installed, it also
8
- * compares RTK command output in the same scenarios.
9
- */
10
-
11
- import { existsSync } from 'node:fs';
12
- import fs from 'node:fs/promises';
13
- import { spawnSync } from 'node:child_process';
14
- import { dirname, join, resolve } from 'node:path';
15
- import { fileURLToPath } from 'node:url';
16
-
17
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
18
- const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
19
- const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
20
- const REPORT_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'token-optimization-benchmark.json');
21
- const LOCAL_RTK_BINARY_PATH = join(REPOSITORY_ROOT, '.benchmarks', 'tools', 'rtk', 'rtk.exe');
22
- const TOKEN_ESTIMATE_DIVISOR = 4;
23
- const ARGUMENT_FLAGS = new Set(process.argv.slice(2));
24
- const isStdoutOnlyMode = ARGUMENT_FLAGS.has('--stdout-only');
25
-
26
- const BENCHMARK_SCENARIOS = [
27
- {
28
- scenarioId: 'git-show',
29
- scenarioName: 'Latest commit detail review',
30
- baselineCommand: { command: 'git', args: ['show', 'HEAD', '--stat', '--patch', '--no-color'] },
31
- nativeOptimizedCommand: { command: 'git', args: ['show', 'HEAD', '--stat', '--no-color'] },
32
- rtkCommand: { command: 'rtk', args: ['git', 'show', 'HEAD', '--stat', '--patch', '--no-color'] },
33
- },
34
- {
35
- scenarioId: 'git-log',
36
- scenarioName: 'Commit history review',
37
- baselineCommand: { command: 'git', args: ['log', '-n', '50'] },
38
- nativeOptimizedCommand: { command: 'git', args: ['log', '--oneline', '-n', '50'] },
39
- rtkCommand: { command: 'rtk', args: ['git', 'log', '-n', '50'] },
40
- },
41
- {
42
- scenarioId: 'search-token',
43
- scenarioName: 'Search result scan',
44
- baselineCommand: { command: 'git', args: ['grep', '-n', 'token'] },
45
- nativeOptimizedCommand: { command: 'git', args: ['grep', '-n', 'token', 'README.md', 'docs'] },
46
- rtkCommand: { command: 'rtk', args: ['git', 'grep', '-n', 'token'] },
47
- },
48
- ];
49
-
50
- function estimateTokenCount(outputText) {
51
- if (!outputText || outputText.length === 0) {
52
- return 0;
53
- }
54
-
55
- return Math.ceil(outputText.length / TOKEN_ESTIMATE_DIVISOR);
56
- }
57
-
58
- function formatCommandLine(commandDefinition) {
59
- return [commandDefinition.command, ...commandDefinition.args].join(' ');
60
- }
61
-
62
- function executeCommand(commandDefinition) {
63
- const commandResult = spawnSync(commandDefinition.command, commandDefinition.args, {
64
- cwd: REPOSITORY_ROOT,
65
- encoding: 'utf8',
66
- maxBuffer: 1024 * 1024 * 20,
67
- });
68
-
69
- const standardOutput = commandResult.stdout || '';
70
- const standardError = commandResult.stderr || '';
71
- const combinedOutput = `${standardOutput}${standardError}`;
72
- const normalizedOutput = combinedOutput.trimEnd();
73
-
74
- const outputLineCount = normalizedOutput.length === 0
75
- ? 0
76
- : normalizedOutput.split(/\r?\n/u).length;
77
-
78
- return {
79
- command: formatCommandLine(commandDefinition),
80
- exitCode: typeof commandResult.status === 'number' ? commandResult.status : 1,
81
- outputChars: normalizedOutput.length,
82
- outputLines: outputLineCount,
83
- estimatedTokens: estimateTokenCount(normalizedOutput),
84
- };
85
- }
86
-
87
- function resolveRtkBinaryPath() {
88
- const configuredRtkBinaryPath = process.env.RTK_BINARY_PATH;
89
-
90
- if (configuredRtkBinaryPath && existsSync(configuredRtkBinaryPath)) {
91
- return {
92
- executablePath: configuredRtkBinaryPath,
93
- source: 'env',
94
- };
95
- }
96
-
97
- if (existsSync(LOCAL_RTK_BINARY_PATH)) {
98
- return {
99
- executablePath: LOCAL_RTK_BINARY_PATH,
100
- source: 'local-tools',
101
- };
102
- }
103
-
104
- return {
105
- executablePath: 'rtk',
106
- source: 'system-path',
107
- };
108
- }
109
-
110
- function detectRtkAvailability() {
111
- const rtkBinary = resolveRtkBinaryPath();
112
-
113
- const versionResult = spawnSync(rtkBinary.executablePath, ['--version'], {
114
- cwd: REPOSITORY_ROOT,
115
- encoding: 'utf8',
116
- maxBuffer: 1024 * 1024,
117
- });
118
-
119
- if (versionResult.error || versionResult.status !== 0) {
120
- return {
121
- isAvailable: false,
122
- version: null,
123
- source: rtkBinary.source,
124
- executablePath: rtkBinary.executablePath,
125
- reason: versionResult.error
126
- ? versionResult.error.message
127
- : (versionResult.stderr || versionResult.stdout || 'RTK command unavailable').trim(),
128
- };
129
- }
130
-
131
- const versionMatch = (versionResult.stdout || '').match(/\d+\.\d+\.\d+/u);
132
- return {
133
- isAvailable: true,
134
- version: versionMatch ? versionMatch[0] : null,
135
- source: rtkBinary.source,
136
- executablePath: rtkBinary.executablePath,
137
- reason: null,
138
- };
139
- }
140
-
141
- function buildRtkCommand(commandDefinition, rtkAvailability) {
142
- return {
143
- command: rtkAvailability.executablePath || commandDefinition.command,
144
- args: commandDefinition.args,
145
- };
146
- }
147
-
148
- function computeSavingsSummary(baselineTokens, optimizedTokens) {
149
- if (baselineTokens <= 0) {
150
- return {
151
- tokenDelta: 0,
152
- savingsPercent: 0,
153
- };
154
- }
155
-
156
- const tokenDelta = baselineTokens - optimizedTokens;
157
- const savingsPercent = Number(((tokenDelta / baselineTokens) * 100).toFixed(2));
158
-
159
- return {
160
- tokenDelta,
161
- savingsPercent,
162
- };
163
- }
164
-
165
- function calculateAverageSavings(benchmarkRows, savingsKeyName) {
166
- const availableSavings = benchmarkRows
167
- .map((benchmarkRow) => benchmarkRow[savingsKeyName]?.savingsPercent)
168
- .filter((savingsPercent) => typeof savingsPercent === 'number');
169
-
170
- if (availableSavings.length === 0) {
171
- return null;
172
- }
173
-
174
- const totalSavings = availableSavings.reduce((runningTotal, savingsPercent) => runningTotal + savingsPercent, 0);
175
- return Number((totalSavings / availableSavings.length).toFixed(2));
176
- }
177
-
178
- async function runTokenOptimizationBenchmark() {
179
- const rtkAvailability = detectRtkAvailability();
180
- const scenarioResults = [];
181
-
182
- for (const benchmarkScenario of BENCHMARK_SCENARIOS) {
183
- const baselineRun = executeCommand(benchmarkScenario.baselineCommand);
184
- const nativeOptimizedRun = executeCommand(benchmarkScenario.nativeOptimizedCommand);
185
- const nativeSavings = computeSavingsSummary(
186
- baselineRun.estimatedTokens,
187
- nativeOptimizedRun.estimatedTokens
188
- );
189
-
190
- let rtkRun = null;
191
- let rtkSavings = null;
192
-
193
- if (rtkAvailability.isAvailable) {
194
- rtkRun = executeCommand(buildRtkCommand(benchmarkScenario.rtkCommand, rtkAvailability));
195
- if (rtkRun.exitCode === 0) {
196
- rtkSavings = computeSavingsSummary(baselineRun.estimatedTokens, rtkRun.estimatedTokens);
197
- }
198
- }
199
-
200
- scenarioResults.push({
201
- scenarioId: benchmarkScenario.scenarioId,
202
- scenarioName: benchmarkScenario.scenarioName,
203
- baseline: baselineRun,
204
- nativeOptimized: nativeOptimizedRun,
205
- nativeSavings,
206
- rtk: rtkRun,
207
- rtkSavings,
208
- });
209
- }
210
-
211
- const benchmarkReport = {
212
- generatedAt: new Date().toISOString(),
213
- reportName: 'token-optimization-benchmark',
214
- methodology: {
215
- tokenEstimate: `estimated_tokens = ceil(output_chars / ${TOKEN_ESTIMATE_DIVISOR})`,
216
- scope: 'command-output estimate only; model-specific tokenization differs by provider',
217
- repositoryRoot: REPOSITORY_ROOT,
218
- },
219
- environment: {
220
- nodeVersion: process.version,
221
- platform: process.platform,
222
- rtk: rtkAvailability,
223
- },
224
- scenarios: scenarioResults,
225
- summary: {
226
- scenarioCount: scenarioResults.length,
227
- averageNativeSavingsPercent: calculateAverageSavings(scenarioResults, 'nativeSavings'),
228
- averageRtkSavingsPercent: calculateAverageSavings(scenarioResults, 'rtkSavings'),
229
- },
230
- artifact: {
231
- path: REPORT_PATH,
232
- writeMode: isStdoutOnlyMode ? 'stdout-only' : 'stdout-and-file',
233
- },
234
- };
235
-
236
- if (!isStdoutOnlyMode) {
237
- await fs.mkdir(dirname(REPORT_PATH), { recursive: true });
238
- await fs.writeFile(REPORT_PATH, JSON.stringify(benchmarkReport, null, 2) + '\n', 'utf8');
239
- }
240
-
241
- return benchmarkReport;
242
- }
243
-
244
- runTokenOptimizationBenchmark()
245
- .then((benchmarkReport) => {
246
- console.log(JSON.stringify(benchmarkReport, null, 2));
247
- })
248
- .catch((benchmarkError) => {
249
- const errorMessage = benchmarkError instanceof Error ? benchmarkError.message : String(benchmarkError);
250
- console.error(`Token benchmark failed: ${errorMessage}`);
251
- process.exit(1);
252
- });
@@ -1,13 +0,0 @@
1
- // @ts-check
2
-
3
- import { resolve, dirname } from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = dirname(__filename);
8
-
9
- export const REPOSITORY_ROOT = resolve(__dirname, '..', '..');
10
- export const DESIGN_GUIDE_PATH = resolve(REPOSITORY_ROOT, 'docs', 'DESIGN.md');
11
- export const MAX_DIFF_CHARS = 12000;
12
- export const UI_FILE_EXTENSIONS = new Set(['.js', '.jsx', '.ts', '.tsx', '.vue', '.css', '.scss', '.sass']);
13
-
@@ -1,81 +0,0 @@
1
- // @ts-check
2
-
3
- import { existsSync, readFileSync } from 'node:fs';
4
- import {
5
- DESIGN_GUIDE_PATH,
6
- } from './constants.mjs';
7
-
8
- /**
9
- * Legacy design-intent.json is no longer generated.
10
- * Returns null unconditionally.
11
- */
12
- export function loadDesignIntent() {
13
- return null;
14
- }
15
-
16
- export function loadDesignGuide() {
17
- if (!existsSync(DESIGN_GUIDE_PATH)) {
18
- return '';
19
- }
20
-
21
- return readFileSync(DESIGN_GUIDE_PATH, 'utf8');
22
- }
23
-
24
- export function normalizeStringArray(rawValue) {
25
- if (!Array.isArray(rawValue)) {
26
- return [];
27
- }
28
-
29
- return rawValue
30
- .map((entryValue) => String(entryValue || '').trim())
31
- .filter(Boolean);
32
- }
33
-
34
- /**
35
- * Simplified design execution policy summary.
36
- * With the design-intent.json contract removed, this returns
37
- * a minimal stub that downstream consumers (main judge, reporting)
38
- * can safely consume without null checks.
39
- */
40
- export function summarizeDesignExecutionPolicy(designIntentContent) {
41
- return {
42
- policyPresent: false,
43
- representationStrategy: null,
44
- contractReady: false,
45
- screenshotDependencyForbidden: false,
46
- repoEvidenceAvailable: false,
47
- structuredInspectionAvailable: false,
48
- handoffPresent: false,
49
- handoffVersion: null,
50
- handoffReady: false,
51
- handoffArtifactCount: 0,
52
- presentHandoffArtifacts: [],
53
- missingHandoffArtifacts: [],
54
- repoEvidenceSummaryVersion: null,
55
- requiredCapabilities: [],
56
- enabledCapabilities: [],
57
- missingCapabilities: [],
58
- semanticReviewFocus: [],
59
- notes: ['Design execution policy is not applicable under the compact token file architecture.'],
60
- };
61
- }
62
-
63
- /**
64
- * Simplified review rubric summary.
65
- * Returns a minimal stub since the JSON contract rubric system was removed.
66
- */
67
- export function summarizeReviewRubric(designIntentContent) {
68
- return {
69
- version: null,
70
- dimensions: [],
71
- genericityAutoFail: false,
72
- genericitySignals: [],
73
- validBoldSignals: [],
74
- forbiddenPatterns: [],
75
- reportingRules: {
76
- mustExplainGenericity: false,
77
- mustSeparateTasteFromFailure: false,
78
- contractFidelityOverridesPersonalTaste: false,
79
- },
80
- };
81
- }
@@ -1,134 +0,0 @@
1
- // @ts-check
2
-
3
- import { execSync } from 'node:child_process';
4
- import { extname } from 'node:path';
5
- import { REPOSITORY_ROOT, UI_FILE_EXTENSIONS } from './constants.mjs';
6
-
7
- export function detectCiProvider() {
8
- if (process.env.GITHUB_ACTIONS === 'true') {
9
- return 'github';
10
- }
11
-
12
- if (process.env.GITLAB_CI === 'true') {
13
- return 'gitlab';
14
- }
15
-
16
- return 'local';
17
- }
18
-
19
- function collectGitDiff(baseSha, headSha) {
20
- const execOptions = {
21
- cwd: REPOSITORY_ROOT,
22
- encoding: /** @type {'utf-8'} */ ('utf-8'),
23
- maxBuffer: 1024 * 1024 * 8,
24
- };
25
-
26
- return execSync(`git diff "${baseSha}...${headSha}"`, execOptions);
27
- }
28
-
29
- function collectGitChangedFiles(baseSha, headSha) {
30
- const execOptions = {
31
- cwd: REPOSITORY_ROOT,
32
- encoding: /** @type {'utf-8'} */ ('utf-8'),
33
- maxBuffer: 1024 * 1024 * 2,
34
- };
35
-
36
- const output = execSync(`git diff --name-only "${baseSha}...${headSha}"`, execOptions);
37
- return output
38
- .split(/\r?\n/u)
39
- .map((filePath) => filePath.trim())
40
- .filter(Boolean);
41
- }
42
-
43
- export function collectPullRequestDiff() {
44
- if (process.env.PR_DIFF) {
45
- return process.env.PR_DIFF;
46
- }
47
-
48
- const githubBaseSha = process.env.GITHUB_BASE_SHA;
49
- const githubHeadSha = process.env.GITHUB_HEAD_SHA ?? 'HEAD';
50
- if (githubBaseSha) {
51
- return collectGitDiff(githubBaseSha, githubHeadSha);
52
- }
53
-
54
- const gitlabBaseSha = process.env.CI_MERGE_REQUEST_DIFF_BASE_SHA;
55
- const gitlabHeadSha = process.env.CI_COMMIT_SHA ?? 'HEAD';
56
- if (gitlabBaseSha) {
57
- return collectGitDiff(gitlabBaseSha, gitlabHeadSha);
58
- }
59
-
60
- try {
61
- return execSync('git diff HEAD~1 HEAD', {
62
- cwd: REPOSITORY_ROOT,
63
- encoding: /** @type {'utf-8'} */ ('utf-8'),
64
- maxBuffer: 1024 * 1024 * 8,
65
- stdio: ['ignore', 'pipe', 'ignore'],
66
- });
67
- } catch {
68
- try {
69
- const emptyTreeSha = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
70
- return execSync(`git diff "${emptyTreeSha}" HEAD`, {
71
- cwd: REPOSITORY_ROOT,
72
- encoding: /** @type {'utf-8'} */ ('utf-8'),
73
- maxBuffer: 1024 * 1024 * 8,
74
- stdio: ['ignore', 'pipe', 'ignore'],
75
- });
76
- } catch {
77
- return '';
78
- }
79
- }
80
- }
81
-
82
- export function collectChangedFiles() {
83
- if (process.env.PR_DIFF) {
84
- const filePathSet = new Set();
85
- for (const diffHeaderMatch of process.env.PR_DIFF.matchAll(/^diff --git a\/(.+?) b\/(.+)$/gm)) {
86
- filePathSet.add(diffHeaderMatch[2]);
87
- }
88
- return Array.from(filePathSet);
89
- }
90
-
91
- const githubBaseSha = process.env.GITHUB_BASE_SHA;
92
- const githubHeadSha = process.env.GITHUB_HEAD_SHA ?? 'HEAD';
93
- if (githubBaseSha) {
94
- return collectGitChangedFiles(githubBaseSha, githubHeadSha);
95
- }
96
-
97
- const gitlabBaseSha = process.env.CI_MERGE_REQUEST_DIFF_BASE_SHA;
98
- const gitlabHeadSha = process.env.CI_COMMIT_SHA ?? 'HEAD';
99
- if (gitlabBaseSha) {
100
- return collectGitChangedFiles(gitlabBaseSha, gitlabHeadSha);
101
- }
102
-
103
- try {
104
- const output = execSync('git diff --name-only HEAD~1 HEAD', {
105
- cwd: REPOSITORY_ROOT,
106
- encoding: /** @type {'utf-8'} */ ('utf-8'),
107
- maxBuffer: 1024 * 1024 * 2,
108
- stdio: ['ignore', 'pipe', 'ignore'],
109
- });
110
- return output.split(/\r?\n/u).map((filePath) => filePath.trim()).filter(Boolean);
111
- } catch {
112
- return [];
113
- }
114
- }
115
-
116
- export function isUiRelevantFilePath(filePath) {
117
- const normalizedFilePath = String(filePath || '').replace(/\\/g, '/').toLowerCase();
118
- const fileExtension = extname(normalizedFilePath);
119
-
120
- if (!UI_FILE_EXTENSIONS.has(fileExtension)) {
121
- return false;
122
- }
123
-
124
- return (
125
- normalizedFilePath.startsWith('src/')
126
- || normalizedFilePath.startsWith('app/')
127
- || normalizedFilePath.startsWith('pages/')
128
- || normalizedFilePath.startsWith('components/')
129
- || normalizedFilePath.startsWith('styles/')
130
- || normalizedFilePath.includes('/components/')
131
- || normalizedFilePath.includes('/screens/')
132
- || normalizedFilePath.includes('/layouts/')
133
- );
134
- }
@@ -1,52 +0,0 @@
1
- // @ts-check
2
-
3
- import { MAX_DIFF_CHARS } from './constants.mjs';
4
-
5
- export function buildSystemPrompt() {
6
- return [
7
- 'You are a Principal UI/UX Design Reviewer.',
8
- 'Compare the changed UI code against the provided design contract.',
9
- 'Treat docs/DESIGN.md as the design contract source of truth.',
10
- 'Use repoEvidence.designEvidenceSummary as implementation evidence when deciding whether the diff follows the intended system.',
11
- 'Do not reward generic SaaS defaults or popular template patterns.',
12
- 'Do not penalize originality when the implementation still aligns with the contract.',
13
- 'Treat purposeful motion as a first-class quality signal for modern UI work. Flag missing or timid motion when the contract calls for expressive interaction, and only flag motion itself when it drifts from the contract, ignores reduced-motion expectations, or adds avoidable performance/accessibility risk.',
14
- 'Only flag drift when there is a clear mismatch with the contract, accessibility non-negotiables, or cross-viewport adaptation rules.',
15
- 'Treat WCAG 2.2 AA failures as hard accessibility drift.',
16
- 'Treat APCA as advisory perceptual tuning only. Do not set blocking solely because APCA indicates a stronger readability adjustment when WCAG hard requirements still pass.',
17
- 'Check focus visibility, focus appearance, target size, keyboard access, accessible authentication, and status or dynamic state access when the diff touches those surfaces.',
18
- 'Check the optional reviewRubric.genericityAutoFail flag when structured context is present. If true and forbiddenPatterns or genericitySignals are detected in the changed UI, this audit is no longer merely advisory for that finding: set blockingRecommended to true, mark the relevant rubric dimension as blocking, and require rebuilding the drifted surface instead of polishing it.',
19
- 'Focus on color intent, typographic hierarchy, responsive re-layout, purposeful motion, component morphology across states, interaction behavior, and genericity drift.',
20
- 'If you call something generic, explain the specific genericity signal or anti-pattern that caused that judgment.',
21
- 'Separate taste from failure. A bold design that follows the contract must not be penalized only because it is unusual.',
22
- 'Return ONLY one JSON object on a single line prefixed with JSON_VERDICT:.',
23
- 'Schema:',
24
- '{"alignmentScore": number|null, "genericityAssessment": {"status": "distinctive|mixed|generic|unclear", "reason": string}, "tasteVsFailureSeparated": boolean, "rubricBreakdown": [{"dimension": string, "score": number|null, "verdict": "strong|acceptable|weak|unclear", "reason": string, "blocking": boolean}], "notes": string[], "findings": [{"area": string, "severity": "high|medium|low", "problem": string, "evidence": string, "requiredAction": string, "blockingRecommended": boolean}]}',
25
- ].join('\n');
26
- }
27
-
28
- export function buildUserMessage(designIntentContent, designGuideContent, diffContent, changedUiFiles, designExecutionSummary) {
29
- const truncatedDiff = diffContent.length > MAX_DIFF_CHARS
30
- ? `${diffContent.slice(0, MAX_DIFF_CHARS)}\n\n[DIFF TRUNCATED - ${diffContent.length - MAX_DIFF_CHARS} additional characters omitted]`
31
- : diffContent;
32
-
33
- return [
34
- '## Changed UI Files',
35
- changedUiFiles.length > 0 ? changedUiFiles.map((filePath) => `- ${filePath}`).join('\n') : '- none',
36
- '',
37
- '## Design Contract',
38
- '',
39
- '## DESIGN.md',
40
- '```md',
41
- designGuideContent.trim() || '(missing DESIGN.md)',
42
- '```',
43
-
44
- '',
45
- '## UI Diff',
46
- '```diff',
47
- truncatedDiff.trim() || '(no UI diff)',
48
- '```',
49
- '',
50
- 'Judge alignment to the contract. Avoid aesthetic bias toward generic web trends or toward motionless/static outputs.',
51
- ].join('\n');
52
- }
@@ -1,102 +0,0 @@
1
- // @ts-check
2
-
3
- async function callOpenAiProvider(systemPrompt, userMessage) {
4
- const selectedModel = process.env.LLM_JUDGE_MODEL ?? 'gpt-4o-mini';
5
- const apiResponse = await fetch('https://api.openai.com/v1/chat/completions', {
6
- method: 'POST',
7
- headers: {
8
- 'Content-Type': 'application/json',
9
- Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
10
- },
11
- body: JSON.stringify({
12
- model: selectedModel,
13
- max_tokens: 2048,
14
- temperature: 0,
15
- messages: [
16
- { role: 'system', content: systemPrompt },
17
- { role: 'user', content: userMessage },
18
- ],
19
- }),
20
- });
21
-
22
- if (!apiResponse.ok) {
23
- const errorBody = await apiResponse.text();
24
- throw new Error(`OpenAI API returned ${apiResponse.status}: ${errorBody}`);
25
- }
26
-
27
- const responsePayload = await apiResponse.json();
28
- return responsePayload.choices[0].message.content;
29
- }
30
-
31
- async function callAnthropicProvider(systemPrompt, userMessage) {
32
- const selectedModel = process.env.LLM_JUDGE_MODEL ?? 'claude-3-5-haiku-latest';
33
- const apiResponse = await fetch('https://api.anthropic.com/v1/messages', {
34
- method: 'POST',
35
- headers: {
36
- 'Content-Type': 'application/json',
37
- 'x-api-key': process.env.ANTHROPIC_API_KEY ?? '',
38
- 'anthropic-version': '2023-06-01',
39
- },
40
- body: JSON.stringify({
41
- model: selectedModel,
42
- max_tokens: 2048,
43
- system: systemPrompt,
44
- messages: [{ role: 'user', content: userMessage }],
45
- }),
46
- });
47
-
48
- if (!apiResponse.ok) {
49
- const errorBody = await apiResponse.text();
50
- throw new Error(`Anthropic API returned ${apiResponse.status}: ${errorBody}`);
51
- }
52
-
53
- const responsePayload = await apiResponse.json();
54
- return responsePayload.content[0].text;
55
- }
56
-
57
- async function callGeminiProvider(systemPrompt, userMessage) {
58
- const selectedModel = process.env.LLM_JUDGE_MODEL ?? 'gemini-2.0-flash';
59
- const apiKey = process.env.GEMINI_API_KEY ?? '';
60
- const endpointUrl = `https://generativelanguage.googleapis.com/v1beta/models/${selectedModel}:generateContent?key=${apiKey}`;
61
-
62
- const apiResponse = await fetch(endpointUrl, {
63
- method: 'POST',
64
- headers: { 'Content-Type': 'application/json' },
65
- body: JSON.stringify({
66
- system_instruction: { parts: [{ text: systemPrompt }] },
67
- contents: [{ role: 'user', parts: [{ text: userMessage }] }],
68
- generationConfig: { temperature: 0, maxOutputTokens: 2048 },
69
- }),
70
- });
71
-
72
- if (!apiResponse.ok) {
73
- const errorBody = await apiResponse.text();
74
- throw new Error(`Gemini API returned ${apiResponse.status}: ${errorBody}`);
75
- }
76
-
77
- const responsePayload = await apiResponse.json();
78
- return responsePayload.candidates[0].content.parts[0].text;
79
- }
80
-
81
- export function selectAvailableProvider() {
82
- if (process.env.UI_DESIGN_JUDGE_MOCK_RESPONSE) {
83
- return {
84
- providerName: 'mock',
85
- invokeProvider: async () => process.env.UI_DESIGN_JUDGE_MOCK_RESPONSE,
86
- };
87
- }
88
-
89
- if (process.env.OPENAI_API_KEY) {
90
- return { providerName: 'openai', invokeProvider: callOpenAiProvider };
91
- }
92
-
93
- if (process.env.ANTHROPIC_API_KEY) {
94
- return { providerName: 'anthropic', invokeProvider: callAnthropicProvider };
95
- }
96
-
97
- if (process.env.GEMINI_API_KEY) {
98
- return { providerName: 'gemini', invokeProvider: callGeminiProvider };
99
- }
100
-
101
- return null;
102
- }