aigis-cli 2.0.1__tar.gz → 2.1.0__tar.gz

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 (81) hide show
  1. aigis_cli-2.1.0/PKG-INFO +133 -0
  2. aigis_cli-2.1.0/README.md +106 -0
  3. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/__init__.py +1 -1
  4. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/auto_verify.py +61 -1
  5. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/build.py +73 -12
  6. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/classify.py +8 -2
  7. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/cli.py +120 -10
  8. aigis_cli-2.1.0/aigis_cli/content/resolvers/triggers.json +551 -0
  9. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/audit-logging.md +33 -0
  10. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/bias-monitoring.md +34 -0
  11. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/confidence-scoring.md +23 -0
  12. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/data-integrity.md +25 -0
  13. aigis_cli-2.1.0/aigis_cli/content/skills/areas/eu-ai-act-art-13-deployer-transparency.md +133 -0
  14. aigis_cli-2.1.0/aigis_cli/content/skills/areas/eu-ai-act-art-50-transparency-disclosure.md +134 -0
  15. aigis_cli-2.1.0/aigis_cli/content/skills/areas/eu-ai-act-art-73-incident-reporting.md +149 -0
  16. aigis_cli-2.1.0/aigis_cli/content/skills/areas/eu-ai-act-art-9-risk-management.md +141 -0
  17. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/fallback-patterns.md +28 -0
  18. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/human-oversight.md +38 -0
  19. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/input-validation.md +27 -0
  20. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/monitoring.md +29 -0
  21. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/prompt-security.md +29 -0
  22. aigis_cli-2.1.0/aigis_cli/content/templates/eu-ai-act-annex-iv.md +193 -0
  23. aigis_cli-2.1.0/aigis_cli/init_ide.py +390 -0
  24. aigis_cli-2.1.0/aigis_cli/jurisdiction.py +115 -0
  25. aigis_cli-2.1.0/aigis_cli/report.py +297 -0
  26. aigis_cli-2.1.0/aigis_cli.egg-info/PKG-INFO +133 -0
  27. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli.egg-info/SOURCES.txt +7 -0
  28. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/pyproject.toml +1 -1
  29. aigis_cli-2.0.1/PKG-INFO +0 -59
  30. aigis_cli-2.0.1/README.md +0 -32
  31. aigis_cli-2.0.1/aigis_cli/content/resolvers/triggers.json +0 -229
  32. aigis_cli-2.0.1/aigis_cli/init_ide.py +0 -159
  33. aigis_cli-2.0.1/aigis_cli.egg-info/PKG-INFO +0 -59
  34. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/LICENSE +0 -0
  35. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/SKILL.md +0 -0
  36. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/annotate.py +0 -0
  37. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/checksum.py +0 -0
  38. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/index/audit-scan.md +0 -0
  39. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/index/auto-verify-rules.json +0 -0
  40. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/index/context-rules.json +0 -0
  41. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/index/frameworks.md +0 -0
  42. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/index/guardrails.json +0 -0
  43. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/index/taxonomy.md +0 -0
  44. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/explainability.md +0 -0
  45. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/output-sanitization.md +0 -0
  46. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/pii-handling.md +0 -0
  47. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/rag-security.md +0 -0
  48. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/rate-limiting.md +0 -0
  49. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/areas/supply-chain.md +0 -0
  50. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/core.md +0 -0
  51. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/infrastructure/logging.md +0 -0
  52. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/infrastructure/rate-limiting.md +0 -0
  53. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/infrastructure/secrets.md +0 -0
  54. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/skills/workflows/fastapi-llm.md +0 -0
  55. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/templates/ai-impact-assessment.md +0 -0
  56. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/templates/intended-purpose-doc.md +0 -0
  57. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/templates/risk-characterization.md +0 -0
  58. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/templates/third-party-assessment.md +0 -0
  59. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-audit-logging.md +0 -0
  60. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-bias-monitoring.md +0 -0
  61. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-confidence-scoring.md +0 -0
  62. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-data-integrity.md +0 -0
  63. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-explainability.md +0 -0
  64. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-fallback-patterns.md +0 -0
  65. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-human-oversight.md +0 -0
  66. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-input-validation.md +0 -0
  67. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-monitoring.md +0 -0
  68. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-output-sanitization.md +0 -0
  69. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-pii-handling.md +0 -0
  70. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-prompt-security.md +0 -0
  71. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-rag-security.md +0 -0
  72. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-rate-limiting.md +0 -0
  73. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/content/verify/checklist-supply-chain.md +0 -0
  74. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/fetch.py +0 -0
  75. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/keywords.py +0 -0
  76. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli/search.py +0 -0
  77. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli.egg-info/dependency_links.txt +0 -0
  78. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli.egg-info/entry_points.txt +0 -0
  79. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli.egg-info/requires.txt +0 -0
  80. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/aigis_cli.egg-info/top_level.txt +0 -0
  81. {aigis_cli-2.0.1 → aigis_cli-2.1.0}/setup.cfg +0 -0
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: aigis-cli
3
+ Version: 2.1.0
4
+ Summary: AI governance guardrails for coding agents. Framework-aligned security and compliance patterns from NIST AI RMF, OWASP Top 10 for LLMs, and ISO/IEC 42001.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/NayanKanaparthi/aigis
7
+ Project-URL: Repository, https://github.com/NayanKanaparthi/aigis
8
+ Keywords: ai,governance,security,compliance,llm,owasp,nist,iso42001,guardrails,coding-agent
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Security
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: click>=8.0
22
+ Requires-Dist: rich>=13.0
23
+ Requires-Dist: python-frontmatter>=1.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # Aigis
29
+
30
+ **AI governance that ships with your code.**
31
+
32
+ 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.
33
+
34
+ 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.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ npm install -g @aigis-ai/cli
40
+ # or
41
+ pip install aigis-cli
42
+ ```
43
+
44
+ Verify:
45
+
46
+ ```bash
47
+ aigis --version
48
+ # 2.0.1
49
+ ```
50
+
51
+ ## Quick start
52
+
53
+ ```bash
54
+ aigis build "customer support chatbot with order history lookup"
55
+ ```
56
+
57
+ 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.
58
+
59
+ Paste the brief into your coding agent's chat. The agent implements the patterns. Then:
60
+
61
+ ```bash
62
+ aigis verify <area> --auto .
63
+ ```
64
+
65
+ Runs deterministic checks on the implementation.
66
+
67
+ ## What's new in v2.0
68
+
69
+ - **`aigis build`** — new command that produces one consolidated governance brief per project
70
+ - **Infrastructure content** — production-ready patterns for rate limiting, secrets management, and structured logging
71
+ - **Curated resolver** — 39 high-signal triggers mapped to traits, with interactive confirmation for low-confidence matches
72
+ - **Content architecture redesign** — areas, workflows, and infrastructure separated into layered skills, built around how modern AI agents actually read context
73
+
74
+ ## How Aigis is different
75
+
76
+ **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.
77
+
78
+ **Honest.** Every iteration of v2.0 was benchmarked. The final numbers, against the same 10 descriptions:
79
+
80
+ - Baseline (no Aigis): P=0.737, R=0.905, F1=0.790
81
+ - v2.0 (aigis build): P=0.847, R=0.851, F1=0.837
82
+
83
+ F1 beats baseline by +0.047. Precision improved by +15%. Methodology and per-run tables live in `benchmarks/`.
84
+
85
+ **Open source.** Local. Never calls external LLMs. Never writes files to your project. Your code, your tools, your accountability.
86
+
87
+ ## The principle behind Aigis
88
+
89
+ Governance isn't a content problem. It's an interface problem.
90
+
91
+ 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.
92
+
93
+ 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.
94
+
95
+ 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.
96
+
97
+ ## Commands
98
+
99
+ ```bash
100
+ aigis build "<description>" # Generate governance brief (the main command)
101
+ aigis build "..." --list # List areas without full brief
102
+ aigis build "..." --compact # Pointer-only brief
103
+
104
+ aigis classify "<text>" # Classify traits from description
105
+ aigis get <area> # Fetch governance procedure for an area
106
+ aigis infra <area> # Fetch infrastructure pattern (rate-limiting, secrets, logging)
107
+ aigis workflow <type> # Fetch workflow template
108
+
109
+ aigis verify <area> --auto . # Run deterministic checks on your implementation
110
+ aigis audit . # Summary audit of all implemented areas
111
+ aigis search --list # List all available areas
112
+ ```
113
+
114
+ Run `aigis --help` for full options.
115
+
116
+ ## Supported agents
117
+
118
+ - Cursor
119
+ - Claude Code
120
+ - GitHub Copilot
121
+ - Windsurf
122
+
123
+ 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`.
124
+
125
+ ## Contributing
126
+
127
+ 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`.
128
+
129
+ See `CONTRIBUTING.md` for the full contributor workflow, including how to add new governance areas, workflows, or infrastructure patterns.
130
+
131
+ ## License
132
+
133
+ MIT
@@ -0,0 +1,106 @@
1
+ # Aigis
2
+
3
+ **AI governance that ships with your code.**
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.
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.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install -g @aigis-ai/cli
13
+ # or
14
+ pip install aigis-cli
15
+ ```
16
+
17
+ Verify:
18
+
19
+ ```bash
20
+ aigis --version
21
+ # 2.0.1
22
+ ```
23
+
24
+ ## Quick start
25
+
26
+ ```bash
27
+ aigis build "customer support chatbot with order history lookup"
28
+ ```
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.
31
+
32
+ Paste the brief into your coding agent's chat. The agent implements the patterns. Then:
33
+
34
+ ```bash
35
+ aigis verify <area> --auto .
36
+ ```
37
+
38
+ Runs deterministic checks on the implementation.
39
+
40
+ ## What's new in v2.0
41
+
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
46
+
47
+ ## How Aigis is different
48
+
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.
50
+
51
+ **Honest.** Every iteration of v2.0 was benchmarked. The final numbers, against the same 10 descriptions:
52
+
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
55
+
56
+ F1 beats baseline by +0.047. Precision improved by +15%. Methodology and per-run tables live in `benchmarks/`.
57
+
58
+ **Open source.** Local. Never calls external LLMs. Never writes files to your project. Your code, your tools, your accountability.
59
+
60
+ ## The principle behind Aigis
61
+
62
+ Governance isn't a content problem. It's an interface problem.
63
+
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.
65
+
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.
67
+
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.
69
+
70
+ ## Commands
71
+
72
+ ```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
85
+ ```
86
+
87
+ Run `aigis --help` for full options.
88
+
89
+ ## Supported agents
90
+
91
+ - Cursor
92
+ - Claude Code
93
+ - GitHub Copilot
94
+ - Windsurf
95
+
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`.
97
+
98
+ ## Contributing
99
+
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`.
101
+
102
+ See `CONTRIBUTING.md` for the full contributor workflow, including how to add new governance areas, workflows, or infrastructure patterns.
103
+
104
+ ## License
105
+
106
+ MIT
@@ -1,3 +1,3 @@
1
1
  """aigis-cli: AI governance guardrails for coding agents."""
