@aigis-ai/cli 2.1.0 → 3.0.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 (50) hide show
  1. package/BENCHMARKS.md +89 -0
  2. package/CHANGELOG.md +49 -0
  3. package/CONTRIBUTING.md +10 -0
  4. package/IMPROVEMENTS.md +41 -0
  5. package/README.md +65 -4
  6. package/SKILL.md +20 -15
  7. package/bin/aigis.js +67 -6
  8. package/content/index/atlas-NOTICE.md +238 -0
  9. package/content/index/atlas-entry-points.json +15 -0
  10. package/content/index/atlas.json +2694 -0
  11. package/content/index/audit-scan.md +6 -0
  12. package/content/index/auto-verify-rules.json +139 -0
  13. package/content/index/taxonomy.md +1 -1
  14. package/content/skills/areas/agent-permissions.md +228 -0
  15. package/content/skills/areas/agent-tool-safety.md +217 -0
  16. package/content/skills/areas/audit-logging.md +1 -0
  17. package/content/skills/areas/bias-monitoring.md +1 -0
  18. package/content/skills/areas/confidence-scoring.md +1 -0
  19. package/content/skills/areas/data-integrity.md +1 -0
  20. package/content/skills/areas/explainability.md +1 -0
  21. package/content/skills/areas/fallback-patterns.md +1 -0
  22. package/content/skills/areas/human-oversight.md +1 -0
  23. package/content/skills/areas/input-validation.md +1 -0
  24. package/content/skills/areas/monitoring.md +1 -0
  25. package/content/skills/areas/output-sanitization.md +1 -0
  26. package/content/skills/areas/pii-handling.md +1 -0
  27. package/content/skills/areas/prompt-security.md +1 -0
  28. package/content/skills/areas/rag-security.md +1 -0
  29. package/content/skills/areas/rate-limiting.md +1 -0
  30. package/content/skills/areas/supply-chain.md +1 -0
  31. package/content/skills/core.md +15 -0
  32. package/content/templates/threat-model.md +80 -0
  33. package/content/verify/checklist-agent-permissions.md +16 -0
  34. package/content/verify/checklist-agent-tool-safety.md +15 -0
  35. package/docs/frontmatter-schema.md +15 -1
  36. package/lib/atlas.js +302 -0
  37. package/lib/auto-verify.js +49 -5
  38. package/lib/build.js +77 -10
  39. package/lib/classify.js +53 -5
  40. package/lib/fetch.js +2 -1
  41. package/lib/report.js +22 -1
  42. package/lib/search.js +6 -2
  43. package/lib/special-recognizers.js +206 -1
  44. package/lib/threats.js +381 -0
  45. package/package.json +4 -1
  46. package/scripts/area-controls-baseline.json +53 -3
  47. package/scripts/area-frontmatter.schema.json +6 -0
  48. package/scripts/build-atlas-index.js +316 -0
  49. package/scripts/test-all.js +61 -0
  50. package/scripts/validate-area-frontmatter.js +58 -2
@@ -18,8 +18,9 @@
18
18
  const fs = require('fs');
19
19
  const path = require('path');
20
20
  const matter = require('gray-matter');
21
- const { REGISTRY: SPECIAL } = require('./special-recognizers');
21
+ const { REGISTRY: SPECIAL, maskNonCode } = require('./special-recognizers');
22
22
  const { getUserJurisdictions } = require('./jurisdiction');
23
+ const atlas = require('./atlas');
23
24
 
24
25
  const RULES_PATH = path.join(__dirname, '..', 'content', 'index', 'auto-verify-rules.json');
25
26
  const AREAS_DIR = path.join(__dirname, '..', 'content', 'skills', 'areas');
@@ -82,6 +83,9 @@ function* walkFiles(rootDir) {
82
83
  } catch {
83
84
  continue;
84
85
  }
