framework-mcp 2.4.6 ā 2.5.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/README.md +9 -9
- package/dist/core/safeguard-manager.d.ts.map +1 -1
- package/dist/core/safeguard-manager.js +160 -7062
- package/dist/core/safeguard-manager.js.map +1 -1
- package/dist/interfaces/http/http-server.d.ts.map +1 -1
- package/dist/interfaces/http/http-server.js +6 -40
- package/dist/interfaces/http/http-server.js.map +1 -1
- package/dist/interfaces/mcp/mcp-server.js +3 -3
- package/dist/shared/types.d.ts +0 -35
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js.map +1 -1
- package/package.json +2 -3
- package/src/core/safeguard-manager.ts +295 -12552
- package/src/interfaces/http/http-server.ts +6 -45
- package/src/interfaces/mcp/mcp-server.ts +3 -3
- package/src/shared/types.ts +0 -37
- package/swagger.json +3 -58
- package/scripts/standardize-prompts.js +0 -325
- package/scripts/validate-capability-prompts.js +0 -110
|
@@ -106,7 +106,7 @@ export class FrameworkHttpServer {
|
|
|
106
106
|
res.json({
|
|
107
107
|
status: 'healthy',
|
|
108
108
|
uptime: Math.round(process.uptime()),
|
|
109
|
-
version: '2.
|
|
109
|
+
version: '2.5.6',
|
|
110
110
|
timestamp: new Date().toISOString()
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -117,54 +117,15 @@ export class FrameworkHttpServer {
|
|
|
117
117
|
const allSafeguards = this.safeguardManager.getAllSafeguards();
|
|
118
118
|
const safeguardIds = Object.keys(allSafeguards);
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
let errors: string[] = [];
|
|
122
|
-
const expectedFields = [
|
|
123
|
-
'systemPromptFull',
|
|
124
|
-
'systemPromptPartial',
|
|
125
|
-
'systemPromptFacilitates',
|
|
126
|
-
'systemPromptGovernance',
|
|
127
|
-
'systemPromptValidates'
|
|
128
|
-
];
|
|
129
|
-
|
|
130
|
-
for (const safeguardId of safeguardIds) {
|
|
131
|
-
const safeguard = allSafeguards[safeguardId];
|
|
132
|
-
|
|
133
|
-
// Check all five capability prompts exist and are complete
|
|
134
|
-
for (const field of expectedFields) {
|
|
135
|
-
const prompt = (safeguard as any)[field];
|
|
136
|
-
if (!prompt) {
|
|
137
|
-
errors.push(`${safeguardId}: Missing ${field}`);
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (!prompt.role || !prompt.context || !prompt.objective ||
|
|
142
|
-
!prompt.guidelines || !prompt.outputFormat) {
|
|
143
|
-
errors.push(`${safeguardId}.${field}: Incomplete structure`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Check deprecated field is gone
|
|
148
|
-
if ('systemPrompt' in safeguard) {
|
|
149
|
-
errors.push(`${safeguardId}: Deprecated systemPrompt field exists`);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
totalValidated++;
|
|
153
|
-
}
|
|
120
|
+
const totalValidated = safeguardIds.length;
|
|
154
121
|
|
|
155
122
|
res.json({
|
|
156
|
-
status:
|
|
123
|
+
status: 'healthy',
|
|
157
124
|
safeguards: {
|
|
158
125
|
total: totalValidated,
|
|
159
126
|
expected: 153,
|
|
160
|
-
complete: totalValidated === 153
|
|
161
|
-
},
|
|
162
|
-
capabilityPrompts: {
|
|
163
|
-
expectedFields: expectedFields.length,
|
|
164
|
-
validatedFields: expectedFields.length
|
|
127
|
+
complete: totalValidated === 153
|
|
165
128
|
},
|
|
166
|
-
errors: errors.length,
|
|
167
|
-
errorDetails: errors.slice(0, 10), // Show first 10 errors only
|
|
168
129
|
timestamp: new Date().toISOString()
|
|
169
130
|
});
|
|
170
131
|
|
|
@@ -222,7 +183,7 @@ export class FrameworkHttpServer {
|
|
|
222
183
|
this.app.get('/api', (req, res) => {
|
|
223
184
|
res.json({
|
|
224
185
|
name: 'Framework MCP HTTP API',
|
|
225
|
-
version: '2.
|
|
186
|
+
version: '2.5.6',
|
|
226
187
|
description: 'Pure Data Provider serving authentic CIS Controls Framework data',
|
|
227
188
|
endpoints: {
|
|
228
189
|
'GET /api/safeguards': 'List all available CIS safeguards',
|
|
@@ -273,7 +234,7 @@ export class FrameworkHttpServer {
|
|
|
273
234
|
|
|
274
235
|
public start(): void {
|
|
275
236
|
this.app.listen(this.port, '0.0.0.0', () => {
|
|
276
|
-
console.log(`š Framework MCP HTTP Server v2.
|
|
237
|
+
console.log(`š Framework MCP HTTP Server v2.5.6 running on port ${this.port}`);
|
|
277
238
|
console.log(`š Health check: http://localhost:${this.port}/health`);
|
|
278
239
|
console.log(`š API docs: http://localhost:${this.port}/api`);
|
|
279
240
|
console.log(`š§ Environment: ${process.env.NODE_ENV || 'development'}`);
|
|
@@ -18,7 +18,7 @@ export class FrameworkMcpServer {
|
|
|
18
18
|
this.server = new Server(
|
|
19
19
|
{
|
|
20
20
|
name: 'framework-analyzer',
|
|
21
|
-
version: '2.
|
|
21
|
+
version: '2.5.6',
|
|
22
22
|
}
|
|
23
23
|
);
|
|
24
24
|
|
|
@@ -129,7 +129,7 @@ export class FrameworkMcpServer {
|
|
|
129
129
|
safeguards,
|
|
130
130
|
total: safeguards.length,
|
|
131
131
|
framework: 'CIS Controls v8.1',
|
|
132
|
-
version: '2.
|
|
132
|
+
version: '2.5.6'
|
|
133
133
|
}, null, 2),
|
|
134
134
|
},
|
|
135
135
|
],
|
|
@@ -153,7 +153,7 @@ export class FrameworkMcpServer {
|
|
|
153
153
|
const transport = new StdioServerTransport();
|
|
154
154
|
await this.server.connect(transport);
|
|
155
155
|
|
|
156
|
-
console.error('š¤ Framework MCP Server v2.
|
|
156
|
+
console.error('š¤ Framework MCP Server v2.5.6 running via stdio');
|
|
157
157
|
console.error('š Pure Data Provider for CIS Controls v8.1');
|
|
158
158
|
}
|
|
159
159
|
}
|
package/src/shared/types.ts
CHANGED
|
@@ -43,43 +43,6 @@ export interface SafeguardElement {
|
|
|
43
43
|
|
|
44
44
|
// Enhanced relationships - new optional field for rich relationship data
|
|
45
45
|
enhancedRelationships?: SafeguardRelationship[];
|
|
46
|
-
|
|
47
|
-
// Capability-specific system prompts for different evaluation levels
|
|
48
|
-
systemPromptFull?: {
|
|
49
|
-
role: string; // e.g., "asset_inventory_expert", "access_control_specialist"
|
|
50
|
-
context: string; // Brief context about the safeguard for AI understanding
|
|
51
|
-
objective: string; // What the AI should accomplish
|
|
52
|
-
guidelines: string[]; // Specific evaluation criteria and methods
|
|
53
|
-
outputFormat: string; // Expected response structure for n8n processing
|
|
54
|
-
};
|
|
55
|
-
systemPromptPartial?: {
|
|
56
|
-
role: string;
|
|
57
|
-
context: string;
|
|
58
|
-
objective: string;
|
|
59
|
-
guidelines: string[];
|
|
60
|
-
outputFormat: string;
|
|
61
|
-
};
|
|
62
|
-
systemPromptFacilitates?: {
|
|
63
|
-
role: string;
|
|
64
|
-
context: string;
|
|
65
|
-
objective: string;
|
|
66
|
-
guidelines: string[];
|
|
67
|
-
outputFormat: string;
|
|
68
|
-
};
|
|
69
|
-
systemPromptGovernance?: {
|
|
70
|
-
role: string;
|
|
71
|
-
context: string;
|
|
72
|
-
objective: string;
|
|
73
|
-
guidelines: string[];
|
|
74
|
-
outputFormat: string;
|
|
75
|
-
};
|
|
76
|
-
systemPromptValidates?: {
|
|
77
|
-
role: string;
|
|
78
|
-
context: string;
|
|
79
|
-
objective: string;
|
|
80
|
-
guidelines: string[];
|
|
81
|
-
outputFormat: string;
|
|
82
|
-
};
|
|
83
46
|
}
|
|
84
47
|
|
|
85
48
|
export interface VendorAnalysis {
|
package/swagger.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.0.3",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "Framework MCP API - Pure Data Provider",
|
|
5
|
-
"description": "Microsoft Copilot-compatible API providing authoritative CIS Controls Framework v8.1 data (153 safeguards). Pure Data Provider architecture empowers LLMs with structured safeguards data
|
|
5
|
+
"description": "Microsoft Copilot-compatible API providing authoritative CIS Controls Framework v8.1 data (153 safeguards). Pure Data Provider architecture empowers LLMs with structured safeguards data for sophisticated, context-aware vendor capability analysis.",
|
|
6
6
|
"version": "2.0.0",
|
|
7
7
|
"contact": {
|
|
8
8
|
"name": "Framework MCP Support",
|
|
@@ -255,26 +255,6 @@
|
|
|
255
255
|
"type": "string"
|
|
256
256
|
},
|
|
257
257
|
"description": "Implementation methods and suggestions (Gray elements)"
|
|
258
|
-
},
|
|
259
|
-
"systemPromptFull": {
|
|
260
|
-
"$ref": "#/components/schemas/SystemPromptStructure",
|
|
261
|
-
"description": "AI-driven system prompt for FULL capability evaluation"
|
|
262
|
-
},
|
|
263
|
-
"systemPromptPartial": {
|
|
264
|
-
"$ref": "#/components/schemas/SystemPromptStructure",
|
|
265
|
-
"description": "AI-driven system prompt for PARTIAL capability evaluation"
|
|
266
|
-
},
|
|
267
|
-
"systemPromptFacilitates": {
|
|
268
|
-
"$ref": "#/components/schemas/SystemPromptStructure",
|
|
269
|
-
"description": "AI-driven system prompt for FACILITATES capability evaluation"
|
|
270
|
-
},
|
|
271
|
-
"systemPromptGovernance": {
|
|
272
|
-
"$ref": "#/components/schemas/SystemPromptStructure",
|
|
273
|
-
"description": "AI-driven system prompt for GOVERNANCE capability evaluation"
|
|
274
|
-
},
|
|
275
|
-
"systemPromptValidates": {
|
|
276
|
-
"$ref": "#/components/schemas/SystemPromptStructure",
|
|
277
|
-
"description": "AI-driven system prompt for VALIDATES capability evaluation"
|
|
278
258
|
}
|
|
279
259
|
}
|
|
280
260
|
},
|
|
@@ -299,7 +279,7 @@
|
|
|
299
279
|
},
|
|
300
280
|
"version": {
|
|
301
281
|
"type": "string",
|
|
302
|
-
"example": "2.
|
|
282
|
+
"example": "2.5.6"
|
|
303
283
|
},
|
|
304
284
|
"timestamp": {
|
|
305
285
|
"type": "string",
|
|
@@ -344,7 +324,7 @@
|
|
|
344
324
|
},
|
|
345
325
|
"version": {
|
|
346
326
|
"type": "string",
|
|
347
|
-
"example": "2.
|
|
327
|
+
"example": "2.5.6"
|
|
348
328
|
},
|
|
349
329
|
"description": {
|
|
350
330
|
"type": "string",
|
|
@@ -390,41 +370,6 @@
|
|
|
390
370
|
"format": "date-time"
|
|
391
371
|
}
|
|
392
372
|
}
|
|
393
|
-
},
|
|
394
|
-
"SystemPromptStructure": {
|
|
395
|
-
"type": "object",
|
|
396
|
-
"description": "AI-driven system prompt structure for vendor capability analysis",
|
|
397
|
-
"properties": {
|
|
398
|
-
"role": {
|
|
399
|
-
"type": "string",
|
|
400
|
-
"description": "Expert role for the specific control type",
|
|
401
|
-
"example": "asset_inventory_expert"
|
|
402
|
-
},
|
|
403
|
-
"context": {
|
|
404
|
-
"type": "string",
|
|
405
|
-
"description": "Brief context about the safeguard for AI understanding",
|
|
406
|
-
"example": "You are evaluating enterprise asset inventory solutions against CIS Control 1.1 requirements"
|
|
407
|
-
},
|
|
408
|
-
"objective": {
|
|
409
|
-
"type": "string",
|
|
410
|
-
"description": "What the AI should accomplish",
|
|
411
|
-
"example": "Determine if vendor solution provides complete asset inventory capabilities"
|
|
412
|
-
},
|
|
413
|
-
"guidelines": {
|
|
414
|
-
"type": "array",
|
|
415
|
-
"items": {
|
|
416
|
-
"type": "string"
|
|
417
|
-
},
|
|
418
|
-
"description": "Specific evaluation criteria and methods",
|
|
419
|
-
"example": ["Verify coverage of all asset types", "Confirm data collection accuracy"]
|
|
420
|
-
},
|
|
421
|
-
"outputFormat": {
|
|
422
|
-
"type": "string",
|
|
423
|
-
"description": "Expected response structure for n8n processing",
|
|
424
|
-
"example": "Provide structured assessment with capability level (FULL/PARTIAL/FACILITATES/GOVERNANCE/VALIDATES), confidence score, and evidence summary"
|
|
425
|
-
}
|
|
426
|
-
},
|
|
427
|
-
"required": ["role", "context", "objective", "guidelines", "outputFormat"]
|
|
428
373
|
}
|
|
429
374
|
}
|
|
430
375
|
},
|
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
class PromptStandardizer {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.safeguardManagerPath = path.join(__dirname, '..', 'src/core/safeguard-manager.ts');
|
|
13
|
-
this.backupPath = `${this.safeguardManagerPath}.backup.${Date.now()}`;
|
|
14
|
-
this.dryRun = false;
|
|
15
|
-
this.verbose = false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Extract template objectives from safeguard 10.2
|
|
20
|
-
*/
|
|
21
|
-
extractTemplateObjectives() {
|
|
22
|
-
const content = fs.readFileSync(this.safeguardManagerPath, 'utf-8');
|
|
23
|
-
|
|
24
|
-
// Find safeguard 10.2 and extract the objectives
|
|
25
|
-
const safeguard10_2Match = content.match(/"10\.2":\s*{[\s\S]*?systemPromptValidates:\s*{[\s\S]*?}\s*}/);
|
|
26
|
-
if (!safeguard10_2Match) {
|
|
27
|
-
throw new Error('Could not find safeguard 10.2 definition');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const safeguard10_2Text = safeguard10_2Match[0];
|
|
31
|
-
|
|
32
|
-
// Extract objectives for each capability
|
|
33
|
-
const extractObjective = (capability) => {
|
|
34
|
-
const regex = new RegExp(`systemPrompt${capability}:[\\s\\S]*?objective:\\s*"([^"]*)"`, 'i');
|
|
35
|
-
const match = safeguard10_2Text.match(regex);
|
|
36
|
-
if (!match) {
|
|
37
|
-
throw new Error(`Could not find ${capability} objective in safeguard 10.2`);
|
|
38
|
-
}
|
|
39
|
-
return match[1];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const template = {
|
|
43
|
-
Full: extractObjective('Full'),
|
|
44
|
-
Partial: extractObjective('Partial'),
|
|
45
|
-
Facilitates: extractObjective('Facilitates'),
|
|
46
|
-
Governance: extractObjective('Governance'),
|
|
47
|
-
Validates: extractObjective('Validates')
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (this.verbose) {
|
|
51
|
-
console.log('š Extracted template objectives:');
|
|
52
|
-
Object.entries(template).forEach(([key, value]) => {
|
|
53
|
-
console.log(` ${key}: ${value.substring(0, 80)}...`);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return template;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Apply standardization using global replacements
|
|
62
|
-
*/
|
|
63
|
-
standardizeContent(template) {
|
|
64
|
-
let content = fs.readFileSync(this.safeguardManagerPath, 'utf-8');
|
|
65
|
-
let totalReplacements = 0;
|
|
66
|
-
|
|
67
|
-
// Track changes
|
|
68
|
-
const stats = {
|
|
69
|
-
objectiveReplacements: 0,
|
|
70
|
-
guidelineReplacements: 0,
|
|
71
|
-
outputFormatReplacements: 0,
|
|
72
|
-
implementationSimplifications: 0
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Step 1: Replace all objectives with template objectives
|
|
76
|
-
const capabilities = ['Full', 'Partial', 'Facilitates', 'Governance', 'Validates'];
|
|
77
|
-
|
|
78
|
-
for (const capability of capabilities) {
|
|
79
|
-
const templateObjective = template[capability];
|
|
80
|
-
|
|
81
|
-
// Replace all objectives for this capability (excluding 10.2)
|
|
82
|
-
const objectiveRegex = new RegExp(
|
|
83
|
-
`(systemPrompt${capability}:[\\s\\S]*?objective:\\s*)"[^"]*"`,
|
|
84
|
-
'g'
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
let matches = 0;
|
|
88
|
-
content = content.replace(objectiveRegex, (match, prefix, offset) => {
|
|
89
|
-
// Skip if this is within safeguard 10.2
|
|
90
|
-
const before = content.substring(Math.max(0, offset - 500), offset);
|
|
91
|
-
if (before.includes('"10.2":')) {
|
|
92
|
-
return match; // Don't replace template safeguard
|
|
93
|
-
}
|
|
94
|
-
matches++;
|
|
95
|
-
return `${prefix}"${templateObjective}"`;
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
stats.objectiveReplacements += matches;
|
|
99
|
-
if (this.verbose && matches > 0) {
|
|
100
|
-
console.log(` ā
Updated ${matches} ${capability} objectives`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Step 2: Replace all guidelines with ["Future Use"] (excluding 10.2)
|
|
105
|
-
const guidelineRegex = /(systemPrompt(?:Full|Partial|Facilitates|Governance|Validates):[\s\S]*?guidelines:\s*)\[[\s\S]*?\]/g;
|
|
106
|
-
|
|
107
|
-
content = content.replace(guidelineRegex, (match, prefix, offset) => {
|
|
108
|
-
// Skip if this is within safeguard 10.2
|
|
109
|
-
const before = content.substring(Math.max(0, offset - 500), offset);
|
|
110
|
-
if (before.includes('"10.2":')) {
|
|
111
|
-
return match; // Don't replace template safeguard
|
|
112
|
-
}
|
|
113
|
-
stats.guidelineReplacements++;
|
|
114
|
-
return `${prefix}[\n "Future Use"\n ]`;
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Step 3: Replace all outputFormat with standardized version (excluding 10.2)
|
|
118
|
-
const outputFormatRegex = /(systemPrompt(?:Full|Partial|Facilitates|Governance|Validates):[\s\S]*?outputFormat:\s*)"[^"]*"/g;
|
|
119
|
-
const standardOutputFormat = 'Provide a structured assessment, confidence score, and evidence summary';
|
|
120
|
-
|
|
121
|
-
content = content.replace(outputFormatRegex, (match, prefix, offset) => {
|
|
122
|
-
// Skip if this is within safeguard 10.2
|
|
123
|
-
const before = content.substring(Math.max(0, offset - 500), offset);
|
|
124
|
-
if (before.includes('"10.2":')) {
|
|
125
|
-
return match; // Don't replace template safeguard
|
|
126
|
-
}
|
|
127
|
-
stats.outputFormatReplacements++;
|
|
128
|
-
return `${prefix}"${standardOutputFormat}"`;
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Step 4: Simplify implementation suggestions (excluding 10.2)
|
|
132
|
-
const implRegex = /(implementationSuggestions:\s*\[\s*)((?:\s*"[^"]*",?\s*)+)(\s*\])/g;
|
|
133
|
-
|
|
134
|
-
content = content.replace(implRegex, (match, prefix, suggestions, suffix, offset) => {
|
|
135
|
-
// Skip if this is within safeguard 10.2
|
|
136
|
-
const before = content.substring(Math.max(0, offset - 500), offset);
|
|
137
|
-
if (before.includes('"10.2":')) {
|
|
138
|
-
return match; // Don't replace template safeguard
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Extract individual suggestions
|
|
142
|
-
const suggestionMatches = suggestions.match(/"[^"]+"/g) || [];
|
|
143
|
-
|
|
144
|
-
if (suggestionMatches.length > 3) {
|
|
145
|
-
stats.implementationSimplifications++;
|
|
146
|
-
const simplified = suggestionMatches.slice(0, 3).join(',\n ');
|
|
147
|
-
return `${prefix} // Gray - Implementation suggestions\n ${simplified}\n ${suffix}`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return match; // Keep as is if 3 or fewer suggestions
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
if (this.verbose) {
|
|
154
|
-
console.log('š Transformation statistics:');
|
|
155
|
-
console.log(` - Objective replacements: ${stats.objectiveReplacements}`);
|
|
156
|
-
console.log(` - Guideline replacements: ${stats.guidelineReplacements}`);
|
|
157
|
-
console.log(` - Output format replacements: ${stats.outputFormatReplacements}`);
|
|
158
|
-
console.log(` - Implementation simplifications: ${stats.implementationSimplifications}`);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return { content, stats };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Create backup of original safeguard-manager.ts
|
|
166
|
-
*/
|
|
167
|
-
createBackup() {
|
|
168
|
-
if (this.verbose) {
|
|
169
|
-
console.log(`š Creating backup: ${this.backupPath}`);
|
|
170
|
-
}
|
|
171
|
-
fs.copyFileSync(this.safeguardManagerPath, this.backupPath);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Save updated content
|
|
176
|
-
*/
|
|
177
|
-
saveContent(content) {
|
|
178
|
-
if (this.dryRun) {
|
|
179
|
-
console.log('š DRY RUN: Would save updated content to file');
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (this.verbose) {
|
|
184
|
-
console.log('š¾ Saving updated content...');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
fs.writeFileSync(this.safeguardManagerPath, content);
|
|
188
|
-
|
|
189
|
-
if (this.verbose) {
|
|
190
|
-
console.log('ā
File saved successfully');
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Validate transformation results
|
|
196
|
-
*/
|
|
197
|
-
validateTransformation(content) {
|
|
198
|
-
if (this.verbose) {
|
|
199
|
-
console.log('š Validating transformation...');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
let isValid = true;
|
|
203
|
-
const errors = [];
|
|
204
|
-
|
|
205
|
-
// Count "Future Use" guidelines
|
|
206
|
-
const futureUseMatches = content.match(/guidelines:\s*\[\s*"Future Use"\s*\]/g);
|
|
207
|
-
const futureUseCount = futureUseMatches ? futureUseMatches.length : 0;
|
|
208
|
-
|
|
209
|
-
// Expected: 153 safeguards Ć 5 capabilities = 765
|
|
210
|
-
// But safeguard 10.2 already has 5, so we should see 760 from transformation + 5 existing = 765 total
|
|
211
|
-
const expectedTotal = 765;
|
|
212
|
-
|
|
213
|
-
if (futureUseCount !== expectedTotal) {
|
|
214
|
-
errors.push(`Expected ${expectedTotal} "Future Use" guidelines, found ${futureUseCount}`);
|
|
215
|
-
isValid = false;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Count standardized output formats
|
|
219
|
-
const outputFormatMatches = content.match(/outputFormat:\s*"Provide a structured assessment, confidence score, and evidence summary"/g);
|
|
220
|
-
const outputFormatCount = outputFormatMatches ? outputFormatMatches.length : 0;
|
|
221
|
-
|
|
222
|
-
if (outputFormatCount !== expectedTotal) {
|
|
223
|
-
errors.push(`Expected ${expectedTotal} standardized output formats, found ${outputFormatCount}`);
|
|
224
|
-
isValid = false;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Verify template objectives are applied
|
|
228
|
-
const fullObjectiveMatches = content.match(/The vendor has taken an assessment and has been mapped to FULL.*?FULLY\./g);
|
|
229
|
-
const fullObjectiveCount = fullObjectiveMatches ? fullObjectiveMatches.length : 0;
|
|
230
|
-
|
|
231
|
-
if (fullObjectiveCount !== 153) {
|
|
232
|
-
errors.push(`Expected 153 FULL template objectives, found ${fullObjectiveCount}`);
|
|
233
|
-
isValid = false;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (errors.length > 0) {
|
|
237
|
-
console.error('ā Validation errors:');
|
|
238
|
-
errors.forEach(error => console.error(` - ${error}`));
|
|
239
|
-
} else {
|
|
240
|
-
console.log('ā
Validation passed: All transformations applied successfully');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return isValid;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Main transformation process
|
|
248
|
-
*/
|
|
249
|
-
async run(options = {}) {
|
|
250
|
-
this.dryRun = options.dryRun || false;
|
|
251
|
-
this.verbose = options.verbose || false;
|
|
252
|
-
|
|
253
|
-
try {
|
|
254
|
-
console.log('š Starting prompt standardization...');
|
|
255
|
-
|
|
256
|
-
// Create backup unless dry run
|
|
257
|
-
if (!this.dryRun) {
|
|
258
|
-
this.createBackup();
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Extract template objectives from 10.2
|
|
262
|
-
console.log('š Extracting template from safeguard 10.2...');
|
|
263
|
-
const template = this.extractTemplateObjectives();
|
|
264
|
-
|
|
265
|
-
// Apply standardization
|
|
266
|
-
console.log('š Applying standardization to all safeguards (excluding 10.2)...');
|
|
267
|
-
const { content, stats } = this.standardizeContent(template);
|
|
268
|
-
|
|
269
|
-
// Validate if requested
|
|
270
|
-
if (options.validate) {
|
|
271
|
-
const isValid = this.validateTransformation(content);
|
|
272
|
-
if (!isValid) {
|
|
273
|
-
throw new Error('Validation failed - transformation incomplete');
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Save results
|
|
278
|
-
this.saveContent(content);
|
|
279
|
-
|
|
280
|
-
console.log('š Standardization complete!');
|
|
281
|
-
console.log('š Summary:');
|
|
282
|
-
console.log(` - Objective updates: ${stats.objectiveReplacements}`);
|
|
283
|
-
console.log(` - Guideline standardizations: ${stats.guidelineReplacements}`);
|
|
284
|
-
console.log(` - Output format standardizations: ${stats.outputFormatReplacements}`);
|
|
285
|
-
console.log(` - Implementation simplifications: ${stats.implementationSimplifications}`);
|
|
286
|
-
if (!this.dryRun) {
|
|
287
|
-
console.log(` - Backup: ${this.backupPath}`);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
} catch (error) {
|
|
291
|
-
console.error('ā Error during standardization:', error);
|
|
292
|
-
process.exit(1);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// CLI interface
|
|
298
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
299
|
-
const args = process.argv.slice(2);
|
|
300
|
-
const options = {
|
|
301
|
-
dryRun: args.includes('--dry-run'),
|
|
302
|
-
validate: args.includes('--validate'),
|
|
303
|
-
verbose: args.includes('--verbose')
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
if (args.includes('--help')) {
|
|
307
|
-
console.log(`
|
|
308
|
-
Usage: npm run standardize-prompts [options]
|
|
309
|
-
|
|
310
|
-
Options:
|
|
311
|
-
--dry-run Show what would be changed without making actual changes
|
|
312
|
-
--validate Run validation after transformation
|
|
313
|
-
--verbose Show detailed progress information
|
|
314
|
-
--help Show this help message
|
|
315
|
-
|
|
316
|
-
Examples:
|
|
317
|
-
npm run standardize-prompts --dry-run --verbose
|
|
318
|
-
npm run standardize-prompts --validate --verbose
|
|
319
|
-
`);
|
|
320
|
-
process.exit(0);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const standardizer = new PromptStandardizer();
|
|
324
|
-
standardizer.run(options).catch(console.error);
|
|
325
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Validate that all 153 safeguards have complete capability-specific prompts
|
|
5
|
-
* This script verifies the transformation was successful
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { SafeguardManager } from '../dist/core/safeguard-manager.js';
|
|
9
|
-
|
|
10
|
-
function validateCapabilityPrompts() {
|
|
11
|
-
console.log('š Starting capability prompt validation...');
|
|
12
|
-
|
|
13
|
-
const safeguardManager = new SafeguardManager();
|
|
14
|
-
const allSafeguards = safeguardManager.getAllSafeguards();
|
|
15
|
-
const safeguardIds = Object.keys(allSafeguards);
|
|
16
|
-
|
|
17
|
-
console.log(`š Found ${safeguardIds.length} safeguards to validate`);
|
|
18
|
-
|
|
19
|
-
const expectedFields = [
|
|
20
|
-
'systemPromptFull',
|
|
21
|
-
'systemPromptPartial',
|
|
22
|
-
'systemPromptFacilitates',
|
|
23
|
-
'systemPromptGovernance',
|
|
24
|
-
'systemPromptValidates'
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
const requiredSubfields = ['role', 'context', 'objective', 'guidelines', 'outputFormat'];
|
|
28
|
-
|
|
29
|
-
let totalValidated = 0;
|
|
30
|
-
let errors = [];
|
|
31
|
-
|
|
32
|
-
for (const safeguardId of safeguardIds) {
|
|
33
|
-
const safeguard = allSafeguards[safeguardId];
|
|
34
|
-
|
|
35
|
-
// Check if all five capability prompts exist
|
|
36
|
-
for (const field of expectedFields) {
|
|
37
|
-
if (!safeguard[field]) {
|
|
38
|
-
errors.push(`ā ${safeguardId}: Missing ${field}`);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check if each prompt has the required structure
|
|
43
|
-
const prompt = safeguard[field];
|
|
44
|
-
for (const subfield of requiredSubfields) {
|
|
45
|
-
if (!prompt[subfield]) {
|
|
46
|
-
errors.push(`ā ${safeguardId}.${field}: Missing ${subfield}`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (subfield === 'guidelines' && (!Array.isArray(prompt[subfield]) || prompt[subfield].length === 0)) {
|
|
50
|
-
errors.push(`ā ${safeguardId}.${field}: Guidelines must be non-empty array`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (subfield !== 'guidelines' && (!prompt[subfield] || typeof prompt[subfield] !== 'string')) {
|
|
54
|
-
errors.push(`ā ${safeguardId}.${field}: ${subfield} must be non-empty string`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Check that old systemPrompt field is gone
|
|
60
|
-
if ('systemPrompt' in safeguard) {
|
|
61
|
-
errors.push(`ā ${safeguardId}: Deprecated systemPrompt field still exists`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
totalValidated++;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Report results
|
|
68
|
-
console.log(`\nš Validation Results:`);
|
|
69
|
-
console.log(`ā
Safeguards validated: ${totalValidated}`);
|
|
70
|
-
console.log(`ā Errors found: ${errors.length}`);
|
|
71
|
-
|
|
72
|
-
if (errors.length > 0) {
|
|
73
|
-
console.log(`\nšØ Validation Errors:`);
|
|
74
|
-
errors.forEach(error => console.log(error));
|
|
75
|
-
process.exit(1);
|
|
76
|
-
} else {
|
|
77
|
-
console.log(`\nš All ${totalValidated} safeguards have complete capability-specific prompts!`);
|
|
78
|
-
console.log(`ā
All safeguards properly transformed`);
|
|
79
|
-
console.log(`ā
No deprecated systemPrompt fields found`);
|
|
80
|
-
console.log(`ā
All capability prompts have complete structure`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Validate specific prompt structure
|
|
85
|
-
function validatePromptStructure(prompt, safeguardId, fieldName) {
|
|
86
|
-
const requiredFields = ['role', 'context', 'objective', 'guidelines', 'outputFormat'];
|
|
87
|
-
const errors = [];
|
|
88
|
-
|
|
89
|
-
for (const field of requiredFields) {
|
|
90
|
-
if (!prompt[field]) {
|
|
91
|
-
errors.push(`Missing ${field}`);
|
|
92
|
-
} else if (field === 'guidelines') {
|
|
93
|
-
if (!Array.isArray(prompt[field]) || prompt[field].length === 0) {
|
|
94
|
-
errors.push(`Guidelines must be non-empty array`);
|
|
95
|
-
}
|
|
96
|
-
} else if (typeof prompt[field] !== 'string' || prompt[field].trim() === '') {
|
|
97
|
-
errors.push(`${field} must be non-empty string`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return errors;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Export for testing
|
|
105
|
-
export { validateCapabilityPrompts, validatePromptStructure };
|
|
106
|
-
|
|
107
|
-
// Run validation if this file is executed directly
|
|
108
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
109
|
-
validateCapabilityPrompts();
|
|
110
|
-
}
|