2
2
 
3
- __version__ = "2.0.0"
3
+ __version__ = "2.1.0"
@@ -406,7 +406,13 @@ _SPECIAL_REGISTRY = {
406
406
 
407
407
  # ── Public API ─────────────────────────────────────────────────────────
408
408
 
409
- def auto_verify_area(area_id: str, project_dir: str) -> dict[str, Any]:
409
+ def auto_verify_area(area_id: str, project_dir: str, jurisdictions: list[str] | None = None) -> dict[str, Any]:
410
+ """v2.1: jurisdictions list (e.g. ['eu']) gates EU AI Act control citations
411
+ in the report. Default empty — verify is conservative; eu_ai_act citations
412
+ only appear when the user explicitly opts in via --jurisdiction eu.
413
+ """
414
+ user_jurisdictions = set(jurisdictions or [])
415
+
410
416
  rules = load_rules()
411
417
  area = rules.get(area_id)
412
418
  if not area:
@@ -414,6 +420,10 @@ def auto_verify_area(area_id: str, project_dir: str) -> dict[str, Any]:
414
420
  f"No auto-verify rules for pattern area '{area_id}'. "
415
421
  f"Known: {', '.join(rules.keys())}"
416
422
  )
423
+
424
+ # v2.1: read area frontmatter controls for citation in the report.
425
+ all_controls = _read_area_controls(area_id)
426
+
417
427
  root = Path(project_dir).resolve()