86
+ // Sort by UTF-8 name bytes so evidence order never depends on filesystem
87
+ // enumeration order. Python's _walk_files sorts the same way.
88
+ entries.sort((x, y) => Buffer.compare(Buffer.from(x.name, 'utf8'), Buffer.from(y.name, 'utf8')));
85
89
  for (const entry of entries) {
86
90
  const full = path.join(dir, entry.name);
87
91
  if (entry.isDirectory()) {
@@ -166,11 +170,18 @@ function scanRule(rule, files) {
166
170
  const require = rule.require || 'any';
167
171
  const inverse = !!rule.inverse;
168
172
  const maxEvidence = 5;
173
+ // v3.0 (rubric C-11): rules that opt in with "code_only": true match only
174
+ // executable code (comments and string blocks blanked, line numbers kept),
175
+ // and keep trying unmatched patterns after the evidence cap is reached, so
176
+ // the result does not depend on file order. Rules without the flag behave
177
+ // exactly as before.
178
+ const codeOnly = rule.code_only === true;
169
179
 
170
180
  const matchedPatterns = new Set();
171
181
  const evidence = [];
172
- for (const { path: relPath, content } of files) {
173
- const lines = content.split('\n');
182
+ for (const { path: relPath, content: rawContent } of files) {
183
+ const content = codeOnly ? maskNonCode(rawContent, relPath) : rawContent;
184
+ const lines = rawContent.split('\n');
174
185
  for (let i = 0; i < patterns.length; i++) {
175
186
  if (matchedPatterns.has(i) && evidence.length >= maxEvidence) continue;
176
187
  const re = patterns[i];
@@ -187,7 +198,7 @@ function scanRule(rule, files) {
187
198
  }
188
199
  if (evidence.length >= maxEvidence) break;
189
200
  }
190
- if (evidence.length >= maxEvidence) break;
201
+ if (evidence.length >= maxEvidence && !codeOnly) break;
191
202
  }
192
203
  if (evidence.length >= maxEvidence && (require === 'any' || matchedPatterns.size === patterns.length)) break;
193
204
  }
@@ -309,7 +320,12 @@ function autoVerifyArea(areaId, projectDir, opts = {}) {
309
320
  eu_ai_act: showEu ? allControls.eu_ai_act : [],
310
321
  } : null;
311
322
 
312
- return {
323
+ // v3.0: MITRE ATLAS citation (SPEC S4.2). Never gated by jurisdiction.
324
+ // Omitted entirely when the catalog is unavailable (fail-soft, S4.5).
325
+ const atlasSummary = atlas.withAtlas(() => atlas.summarizeAreas([areaId]), null);
326
+ if (atlasSummary && cited) cited.atlas = atlasSummary.mitigations.map((m) => m.id);
327
+
328
+ const out = {
313
329
  area: areaId,
314
330
  project_dir: projectDir,
315
331
  files_scanned: files.length,
@@ -326,6 +342,31 @@ function autoVerifyArea(areaId, projectDir, opts = {}) {
326
342
  cited_controls: cited,
327
343
  user_jurisdictions: [...userJurisdictions],
328
344
  };
345
+ if (atlasSummary) out.atlas = atlasSummary;
346
+ return out;
347
+ }
348
+
349
+ /**
350
+ * v3.0: the MITRE ATLAS block of the text report (SPEC S4.2). Separate from
351
+ * the "Controls satisfied / in scope" block on purpose: ATLAS is a threat
352
+ * catalog, so nothing here is "satisfied".
353
+ */
354
+ function formatAtlasBlock(a) {
355
+ const lines = [];
356
+ lines.push(`── MITRE ATLAS v${a.version} (threat catalog, not a compliance standard) ──`);
357
+ if (a.mitigations.length === 0) {
358
+ lines.push(' No ATLAS mitigation is mapped to this area.');
359
+ } else {
360
+ const t = a.techniques_addressed;
361
+ lines.push(` Mitigations this area helps implement (in part): ${a.mitigations.map((m) => `${m.id} ${m.name}`).join('; ')}`);
362
+ lines.push(` Techniques MITRE links to those mitigations: ${t.total} (${t.realized} Realized, ${t.demonstrated} Demonstrated, ${t.feasible} Feasible)`);
363
+ if (a.top_techniques.length > 0) {
364
+ lines.push(` Highest maturity: ${a.top_techniques.map((x) => `${x.id} ${x.name}`).join('; ')}`);
365
+ }
366
+ }
367
+ lines.push(` ${a.disclaimer}`);
368
+ lines.push('');
369
+ return lines;
329
370
  }
330
371
 
331
372
  // Glob matcher supporting `*` and `**`. `**/` at the start matches any number
@@ -378,6 +419,9 @@ function formatTextReport(result) {
378
419
  }
379
420
  }
380
421
 
422
+ // v3.0: MITRE ATLAS block, immediately before AUTO CHECKS.
423
+ if (result.atlas) lines.push(...formatAtlasBlock(result.atlas));
424
+
381
425
  // AUTO section
382
426
  if (Object.keys(result.auto_checks).length > 0) {
383
427
  lines.push('── AUTO CHECKS ──');
package/lib/build.js CHANGED
@@ -33,6 +33,7 @@ const { classify, ALL_TRAITS } = require('./classify');
33
33
  const { detectTraitsFromText, applyConfirmations } = require('./keywords');
34
34
  const { get: fetchAreas, getInfra } = require('./fetch');
35
35
  const { getUserJurisdictions, filterAreasByJurisdiction, stripJurisdictionGatedSections } = require('./jurisdiction');
36
+ const atlas = require('./atlas');
36
37
 
37
38
  const CONTENT_DIR = path.join(__dirname, '..', 'content');
38
39
 
@@ -271,9 +272,63 @@ function buildList({ description, extraJurisdictions = [], tight = false } = {})
271
272
  lines.push(`Documentation templates (${cls.templates.length}):`);
272
273
  for (const t of cls.templates) lines.push(` aigis template ${t}`);
273
274
  }
275
+ // v3.0 (SPEC S4.4, AC22): point at the threat model. Omitted when the ATLAS
276
+ // catalog is unavailable, because the command it names would fail.
277
+ const threatsCommand = atlas.withAtlas(() => {
278
+ atlas.loadCatalog();
279
+ return threatsCommandFor(allTraitsWithJurisdiction);
280
+ }, null);
281
+ if (threatsCommand) {
282
+ lines.push('');
283
+ lines.push('Threat model:');
284
+ lines.push(` ${threatsCommand}`);
285
+ }
274
286
  return lines.join('\n') + '\n';
275
287
  }
276
288
 
289
+ /** v3.0: `aigis threats --traits <csv>` for the trait set passed to classify, ascending. */
290
+ function threatsCommandFor(traits) {
291
+ return `aigis threats --traits ${[...traits].sort().join(',')}`;
292
+ }
293
+
294
+ /**
295
+ * v3.0 (SPEC S4.4a): ATLAS data for a brief, or null when the catalog is
296
+ * unavailable (fail-soft, S4.5: then none of the brief additions is printed).
297
+ */
298
+ function prepareAtlas(prep) {
299
+ return atlas.withAtlas(() => {
300
+ const summary = atlas.summarizeAreas(prep.areas);
301
+ return {
302
+ version: summary.version,
303
+ disclaimer: summary.disclaimer,
304
+ mitigations: summary.mitigations.map((m) => m.id),
305
+ threats_command: threatsCommandFor(prep.all_traits),
306
+ };
307
+ }, null);
308
+ }
309
+
310
+ /** v3.0 (SPEC S4.4a): the "Threat model (MITRE ATLAS)" section, placed immediately before "Verification". */
311
+ function renderThreatModelSection(atlasMeta) {
312
+ const n = atlasMeta.mitigations.length;
313
+ const sections = [];
314
+ sections.push(`## Threat model (MITRE ATLAS)`);
315
+ sections.push('');
316
+ sections.push(n === 0
317
+ ? `None of the areas above maps to an ATLAS mitigation.`
318
+ : `The areas above help implement ${n} ATLAS mitigations.`);
319
+ sections.push('');
320
+ sections.push(`Do this before you finish, without waiting to be asked:`);
321
+ sections.push('');
322
+ sections.push(`1. Run \`${atlasMeta.threats_command}\`. It lists attacker techniques for this system's entry points (Realized first), the mitigations MITRE links to each, the Aigis areas that help implement each one (in part), and gaps.`);
323
+ sections.push(`2. For every area it names that is not in this brief, run \`aigis get <area>\`, implement it and verify it.`);
324
+ sections.push(`3. Tell the user about every gap (a mitigation with no mapped Aigis area). Never report a gap as handled.`);
325
+ sections.push(`4. Rerun it when tools, write access, memory or data sources change.`);
326
+ sections.push('');
327
+ sections.push(atlasMeta.disclaimer);
328
+ sections.push('');
329
+ return sections;
330
+ }
331
+
277
332
  function collectInfraReferences(areas) {
278
333
  const infraIds = [];
279
334
  const seen = new Set();
@@ -313,7 +368,7 @@ function readTitle(subdir, id) {
313
368
  * briefs. Returns an array of section strings (joined with '\n' by the caller).
314
369
  */
315
370
  function renderCommonSections({
316
- normalized, version, ts, modeNote, cls, resolved, areas, infraIds,
371
+ normalized, version, ts, modeNote, cls, resolved, areas, infraIds, atlasMeta = null,
317
372
  }) {
318
373
  const sections = [];
319
374
 
@@ -349,13 +404,17 @@ function renderCommonSections({
349
404
  sections.push(`3. For each area below, follow the procedure step by step. Honor every **verification checkpoint** — those are not suggestions.`);
350
405
  sections.push(`4. Run \`aigis verify <area> --auto .\` after implementing each area. Fix any FAIL or OVERCLAIM before moving on.`);
351
406
  sections.push(`5. For uncertain traits (⚠ above), pause before implementing the dependent area and ask the user to confirm it applies.`);
407
+ if (atlasMeta) {
408
+ sections.push(`6. Run the threat model in the "Threat model (MITRE ATLAS)" section before you finish, and act on what it lists.`);
409
+ }
352
410
  sections.push('');
353
411
 
354
412
  return sections;
355
413
  }
356
414
 
357
- function renderVerificationSection({ areas, resolved, cls }) {
415
+ function renderVerificationSection({ areas, resolved, cls, atlasMeta = null }) {
358
416
  const sections = [];
417
+ if (atlasMeta) sections.push(...renderThreatModelSection(atlasMeta));
359
418
  sections.push(`## Verification`);
360
419
  sections.push('');
361
420
  sections.push(`After implementing the areas above, the agent should confirm:`);
@@ -364,6 +423,9 @@ function renderVerificationSection({ areas, resolved, cls }) {
364
423
  for (const area of areas) {
365
424
  sections.push(`- [ ] \`aigis verify ${area} --auto .\` returns no FAIL or OVERCLAIM.`);
366
425
  }
426
+ if (atlasMeta) {
427
+ sections.push(`- [ ] \`aigis threats\` was run; every area it named is implemented or skipped with a written reason; every gap was reported to the user.`);
428
+ }
367
429
  sections.push(`- [ ] If any area was added or removed from the recommended set, document the reason in the PR description.`);
368
430
  if (resolved.uncertain_traits.length > 0) {
369
431
  sections.push(`- [ ] Uncertain trait${resolved.uncertain_traits.length === 1 ? '' : 's'} (${resolved.uncertain_traits.map((t) => `\`${t}\``).join(', ')}) confirmed or rejected with the user before relevant code paths shipped.`);
@@ -405,7 +467,8 @@ function buildCompact({
405
467
  ? `Compact mode (auto-fallback): full brief would exceed ${AUTO_FULL_CAP.toLocaleString()} chars. Run \`aigis build "${normalized}" --full\` to force inlined content; you may need to split into per-domain runs.`
406
468
  : `Compact mode: pointer-only. Run \`aigis build "${normalized}" --full\` to inline procedure content.`;
407
469
 
408
- const sections = renderCommonSections({ normalized, version, ts, modeNote, cls, resolved, areas, infraIds });
470
+ const atlasMeta = prepareAtlas(prep);
471
+ const sections = renderCommonSections({ normalized, version, ts, modeNote, cls, resolved, areas, infraIds, atlasMeta });
409
472
 
410
473
  // ─── Areas (pointers) ──────────────────────────────────────────────────
411
474
  sections.push(`## Areas (${areas.length})`);
@@ -435,12 +498,12 @@ function buildCompact({
435
498
  sections.push('');
436
499
  }
437
500
 
438
- sections.push(...renderVerificationSection({ areas, resolved, cls }));
501
+ sections.push(...renderVerificationSection({ areas, resolved, cls, atlasMeta }));
439
502
 
440
503
  const brief = sections.join('\n');
441
504
  return {
442
505
  brief,
443
- meta: makeMeta({ prep, brief, mode: 'compact', cap: null, ts, version, fellBackFromFull }),
506
+ meta: makeMeta({ prep, brief, mode: 'compact', cap: null, ts, version, fellBackFromFull, atlasMeta }),
444
507
  };
445
508
  }
446
509
 
@@ -461,7 +524,8 @@ function buildFull({
461
524
  const ts = (timestamp || new Date()).toISOString();
462
525
  const version = versionString || readPackageVersion();
463
526
 
464
- const sections = renderCommonSections({ normalized, version, ts, modeNote: null, cls, resolved, areas, infraIds });
527
+ const atlasMeta = prepareAtlas(prep);
528
+ const sections = renderCommonSections({ normalized, version, ts, modeNote: null, cls, resolved, areas, infraIds, atlasMeta });
465
529
 
466
530
  // ─── Areas (inlined) ───────────────────────────────────────────────────
467
531
  // v2.1: for non-EU users, strip `## EU AI Act extensions` sections from
@@ -511,7 +575,7 @@ function buildFull({
511
575
  }
512
576
  }
513
577
 
514
- sections.push(...renderVerificationSection({ areas, resolved, cls }));
578
+ sections.push(...renderVerificationSection({ areas, resolved, cls, atlasMeta }));
515
579
 
516
580
  const brief = sections.join('\n');
517
581
 
@@ -521,7 +585,7 @@ function buildFull({
521
585
 
522
586
  return {
523
587
  brief,
524
- meta: makeMeta({ prep, brief, mode: 'full', cap: charCap, ts, version, fellBackFromFull: false }),
588
+ meta: makeMeta({ prep, brief, mode: 'full', cap: charCap, ts, version, fellBackFromFull: false, atlasMeta }),
525
589
  };
526
590
  }
527
591
 
@@ -628,6 +692,7 @@ function prepareBriefInputs({ description, decisions = {}, extraJurisdictions =
628
692
 
629
693
  return {
630
694
  normalized,
695
+ all_traits: allTraitsWithJurisdiction, // v3.0: the trait set passed to classify (sorted)
631
696
  raw_input: description,
632
697
  detection,
633
698
  lowConfWithSlugs,
@@ -659,9 +724,9 @@ function readAreaSystemTraits(areaId) {
659
724
  }
660
725
  }
661
726
 
662
- function makeMeta({ prep, brief, mode, cap, ts, version, fellBackFromFull }) {
727
+ function makeMeta({ prep, brief, mode, cap, ts, version, fellBackFromFull, atlasMeta = null }) {
663
728
  const { normalized, raw_input, resolved, cls, areas, infraIds, lowConfWithSlugs } = prep;
664
- return {
729
+ const meta = {
665
730
  mode,
666
731
  auto_fallback: fellBackFromFull,
667
732
  normalized_description: normalized,
@@ -687,6 +752,8 @@ function makeMeta({ prep, brief, mode, cap, ts, version, fellBackFromFull }) {
687
752
  generated_at: ts,
688
753
  version,
689
754
  };
755
+ if (atlasMeta) meta.atlas = { ...atlasMeta, mitigations: [...atlasMeta.mitigations] };
756
+ return meta;
690
757
  }
691
758
 
692
759
  let _cachedVersion = null;
package/lib/classify.js CHANGED
@@ -1,5 +1,9 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const matter = require('gray-matter');
4
+ const atlas = require('./atlas');
5
+
6
+ const AREAS_DIR = path.join(__dirname, '..', 'content', 'skills', 'areas');
3
7
 
4
8
  const ALL_TRAITS = [
5
9
  'uses-llm', 'uses-rag', 'uses-finetuned', 'uses-thirdparty-api', 'is-agentic', 'is-multimodal',
@@ -15,7 +19,7 @@ const TRAIT_FILES = {
15
19
  'uses-rag': ['rag-security', 'data-integrity'],
16
20
  'uses-finetuned': ['data-integrity', 'supply-chain'],
17
21
  'uses-thirdparty-api': ['supply-chain'],
18
- 'is-agentic': ['human-oversight', 'rate-limiting', 'fallback-patterns', 'audit-logging'],
22
+ 'is-agentic': ['human-oversight', 'rate-limiting', 'fallback-patterns', 'audit-logging', 'agent-permissions', 'agent-tool-safety'],
19
23
  'is-multimodal': ['input-validation', 'output-sanitization', 'pii-handling'],
20
24
  'processes-pii': ['pii-handling', 'audit-logging'],
21
25
  'handles-financial': ['pii-handling', 'audit-logging', 'bias-monitoring'],
@@ -58,6 +62,40 @@ const FILE_CONTROLS = {
58
62
  'explainability': { owasp: [], nist: ['MEASURE-2.8', 'MEASURE-2.9'], iso: ['Annex-A.8', 'Clause-7.4'] },
59
63
  };
60
64
 
65
+ // v3.0 (SPEC S4.6): the two agent areas have no FILE_CONTROLS entry; their
66
+ // owasp / nist / iso42001 ids are read from frontmatter. Limited to this fixed
67
+ // list so the EU areas (no FILE_CONTROLS entry either) keep contributing nothing.
68
+ const FRONTMATTER_CONTROL_AREAS = ['agent-permissions', 'agent-tool-safety'];
69
+
70
+ function readFrontmatterControls(areaId) {
71
+ try {
72
+ const filepath = path.join(AREAS_DIR, `${areaId}.md`);
73
+ if (!fs.existsSync(filepath)) return null;
74
+ const c = (matter(fs.readFileSync(filepath, 'utf8')).data || {}).controls || {};
75
+ const list = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string') : []);
76
+ return { owasp: list(c.owasp), nist: list(c.nist), iso: list(c.iso42001) };
77
+ } catch (_) {
78
+ return null;
79
+ }
80
+ }
81
+
82
+ // v3.0 (SPEC S4.1): ATLAS citation for a classify result. Returns null when the
83
+ // catalog is unavailable (fail-soft, S4.5): the caller then adds no ATLAS key.
84
+ function atlasForAreas(areaIds, traits) {
85
+ return atlas.withAtlas(() => {
86
+ const summary = atlas.summarizeAreas(areaIds);
87
+ return {
88
+ ids: summary.mitigations.map((m) => m.id),
89
+ block: {
90
+ version: summary.version,
91
+ disclaimer: summary.disclaimer,
92
+ techniques_addressed: summary.techniques_addressed,
93
+ threats_command: `aigis threats --traits ${[...traits].sort().join(',')}`,
94
+ },
95
+ };
96
+ }, null);
97
+ }
98
+
61
99
  function classify(traitList) {
62
100
  const ts = new Set(traitList);
63
101
  const warnings = [];
@@ -164,7 +202,7 @@ function classify(traitList) {
164
202
  const allNist = new Set();
165
203
  const allIso = new Set();
166
204
  for (const f of files) {
167
- const c = FILE_CONTROLS[f];
205
+ const c = FILE_CONTROLS[f] || (FRONTMATTER_CONTROL_AREAS.includes(f) ? readFrontmatterControls(f) : null);
168
206
  if (c) {
169
207
  c.owasp.forEach(x => allOwasp.add(x));
170
208
  c.nist.forEach(x => allNist.add(x));
@@ -172,11 +210,12 @@ function classify(traitList) {
172
210
  }
173
211
  }
174
212
 
175
- return {
213
+ const implementFiles = [...files].sort();
214
+ const result = {
176
215
  risk_tier: tier,
177
216
  reason,
178
217
  traits: [...ts],
179
- implement_files: [...files].sort(),
218
+ implement_files: implementFiles,
180
219
  templates: [...new Set(templates)],
181
220
  guardrails_fired: guardrailsFired,
182
221
  warnings,
@@ -186,6 +225,15 @@ function classify(traitList) {
186
225
  iso: [...allIso].sort(),
187
226
  },
188
227
  };
228
+
229
+ // v3.0: MITRE ATLAS (additive; omitted entirely when the catalog is unavailable).
230
+ const atlasInfo = atlasForAreas(implementFiles, result.traits);
231
+ if (atlasInfo) {
232
+ result.controls.atlas = atlasInfo.ids;
233
+ result.atlas = atlasInfo.block;
234
+ }
235
+
236
+ return result;
189
237
  }
190
238
 
191
- module.exports = { classify, ALL_TRAITS };
239
+ module.exports = { classify, ALL_TRAITS, TRAIT_FILES, FRONTMATTER_CONTROL_AREAS };
package/lib/fetch.js CHANGED
@@ -18,7 +18,8 @@ function listDir(dir) {
18
18
  if (!fs.existsSync(dirpath)) return [];
19
19
  return fs.readdirSync(dirpath)
20
20
  .filter(f => f.endsWith('.md'))
21
- .map(f => f.replace('.md', ''));
21
+ .map(f => f.replace('.md', ''))
22
+ .sort();
22
23
  }
23
24
 
24
25
  function stripFrontmatter(content) {
package/lib/report.js CHANGED
@@ -28,6 +28,7 @@ const fs = require('fs');
28
28
  const path = require('path');
29
29
  const matter = require('gray-matter');
30
30
  const { autoVerifyArea } = require('./auto-verify');
31
+ const atlas = require('./atlas');
31
32
 
32
33
  const AREAS_DIR = path.join(__dirname, '..', 'content', 'skills', 'areas');
33
34
 
@@ -55,6 +56,7 @@ function buildReport({ projectDir, areas, jurisdictions = [], version = null, ti
55
56
  let aggNist = new Set();
56
57
  let aggIso = new Set();
57
58
  let aggEu = new Set();
59
+ let aggAtlas = new Set();
58
60
  let totalAutoPass = 0, totalAutoFail = 0, totalOverclaims = 0, totalJudgment = 0;
59
61
  let areasFullyPassing = 0;
60
62
 
@@ -87,6 +89,7 @@ function buildReport({ projectDir, areas, jurisdictions = [], version = null, ti
87
89
  for (const v of result.cited_controls.nist) aggNist.add(v);
88
90
  for (const v of result.cited_controls.iso42001) aggIso.add(v);
89
91
  for (const v of result.cited_controls.eu_ai_act) aggEu.add(v);
92
+ for (const v of (result.cited_controls.atlas || [])) aggAtlas.add(v);
90
93
  }
91
94
 
92
95
  totalAutoPass += s.auto_pass;
@@ -116,7 +119,14 @@ function buildReport({ projectDir, areas, jurisdictions = [], version = null, ti
116
119
  });
117
120
  }
118
121
 
119
- return {
122
+ // v3.0: MITRE ATLAS (SPEC S4.3). Omitted entirely when the catalog is
123
+ // unavailable (fail-soft, S4.5); verify then also omits cited_controls.atlas.
124
+ const atlasHeader = atlas.withAtlas(() => {
125
+ atlas.loadCatalog();
126
+ return { version: atlas.PINNED.version, disclaimer: atlas.DISCLAIMER };
127
+ }, null);
128
+
129
+ const report = {
120
130
  generated_at: ts,
121
131
  aigis_version: ver,
122
132
  project_dir: projectDir,
@@ -144,6 +154,12 @@ function buildReport({ projectDir, areas, jurisdictions = [], version = null, ti
144
154
  },
145
155
  per_area: perArea,
146
156
  };
157
+ if (atlasHeader) {
158
+ report.summary.cross_framework_coverage.atlas_count = aggAtlas.size;
159
+ report.summary.cross_framework_citations.atlas = [...aggAtlas].sort();
160
+ report.atlas = atlasHeader;
161
+ }
162
+ return report;
147
163
  }
148
164
 
149
165
  /** Format the structured report as audit-ready markdown. */
@@ -181,6 +197,7 @@ function formatReportMarkdown(report) {
181
197
  L.push(`| NIST AI RMF | ${s.cross_framework_coverage.nist_count} |`);
182
198
  L.push(`| ISO/IEC 42001 | ${s.cross_framework_coverage.iso42001_count} |`);
183
199
  L.push(`| EU AI Act | ${s.cross_framework_coverage.eu_ai_act_count}${report.user_jurisdictions.includes('eu') ? '' : ' _(not surfaced — no EU jurisdiction)_'} |`);
200
+ if (report.atlas) L.push(`| MITRE ATLAS mitigations (threat catalog, not a standard) | ${s.cross_framework_coverage.atlas_count} |`);
184
201
  L.push('');
185
202
 
186
203
  // ── Per-area results ────────────────────────────────────────────────────
@@ -210,6 +227,7 @@ function formatReportMarkdown(report) {
210
227
  if (c.nist.length > 0) L.push(`- NIST AI RMF: ${c.nist.map((v) => `\`${v}\``).join(', ')}`);
211
228
  if (c.iso42001.length > 0) L.push(`- ISO/IEC 42001: ${c.iso42001.map((v) => `\`${v}\``).join(', ')}`);
212
229
  if (c.eu_ai_act.length > 0) L.push(`- EU AI Act: ${c.eu_ai_act.map((v) => `\`${v}\``).join(', ')}`);
230
+ if (report.atlas && c.atlas && c.atlas.length > 0) L.push(`- MITRE ATLAS mitigations (helps implement, in part): ${c.atlas.map((v) => `\`${v}\``).join(', ')}`);
213
231
  L.push('');
214
232
  }
215
233
  }
@@ -294,6 +312,9 @@ function formatReportMarkdown(report) {
294
312
  L.push(`- **Cross-framework citations**: each area's \`controls\` frontmatter declares which OWASP / NIST / ISO 42001 / EU AI Act controls it satisfies. Citations are surfaced when the area's auto checks PASS (or PARTIAL — flagged accordingly).`);
295
313
  L.push(`- **Jurisdiction gating**: EU AI Act citations are only surfaced when \`--jurisdiction eu\` was passed. This report's "Jurisdictions in scope" header documents what was requested.`);
296
314
  L.push(`- **Determinism**: same project + same options + same Aigis version produces byte-identical reports (modulo the timestamp line).`);
315
+ if (report.atlas) {
316
+ L.push(`- **MITRE ATLAS**: mitigation ids come from each area's \`controls.atlas\` frontmatter (Aigis's own mapping, pinned to ATLAS v${report.atlas.version}). A cited mitigation means the area helps implement it (in part). ${report.atlas.disclaimer}`);
317
+ }
297
318
  L.push('');
298
319
  L.push(`This report is content output. It is not a certification. EU AI Act conformity assessment requires notified-body involvement; this report is preparation material.`);
299
320
  L.push('');
package/lib/search.js CHANGED
@@ -3,6 +3,9 @@ const path = require('path');
3
3
  const matter = require('gray-matter');
4
4
 
5
5
  const CONTENT_DIR = path.join(__dirname, '..', 'content');
6
+ // Areas live in content/skills/areas (v2.0 moved them out of content/implement,
7
+ // which made search and --list return no areas before v3.0).
8
+ const AREAS_DIR = 'skills/areas';
6
9
 
7
10
  function loadFileMeta(dir) {
8
11
  const dirpath = path.join(CONTENT_DIR, dir);
@@ -10,6 +13,7 @@ function loadFileMeta(dir) {
10
13
 
11
14
  return fs.readdirSync(dirpath)
12
15
  .filter(f => f.endsWith('.md'))
16
+ .sort()
13
17
  .map(f => {
14
18
  const content = fs.readFileSync(path.join(dirpath, f), 'utf8');
15
19
  const parsed = matter(content);
@@ -28,7 +32,7 @@ function search(query) {
28
32
  const queryLower = query.toLowerCase();
29
33
  const results = [];
30
34
 
31
- const implement = loadFileMeta('implement');
35
+ const implement = loadFileMeta(AREAS_DIR);
32
36
  const templates = loadFileMeta('templates');
33
37
  const all = [...implement, ...templates];
34
38
 
@@ -68,7 +72,7 @@ function search(query) {
68
72
 
69
73
  function listAll() {
70
74
  return {
71
- implement: loadFileMeta('implement').map(f => ({ id: f.id, title: f.title })),
75
+ implement: loadFileMeta(AREAS_DIR).map(f => ({ id: f.id, title: f.title })),
72
76
  templates: loadFileMeta('templates').map(f => ({ id: f.id, title: f.title })),
73
77
  };
74
78
  }