@aigis-ai/cli 2.0.2 → 2.1.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 (33) hide show
  1. package/README.md +94 -45
  2. package/bin/aigis.js +139 -8
  3. package/content/resolvers/triggers.json +363 -41
  4. package/content/skills/areas/audit-logging.md +33 -0
  5. package/content/skills/areas/bias-monitoring.md +34 -0
  6. package/content/skills/areas/confidence-scoring.md +23 -0
  7. package/content/skills/areas/data-integrity.md +25 -0
  8. package/content/skills/areas/eu-ai-act-art-13-deployer-transparency.md +133 -0
  9. package/content/skills/areas/eu-ai-act-art-50-transparency-disclosure.md +134 -0
  10. package/content/skills/areas/eu-ai-act-art-73-incident-reporting.md +149 -0
  11. package/content/skills/areas/eu-ai-act-art-9-risk-management.md +141 -0
  12. package/content/skills/areas/fallback-patterns.md +28 -0
  13. package/content/skills/areas/human-oversight.md +38 -0
  14. package/content/skills/areas/input-validation.md +27 -0
  15. package/content/skills/areas/monitoring.md +29 -0
  16. package/content/skills/areas/prompt-security.md +29 -0
  17. package/content/templates/eu-ai-act-annex-iv.md +193 -0
  18. package/docs/frontmatter-schema.md +75 -0
  19. package/docs/screenshots/README.md +17 -0
  20. package/docs/screenshots/agent-flow.png +0 -0
  21. package/docs/screenshots/setup.png +0 -0
  22. package/docs/screenshots/verify.png +0 -0
  23. package/lib/auto-verify.js +70 -1
  24. package/lib/build.js +101 -12
  25. package/lib/classify.js +8 -2
  26. package/lib/init.js +269 -5
  27. package/lib/jurisdiction.js +137 -0
  28. package/lib/report.js +331 -0
  29. package/package.json +1 -1
  30. package/scripts/area-controls-baseline.json +188 -0
  31. package/scripts/area-frontmatter.schema.json +61 -0
  32. package/scripts/validate-area-frontmatter.js +228 -0
  33. package/aigis-ai-cli-2.0.1.tgz +0 -0
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  **AI governance that ships with your code.**
4
4
 
5
- Aigis is a command-line tool that gives coding agents like Cursor, Claude Code, GitHub Copilot, and Windsurf curated AI governance patterns mapped to NIST AI RMF, OWASP Top 10 for LLMs, and ISO/IEC 42001.
5
+ Aigis sits between you and your coding agent (Cursor, Claude Code, GitHub Copilot, Windsurf) and gives the agent curated AI governance patterns mapped to NIST AI RMF, OWASP Top 10 for LLMs, ISO/IEC 42001, and the EU AI Act.
6
6
 
7
- You describe what you're building. Aigis classifies it against the frameworks that apply. Your agent pulls the right governance patterns and implements them. One command verifies the result.
7
+ You don't run Aigis. Your agent does. After one setup command, you describe what you're building and your agent picks the right governance patterns, implements them, and verifies the result — all in the same chat where you write code.
8
8
 
9
9
  ## Install
10
10
 
@@ -12,80 +12,129 @@ You describe what you're building. Aigis classifies it against the frameworks th
12
12
  npm install -g @aigis-ai/cli
13
13
  # or
14
14
  pip install aigis-cli
15
+
16
+ cd your-project
17
+ aigis init cursor # or: claude-code, copilot, windsurf
15
18
  ```
16
19
 
17
- Verify:
20
+ That's it. `aigis init` writes a single rules file (`.cursorrules` for Cursor, `.github/copilot-instructions.md` for Copilot, etc.) that teaches your agent the Aigis workflow. Your agent reads it on every interaction in this project.
18
21
 
19
- ```bash
20
- aigis --version
21
- # 2.0.1
22
- ```
22
+ ![One command and you're done — your agent takes over.](docs/screenshots/setup.png)
23
23
 
24
24
  ## Quick start
25
25
 
26
- ```bash
27
- aigis build "customer support chatbot with order history lookup"
28
- ```
26
+ Open the project in your IDE. In the agent chat, just describe what you're building:
27
+
28
+ > *Build me an EU AI Act compliant customer support chatbot for an e-commerce site. Use aigis to figure out the governance patterns and apply them.*
29
29
 
30
- Aigis will classify the description against NIST, OWASP, and ISO frameworks, identify relevant governance areas (PII handling, rate limiting, audit logging, prompt security), and produce a consolidated brief your agent can implement from.
30
+ Your agent will read `.cursorrules`, classify the description against the resolver, fetch the relevant procedures, and implement them — invoking `aigis` itself as it works:
31
31
 
32
- Paste the brief into your coding agent's chat. The agent implements the patterns. Then:
32
+ ![Your agent reads the rules file, classifies the project, fetches the brief, and implements — without you opening a separate terminal.](docs/screenshots/agent-flow.png)
33
+
34
+ When the agent is done, you can verify deterministically:
33
35
 
34
36
  ```bash
