@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,322 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * memory-continuity-benchmark.mjs
5
- *
6
- * Provider-agnostic continuity benchmark for cross-agent memory retrieval.
7
- * Measures new-session hydration relevance, token savings, and privacy redaction safety.
8
- */
9
-
10
- import { existsSync, readFileSync } from 'node:fs';
11
- import fs from 'node:fs/promises';
12
- import { dirname, join, resolve } from 'node:path';
13
- import { fileURLToPath } from 'node:url';
14
- import {
15
- MEMORY_SCHEMA_VERSION,
16
- SUPPORTED_MEMORY_ADAPTER_IDS,
17
- normalizeMemoryObservation,
18
- buildSessionStartIndex,
19
- hydrateIndexedObservations,
20
- estimateTokenUsage,
21
- } from '../lib/cli/memory-continuity.mjs';
22
-
23
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
24
- const SCRIPT_DIR = dirname(SCRIPT_FILE_PATH);
25
- const REPOSITORY_ROOT = resolve(SCRIPT_DIR, '..');
26
- const ARGUMENT_FLAGS = new Set(process.argv.slice(2));
27
- const isStdoutOnlyMode = ARGUMENT_FLAGS.has('--stdout-only');
28
-
29
- const MEMORY_SCHEMA_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'memory-schema-v1.json');
30
- const MEMORY_ADAPTER_CONTRACT_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'memory-adapter-contract.json');
31
- const OUTPUT_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'memory-continuity-benchmark.json');
32
-
33
- const THRESHOLDS = {
34
- minimumRelevantRecall: 0.8,
35
- minimumSessionStartTokenSavingsPercent: 35,
36
- maximumUnsafeObservationCount: 0,
37
- };
38
-
39
- const MEMORY_FIXTURES = [
40
- {
41
- id: 'obs-001',
42
- adapterId: 'claude-code',
43
- eventType: 'decision',
44
- projectId: 'agentic-senior-core',
45
- sessionId: 'session-a',
46
- timestamp: '2026-04-17T02:30:00.000Z',
47
- title: 'Docker development lane agreed',
48
- summary: 'Team agreed Docker for development and production lanes with separate optimization priorities.',
49
- detail: 'Use compose for local build loop. Production images must stay minimal. api_key=prod-key-placeholder should be stored outside code.',
50
- tags: ['docker', 'dev-prod-split', 'runtime'],
51
- privacyLevel: 'internal',
52
- },
53
- {
54
- id: 'obs-002',
55
- adapterId: 'gemini-cli',
56
- eventType: 'context',
57
- projectId: 'agentic-senior-core',
58
- sessionId: 'session-b',
59
- timestamp: '2026-04-17T02:31:00.000Z',
60
- title: 'Runtime environment policy',
61
- summary: 'Windows and Linux or WSL command context should be explicit in generated guidance.',
62
- detail: 'Runtime hint: prefer linux-wsl for container tasks on Windows hosts. <private>internal machine hostname and user alias</private>',
63
- tags: ['runtime', 'linux-wsl', 'windows'],
64
- privacyLevel: 'restricted',
65
- },
66
- {
67
- id: 'obs-003',
68
- adapterId: 'vscode-chat',
69
- eventType: 'summary',
70
- projectId: 'agentic-senior-core',
71
- sessionId: 'session-c',
72
- timestamp: '2026-04-17T02:32:00.000Z',
73
- title: 'Frontend excellence baseline',
74
- summary: 'Frontend rubric must enforce visual direction, typography intent, and responsive behavior checks.',
75
- detail: 'Use diversity checks for layout and style systems, and avoid template output repetition.',
76
- tags: ['frontend', 'rubric', 'quality'],
77
- privacyLevel: 'internal',
78
- },
79
- {
80
- id: 'obs-004',
81
- adapterId: 'claude-code',
82
- eventType: 'issue',
83
- projectId: 'agentic-senior-core',
84
- sessionId: 'session-d',
85
- timestamp: '2026-04-17T02:33:00.000Z',
86
- title: 'Nested template conditional issue',
87
- summary: 'Nested conditional blocks caused unresolved placeholders in generated docs.',
88
- detail: 'Fix by precomputing placeholder text before rendering template.',
89
- tags: ['template', 'rendering', 'fix'],
90
- privacyLevel: 'internal',
91
- },
92
- {
93
- id: 'obs-005',
94
- adapterId: 'gemini-cli',
95
- eventType: 'tool-use',
96
- projectId: 'agentic-senior-core',
97
- sessionId: 'session-e',
98
- timestamp: '2026-04-17T02:34:00.000Z',
99
- title: 'Benchmark trend report generated',
100
- summary: 'History and trend csv outputs are generated each run for release-over-release review.',
101
- detail: 'Artifacts include benchmark-history json and benchmark-trend-report csv for quick chart ingestion.',
102
- tags: ['benchmark', 'trend', 'history'],
103
- privacyLevel: 'internal',
104
- },
105
- ];
106
-
107
- const CONTINUITY_SCENARIOS = [
108
- {
109
- scenarioId: 'docker-lane-hydration',
110
- query: 'what is docker strategy for development and production',
111
- expectedObservationIds: ['obs-001'],
112
- },
113
- {
114
- scenarioId: 'runtime-hydration',
115
- query: 'which runtime target should we prefer on windows with wsl',
116
- expectedObservationIds: ['obs-002'],
117
- },
118
- {
119
- scenarioId: 'frontend-quality-hydration',
120
- query: 'show frontend rubric quality decisions',
121
- expectedObservationIds: ['obs-003'],
122
- },
123
- ];
124
-
125
- function readJsonOrNull(filePath) {
126
- if (!existsSync(filePath)) {
127
- return null;
128
- }
129
-
130
- try {
131
- return JSON.parse(readFileSync(filePath, 'utf8'));
132
- } catch {
133
- return null;
134
- }
135
- }
136
-
137
- function calculateRecall(expectedObservationIds, selectedIds) {
138
- if (!Array.isArray(expectedObservationIds) || expectedObservationIds.length === 0) {
139
- return 1;
140
- }
141
-
142
- const selectedIdSet = new Set(selectedIds);
143
- const matchedCount = expectedObservationIds.filter((expectedId) => selectedIdSet.has(expectedId)).length;
144
- return Number((matchedCount / expectedObservationIds.length).toFixed(4));
145
- }
146
-
147
- function summarizePrivacyControls(normalizedObservations) {
148
- const redactedObservationCount = normalizedObservations.filter(
149
- (normalizedObservation) => normalizedObservation.privacy.redactionApplied
150
- ).length;
151
-
152
- const privateTagRedactionCount = normalizedObservations.reduce(
153
- (countAccumulator, normalizedObservation) => countAccumulator + normalizedObservation.privacy.privateTagRedactionCount,
154
- 0
155
- );
156
-
157
- const inlineRedactionCount = normalizedObservations.reduce(
158
- (countAccumulator, normalizedObservation) => countAccumulator + normalizedObservation.privacy.inlineRedactionCount,
159
- 0
160
- );
161
-
162
- const unsafeObservationCount = normalizedObservations.filter((normalizedObservation) => {
163
- const detailText = String(normalizedObservation.detail || '');
164
- return /<private>/i.test(detailText);
165
- }).length;
166
-
167
- return {
168
- redactedObservationCount,
169
- privateTagRedactionCount,
170
- inlineRedactionCount,
171
- unsafeObservationCount,
172
- };
173
- }
174
-
175
- function buildAdapterCoverage(adapterContract) {
176
- const requiredAdapterIds = Array.isArray(adapterContract?.requiredAdapters)
177
- ? adapterContract.requiredAdapters
178
- : [...SUPPORTED_MEMORY_ADAPTER_IDS];
179
-
180
- const declaredAdapters = Array.isArray(adapterContract?.adapters)
181
- ? adapterContract.adapters.map((adapterEntry) => adapterEntry.adapterId)
182
- : [];
183
-
184
- const availableAdapterIds = Array.from(new Set([
185
- ...SUPPORTED_MEMORY_ADAPTER_IDS,
186
- ...declaredAdapters,
187
- ])).sort();
188
-
189
- const missingAdapterIds = requiredAdapterIds.filter(
190
- (requiredAdapterId) => !availableAdapterIds.includes(requiredAdapterId)
191
- );
192
-
193
- return {
194
- requiredAdapterIds,
195
- availableAdapterIds,
196
- missingAdapterIds,
197
- passed: missingAdapterIds.length === 0,
198
- };
199
- }
200
-
201
- async function runMemoryContinuityBenchmark() {
202
- const memorySchema = readJsonOrNull(MEMORY_SCHEMA_PATH);
203
- const memoryAdapterContract = readJsonOrNull(MEMORY_ADAPTER_CONTRACT_PATH);
204
-
205
- const normalizedObservations = MEMORY_FIXTURES.map((memoryFixture) => normalizeMemoryObservation(memoryFixture));
206
-
207
- const fullContextTokenEstimate = normalizedObservations.reduce(
208
- (tokenAccumulator, normalizedObservation) => tokenAccumulator
209
- + estimateTokenUsage(normalizedObservation.title)
210
- + estimateTokenUsage(normalizedObservation.summary)
211
- + estimateTokenUsage(normalizedObservation.detail),
212
- 0
213
- );
214
-
215
- const scenarioResults = CONTINUITY_SCENARIOS.map((continuityScenario) => {
216
- const sessionStartIndex = buildSessionStartIndex(normalizedObservations, {
217
- queryText: continuityScenario.query,
218
- limit: 5,
219
- });
220
-
221
- const hydration = hydrateIndexedObservations(
222
- sessionStartIndex.indexEntries,
223
- normalizedObservations,
224
- { fullFetchLimit: 1 }
225
- );
226
-
227
- const recall = calculateRecall(continuityScenario.expectedObservationIds, hydration.selectedIds);
228
- const sessionStartTokenEstimate = sessionStartIndex.totalTokenEstimate + hydration.hydrationTokenEstimate;
229
- const tokenSavingsPercent = fullContextTokenEstimate === 0
230
- ? 0
231
- : Number((((fullContextTokenEstimate - sessionStartTokenEstimate) / fullContextTokenEstimate) * 100).toFixed(2));
232
-
233
- return {
234
- scenarioId: continuityScenario.scenarioId,
235
- query: continuityScenario.query,
236
- expectedObservationIds: continuityScenario.expectedObservationIds,
237
- indexObservationIds: sessionStartIndex.indexEntries.map((indexEntry) => indexEntry.id),
238
- hydratedObservationIds: hydration.selectedIds,
239
- relevantRecall: recall,
240
- fullContextTokenEstimate,
241
- sessionStartTokenEstimate,
242
- sessionStartTokenSavingsPercent: tokenSavingsPercent,
243
- };
244
- });
245
-
246
- const averageRelevantRecall = Number((
247
- scenarioResults.reduce((sum, scenarioResult) => sum + scenarioResult.relevantRecall, 0)
248
- / scenarioResults.length
249
- ).toFixed(4));
250
-
251
- const averageSessionStartTokenSavingsPercent = Number((
252
- scenarioResults.reduce((sum, scenarioResult) => sum + scenarioResult.sessionStartTokenSavingsPercent, 0)
253
- / scenarioResults.length
254
- ).toFixed(2));
255
-
256
- const privacyControls = summarizePrivacyControls(normalizedObservations);
257
- const adapterCoverage = buildAdapterCoverage(memoryAdapterContract);
258
-
259
- const checks = [
260
- {
261
- checkName: 'adapter-coverage',
262
- passed: adapterCoverage.passed,
263
- details: `required=${adapterCoverage.requiredAdapterIds.length} missing=${adapterCoverage.missingAdapterIds.length}`,
264
- },
265
- {
266
- checkName: 'continuity-recall-threshold',
267
- passed: averageRelevantRecall >= THRESHOLDS.minimumRelevantRecall,
268
- details: `averageRelevantRecall=${averageRelevantRecall} minimum=${THRESHOLDS.minimumRelevantRecall}`,
269
- },
270
- {
271
- checkName: 'session-start-token-savings-threshold',
272
- passed: averageSessionStartTokenSavingsPercent >= THRESHOLDS.minimumSessionStartTokenSavingsPercent,
273
- details: `averageSessionStartTokenSavingsPercent=${averageSessionStartTokenSavingsPercent} minimum=${THRESHOLDS.minimumSessionStartTokenSavingsPercent}`,
274
- },
275
- {
276
- checkName: 'privacy-redaction-safety',
277
- passed: privacyControls.unsafeObservationCount <= THRESHOLDS.maximumUnsafeObservationCount,
278
- details: `unsafeObservationCount=${privacyControls.unsafeObservationCount} max=${THRESHOLDS.maximumUnsafeObservationCount}`,
279
- },
280
- ];
281
-
282
- const failureCount = checks.filter((checkResult) => !checkResult.passed).length;
283
-
284
- const reportPayload = {
285
- generatedAt: new Date().toISOString(),
286
- reportName: 'memory-continuity-benchmark',
287
- schemaVersion: MEMORY_SCHEMA_VERSION,
288
- passed: failureCount === 0,
289
- failureCount,
290
- thresholds: THRESHOLDS,
291
- adapterCoverage,
292
- privacyControls,
293
- continuitySummary: {
294
- totalObservationCount: normalizedObservations.length,
295
- scenarioCount: scenarioResults.length,
296
- averageRelevantRecall,
297
- averageSessionStartTokenSavingsPercent,
298
- },
299
- scenarios: scenarioResults,
300
- references: {
301
- memorySchemaPath: '.agent-context/state/memory-schema-v1.json',
302
- memoryAdapterContractPath: '.agent-context/state/memory-adapter-contract.json',
303
- benchmarkOutputPath: '.agent-context/state/memory-continuity-benchmark.json',
304
- schemaDeclaredVersion: memorySchema?.schemaVersion || null,
305
- adapterContractVersion: memoryAdapterContract?.schemaVersion || null,
306
- },
307
- checks,
308
- };
309
-
310
- if (!isStdoutOnlyMode) {
311
- await fs.writeFile(OUTPUT_PATH, JSON.stringify(reportPayload, null, 2) + '\n', 'utf8');
312
- }
313
-
314
- console.log(JSON.stringify(reportPayload, null, 2));
315
- process.exit(reportPayload.passed ? 0 : 1);
316
- }
317
-
318
- runMemoryContinuityBenchmark().catch((benchmarkError) => {
319
- const errorMessage = benchmarkError instanceof Error ? benchmarkError.message : String(benchmarkError);
320
- console.error(`Memory continuity benchmark failed: ${errorMessage}`);
321
- process.exit(1);
322
- });
@@ -1,289 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * quality-trend-report.mjs
5
- *
6
- * Generates a machine-readable quality trend artifact that summarizes
7
- * governance gate pass rates, rejection categories, rollback frequency,
8
- * and token-efficiency signals.
9
- */
10
-
11
- import { existsSync, readFileSync } 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', 'quality-trend-report.json');
21
- const TOKEN_BENCHMARK_PATH = join(REPOSITORY_ROOT, '.agent-context', 'state', 'token-optimization-benchmark.json');
22
- const ARGUMENT_FLAGS = new Set(process.argv.slice(2));
23
- const isStdoutOnlyMode = ARGUMENT_FLAGS.has('--stdout-only');
24
- const MAX_SNAPSHOT_HISTORY = 30;
25
- const ROLLBACK_WINDOW_DAYS = 30;
26
-
27
- function runJsonScript(scriptRelativePath) {
28
- const absoluteScriptPath = join(REPOSITORY_ROOT, scriptRelativePath);
29
- const commandResult = spawnSync('node', [absoluteScriptPath], {
30
- cwd: REPOSITORY_ROOT,
31
- encoding: 'utf8',
32
- maxBuffer: 1024 * 1024 * 10,
33
- });
34
-
35
- const standardOutput = (commandResult.stdout || '').trim();
36
- const standardError = (commandResult.stderr || '').trim();
37
- const exitCode = typeof commandResult.status === 'number' ? commandResult.status : 1;
38
-
39
- if (!standardOutput) {
40
- return {
41
- scriptPath: scriptRelativePath,
42
- exitCode,
43
- parsedReport: null,
44
- parseError: 'Script produced no stdout JSON payload',
45
- stderr: standardError,
46
- };
47
- }
48
-
49
- try {
50
- const parsedReport = JSON.parse(standardOutput);
51
- return {
52
- scriptPath: scriptRelativePath,
53
- exitCode,
54
- parsedReport,
55
- parseError: null,
56
- stderr: standardError,
57
- };
58
- } catch (jsonParseError) {
59
- const errorMessage = jsonParseError instanceof Error ? jsonParseError.message : String(jsonParseError);
60
- return {
61
- scriptPath: scriptRelativePath,
62
- exitCode,
63
- parsedReport: null,
64
- parseError: errorMessage,
65
- stderr: standardError,
66
- };
67
- }
68
- }
69
-
70
- function readJsonFileOrNull(filePath) {
71
- if (!existsSync(filePath)) {
72
- return null;
73
- }
74
-
75
- try {
76
- return JSON.parse(readFileSync(filePath, 'utf8'));
77
- } catch {
78
- return null;
79
- }
80
- }
81
-
82
- function summarizeGateExecution(gateExecutionResults) {
83
- const gateSummaries = gateExecutionResults.map((gateExecutionResult) => {
84
- const gateReport = gateExecutionResult.parsedReport;
85
- return {
86
- scriptPath: gateExecutionResult.scriptPath,
87
- gateName: gateReport?.gateName || gateReport?.reportName || gateExecutionResult.scriptPath,
88
- exitCode: gateExecutionResult.exitCode,
89
- passed: typeof gateReport?.passed === 'boolean' ? gateReport.passed : false,
90
- parseError: gateExecutionResult.parseError,
91
- failureCount: typeof gateReport?.failureCount === 'number' ? gateReport.failureCount : null,
92
- generatedAt: gateReport?.generatedAt || null,
93
- };
94
- });
95
-
96
- const availableGateCount = gateSummaries.length;
97
- const passedGateCount = gateSummaries.filter((gateSummary) => gateSummary.passed).length;
98
- const gatePassRatePercent = availableGateCount === 0
99
- ? 0
100
- : Number(((passedGateCount / availableGateCount) * 100).toFixed(2));
101
-
102
- return {
103
- gateSummaries,
104
- availableGateCount,
105
- passedGateCount,
106
- gatePassRatePercent,
107
- };
108
- }
109
-
110
- function collectRejectionCategories(gateExecutionResults) {
111
- const rejectionCategoryMap = new Map();
112
-
113
- for (const gateExecutionResult of gateExecutionResults) {
114
- const gateReport = gateExecutionResult.parsedReport;
115
- const gateName = gateReport?.gateName || gateReport?.reportName || gateExecutionResult.scriptPath;
116
- const gateResults = Array.isArray(gateReport?.results) ? gateReport.results : [];
117
-
118
- for (const checkResult of gateResults) {
119
- if (checkResult?.passed === true) {
120
- continue;
121
- }
122
-
123
- const checkName = typeof checkResult?.checkName === 'string' ? checkResult.checkName : 'unknown-check';
124
- const existingCategory = rejectionCategoryMap.get(checkName) || {
125
- checkName,
126
- count: 0,
127
- gates: new Set(),
128
- };
129
-
130
- existingCategory.count += 1;
131
- existingCategory.gates.add(gateName);
132
- rejectionCategoryMap.set(checkName, existingCategory);
133
- }
134
- }
135
-
136
- return Array.from(rejectionCategoryMap.values())
137
- .map((rejectionCategory) => ({
138
- checkName: rejectionCategory.checkName,
139
- count: rejectionCategory.count,
140
- gates: Array.from(rejectionCategory.gates),
141
- }))
142
- .sort((firstCategory, secondCategory) => secondCategory.count - firstCategory.count);
143
- }
144
-
145
- function calculateRollbackFrequencySnapshot() {
146
- const gitLogResult = spawnSync('git', ['log', `--since=${ROLLBACK_WINDOW_DAYS}.days`, '--pretty=format:%s'], {
147
- cwd: REPOSITORY_ROOT,
148
- encoding: 'utf8',
149
- maxBuffer: 1024 * 1024,
150
- });
151
-
152
- if (gitLogResult.status !== 0) {
153
- return {
154
- windowDays: ROLLBACK_WINDOW_DAYS,
155
- commitCount: 0,
156
- rollbackCommitCount: 0,
157
- rollbackFrequencyPercent: null,
158
- source: 'git-log',
159
- error: (gitLogResult.stderr || 'Failed to read git log').trim(),
160
- };
161
- }
162
-
163
- const commitSubjects = (gitLogResult.stdout || '')
164
- .split(/\r?\n/u)
165
- .map((subjectLine) => subjectLine.trim())
166
- .filter((subjectLine) => subjectLine.length > 0);
167
-
168
- const rollbackCommitCount = commitSubjects.filter((subjectLine) => /rollback/i.test(subjectLine)).length;
169
- const commitCount = commitSubjects.length;
170
- const rollbackFrequencyPercent = commitCount === 0
171
- ? 0
172
- : Number(((rollbackCommitCount / commitCount) * 100).toFixed(2));
173
-
174
- return {
175
- windowDays: ROLLBACK_WINDOW_DAYS,
176
- commitCount,
177
- rollbackCommitCount,
178
- rollbackFrequencyPercent,
179
- source: 'git-log',
180
- error: null,
181
- };
182
- }
183
-
184
- function summarizeTokenBenchmark() {
185
- const tokenBenchmarkReport = readJsonFileOrNull(TOKEN_BENCHMARK_PATH);
186
- if (!tokenBenchmarkReport) {
187
- return {
188
- isAvailable: false,
189
- generatedAt: null,
190
- averageNativeSavingsPercent: null,
191
- averageRtkSavingsPercent: null,
192
- scenarioCount: 0,
193
- };
194
- }
195
-
196
- return {
197
- isAvailable: true,
198
- generatedAt: tokenBenchmarkReport.generatedAt || null,
199
- averageNativeSavingsPercent: tokenBenchmarkReport.summary?.averageNativeSavingsPercent ?? null,
200
- averageRtkSavingsPercent: tokenBenchmarkReport.summary?.averageRtkSavingsPercent ?? null,
201
- scenarioCount: Array.isArray(tokenBenchmarkReport.scenarios) ? tokenBenchmarkReport.scenarios.length : 0,
202
- };
203
- }
204
-
205
- function loadPreviousTrendHistory() {
206
- const previousReport = readJsonFileOrNull(REPORT_PATH);
207
- if (!previousReport || !Array.isArray(previousReport.history)) {
208
- return [];
209
- }
210
-
211
- return previousReport.history;
212
- }
213
-
214
- function buildHistoryEntry(currentSnapshot) {
215
- return {
216
- generatedAt: currentSnapshot.generatedAt,
217
- gatePassRatePercent: currentSnapshot.governanceHealth.gatePassRatePercent,
218
- passedGateCount: currentSnapshot.governanceHealth.passedGateCount,
219
- availableGateCount: currentSnapshot.governanceHealth.availableGateCount,
220
- rollbackFrequencyPercent: currentSnapshot.rollbackSignals.rollbackFrequencyPercent,
221
- averageNativeSavingsPercent: currentSnapshot.tokenEfficiency.averageNativeSavingsPercent,
222
- averageRtkSavingsPercent: currentSnapshot.tokenEfficiency.averageRtkSavingsPercent,
223
- rejectionCategoryCount: currentSnapshot.rejectionCategories.length,
224
- };
225
- }
226
-
227
- function mergeHistory(previousHistoryEntries, currentHistoryEntry) {
228
- const mergedHistoryEntries = [...previousHistoryEntries, currentHistoryEntry];
229
- if (mergedHistoryEntries.length <= MAX_SNAPSHOT_HISTORY) {
230
- return mergedHistoryEntries;
231
- }
232
-
233
- return mergedHistoryEntries.slice(mergedHistoryEntries.length - MAX_SNAPSHOT_HISTORY);
234
- }
235
-
236
- async function runQualityTrendReport() {
237
- const releaseGateExecution = runJsonScript('scripts/release-gate.mjs');
238
- const benchmarkGateExecution = runJsonScript('scripts/benchmark-gate.mjs');
239
- const benchmarkIntelligenceExecution = runJsonScript('scripts/benchmark-intelligence.mjs');
240
- const gateExecutionResults = [releaseGateExecution, benchmarkGateExecution, benchmarkIntelligenceExecution];
241
-
242
- const governanceHealth = summarizeGateExecution(gateExecutionResults);
243
- const rejectionCategories = collectRejectionCategories(gateExecutionResults);
244
- const rollbackSignals = calculateRollbackFrequencySnapshot();
245
- const tokenEfficiency = summarizeTokenBenchmark();
246
-
247
- const qualityTrendSnapshot = {
248
- generatedAt: new Date().toISOString(),
249
- reportName: 'quality-trend-report',
250
- methodology: {
251
- gateSources: gateExecutionResults.map((gateExecutionResult) => gateExecutionResult.scriptPath),
252
- rollbackSource: 'git log commit subjects within 30-day window',
253
- tokenSource: '.agent-context/state/token-optimization-benchmark.json',
254
- },
255
- governanceHealth,
256
- rejectionCategories,
257
- rollbackSignals,
258
- tokenEfficiency,
259
- artifact: {
260
- path: REPORT_PATH,
261
- writeMode: isStdoutOnlyMode ? 'stdout-only' : 'stdout-and-file',
262
- },
263
- };
264
-
265
- const previousHistoryEntries = loadPreviousTrendHistory();
266
- const currentHistoryEntry = buildHistoryEntry(qualityTrendSnapshot);
267
- const history = mergeHistory(previousHistoryEntries, currentHistoryEntry);
268
- const qualityTrendReport = {
269
- ...qualityTrendSnapshot,
270
- history,
271
- };
272
-
273
- if (!isStdoutOnlyMode) {
274
- await fs.mkdir(dirname(REPORT_PATH), { recursive: true });
275
- await fs.writeFile(REPORT_PATH, JSON.stringify(qualityTrendReport, null, 2) + '\n', 'utf8');
276
- }
277
-
278
- return qualityTrendReport;
279
- }
280
-
281
- runQualityTrendReport()
282
- .then((qualityTrendReport) => {
283
- console.log(JSON.stringify(qualityTrendReport, null, 2));
284
- })
285
- .catch((qualityTrendError) => {
286
- const errorMessage = qualityTrendError instanceof Error ? qualityTrendError.message : String(qualityTrendError);
287
- console.error(`Quality trend report failed: ${errorMessage}`);
288
- process.exit(1);
289
- });