418
428
  files = _load_files(root)
419
429
 
@@ -455,6 +465,17 @@ def auto_verify_area(area_id: str, project_dir: str) -> dict[str, Any]:
455
465
  auto_fail = sum(1 for r in auto_results.values() if r["status"] == "FAIL")
456
466
  overclaims_raised = sum(1 for r in overclaim_results.values() if r["raised"])
457
467
 
468
+ # v2.1: assemble cited controls. EU AI Act gated on jurisdiction.
469
+ show_eu = "eu" in user_jurisdictions
470
+ cited = None
471
+ if all_controls:
472
+ cited = {
473
+ "owasp": all_controls["owasp"],
474
+ "nist": all_controls["nist"],
475
+ "iso42001": all_controls["iso42001"],
476
+ "eu_ai_act": all_controls["eu_ai_act"] if show_eu else [],
477
+ }
478
+
458
479
  return {
459
480
  "area": area_id,
460
481
  "project_dir": str(root),
@@ -469,9 +490,34 @@ def auto_verify_area(area_id: str, project_dir: str) -> dict[str, Any]:
469
490
  "auto_checks": auto_results,
470
491
  "overclaim_checks": overclaim_results,
471
492
  "judgment_checks": judgment_results,
493
+ "cited_controls": cited,
494
+ "user_jurisdictions": sorted(user_jurisdictions),
472
495
  }