35
- aigis verify <area> --auto .
37
+ aigis verify input-validation --auto . --jurisdiction eu
36
38
  ```
37
39
 
38
- Runs deterministic checks on the implementation.
40
+ ![aigis verify cites OWASP + NIST + ISO + EU AI Act controls per check, with file:line evidence.](docs/screenshots/verify.png)
39
41
 
40
- ## What's new in v2.0
42
+ The whole loop — describe, implement, verify — happens without leaving the IDE. You stay in the chat; the agent uses the CLI.
41
43
 
42
- - **`aigis build`** — new command that produces one consolidated governance brief per project
43
- - **Infrastructure content** — production-ready patterns for rate limiting, secrets management, and structured logging
44
- - **Curated resolver** — 39 high-signal triggers mapped to traits, with interactive confirmation for low-confidence matches
45
- - **Content architecture redesign** — areas, workflows, and infrastructure separated into layered skills, built around how modern AI agents actually read context
44
+ ## What `aigis init` actually did
46
45
 
47
- ## How Aigis is different
46
+ When you ran `aigis init cursor`, three things landed in your repo:
48
47
 
49
- **Structured.** Aigis is a compiler for agent instructions, not a prompt. The resolver uses deterministic rules. The procedures have explicit verification checkpoints. Brief generation is fully deterministic — same description produces byte-identical output.
48
+ 1. **`.cursorrules`** — the Aigis "core skill" your agent loads on every interaction. It documents the workflow (`classify → build → implement → verify → report`) and embeds a 39-phrase resolver block (high-confidence and low-confidence triggers) the agent uses to pick traits from your description.
49
+ 2. **A checksum** at the top of the resolver block. When Aigis updates, `aigis init <ide> --refresh` overwrites cleanly; mismatched checksums error out so you can see what changed.
50
+ 3. **No hidden services. No telemetry. No background processes.** Just a markdown file your agent reads.
50
51
 
51
- **Honest.** Every iteration of v2.0 was benchmarked. The final numbers, against the same 10 descriptions:
52
+ Optional add-ons at init time:
52
53
 
53
- - Baseline (no Aigis): P=0.737, R=0.905, F1=0.790
54
- - v2.0 (aigis build): P=0.847, R=0.851, F1=0.837
54
+ ```bash
55
+ aigis init cursor --ci github # drops .github/workflows/aigis.yml
56
+ aigis init cursor --hook # installs .git/hooks/pre-commit
57
+ ```
58
+
59
+ Both surfaces read a single `.aigisrc.json` config:
55
60
 
56
- F1 beats baseline by +0.047. Precision improved by +15%. Methodology and per-run tables live in `benchmarks/`.
61
+ ```json
62
+ { "areas": ["pii-handling", "audit-logging"], "jurisdiction": "eu" }
63
+ ```
64
+
65
+ The CI workflow runs `aigis verify` on every PR; the pre-commit hook runs it before each commit. Configure once, both run.
66
+
67
+ ## What's new in v2.1
57
68
 
58
- **Open source.** Local. Never calls external LLMs. Never writes files to your project. Your code, your tools, your accountability.
69
+ - **EU AI Act mapping** — Articles 9, 10, 12, 13, 14, 15, 50, 72, 73 mapped to runnable governance patterns, plus an Annex IV technical documentation template
70
+ - **`--jurisdiction` flag** (`eu`, `us-regulated`) — gates content by where you ship. EU AI Act citations only surface when you're shipping to EU users
71
+ - **`aigis report`** — generates audit-ready compliance documentation with cross-framework citations (NIST + OWASP + ISO + EU AI Act) and file:line evidence per check
72
+ - **Activation surfaces** — `aigis init --ci github` drops a GitHub Action; `aigis init --hook` installs a pre-commit hook
73
+ - **`--tight` flag** (experimental) — minimal briefs for users who want less context. Requires ≥2 trait matches per area instead of ≥1
74
+ - **Resolver expansion** — 27 new triggers covering modern AI project types (internal coding assistants, agentic code review, document Q&A, image generation, enterprise search) and EU Annex III high-risk categories (biometric ID, credit scoring, hiring, law enforcement)
59
75
 
60
76
  ## The principle behind Aigis
61
77
 
62
78
  Governance isn't a content problem. It's an interface problem.
63
79
 
64
- AI governance frameworks exist. NIST AI RMF, OWASP Top 10 for LLMs, ISO/IEC 42001 — all rigorous, all published, all sitting in documents that engineering teams never read.
80
+ NIST AI RMF, OWASP Top 10 for LLMs, ISO/IEC 42001, and the EU AI Act are all rigorous, all published, and all sit in documents that engineering teams never read. Aigis treats governance as an **agent-computer interface** problem: how the right content reaches an LM agent at the right time, in the right shape.
65
81
 
66
- Aigis treats governance as an agent-computer interface problem. Context layered for on-demand loading. Deterministic rules where accuracy isn't negotiable. Flexible reasoning where real projects don't fit rigid templates.
82
+ - Context layered for on-demand loading (core skill always loaded; per-area procedures fetched when needed)
83
+ - Deterministic rules where accuracy isn't negotiable (resolver triggers, brief generation, verify regexes)
84
+ - Flexible reasoning where real projects don't fit rigid templates (the brief tells the agent to skip areas that don't apply, with a written reason)
67
85
 
68
- Inspired by [SWE-agent's work on agent-computer interfaces](https://arxiv.org/abs/2405.15793) — the idea that how information reaches an LM agent matters as much as what reaches it.
86
+ Inspired by [SWE-agent's work on agent-computer interfaces](https://arxiv.org/abs/2405.15793) — the idea that *how* information reaches an LM agent matters as much as *what* reaches it.
69
87
 
70
- ## Commands
88
+ ## Manual CLI reference (for CI, scripting, audit prep, power users)
89
+
90
+ The CLI exists in case you want to drive Aigis directly — for CI workflows, audit prep, debugging, or one-off invocations.
71
91
 
72
92
  ```bash
