@greenarmor/ges-core 1.2.5 → 1.2.7
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/recommendations/index.d.ts +22 -0
- package/dist/recommendations/index.js +102 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface AIRecommendation {
|
|
2
|
+
id: string;
|
|
3
|
+
timestamp: string;
|
|
4
|
+
category: "security" | "compliance" | "architecture" | "performance" | "best-practice" | "bug" | "improvement";
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
severity: "info" | "low" | "medium" | "high";
|
|
8
|
+
affected_controls?: string[];
|
|
9
|
+
affected_files?: string[];
|
|
10
|
+
suggested_action: string;
|
|
11
|
+
status: "open" | "acknowledged" | "implemented" | "dismissed";
|
|
12
|
+
}
|
|
13
|
+
export declare function recordAIRecommendation(projectPath: string, opts: {
|
|
14
|
+
category: AIRecommendation["category"];
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
severity?: AIRecommendation["severity"];
|
|
18
|
+
affected_controls?: string[];
|
|
19
|
+
affected_files?: string[];
|
|
20
|
+
suggested_action: string;
|
|
21
|
+
}): AIRecommendation;
|
|
22
|
+
export declare function loadAIRecommendations(projectPath: string): AIRecommendation[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
let recCounter = 0;
|
|
4
|
+
export function recordAIRecommendation(projectPath, opts) {
|
|
5
|
+
recCounter++;
|
|
6
|
+
const recommendation = {
|
|
7
|
+
id: `ai-rec-${Date.now()}-${recCounter}`,
|
|
8
|
+
timestamp: new Date().toISOString(),
|
|
9
|
+
category: opts.category,
|
|
10
|
+
title: opts.title,
|
|
11
|
+
description: opts.description,
|
|
12
|
+
severity: opts.severity || "info",
|
|
13
|
+
affected_controls: opts.affected_controls || [],
|
|
14
|
+
affected_files: opts.affected_files || [],
|
|
15
|
+
suggested_action: opts.suggested_action,
|
|
16
|
+
status: "open",
|
|
17
|
+
};
|
|
18
|
+
const devLogsDir = path.join(projectPath, ".dev-logs", "ai-recommendations");
|
|
19
|
+
if (!fs.existsSync(devLogsDir)) {
|
|
20
|
+
fs.mkdirSync(devLogsDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
const dateStr = new Date().toISOString().split("T")[0];
|
|
23
|
+
const fileName = `${dateStr}-${recommendation.id}.md`;
|
|
24
|
+
const md = [
|
|
25
|
+
`# AI Recommendation: ${recommendation.title}`,
|
|
26
|
+
``,
|
|
27
|
+
`**ID**: ${recommendation.id}`,
|
|
28
|
+
`**Date**: ${recommendation.timestamp}`,
|
|
29
|
+
`**Category**: ${recommendation.category}`,
|
|
30
|
+
`**Severity**: ${recommendation.severity}`,
|
|
31
|
+
`**Status**: ${recommendation.status}`,
|
|
32
|
+
``,
|
|
33
|
+
`## Description`,
|
|
34
|
+
``,
|
|
35
|
+
recommendation.description,
|
|
36
|
+
``,
|
|
37
|
+
];
|
|
38
|
+
if (recommendation.affected_controls && recommendation.affected_controls.length > 0) {
|
|
39
|
+
md.push(`## Affected Controls`);
|
|
40
|
+
md.push("");
|
|
41
|
+
for (const c of recommendation.affected_controls) {
|
|
42
|
+
md.push(`- ${c}`);
|
|
43
|
+
}
|
|
44
|
+
md.push("");
|
|
45
|
+
}
|
|
46
|
+
if (recommendation.affected_files && recommendation.affected_files.length > 0) {
|
|
47
|
+
md.push(`## Affected Files`);
|
|
48
|
+
md.push("");
|
|
49
|
+
for (const f of recommendation.affected_files) {
|
|
50
|
+
md.push(`- ${f}`);
|
|
51
|
+
}
|
|
52
|
+
md.push("");
|
|
53
|
+
}
|
|
54
|
+
md.push(`## Suggested Action`);
|
|
55
|
+
md.push("");
|
|
56
|
+
md.push(recommendation.suggested_action);
|
|
57
|
+
md.push("");
|
|
58
|
+
md.push(`---`);
|
|
59
|
+
md.push(`*This recommendation was generated by an AI assistant using the GESF MCP server. It is logged here for developer review and is NOT automatically applied to the project.*`);
|
|
60
|
+
md.push("");
|
|
61
|
+
fs.writeFileSync(path.join(devLogsDir, fileName), md.join("\n"), "utf-8");
|
|
62
|
+
return recommendation;
|
|
63
|
+
}
|
|
64
|
+
export function loadAIRecommendations(projectPath) {
|
|
65
|
+
const recDir = path.join(projectPath, ".dev-logs", "ai-recommendations");
|
|
66
|
+
const results = [];
|
|
67
|
+
try {
|
|
68
|
+
const entries = fs.readdirSync(recDir);
|
|
69
|
+
for (const entry of entries) {
|
|
70
|
+
if (!entry.endsWith(".md"))
|
|
71
|
+
continue;
|
|
72
|
+
try {
|
|
73
|
+
const content = fs.readFileSync(path.join(recDir, entry), "utf-8");
|
|
74
|
+
const idMatch = content.match(/\*\*ID\*\*:\s*(.+)/);
|
|
75
|
+
const titleMatch = content.match(/^# AI Recommendation:\s*(.+)/m);
|
|
76
|
+
const catMatch = content.match(/\*\*Category\*\*:\s*(.+)/);
|
|
77
|
+
const sevMatch = content.match(/\*\*Severity\*\*:\s*(.+)/);
|
|
78
|
+
const dateMatch = content.match(/\*\*Date\*\*:\s*(.+)/);
|
|
79
|
+
const statusMatch = content.match(/\*\*Status\*\*:\s*(.+)/);
|
|
80
|
+
if (idMatch && titleMatch) {
|
|
81
|
+
results.push({
|
|
82
|
+
id: idMatch[1].trim(),
|
|
83
|
+
timestamp: dateMatch ? dateMatch[1].trim() : "",
|
|
84
|
+
category: (catMatch ? catMatch[1].trim() : "improvement"),
|
|
85
|
+
title: titleMatch[1].trim(),
|
|
86
|
+
severity: (sevMatch ? sevMatch[1].trim() : "info"),
|
|
87
|
+
description: "",
|
|
88
|
+
suggested_action: "",
|
|
89
|
+
status: (statusMatch ? statusMatch[1].trim() : "open"),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// skip malformed files
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// dir doesn't exist
|
|
100
|
+
}
|
|
101
|
+
return results.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
102
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type ProjectType = "saas" | "ai-application" | "mcp-server" | "blockchain" | "wallet" | "government-system" | "healthcare-system" | "event-platform" | "photo-storage-platform" | "vulnerability-scanner" | "generic-web-application" | "api-backend" | "mobile-application";
|
|
2
|
-
export type FrameworkName = "GDPR" | "OWASP" | "CIS" | "NIST" | "ISO27001" | "ISO27701" | "HIPAA";
|
|
2
|
+
export type FrameworkName = "GDPR" | "OWASP" | "CIS" | "NIST" | "NIST-800-53" | "ISO27001" | "ISO27701" | "HIPAA";
|
|
3
3
|
export type DataClassification = "public" | "internal" | "confidential" | "restricted";
|
|
4
4
|
export type SeverityLevel = "critical" | "high" | "medium" | "low";
|
|
5
5
|
export type ControlStatus = "pass" | "fail" | "warning" | "not-applicable" | "not-implemented";
|