@aigis-ai/cli 2.0.2 → 2.1.1
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.
- package/README.md +94 -45
- package/bin/aigis.js +139 -8
- package/content/resolvers/triggers.json +363 -41
- package/content/skills/areas/audit-logging.md +33 -0
- package/content/skills/areas/bias-monitoring.md +34 -0
- package/content/skills/areas/confidence-scoring.md +23 -0
- package/content/skills/areas/data-integrity.md +25 -0
- package/content/skills/areas/eu-ai-act-art-13-deployer-transparency.md +133 -0
- package/content/skills/areas/eu-ai-act-art-50-transparency-disclosure.md +134 -0
- package/content/skills/areas/eu-ai-act-art-73-incident-reporting.md +149 -0
- package/content/skills/areas/eu-ai-act-art-9-risk-management.md +141 -0
- package/content/skills/areas/fallback-patterns.md +28 -0
- package/content/skills/areas/human-oversight.md +38 -0
- package/content/skills/areas/input-validation.md +27 -0
- package/content/skills/areas/monitoring.md +29 -0
- package/content/skills/areas/prompt-security.md +29 -0
- package/content/templates/eu-ai-act-annex-iv.md +193 -0
- package/docs/frontmatter-schema.md +75 -0
- package/docs/screenshots/README.md +17 -0
- package/docs/screenshots/agent-flow.png +0 -0
- package/docs/screenshots/setup.png +0 -0
- package/docs/screenshots/verify.png +0 -0
- package/lib/auto-verify.js +70 -1
- package/lib/build.js +101 -12
- package/lib/classify.js +8 -2
- package/lib/init.js +269 -5
- package/lib/jurisdiction.js +137 -0
- package/lib/report.js +331 -0
- package/package.json +1 -1
- package/scripts/area-controls-baseline.json +188 -0
- package/scripts/area-frontmatter.schema.json +61 -0
- package/scripts/validate-area-frontmatter.js +228 -0
- package/aigis-ai-cli-2.0.1.tgz +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Aigis area frontmatter schema",
|
|
4
|
+
"description": "YAML frontmatter contract for content/skills/areas/*.md. See docs/frontmatter-schema.md for full semantics.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["id", "title", "controls", "min_risk_tier", "system_traits"],
|
|
7
|
+
"additionalProperties": true,
|
|
8
|
+
"properties": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^[a-z][a-z0-9-]*$",
|
|
12
|
+
"description": "Must equal the filename without .md."
|
|
13
|
+
},
|
|
14
|
+
"title": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"minLength": 1
|
|
17
|
+
},
|
|
18
|
+
"controls": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"required": ["owasp", "nist", "iso42001"],
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"properties": {
|
|
23
|
+
"owasp": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": { "type": "string", "pattern": "^LLM\\d{2}$" }
|
|
26
|
+
},
|
|
27
|
+
"nist": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": { "type": "string", "pattern": "^(MAP|MEASURE|MANAGE|GOVERN)-\\d+(\\.\\d+)?$" }
|
|
30
|
+
},
|
|
31
|
+
"iso42001": {
|
|
32
|
+
"type": "array",
|
|
33
|
+
"items": { "type": "string", "pattern": "^(Clause-\\d+(\\.\\d+)?|Annex-[A-Z](\\.\\d+)?|Annex-[A-Z])$" }
|
|
34
|
+
},
|
|
35
|
+
"eu_ai_act": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"items": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"pattern": "^(Art-\\d+(\\([0-9a-z]+\\))*|Annex-[IVX]+(\\([0-9a-z]+\\))*)$"
|
|
40
|
+
},
|
|
41
|
+
"description": "EU AI Act article references. v2.1 addition. Optional."
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"min_risk_tier": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"enum": ["low", "medium", "high", "all"]
|
|
48
|
+
},
|
|
49
|
+
"system_traits": {
|
|
50
|
+
"type": "array",
|
|
51
|
+
"minItems": 1,
|
|
52
|
+
"items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" }
|
|
53
|
+
},
|
|
54
|
+
"jurisdiction": {
|
|
55
|
+
"type": "array",
|
|
56
|
+
"minItems": 1,
|
|
57
|
+
"items": { "type": "string", "enum": ["eu", "us-regulated"] },
|
|
58
|
+
"description": "Gates which framework controls render in brief. v2.1 addition. Optional. Absence = applies to all jurisdictions."
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Validates frontmatter on every file in content/skills/areas/*.md.
|
|
4
|
+
*
|
|
5
|
+
* Schema: scripts/area-frontmatter.schema.json (reference doc, also validated
|
|
6
|
+
* here by a hand-rolled subset of JSON Schema — same approach as
|
|
7
|
+
* scripts/validate-triggers.js, no ajv dep).
|
|
8
|
+
*
|
|
9
|
+
* Doc: docs/frontmatter-schema.md
|
|
10
|
+
*
|
|
11
|
+
* Exit codes:
|
|
12
|
+
* 0 All area files satisfy the schema.
|
|
13
|
+
* 1 At least one file failed; offending entries printed to stderr.
|
|
14
|
+
*
|
|
15
|
+
* Used by .github/workflows/area-frontmatter-validation.yml on PRs that touch
|
|
16
|
+
* content/skills/areas/. Also runs locally:
|
|
17
|
+
* node scripts/validate-area-frontmatter.js
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const matter = require('gray-matter');
|
|
23
|
+
|
|
24
|
+
const ROOT = path.join(__dirname, '..');
|
|
25
|
+
const AREAS_DIR = path.join(ROOT, 'content', 'skills', 'areas');
|
|
26
|
+
const BASELINE_PATH = path.join(__dirname, 'area-controls-baseline.json');
|
|
27
|
+
const { ALL_TRAITS } = require(path.join(ROOT, 'lib', 'classify.js'));
|
|
28
|
+
const ALL_TRAITS_SET = new Set(ALL_TRAITS);
|
|
29
|
+
|
|
30
|
+
// v2.1 no-deletion baseline: existing area files (those listed in
|
|
31
|
+
// area-controls-baseline.json, captured at v2.0.2) must preserve their
|
|
32
|
+
// owasp/nist/iso42001 control arrays. Adding new framework citations
|
|
33
|
+
// (eu_ai_act) is fine; removing or modifying existing ones is a
|
|
34
|
+
// regression that breaks audit traceability.
|
|
35
|
+
let _baselineCache = null;
|
|
36
|
+
function loadBaseline() {
|
|
37
|
+
if (_baselineCache) return _baselineCache;
|
|
38
|
+
if (!fs.existsSync(BASELINE_PATH)) {
|
|
39
|
+
_baselineCache = {};
|
|
40
|
+
return _baselineCache;
|
|
41
|
+
}
|
|
42
|
+
_baselineCache = JSON.parse(fs.readFileSync(BASELINE_PATH, 'utf8'));
|
|
43
|
+
return _baselineCache;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function arraysEqualSet(a, b) {
|
|
47
|
+
const sa = new Set(a || []); const sb = new Set(b || []);
|
|
48
|
+
if (sa.size !== sb.size) return false;
|
|
49
|
+
for (const x of sa) if (!sb.has(x)) return false;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const RISK_TIERS = new Set(['low', 'medium', 'high', 'all']);
|
|
54
|
+
const JURISDICTIONS = new Set(['eu', 'us-regulated']);
|
|
55
|
+
|
|
56
|
+
const RE_ID = /^[a-z][a-z0-9-]*$/;
|
|
57
|
+
const RE_OWASP = /^LLM\d{2}$/;
|
|
58
|
+
const RE_NIST = /^(MAP|MEASURE|MANAGE|GOVERN)-\d+(\.\d+)?$/;
|
|
59
|
+
const RE_ISO = /^(Clause-\d+(\.\d+)?|Annex-[A-Z](\.\d+)?|Annex-[A-Z])$/;
|
|
60
|
+
const RE_EU_AI_ACT = /^(Art-\d+(\([0-9a-z]+\))*|Annex-[IVX]+(\([0-9a-z]+\))*)$/;
|
|
61
|
+
|
|
62
|
+
function listAreaFiles() {
|
|
63
|
+
return fs.readdirSync(AREAS_DIR)
|
|
64
|
+
.filter((f) => f.endsWith('.md'))
|
|
65
|
+
.sort();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function validateOne(filename) {
|
|
69
|
+
const errors = [];
|
|
70
|
+
const filepath = path.join(AREAS_DIR, filename);
|
|
71
|
+
const expectedId = filename.replace(/\.md$/, '');
|
|
72
|
+
const raw = fs.readFileSync(filepath, 'utf8');
|
|
73
|
+
|
|
74
|
+
let parsed;
|
|
75
|
+
try {
|
|
76
|
+
parsed = matter(raw);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
return [`frontmatter parse error: ${e.message}`];
|
|
79
|
+
}
|
|
80
|
+
const fm = parsed.data;
|
|
81
|
+
|
|
82
|
+
// ── Required fields present
|
|
83
|
+
for (const field of ['id', 'title', 'controls', 'min_risk_tier', 'system_traits']) {
|
|
84
|
+
if (!(field in fm)) errors.push(`missing required field: ${field}`);
|
|
85
|
+
}
|
|
86
|
+
if (errors.length > 0) return errors;
|
|
87
|
+
|
|
88
|
+
// ── id must match filename
|
|
89
|
+
if (typeof fm.id !== 'string' || !RE_ID.test(fm.id)) {
|
|
90
|
+
errors.push(`id "${fm.id}" must be lowercase-kebab-case`);
|
|
91
|
+
} else if (fm.id !== expectedId) {
|
|
92
|
+
errors.push(`id "${fm.id}" must match filename "${expectedId}"`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ── title is non-empty string
|
|
96
|
+
if (typeof fm.title !== 'string' || fm.title.length === 0) {
|
|
97
|
+
errors.push('title must be a non-empty string');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ── controls shape
|
|
101
|
+
if (typeof fm.controls !== 'object' || Array.isArray(fm.controls) || fm.controls === null) {
|
|
102
|
+
errors.push('controls must be an object');
|
|
103
|
+
} else {
|
|
104
|
+
for (const key of ['owasp', 'nist', 'iso42001']) {
|
|
105
|
+
if (!(key in fm.controls)) {
|
|
106
|
+
errors.push(`controls.${key} is required (may be an empty array)`);
|
|
107
|
+
} else if (!Array.isArray(fm.controls[key])) {
|
|
108
|
+
errors.push(`controls.${key} must be an array`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Validate control identifier patterns where the array exists
|
|
112
|
+
for (const v of fm.controls.owasp || []) {
|
|
113
|
+
if (typeof v !== 'string' || !RE_OWASP.test(v)) {
|
|
114
|
+
errors.push(`controls.owasp value "${v}" does not match LLM##`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (const v of fm.controls.nist || []) {
|
|
118
|
+
if (typeof v !== 'string' || !RE_NIST.test(v)) {
|
|
119
|
+
errors.push(`controls.nist value "${v}" does not match <FUNCTION>-N.N`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for (const v of fm.controls.iso42001 || []) {
|
|
123
|
+
if (typeof v !== 'string' || !RE_ISO.test(v)) {
|
|
124
|
+
errors.push(`controls.iso42001 value "${v}" does not match Clause-N or Annex-X[.N]`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// eu_ai_act is OPTIONAL — only validate if present
|
|
128
|
+
if ('eu_ai_act' in fm.controls) {
|
|
129
|
+
if (!Array.isArray(fm.controls.eu_ai_act)) {
|
|
130
|
+
errors.push('controls.eu_ai_act must be an array if present');
|
|
131
|
+
} else {
|
|
132
|
+
for (const v of fm.controls.eu_ai_act) {
|
|
133
|
+
if (typeof v !== 'string' || !RE_EU_AI_ACT.test(v)) {
|
|
134
|
+
errors.push(`controls.eu_ai_act value "${v}" does not match Art-N[(N)(letter)] or Annex-X[(N)]`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// No other keys allowed under controls
|
|
140
|
+
for (const k of Object.keys(fm.controls)) {
|
|
141
|
+
if (!['owasp', 'nist', 'iso42001', 'eu_ai_act'].includes(k)) {
|
|
142
|
+
errors.push(`controls.${k} is not a recognized framework key`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ── v2.1 no-deletion check: existing areas must preserve their
|
|
146
|
+
// owasp/nist/iso42001 arrays from the v2.0.2 baseline. Adding
|
|
147
|
+
// eu_ai_act is fine; modifying the original three is a regression.
|
|
148
|
+
const baseline = loadBaseline();
|
|
149
|
+
if (baseline[expectedId]) {
|
|
150
|
+
for (const fw of ['owasp', 'nist', 'iso42001']) {
|
|
151
|
+
if (!arraysEqualSet(fm.controls[fw], baseline[expectedId][fw])) {
|
|
152
|
+
const before = JSON.stringify(baseline[expectedId][fw]);
|
|
153
|
+
const after = JSON.stringify(fm.controls[fw] || []);
|
|
154
|
+
errors.push(
|
|
155
|
+
`controls.${fw} changed from baseline ${before} → ${after}. ` +
|
|
156
|
+
`Existing framework controls must be preserved (additive-only rule). ` +
|
|
157
|
+
`If the change is intentional, update scripts/area-controls-baseline.json in the same commit.`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ── min_risk_tier
|
|
165
|
+
if (!RISK_TIERS.has(fm.min_risk_tier)) {
|
|
166
|
+
errors.push(`min_risk_tier "${fm.min_risk_tier}" must be one of low | medium | high | all`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ── system_traits
|
|
170
|
+
if (!Array.isArray(fm.system_traits) || fm.system_traits.length === 0) {
|
|
171
|
+
errors.push('system_traits must be a non-empty array');
|
|
172
|
+
} else {
|
|
173
|
+
for (const t of fm.system_traits) {
|
|
174
|
+
if (typeof t !== 'string' || !RE_ID.test(t)) {
|
|
175
|
+
errors.push(`system_traits value "${t}" must be lowercase-kebab-case`);
|
|
176
|
+
} else if (!ALL_TRAITS_SET.has(t)) {
|
|
177
|
+
errors.push(`system_traits value "${t}" is not in lib/classify.js ALL_TRAITS`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ── jurisdiction (optional)
|
|
183
|
+
if ('jurisdiction' in fm) {
|
|
184
|
+
if (!Array.isArray(fm.jurisdiction) || fm.jurisdiction.length === 0) {
|
|
185
|
+
errors.push('jurisdiction must be a non-empty array if present');
|
|
186
|
+
} else {
|
|
187
|
+
for (const j of fm.jurisdiction) {
|
|
188
|
+
if (!JURISDICTIONS.has(j)) {
|
|
189
|
+
errors.push(`jurisdiction value "${j}" must be one of: ${[...JURISDICTIONS].join(', ')}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return errors;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function main() {
|
|
199
|
+
const files = listAreaFiles();
|
|
200
|
+
if (files.length === 0) {
|
|
201
|
+
console.error(`No area files found in ${AREAS_DIR}`);
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let totalErrors = 0;
|
|
206
|
+
let firstErrorFile = null;
|
|
207
|
+
for (const f of files) {
|
|
208
|
+
const errs = validateOne(f);
|
|
209
|
+
if (errs.length > 0) {
|
|
210
|
+
totalErrors += errs.length;
|
|
211
|
+
if (!firstErrorFile) firstErrorFile = f;
|
|
212
|
+
console.error(`\n✗ ${f}`);
|
|
213
|
+
for (const e of errs) console.error(` ${e}`);
|
|
214
|
+
} else {
|
|
215
|
+
console.log(` ✓ ${f}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (totalErrors > 0) {
|
|
220
|
+
console.error(`\nFAIL: ${totalErrors} schema error${totalErrors === 1 ? '' : 's'} across ${files.length} area file${files.length === 1 ? '' : 's'} (first failure: ${firstErrorFile}).`);
|
|
221
|
+
console.error('See docs/frontmatter-schema.md for the schema contract.');
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
console.log(`\nPASS: all ${files.length} area files satisfy the schema.`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (require.main === module) main();
|
|
228
|
+
module.exports = { validateOne, listAreaFiles };
|
package/aigis-ai-cli-2.0.1.tgz
DELETED
|
Binary file
|