73
- aigis build "<description>" # Generate governance brief (the main command)
74
- aigis build "..." --list # List areas without full brief
75
- aigis build "..." --compact # Pointer-only brief
76
-
77
- aigis classify "<text>" # Classify traits from description
78
- aigis get <area> # Fetch governance procedure for an area
79
- aigis infra <area> # Fetch infrastructure pattern (rate-limiting, secrets, logging)
80
- aigis workflow <type> # Fetch workflow template
81
-
82
- aigis verify <area> --auto . # Run deterministic checks on your implementation
83
- aigis audit . # Summary audit of all implemented areas
84
- aigis search --list # List all available areas
93
+ # Classification + brief
94
+ aigis classify "<description>" # detect traits + recommended areas
95
+ aigis build "<description>" # the consolidated brief (the main command)
96
+ aigis build "..." --jurisdiction eu # surface EU AI Act content for EU-bound systems
97
+ aigis build "..." --tight # minimal brief: ≥2 trait matches required (experimental)
98
+ aigis build "..." --list # area names + traits, no procedure content
99
+ aigis build "..." --compact # pointer-only brief
100
+
101
+ # Per-area work
102
+ aigis get <area> # fetch a single governance procedure
103
+ aigis infra <area> # fetch infrastructure pattern (rate-limiting, secrets, logging)
104
+ aigis workflow <type> # fetch workflow template
105
+
106
+ # Verify + audit
107
+ aigis verify <area> --auto . # deterministic check on your implementation
108
+ aigis verify <area> --auto . --jurisdiction eu # surfaces EU AI Act citations in output
109
+ aigis report --from-classify "<desc>" --jurisdiction eu --output audit.md
110
+ # audit-ready compliance documentation
111
+ aigis audit --scan # discovery prompt for auditing existing code
112
+ aigis audit --traits <list> # scoped audit with deterministic denominator
113
+
114
+ # Misc
115
+ aigis search --list # list all available areas
116
+ aigis traits # list classification traits
117
+ aigis template <id> # compliance documentation template
85
118
  ```
86
119
 
87
120
  Run `aigis --help` for full options.
88
121
 
122
+ ## Honest about what this isn't
123
+
124
+ - **Not a certification.** EU AI Act conformity assessment requires a notified body. `aigis report` is preparation material; it does not certify.
125
+ - **Not a security audit.** `aigis verify` is heuristic regex over your source. It catches common misimplementations; it doesn't replace SAST, code review, or penetration testing.
126
+ - **Doesn't run your code or call your APIs.** The agent does the work. Aigis provides the brief, the verifier, and the audit doc.
127
+ - **Local. No cloud. No telemetry.** Aigis ships nothing back to a server. Your descriptions, your code, and your verify results stay on your machine.
128
+
129
+ ## Benchmark results
130
+
131
+ v2.0 was benchmarked at every iteration. Final numbers, against the same 10 descriptions:
132
+
133
+ - Baseline (no Aigis): P=0.737, R=0.905, F1=0.790
134
+ - v2.0 (`aigis build`): P=0.847, R=0.851, F1=0.837
135
+
136
+ F1 beats baseline by +0.047. v2.1 ships `--tight` as a flag-gated experiment; promotion to default in v2.2 is pending a confirmation benchmark. Methodology, per-run tables, and the v2.1 manual end-to-end test live in the [`benchmarks/`](https://github.com/NayanKanaparthi/aigis) directory.
137
+
89
138
  ## Supported agents
90
139
 
91
140
  - Cursor
@@ -93,13 +142,13 @@ Run `aigis --help` for full options.
93
142
  - GitHub Copilot
94
143
  - Windsurf
95
144
 
96
- Run `aigis init <ide>` to set up your IDE rules. The resolver's trigger reference is embedded in the rules file with a checksum that automatically refreshes on `aigis init --refresh`.
145
+ Each maps to a different rules file location. `aigis init <ide>` handles the difference; `--refresh` updates safely.
97
146
 
98
147
  ## Contributing
99
148
 
100
- Aigis is built around a curated trigger map for classification. Trigger contributions are welcome, with one-sentence use-case justification per the template in `.github/PULL_REQUEST_TEMPLATE/trigger_mapping.md`.
149
+ Aigis is built around a curated trigger map for classification. Trigger contributions are welcome, with a one-sentence use-case justification per the template in `.github/PULL_REQUEST_TEMPLATE/trigger_mapping.md`.
101
150
 
102
- See `CONTRIBUTING.md` for the full contributor workflow, including how to add new governance areas, workflows, or infrastructure patterns.
151
+ See `CONTRIBUTING.md` for the full contributor workflow, including how to add new governance areas, workflows, infrastructure patterns, or EU AI Act article mappings.
103
152
 
104
153
  ## License
105
154
 
package/bin/aigis.js CHANGED
@@ -5,6 +5,7 @@ const chalk = require('chalk');
5
5
  const { classify } = require('../lib/classify');
6
6
  const { get, getTemplate, getAuditScan, getWorkflow, listWorkflows, getInfra, listInfras } = require('../lib/fetch');
7
7
  const { buildBrief, buildList, BriefTooLargeError } = require('../lib/build');
8
+ const { getUserJurisdictions, filterAreasByJurisdiction } = require('../lib/jurisdiction');
8
9
  const { verify } = require('../lib/fetch');
9
10
  const { search, listAll } = require('../lib/search');
10
11
  const { annotate, listAnnotations, clearAnnotation } = require('../lib/annotate');
@@ -17,7 +18,7 @@ const program = new Command();
17
18
  program
18
19
  .name('aigis')
19
20
  .description('AI governance guardrails for coding agents')
20
- .version('2.0.0');
21
+ .version('2.1.0');
21
22
 
22
23
  // ============================================================
23
24
  // aigis classify
@@ -29,6 +30,7 @@ program
29
30
  .option('--json', 'Output as JSON (also enabled automatically when stdout is not a TTY)')
30
31
  .option('--confirm <ids>', 'Comma-separated low-confidence suggestion IDs to confirm (no interactive prompt)')
31
32
  .option('--reject <ids>', 'Comma-separated low-confidence suggestion IDs to reject (no interactive prompt)')
33
+ .option('--jurisdiction <codes>', 'Comma-separated jurisdiction codes (eu, us-regulated, global). Adds the matching jurisdiction-* traits to your set, overriding resolver detection.')
32
34
  .argument('[description]', 'Natural language description (resolved via content/resolvers/triggers.json)')
33
35
  .action(async (description, opts) => {
34
36
  // Three modes: --traits only, description only, both (additive).
@@ -72,8 +74,11 @@ program
72
74
  }
73
75
 
74
76
  const resolved = applyConfirmations(detection, decisions);
75
- // Merge with --traits
76
- const finalTraits = [...new Set([...resolved.final_traits, ...traitsFromFlag])].sort();
77
+ // Merge with --traits + --jurisdiction-derived traits
78
+ const jurisdictionTraits = opts.jurisdiction
79
+ ? opts.jurisdiction.split(',').map((s) => s.trim()).filter(Boolean).map((c) => `jurisdiction-${c}`)
80
+ : [];
81
+ const finalTraits = [...new Set([...resolved.final_traits, ...traitsFromFlag, ...jurisdictionTraits])].sort();
77
82
 
78
83
  // Build a resolver report for transparency (in both JSON and text modes when description was given)
79
84
  const resolverReport = description ? {
@@ -103,6 +108,18 @@ program
103
108
  console.error(chalk.red(e.message));
104
109
  process.exit(1);
105
110
  }
111
+
112
+ // v2.1: jurisdiction filter. classify produces conceptually-relevant areas;
113
+ // we drop EU-tagged areas if user is not in EU jurisdiction (and same for
114
+ // any other jurisdiction-gated area). Universal areas pass through.
115
+ const userJurisdictions = getUserJurisdictions(finalTraits);
116
+ const beforeFilter = result.implement_files.length;
117
+ result.implement_files = filterAreasByJurisdiction(result.implement_files, userJurisdictions);
118
+ result.filtered_by_jurisdiction = {
119
+ user_jurisdictions: [...userJurisdictions],
120
+ dropped_count: beforeFilter - result.implement_files.length,
121
+ };
122
+
106
123
  if (resolverReport) result.resolver = resolverReport;
107
124
 
108
125
  if (jsonMode) {
@@ -207,6 +224,7 @@ program
207
224
  .argument('<files...>', 'File IDs to verify')
208
225
  .option('--auto <path>', 'Run deterministic scanner against the project at <path> instead of returning the blank checklist')
209
226
  .option('--json', 'Output auto-verify results as JSON (only with --auto)')
227
+ .option('--jurisdiction <codes>', 'Comma-separated jurisdiction codes (eu, us-regulated). Surfaces jurisdiction-specific control citations (e.g. EU AI Act articles) in the report.')
210
228
  .action((files, opts) => {
211
229
  if (!opts.auto) {
212
230
  // Backward-compatible behavior: fetch the blank checklist markdown
@@ -223,10 +241,15 @@ program
223
241
  process.exit(1);
224
242
  }
225
243
 
244
+ // v2.1: parse --jurisdiction once, applied to every area's verify run.
245
+ const jurisdictions = opts.jurisdiction
246
+ ? opts.jurisdiction.split(',').map((s) => s.trim()).filter(Boolean)
247
+ : [];
248
+
226
249
  const results = [];
227
250
  for (const area of files) {
228
251
  try {
229
- const r = autoVerifyArea(area, projectDir);
252
+ const r = autoVerifyArea(area, projectDir, { jurisdictions });
230
253
  results.push(r);
231
254
  } catch (e) {
232
255
  console.error(chalk.red(`Error verifying "${area}": ${e.message}`));
@@ -307,6 +330,8 @@ program
307
330
  .option('--list', 'Shape A: print area names + traits + pre-built --confirm/--reject flags only')
308
331
  .option('--confirm <ids>', 'Comma-separated low-confidence trigger ids/slugs to confirm (no interactive prompt)')
309
332
  .option('--reject <ids>', 'Comma-separated low-confidence trigger ids/slugs to reject (no interactive prompt)')
333
+ .option('--jurisdiction <codes>', 'Comma-separated jurisdiction codes (eu, us-regulated). Adds jurisdiction-* traits and gates EU AI Act / regional content accordingly.')
334
+ .option('--tight', 'Experimental: require ≥2 trait matches for area inclusion (vs default ≥1). Produces smaller briefs; trades some recall for precision.')
310
335
  .option('--json', 'Output JSON (brief + meta) instead of plain markdown to stdout')
311
336
  .action(async (description, opts) => {
312
337
  if (opts.full && opts.compact) {
@@ -318,10 +343,15 @@ program
318
343
  process.exit(1);
319
344
  }
320
345
 
346
+ // v2.1: parse --jurisdiction flag once, used by all paths below.
347
+ const extraJurisdictions = opts.jurisdiction
348
+ ? opts.jurisdiction.split(',').map((s) => s.trim()).filter(Boolean)
349
+ : [];
350
+
321
351
  // --list short-circuit (Shape A)
322
352
  if (opts.list) {
323
353
  try {
324
- process.stdout.write(buildList({ description }));
354
+ process.stdout.write(buildList({ description, extraJurisdictions, tight: !!opts.tight }));
325
355
  } catch (err) {
326
356
  console.error(chalk.red(err.message));
327
357
  process.exit(1);
@@ -383,7 +413,7 @@ program
383
413
 
384
414
  let result;
385
415
  try {
386
- result = buildBrief({ description, decisions, mode });
416
+ result = buildBrief({ description, decisions, extraJurisdictions, tight: !!opts.tight, mode });
387
417
  } catch (err) {
388
418
  if (err instanceof BriefTooLargeError) {
389
419
  console.error(chalk.red(err.message));
@@ -537,6 +567,105 @@ program
537
567
  process.exit(1);
538
568
  });
539
569
 
570
+ // ============================================================
571
+ // aigis report (v2.1)
572
+ // ============================================================
573
+ program
574
+ .command('report')
575
+ .description('Compile an audit-ready compliance report (verify across multiple areas + cross-framework citations + evidence)')
576
+ .option('--areas <ids>', 'Comma-separated area ids to evaluate (e.g. pii-handling,audit-logging)')
577
+ .option('--from-classify <description>', 'Auto-detect areas: run aigis classify on this description first, then report on the recommended areas')
578
+ .option('--all', 'Evaluate every area in content/skills/areas/ (warning: large output)')
579
+ .option('--project <path>', 'Path to project to scan (default: current directory)', '.')
580
+ .option('--jurisdiction <codes>', 'Comma-separated jurisdiction codes (eu, us-regulated). Surfaces jurisdiction-specific control citations.')
581
+ .option('--format <fmt>', 'Output format: markdown | json (default markdown)', 'markdown')
582
+ .option('--output <path>', 'Write report to file instead of stdout')
583
+ .action(async (opts) => {
584
+ const { buildReport, formatReportMarkdown, formatReportJSON } = require('../lib/report');
585
+ const fs2 = require('fs');
586
+ const pathMod = require('path');
587
+
588
+ const projectDir = pathMod.resolve(opts.project);
589
+ if (!fs2.existsSync(projectDir)) {
590
+ console.error(chalk.red(`Project path does not exist: ${projectDir}`));
591
+ process.exit(1);
592
+ }
593
+
594
+ // Resolve area list — exactly one source must be provided.
595
+ const sources = [opts.areas, opts.fromClassify, opts.all].filter(Boolean).length;
596
+ if (sources === 0) {
597
+ console.error(chalk.red('Provide one of --areas <ids>, --from-classify "<description>", or --all.'));
598
+ console.error(chalk.dim(' aigis report --areas pii-handling,audit-logging --project .'));
599
+ console.error(chalk.dim(' aigis report --from-classify "EU credit scoring system" --project .'));
600
+ console.error(chalk.dim(' aigis report --all --project .'));
601
+ process.exit(1);
602
+ }
603
+ if (sources > 1) {
604
+ console.error(chalk.red('Pass exactly one of --areas, --from-classify, --all.'));
605
+ process.exit(1);
606
+ }
607
+
608
+ let areas = [];
609
+ const jurisdictions = opts.jurisdiction
610
+ ? opts.jurisdiction.split(',').map((s) => s.trim()).filter(Boolean)
611
+ : [];
612
+
613
+ if (opts.areas) {
614
+ areas = opts.areas.split(',').map((s) => s.trim()).filter(Boolean);
615
+ } else if (opts.fromClassify) {
616
+ // Run classify, take its (jurisdiction-filtered) implement_files.
617
+ const { detectTraitsFromText, applyConfirmations } = require('../lib/keywords');
618
+ const detection = detectTraitsFromText(opts.fromClassify);
619
+ const decisions = {};
620
+ for (const sug of detection.low_confidence_matches) decisions[sug.id] = 'no'; // conservative for non-interactive report
621
+ const resolved = applyConfirmations(detection, decisions);
622
+ const jurisdictionTraits = jurisdictions.map((c) => `jurisdiction-${c}`);
623
+ const finalTraits = [...new Set([...resolved.final_traits, ...jurisdictionTraits])].sort();
624
+ if (finalTraits.length === 0) {
625
+ console.error(chalk.red('No traits resolved from --from-classify description. Try --areas <list> instead, or pass a more specific description.'));
626
+ process.exit(1);
627
+ }
628
+ const cls = classify(finalTraits);
629
+ areas = filterAreasByJurisdiction(cls.implement_files, getUserJurisdictions(finalTraits));
630
+ } else {
631
+ // --all: every area markdown file
632
+ const areasDir = pathMod.join(__dirname, '..', 'content', 'skills', 'areas');
633
+ areas = fs2.readdirSync(areasDir)
634
+ .filter((f) => f.endsWith('.md'))
635
+ .map((f) => f.replace(/\.md$/, ''))
636
+ .sort();
637
+ // Apply jurisdiction filter so EU areas don't show for non-EU reports
638
+ areas = filterAreasByJurisdiction(areas, getUserJurisdictions(jurisdictions.map((c) => `jurisdiction-${c}`)));
639
+ }
640
+
641
+ if (areas.length === 0) {
642
+ console.error(chalk.red('No areas to evaluate after jurisdiction filtering. Pass --jurisdiction or different --areas.'));
643
+ process.exit(1);
644
+ }
645
+
646
+ let report;
647
+ try {
648
+ report = buildReport({ projectDir, areas, jurisdictions });
649
+ } catch (err) {
650
+ console.error(chalk.red(err.message));
651
+ process.exit(1);
652
+ }
653
+
654
+ const fmt = (opts.format || 'markdown').toLowerCase();
655
+ let output;
656
+ if (fmt === 'json') output = formatReportJSON(report);
657
+ else if (fmt === 'markdown' || fmt === 'md') output = formatReportMarkdown(report);
658
+ else { console.error(chalk.red(`Unknown --format "${opts.format}". Use markdown or json.`)); process.exit(1); }
659
+
660
+ if (opts.output) {
661
+ fs2.writeFileSync(opts.output, output + (output.endsWith('\n') ? '' : '\n'));
662
+ console.error(chalk.green(`Report written to ${opts.output} (${output.length} chars, ${areas.length} area${areas.length === 1 ? '' : 's'} evaluated)`));
663
+ } else {
664
+ process.stdout.write(output);
665
+ if (!output.endsWith('\n')) process.stdout.write('\n');
666
+ }
667
+ });
668
+
540
669
  // ============================================================
541
670
  // aigis search
542
671
  // ============================================================
@@ -634,11 +763,13 @@ program
634
763
  // ============================================================
635
764
  program
636
765
  .command('init')
637
- .description('Set up aigis for your IDE (writes core skill + resolver block)')
766
+ .description('Set up aigis for your IDE (writes core skill + resolver block). Optional --ci and --hook activation surfaces.')
638
767
  .argument('<ide>', 'IDE to configure: cursor, claude-code, windsurf, copilot')
639
768
  .option('--refresh', 'Overwrite existing aigis content (destructive — use after Aigis updates or to fix a stale resolver block checksum)')
769
+ .option('--ci <provider>', 'Install CI workflow file. Currently supports: github (drops .github/workflows/aigis.yml).')
770
+ .option('--hook', 'Install .git/hooks/pre-commit that runs aigis verify on areas declared in .aigisrc.json.')
640
771
  .action((ide, opts) => {
641
- init(ide, { refresh: !!opts.refresh });
772
+ init(ide, { refresh: !!opts.refresh, ci: opts.ci, hook: !!opts.hook });
642
773
  });
643
774
 
644
775
  // ============================================================