@toolbaux/guardian 0.1.5 → 0.1.6

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.
@@ -12,11 +12,20 @@ export async function runContext(options) {
12
12
  loadArchitectureDiff(inputDir),
13
13
  loadHeatmap(inputDir)
14
14
  ]);
15
+ // Load structural intelligence if available
16
+ let si;
17
+ try {
18
+ const siPath = path.join(inputDir, "structural-intelligence.json");
19
+ const siRaw = await fs.readFile(siPath, "utf8");
20
+ si = JSON.parse(siRaw);
21
+ }
22
+ catch { /* not available */ }
15
23
  const content = renderContextBlock(architecture, ux, {
16
24
  focusQuery: options.focus,
17
25
  maxLines: normalizeMaxLines(options.maxLines),
18
26
  diff,
19
- heatmap
27
+ heatmap,
28
+ structuralIntelligence: si
20
29
  });
21
30
  if (!options.output) {
22
31
  console.log(content);
@@ -144,7 +144,7 @@ function renderAiContextMarkdown(architecture, ux, options) {
144
144
  }
145
145
  lines.push(renderContextBlock(architecture, ux, {
146
146
  focusQuery: options?.focusQuery,
147
- maxLines: options?.maxLines ?? 80,
147
+ maxLines: options?.maxLines ?? 200,
148
148
  structuralIntelligence: options?.structuralIntelligence
149
149
  }));
150
150
  lines.push("");
@@ -8,7 +8,36 @@ export function renderContextBlock(architecture, ux, options) {
8
8
  lines.push("");
9
9
  lines.push(`**Backend:** ${ormModels.length} ORM models + ${schemaModels} schemas · ${architecture.endpoints.length} endpoints · ${architecture.modules.length} modules`);
10
10
  lines.push(`**Frontend:** ${ux.components.length} components · ${ux.pages.length} pages`);
11
+ // Show all roots if multi-root project
12
+ const roots = architecture.project.roots;
13
+ if (roots && roots.length > 2) {
14
+ lines.push(`**Roots:** ${roots.join(", ")}`);
15
+ }
11
16
  lines.push("");
17
+ // Module map with key exports — the most useful section for AI context
18
+ const modulesWithExports = architecture.modules.filter(m => m.exports.length > 0 || m.files.length > 0);
19
+ if (modulesWithExports.length > 0) {
20
+ lines.push("### Module Map");
21
+ for (const mod of modulesWithExports) {
22
+ const allSymbols = mod.exports.flatMap(e => e.symbols).filter(Boolean);
23
+ const topSymbols = allSymbols.slice(0, 6);
24
+ const symbolStr = topSymbols.length > 0
25
+ ? ` — exports: ${topSymbols.join(", ")}${allSymbols.length > 6 ? ` (+${allSymbols.length - 6} more)` : ""}`
26
+ : ` — ${mod.files.length} files`;
27
+ const epCount = mod.endpoints.length > 0 ? ` · ${mod.endpoints.length} endpoints` : "";
28
+ lines.push(`- **${mod.id}** (${mod.layer})${epCount}${symbolStr}`);
29
+ }
30
+ lines.push("");
31
+ }
32
+ // Cross-module dependencies
33
+ const crossEdges = architecture.dependencies.module_graph.filter(e => e.from !== e.to);
34
+ if (crossEdges.length > 0) {
35
+ lines.push("### Module Dependencies");
36
+ for (const edge of crossEdges.slice(0, 10)) {
37
+ lines.push(`- ${edge.from} → ${edge.to}`);
38
+ }
39
+ lines.push("");
40
+ }
12
41
  const couplingFiles = pickTopCouplingFiles(architecture, options?.heatmap, 5);
13
42
  if (couplingFiles.length > 0) {
14
43
  lines.push("### High-Coupling Files");
@@ -103,11 +132,9 @@ export function renderContextBlock(architecture, ux, options) {
103
132
  }
104
133
  }
105
134
  lines.push("<!-- /guardian:context -->");
106
- const maxLines = options?.maxLines ?? 120;
107
- if (lines.length <= maxLines) {
108
- return lines.join("\n");
109
- }
110
- return [...lines.slice(0, maxLines - 2), "- context truncated for line budget", "<!-- /guardian:context -->"].join("\n");
135
+ // No global truncation each section self-limits via .slice().
136
+ // Every section is guaranteed to appear with at least a few entries.
137
+ return lines.join("\n");
111
138
  }
112
139
  function tokenize(value) {
113
140
  return value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolbaux/guardian",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Architectural intelligence for codebases. Verify that AI-generated code matches your architectural intent.",
6
6
  "keywords": [
@@ -41,7 +41,8 @@
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsc -p tsconfig.json",
44
- "prepublishOnly": "npm run build",
44
+ "prepublishOnly": "npm run test:critical && npm run build",
45
+ "test:critical": "vitest run tests/critical/",
45
46
  "dev": "tsx src/cli.ts",
46
47
  "start": "node dist/cli.js",
47
48
  "typecheck": "tsc -p tsconfig.json --noEmit",