473
496
 
474
497
 
498
+ def _read_area_controls(area_id: str) -> dict[str, list[str]] | None:
499
+ """Read an area's frontmatter `controls` block (all four frameworks).
500
+ Returns None on missing file or parse failure.
501
+ """
502
+ try:
503
+ import frontmatter # local import to keep top-of-file imports lean
504
+ from pathlib import Path
505
+ areas_dir = Path(__file__).resolve().parent / "content" / "skills" / "areas"
506
+ filepath = areas_dir / f"{area_id}.md"
507
+ if not filepath.exists():
508
+ return None
509
+ fm = frontmatter.loads(filepath.read_text(encoding="utf-8")).metadata
510
+ c = fm.get("controls", {}) or {}
511
+ return {
512
+ "owasp": c.get("owasp", []) or [],
513
+ "nist": c.get("nist", []) or [],
514
+ "iso42001": c.get("iso42001", []) or [],
515
+ "eu_ai_act": c.get("eu_ai_act", []) or [],
516
+ }
517
+ except Exception:
518
+ return None
519
+
520
+
475
521
  def format_text_report(result: dict[str, Any]) -> str:
476
522
  lines: list[str] = []
477
523
  lines.append(f"═══ AUTO-VERIFY: {result['area']} ═══\n")
@@ -482,6 +528,20 @@ def format_text_report(result: dict[str, Any]) -> str:
482
528
  lines.append(f"Overclaim recognizers raised: {s['overclaims_raised']}")
483
529
  lines.append(f"Judgment required: {s['judgment_required']} check(s)\n")
484
530
 
531
+ # v2.1: cite framework controls. Mirror of lib/auto-verify.js.
532
+ cited = result.get("cited_controls")
533
+ if cited:
534
+ total_cited = len(cited["owasp"]) + len(cited["nist"]) + len(cited["iso42001"]) + len(cited["eu_ai_act"])
535
+ if total_cited > 0:
536
+ all_pass = s["auto_pass"] == s["auto_total"] and s["auto_fail"] == 0
537
+ header = "Controls satisfied (all auto checks PASS):" if all_pass else "Controls in scope (partial — fix FAIL/OVERCLAIM to fully satisfy):"
538
+ lines.append(f"── {header} ──")
539
+ if cited["owasp"]: lines.append(f" OWASP LLM Top 10: {', '.join(cited['owasp'])}")
540
+ if cited["nist"]: lines.append(f" NIST AI RMF: {', '.join(cited['nist'])}")
541
+ if cited["iso42001"]: lines.append(f" ISO/IEC 42001: {', '.join(cited['iso42001'])}")
542
+ if cited["eu_ai_act"]:lines.append(f" EU AI Act: {', '.join(cited['eu_ai_act'])}")
543
+ lines.append("")
544
+
485
545
  if result["auto_checks"]:
