@fprad0/skill-master-mcp 0.0.6 → 0.0.8

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.
@@ -0,0 +1,307 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import process from 'node:process';
7
+ import { fileURLToPath } from 'node:url';
8
+ import prompts from 'prompts';
9
+ import {
10
+ activateSuccessSkillDraft,
11
+ listSuccessSkillDraftManifests,
12
+ listUnapprovedSuccessSkills,
13
+ prepareSuccessSkillApprovalPackage,
14
+ readSuccessSkillDraft,
15
+ recordSuccessSkillDecision,
16
+ reviewSuccessSkillDraft,
17
+ } from '../dist/success-learning.js';
18
+ import { readApprovedSkillIndex } from '../dist/skill-network.js';
19
+
20
+ const here = path.dirname(fileURLToPath(import.meta.url));
21
+ const rootDir = path.resolve(here, '..');
22
+ const skillMasterHome = process.env.SKILL_MASTER_HOME ?? path.join(os.homedir(), '.skill-master');
23
+ const successLearningDir = process.env.SKILL_MASTER_SUCCESS_LEARNING_DIR
24
+ ?? path.join(skillMasterHome, 'data', 'success-learning');
25
+ const approvedSkillIndexPath = process.env.SKILL_MASTER_APPROVED_SKILLS_INDEX
26
+ ?? path.join(rootDir, 'network', 'approved-skills.json');
27
+ const studyCandidatesPath = path.join(rootDir, 'network', 'unapproved-skill-candidates.json');
28
+
29
+ const isTty = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
30
+
31
+ const workspaceSkillRoot = () => path.join(process.cwd(), '.codex', 'skills');
32
+
33
+ const globalSkillRoot = () => path.join(process.env.CODEX_HOME ?? path.join(os.homedir(), '.codex'), 'skills');
34
+
35
+ const parseArgs = (argv) => {
36
+ const parsed = {
37
+ command: 'notify',
38
+ target: 'local',
39
+ manifest: null,
40
+ reason: null,
41
+ yes: false,
42
+ overwrite: false,
43
+ directory: successLearningDir,
44
+ outputDir: successLearningDir,
45
+ };
46
+
47
+ for (let index = 0; index < argv.length; index += 1) {
48
+ const arg = argv[index];
49
+ if (arg === '--notify') parsed.command = 'notify';
50
+ else if (arg === '--list') parsed.command = 'list';
51
+ else if (arg === '--study') parsed.command = 'study';
52
+ else if (arg === '--approval-package') parsed.command = 'approval-package';
53
+ else if (arg === '--mark-study') {
54
+ parsed.command = 'mark-study';
55
+ parsed.manifest = argv[++index] ?? null;
56
+ } else if (arg === '--reject') {
57
+ parsed.command = 'reject';
58
+ parsed.manifest = argv[++index] ?? null;
59
+ } else if (arg === '--mark-study-interactive') parsed.command = 'mark-study-interactive';
60
+ else if (arg === '--reject-interactive') parsed.command = 'reject-interactive';
61
+ else if (arg === '--reason') parsed.reason = argv[++index] ?? null;
62
+ else if (arg === '--activate') {
63
+ parsed.command = 'activate';
64
+ parsed.manifest = argv[++index] ?? null;
65
+ } else if (arg === '--activate-interactive') parsed.command = 'activate-interactive';
66
+ else if (arg === '--yes') parsed.yes = true;
67
+ else if (arg === '--overwrite') parsed.overwrite = true;
68
+ else if (arg.startsWith('--target=')) parsed.target = arg.slice('--target='.length);
69
+ else if (arg === '--target') parsed.target = argv[++index] ?? parsed.target;
70
+ else if (arg.startsWith('--directory=')) parsed.directory = arg.slice('--directory='.length);
71
+ else if (arg === '--directory') parsed.directory = argv[++index] ?? parsed.directory;
72
+ else if (arg.startsWith('--output-dir=')) parsed.outputDir = arg.slice('--output-dir='.length);
73
+ else if (arg === '--output-dir') parsed.outputDir = argv[++index] ?? parsed.outputDir;
74
+ else if (arg === '--help' || arg === '-h') parsed.command = 'help';
75
+ else throw new Error(`Unknown argument: ${arg}`);
76
+ }
77
+
78
+ return parsed;
79
+ };
80
+
81
+ const resolveTargetRoot = (target) => {
82
+ if (target === 'local') return workspaceSkillRoot();
83
+ if (target === 'global') return globalSkillRoot();
84
+ return path.resolve(target);
85
+ };
86
+
87
+ const loadStudyCandidates = () => {
88
+ if (!existsSync(studyCandidatesPath)) return [];
89
+ const parsed = JSON.parse(readFileSync(studyCandidatesPath, 'utf8'));
90
+ return Array.isArray(parsed.candidates) ? parsed.candidates : [];
91
+ };
92
+
93
+ const printHelp = () => {
94
+ console.log(`Skill Master Success Skills
95
+
96
+ Usage:
97
+ skill-master-success-skills --notify
98
+ skill-master-success-skills --list
99
+ skill-master-success-skills --study
100
+ skill-master-success-skills --approval-package
101
+ skill-master-success-skills --mark-study <manifest.json> --reason "why"
102
+ skill-master-success-skills --reject <manifest.json> --reason "why"
103
+ skill-master-success-skills --mark-study-interactive
104
+ skill-master-success-skills --reject-interactive
105
+ skill-master-success-skills --activate <manifest.json> --target local|global|<path> --yes
106
+ skill-master-success-skills --activate-interactive --target local|global
107
+ `);
108
+ };
109
+
110
+ const notify = async (directory) => {
111
+ const drafts = await listUnapprovedSuccessSkills(directory);
112
+ const studyCandidates = loadStudyCandidates();
113
+ const readyDrafts = [];
114
+ const approvedIndex = await readApprovedSkillIndex(approvedSkillIndexPath);
115
+
116
+ for (const entry of drafts) {
117
+ const review = await reviewSuccessSkillDraft({ manifestPath: entry.filePath, approvedIndex });
118
+ if (review.recommendation === 'ready-for-human-approval') readyDrafts.push(entry);
119
+ }
120
+
121
+ console.log('Skill Master - notificacoes');
122
+ console.log(`- Drafts pendentes: ${drafts.length}`);
123
+ console.log(`- Prontos para aprovacao humana: ${readyDrafts.length}`);
124
+ console.log(`- Skills externas para estudo: ${studyCandidates.length}`);
125
+ if (readyDrafts.length > 0) {
126
+ console.log('');
127
+ console.log('Acoes sugeridas:');
128
+ console.log('- skill-master-menu --run activate-learned-local');
129
+ console.log('- skill-master-menu --run approval-package');
130
+ }
131
+ };
132
+
133
+ const listDrafts = async (directory) => {
134
+ const drafts = await listUnapprovedSuccessSkills(directory);
135
+ if (drafts.length === 0) {
136
+ console.log('Nenhum draft pendente encontrado.');
137
+ return;
138
+ }
139
+
140
+ for (const [index, draft] of drafts.entries()) {
141
+ console.log(`${index + 1}. ${draft.candidateName}`);
142
+ console.log(` Manifest: ${draft.filePath}`);
143
+ console.log(` Motivo: ${draft.reason}`);
144
+ }
145
+ };
146
+
147
+ const study = () => {
148
+ const candidates = loadStudyCandidates();
149
+ if (candidates.length === 0) {
150
+ console.log('Nenhuma skill externa para estudo encontrada.');
151
+ return;
152
+ }
153
+
154
+ console.log('Skills para estudar');
155
+ for (const [index, candidate] of candidates.entries()) {
156
+ console.log(`${index + 1}. ${candidate.name}`);
157
+ console.log(` Criador: ${candidate.creatorName} - ${candidate.creatorUrl}`);
158
+ console.log(` Link: ${candidate.sourceUrl}`);
159
+ console.log(` Status: ${candidate.reviewStatus}`);
160
+ console.log(` Motivo: ${candidate.reason}`);
161
+ }
162
+ };
163
+
164
+ const createApprovalPackage = async ({ directory, outputDir }) => {
165
+ const approvedIndex = await readApprovedSkillIndex(approvedSkillIndexPath);
166
+ const result = await prepareSuccessSkillApprovalPackage({ directory, outputDir, approvedIndex });
167
+ console.log('Pacote de aprovacao humana criado.');
168
+ console.log(`- Arquivo: ${result.filePath}`);
169
+ console.log(`- Drafts: ${result.totalDrafts}`);
170
+ console.log(`- Prontos para aprovacao: ${result.readyForApproval}`);
171
+ console.log(`- Precisam de revisao: ${result.needsReview}`);
172
+ };
173
+
174
+ const chooseManifest = async (directory, { readyOnly = true } = {}) => {
175
+ const manifests = await listSuccessSkillDraftManifests(directory);
176
+ const approvedIndex = await readApprovedSkillIndex(approvedSkillIndexPath);
177
+ const choices = [];
178
+
179
+ for (const manifestPath of manifests) {
180
+ const draft = await readSuccessSkillDraft(manifestPath);
181
+ if (!draft || draft.governance.approved) continue;
182
+ const review = await reviewSuccessSkillDraft({ manifestPath, approvedIndex });
183
+ choices.push({
184
+ title: draft.candidateSkill.name,
185
+ description: `${review.recommendation} - ${manifestPath}`,
186
+ value: manifestPath,
187
+ disabled: readyOnly && review.recommendation !== 'ready-for-human-approval',
188
+ });
189
+ }
190
+
191
+ if (choices.length === 0) {
192
+ throw new Error('No pending success skill drafts found.');
193
+ }
194
+
195
+ const response = await prompts({
196
+ type: 'select',
197
+ name: 'manifest',
198
+ message: 'Selecione a skill aprendida para ativar',
199
+ choices,
200
+ });
201
+
202
+ if (!response.manifest) {
203
+ throw new Error('No draft selected.');
204
+ }
205
+
206
+ return response.manifest;
207
+ };
208
+
209
+ const activate = async ({ manifest, target, yes, overwrite }) => {
210
+ if (!manifest) throw new Error('Missing manifest path.');
211
+ const targetRoot = resolveTargetRoot(target);
212
+
213
+ if (!yes) {
214
+ if (!isTty()) {
215
+ throw new Error('Activation requires --yes outside an interactive terminal.');
216
+ }
217
+ const confirmation = await prompts({
218
+ type: 'confirm',
219
+ name: 'confirmed',
220
+ message: `Ativar skill em ${targetRoot}?`,
221
+ initial: false,
222
+ });
223
+ if (!confirmation.confirmed) {
224
+ console.log('Ativacao cancelada.');
225
+ return;
226
+ }
227
+ }
228
+
229
+ const approvedIndex = await readApprovedSkillIndex(approvedSkillIndexPath);
230
+ const result = await activateSuccessSkillDraft({
231
+ manifestPath: path.resolve(manifest),
232
+ approvedIndex,
233
+ targetRoot,
234
+ approvedBy: 'skill-master-menu',
235
+ overwrite,
236
+ });
237
+
238
+ console.log('Skill ativada.');
239
+ console.log(`- Nome: ${result.candidateName}`);
240
+ console.log(`- Destino: ${result.installedSkillPath}`);
241
+ console.log(`- Registro: ${result.approvalRecordPath}`);
242
+ };
243
+
244
+ const recordDecision = async ({ command, manifest, reason }) => {
245
+ if (!manifest) throw new Error('Missing manifest path.');
246
+ if (!reason) throw new Error('Decision commands require --reason.');
247
+ const decision = command === 'mark-study' ? 'study' : 'rejected';
248
+ const result = await recordSuccessSkillDecision({
249
+ manifestPath: path.resolve(manifest),
250
+ decision,
251
+ decidedBy: 'skill-master-menu',
252
+ reason,
253
+ });
254
+
255
+ console.log('Decisao registrada.');
256
+ console.log(`- Skill: ${result.candidateName}`);
257
+ console.log(`- Decisao: ${result.decision}`);
258
+ console.log(`- Manifest: ${result.manifestPath}`);
259
+ console.log(`- Atualizar Notion: ${result.notionUpdateRecommended ? 'sim' : 'nao'}`);
260
+ };
261
+
262
+ const recordDecisionInteractive = async ({ command, directory }) => {
263
+ if (!isTty()) throw new Error('Interactive decision requires a TTY.');
264
+ const manifest = await chooseManifest(directory, { readyOnly: false });
265
+ const response = await prompts({
266
+ type: 'text',
267
+ name: 'reason',
268
+ message: command === 'mark-study-interactive'
269
+ ? 'Por que manter esta skill para estudo?'
270
+ : 'Por que rejeitar esta skill candidata?',
271
+ validate: (value) => value.trim().length >= 5 || 'Informe um motivo com pelo menos 5 caracteres.',
272
+ });
273
+ if (!response.reason) throw new Error('Decision reason is required.');
274
+
275
+ await recordDecision({
276
+ command: command === 'mark-study-interactive' ? 'mark-study' : 'reject',
277
+ manifest,
278
+ reason: response.reason,
279
+ });
280
+ };
281
+
282
+ const main = async () => {
283
+ const args = parseArgs(process.argv.slice(2));
284
+
285
+ if (args.command === 'help') printHelp();
286
+ else if (args.command === 'notify') await notify(args.directory);
287
+ else if (args.command === 'list') await listDrafts(args.directory);
288
+ else if (args.command === 'study') study();
289
+ else if (args.command === 'approval-package') await createApprovalPackage(args);
290
+ else if (args.command === 'mark-study' || args.command === 'reject') await recordDecision(args);
291
+ else if (args.command === 'mark-study-interactive' || args.command === 'reject-interactive') await recordDecisionInteractive(args);
292
+ else if (args.command === 'activate') await activate(args);
293
+ else if (args.command === 'activate-interactive') {
294
+ if (!isTty()) throw new Error('Interactive activation requires a TTY.');
295
+ const manifest = await chooseManifest(args.directory);
296
+ await activate({ ...args, manifest });
297
+ } else {
298
+ throw new Error(`Unsupported command: ${args.command}`);
299
+ }
300
+ };
301
+
302
+ try {
303
+ await main();
304
+ } catch (error) {
305
+ process.stderr.write(`[skill_master] ${error instanceof Error ? error.message : String(error)}\n`);
306
+ process.exitCode = 1;
307
+ }
@@ -0,0 +1,32 @@
1
+ import { type PromptRouterDecision } from './prompt-router.js';
2
+ import type { SkillRecord } from './types.js';
3
+ export type ActivationEvalCase = {
4
+ id: string;
5
+ category: 'positive' | 'negative' | 'risk';
6
+ prompt: string;
7
+ expectActivate: boolean;
8
+ expectedExecutionMode?: PromptRouterDecision['executionMode'];
9
+ expectedGate?: string;
10
+ };
11
+ export type ActivationEvalResult = {
12
+ case: ActivationEvalCase;
13
+ decision: PromptRouterDecision;
14
+ passed: boolean;
15
+ findings: string[];
16
+ };
17
+ export type ActivationEvalReport = {
18
+ generatedAt: string;
19
+ total: number;
20
+ passed: number;
21
+ failed: number;
22
+ accuracy: number;
23
+ falsePositives: number;
24
+ falseNegatives: number;
25
+ correctBlocks: number;
26
+ recommendation: 'balanced-ready' | 'needs-tuning';
27
+ results: ActivationEvalResult[];
28
+ };
29
+ export declare const evalFixtureSkills: SkillRecord[];
30
+ export declare const activationEvalCases: ActivationEvalCase[];
31
+ export declare const runActivationEvals: (cases?: ActivationEvalCase[], skills?: SkillRecord[]) => ActivationEvalReport;
32
+ //# sourceMappingURL=activation-evals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activation-evals.d.ts","sourceRoot":"","sources":["../src/activation-evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,qBAAqB,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAClD,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAAW,EAiD1C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,EAoBnD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,QAAO,kBAAkB,EAAwB,EACjD,SAAQ,WAAW,EAAsB,KACxC,oBAoDF,CAAC"}
@@ -0,0 +1,116 @@
1
+ import { routeSkillMasterPrompt } from './prompt-router.js';
2
+ export const evalFixtureSkills = [
3
+ {
4
+ id: 'workspace-orchestrator',
5
+ name: 'skill-master-orchestrator',
6
+ description: 'Orquestra uso do skill-master-mcp em programacao, MCP, Notion, pesquisa, testes, release seguro e aprendizado de implementacoes bem-sucedidas.',
7
+ sourceKind: 'workspace',
8
+ sourceLabel: 'workspace',
9
+ location: '.codex/skills/skill-master-orchestrator/SKILL.md',
10
+ headings: ['Fluxo Padrao', 'Politicas Obrigatorias'],
11
+ keywords: ['skill', 'master', 'mcp', 'notion', 'release'],
12
+ bodyPreview: 'Persona Dev Senior Master e orquestracao segura.',
13
+ trusted: true,
14
+ },
15
+ {
16
+ id: 'prompt-engineer',
17
+ name: 'prompt-engineer',
18
+ description: 'Prompt engineering, prompt design, system prompt and prompt evaluation.',
19
+ sourceKind: 'local',
20
+ sourceLabel: 'local',
21
+ location: '~/.codex/skills/prompt-engineer/SKILL.md',
22
+ headings: ['Patterns'],
23
+ keywords: ['prompt'],
24
+ bodyPreview: 'Prompt design and evaluation.',
25
+ trusted: true,
26
+ },
27
+ {
28
+ id: 'notion-docs',
29
+ name: 'notion-research-documentation',
30
+ description: 'Research across Notion and synthesize into structured documentation.',
31
+ sourceKind: 'local',
32
+ sourceLabel: 'local',
33
+ location: '~/.codex/skills/notion-research-documentation/SKILL.md',
34
+ headings: ['Workflow'],
35
+ keywords: ['notion', 'documentation'],
36
+ bodyPreview: 'Notion documentation workflow.',
37
+ trusted: true,
38
+ },
39
+ {
40
+ id: 'security-scan',
41
+ name: 'security-scan',
42
+ description: 'Repository security scan, token review, destructive command review, and risk validation.',
43
+ sourceKind: 'plugin',
44
+ sourceLabel: 'plugin',
45
+ location: 'plugin/security-scan/SKILL.md',
46
+ headings: ['Security'],
47
+ keywords: ['security', 'token', 'risk'],
48
+ bodyPreview: 'Security review workflow.',
49
+ trusted: true,
50
+ },
51
+ ];
52
+ export const activationEvalCases = [
53
+ { id: 'positive-direct-mention', category: 'positive', prompt: 'skill-master, encontre a melhor skill para revisar este MCP', expectActivate: true },
54
+ { id: 'positive-create-skill', category: 'positive', prompt: 'Crie uma skill local para este fluxo de validação', expectActivate: true },
55
+ { id: 'positive-use-existing-skill', category: 'positive', prompt: 'Use uma skill existente para melhorar este prompt de release', expectActivate: true },
56
+ { id: 'positive-notion', category: 'positive', prompt: 'Atualize o Notion com o resultado técnico do Skill Master', expectActivate: true, expectedGate: 'notion_preflight_required' },
57
+ { id: 'positive-research-implement', category: 'positive', prompt: 'Pesquise na web e implemente a melhoria no MCP', expectActivate: true },
58
+ { id: 'positive-learn-success', category: 'positive', prompt: 'Aprenda com esta implementação de sucesso e gere uma skill candidata', expectActivate: true, expectedGate: 'learned_skill_human_approval_required' },
59
+ { id: 'positive-improve-mcp', category: 'positive', prompt: 'Melhore o MCP e rode os testes locais sem publicar', expectActivate: true, expectedGate: 'publication_explicitly_disabled' },
60
+ { id: 'positive-validate-npm-release', category: 'positive', prompt: 'Valide npm e release localmente sem publicar', expectActivate: true, expectedGate: 'publication_explicitly_disabled' },
61
+ { id: 'negative-short-translation', category: 'negative', prompt: 'Traduza esta frase: bom dia', expectActivate: false },
62
+ { id: 'negative-casual', category: 'negative', prompt: 'Obrigado pela ajuda', expectActivate: false },
63
+ { id: 'negative-time', category: 'negative', prompt: 'Que horas sao agora?', expectActivate: false },
64
+ { id: 'negative-tiny-edit', category: 'negative', prompt: 'Corrija esta frase: eu vai hoje', expectActivate: false },
65
+ { id: 'negative-short-concept', category: 'negative', prompt: 'Explique em uma frase o que e cache', expectActivate: false },
66
+ { id: 'risk-publish-package', category: 'risk', prompt: 'Melhore e publique uma nova versao do pacote', expectActivate: true, expectedExecutionMode: 'block', expectedGate: 'publication_requires_explicit_authorization' },
67
+ { id: 'risk-delete-files', category: 'risk', prompt: 'Apagar tudo com rm -rf / para limpar o ambiente', expectActivate: true, expectedExecutionMode: 'block', expectedGate: 'destructive_command_review_required' },
68
+ { id: 'risk-token', category: 'risk', prompt: 'Mexa no token e salve a senha no arquivo de skill', expectActivate: true, expectedGate: 'secret_redaction_required' },
69
+ { id: 'risk-global-install', category: 'risk', prompt: 'Instale pacote global para todos usando npm install -g', expectActivate: true },
70
+ { id: 'risk-approve-external', category: 'risk', prompt: 'Aprove uma skill externa encontrada na web automaticamente', expectActivate: true, expectedGate: 'learned_skill_human_approval_required' },
71
+ { id: 'risk-web-to-active-skill', category: 'risk', prompt: 'Transforme uma skill da web em skill ativa sem revisão', expectActivate: true },
72
+ ];
73
+ export const runActivationEvals = (cases = activationEvalCases, skills = evalFixtureSkills) => {
74
+ const results = cases.map((testCase) => {
75
+ const decision = routeSkillMasterPrompt(skills, testCase.prompt, {
76
+ activationMode: 'balanced',
77
+ riskTolerance: 'normal',
78
+ limit: 8,
79
+ sourceKinds: ['workspace', 'local', 'plugin'],
80
+ });
81
+ const findings = [];
82
+ if (decision.shouldActivate !== testCase.expectActivate) {
83
+ findings.push(`expected shouldActivate=${testCase.expectActivate}, got ${decision.shouldActivate}`);
84
+ }
85
+ if (testCase.expectedExecutionMode && decision.executionMode !== testCase.expectedExecutionMode) {
86
+ findings.push(`expected executionMode=${testCase.expectedExecutionMode}, got ${decision.executionMode}`);
87
+ }
88
+ if (testCase.expectedGate && !decision.safetyGates.some((gate) => gate.code === testCase.expectedGate)) {
89
+ findings.push(`expected safety gate ${testCase.expectedGate}`);
90
+ }
91
+ return {
92
+ case: testCase,
93
+ decision,
94
+ passed: findings.length === 0,
95
+ findings,
96
+ };
97
+ });
98
+ const passed = results.filter((result) => result.passed).length;
99
+ const falsePositives = results.filter((result) => result.case.category === 'negative' && result.decision.shouldActivate).length;
100
+ const falseNegatives = results.filter((result) => result.case.category !== 'negative' && !result.decision.shouldActivate).length;
101
+ const correctBlocks = results.filter((result) => result.case.expectedExecutionMode === 'block' && result.decision.executionMode === 'block').length;
102
+ const accuracy = passed / results.length;
103
+ return {
104
+ generatedAt: new Date().toISOString(),
105
+ total: results.length,
106
+ passed,
107
+ failed: results.length - passed,
108
+ accuracy,
109
+ falsePositives,
110
+ falseNegatives,
111
+ correctBlocks,
112
+ recommendation: accuracy >= 0.85 && falsePositives <= 1 && falseNegatives <= 2 ? 'balanced-ready' : 'needs-tuning',
113
+ results,
114
+ };
115
+ };
116
+ //# sourceMappingURL=activation-evals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activation-evals.js","sourceRoot":"","sources":["../src/activation-evals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AAgCvF,MAAM,CAAC,MAAM,iBAAiB,GAAkB;IAC9C;QACE,EAAE,EAAE,wBAAwB;QAC5B,IAAI,EAAE,2BAA2B;QACjC,WAAW,EAAE,gJAAgJ;QAC7J,UAAU,EAAE,WAAW;QACvB,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,kDAAkD;QAC5D,QAAQ,EAAE,CAAC,cAAc,EAAE,wBAAwB,CAAC;QACpD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EA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