@aigis-ai/cli 1.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.
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/SKILL.md +74 -0
- package/bin/aigis.js +337 -0
- package/content/implement/audit-logging.md +171 -0
- package/content/implement/bias-monitoring.md +172 -0
- package/content/implement/confidence-scoring.md +180 -0
- package/content/implement/data-integrity.md +257 -0
- package/content/implement/explainability.md +174 -0
- package/content/implement/fallback-patterns.md +190 -0
- package/content/implement/human-oversight.md +220 -0
- package/content/implement/input-validation.md +212 -0
- package/content/implement/monitoring.md +207 -0
- package/content/implement/output-sanitization.md +183 -0
- package/content/implement/pii-handling.md +207 -0
- package/content/implement/prompt-security.md +153 -0
- package/content/implement/rag-security.md +230 -0
- package/content/implement/rate-limiting.md +217 -0
- package/content/implement/supply-chain.md +193 -0
- package/content/index/audit-scan.md +403 -0
- package/content/index/frameworks.md +82 -0
- package/content/index/guardrails.json +23 -0
- package/content/index/taxonomy.md +81 -0
- package/content/templates/ai-impact-assessment.md +54 -0
- package/content/templates/intended-purpose-doc.md +39 -0
- package/content/templates/risk-characterization.md +34 -0
- package/content/templates/third-party-assessment.md +41 -0
- package/content/verify/checklist-audit-logging.md +13 -0
- package/content/verify/checklist-bias-monitoring.md +13 -0
- package/content/verify/checklist-confidence-scoring.md +13 -0
- package/content/verify/checklist-data-integrity.md +12 -0
- package/content/verify/checklist-explainability.md +13 -0
- package/content/verify/checklist-fallback-patterns.md +13 -0
- package/content/verify/checklist-human-oversight.md +14 -0
- package/content/verify/checklist-input-validation.md +16 -0
- package/content/verify/checklist-monitoring.md +13 -0
- package/content/verify/checklist-output-sanitization.md +14 -0
- package/content/verify/checklist-pii-handling.md +14 -0
- package/content/verify/checklist-prompt-security.md +13 -0
- package/content/verify/checklist-rag-security.md +12 -0
- package/content/verify/checklist-rate-limiting.md +13 -0
- package/content/verify/checklist-supply-chain.md +13 -0
- package/lib/annotate.js +53 -0
- package/lib/classify.js +185 -0
- package/lib/fetch.js +112 -0
- package/lib/init.js +122 -0
- package/lib/keywords.js +139 -0
- package/lib/search.js +76 -0
- package/package.json +35 -0
package/lib/fetch.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const matter = require('gray-matter');
|
|
4
|
+
const { getAnnotations } = require('./annotate');
|
|
5
|
+
|
|
6
|
+
const CONTENT_DIR = path.join(__dirname, '..', 'content');
|
|
7
|
+
|
|
8
|
+
function readFile(dir, id) {
|
|
9
|
+
const filepath = path.join(CONTENT_DIR, dir, `${id}.md`);
|
|
10
|
+
if (!fs.existsSync(filepath)) {
|
|
11
|
+
throw new Error(`File not found: ${dir}/${id}.md`);
|
|
12
|
+
}
|
|
13
|
+
return fs.readFileSync(filepath, 'utf8');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function listDir(dir) {
|
|
17
|
+
const dirpath = path.join(CONTENT_DIR, dir);
|
|
18
|
+
if (!fs.existsSync(dirpath)) return [];
|
|
19
|
+
return fs.readdirSync(dirpath)
|
|
20
|
+
.filter(f => f.endsWith('.md'))
|
|
21
|
+
.map(f => f.replace('.md', ''));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function stripFrontmatter(content) {
|
|
25
|
+
const parsed = matter(content);
|
|
26
|
+
return parsed.content.trim();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function filterLanguage(content, lang) {
|
|
30
|
+
if (!lang) return content;
|
|
31
|
+
|
|
32
|
+
const keep = lang === 'py' ? 'python' : 'javascript';
|
|
33
|
+
const remove = lang === 'py' ? 'javascript' : 'python';
|
|
34
|
+
|
|
35
|
+
// Remove code blocks of the unwanted language
|
|
36
|
+
const regex = new RegExp('```' + remove + '[\\s\\S]*?```\\n?', 'g');
|
|
37
|
+
return content.replace(regex, '');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function appendAnnotations(content, fileId) {
|
|
41
|
+
const annotations = getAnnotations(fileId);
|
|
42
|
+
if (annotations.length === 0) return content;
|
|
43
|
+
|
|
44
|
+
let annotationBlock = '\n\n---\n## Local annotations\n\n';
|
|
45
|
+
for (const a of annotations) {
|
|
46
|
+
annotationBlock += `- ${a.note} _(${a.date})_\n`;
|
|
47
|
+
}
|
|
48
|
+
return content + annotationBlock;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function get(fileIds, opts = {}) {
|
|
52
|
+
if (opts.all) {
|
|
53
|
+
fileIds = listDir('implement');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!fileIds || fileIds.length === 0) {
|
|
57
|
+
throw new Error('Provide file IDs or use --all. Run "aigis search --list" to see available files.');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const outputs = [];
|
|
61
|
+
for (const id of fileIds) {
|
|
62
|
+
let content = readFile('implement', id);
|
|
63
|
+
|
|
64
|
+
if (opts.frontmatter === false) {
|
|
65
|
+
content = stripFrontmatter(content);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (opts.lang) {
|
|
69
|
+
content = filterLanguage(content, opts.lang);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
content = appendAnnotations(content, id);
|
|
73
|
+
outputs.push(content);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return outputs.join('\n\n---\n\n');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function verify(fileIds) {
|
|
80
|
+
if (!fileIds || fileIds.length === 0) {
|
|
81
|
+
throw new Error('Provide file IDs to verify.');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const outputs = [];
|
|
85
|
+
for (const id of fileIds) {
|
|
86
|
+
const checklistId = `checklist-${id}`;
|
|
87
|
+
const content = readFile('verify', checklistId);
|
|
88
|
+
outputs.push(content);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return outputs.join('\n\n---\n\n');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getTemplate(templateIds) {
|
|
95
|
+
if (!templateIds || templateIds.length === 0) {
|
|
96
|
+
throw new Error('Provide template IDs.');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const outputs = [];
|
|
100
|
+
for (const id of templateIds) {
|
|
101
|
+
const content = readFile('templates', id);
|
|
102
|
+
outputs.push(content);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return outputs.join('\n\n---\n\n');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function getAuditScan() {
|
|
109
|
+
return readFile('index', 'audit-scan');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
module.exports = { get, verify, getTemplate, getAuditScan, readFile, listDir };
|
package/lib/init.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
const CURSOR_RULES = `# Aigis AI Governance
|
|
6
|
+
# Added by: aigis init cursor
|
|
7
|
+
# Docs: https://github.com/aigis-ai/aigis
|
|
8
|
+
|
|
9
|
+
When building any AI or LLM feature, use the aigis CLI for governance patterns:
|
|
10
|
+
|
|
11
|
+
1. Before writing LLM code, classify the system:
|
|
12
|
+
Run: aigis classify --traits <relevant-traits> --json
|
|
13
|
+
|
|
14
|
+
2. Fetch implementation patterns for each recommended file:
|
|
15
|
+
Run: aigis get <file-id> [file-id...]
|
|
16
|
+
|
|
17
|
+
3. Apply the patterns when writing code.
|
|
18
|
+
|
|
19
|
+
4. After writing code, verify:
|
|
20
|
+
Run: aigis verify <file-id> [file-id...]
|
|
21
|
+
|
|
22
|
+
5. For HIGH/MEDIUM risk systems, generate compliance docs:
|
|
23
|
+
Run: aigis template <template-id>
|
|
24
|
+
|
|
25
|
+
6. To audit an existing project:
|
|
26
|
+
Run: aigis audit --scan
|
|
27
|
+
|
|
28
|
+
Available traits: uses-llm, uses-rag, uses-finetuned, uses-thirdparty-api, is-agentic, is-multimodal, processes-pii, handles-financial, handles-health, handles-proprietary, handles-minors, influences-decisions, accepts-user-input, is-external, is-internal, is-high-volume, generates-code, generates-content, multi-model-pipeline, jurisdiction-eu, jurisdiction-us-regulated, jurisdiction-global
|
|
29
|
+
|
|
30
|
+
Run "aigis search --list" to see all available governance patterns.
|
|
31
|
+
Run "aigis traits" to see trait descriptions.
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const WINDSURF_RULES = CURSOR_RULES;
|
|
35
|
+
|
|
36
|
+
const COPILOT_INSTRUCTIONS = CURSOR_RULES;
|
|
37
|
+
|
|
38
|
+
const CLAUDE_CODE_SKILL = fs.readFileSync(
|
|
39
|
+
path.join(__dirname, '..', 'SKILL.md'),
|
|
40
|
+
'utf8'
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const IDE_CONFIG = {
|
|
44
|
+
cursor: {
|
|
45
|
+
file: '.cursorrules',
|
|
46
|
+
content: CURSOR_RULES,
|
|
47
|
+
description: 'Cursor rules file',
|
|
48
|
+
instruction: 'Cursor will read these instructions on every interaction in this project.',
|
|
49
|
+
},
|
|
50
|
+
windsurf: {
|
|
51
|
+
file: '.windsurfrules',
|
|
52
|
+
content: WINDSURF_RULES,
|
|
53
|
+
description: 'Windsurf rules file',
|
|
54
|
+
instruction: 'Windsurf will read these instructions on every interaction in this project.',
|
|
55
|
+
},
|
|
56
|
+
copilot: {
|
|
57
|
+
file: '.github/copilot-instructions.md',
|
|
58
|
+
content: COPILOT_INSTRUCTIONS,
|
|
59
|
+
description: 'GitHub Copilot instructions',
|
|
60
|
+
instruction: 'Copilot will read these instructions for this repository.',
|
|
61
|
+
},
|
|
62
|
+
'claude-code': {
|
|
63
|
+
file: null, // Special handling
|
|
64
|
+
content: CLAUDE_CODE_SKILL,
|
|
65
|
+
description: 'Claude Code skill file',
|
|
66
|
+
instruction: null,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function init(ide) {
|
|
71
|
+
const ideLower = ide.toLowerCase();
|
|
72
|
+
const config = IDE_CONFIG[ideLower];
|
|
73
|
+
|
|
74
|
+
if (!config) {
|
|
75
|
+
console.error(chalk.red(`Unknown IDE: ${ide}`));
|
|
76
|
+
console.log(chalk.dim('Available: cursor, claude-code, windsurf, copilot\n'));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Claude Code has a special setup path
|
|
81
|
+
if (ideLower === 'claude-code') {
|
|
82
|
+
const skillDir = path.join(require('os').homedir(), '.claude', 'skills', 'aigis');
|
|
83
|
+
const skillFile = path.join(skillDir, 'SKILL.md');
|
|
84
|
+
|
|
85
|
+
if (!fs.existsSync(skillDir)) {
|
|
86
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fs.writeFileSync(skillFile, config.content);
|
|
90
|
+
console.log(chalk.green(`\n✓ Created ${skillFile}\n`));
|
|
91
|
+
console.log(chalk.dim('Claude Code will automatically read this skill file.'));
|
|
92
|
+
console.log(chalk.dim('Restart Claude Code for the skill to take effect.\n'));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// For Copilot, ensure .github directory exists
|
|
97
|
+
const targetFile = path.resolve(config.file);
|
|
98
|
+
const targetDir = path.dirname(targetFile);
|
|
99
|
+
if (!fs.existsSync(targetDir)) {
|
|
100
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Append or create
|
|
104
|
+
if (fs.existsSync(targetFile)) {
|
|
105
|
+
const existing = fs.readFileSync(targetFile, 'utf8');
|
|
106
|
+
if (existing.includes('aigis')) {
|
|
107
|
+
console.log(chalk.yellow(`\n⚠ ${config.file} already contains aigis configuration.\n`));
|
|
108
|
+
console.log(chalk.dim('No changes made. Remove the existing aigis section first if you want to update.\n'));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
fs.appendFileSync(targetFile, '\n\n' + config.content);
|
|
112
|
+
console.log(chalk.green(`\n✓ Appended aigis configuration to ${config.file}\n`));
|
|
113
|
+
console.log(chalk.dim('Your existing rules are preserved.\n'));
|
|
114
|
+
} else {
|
|
115
|
+
fs.writeFileSync(targetFile, config.content);
|
|
116
|
+
console.log(chalk.green(`\n✓ Created ${config.file}\n`));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log(chalk.dim(config.instruction + '\n'));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = { init };
|
package/lib/keywords.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const KEYWORD_MAP = {
|
|
2
|
+
'uses-llm': [
|
|
3
|
+
'llm', 'language model', 'gpt', 'claude', 'chatbot', 'chat bot', 'bot',
|
|
4
|
+
'generative ai', 'gen ai', 'genai', 'openai', 'anthropic', 'gemini',
|
|
5
|
+
'mistral', 'cohere', 'completion', 'prompt', 'chat completion',
|
|
6
|
+
'text generation', 'natural language', 'nlp',
|
|
7
|
+
],
|
|
8
|
+
'uses-rag': [
|
|
9
|
+
'rag', 'retrieval', 'vector', 'embedding', 'knowledge base', 'knowledgebase',
|
|
10
|
+
'pinecone', 'weaviate', 'chromadb', 'chroma', 'qdrant', 'pgvector',
|
|
11
|
+
'faiss', 'milvus', 'semantic search', 'document search', 'vector db',
|
|
12
|
+
'vector database', 'vector store',
|
|
13
|
+
],
|
|
14
|
+
'uses-finetuned': [
|
|
15
|
+
'fine-tune', 'finetune', 'fine tune', 'custom model', 'trained model',
|
|
16
|
+
'lora', 'qlora', 'peft', 'sft', 'custom trained', 'training data',
|
|
17
|
+
'fine-tuning',
|
|
18
|
+
],
|
|
19
|
+
'uses-thirdparty-api': [
|
|
20
|
+
'openai api', 'anthropic api', 'api key', 'third party', 'third-party',
|
|
21
|
+
'external model', 'model provider', 'hosted model', 'api provider',
|
|
22
|
+
'cloud model', 'model api',
|
|
23
|
+
],
|
|
24
|
+
'is-agentic': [
|
|
25
|
+
'agent', 'agentic', 'autonomous', 'auto-execute', 'takes actions',
|
|
26
|
+
'tool use', 'function calling', 'tool calling', 'writes to database',
|
|
27
|
+
'sends email', 'executes code', 'multi-step', 'self-directed',
|
|
28
|
+
'langchain agent', 'autogen', 'crewai',
|
|
29
|
+
],
|
|
30
|
+
'is-multimodal': [
|
|
31
|
+
'multimodal', 'multi-modal', 'image', 'audio', 'video', 'vision',
|
|
32
|
+
'speech', 'voice', 'text-to-speech', 'speech-to-text', 'ocr',
|
|
33
|
+
'image generation', 'dall-e', 'stable diffusion', 'whisper',
|
|
34
|
+
],
|
|
35
|
+
'processes-pii': [
|
|
36
|
+
'pii', 'personal data', 'personally identifiable', 'names', 'emails',
|
|
37
|
+
'email address', 'phone number', 'ssn', 'social security', 'address',
|
|
38
|
+
'date of birth', 'user data', 'customer data', 'gdpr', 'personal information',
|
|
39
|
+
],
|
|
40
|
+
'handles-financial': [
|
|
41
|
+
'financial', 'finance', 'banking', 'payment', 'credit', 'debit',
|
|
42
|
+
'transaction', 'insurance', 'claim', 'policy', 'lending', 'loan',
|
|
43
|
+
'mortgage', 'investment', 'trading', 'fintech', 'account balance',
|
|
44
|
+
'credit card', 'credit score',
|
|
45
|
+
],
|
|
46
|
+
'handles-health': [
|
|
47
|
+
'health', 'medical', 'clinical', 'patient', 'diagnosis', 'prescription',
|
|
48
|
+
'hipaa', 'healthcare', 'hospital', 'doctor', 'treatment', 'symptom',
|
|
49
|
+
'disease', 'medication', 'ehr', 'electronic health', 'pharma',
|
|
50
|
+
'pharmaceutical',
|
|
51
|
+
],
|
|
52
|
+
'handles-proprietary': [
|
|
53
|
+
'proprietary', 'trade secret', 'confidential', 'internal only',
|
|
54
|
+
'competitive', 'intellectual property', 'ip', 'source code analysis',
|
|
55
|
+
'strategy', 'classified',
|
|
56
|
+
],
|
|
57
|
+
'handles-minors': [
|
|
58
|
+
'children', 'child', 'minor', 'kid', 'student', 'school', 'coppa',
|
|
59
|
+
'under 13', 'under 16', 'parental', 'youth', 'teen', 'education',
|
|
60
|
+
'k-12', 'k12',
|
|
61
|
+
],
|
|
62
|
+
'influences-decisions': [
|
|
63
|
+
'decision', 'approve', 'deny', 'reject', 'score', 'rank', 'filter',
|
|
64
|
+
'hiring', 'recruitment', 'credit decision', 'loan decision',
|
|
65
|
+
'eligibility', 'assessment', 'evaluation', 'grading', 'sentencing',
|
|
66
|
+
'recommendation', 'determines', 'affects people',
|
|
67
|
+
],
|
|
68
|
+
'accepts-user-input': [
|
|
69
|
+
'user input', 'user text', 'chat', 'message', 'form', 'text area',
|
|
70
|
+
'text input', 'free text', 'user query', 'search box', 'prompt input',
|
|
71
|
+
'customer message', 'user message', 'text field',
|
|
72
|
+
],
|
|
73
|
+
'is-external': [
|
|
74
|
+
'customer', 'public', 'external', 'user-facing', 'customer-facing',
|
|
75
|
+
'consumer', 'website', 'app', 'saas', 'product', 'end user',
|
|
76
|
+
'client-facing',
|
|
77
|
+
],
|
|
78
|
+
'is-internal': [
|
|
79
|
+
'internal', 'employee', 'staff only', 'back office', 'internal tool',
|
|
80
|
+
'admin only', 'intranet', 'corporate only',
|
|
81
|
+
],
|
|
82
|
+
'is-high-volume': [
|
|
83
|
+
'high volume', 'production', 'scale', 'thousands', 'millions',
|
|
84
|
+
'high traffic', 'load balancer', 'auto-scaling', 'enterprise',
|
|
85
|
+
'at scale', 'high throughput',
|
|
86
|
+
],
|
|
87
|
+
'generates-code': [
|
|
88
|
+
'generates code', 'code generation', 'sql generation', 'writes code',
|
|
89
|
+
'code execution', 'executes code', 'eval', 'exec', 'coding assistant',
|
|
90
|
+
'code interpreter',
|
|
91
|
+
],
|
|
92
|
+
'generates-content': [
|
|
93
|
+
'generates content', 'content generation', 'marketing copy', 'blog post',
|
|
94
|
+
'email generation', 'social media', 'article', 'report generation',
|
|
95
|
+
'publish', 'customer email', 'notification',
|
|
96
|
+
],
|
|
97
|
+
'multi-model-pipeline': [
|
|
98
|
+
'pipeline', 'chain', 'multi-model', 'multi model', 'sequential',
|
|
99
|
+
'model chain', 'orchestration', 'workflow', 'first model',
|
|
100
|
+
'second model', 'feeds into',
|
|
101
|
+
],
|
|
102
|
+
'jurisdiction-eu': [
|
|
103
|
+
'eu', 'european', 'europe', 'gdpr', 'eu ai act', 'ai act',
|
|
104
|
+
'european union', 'germany', 'france', 'brussels',
|
|
105
|
+
],
|
|
106
|
+
'jurisdiction-us-regulated': [
|
|
107
|
+
'hipaa', 'fcra', 'ferpa', 'fedramp', 'soc2', 'regulated',
|
|
108
|
+
'compliance', 'banking regulation', 'sec', 'finra', 'occ',
|
|
109
|
+
'us regulated', 'federal',
|
|
110
|
+
],
|
|
111
|
+
'jurisdiction-global': [
|
|
112
|
+
'global', 'worldwide', 'international', 'multi-country', 'multi country',
|
|
113
|
+
'cross-border', 'multiple countries', 'global deployment',
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
function detectTraitsFromText(text) {
|
|
118
|
+
const textLower = text.toLowerCase();
|
|
119
|
+
const detected = [];
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
|
|
122
|
+
for (const [trait, keywords] of Object.entries(KEYWORD_MAP)) {
|
|
123
|
+
for (const keyword of keywords) {
|
|
124
|
+
if (textLower.includes(keyword) && !seen.has(trait)) {
|
|
125
|
+
seen.add(trait);
|
|
126
|
+
detected.push({
|
|
127
|
+
trait,
|
|
128
|
+
keyword,
|
|
129
|
+
confidence: keyword.length > 4 ? 'high' : 'medium',
|
|
130
|
+
});
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return detected;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
module.exports = { detectTraitsFromText, KEYWORD_MAP };
|
package/lib/search.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const matter = require('gray-matter');
|
|
4
|
+
|
|
5
|
+
const CONTENT_DIR = path.join(__dirname, '..', 'content');
|
|
6
|
+
|
|
7
|
+
function loadFileMeta(dir) {
|
|
8
|
+
const dirpath = path.join(CONTENT_DIR, dir);
|
|
9
|
+
if (!fs.existsSync(dirpath)) return [];
|
|
10
|
+
|
|
11
|
+
return fs.readdirSync(dirpath)
|
|
12
|
+
.filter(f => f.endsWith('.md'))
|
|
13
|
+
.map(f => {
|
|
14
|
+
const content = fs.readFileSync(path.join(dirpath, f), 'utf8');
|
|
15
|
+
const parsed = matter(content);
|
|
16
|
+
return {
|
|
17
|
+
id: parsed.data.id || f.replace('.md', ''),
|
|
18
|
+
title: parsed.data.title || f.replace('.md', ''),
|
|
19
|
+
controls: parsed.data.controls || {},
|
|
20
|
+
dir,
|
|
21
|
+
filename: f,
|
|
22
|
+
content: content.toLowerCase(),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function search(query) {
|
|
28
|
+
const queryLower = query.toLowerCase();
|
|
29
|
+
const results = [];
|
|
30
|
+
|
|
31
|
+
const implement = loadFileMeta('implement');
|
|
32
|
+
const templates = loadFileMeta('templates');
|
|
33
|
+
const all = [...implement, ...templates];
|
|
34
|
+
|
|
35
|
+
for (const file of all) {
|
|
36
|
+
const matchedControls = [];
|
|
37
|
+
|
|
38
|
+
// Check title match
|
|
39
|
+
const titleMatch = file.title.toLowerCase().includes(queryLower);
|
|
40
|
+
|
|
41
|
+
// Check control ID match
|
|
42
|
+
if (file.controls) {
|
|
43
|
+
for (const [framework, ids] of Object.entries(file.controls)) {
|
|
44
|
+
for (const id of (ids || [])) {
|
|
45
|
+
if (id.toLowerCase().includes(queryLower)) {
|
|
46
|
+
matchedControls.push(`${framework}:${id}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check content match
|
|
53
|
+
const contentMatch = file.content.includes(queryLower);
|
|
54
|
+
|
|
55
|
+
if (titleMatch || matchedControls.length > 0 || contentMatch) {
|
|
56
|
+
results.push({
|
|
57
|
+
id: file.id,
|
|
58
|
+
title: file.title,
|
|
59
|
+
dir: file.dir,
|
|
60
|
+
matched_controls: matchedControls,
|
|
61
|
+
relevance: (titleMatch ? 3 : 0) + (matchedControls.length * 2) + (contentMatch ? 1 : 0),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return results.sort((a, b) => b.relevance - a.relevance);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function listAll() {
|
|
70
|
+
return {
|
|
71
|
+
implement: loadFileMeta('implement').map(f => ({ id: f.id, title: f.title })),
|
|
72
|
+
templates: loadFileMeta('templates').map(f => ({ id: f.id, title: f.title })),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = { search, listAll };
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aigis-ai/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "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
|
+
"main": "bin/aigis.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"aigis": "bin/aigis.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"ai",
|
|
11
|
+
"governance",
|
|
12
|
+
"security",
|
|
13
|
+
"compliance",
|
|
14
|
+
"llm",
|
|
15
|
+
"owasp",
|
|
16
|
+
"nist",
|
|
17
|
+
"iso42001",
|
|
18
|
+
"guardrails",
|
|
19
|
+
"coding-agent"
|
|
20
|
+
],
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/aigis-ai/aigis.git"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"commander": "^12.0.0",
|
|
32
|
+
"chalk": "^4.1.2",
|
|
33
|
+
"gray-matter": "^4.0.3"
|
|
34
|
+
}
|
|
35
|
+
}
|