486
546
  lines.append("── AUTO CHECKS ──")
487
547
  for cid, r in result["auto_checks"].items():
@@ -23,6 +23,11 @@ import frontmatter
23
23
  from .classify import classify
24
24
  from .keywords import detect_traits_from_text
25
25
  from .fetch import get_infra
26
+ from .jurisdiction import (
27
+ get_user_jurisdictions,
28
+ filter_areas_by_jurisdiction,
29
+ strip_jurisdiction_gated_sections,
30
+ )
26
31
 
27
32
  CONTENT_DIR = Path(__file__).resolve().parent / "content"
28
33
 
@@ -169,7 +174,21 @@ def _read_version() -> str:
169
174
  return "unknown"
170
175
 
171
176
 
172
- def _prepare(description: str, decisions: dict) -> dict:
177
+ def _read_area_system_traits(area_id: str) -> list[str] | None:
178
+ """v2.1: read an area's `system_traits` frontmatter for --tight matching."""
179
+ try:
180
+ filepath = CONTENT_DIR / "skills" / "areas" / f"{area_id}.md"
181
+ if not filepath.exists():
182
+ return None
183
+ fm = frontmatter.loads(filepath.read_text(encoding="utf-8")).metadata
184
+ st = fm.get("system_traits")
185
+ return list(st) if isinstance(st, list) else None
186
+ except Exception:
187
+ return None
188
+
189
+
190
+ def _prepare(description: str, decisions: dict, extra_jurisdictions: list[str] | None = None, tight: bool = False) -> dict:
191
+ extra_jurisdictions = extra_jurisdictions or []
173
192
  normalized = normalize_description(description)
174
193
  if not normalized:
175
194
  raise ValueError('Provide a description in quotes. Example: aigis build "customer chatbot with RAG"')
@@ -185,13 +204,39 @@ def _prepare(description: str, decisions: dict) -> dict:
185
204
  numeric_decisions[m["id"]] = decisions[m["id"]]
186
205
 
187
206
  resolved = resolve_traits(detection_with_slugs, numeric_decisions, uncertain_as_included=True)
188
- if not resolved["all_traits"]:
207
+
208
+ # v2.1: --jurisdiction flag adds jurisdiction-* traits before classify.
209
+ extra_jurisdiction_traits = [f"jurisdiction-{c}" for c in (extra_jurisdictions or []) if c]
210
+ all_traits_with_jurisdiction = sorted(set(resolved["all_traits"]) | set(extra_jurisdiction_traits))
211
+
212
+ if not all_traits_with_jurisdiction:
189
213
  raise ValueError(
190
214
  "No traits resolved from description. Try a more specific description, "
191
215
  'or use `aigis classify --traits ...` directly.'
192
216
  )
193
- cls = classify(resolved["all_traits"])
194
- areas = cls["implement_files"]
217
+ cls = classify(all_traits_with_jurisdiction)
218
+
219
+ # v2.1: jurisdiction filter on the area list.
220
+ user_jurisdictions = get_user_jurisdictions(all_traits_with_jurisdiction)
221
+ areas_before_filter = cls["implement_files"]
222
+ areas = filter_areas_by_jurisdiction(areas_before_filter, user_jurisdictions)
223
+
224
+ # v2.1 --tight mode: require ≥2 of the user's traits to match an area's system_traits.
225
+ areas_before_tight: list[str] | None = None
226
+ tight_dropped: list[dict] = []
227
+ if tight:
228
+ areas_before_tight = list(areas)
229
+ user_trait_set = set(all_traits_with_jurisdiction)
230
+ kept: list[str] = []
231
+ for area in areas:
232
+ sys_traits = _read_area_system_traits(area) or []
233
+ match_count = sum(1 for t in sys_traits if t in user_trait_set)
234
+ if match_count >= 2:
235
+ kept.append(area)
236
+ else:
237
+ tight_dropped.append({"area": area, "match_count": match_count})
238
+ areas = kept
239
+
195
240
  infra_ids = collect_infra_references(areas)
196
241
 
