decibel-tools-mcp 1.0.6 → 1.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.
- package/README.md +35 -3
- package/dist/server.js +0 -0
- package/dist/tools/corpus/index.d.ts +5 -0
- package/dist/tools/corpus/index.d.ts.map +1 -0
- package/dist/tools/corpus/index.js +95 -0
- package/dist/tools/corpus/index.js.map +1 -0
- package/dist/tools/corpus.d.ts +33 -0
- package/dist/tools/corpus.d.ts.map +1 -0
- package/dist/tools/corpus.js +180 -0
- package/dist/tools/corpus.js.map +1 -0
- package/dist/tools/designer/index.d.ts +4 -0
- package/dist/tools/designer/index.d.ts.map +1 -1
- package/dist/tools/designer/index.js +177 -1
- package/dist/tools/designer/index.js.map +1 -1
- package/dist/tools/designer.d.ts +81 -0
- package/dist/tools/designer.d.ts.map +1 -1
- package/dist/tools/designer.js +304 -0
- package/dist/tools/designer.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/registry.d.ts +3 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +189 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/toolsIndex.d.ts +5 -0
- package/dist/tools/toolsIndex.d.ts.map +1 -0
- package/dist/tools/toolsIndex.js +37 -0
- package/dist/tools/toolsIndex.js.map +1 -0
- package/dist/tools/vector/index.d.ts +9 -0
- package/dist/tools/vector/index.d.ts.map +1 -0
- package/dist/tools/vector/index.js +299 -0
- package/dist/tools/vector/index.js.map +1 -0
- package/dist/tools/vector.d.ts +153 -0
- package/dist/tools/vector.d.ts.map +1 -0
- package/dist/tools/vector.js +395 -0
- package/dist/tools/vector.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/** Supported AI coding agent types */
|
|
2
|
+
export type AgentType = 'claude-code' | 'cursor' | 'replit' | 'chatgpt' | 'custom';
|
|
3
|
+
/** Information about the AI agent generating events */
|
|
4
|
+
export interface AgentInfo {
|
|
5
|
+
type: AgentType;
|
|
6
|
+
version?: string;
|
|
7
|
+
}
|
|
8
|
+
/** All possible event types */
|
|
9
|
+
export type EventType = 'prompt_received' | 'plan_proposed' | 'assumption_made' | 'clarifying_question' | 'command_ran' | 'file_touched' | 'test_result' | 'backtrack' | 'error' | 'user_correction' | 'run_completed';
|
|
10
|
+
/** Base event structure */
|
|
11
|
+
export interface BaseEvent {
|
|
12
|
+
ts: string;
|
|
13
|
+
run_id: string;
|
|
14
|
+
agent: AgentInfo;
|
|
15
|
+
type: EventType;
|
|
16
|
+
}
|
|
17
|
+
/** Full event with type-specific payload */
|
|
18
|
+
export interface VectorEvent extends BaseEvent {
|
|
19
|
+
payload?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
/** Intent specification from prompt analysis */
|
|
22
|
+
export interface PromptIntent {
|
|
23
|
+
goal?: string;
|
|
24
|
+
scope?: string[];
|
|
25
|
+
non_goals?: string[];
|
|
26
|
+
constraints?: string[];
|
|
27
|
+
acceptance?: string[];
|
|
28
|
+
risk_posture?: 'safe' | 'moderate' | 'aggressive';
|
|
29
|
+
}
|
|
30
|
+
/** Prompt specification stored with each run */
|
|
31
|
+
export interface PromptSpec {
|
|
32
|
+
run_id: string;
|
|
33
|
+
agent: AgentInfo;
|
|
34
|
+
raw_prompt: string;
|
|
35
|
+
intent?: PromptIntent;
|
|
36
|
+
anchors?: {
|
|
37
|
+
adrs?: string[];
|
|
38
|
+
memento_packs?: string[];
|
|
39
|
+
};
|
|
40
|
+
created_at: string;
|
|
41
|
+
}
|
|
42
|
+
/** Run summary information */
|
|
43
|
+
export interface RunInfo {
|
|
44
|
+
run_id: string;
|
|
45
|
+
agent: AgentInfo;
|
|
46
|
+
created_at: string;
|
|
47
|
+
completed_at?: string;
|
|
48
|
+
event_count: number;
|
|
49
|
+
success?: boolean;
|
|
50
|
+
summary?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Inference load score breakdown */
|
|
53
|
+
export interface ScoreBreakdown {
|
|
54
|
+
nonGoals?: number;
|
|
55
|
+
acceptance?: number;
|
|
56
|
+
constraints?: number;
|
|
57
|
+
scopeBounds?: number;
|
|
58
|
+
ambiguousVerbs?: number;
|
|
59
|
+
undefinedNouns?: number;
|
|
60
|
+
unguardedRiskAreas?: number;
|
|
61
|
+
}
|
|
62
|
+
/** Suggestion for reducing inference load */
|
|
63
|
+
export interface Suggestion {
|
|
64
|
+
type: 'add_non_goals' | 'add_acceptance' | 'add_constraints' | 'add_scope' | 'clarify_verbs' | 'bind_nouns' | 'guard_risk';
|
|
65
|
+
message: string;
|
|
66
|
+
priority: 'high' | 'medium' | 'low';
|
|
67
|
+
}
|
|
68
|
+
/** Complete inference score result */
|
|
69
|
+
export interface InferenceScore {
|
|
70
|
+
score: number;
|
|
71
|
+
breakdown: ScoreBreakdown;
|
|
72
|
+
suggestions: Suggestion[];
|
|
73
|
+
risk_level: 'low' | 'medium' | 'high' | 'critical';
|
|
74
|
+
}
|
|
75
|
+
export interface CreateRunInput {
|
|
76
|
+
projectId?: string;
|
|
77
|
+
project_id?: string;
|
|
78
|
+
agent: AgentInfo;
|
|
79
|
+
raw_prompt: string;
|
|
80
|
+
intent?: PromptIntent;
|
|
81
|
+
}
|
|
82
|
+
export interface LogEventInput {
|
|
83
|
+
projectId?: string;
|
|
84
|
+
project_id?: string;
|
|
85
|
+
run_id: string;
|
|
86
|
+
type: EventType;
|
|
87
|
+
payload?: Record<string, any>;
|
|
88
|
+
}
|
|
89
|
+
export interface CompleteRunInput {
|
|
90
|
+
projectId?: string;
|
|
91
|
+
project_id?: string;
|
|
92
|
+
run_id: string;
|
|
93
|
+
success: boolean;
|
|
94
|
+
summary?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ListRunsInput {
|
|
97
|
+
projectId?: string;
|
|
98
|
+
project_id?: string;
|
|
99
|
+
limit?: number;
|
|
100
|
+
agent_type?: AgentType;
|
|
101
|
+
}
|
|
102
|
+
export interface GetRunInput {
|
|
103
|
+
projectId?: string;
|
|
104
|
+
project_id?: string;
|
|
105
|
+
run_id: string;
|
|
106
|
+
include_events?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export interface ScorePromptInput {
|
|
109
|
+
prompt: string;
|
|
110
|
+
projectId?: string;
|
|
111
|
+
project_id?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Create a new run for an agent session
|
|
115
|
+
*/
|
|
116
|
+
export declare function createRun(input: CreateRunInput): Promise<{
|
|
117
|
+
run_id: string;
|
|
118
|
+
path: string;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Log an event to an existing run
|
|
122
|
+
*/
|
|
123
|
+
export declare function logEvent(input: LogEventInput): Promise<{
|
|
124
|
+
success: true;
|
|
125
|
+
event_count: number;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Complete a run with summary
|
|
129
|
+
*/
|
|
130
|
+
export declare function completeRun(input: CompleteRunInput): Promise<{
|
|
131
|
+
success: true;
|
|
132
|
+
run_id: string;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* List runs for a project
|
|
136
|
+
*/
|
|
137
|
+
export declare function listRuns(input: ListRunsInput): Promise<{
|
|
138
|
+
runs: RunInfo[];
|
|
139
|
+
}>;
|
|
140
|
+
/**
|
|
141
|
+
* Get details of a specific run
|
|
142
|
+
*/
|
|
143
|
+
export declare function getRun(input: GetRunInput): Promise<{
|
|
144
|
+
prompt: PromptSpec;
|
|
145
|
+
events?: VectorEvent[];
|
|
146
|
+
event_count: number;
|
|
147
|
+
completed: boolean;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Calculate inference load score for a prompt
|
|
151
|
+
*/
|
|
152
|
+
export declare function scorePrompt(input: ScorePromptInput): InferenceScore;
|
|
153
|
+
//# sourceMappingURL=vector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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Q,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAwCpG;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAsDrG;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,CAuEjF;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC;IACxD,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC,CA+CD;AAMD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,cAAc,CAwGnE"}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Vector Domain Logic
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Core implementation for Vector (AI session tracking and analysis).
|
|
5
|
+
// Manages runs, events, and inference scoring.
|
|
6
|
+
// ============================================================================
|
|
7
|
+
import fs from 'fs/promises';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { resolveProjectPaths } from '../projectRegistry.js';
|
|
10
|
+
import { log } from '../config.js';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Constants
|
|
13
|
+
// ============================================================================
|
|
14
|
+
const VALID_AGENT_TYPES = ['claude-code', 'cursor', 'replit', 'chatgpt', 'custom'];
|
|
15
|
+
const VALID_EVENT_TYPES = [
|
|
16
|
+
'prompt_received', 'plan_proposed', 'assumption_made', 'clarifying_question',
|
|
17
|
+
'command_ran', 'file_touched', 'test_result', 'backtrack', 'error',
|
|
18
|
+
'user_correction', 'run_completed'
|
|
19
|
+
];
|
|
20
|
+
// Inference scoring constants
|
|
21
|
+
const MISSING_NON_GOALS_POINTS = 15;
|
|
22
|
+
const MISSING_ACCEPTANCE_POINTS = 15;
|
|
23
|
+
const MISSING_CONSTRAINTS_POINTS = 10;
|
|
24
|
+
const MISSING_SCOPE_BOUNDS_POINTS = 10;
|
|
25
|
+
const AMBIGUOUS_VERBS_POINTS = 10;
|
|
26
|
+
const UNDEFINED_NOUN_POINTS = 5;
|
|
27
|
+
const UNGUARDED_RISK_AREA_POINTS = 10;
|
|
28
|
+
const MAX_SCORE = 100;
|
|
29
|
+
// Detection patterns
|
|
30
|
+
const AMBIGUOUS_VERBS = ['refactor', 'clean up', 'cleanup', 'improve', 'optimize', 'fix', 'update', 'enhance'];
|
|
31
|
+
const RISK_AREAS = ['database', 'db', 'auth', 'authentication', 'payment', 'migration', 'security', 'password', 'credential', 'secret'];
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// Helpers
|
|
34
|
+
// ============================================================================
|
|
35
|
+
function generateRunId() {
|
|
36
|
+
const now = new Date();
|
|
37
|
+
return `RUN-${now.toISOString().replace(/[:.]/g, '-')}`;
|
|
38
|
+
}
|
|
39
|
+
function getRunsDir(projectId) {
|
|
40
|
+
const resolved = resolveProjectPaths(projectId);
|
|
41
|
+
return resolved.subPath('runs');
|
|
42
|
+
}
|
|
43
|
+
async function ensureDir(dir) {
|
|
44
|
+
try {
|
|
45
|
+
await fs.mkdir(dir, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
// Ignore if exists
|
|
49
|
+
const error = err;
|
|
50
|
+
if (error.code !== 'EEXIST')
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function fileExists(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
await fs.access(filePath);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Run Management
|
|
65
|
+
// ============================================================================
|
|
66
|
+
/**
|
|
67
|
+
* Create a new run for an agent session
|
|
68
|
+
*/
|
|
69
|
+
export async function createRun(input) {
|
|
70
|
+
const projectId = input.projectId || input.project_id;
|
|
71
|
+
const runsDir = getRunsDir(projectId);
|
|
72
|
+
// Validate agent type
|
|
73
|
+
if (!VALID_AGENT_TYPES.includes(input.agent.type)) {
|
|
74
|
+
throw new Error(`Invalid agent type: ${input.agent.type}. Must be one of: ${VALID_AGENT_TYPES.join(', ')}`);
|
|
75
|
+
}
|
|
76
|
+
const run_id = generateRunId();
|
|
77
|
+
const runDir = path.join(runsDir, run_id);
|
|
78
|
+
await ensureDir(runDir);
|
|
79
|
+
// Create prompt.json
|
|
80
|
+
const promptSpec = {
|
|
81
|
+
run_id,
|
|
82
|
+
agent: input.agent,
|
|
83
|
+
raw_prompt: input.raw_prompt,
|
|
84
|
+
intent: input.intent,
|
|
85
|
+
created_at: new Date().toISOString(),
|
|
86
|
+
};
|
|
87
|
+
await fs.writeFile(path.join(runDir, 'prompt.json'), JSON.stringify(promptSpec, null, 2));
|
|
88
|
+
// Initialize events.jsonl (empty)
|
|
89
|
+
await fs.writeFile(path.join(runDir, 'events.jsonl'), '');
|
|
90
|
+
// Log initial prompt_received event
|
|
91
|
+
const initialEvent = {
|
|
92
|
+
ts: new Date().toISOString(),
|
|
93
|
+
run_id,
|
|
94
|
+
agent: input.agent,
|
|
95
|
+
type: 'prompt_received',
|
|
96
|
+
payload: { prompt: input.raw_prompt },
|
|
97
|
+
};
|
|
98
|
+
await fs.appendFile(path.join(runDir, 'events.jsonl'), JSON.stringify(initialEvent) + '\n');
|
|
99
|
+
log(`Vector: Created run ${run_id}`);
|
|
100
|
+
return { run_id, path: runDir };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Log an event to an existing run
|
|
104
|
+
*/
|
|
105
|
+
export async function logEvent(input) {
|
|
106
|
+
const projectId = input.projectId || input.project_id;
|
|
107
|
+
const runsDir = getRunsDir(projectId);
|
|
108
|
+
const runDir = path.join(runsDir, input.run_id);
|
|
109
|
+
// Validate run exists
|
|
110
|
+
if (!await fileExists(runDir)) {
|
|
111
|
+
throw new Error(`Run not found: ${input.run_id}`);
|
|
112
|
+
}
|
|
113
|
+
// Validate event type
|
|
114
|
+
if (!VALID_EVENT_TYPES.includes(input.type)) {
|
|
115
|
+
throw new Error(`Invalid event type: ${input.type}. Must be one of: ${VALID_EVENT_TYPES.join(', ')}`);
|
|
116
|
+
}
|
|
117
|
+
// Read prompt.json to get agent info
|
|
118
|
+
const promptPath = path.join(runDir, 'prompt.json');
|
|
119
|
+
const promptContent = await fs.readFile(promptPath, 'utf-8');
|
|
120
|
+
const promptSpec = JSON.parse(promptContent);
|
|
121
|
+
// Create event
|
|
122
|
+
const event = {
|
|
123
|
+
ts: new Date().toISOString(),
|
|
124
|
+
run_id: input.run_id,
|
|
125
|
+
agent: promptSpec.agent,
|
|
126
|
+
type: input.type,
|
|
127
|
+
payload: input.payload,
|
|
128
|
+
};
|
|
129
|
+
// Append to events.jsonl
|
|
130
|
+
const eventsPath = path.join(runDir, 'events.jsonl');
|
|
131
|
+
await fs.appendFile(eventsPath, JSON.stringify(event) + '\n');
|
|
132
|
+
// Count events
|
|
133
|
+
const eventsContent = await fs.readFile(eventsPath, 'utf-8');
|
|
134
|
+
const eventCount = eventsContent.trim().split('\n').filter(Boolean).length;
|
|
135
|
+
log(`Vector: Logged ${input.type} event to ${input.run_id}`);
|
|
136
|
+
return { success: true, event_count: eventCount };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Complete a run with summary
|
|
140
|
+
*/
|
|
141
|
+
export async function completeRun(input) {
|
|
142
|
+
const projectId = input.projectId || input.project_id;
|
|
143
|
+
const runsDir = getRunsDir(projectId);
|
|
144
|
+
const runDir = path.join(runsDir, input.run_id);
|
|
145
|
+
// Validate run exists
|
|
146
|
+
if (!await fileExists(runDir)) {
|
|
147
|
+
throw new Error(`Run not found: ${input.run_id}`);
|
|
148
|
+
}
|
|
149
|
+
// Read prompt.json to get agent info
|
|
150
|
+
const promptPath = path.join(runDir, 'prompt.json');
|
|
151
|
+
const promptContent = await fs.readFile(promptPath, 'utf-8');
|
|
152
|
+
const promptSpec = JSON.parse(promptContent);
|
|
153
|
+
// Log run_completed event
|
|
154
|
+
const completedEvent = {
|
|
155
|
+
ts: new Date().toISOString(),
|
|
156
|
+
run_id: input.run_id,
|
|
157
|
+
agent: promptSpec.agent,
|
|
158
|
+
type: 'run_completed',
|
|
159
|
+
payload: {
|
|
160
|
+
success: input.success,
|
|
161
|
+
summary: input.summary,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
const eventsPath = path.join(runDir, 'events.jsonl');
|
|
165
|
+
await fs.appendFile(eventsPath, JSON.stringify(completedEvent) + '\n');
|
|
166
|
+
// Create summary.md
|
|
167
|
+
const summaryContent = `# Run Summary: ${input.run_id}
|
|
168
|
+
|
|
169
|
+
**Agent**: ${promptSpec.agent.type}${promptSpec.agent.version ? ` v${promptSpec.agent.version}` : ''}
|
|
170
|
+
**Started**: ${promptSpec.created_at}
|
|
171
|
+
**Completed**: ${completedEvent.ts}
|
|
172
|
+
**Status**: ${input.success ? 'Success' : 'Failed'}
|
|
173
|
+
|
|
174
|
+
## Original Prompt
|
|
175
|
+
|
|
176
|
+
\`\`\`
|
|
177
|
+
${promptSpec.raw_prompt}
|
|
178
|
+
\`\`\`
|
|
179
|
+
|
|
180
|
+
## Summary
|
|
181
|
+
|
|
182
|
+
${input.summary || 'No summary provided.'}
|
|
183
|
+
`;
|
|
184
|
+
await fs.writeFile(path.join(runDir, 'summary.md'), summaryContent);
|
|
185
|
+
log(`Vector: Completed run ${input.run_id}`);
|
|
186
|
+
return { success: true, run_id: input.run_id };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* List runs for a project
|
|
190
|
+
*/
|
|
191
|
+
export async function listRuns(input) {
|
|
192
|
+
const projectId = input.projectId || input.project_id;
|
|
193
|
+
const runsDir = getRunsDir(projectId);
|
|
194
|
+
// Ensure runs dir exists
|
|
195
|
+
await ensureDir(runsDir);
|
|
196
|
+
const entries = await fs.readdir(runsDir, { withFileTypes: true });
|
|
197
|
+
const runDirs = entries
|
|
198
|
+
.filter(e => e.isDirectory() && e.name.startsWith('RUN-'))
|
|
199
|
+
.map(e => e.name);
|
|
200
|
+
// Sort by run ID (which includes timestamp)
|
|
201
|
+
runDirs.sort().reverse();
|
|
202
|
+
const limit = input.limit || 20;
|
|
203
|
+
const runs = [];
|
|
204
|
+
for (const run_id of runDirs.slice(0, limit)) {
|
|
205
|
+
try {
|
|
206
|
+
const runDir = path.join(runsDir, run_id);
|
|
207
|
+
const promptPath = path.join(runDir, 'prompt.json');
|
|
208
|
+
const eventsPath = path.join(runDir, 'events.jsonl');
|
|
209
|
+
if (!await fileExists(promptPath))
|
|
210
|
+
continue;
|
|
211
|
+
const promptContent = await fs.readFile(promptPath, 'utf-8');
|
|
212
|
+
const promptSpec = JSON.parse(promptContent);
|
|
213
|
+
// Filter by agent type if specified
|
|
214
|
+
if (input.agent_type && promptSpec.agent.type !== input.agent_type) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
// Count events and check for completion
|
|
218
|
+
let eventCount = 0;
|
|
219
|
+
let completed_at;
|
|
220
|
+
let success;
|
|
221
|
+
let summary;
|
|
222
|
+
if (await fileExists(eventsPath)) {
|
|
223
|
+
const eventsContent = await fs.readFile(eventsPath, 'utf-8');
|
|
224
|
+
const lines = eventsContent.trim().split('\n').filter(Boolean);
|
|
225
|
+
eventCount = lines.length;
|
|
226
|
+
// Check last event for completion
|
|
227
|
+
if (lines.length > 0) {
|
|
228
|
+
const lastEvent = JSON.parse(lines[lines.length - 1]);
|
|
229
|
+
if (lastEvent.type === 'run_completed') {
|
|
230
|
+
completed_at = lastEvent.ts;
|
|
231
|
+
success = lastEvent.payload?.success;
|
|
232
|
+
summary = lastEvent.payload?.summary;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
runs.push({
|
|
237
|
+
run_id,
|
|
238
|
+
agent: promptSpec.agent,
|
|
239
|
+
created_at: promptSpec.created_at,
|
|
240
|
+
completed_at,
|
|
241
|
+
event_count: eventCount,
|
|
242
|
+
success,
|
|
243
|
+
summary,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
log(`Vector: Error reading run ${run_id}: ${err}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return { runs };
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get details of a specific run
|
|
254
|
+
*/
|
|
255
|
+
export async function getRun(input) {
|
|
256
|
+
const projectId = input.projectId || input.project_id;
|
|
257
|
+
const runsDir = getRunsDir(projectId);
|
|
258
|
+
const runDir = path.join(runsDir, input.run_id);
|
|
259
|
+
// Validate run exists
|
|
260
|
+
if (!await fileExists(runDir)) {
|
|
261
|
+
throw new Error(`Run not found: ${input.run_id}`);
|
|
262
|
+
}
|
|
263
|
+
// Read prompt
|
|
264
|
+
const promptPath = path.join(runDir, 'prompt.json');
|
|
265
|
+
const promptContent = await fs.readFile(promptPath, 'utf-8');
|
|
266
|
+
const prompt = JSON.parse(promptContent);
|
|
267
|
+
// Read events
|
|
268
|
+
const eventsPath = path.join(runDir, 'events.jsonl');
|
|
269
|
+
let events = [];
|
|
270
|
+
let completed = false;
|
|
271
|
+
if (await fileExists(eventsPath)) {
|
|
272
|
+
const eventsContent = await fs.readFile(eventsPath, 'utf-8');
|
|
273
|
+
const lines = eventsContent.trim().split('\n').filter(Boolean);
|
|
274
|
+
events = lines.map(line => JSON.parse(line));
|
|
275
|
+
// Check if completed
|
|
276
|
+
if (events.length > 0 && events[events.length - 1].type === 'run_completed') {
|
|
277
|
+
completed = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const result = {
|
|
281
|
+
prompt,
|
|
282
|
+
event_count: events.length,
|
|
283
|
+
completed,
|
|
284
|
+
};
|
|
285
|
+
if (input.include_events) {
|
|
286
|
+
result.events = events;
|
|
287
|
+
}
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
// ============================================================================
|
|
291
|
+
// Inference Scoring
|
|
292
|
+
// ============================================================================
|
|
293
|
+
/**
|
|
294
|
+
* Calculate inference load score for a prompt
|
|
295
|
+
*/
|
|
296
|
+
export function scorePrompt(input) {
|
|
297
|
+
const prompt = input.prompt.toLowerCase();
|
|
298
|
+
const breakdown = {};
|
|
299
|
+
let totalScore = 0;
|
|
300
|
+
const suggestions = [];
|
|
301
|
+
// Check for non-goals
|
|
302
|
+
if (!prompt.includes('non-goal') && !prompt.includes('do not') && !prompt.includes("don't") && !prompt.includes('avoid')) {
|
|
303
|
+
breakdown.nonGoals = MISSING_NON_GOALS_POINTS;
|
|
304
|
+
totalScore += MISSING_NON_GOALS_POINTS;
|
|
305
|
+
suggestions.push({
|
|
306
|
+
type: 'add_non_goals',
|
|
307
|
+
message: 'Add explicit non-goals to prevent scope creep (e.g., "Do NOT refactor unrelated code")',
|
|
308
|
+
priority: 'high',
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
// Check for acceptance criteria
|
|
312
|
+
if (!prompt.includes('accept') && !prompt.includes('success') && !prompt.includes('done when') && !prompt.includes('complete when')) {
|
|
313
|
+
breakdown.acceptance = MISSING_ACCEPTANCE_POINTS;
|
|
314
|
+
totalScore += MISSING_ACCEPTANCE_POINTS;
|
|
315
|
+
suggestions.push({
|
|
316
|
+
type: 'add_acceptance',
|
|
317
|
+
message: 'Add acceptance criteria (e.g., "Done when tests pass and API returns 200")',
|
|
318
|
+
priority: 'high',
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
// Check for constraints
|
|
322
|
+
if (!prompt.includes('constraint') && !prompt.includes('must') && !prompt.includes('require') && !prompt.includes('only')) {
|
|
323
|
+
breakdown.constraints = MISSING_CONSTRAINTS_POINTS;
|
|
324
|
+
totalScore += MISSING_CONSTRAINTS_POINTS;
|
|
325
|
+
suggestions.push({
|
|
326
|
+
type: 'add_constraints',
|
|
327
|
+
message: 'Add constraints (e.g., "Must maintain backward compatibility")',
|
|
328
|
+
priority: 'medium',
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
// Check for scope bounds (file/module hints)
|
|
332
|
+
const hasFilePath = /\.(ts|js|py|go|rs|java|tsx|jsx|vue|svelte|rb|php|swift|kt)/.test(prompt);
|
|
333
|
+
const hasModuleHint = /src\/|lib\/|components\/|services\/|utils\//.test(prompt);
|
|
334
|
+
if (!hasFilePath && !hasModuleHint) {
|
|
335
|
+
breakdown.scopeBounds = MISSING_SCOPE_BOUNDS_POINTS;
|
|
336
|
+
totalScore += MISSING_SCOPE_BOUNDS_POINTS;
|
|
337
|
+
suggestions.push({
|
|
338
|
+
type: 'add_scope',
|
|
339
|
+
message: 'Add scope bounds (e.g., "Only modify files in src/services/")',
|
|
340
|
+
priority: 'medium',
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// Check for ambiguous verbs
|
|
344
|
+
const foundAmbiguous = AMBIGUOUS_VERBS.filter(verb => {
|
|
345
|
+
const regex = new RegExp(`\\b${verb}\\b`, 'i');
|
|
346
|
+
return regex.test(prompt);
|
|
347
|
+
});
|
|
348
|
+
if (foundAmbiguous.length > 0) {
|
|
349
|
+
breakdown.ambiguousVerbs = AMBIGUOUS_VERBS_POINTS;
|
|
350
|
+
totalScore += AMBIGUOUS_VERBS_POINTS;
|
|
351
|
+
suggestions.push({
|
|
352
|
+
type: 'clarify_verbs',
|
|
353
|
+
message: `Clarify ambiguous verbs: "${foundAmbiguous.join('", "')}". Be specific about what changes to make.`,
|
|
354
|
+
priority: 'medium',
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
// Check for unguarded risk areas
|
|
358
|
+
const foundRiskAreas = RISK_AREAS.filter(area => {
|
|
359
|
+
const regex = new RegExp(`\\b${area}\\b`, 'i');
|
|
360
|
+
return regex.test(prompt);
|
|
361
|
+
});
|
|
362
|
+
if (foundRiskAreas.length > 0 && !prompt.includes('constraint') && !prompt.includes('do not') && !prompt.includes("don't")) {
|
|
363
|
+
breakdown.unguardedRiskAreas = UNGUARDED_RISK_AREA_POINTS;
|
|
364
|
+
totalScore += UNGUARDED_RISK_AREA_POINTS;
|
|
365
|
+
suggestions.push({
|
|
366
|
+
type: 'guard_risk',
|
|
367
|
+
message: `Add guardrails for risk areas: "${foundRiskAreas.join('", "')}". Specify what changes are allowed.`,
|
|
368
|
+
priority: 'high',
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
// Cap score
|
|
372
|
+
const cappedScore = Math.min(totalScore, MAX_SCORE);
|
|
373
|
+
// Determine risk level
|
|
374
|
+
let risk_level;
|
|
375
|
+
if (cappedScore <= 25)
|
|
376
|
+
risk_level = 'low';
|
|
377
|
+
else if (cappedScore <= 50)
|
|
378
|
+
risk_level = 'medium';
|
|
379
|
+
else if (cappedScore <= 75)
|
|
380
|
+
risk_level = 'high';
|
|
381
|
+
else
|
|
382
|
+
risk_level = 'critical';
|
|
383
|
+
// Sort suggestions by priority
|
|
384
|
+
suggestions.sort((a, b) => {
|
|
385
|
+
const order = { high: 0, medium: 1, low: 2 };
|
|
386
|
+
return order[a.priority] - order[b.priority];
|
|
387
|
+
});
|
|
388
|
+
return {
|
|
389
|
+
score: cappedScore,
|
|
390
|
+
breakdown,
|
|
391
|
+
suggestions,
|
|
392
|
+
risk_level,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=vector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../../src/tools/vector.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,sBAAsB;AACt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