@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,466 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * governance-weekly-report.mjs
5
- *
6
- * Aggregates weekly governance readiness signals for maintainers.
7
- * Produces a machine-readable report with trend, trust, and release posture.
8
- */
9
-
10
- import { existsSync, readFileSync } from 'node:fs';
11
- import fs from 'node:fs/promises';
12
- import { spawnSync } from 'node:child_process';
13
- import { dirname, join, resolve } from 'node:path';
14
- import { fileURLToPath } from 'node:url';
15
-
16
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
17
- const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
18
- const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
19
- const QUALITY_TREND_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'quality-trend-report.json');
20
- const REPORT_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'weekly-governance-report.json');
21
- const ARGUMENT_FLAGS = new Set(process.argv.slice(2));
22
- const isStdoutOnlyMode = ARGUMENT_FLAGS.has('--stdout-only');
23
- const WEEKLY_WINDOW_DAYS = 7;
24
- const HISTORY_LIMIT = 26;
25
- const BACKEND_REQUIRED_DOMAIN_NAMES = new Set([
26
- 'backend-architecture',
27
- 'backend-security',
28
- 'backend-data-access',
29
- 'backend-error-handling',
30
- 'backend-api-contract',
31
- 'backend-testing',
32
- 'backend-performance',
33
- 'backend-idempotency',
34
- 'backend-risk-map',
35
- ]);
36
- const REQUIRED_VERIFIED_DOMAINS = new Set([
37
- 'canonical-instructions',
38
- 'frontend-design-contract',
39
- 'frontend-architecture',
40
- ...Array.from(BACKEND_REQUIRED_DOMAIN_NAMES),
41
- 'pr-checklist',
42
- 'architecture-review',
43
- 'mcp-server',
44
- 'state-continuity',
45
- ]);
46
- const GOVERNANCE_SURFACE_PATHS = {
47
- 'canonical-instructions': 'AGENTS.md',
48
- 'frontend-design-contract': '.agent-context/prompts/bootstrap-design.md',
49
- 'frontend-architecture': '.agent-context/rules/frontend-architecture.md',
50
- 'backend-architecture': '.agent-context/rules/architecture.md',
51
- 'backend-security': '.agent-context/rules/security.md',
52
- 'backend-data-access': '.agent-context/rules/database-design.md',
53
- 'backend-error-handling': '.agent-context/rules/error-handling.md',
54
- 'backend-api-contract': '.agent-context/rules/api-docs.md',
55
- 'backend-testing': '.agent-context/rules/testing.md',
56
- 'backend-performance': '.agent-context/rules/performance.md',
57
- 'backend-idempotency': '.agent-context/rules/event-driven.md',
58
- 'backend-risk-map': '.agent-context/state/architecture-map.md',
59
- 'pr-checklist': '.agent-context/review-checklists/pr-checklist.md',
60
- 'architecture-review': '.agent-context/review-checklists/architecture-review.md',
61
- 'mcp-server': 'scripts/mcp-server.mjs',
62
- 'state-continuity': '.agent-context/state',
63
- };
64
- const BACKEND_GOVERNANCE_COVERAGE = [
65
- {
66
- constraint: 'Layered architecture and separation of concerns',
67
- status: 'covered',
68
- sourcePaths: [
69
- '.agent-context/rules/architecture.md',
70
- '.agent-context/review-checklists/architecture-review.md',
71
- ],
72
- signal: 'Transport, application, domain, and infrastructure boundaries are explicit.',
73
- },
74
- {
75
- constraint: 'Global backend/API rule routing',
76
- status: 'strengthened',
77
- sourcePaths: [
78
- 'AGENTS.md',
79
- '.agent-context/rules/architecture.md',
80
- '.agent-context/prompts/refactor.md',
81
- ],
82
- signal: 'Backend/API governance routes by problem domain and stays stack-agnostic; no stack-specific governance adapters are created.',
83
- },
84
- {
85
- constraint: 'Zero-trust input validation',
86
- status: 'strengthened',
87
- sourcePaths: [
88
- '.agent-context/rules/security.md',
89
- '.agent-context/review-checklists/pr-checklist.md',
90
- ],
91
- signal: 'User-controlled body, query, params, headers, cookies, files, webhooks, and job payloads must be validated before service logic.',
92
- },
93
- {
94
- constraint: 'Data access performance and integrity',
95
- status: 'strengthened',
96
- sourcePaths: [
97
- '.agent-context/rules/database-design.md',
98
- '.agent-context/rules/performance.md',
99
- '.agent-context/state/architecture-map.md',
100
- ],
101
- signal: 'Backend reads must avoid N+1 and unbounded list responses; multi-write mutations need transaction or recovery evidence.',
102
- },
103
- {
104
- constraint: 'Distributed consistency and outbox safety',
105
- status: 'strengthened',
106
- sourcePaths: [
107
- '.agent-context/rules/event-driven.md',
108
- '.agent-context/rules/database-design.md',
109
- '.agent-context/rules/microservices.md',
110
- ],
111
- signal: 'Dual-write flows need outbox or equivalent replay safety, and cross-service consistency must define saga, compensation, or recovery behavior instead of defaulting to two-phase commit.',
112
- },
113
- {
114
- constraint: 'Safe centralized API errors',
115
- status: 'strengthened',
116
- sourcePaths: [
117
- '.agent-context/rules/error-handling.md',
118
- '.agent-context/rules/api-docs.md',
119
- ],
120
- signal: 'HTTP/API responses use safe machine-readable error shapes, may align with RFC 9457 Problem Details, and preserve safe trace/correlation identifiers without leaking internals.',
121
- },
122
- {
123
- constraint: 'Sensitive mutation idempotency',
124
- status: 'strengthened',
125
- sourcePaths: [
126
- '.agent-context/rules/api-docs.md',
127
- '.agent-context/rules/testing.md',
128
- '.agent-context/rules/event-driven.md',
129
- ],
130
- signal: 'Payments, orders, status changes, and other risky mutations must document and test duplicate-submit behavior.',
131
- },
132
- {
133
- constraint: 'API contract and behavior testing',
134
- status: 'strengthened',
135
- sourcePaths: [
136
- '.agent-context/rules/testing.md',
137
- '.agent-context/review-checklists/pr-checklist.md',
138
- ],
139
- signal: 'API tests cover validation, auth, documented error shapes, pagination defaults, empty states, and mutation retry safety.',
140
- },
141
- ];
142
-
143
- function readJsonOrNull(filePath) {
144
- if (!existsSync(filePath)) {
145
- return null;
146
- }
147
-
148
- try {
149
- return JSON.parse(readFileSync(filePath, 'utf8'));
150
- } catch {
151
- return null;
152
- }
153
- }
154
-
155
- function runJsonScript(scriptRelativePath, scriptArguments = []) {
156
- const absoluteScriptPath = join(REPOSITORY_ROOT, scriptRelativePath);
157
- const commandResult = spawnSync('node', [absoluteScriptPath, ...scriptArguments], {
158
- cwd: REPOSITORY_ROOT,
159
- encoding: 'utf8',
160
- maxBuffer: 1024 * 1024 * 10,
161
- });
162
-
163
- const standardOutput = (commandResult.stdout || '').trim();
164
- const standardError = (commandResult.stderr || '').trim();
165
- const exitCode = typeof commandResult.status === 'number' ? commandResult.status : 1;
166
-
167
- if (!standardOutput) {
168
- return {
169
- scriptPath: scriptRelativePath,
170
- exitCode,
171
- parsedReport: null,
172
- parseError: 'Script produced no stdout JSON payload',
173
- stderr: standardError,
174
- };
175
- }
176
-
177
- try {
178
- return {
179
- scriptPath: scriptRelativePath,
180
- exitCode,
181
- parsedReport: JSON.parse(standardOutput),
182
- parseError: null,
183
- stderr: standardError,
184
- };
185
- } catch (jsonParseError) {
186
- const parseErrorMessage = jsonParseError instanceof Error ? jsonParseError.message : String(jsonParseError);
187
- return {
188
- scriptPath: scriptRelativePath,
189
- exitCode,
190
- parsedReport: null,
191
- parseError: parseErrorMessage,
192
- stderr: standardError,
193
- };
194
- }
195
- }
196
-
197
- function loadQualityTrendReport() {
198
- const existingQualityTrend = readJsonOrNull(QUALITY_TREND_PATH);
199
- if (existingQualityTrend) {
200
- return {
201
- source: 'state-file',
202
- report: existingQualityTrend,
203
- freshness: existingQualityTrend.generatedAt || null,
204
- };
205
- }
206
-
207
- const generatedQualityTrend = runJsonScript('scripts/quality-trend-report.mjs', ['--stdout-only']);
208
- return {
209
- source: 'generated-stdout',
210
- report: generatedQualityTrend.parsedReport,
211
- freshness: generatedQualityTrend.parsedReport?.generatedAt || null,
212
- parseError: generatedQualityTrend.parseError,
213
- exitCode: generatedQualityTrend.exitCode,
214
- };
215
- }
216
-
217
- function collectCommitSignals(windowDays) {
218
- const commitLogResult = spawnSync('git', ['log', `--since=${windowDays}.days`, '--pretty=format:%s'], {
219
- cwd: REPOSITORY_ROOT,
220
- encoding: 'utf8',
221
- maxBuffer: 1024 * 1024,
222
- });
223
-
224
- if (commitLogResult.status !== 0) {
225
- return {
226
- windowDays,
227
- commitCount: 0,
228
- releaseCommitCount: 0,
229
- rollbackCommitCount: 0,
230
- releaseFrequencyPercent: null,
231
- rollbackFrequencyPercent: null,
232
- error: (commitLogResult.stderr || 'Failed to read git log').trim(),
233
- };
234
- }
235
-
236
- const commitSubjects = (commitLogResult.stdout || '')
237
- .split(/\r?\n/u)
238
- .map((subjectLine) => subjectLine.trim())
239
- .filter((subjectLine) => subjectLine.length > 0);
240
-
241
- const commitCount = commitSubjects.length;
242
- const releaseCommitCount = commitSubjects.filter((subjectLine) => /release|publish|chore\(release\)/i.test(subjectLine)).length;
243
- const rollbackCommitCount = commitSubjects.filter((subjectLine) => /rollback|revert/i.test(subjectLine)).length;
244
-
245
- return {
246
- windowDays,
247
- commitCount,
248
- releaseCommitCount,
249
- rollbackCommitCount,
250
- releaseFrequencyPercent: commitCount === 0 ? 0 : Number(((releaseCommitCount / commitCount) * 100).toFixed(2)),
251
- rollbackFrequencyPercent: commitCount === 0 ? 0 : Number(((rollbackCommitCount / commitCount) * 100).toFixed(2)),
252
- error: null,
253
- };
254
- }
255
-
256
- async function collectGovernanceSurfaceTrustSignals() {
257
- const trustRows = [];
258
- const tierCounts = {
259
- verified: 0,
260
- community: 0,
261
- experimental: 0,
262
- };
263
-
264
- const sortedDomainNames = Array.from(REQUIRED_VERIFIED_DOMAINS).sort((leftName, rightName) => {
265
- return leftName.localeCompare(rightName);
266
- });
267
-
268
- for (const surfaceDomainName of sortedDomainNames) {
269
- const relativeSurfacePath = GOVERNANCE_SURFACE_PATHS[surfaceDomainName];
270
- const absoluteSurfacePath = join(REPOSITORY_ROOT, relativeSurfacePath);
271
- const surfaceExists = existsSync(absoluteSurfacePath);
272
- const trustTier = surfaceExists ? 'verified' : 'experimental';
273
- const trustScore = surfaceExists ? 100 : 0;
274
-
275
- if (typeof tierCounts[trustTier] === 'number') {
276
- tierCounts[trustTier] += 1;
277
- }
278
-
279
- trustRows.push({
280
- domain: surfaceDomainName,
281
- tier: trustTier,
282
- score: trustScore,
283
- sourcePath: relativeSurfacePath,
284
- });
285
- }
286
-
287
- const requiredVerifiedDomainFailures = trustRows
288
- .filter((trustRow) => REQUIRED_VERIFIED_DOMAINS.has(trustRow.domain) && trustRow.tier !== 'verified')
289
- .map((trustRow) => trustRow.domain);
290
-
291
- return {
292
- domains: trustRows,
293
- tierCounts,
294
- requiredVerifiedDomains: Array.from(REQUIRED_VERIFIED_DOMAINS),
295
- requiredVerifiedDomainFailures,
296
- allRequiredVerified: requiredVerifiedDomainFailures.length === 0,
297
- };
298
- }
299
-
300
- function buildBackendGovernancePosture(governanceSurfaceTrustSignals) {
301
- const backendSurfaceRows = governanceSurfaceTrustSignals.domains.filter((trustRow) => {
302
- return BACKEND_REQUIRED_DOMAIN_NAMES.has(trustRow.domain);
303
- });
304
- const missingBackendSurfaceNames = backendSurfaceRows
305
- .filter((trustRow) => trustRow.tier !== 'verified')
306
- .map((trustRow) => trustRow.domain);
307
- const verifiedSurfaceCount = backendSurfaceRows.length - missingBackendSurfaceNames.length;
308
-
309
- return {
310
- status: missingBackendSurfaceNames.length === 0 ? 'verified' : 'needs-attention',
311
- summary: missingBackendSurfaceNames.length === 0
312
- ? 'Backend governance is verified across architecture, security, data access, error handling, API contracts, testing, performance, idempotency, and risk-map surfaces.'
313
- : 'Backend governance is missing one or more required surfaces.',
314
- requiredSurfaceCount: backendSurfaceRows.length,
315
- verifiedSurfaceCount,
316
- missingSurfaceNames: missingBackendSurfaceNames,
317
- coverage: BACKEND_GOVERNANCE_COVERAGE,
318
- developmentFocus: [
319
- {
320
- focus: 'Keep backend guidance global and stack-agnostic.',
321
- reason: 'The repo should enforce architecture, security, API, data, error, event, and testing thinking without building Nest, Laravel, FastAPI, Express, Go, or other stack-specific governance adapters.',
322
- },
323
- {
324
- focus: 'Use framework facts only when implementing inside an existing project.',
325
- reason: 'LLMs can apply current ecosystem knowledge directly; governance should route the relevant global constraints instead of acting as a stack detector.',
326
- },
327
- ],
328
- };
329
- }
330
-
331
- function buildBlockers(qualityTrendReport, governanceSurfaceTrustSignals, commitSignals) {
332
- const blockers = [];
333
-
334
- const qualityGatePassRatePercent = qualityTrendReport?.governanceHealth?.gatePassRatePercent;
335
- if (typeof qualityGatePassRatePercent !== 'number' || qualityGatePassRatePercent < 100) {
336
- blockers.push('Governance gate pass rate is below 100%.');
337
- }
338
-
339
- if (!governanceSurfaceTrustSignals.allRequiredVerified) {
340
- blockers.push(
341
- `Required verified governance surfaces missing: ${governanceSurfaceTrustSignals.requiredVerifiedDomainFailures.join(', ')}`
342
- );
343
- }
344
-
345
- if (commitSignals.error) {
346
- blockers.push(`Commit signal extraction failed: ${commitSignals.error}`);
347
- }
348
-
349
- return blockers;
350
- }
351
-
352
- function buildHistoryEntry(weeklyReport) {
353
- return {
354
- generatedAt: weeklyReport.generatedAt,
355
- readinessStatus: weeklyReport.releaseReadiness.isReady ? 'ready' : 'blocked',
356
- blockerCount: weeklyReport.releaseReadiness.blockers.length,
357
- gatePassRatePercent: weeklyReport.qualitySignals.governanceHealth.gatePassRatePercent,
358
- verifiedGovernanceSurfaceCount: weeklyReport.governanceSurfaceTrust.tierCounts.verified,
359
- backendVerifiedSurfaceCount: weeklyReport.backendGovernance?.verifiedSurfaceCount ?? null,
360
- releaseFrequencyPercent: weeklyReport.commitSignals.releaseFrequencyPercent,
361
- rollbackFrequencyPercent: weeklyReport.commitSignals.rollbackFrequencyPercent,
362
- };
363
- }
364
-
365
- function normalizeHistoryEntry(historyEntry) {
366
- if (!historyEntry || typeof historyEntry !== 'object') {
367
- return historyEntry;
368
- }
369
-
370
- const {
371
- verifiedSkillDomainCount,
372
- ...normalizedHistoryEntry
373
- } = historyEntry;
374
-
375
- if (
376
- typeof normalizedHistoryEntry.verifiedGovernanceSurfaceCount !== 'number'
377
- && typeof verifiedSkillDomainCount === 'number'
378
- ) {
379
- normalizedHistoryEntry.verifiedGovernanceSurfaceCount = verifiedSkillDomainCount;
380
- }
381
-
382
- return normalizedHistoryEntry;
383
- }
384
-
385
- function mergeHistory(previousReport, currentHistoryEntry) {
386
- const existingHistory = Array.isArray(previousReport?.history)
387
- ? previousReport.history.map((historyEntry) => normalizeHistoryEntry(historyEntry))
388
- : [];
389
- const mergedHistory = [...existingHistory, currentHistoryEntry];
390
-
391
- if (mergedHistory.length <= HISTORY_LIMIT) {
392
- return mergedHistory;
393
- }
394
-
395
- return mergedHistory.slice(mergedHistory.length - HISTORY_LIMIT);
396
- }
397
-
398
- async function runWeeklyGovernanceReport() {
399
- const qualityTrendState = loadQualityTrendReport();
400
- const qualityTrendReport = qualityTrendState.report;
401
-
402
- const governanceSurfaceTrustSignals = await collectGovernanceSurfaceTrustSignals();
403
- const backendGovernance = buildBackendGovernancePosture(governanceSurfaceTrustSignals);
404
- const commitSignals = collectCommitSignals(WEEKLY_WINDOW_DAYS);
405
- const blockers = buildBlockers(qualityTrendReport, governanceSurfaceTrustSignals, commitSignals);
406
-
407
- const weeklyReportSnapshot = {
408
- generatedAt: new Date().toISOString(),
409
- reportName: 'weekly-governance-report',
410
- methodology: {
411
- qualityTrendSource: qualityTrendState.source,
412
- qualityTrendGeneratedAt: qualityTrendState.freshness,
413
- commitWindowDays: WEEKLY_WINDOW_DAYS,
414
- requiredVerifiedDomains: Array.from(REQUIRED_VERIFIED_DOMAINS),
415
- },
416
- qualitySignals: {
417
- governanceHealth: {
418
- availableGateCount: qualityTrendReport?.governanceHealth?.availableGateCount ?? null,
419
- passedGateCount: qualityTrendReport?.governanceHealth?.passedGateCount ?? null,
420
- gatePassRatePercent: qualityTrendReport?.governanceHealth?.gatePassRatePercent ?? null,
421
- },
422
- rejectionCategories: Array.isArray(qualityTrendReport?.rejectionCategories)
423
- ? qualityTrendReport.rejectionCategories
424
- : [],
425
- tokenEfficiency: qualityTrendReport?.tokenEfficiency || null,
426
- },
427
- governanceSurfaceTrust: governanceSurfaceTrustSignals,
428
- backendGovernance,
429
- commitSignals,
430
- releaseReadiness: {
431
- isReady: blockers.length === 0,
432
- blockers,
433
- summary: blockers.length === 0
434
- ? 'Weekly governance posture is ready for maintenance releases with frontend and backend governance surfaces verified.'
435
- : 'Weekly governance posture is blocked by unresolved readiness signals.',
436
- },
437
- artifact: {
438
- path: REPORT_PATH,
439
- writeMode: isStdoutOnlyMode ? 'stdout-only' : 'stdout-and-file',
440
- },
441
- };
442
-
443
- const previousReport = readJsonOrNull(REPORT_PATH);
444
- const history = mergeHistory(previousReport, buildHistoryEntry(weeklyReportSnapshot));
445
- const weeklyReport = {
446
- ...weeklyReportSnapshot,
447
- history,
448
- };
449
-
450
- if (!isStdoutOnlyMode) {
451
- await fs.mkdir(dirname(REPORT_PATH), { recursive: true });
452
- await fs.writeFile(REPORT_PATH, JSON.stringify(weeklyReport, null, 2) + '\n', 'utf8');
453
- }
454
-
455
- return weeklyReport;
456
- }
457
-
458
- runWeeklyGovernanceReport()
459
- .then((weeklyReport) => {
460
- console.log(JSON.stringify(weeklyReport, null, 2));
461
- })
462
- .catch((reportError) => {
463
- const errorMessage = reportError instanceof Error ? reportError.message : String(reportError);
464
- console.error(`Weekly governance report failed: ${errorMessage}`);
465
- process.exit(1);
466
- });
@@ -1,45 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * Loaders for the PR checklist content and the threshold profile JSON. The
5
- * thresholds loader returns a safe balanced-profile default when the policy
6
- * file is absent so the gate stays functional in fresh checkouts.
7
- */
8
-
9
- import { existsSync, readFileSync } from 'node:fs';
10
-
11
- import { PR_CHECKLIST_PATH, THRESHOLDS_PATH } from './constants.mjs';
12
-
13
- /**
14
- * Loads and returns the PR checklist markdown content.
15
- *
16
- * @returns {string} The checklist file contents
17
- */
18
- export function loadPrChecklist() {
19
- if (!existsSync(PR_CHECKLIST_PATH)) {
20
- throw new Error(`PR checklist not found at: ${PR_CHECKLIST_PATH}`);
21
- }
22
- return readFileSync(PR_CHECKLIST_PATH, 'utf-8');
23
- }
24
-
25
- /**
26
- * Loads the LLM judge thresholds, falling back to a safe balanced-profile
27
- * default when the policy file is missing.
28
- *
29
- * @returns {any} The thresholds object
30
- */
31
- export function loadThresholds() {
32
- if (!existsSync(THRESHOLDS_PATH)) {
33
- return {
34
- selectedProfile: 'balanced',
35
- profileThresholds: {
36
- balanced: {
37
- blockingSeverities: ['critical', 'high'],
38
- failOnMalformedResponse: true,
39
- failOnProviderError: false,
40
- },
41
- },
42
- };
43
- }
44
- return JSON.parse(readFileSync(THRESHOLDS_PATH, 'utf-8'));
45
- }
@@ -1,66 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * Static configuration for the LLM judge CI gate. Centralizes paths, env-driven
5
- * settings, and severity normalization so the rest of the pipeline reads from a
6
- * single config surface.
7
- */
8
-
9
- import { resolve, dirname } from 'node:path';
10
- import { fileURLToPath } from 'node:url';
11
-
12
- const __filename = fileURLToPath(import.meta.url);
13
- const __dirname = dirname(__filename);
14
-
15
- export const REPOSITORY_ROOT = resolve(__dirname, '..', '..');
16
- export const PR_CHECKLIST_PATH = resolve(REPOSITORY_ROOT, '.agent-context/review-checklists/pr-checklist.md');
17
- export const THRESHOLDS_PATH = resolve(REPOSITORY_ROOT, '.agent-context/policies/llm-judge-threshold.json');
18
- export const DEFAULT_MACHINE_REPORT_PATH = resolve(REPOSITORY_ROOT, '.agent-context/state/llm-judge-report.json');
19
-
20
- export const MAX_DIFF_CHARS = parseInt(process.env.LLM_MAX_DIFF_CHARS ?? '12000', 10);
21
- export const IS_DRY_RUN = process.argv.includes('--dry-run');
22
- export const SHOULD_EMIT_MACHINE_REPORT = process.env.LLM_JUDGE_EMIT_JSON !== 'false';
23
- export const MACHINE_REPORT_PATH = process.env.LLM_JUDGE_OUTPUT_PATH || DEFAULT_MACHINE_REPORT_PATH;
24
-
25
- /** @type {Record<string, string>} */
26
- export const SEVERITY_NORMALIZATION_TABLE = {
27
- critical: 'critical',
28
- blocker: 'critical',
29
- severe: 'critical',
30
- high: 'high',
31
- major: 'high',
32
- medium: 'medium',
33
- moderate: 'medium',
34
- low: 'low',
35
- minor: 'low',
36
- info: 'low',
37
- informational: 'low',
38
- };
39
-
40
- /**
41
- * @typedef {{
42
- * rule: string,
43
- * problem: string,
44
- * severity: string,
45
- * }} Violation
46
- */
47
-
48
- /**
49
- * @typedef {{
50
- * generatedAt: string,
51
- * schemaVersion: string,
52
- * profile: string,
53
- * provider: string,
54
- * ciProvider: string,
55
- * blockingSeverities: string[],
56
- * failDecision: boolean,
57
- * malformedVerdict: boolean,
58
- * providerError: boolean,
59
- * dryRun: boolean,
60
- * summary: {
61
- * totalViolations: number,
62
- * blockingViolations: number,
63
- * },
64
- * violations: Violation[],
65
- * }} MachineReportPayload
66
- */
@@ -1,74 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * Git diff collection for the LLM judge. Selects the best available diff source
5
- * based on environment signals (PR_DIFF override, GitHub Actions, GitLab CI),
6
- * with a local HEAD~1..HEAD fallback that handles the initial-commit edge case
7
- * by diffing against Git's empty-tree object.
8
- */
9
-
10
- import { execSync } from 'node:child_process';
11
-
12
- import { REPOSITORY_ROOT } from './constants.mjs';
13
-
14
- export function detectCiProvider() {
15
- if (process.env.GITHUB_ACTIONS === 'true') {
16
- return 'github';
17
- }
18
-
19
- if (process.env.GITLAB_CI === 'true') {
20
- return 'gitlab';
21
- }
22
-
23
- return 'local';
24
- }
25
-
26
- /**
27
- * Collects the pull request diff from the best available source:
28
- * 1. PR_DIFF env var (direct injection, highest priority)
29
- * 2. GitHub Actions env vars (GITHUB_BASE_SHA / GITHUB_HEAD_SHA)
30
- * 3. GitLab CI env vars (CI_MERGE_REQUEST_DIFF_BASE_SHA / CI_COMMIT_SHA)
31
- * 4. Local fallback: HEAD~1..HEAD, then empty-tree if no parent exists
32
- *
33
- * @returns {string} The raw git diff output
34
- */
35
- export function collectPullRequestDiff() {
36
- if (process.env.PR_DIFF) {
37
- console.log(' Source: PR_DIFF env variable');
38
- return process.env.PR_DIFF;
39
- }
40
-
41
- const execOptions = {
42
- cwd: REPOSITORY_ROOT,
43
- encoding: /** @type {'utf-8'} */ ('utf-8'),
44
- maxBuffer: 1024 * 1024 * 8,
45
- stdio: /** @type {['ignore', 'pipe', 'ignore']} */ (['ignore', 'pipe', 'ignore']),
46
- };
47
-
48
- const githubBaseSha = process.env.GITHUB_BASE_SHA;
49
- const githubHeadSha = process.env.GITHUB_HEAD_SHA ?? 'HEAD';
50
- if (githubBaseSha) {
51
- console.log(` Source: GitHub Actions diff (${githubBaseSha.slice(0, 8)}...${githubHeadSha.slice(0, 8)})`);
52
- return execSync(`git diff "${githubBaseSha}...${githubHeadSha}"`, execOptions);
53
- }
54
-
55
- const gitlabBaseSha = process.env.CI_MERGE_REQUEST_DIFF_BASE_SHA;
56
- const gitlabHeadSha = process.env.CI_COMMIT_SHA ?? 'HEAD';
57
- if (gitlabBaseSha) {
58
- console.log(` Source: GitLab CI diff (${gitlabBaseSha.slice(0, 8)}...${gitlabHeadSha.slice(0, 8)})`);
59
- return execSync(`git diff "${gitlabBaseSha}...${gitlabHeadSha}"`, execOptions);
60
- }
61
-
62
- console.log(' Source: local HEAD~1..HEAD fallback');
63
- try {
64
- return execSync('git diff HEAD~1 HEAD', execOptions);
65
- } catch {
66
- try {
67
- const emptyTreeSha = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
68
- return execSync(`git diff "${emptyTreeSha}" HEAD`, execOptions);
69
- } catch {
70
- console.warn(' ⚠️ Unable to execute git diff. Defaulting to empty diff.');
71
- return '';
72
- }
73
- }
74
- }