197
242
  return {
@@ -202,6 +247,11 @@ def _prepare(description: str, decisions: dict) -> dict:
202
247
  "resolved": resolved,
203
248
  "cls": cls,
204
249
  "areas": areas,
250
+ "areas_before_jurisdiction_filter": areas_before_filter,
251
+ "areas_before_tight_filter": areas_before_tight,
252
+ "tight_dropped": tight_dropped,
253
+ "tight_mode": bool(tight),
254
+ "user_jurisdictions": sorted(user_jurisdictions),
205
255
  "infra_ids": infra_ids,
206
256
  }
207
257
 
@@ -303,11 +353,13 @@ def _render_verification(*, areas, resolved, cls):
303
353
 
304
354
 
305
355
  def build_compact(description: str, decisions: dict | None = None, *,
356
+ extra_jurisdictions: list[str] | None = None,
357
+ tight: bool = False,
306
358
  timestamp: datetime | None = None,
307
359
  version_string: str | None = None,
308
360
  fell_back_from_full: bool = False) -> dict:
309
361
  decisions = decisions or {}
310
- prep = _prepare(description, decisions)
362
+ prep = _prepare(description, decisions, extra_jurisdictions, tight=tight)
311
363
  ts = _iso_ms(timestamp)
312
364
  version = version_string or _read_version()
313
365
 
