@weavelogic/knowledge-graph-agent 0.11.5 → 0.11.6
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/dist/node_modules/@typescript-eslint/types/dist/index.js +1 -1
- package/dist/node_modules/@typescript-eslint/visitor-keys/dist/index.js +1 -1
- package/dist/sops/compliance-checker.d.ts.map +1 -1
- package/dist/sops/compliance-checker.js +151 -23
- package/dist/sops/compliance-checker.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as dist } from "../../../../_virtual/
|
|
1
|
+
import { __exports as dist } from "../../../../_virtual/index5.js";
|
|
2
2
|
import { __require as requireAstSpec } from "./generated/ast-spec.js";
|
|
3
3
|
import { __require as requireLib } from "./lib.js";
|
|
4
4
|
import { __require as requireParserOptions } from "./parser-options.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as dist } from "../../../../_virtual/
|
|
1
|
+
import { __exports as dist } from "../../../../_virtual/index6.js";
|
|
2
2
|
import { __require as requireGetKeys } from "./get-keys.js";
|
|
3
3
|
import { __require as requireVisitorKeys } from "./visitor-keys.js";
|
|
4
4
|
var hasRequiredDist;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compliance-checker.d.ts","sourceRoot":"","sources":["../../src/sops/compliance-checker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAGL,aAAa,EAGb,WAAW,EAEZ,MAAM,YAAY,CAAC;AAMpB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IAEpB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC;IAE3B,uCAAuC;IACvC,YAAY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c,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE5C,yBAAyB;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AA4CD;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAkFhC;AAyjBD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE,MAAe,GACxB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAQ/B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,MAAW,EACtB,UAAU,CAAC,EAAE,WAAW,EAAE,GACzB,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAe5D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, statSync, readFileSync } from "fs";
|
|
1
|
+
import { existsSync, readdirSync, statSync, readFileSync } from "fs";
|
|
2
2
|
import { basename, join, extname } from "path";
|
|
3
3
|
import { ComplianceStatus, IRBStatus, SOPCategory, SOPPriority } from "./types.js";
|
|
4
4
|
import { getSOPById, getSOPsByCategory, getAllSOPs } from "./registry.js";
|
|
@@ -110,8 +110,63 @@ function scanProjectArtifacts(projectRoot, docsPath, patterns) {
|
|
|
110
110
|
artifacts.set(category, found);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
const docsDir = join(projectRoot, docsPath);
|
|
114
|
+
if (existsSync(docsDir)) {
|
|
115
|
+
const allDocs = scanDocsRecursively(docsDir);
|
|
116
|
+
categorizeDocsByPath(allDocs, artifacts);
|
|
117
|
+
}
|
|
113
118
|
return artifacts;
|
|
114
119
|
}
|
|
120
|
+
function scanDocsRecursively(dir) {
|
|
121
|
+
const results = [];
|
|
122
|
+
try {
|
|
123
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
124
|
+
for (const entry of entries) {
|
|
125
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "analysis") {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const fullPath = join(dir, entry.name);
|
|
129
|
+
if (entry.isDirectory()) {
|
|
130
|
+
results.push(...scanDocsRecursively(fullPath));
|
|
131
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
132
|
+
results.push(fullPath);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
return results;
|
|
138
|
+
}
|
|
139
|
+
function categorizeDocsByPath(docs, artifacts) {
|
|
140
|
+
const pathMappings = {
|
|
141
|
+
"requirements": ["requirements", "specs", "specification", "features"],
|
|
142
|
+
"architecture": ["architecture", "design", "system", "components"],
|
|
143
|
+
"testing": ["testing", "test", "tests", "quality", "qa"],
|
|
144
|
+
"security": ["security", "auth", "authentication", "authorization"],
|
|
145
|
+
"ethics": ["ethics", "bias", "fairness", "responsible"],
|
|
146
|
+
"monitoring": ["monitoring", "observability", "metrics", "logging"],
|
|
147
|
+
"api-docs": ["api", "endpoints", "services", "rest", "graphql"],
|
|
148
|
+
"privacy": ["privacy", "data-protection", "gdpr", "compliance"],
|
|
149
|
+
"ci-cd": ["deployment", "ci-cd", "pipeline", "devops"],
|
|
150
|
+
"documentation": ["guides", "tutorials", "docs", "standards", "references"],
|
|
151
|
+
"validation": ["validation", "schema", "contracts"],
|
|
152
|
+
"config-management": ["config", "settings", "environment"],
|
|
153
|
+
"data-management": ["data", "database", "storage", "migrations"]
|
|
154
|
+
};
|
|
155
|
+
for (const docPath of docs) {
|
|
156
|
+
const lowerPath = docPath.toLowerCase();
|
|
157
|
+
for (const [category, keywords] of Object.entries(pathMappings)) {
|
|
158
|
+
if (keywords.some((kw) => lowerPath.includes(kw))) {
|
|
159
|
+
if (!artifacts.has(category)) {
|
|
160
|
+
artifacts.set(category, []);
|
|
161
|
+
}
|
|
162
|
+
const categoryDocs = artifacts.get(category);
|
|
163
|
+
if (!categoryDocs.includes(docPath)) {
|
|
164
|
+
categoryDocs.push(docPath);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
115
170
|
async function assessSOP(sop, projectRoot, docsPath, projectArtifacts, evidenceList, deepAnalysis, assessor) {
|
|
116
171
|
const requirementsMet = [];
|
|
117
172
|
const requirementsGaps = [];
|
|
@@ -214,26 +269,39 @@ function checkRequirement(requirement, projectRoot, docsPath, projectArtifacts,
|
|
|
214
269
|
}
|
|
215
270
|
}
|
|
216
271
|
function checkDocumentEvidence(requirement, projectRoot, docsPath, projectArtifacts, deepAnalysis) {
|
|
217
|
-
const docPatterns = [
|
|
272
|
+
const docPatterns = [
|
|
273
|
+
"readme",
|
|
274
|
+
"requirements",
|
|
275
|
+
"architecture",
|
|
276
|
+
"api-docs",
|
|
277
|
+
"documentation",
|
|
278
|
+
"testing",
|
|
279
|
+
"security",
|
|
280
|
+
"monitoring",
|
|
281
|
+
"validation",
|
|
282
|
+
"config-management",
|
|
283
|
+
"data-management",
|
|
284
|
+
"privacy",
|
|
285
|
+
"ci-cd",
|
|
286
|
+
"ethics"
|
|
287
|
+
];
|
|
218
288
|
for (const pattern of docPatterns) {
|
|
219
289
|
const artifacts = projectArtifacts.get(pattern);
|
|
220
290
|
if (artifacts && artifacts.length > 0) {
|
|
221
291
|
for (const artifact of artifacts) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
};
|
|
236
|
-
}
|
|
292
|
+
const contentMatch = checkContentForRequirement(artifact, requirement);
|
|
293
|
+
if (contentMatch) {
|
|
294
|
+
return {
|
|
295
|
+
met: true,
|
|
296
|
+
evidenceFound: {
|
|
297
|
+
requirementId: requirement.id,
|
|
298
|
+
filePath: artifact,
|
|
299
|
+
type: "document",
|
|
300
|
+
description: `Found documentation evidence in ${basename(artifact)}`,
|
|
301
|
+
confidence: deepAnalysis ? 0.9 : 0.75,
|
|
302
|
+
excerpt: contentMatch
|
|
303
|
+
}
|
|
304
|
+
};
|
|
237
305
|
}
|
|
238
306
|
}
|
|
239
307
|
}
|
|
@@ -282,29 +350,89 @@ function checkContentForRequirement(filePath, requirement) {
|
|
|
282
350
|
const content = readFileSync(filePath, "utf-8");
|
|
283
351
|
const lowerContent = content.toLowerCase();
|
|
284
352
|
const lowerDesc = requirement.description.toLowerCase();
|
|
285
|
-
const keywords = lowerDesc.split(/\s+/).filter((w) => w.length >
|
|
353
|
+
const keywords = lowerDesc.split(/\s+/).filter((w) => w.length > 3);
|
|
286
354
|
let matchCount = 0;
|
|
287
355
|
let matchedLine = "";
|
|
288
356
|
for (const keyword of keywords) {
|
|
289
357
|
if (lowerContent.includes(keyword)) {
|
|
290
358
|
matchCount++;
|
|
359
|
+
if (!matchedLine) {
|
|
360
|
+
const lines = content.split("\n");
|
|
361
|
+
for (const line of lines) {
|
|
362
|
+
if (line.toLowerCase().includes(keyword) && line.length < 200 && line.trim().length > 10) {
|
|
363
|
+
matchedLine = line.trim();
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (matchCount >= keywords.length * 0.2 && matchedLine) {
|
|
371
|
+
return matchedLine;
|
|
372
|
+
}
|
|
373
|
+
const evidenceKeywords = requirement.evidence || [];
|
|
374
|
+
for (const evidenceKey of evidenceKeywords) {
|
|
375
|
+
const evidenceLower = evidenceKey.toLowerCase();
|
|
376
|
+
if (lowerContent.includes(evidenceLower)) {
|
|
291
377
|
const lines = content.split("\n");
|
|
292
378
|
for (const line of lines) {
|
|
293
|
-
if (line.toLowerCase().includes(
|
|
294
|
-
|
|
295
|
-
break;
|
|
379
|
+
if (line.toLowerCase().includes(evidenceLower) && line.length < 200 && line.trim().length > 10) {
|
|
380
|
+
return line.trim();
|
|
296
381
|
}
|
|
297
382
|
}
|
|
298
383
|
}
|
|
299
384
|
}
|
|
300
|
-
|
|
301
|
-
|
|
385
|
+
const complianceTerms = getComplianceTermsForRequirement(requirement);
|
|
386
|
+
for (const term of complianceTerms) {
|
|
387
|
+
if (lowerContent.includes(term.toLowerCase())) {
|
|
388
|
+
const lines = content.split("\n");
|
|
389
|
+
for (const line of lines) {
|
|
390
|
+
if (line.toLowerCase().includes(term.toLowerCase()) && line.length < 200 && line.trim().length > 10) {
|
|
391
|
+
return line.trim();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
302
395
|
}
|
|
303
396
|
return null;
|
|
304
397
|
} catch {
|
|
305
398
|
return null;
|
|
306
399
|
}
|
|
307
400
|
}
|
|
401
|
+
function getComplianceTermsForRequirement(requirement) {
|
|
402
|
+
const reqId = requirement.id.toLowerCase();
|
|
403
|
+
const terms = [];
|
|
404
|
+
if (reqId.includes("req") || reqId.includes("spec")) {
|
|
405
|
+
terms.push("requirement", "specification", "functional", "non-functional", "acceptance criteria");
|
|
406
|
+
}
|
|
407
|
+
if (reqId.includes("test")) {
|
|
408
|
+
terms.push("test", "testing", "coverage", "unit test", "integration", "validation");
|
|
409
|
+
}
|
|
410
|
+
if (reqId.includes("arch") || reqId.includes("design")) {
|
|
411
|
+
terms.push("architecture", "design", "component", "system", "integration");
|
|
412
|
+
}
|
|
413
|
+
if (reqId.includes("sec")) {
|
|
414
|
+
terms.push("security", "authentication", "authorization", "encryption", "vulnerability");
|
|
415
|
+
}
|
|
416
|
+
if (reqId.includes("doc")) {
|
|
417
|
+
terms.push("documentation", "guide", "reference", "manual", "tutorial");
|
|
418
|
+
}
|
|
419
|
+
if (reqId.includes("deploy") || reqId.includes("ci")) {
|
|
420
|
+
terms.push("deployment", "pipeline", "continuous", "automation", "release");
|
|
421
|
+
}
|
|
422
|
+
if (reqId.includes("monitor") || reqId.includes("observe")) {
|
|
423
|
+
terms.push("monitoring", "metrics", "alerting", "logging", "observability");
|
|
424
|
+
}
|
|
425
|
+
if (reqId.includes("data") || reqId.includes("privacy")) {
|
|
426
|
+
terms.push("data", "privacy", "protection", "governance", "retention");
|
|
427
|
+
}
|
|
428
|
+
if (reqId.includes("risk")) {
|
|
429
|
+
terms.push("risk", "mitigation", "assessment", "impact", "likelihood");
|
|
430
|
+
}
|
|
431
|
+
if (reqId.includes("quality") || reqId.includes("qa")) {
|
|
432
|
+
terms.push("quality", "assurance", "standard", "review", "inspection");
|
|
433
|
+
}
|
|
434
|
+
return terms;
|
|
435
|
+
}
|
|
308
436
|
function categorizeArtifact(filePath) {
|
|
309
437
|
const ext = extname(filePath).toLowerCase();
|
|
310
438
|
const name = basename(filePath).toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compliance-checker.js","sources":["../../src/sops/compliance-checker.ts"],"sourcesContent":["/**\n * SOP Compliance Checker\n *\n * Checks project artifacts against AI-SDLC SOP requirements\n * and determines compliance status.\n *\n * @module sops/compliance-checker\n */\n\nimport { existsSync, readdirSync, readFileSync, statSync } from 'fs';\nimport { join, basename, extname } from 'path';\nimport {\n SOPDefinition,\n SOPRequirement,\n SOPAssessment,\n ComplianceStatus,\n IRBStatus,\n SOPCategory,\n SOPPriority,\n} from './types.js';\nimport { getSOPById, getSOPsByCategory, getAllSOPs } from './registry.js';\nimport { createLogger } from '../utils/logger.js';\n\nconst logger = createLogger('compliance-checker');\n\n/**\n * Compliance check options\n */\nexport interface ComplianceCheckOptions {\n /** Project root directory */\n projectRoot: string;\n\n /** Documentation path relative to project root */\n docsPath?: string;\n\n /** SOPs to check (default: all applicable) */\n sopIds?: string[];\n\n /** Categories to include */\n categories?: SOPCategory[];\n\n /** Whether to perform deep analysis */\n deepAnalysis?: boolean;\n\n /** Assessor name */\n assessor?: string;\n\n /** Custom artifact patterns */\n artifactPatterns?: Record<string, string[]>;\n}\n\n/**\n * Evidence item found during checking\n */\nexport interface EvidenceItem {\n /** Requirement ID this evidence supports */\n requirementId: string;\n\n /** File path where evidence was found */\n filePath: string;\n\n /** Type of evidence */\n type: 'document' | 'code' | 'test' | 'config' | 'artifact';\n\n /** Description of the evidence */\n description: string;\n\n /** Confidence score (0-1) */\n confidence: number;\n\n /** Relevant excerpt from file */\n excerpt?: string;\n}\n\n/**\n * Result of a compliance check\n */\nexport interface ComplianceCheckResult {\n /** Whether check completed successfully */\n success: boolean;\n\n /** Project name */\n projectName: string;\n\n /** Check timestamp */\n checkedAt: Date;\n\n /** Assessments by SOP */\n assessments: SOPAssessment[];\n\n /** Evidence found */\n evidence: EvidenceItem[];\n\n /** Overall compliance score */\n overallScore: number;\n\n /** Summary by category */\n categoryScores: Record<SOPCategory, number>;\n\n /** Errors encountered */\n errors: string[];\n}\n\n/**\n * Default artifact patterns for detecting compliance evidence\n */\nconst DEFAULT_ARTIFACT_PATTERNS: Record<string, string[]> = {\n // Documentation artifacts\n 'requirements': ['requirements.md', 'requirements.txt', 'REQUIREMENTS.md', 'specs/', 'requirements/'],\n 'architecture': ['ARCHITECTURE.md', 'architecture/', 'design/', 'ADR-*.md', 'adr/'],\n 'testing': ['tests/', '__tests__/', 'test/', '*.test.ts', '*.spec.ts', 'jest.config.*', 'vitest.config.*'],\n 'security': ['SECURITY.md', 'security/', '.snyk', 'security-policy.md'],\n 'ethics': ['ETHICS.md', 'ethics/', 'AI-ETHICS.md', 'bias-assessment.md'],\n 'changelog': ['CHANGELOG.md', 'HISTORY.md', 'releases/'],\n 'readme': ['README.md', 'README.txt', 'readme.md'],\n 'license': ['LICENSE', 'LICENSE.md', 'LICENSE.txt'],\n 'contributing': ['CONTRIBUTING.md', 'CONTRIBUTORS.md'],\n 'code-of-conduct': ['CODE_OF_CONDUCT.md'],\n 'ci-cd': ['.github/workflows/', '.gitlab-ci.yml', 'Jenkinsfile', '.circleci/'],\n 'docker': ['Dockerfile', 'docker-compose.yml', '.dockerignore'],\n 'monitoring': ['monitoring/', 'observability/', 'metrics/', 'prometheus.yml'],\n 'validation': ['validation/', 'schemas/', '*.schema.json', 'zod/', 'yup/'],\n 'config-management': ['.env.example', 'config/', 'settings/', '*.config.js', '*.config.ts'],\n 'data-management': ['data/', 'datasets/', 'migrations/', 'seeds/'],\n 'model-cards': ['MODEL_CARD.md', 'model-card.md', 'model-cards/'],\n 'api-docs': ['openapi.yaml', 'swagger.json', 'api/', 'API.md'],\n 'privacy': ['PRIVACY.md', 'privacy-policy.md', 'data-protection.md'],\n};\n\n/**\n * Keyword patterns for detecting compliance in content\n */\nconst COMPLIANCE_KEYWORDS: Record<string, string[]> = {\n 'requirements-definition': ['requirement', 'specification', 'user story', 'acceptance criteria', 'functional', 'non-functional'],\n 'risk-assessment': ['risk', 'mitigation', 'threat', 'vulnerability', 'impact', 'likelihood'],\n 'testing': ['test', 'coverage', 'unit test', 'integration test', 'e2e', 'regression'],\n 'security': ['authentication', 'authorization', 'encryption', 'secure', 'vulnerability', 'audit'],\n 'ethics': ['bias', 'fairness', 'ethical', 'responsible', 'transparency', 'accountability'],\n 'monitoring': ['monitor', 'alert', 'metric', 'observability', 'logging', 'tracing'],\n 'documentation': ['document', 'guide', 'manual', 'tutorial', 'reference'],\n 'validation': ['validate', 'verify', 'check', 'assert', 'schema', 'constraint'],\n 'privacy': ['privacy', 'gdpr', 'pii', 'data protection', 'consent', 'anonymization'],\n 'governance': ['governance', 'policy', 'procedure', 'standard', 'compliance', 'audit'],\n};\n\n/**\n * Check compliance for a project against AI-SDLC SOPs\n */\nexport async function checkCompliance(\n options: ComplianceCheckOptions\n): Promise<ComplianceCheckResult> {\n const {\n projectRoot,\n docsPath = 'docs',\n sopIds,\n categories,\n deepAnalysis = false,\n assessor = 'automated',\n artifactPatterns = DEFAULT_ARTIFACT_PATTERNS,\n } = options;\n\n logger.info('Starting compliance check', { projectRoot, docsPath });\n\n const result: ComplianceCheckResult = {\n success: true,\n projectName: basename(projectRoot),\n checkedAt: new Date(),\n assessments: [],\n evidence: [],\n overallScore: 0,\n categoryScores: {} as Record<SOPCategory, number>,\n errors: [],\n };\n\n try {\n // Determine which SOPs to check\n let sopsToCheck: SOPDefinition[] = [];\n\n if (sopIds && sopIds.length > 0) {\n // Check specific SOPs\n for (const id of sopIds) {\n const sop = getSOPById(id);\n if (sop) {\n sopsToCheck.push(sop);\n } else {\n result.errors.push(`SOP not found: ${id}`);\n }\n }\n } else if (categories && categories.length > 0) {\n // Check SOPs in specified categories\n for (const category of categories) {\n sopsToCheck.push(...getSOPsByCategory(category));\n }\n } else {\n // Check all SOPs\n sopsToCheck = getAllSOPs();\n }\n\n // Scan project for artifacts\n const projectArtifacts = scanProjectArtifacts(projectRoot, docsPath, artifactPatterns);\n logger.debug('Found project artifacts', { count: projectArtifacts.size });\n\n // Check each SOP\n for (const sop of sopsToCheck) {\n const assessment = await assessSOP(\n sop,\n projectRoot,\n docsPath,\n projectArtifacts,\n result.evidence,\n deepAnalysis,\n assessor\n );\n result.assessments.push(assessment);\n }\n\n // Calculate scores\n calculateScores(result);\n\n logger.info('Compliance check complete', {\n overallScore: result.overallScore,\n assessments: result.assessments.length,\n evidence: result.evidence.length,\n });\n\n } catch (error) {\n result.success = false;\n result.errors.push(String(error));\n logger.error(`Compliance check failed: ${String(error)}`);\n }\n\n return result;\n}\n\n/**\n * Scan project for artifacts that may indicate compliance\n */\nfunction scanProjectArtifacts(\n projectRoot: string,\n docsPath: string,\n patterns: Record<string, string[]>\n): Map<string, string[]> {\n const artifacts = new Map<string, string[]>();\n\n for (const [category, filePatterns] of Object.entries(patterns)) {\n const found: string[] = [];\n\n for (const pattern of filePatterns) {\n // Check in project root\n const rootPath = join(projectRoot, pattern);\n if (existsSync(rootPath)) {\n found.push(rootPath);\n }\n\n // Check in docs path\n const docsFullPath = join(projectRoot, docsPath, pattern);\n if (existsSync(docsFullPath)) {\n found.push(docsFullPath);\n }\n }\n\n if (found.length > 0) {\n artifacts.set(category, found);\n }\n }\n\n return artifacts;\n}\n\n/**\n * Assess a single SOP against project\n */\nasync function assessSOP(\n sop: SOPDefinition,\n projectRoot: string,\n docsPath: string,\n projectArtifacts: Map<string, string[]>,\n evidenceList: EvidenceItem[],\n deepAnalysis: boolean,\n assessor: string\n): Promise<SOPAssessment> {\n const requirementsMet: string[] = [];\n const requirementsGaps: string[] = [];\n const evidence: Record<string, string> = {};\n\n // Check each requirement\n for (const requirement of sop.requirements) {\n const { met, evidenceFound } = checkRequirement(\n requirement,\n projectRoot,\n docsPath,\n projectArtifacts,\n deepAnalysis\n );\n\n if (met) {\n requirementsMet.push(requirement.id);\n if (evidenceFound) {\n evidence[requirement.id] = evidenceFound.filePath;\n evidenceList.push(evidenceFound);\n }\n } else {\n requirementsGaps.push(requirement.id);\n }\n }\n\n // Calculate score\n const totalRequirements = sop.requirements.length;\n const mandatoryRequirements = sop.requirements.filter(r => r.mandatory);\n const mandatoryMet = mandatoryRequirements.filter(r => requirementsMet.includes(r.id));\n\n let score = 0;\n if (totalRequirements > 0) {\n // Weight mandatory requirements more heavily\n const mandatoryWeight = 0.7;\n const optionalWeight = 0.3;\n\n const mandatoryScore = mandatoryRequirements.length > 0\n ? (mandatoryMet.length / mandatoryRequirements.length) * 100\n : 100;\n\n const optionalRequirements = sop.requirements.filter(r => !r.mandatory);\n const optionalMet = optionalRequirements.filter(r => requirementsMet.includes(r.id));\n const optionalScore = optionalRequirements.length > 0\n ? (optionalMet.length / optionalRequirements.length) * 100\n : 100;\n\n score = Math.round(mandatoryScore * mandatoryWeight + optionalScore * optionalWeight);\n }\n\n // Determine status\n let status: ComplianceStatus;\n if (score >= 90) {\n status = ComplianceStatus.COMPLIANT;\n } else if (score >= 50) {\n status = ComplianceStatus.PARTIAL;\n } else if (score > 0) {\n status = ComplianceStatus.NON_COMPLIANT;\n } else {\n status = ComplianceStatus.PENDING;\n }\n\n // Determine IRB status\n let irbStatus: IRBStatus = IRBStatus.NOT_REQUIRED;\n if (sop.irbTypicallyRequired) {\n irbStatus = IRBStatus.PENDING;\n // Check for IRB approval artifacts\n const irbArtifacts = projectArtifacts.get('ethics') || [];\n if (irbArtifacts.length > 0) {\n irbStatus = IRBStatus.IN_REVIEW;\n }\n }\n\n return {\n sopId: sop.id,\n status,\n score,\n requirementsMet,\n requirementsGaps,\n evidence,\n irbStatus,\n assessedAt: new Date(),\n assessedBy: assessor,\n notes: `Automated assessment: ${requirementsMet.length}/${totalRequirements} requirements met`,\n };\n}\n\n/**\n * Check if a specific requirement is met\n */\nfunction checkRequirement(\n requirement: SOPRequirement,\n projectRoot: string,\n docsPath: string,\n projectArtifacts: Map<string, string[]>,\n deepAnalysis: boolean\n): { met: boolean; evidenceFound?: EvidenceItem } {\n // Check for artifacts that match the requirement\n for (const artifactType of requirement.artifacts || []) {\n const artifacts = projectArtifacts.get(artifactType);\n if (artifacts && artifacts.length > 0) {\n // Found matching artifact\n const evidenceItem: EvidenceItem = {\n requirementId: requirement.id,\n filePath: artifacts[0],\n type: categorizeArtifact(artifacts[0]),\n description: `Found ${artifactType} artifact: ${basename(artifacts[0])}`,\n confidence: 0.8,\n };\n\n // Deep analysis: check content for keywords\n if (deepAnalysis) {\n const contentMatch = checkContentForRequirement(artifacts[0], requirement);\n if (contentMatch) {\n evidenceItem.confidence = 0.95;\n evidenceItem.excerpt = contentMatch;\n }\n }\n\n return { met: true, evidenceFound: evidenceItem };\n }\n }\n\n // Check based on verification method\n switch (requirement.verification) {\n case 'document':\n return checkDocumentEvidence(requirement, projectRoot, docsPath, projectArtifacts, deepAnalysis);\n case 'test':\n return checkTestEvidence(requirement, projectRoot, projectArtifacts);\n case 'automated':\n return checkAutomatedEvidence(requirement, projectRoot, projectArtifacts);\n case 'review':\n case 'audit':\n // These require manual verification\n return { met: false };\n default:\n return { met: false };\n }\n}\n\n/**\n * Check for document-based evidence\n */\nfunction checkDocumentEvidence(\n requirement: SOPRequirement,\n projectRoot: string,\n docsPath: string,\n projectArtifacts: Map<string, string[]>,\n deepAnalysis: boolean\n): { met: boolean; evidenceFound?: EvidenceItem } {\n // Look for documentation files\n const docPatterns = ['readme', 'requirements', 'architecture', 'api-docs'];\n\n for (const pattern of docPatterns) {\n const artifacts = projectArtifacts.get(pattern);\n if (artifacts && artifacts.length > 0) {\n for (const artifact of artifacts) {\n if (deepAnalysis) {\n const contentMatch = checkContentForRequirement(artifact, requirement);\n if (contentMatch) {\n return {\n met: true,\n evidenceFound: {\n requirementId: requirement.id,\n filePath: artifact,\n type: 'document',\n description: `Found documentation evidence in ${basename(artifact)}`,\n confidence: 0.85,\n excerpt: contentMatch,\n },\n };\n }\n }\n }\n }\n }\n\n return { met: false };\n}\n\n/**\n * Check for test-based evidence\n */\nfunction checkTestEvidence(\n requirement: SOPRequirement,\n projectRoot: string,\n projectArtifacts: Map<string, string[]>\n): { met: boolean; evidenceFound?: EvidenceItem } {\n const testArtifacts = projectArtifacts.get('testing');\n\n if (testArtifacts && testArtifacts.length > 0) {\n return {\n met: true,\n evidenceFound: {\n requirementId: requirement.id,\n filePath: testArtifacts[0],\n type: 'test',\n description: `Test infrastructure found: ${basename(testArtifacts[0])}`,\n confidence: 0.7,\n },\n };\n }\n\n return { met: false };\n}\n\n/**\n * Check for automated/CI evidence\n */\nfunction checkAutomatedEvidence(\n requirement: SOPRequirement,\n projectRoot: string,\n projectArtifacts: Map<string, string[]>\n): { met: boolean; evidenceFound?: EvidenceItem } {\n const ciArtifacts = projectArtifacts.get('ci-cd');\n\n if (ciArtifacts && ciArtifacts.length > 0) {\n return {\n met: true,\n evidenceFound: {\n requirementId: requirement.id,\n filePath: ciArtifacts[0],\n type: 'config',\n description: `CI/CD configuration found: ${basename(ciArtifacts[0])}`,\n confidence: 0.75,\n },\n };\n }\n\n return { met: false };\n}\n\n/**\n * Check file content for requirement keywords\n */\nfunction checkContentForRequirement(\n filePath: string,\n requirement: SOPRequirement\n): string | null {\n try {\n const stat = statSync(filePath);\n if (stat.isDirectory()) return null;\n\n // Only check text files\n const ext = extname(filePath).toLowerCase();\n const textExtensions = ['.md', '.txt', '.ts', '.js', '.json', '.yaml', '.yml', '.html', '.rst'];\n if (!textExtensions.includes(ext)) return null;\n\n const content = readFileSync(filePath, 'utf-8');\n const lowerContent = content.toLowerCase();\n const lowerDesc = requirement.description.toLowerCase();\n\n // Check for keywords from requirement description\n const keywords = lowerDesc.split(/\\s+/).filter(w => w.length > 4);\n let matchCount = 0;\n let matchedLine = '';\n\n for (const keyword of keywords) {\n if (lowerContent.includes(keyword)) {\n matchCount++;\n // Find the line containing this keyword\n const lines = content.split('\\n');\n for (const line of lines) {\n if (line.toLowerCase().includes(keyword) && line.length < 200) {\n matchedLine = line.trim();\n break;\n }\n }\n }\n }\n\n // If at least 30% of keywords match, consider it evidence\n if (matchCount >= keywords.length * 0.3 && matchedLine) {\n return matchedLine;\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Categorize an artifact by its type\n */\nfunction categorizeArtifact(filePath: string): 'document' | 'code' | 'test' | 'config' | 'artifact' {\n const ext = extname(filePath).toLowerCase();\n const name = basename(filePath).toLowerCase();\n\n if (['.md', '.txt', '.rst', '.html'].includes(ext)) {\n return 'document';\n }\n if (['.ts', '.js', '.py', '.java', '.go', '.rs'].includes(ext)) {\n if (name.includes('test') || name.includes('spec')) {\n return 'test';\n }\n return 'code';\n }\n if (['.json', '.yaml', '.yml', '.toml', '.ini'].includes(ext)) {\n return 'config';\n }\n return 'artifact';\n}\n\n/**\n * Calculate overall scores from assessments\n */\nfunction calculateScores(result: ComplianceCheckResult): void {\n if (result.assessments.length === 0) {\n result.overallScore = 0;\n return;\n }\n\n // Calculate category scores\n const categoryTotals: Record<SOPCategory, { sum: number; count: number }> = {\n [SOPCategory.PROGRAM_MANAGEMENT]: { sum: 0, count: 0 },\n [SOPCategory.OPERATIONS]: { sum: 0, count: 0 },\n [SOPCategory.DEVELOPMENT]: { sum: 0, count: 0 },\n [SOPCategory.GOVERNANCE]: { sum: 0, count: 0 },\n [SOPCategory.QUALITY]: { sum: 0, count: 0 },\n };\n\n for (const assessment of result.assessments) {\n const sop = getSOPById(assessment.sopId);\n if (sop) {\n categoryTotals[sop.category].sum += assessment.score;\n categoryTotals[sop.category].count += 1;\n }\n }\n\n // Calculate category averages\n for (const category of Object.values(SOPCategory)) {\n const totals = categoryTotals[category];\n result.categoryScores[category] = totals.count > 0\n ? Math.round(totals.sum / totals.count)\n : 0;\n }\n\n // Calculate overall score (weighted by priority)\n let weightedSum = 0;\n let totalWeight = 0;\n\n for (const assessment of result.assessments) {\n const sop = getSOPById(assessment.sopId);\n if (sop) {\n const weight = getPriorityWeight(sop.priority);\n weightedSum += assessment.score * weight;\n totalWeight += weight;\n }\n }\n\n result.overallScore = totalWeight > 0\n ? Math.round(weightedSum / totalWeight)\n : 0;\n}\n\n/**\n * Get weight for priority level\n */\nfunction getPriorityWeight(priority: SOPPriority): number {\n switch (priority) {\n case SOPPriority.CRITICAL:\n return 4;\n case SOPPriority.HIGH:\n return 3;\n case SOPPriority.MEDIUM:\n return 2;\n case SOPPriority.LOW:\n return 1;\n default:\n return 1;\n }\n}\n\n/**\n * Quick check for a specific SOP\n */\nexport async function checkSOPCompliance(\n sopId: string,\n projectRoot: string,\n docsPath: string = 'docs'\n): Promise<SOPAssessment | null> {\n const result = await checkCompliance({\n projectRoot,\n docsPath,\n sopIds: [sopId],\n });\n\n return result.assessments[0] || null;\n}\n\n/**\n * Check if project meets minimum compliance threshold\n */\nexport async function meetsMinimumCompliance(\n projectRoot: string,\n threshold: number = 50,\n categories?: SOPCategory[]\n): Promise<{ meets: boolean; score: number; gaps: string[] }> {\n const result = await checkCompliance({\n projectRoot,\n categories,\n });\n\n const gaps = result.assessments\n .filter(a => a.score < threshold)\n .map(a => a.sopId);\n\n return {\n meets: result.overallScore >= threshold,\n score: result.overallScore,\n gaps,\n };\n}\n"],"names":[],"mappings":";;;;;AAuBA,MAAM,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gBAAgB;AAAA,IACnC;AAAA,IACA;AAAA,IACA,QAAQ,CAAC,KAAK;AAAA,EAAA,CACf;AAED,SAAO,OAAO,YAAY,CAAC,KAAK;AAClC;AAKA,eAAsB,uBACpB,aACA,YAAoB,IACpB,YAC4D;AAC5D,QAAM,SAAS,MAAM,gBAAgB;AAAA,IACnC;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,OAAO,OAAO,YACjB,OAAO,CAAA,MAAK,EAAE,QAAQ,SAAS,EAC/B,IAAI,CAAA,MAAK,EAAE,KAAK;AAEnB,SAAO;AAAA,IACL,OAAO,OAAO,gBAAgB;AAAA,IAC9B,OAAO,OAAO;AAAA,IACd;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"compliance-checker.js","sources":["../../src/sops/compliance-checker.ts"],"sourcesContent":["/**\n * SOP Compliance Checker\n *\n * Checks project artifacts against AI-SDLC SOP requirements\n * and determines compliance status.\n *\n * @module sops/compliance-checker\n */\n\nimport { existsSync, readdirSync, readFileSync, statSync } from 'fs';\nimport { join, basename, extname } from 'path';\nimport {\n SOPDefinition,\n SOPRequirement,\n SOPAssessment,\n ComplianceStatus,\n IRBStatus,\n SOPCategory,\n SOPPriority,\n} from './types.js';\nimport { getSOPById, getSOPsByCategory, getAllSOPs } from './registry.js';\nimport { createLogger } from '../utils/logger.js';\n\nconst logger = createLogger('compliance-checker');\n\n/**\n * Compliance check options\n */\nexport interface ComplianceCheckOptions {\n /** Project root directory */\n projectRoot: string;\n\n /** Documentation path relative to project root */\n docsPath?: string;\n\n /** SOPs to check (default: all applicable) */\n sopIds?: string[];\n\n /** Categories to include */\n categories?: SOPCategory[];\n\n /** Whether to perform deep analysis */\n deepAnalysis?: boolean;\n\n /** Assessor name */\n assessor?: string;\n\n /** Custom artifact patterns */\n artifactPatterns?: Record<string, string[]>;\n}\n\n/**\n * Evidence item found during checking\n */\nexport interface EvidenceItem {\n /** Requirement ID this evidence supports */\n requirementId: string;\n\n /** File path where evidence was found */\n filePath: string;\n\n /** Type of evidence */\n type: 'document' | 'code' | 'test' | 'config' | 'artifact';\n\n /** Description of the evidence */\n description: string;\n\n /** Confidence score (0-1) */\n confidence: number;\n\n /** Relevant excerpt from file */\n excerpt?: string;\n}\n\n/**\n * Result of a compliance check\n */\nexport interface ComplianceCheckResult {\n /** Whether check completed successfully */\n success: boolean;\n\n /** Project name */\n projectName: string;\n\n /** Check timestamp */\n checkedAt: Date;\n\n /** Assessments by SOP */\n assessments: SOPAssessment[];\n\n /** Evidence found */\n evidence: EvidenceItem[];\n\n /** Overall compliance score */\n overallScore: number;\n\n /** Summary by category */\n categoryScores: Record<SOPCategory, number>;\n\n /** Errors encountered */\n errors: string[];\n}\n\n/**\n * Default artifact patterns for detecting compliance evidence\n */\nconst DEFAULT_ARTIFACT_PATTERNS: Record<string, string[]> = {\n // Documentation artifacts\n 'requirements': ['requirements.md', 'requirements.txt', 'REQUIREMENTS.md', 'specs/', 'requirements/'],\n 'architecture': ['ARCHITECTURE.md', 'architecture/', 'design/', 'ADR-*.md', 'adr/'],\n 'testing': ['tests/', '__tests__/', 'test/', '*.test.ts', '*.spec.ts', 'jest.config.*', 'vitest.config.*'],\n 'security': ['SECURITY.md', 'security/', '.snyk', 'security-policy.md'],\n 'ethics': ['ETHICS.md', 'ethics/', 'AI-ETHICS.md', 'bias-assessment.md'],\n 'changelog': ['CHANGELOG.md', 'HISTORY.md', 'releases/'],\n 'readme': ['README.md', 'README.txt', 'readme.md'],\n 'license': ['LICENSE', 'LICENSE.md', 'LICENSE.txt'],\n 'contributing': ['CONTRIBUTING.md', 'CONTRIBUTORS.md'],\n 'code-of-conduct': ['CODE_OF_CONDUCT.md'],\n 'ci-cd': ['.github/workflows/', '.gitlab-ci.yml', 'Jenkinsfile', '.circleci/'],\n 'docker': ['Dockerfile', 'docker-compose.yml', '.dockerignore'],\n 'monitoring': ['monitoring/', 'observability/', 'metrics/', 'prometheus.yml'],\n 'validation': ['validation/', 'schemas/', '*.schema.json', 'zod/', 'yup/'],\n 'config-management': ['.env.example', 'config/', 'settings/', '*.config.js', '*.config.ts'],\n 'data-management': ['data/', 'datasets/', 'migrations/', 'seeds/'],\n 'model-cards': ['MODEL_CARD.md', 'model-card.md', 'model-cards/'],\n 'api-docs': ['openapi.yaml', 'swagger.json', 'api/', 'API.md'],\n 'privacy': ['PRIVACY.md', 'privacy-policy.md', 'data-protection.md'],\n};\n\n/**\n * Keyword patterns for detecting compliance in content\n */\nconst COMPLIANCE_KEYWORDS: Record<string, string[]> = {\n 'requirements-definition': ['requirement', 'specification', 'user story', 'acceptance criteria', 'functional', 'non-functional'],\n 'risk-assessment': ['risk', 'mitigation', 'threat', 'vulnerability', 'impact', 'likelihood'],\n 'testing': ['test', 'coverage', 'unit test', 'integration test', 'e2e', 'regression'],\n 'security': ['authentication', 'authorization', 'encryption', 'secure', 'vulnerability', 'audit'],\n 'ethics': ['bias', 'fairness', 'ethical', 'responsible', 'transparency', 'accountability'],\n 'monitoring': ['monitor', 'alert', 'metric', 'observability', 'logging', 'tracing'],\n 'documentation': ['document', 'guide', 'manual', 'tutorial', 'reference'],\n 'validation': ['validate', 'verify', 'check', 'assert', 'schema', 'constraint'],\n 'privacy': ['privacy', 'gdpr', 'pii', 'data protection', 'consent', 'anonymization'],\n 'governance': ['governance', 'policy', 'procedure', 'standard', 'compliance', 'audit'],\n};\n\n/**\n * Check compliance for a project against AI-SDLC SOPs\n */\nexport async function checkCompliance(\n options: ComplianceCheckOptions\n): Promise<ComplianceCheckResult> {\n const {\n projectRoot,\n docsPath = 'docs',\n sopIds,\n categories,\n deepAnalysis = false,\n assessor = 'automated',\n artifactPatterns = DEFAULT_ARTIFACT_PATTERNS,\n } = options;\n\n logger.info('Starting compliance check', { projectRoot, docsPath });\n\n const result: ComplianceCheckResult = {\n success: true,\n projectName: basename(projectRoot),\n checkedAt: new Date(),\n assessments: [],\n evidence: [],\n overallScore: 0,\n categoryScores: {} as Record<SOPCategory, number>,\n errors: [],\n };\n\n try {\n // Determine which SOPs to check\n let sopsToCheck: SOPDefinition[] = [];\n\n if (sopIds && sopIds.length > 0) {\n // Check specific SOPs\n for (const id of sopIds) {\n const sop = getSOPById(id);\n if (sop) {\n sopsToCheck.push(sop);\n } else {\n result.errors.push(`SOP not found: ${id}`);\n }\n }\n } else if (categories && categories.length > 0) {\n // Check SOPs in specified categories\n for (const category of categories) {\n sopsToCheck.push(...getSOPsByCategory(category));\n }\n } else {\n // Check all SOPs\n sopsToCheck = getAllSOPs();\n }\n\n // Scan project for artifacts\n const projectArtifacts = scanProjectArtifacts(projectRoot, docsPath, artifactPatterns);\n logger.debug('Found project artifacts', { count: projectArtifacts.size });\n\n // Check each SOP\n for (const sop of sopsToCheck) {\n const assessment = await assessSOP(\n sop,\n projectRoot,\n docsPath,\n projectArtifacts,\n result.evidence,\n deepAnalysis,\n assessor\n );\n result.assessments.push(assessment);\n }\n\n // Calculate scores\n calculateScores(result);\n\n logger.info('Compliance check complete', {\n overallScore: result.overallScore,\n assessments: result.assessments.length,\n evidence: result.evidence.length,\n });\n\n } catch (error) {\n result.success = false;\n result.errors.push(String(error));\n logger.error(`Compliance check failed: ${String(error)}`);\n }\n\n return result;\n}\n\n/**\n * Scan project for artifacts that may indicate compliance\n */\nfunction scanProjectArtifacts(\n projectRoot: string,\n docsPath: string,\n patterns: Record<string, string[]>\n): Map<string, string[]> {\n const artifacts = new Map<string, string[]>();\n\n for (const [category, filePatterns] of Object.entries(patterns)) {\n const found: string[] = [];\n\n for (const pattern of filePatterns) {\n // Check in project root\n const rootPath = join(projectRoot, pattern);\n if (existsSync(rootPath)) {\n found.push(rootPath);\n }\n\n // Check in docs path\n const docsFullPath = join(projectRoot, docsPath, pattern);\n if (existsSync(docsFullPath)) {\n found.push(docsFullPath);\n }\n }\n\n if (found.length > 0) {\n artifacts.set(category, found);\n }\n }\n\n // Additionally, scan all markdown files in docs recursively\n // and categorize them based on path and content\n const docsDir = join(projectRoot, docsPath);\n if (existsSync(docsDir)) {\n const allDocs = scanDocsRecursively(docsDir);\n categorizeDocsByPath(allDocs, artifacts);\n }\n\n return artifacts;\n}\n\n/**\n * Recursively scan all markdown files in a directory\n */\nfunction scanDocsRecursively(dir: string): string[] {\n const results: string[] = [];\n\n try {\n const entries = readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'analysis') {\n continue;\n }\n\n const fullPath = join(dir, entry.name);\n if (entry.isDirectory()) {\n results.push(...scanDocsRecursively(fullPath));\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n results.push(fullPath);\n }\n }\n } catch {\n // Ignore errors\n }\n\n return results;\n}\n\n/**\n * Categorize documents by their path structure\n */\nfunction categorizeDocsByPath(docs: string[], artifacts: Map<string, string[]>): void {\n const pathMappings: Record<string, string[]> = {\n 'requirements': ['requirements', 'specs', 'specification', 'features'],\n 'architecture': ['architecture', 'design', 'system', 'components'],\n 'testing': ['testing', 'test', 'tests', 'quality', 'qa'],\n 'security': ['security', 'auth', 'authentication', 'authorization'],\n 'ethics': ['ethics', 'bias', 'fairness', 'responsible'],\n 'monitoring': ['monitoring', 'observability', 'metrics', 'logging'],\n 'api-docs': ['api', 'endpoints', 'services', 'rest', 'graphql'],\n 'privacy': ['privacy', 'data-protection', 'gdpr', 'compliance'],\n 'ci-cd': ['deployment', 'ci-cd', 'pipeline', 'devops'],\n 'documentation': ['guides', 'tutorials', 'docs', 'standards', 'references'],\n 'validation': ['validation', 'schema', 'contracts'],\n 'config-management': ['config', 'settings', 'environment'],\n 'data-management': ['data', 'database', 'storage', 'migrations'],\n };\n\n for (const docPath of docs) {\n const lowerPath = docPath.toLowerCase();\n\n for (const [category, keywords] of Object.entries(pathMappings)) {\n if (keywords.some(kw => lowerPath.includes(kw))) {\n if (!artifacts.has(category)) {\n artifacts.set(category, []);\n }\n const categoryDocs = artifacts.get(category)!;\n if (!categoryDocs.includes(docPath)) {\n categoryDocs.push(docPath);\n }\n }\n }\n }\n}\n\n/**\n * Assess a single SOP against project\n */\nasync function assessSOP(\n sop: SOPDefinition,\n projectRoot: string,\n docsPath: string,\n projectArtifacts: Map<string, string[]>,\n evidenceList: EvidenceItem[],\n deepAnalysis: boolean,\n assessor: string\n): Promise<SOPAssessment> {\n const requirementsMet: string[] = [];\n const requirementsGaps: string[] = [];\n const evidence: Record<string, string> = {};\n\n // Check each requirement\n for (const requirement of sop.requirements) {\n const { met, evidenceFound } = checkRequirement(\n requirement,\n projectRoot,\n docsPath,\n projectArtifacts,\n deepAnalysis\n );\n\n if (met) {\n requirementsMet.push(requirement.id);\n if (evidenceFound) {\n evidence[requirement.id] = evidenceFound.filePath;\n evidenceList.push(evidenceFound);\n }\n } else {\n requirementsGaps.push(requirement.id);\n }\n }\n\n // Calculate score\n const totalRequirements = sop.requirements.length;\n const mandatoryRequirements = sop.requirements.filter(r => r.mandatory);\n const mandatoryMet = mandatoryRequirements.filter(r => requirementsMet.includes(r.id));\n\n let score = 0;\n if (totalRequirements > 0) {\n // Weight mandatory requirements more heavily\n const mandatoryWeight = 0.7;\n const optionalWeight = 0.3;\n\n const mandatoryScore = mandatoryRequirements.length > 0\n ? (mandatoryMet.length / mandatoryRequirements.length) * 100\n : 100;\n\n const optionalRequirements = sop.requirements.filter(r => !r.mandatory);\n const optionalMet = optionalRequirements.filter(r => requirementsMet.includes(r.id));\n const optionalScore = optionalRequirements.length > 0\n ? (optionalMet.length / optionalRequirements.length) * 100\n : 100;\n\n score = Math.round(mandatoryScore * mandatoryWeight + optionalScore * optionalWeight);\n }\n\n // Determine status\n let status: ComplianceStatus;\n if (score >= 90) {\n status = ComplianceStatus.COMPLIANT;\n } else if (score >= 50) {\n status = ComplianceStatus.PARTIAL;\n } else if (score > 0) {\n status = ComplianceStatus.NON_COMPLIANT;\n } else {\n status = ComplianceStatus.PENDING;\n }\n\n // Determine IRB status\n let irbStatus: IRBStatus = IRBStatus.NOT_REQUIRED;\n if (sop.irbTypicallyRequired) {\n irbStatus = IRBStatus.PENDING;\n // Check for IRB approval artifacts\n const irbArtifacts = projectArtifacts.get('ethics') || [];\n if (irbArtifacts.length > 0) {\n irbStatus = IRBStatus.IN_REVIEW;\n }\n }\n\n return {\n sopId: sop.id,\n status,\n score,\n requirementsMet,\n requirementsGaps,\n evidence,\n irbStatus,\n assessedAt: new Date(),\n assessedBy: assessor,\n notes: `Automated assessment: ${requirementsMet.length}/${totalRequirements} requirements met`,\n };\n}\n\n/**\n * Check if a specific requirement is met\n */\nfunction checkRequirement(\n requirement: SOPRequirement,\n projectRoot: string,\n docsPath: string,\n projectArtifacts: Map<string, string[]>,\n deepAnalysis: boolean\n): { met: boolean; evidenceFound?: EvidenceItem } {\n // Check for artifacts that match the requirement\n for (const artifactType of requirement.artifacts || []) {\n const artifacts = projectArtifacts.get(artifactType);\n if (artifacts && artifacts.length > 0) {\n // Found matching artifact\n const evidenceItem: EvidenceItem = {\n requirementId: requirement.id,\n filePath: artifacts[0],\n type: categorizeArtifact(artifacts[0]),\n description: `Found ${artifactType} artifact: ${basename(artifacts[0])}`,\n confidence: 0.8,\n };\n\n // Deep analysis: check content for keywords\n if (deepAnalysis) {\n const contentMatch = checkContentForRequirement(artifacts[0], requirement);\n if (contentMatch) {\n evidenceItem.confidence = 0.95;\n evidenceItem.excerpt = contentMatch;\n }\n }\n\n return { met: true, evidenceFound: evidenceItem };\n }\n }\n\n // Check based on verification method\n switch (requirement.verification) {\n case 'document':\n return checkDocumentEvidence(requirement, projectRoot, docsPath, projectArtifacts, deepAnalysis);\n case 'test':\n return checkTestEvidence(requirement, projectRoot, projectArtifacts);\n case 'automated':\n return checkAutomatedEvidence(requirement, projectRoot, projectArtifacts);\n case 'review':\n case 'audit':\n // These require manual verification\n return { met: false };\n default:\n return { met: false };\n }\n}\n\n/**\n * Check for document-based evidence\n */\nfunction checkDocumentEvidence(\n requirement: SOPRequirement,\n projectRoot: string,\n docsPath: string,\n projectArtifacts: Map<string, string[]>,\n deepAnalysis: boolean\n): { met: boolean; evidenceFound?: EvidenceItem } {\n // Look for documentation files in all relevant categories\n const docPatterns = [\n 'readme', 'requirements', 'architecture', 'api-docs',\n 'documentation', 'testing', 'security', 'monitoring',\n 'validation', 'config-management', 'data-management',\n 'privacy', 'ci-cd', 'ethics'\n ];\n\n for (const pattern of docPatterns) {\n const artifacts = projectArtifacts.get(pattern);\n if (artifacts && artifacts.length > 0) {\n for (const artifact of artifacts) {\n // Always check content for matches (not just with deepAnalysis)\n const contentMatch = checkContentForRequirement(artifact, requirement);\n if (contentMatch) {\n return {\n met: true,\n evidenceFound: {\n requirementId: requirement.id,\n filePath: artifact,\n type: 'document',\n description: `Found documentation evidence in ${basename(artifact)}`,\n confidence: deepAnalysis ? 0.90 : 0.75,\n excerpt: contentMatch,\n },\n };\n }\n }\n }\n }\n\n return { met: false };\n}\n\n/**\n * Check for test-based evidence\n */\nfunction checkTestEvidence(\n requirement: SOPRequirement,\n projectRoot: string,\n projectArtifacts: Map<string, string[]>\n): { met: boolean; evidenceFound?: EvidenceItem } {\n const testArtifacts = projectArtifacts.get('testing');\n\n if (testArtifacts && testArtifacts.length > 0) {\n return {\n met: true,\n evidenceFound: {\n requirementId: requirement.id,\n filePath: testArtifacts[0],\n type: 'test',\n description: `Test infrastructure found: ${basename(testArtifacts[0])}`,\n confidence: 0.7,\n },\n };\n }\n\n return { met: false };\n}\n\n/**\n * Check for automated/CI evidence\n */\nfunction checkAutomatedEvidence(\n requirement: SOPRequirement,\n projectRoot: string,\n projectArtifacts: Map<string, string[]>\n): { met: boolean; evidenceFound?: EvidenceItem } {\n const ciArtifacts = projectArtifacts.get('ci-cd');\n\n if (ciArtifacts && ciArtifacts.length > 0) {\n return {\n met: true,\n evidenceFound: {\n requirementId: requirement.id,\n filePath: ciArtifacts[0],\n type: 'config',\n description: `CI/CD configuration found: ${basename(ciArtifacts[0])}`,\n confidence: 0.75,\n },\n };\n }\n\n return { met: false };\n}\n\n/**\n * Check file content for requirement keywords\n */\nfunction checkContentForRequirement(\n filePath: string,\n requirement: SOPRequirement\n): string | null {\n try {\n const stat = statSync(filePath);\n if (stat.isDirectory()) return null;\n\n // Only check text files\n const ext = extname(filePath).toLowerCase();\n const textExtensions = ['.md', '.txt', '.ts', '.js', '.json', '.yaml', '.yml', '.html', '.rst'];\n if (!textExtensions.includes(ext)) return null;\n\n const content = readFileSync(filePath, 'utf-8');\n const lowerContent = content.toLowerCase();\n const lowerDesc = requirement.description.toLowerCase();\n\n // Check for keywords from requirement description\n const keywords = lowerDesc.split(/\\s+/).filter(w => w.length > 3);\n let matchCount = 0;\n let matchedLine = '';\n\n for (const keyword of keywords) {\n if (lowerContent.includes(keyword)) {\n matchCount++;\n // Find the line containing this keyword\n if (!matchedLine) {\n const lines = content.split('\\n');\n for (const line of lines) {\n if (line.toLowerCase().includes(keyword) && line.length < 200 && line.trim().length > 10) {\n matchedLine = line.trim();\n break;\n }\n }\n }\n }\n }\n\n // If at least 20% of keywords match, consider it evidence (lowered threshold)\n if (matchCount >= keywords.length * 0.2 && matchedLine) {\n return matchedLine;\n }\n\n // Also check for SOP-related keywords based on the requirement's evidence list\n const evidenceKeywords = requirement.evidence || [];\n for (const evidenceKey of evidenceKeywords) {\n const evidenceLower = evidenceKey.toLowerCase();\n if (lowerContent.includes(evidenceLower)) {\n const lines = content.split('\\n');\n for (const line of lines) {\n if (line.toLowerCase().includes(evidenceLower) && line.length < 200 && line.trim().length > 10) {\n return line.trim();\n }\n }\n }\n }\n\n // Check for compliance-related keywords in general\n const complianceTerms = getComplianceTermsForRequirement(requirement);\n for (const term of complianceTerms) {\n if (lowerContent.includes(term.toLowerCase())) {\n const lines = content.split('\\n');\n for (const line of lines) {\n if (line.toLowerCase().includes(term.toLowerCase()) && line.length < 200 && line.trim().length > 10) {\n return line.trim();\n }\n }\n }\n }\n\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Get compliance-related terms for a requirement based on its ID\n */\nfunction getComplianceTermsForRequirement(requirement: SOPRequirement): string[] {\n const reqId = requirement.id.toLowerCase();\n const terms: string[] = [];\n\n // Map requirement IDs to relevant terms\n if (reqId.includes('req') || reqId.includes('spec')) {\n terms.push('requirement', 'specification', 'functional', 'non-functional', 'acceptance criteria');\n }\n if (reqId.includes('test')) {\n terms.push('test', 'testing', 'coverage', 'unit test', 'integration', 'validation');\n }\n if (reqId.includes('arch') || reqId.includes('design')) {\n terms.push('architecture', 'design', 'component', 'system', 'integration');\n }\n if (reqId.includes('sec')) {\n terms.push('security', 'authentication', 'authorization', 'encryption', 'vulnerability');\n }\n if (reqId.includes('doc')) {\n terms.push('documentation', 'guide', 'reference', 'manual', 'tutorial');\n }\n if (reqId.includes('deploy') || reqId.includes('ci')) {\n terms.push('deployment', 'pipeline', 'continuous', 'automation', 'release');\n }\n if (reqId.includes('monitor') || reqId.includes('observe')) {\n terms.push('monitoring', 'metrics', 'alerting', 'logging', 'observability');\n }\n if (reqId.includes('data') || reqId.includes('privacy')) {\n terms.push('data', 'privacy', 'protection', 'governance', 'retention');\n }\n if (reqId.includes('risk')) {\n terms.push('risk', 'mitigation', 'assessment', 'impact', 'likelihood');\n }\n if (reqId.includes('quality') || reqId.includes('qa')) {\n terms.push('quality', 'assurance', 'standard', 'review', 'inspection');\n }\n\n return terms;\n}\n\n/**\n * Categorize an artifact by its type\n */\nfunction categorizeArtifact(filePath: string): 'document' | 'code' | 'test' | 'config' | 'artifact' {\n const ext = extname(filePath).toLowerCase();\n const name = basename(filePath).toLowerCase();\n\n if (['.md', '.txt', '.rst', '.html'].includes(ext)) {\n return 'document';\n }\n if (['.ts', '.js', '.py', '.java', '.go', '.rs'].includes(ext)) {\n if (name.includes('test') || name.includes('spec')) {\n return 'test';\n }\n return 'code';\n }\n if (['.json', '.yaml', '.yml', '.toml', '.ini'].includes(ext)) {\n return 'config';\n }\n return 'artifact';\n}\n\n/**\n * Calculate overall scores from assessments\n */\nfunction calculateScores(result: ComplianceCheckResult): void {\n if (result.assessments.length === 0) {\n result.overallScore = 0;\n return;\n }\n\n // Calculate category scores\n const categoryTotals: Record<SOPCategory, { sum: number; count: number }> = {\n [SOPCategory.PROGRAM_MANAGEMENT]: { sum: 0, count: 0 },\n [SOPCategory.OPERATIONS]: { sum: 0, count: 0 },\n [SOPCategory.DEVELOPMENT]: { sum: 0, count: 0 },\n [SOPCategory.GOVERNANCE]: { sum: 0, count: 0 },\n [SOPCategory.QUALITY]: { sum: 0, count: 0 },\n };\n\n for (const assessment of result.assessments) {\n const sop = getSOPById(assessment.sopId);\n if (sop) {\n categoryTotals[sop.category].sum += assessment.score;\n categoryTotals[sop.category].count += 1;\n }\n }\n\n // Calculate category averages\n for (const category of Object.values(SOPCategory)) {\n const totals = categoryTotals[category];\n result.categoryScores[category] = totals.count > 0\n ? Math.round(totals.sum / totals.count)\n : 0;\n }\n\n // Calculate overall score (weighted by priority)\n let weightedSum = 0;\n let totalWeight = 0;\n\n for (const assessment of result.assessments) {\n const sop = getSOPById(assessment.sopId);\n if (sop) {\n const weight = getPriorityWeight(sop.priority);\n weightedSum += assessment.score * weight;\n totalWeight += weight;\n }\n }\n\n result.overallScore = totalWeight > 0\n ? Math.round(weightedSum / totalWeight)\n : 0;\n}\n\n/**\n * Get weight for priority level\n */\nfunction getPriorityWeight(priority: SOPPriority): number {\n switch (priority) {\n case SOPPriority.CRITICAL:\n return 4;\n case SOPPriority.HIGH:\n return 3;\n case SOPPriority.MEDIUM:\n return 2;\n case SOPPriority.LOW:\n return 1;\n default:\n return 1;\n }\n}\n\n/**\n * Quick check for a specific SOP\n */\nexport async function checkSOPCompliance(\n sopId: string,\n projectRoot: string,\n docsPath: string = 'docs'\n): Promise<SOPAssessment | null> {\n const result = await checkCompliance({\n projectRoot,\n docsPath,\n sopIds: [sopId],\n });\n\n return result.assessments[0] || null;\n}\n\n/**\n * Check if project meets minimum compliance threshold\n */\nexport async function meetsMinimumCompliance(\n projectRoot: string,\n threshold: number = 50,\n categories?: SOPCategory[]\n): Promise<{ meets: boolean; score: number; gaps: string[] }> {\n const result = await checkCompliance({\n projectRoot,\n categories,\n });\n\n const gaps = result.assessments\n .filter(a => a.score < threshold)\n .map(a => a.sopId);\n\n return {\n meets: result.overallScore >= threshold,\n score: result.overallScore,\n gaps,\n };\n}\n"],"names":[],"mappings":";;;;;AAuBA,MAAM,SAAS,aAAa,oBAAoB;AAmFhD,MAAM,4BAAsD;AAAA;AAAA,EAE1D,gBAAgB,CAAC,mBAAmB,oBAAoB,mBAAmB,UAAU,eAAe;AAAA,EACpG,gBAAgB,CAAC,mBAAmB,iBAAiB,WAAW,YAAY,MAAM;AAAA,EAClF,WAAW,CAAC,UAAU,cAAc,SAAS,aAAa,aAAa,iBAAiB,iBAAiB;AAAA,EACzG,YAAY,CAAC,eAAe,aAAa,SAAS,oBAAoB;AAAA,EACtE,UAAU,CAAC,aAAa,WAAW,gBAAgB,oBAAoB;AAAA,EACvE,aAAa,CAAC,gBAAgB,cAAc,WAAW;AAAA,EACvD,UAAU,CAAC,aAAa,cAAc,WAAW;AAAA,EACjD,WAAW,CAAC,WAAW,cAAc,aAAa;AAAA,EAClD,gBAAgB,CAAC,mBAAmB,iBAAiB;AAAA,EACrD,mBAAmB,CAAC,oBAAoB;AAAA,EACxC,SAAS,CAAC,sBAAsB,kBAAkB,eAAe,YAAY;AAAA,EAC7E,UAAU,CAAC,cAAc,sBAAsB,eAAe;AAAA,EAC9D,cAAc,CAAC,eAAe,kBAAkB,YAAY,gBAAgB;AAAA,EAC5E,cAAc,CAAC,eAAe,YAAY,iBAAiB,QAAQ,MAAM;AAAA,EACzE,qBAAqB,CAAC,gBAAgB,WAAW,aAAa,eAAe,aAAa;AAAA,EAC1F,mBAAmB,CAAC,SAAS,aAAa,eAAe,QAAQ;AAAA,EACjE,eAAe,CAAC,iBAAiB,iBAAiB,cAAc;AAAA,EAChE,YAAY,CAAC,gBAAgB,gBAAgB,QAAQ,QAAQ;AAAA,EAC7D,WAAW,CAAC,cAAc,qBAAqB,oBAAoB;AACrE;AAqBA,eAAsB,gBACpB,SACgC;AAChC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;AACP,YAAM,SAAS,kBAAkB,IAAI,QAAQ;AAC7C,qBAAe,WAAW,QAAQ;AAClC,qBAAe;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,eAAe,cAAc,IAChC,KAAK,MAAM,cAAc,WAAW,IACpC;AACN;AAKA,SAAS,kBAAkB,UAA+B;AACxD,UAAQ,UAAA;AAAA,IACN,KAAK,YAAY;AACf,aAAO;AAAA,IACT,KAAK,YAAY;AACf,aAAO;AAAA,IACT,KAAK,YAAY;AACf,aAAO;AAAA,IACT,KAAK,YAAY;AACf,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EAAA;AAEb;AAKA,eAAsB,mBACpB,OACA,aACA,WAAmB,QACY;AAC/B,QAAM,SAAS,MAAM,gBAAgB;AAAA,IACnC;AAAA,IACA;AAAA,IACA,QAAQ,CAAC,KAAK;AAAA,EAAA,CACf;AAED,SAAO,OAAO,YAAY,CAAC,KAAK;AAClC;AAKA,eAAsB,uBACpB,aACA,YAAoB,IACpB,YAC4D;AAC5D,QAAM,SAAS,MAAM,gBAAgB;AAAA,IACnC;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,OAAO,OAAO,YACjB,OAAO,CAAA,MAAK,EAAE,QAAQ,SAAS,EAC/B,IAAI,CAAA,MAAK,EAAE,KAAK;AAEnB,SAAO;AAAA,IACL,OAAO,OAAO,gBAAgB;AAAA,IAC9B,OAAO,OAAO;AAAA,IACd;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weavelogic/knowledge-graph-agent",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
4
|
"description": "Knowledge graph agent for Claude Code - generates knowledge graphs, initializes docs, and integrates with claude-flow",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|