feat: confluence benchmark, pattern extractor, agent KB, UX spec

- extract-patterns.js: mines layered arch, ArgoCD appsets, cloud regions,
  CIDR allocations, naming conventions, sync waves, tech stack from code
- agent-kb.js: token-efficient JSON rendering of same doc tree
- eval-confluence-ref-questions.json: 32 reference-only benchmark questions
- wiggum-v2.sh: Ralph Wiggum loop targeting confluence baseline (77.8%)
- docs/human-ux-spec.md: BMad UX designer spec for human doc structure
- Eval results: V2 at 28.7% vs confluence 77.8% baseline
- Hub/spoke ownership now correctly extracted (95% on that question)
- Naming conventions, regions, CIDRs surfaced in system-architecture.md
This commit is contained in:
Jarvis Prime
2026-03-10 14:20:35 +00:00
parent 049609a358
commit 0265ec7a60
844 changed files with 2129910 additions and 30 deletions

83
agent-kb.js Normal file
View File

@@ -0,0 +1,83 @@
/**
* agent-kb.js — Render V2 docs as token-efficient JSON for AI agents.
*
* Output: A single JSON file mirroring the markdown doc structure exactly, but
* stripped of markdown formatting to save context tokens during agent eval.
*/
const fs = require('fs');
const path = require('path');
/**
* Build the agent knowledge base from the exact same data used to render the markdown docs.
*/
function buildAgentKB(graph, srcRoot, helmCharts, subs, contractsResult, patterns, impactResults) {
const kb = {
_meta: {
generated: new Date().toISOString(),
format: 'dev-intel-agent-kb-v2',
description: 'Token-efficient rendering of Dev Intel V2 documentation for AI agents.',
},
reference: {
systemArchitecture: {
summary: {
subsystemCount: subs.subsystems.length,
helmChartCount: helmCharts.length,
contractCount: contractsResult.contracts.length,
crossCuttingConcerns: subs.crossCutting,
},
patterns: patterns,
},
subsystems: subs.subsystems.map(sub => {
const outgoing = Object.entries(subs.dependencyMatrix)
.filter(([k]) => k.startsWith(sub.name + '→'))
.map(([k, v]) => ({ target: k.split('→')[1], calls: v.calls, imports: v.imports }));
const incoming = Object.entries(subs.dependencyMatrix)
.filter(([k]) => k.endsWith('→' + sub.name))
.map(([k, v]) => ({ source: k.split('→')[0], calls: v.calls, imports: v.imports }));
return {
name: sub.name,
kind: sub.kind,
files: sub.files,
entities: sub.entities,
publicExports: sub.publicExports,
dependencies: {
outgoing,
incoming,
},
contracts: (contractsResult.bySubsystem[sub.name] || []).map(c => ({
name: c.name,
type: c.type,
})),
};
}),
helm: {
charts: helmCharts.map(c => ({
name: c.chart.name,
version: c.chart.version,
appVersion: c.chart.appVersion || null,
path: c.dir,
dependencies: c.chart.dependencies.map(d => d.name),
resourceCount: c.templates.resources.length,
valuesKeys: c.values.keys.map(k => k.name),
interactions: c.interactions.map(i => ({ type: i.type, target: i.target }))
})),
syncWaves: patterns.syncWaves,
},
contracts: contractsResult.contracts.map(c => ({
name: c.name,
type: c.type,
id: c.id,
})),
}
};
return kb;
}
module.exports = { buildAgentKB };