@@ -352,11 +404,13 @@ def build_compact(description: str, decisions: dict | None = None, *,
352
404
 
353
405
 
354
406
  def build_full(description: str, decisions: dict | None = None, *,
407
+ extra_jurisdictions: list[str] | None = None,
408
+ tight: bool = False,
355
409
  char_cap: int = FULL_HARD_CAP,
356
410
  timestamp: datetime | None = None,
357
411
  version_string: str | None = None) -> dict:
358
412
  decisions = decisions or {}
359
- prep = _prepare(description, decisions)
413
+ prep = _prepare(description, decisions, extra_jurisdictions, tight=tight)
360
414
  ts = _iso_ms(timestamp)
361
415
  version = version_string or _read_version()
362
416
 
@@ -365,6 +419,10 @@ def build_full(description: str, decisions: dict | None = None, *,
365
419
  cls=prep["cls"], resolved=prep["resolved"], areas=prep["areas"], infra_ids=prep["infra_ids"],
366
420
  )
367
421
 
422
+ # v2.1: for non-EU users, strip `## EU AI Act extensions` sections from
423
+ # universal-area content before inlining (parity with lib/build.js).
424
+ user_j = set(prep["user_jurisdictions"])
425
+
368
426
  s.append("## Areas")
369
427
  s.append("")
370
428
  for i, area in enumerate(prep["areas"], 1):
@@ -373,6 +431,7 @@ def build_full(description: str, decisions: dict | None = None, *,
373
431
  except FileNotFoundError:
374
432
  continue
375
433
  stripped = strip_frontmatter_raw(raw)
434
+ stripped = strip_jurisdiction_gated_sections(stripped, user_j)
376
435
  s.append(f"### {i}. {area}")
377
436
  s.append("")
378
437
  s.append(stripped)
@@ -406,23 +465,25 @@ def build_full(description: str, decisions: dict | None = None, *,
406
465
 
407
466
 
408
467
  def build_brief(description: str, decisions: dict | None = None, *,
468
+ extra_jurisdictions: list[str] | None = None,
469
+ tight: bool = False,
409
470
  mode: str = "auto",
410
471
  timestamp: datetime | None = None,
411
472
  version_string: str | None = None) -> dict:
412
473
  """Dispatcher. mode ∈ {'auto', 'full', 'compact'}."""
413
474
  decisions = decisions or {}
414
475
  if mode == "compact":
415
- r = build_compact(description, decisions, timestamp=timestamp, version_string=version_string)
476
+ r = build_compact(description, decisions, extra_jurisdictions=extra_jurisdictions, tight=tight, timestamp=timestamp, version_string=version_string)
416
477
  return {**r, "mode": "compact", "auto_fallback": False}
417
478
  if mode == "full":
418
- r = build_full(description, decisions, char_cap=FULL_HARD_CAP, timestamp=timestamp, version_string=version_string)
479
+ r = build_full(description, decisions, extra_jurisdictions=extra_jurisdictions, tight=tight, char_cap=FULL_HARD_CAP, timestamp=timestamp, version_string=version_string)
419
480
  return {**r, "mode": "full", "auto_fallback": False}
420
481
  # auto
421
482
  try:
422
- r = build_full(description, decisions, char_cap=AUTO_FULL_CAP, timestamp=timestamp, version_string=version_string)
483
+ r = build_full(description, decisions, extra_jurisdictions=extra_jurisdictions, tight=tight, char_cap=AUTO_FULL_CAP, timestamp=timestamp, version_string=version_string)
423
484
  return {**r, "mode": "full", "auto_fallback": False}
424
485
  except BriefTooLargeError as e:
425
- compact = build_compact(description, decisions, timestamp=timestamp, version_string=version_string, fell_back_from_full=True)
486
+ compact = build_compact(description, decisions, extra_jurisdictions=extra_jurisdictions, tight=tight, timestamp=timestamp, version_string=version_string, fell_back_from_full=True)
426
487
  return {
427
488
  **compact,
428
489
  "mode": "compact",
@@ -432,9 +493,9 @@ def build_brief(description: str, decisions: dict | None = None, *,
432
493
  }
433
494
 
434
495
 
435
- def build_list(description: str) -> str:
496
+ def build_list(description: str, extra_jurisdictions: list[str] | None = None, tight: bool = False) -> str:
436
497
  """Shape A — text output for `aigis build --list`."""
437
- prep = _prepare(description, {})
498
+ prep = _prepare(description, {}, extra_jurisdictions, tight=tight)
438
499
  lines: list[str] = []
439
500
  lines.append(f"Description: {prep['normalized']}")
440
501
  lines.append(f"Risk tier: {prep['cls']['risk_tier']}")
@@ -6,10 +6,11 @@ ALL_TRAITS = [
6
6
  "influences-decisions", "accepts-user-input", "is-external", "is-internal", "is-high-volume",
7
7
  "generates-code", "generates-content", "multi-model-pipeline",
8
8
  "jurisdiction-eu", "jurisdiction-us-regulated", "jurisdiction-global",
9
+ "is-eu-high-risk", # v2.1: EU AI Act Annex III gating trait
9
10
  ]
10
11
 
11
12
  TRAIT_FILES: dict[str, list[str]] = {
12
- "uses-llm": ["input-validation", "output-sanitization", "prompt-security", "audit-logging", "monitoring"],
13
+ "uses-llm": ["input-validation", "output-sanitization", "prompt-security", "audit-logging", "monitoring", "eu-ai-act-art-50-transparency-disclosure"],
13
14
  "uses-rag": ["rag-security", "data-integrity"],
14
15
  "uses-finetuned": ["data-integrity", "supply-chain"],
15
16
  "uses-thirdparty-api": ["supply-chain"],
@@ -21,7 +22,7 @@ TRAIT_FILES: dict[str, list[str]] = {
21
22
  "handles-proprietary": ["pii-handling", "prompt-security"],
22
23
  "handles-minors": ["pii-handling", "bias-monitoring", "human-oversight"],
23
24
  "influences-decisions": ["bias-monitoring", "confidence-scoring", "human-oversight", "explainability"],
24
- "accepts-user-input": ["input-validation", "output-sanitization"],
25
+ "accepts-user-input": ["input-validation", "output-sanitization", "eu-ai-act-art-50-transparency-disclosure"],
25
26
  "is-external": ["rate-limiting", "confidence-scoring"],
26
27
  "is-internal": [],
27
28
  "is-high-volume": ["rate-limiting", "monitoring", "fallback-patterns"],
@@ -31,6 +32,11 @@ TRAIT_FILES: dict[str, list[str]] = {
31
32
  "jurisdiction-eu": [],
32
33
  "jurisdiction-us-regulated": [],
33
34
  "jurisdiction-global": [],
35
+ "is-eu-high-risk": [
36
+ "eu-ai-act-art-9-risk-management",
37
+ "eu-ai-act-art-13-deployer-transparency",
38
+ "eu-ai-act-art-73-incident-reporting",
39
+ ], # v2.1: pulls EU AI Act high-risk areas; brief assembly filters by jurisdiction-eu
34
40
  }
35
41
 
36
42
  FILE_CONTROLS: dict[str, dict[str, list[str]]] = {