devworkspace 0.3.3 → 0.4.1
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/CHANGELOG.md +53 -0
- package/README.md +220 -90
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.js +16 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.js +28 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/render.d.ts +2 -0
- package/dist/cli/render.js +10 -0
- package/dist/cli/render.js.map +1 -1
- package/dist/cli/run.js +62 -2
- package/dist/cli/run.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/protocol.d.ts +35 -0
- package/dist/mcp/protocol.js +175 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/server.d.ts +25 -0
- package/dist/mcp/server.js +163 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/setup.d.ts +54 -0
- package/dist/mcp/setup.js +288 -0
- package/dist/mcp/setup.js.map +1 -0
- package/dist/mcp/tools.d.ts +8 -0
- package/dist/mcp/tools.js +446 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/mcp/types.d.ts +80 -0
- package/dist/mcp/types.js +15 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/services/taskContext.js +204 -41
- package/dist/services/taskContext.js.map +1 -1
- package/docs/agents.md +32 -0
- package/docs/context-accuracy-report.md +60 -0
- package/docs/context-evaluation.md +170 -0
- package/docs/mcp.md +264 -0
- package/package.json +3 -1
|
@@ -16,14 +16,119 @@ export const CONTEXT_ROLES = ['explorer', 'tester', 'reviewer'];
|
|
|
16
16
|
export function isContextRole(v) {
|
|
17
17
|
return typeof v === 'string' && CONTEXT_ROLES.includes(v);
|
|
18
18
|
}
|
|
19
|
-
const STOP = new Set([
|
|
19
|
+
const STOP = new Set([
|
|
20
|
+
'the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'does', 'how',
|
|
21
|
+
'what', 'where', 'why', 'when', 'which', 'fix', 'add', 'bug', 'make', 'new',
|
|
22
|
+
'can', 'are', 'not', 'our', 'all', 'use', 'get', 'set', 'let', 'may'
|
|
23
|
+
]);
|
|
24
|
+
const WEAK_TERMS = new Set(['error', 'errors', 'check', 'checks', 'data', 'improve', 'update', 'run', 'test', 'handle', 'handling', 'code']);
|
|
25
|
+
const PATH_STRUCTURAL_TERMS = new Set([
|
|
26
|
+
'backend', 'frontend', 'service', 'services', 'controller', 'controllers',
|
|
27
|
+
'worker', 'workers', 'dto', 'dtos', 'src', 'modules', 'app', 'tests',
|
|
28
|
+
'unit', 'integration', 'test', 'spec', 'ts', 'tsx', 'js', 'jsx', 'json', 'md'
|
|
29
|
+
]);
|
|
20
30
|
const CLIP = 400;
|
|
21
31
|
const SECURITY_WORDS = /auth|tenant|permission|rbac|security|isolation|role|session|ownership/i;
|
|
22
32
|
const ISSUE_KEY = /^(?:issue|limit|known|bug|risk)/i;
|
|
23
33
|
/** Facts that describe the stack and layout; implementation-style tasks need them, a lookup question does not. */
|
|
24
34
|
const STACK_KEY = /^(?:stack\.|repo\.packages|repo\.monorepo|repo\.entry-points|convention|style|arch|pattern|testing)/i;
|
|
25
35
|
const BROAD_TYPES = ['FEATURE', 'REFACTOR', 'ARCHITECTURE', 'TESTING', 'PERFORMANCE', 'MAINTENANCE', 'RELEASE'];
|
|
26
|
-
|
|
36
|
+
/** Normalizes words by stripping standard English inflectional suffixes deterministically. */
|
|
37
|
+
function normalizeStem(w) {
|
|
38
|
+
const s = w.toLowerCase().trim();
|
|
39
|
+
if (s.endsWith('ies') && s.length > 4)
|
|
40
|
+
return s.slice(0, -3) + 'y';
|
|
41
|
+
if (s.endsWith('es') && s.length > 4 && /[sxz]|ch|sh$/.test(s.slice(0, -2)))
|
|
42
|
+
return s.slice(0, -2);
|
|
43
|
+
if (s.endsWith('s') && s.length > 3 && !s.endsWith('ss'))
|
|
44
|
+
return s.slice(0, -1);
|
|
45
|
+
if (s.endsWith('ing') && s.length > 5)
|
|
46
|
+
return s.slice(0, -3);
|
|
47
|
+
if (s.endsWith('tion') && s.length > 6)
|
|
48
|
+
return s.slice(0, -4);
|
|
49
|
+
if (s.endsWith('ed') && s.length > 4)
|
|
50
|
+
return s.slice(0, -2);
|
|
51
|
+
return s;
|
|
52
|
+
}
|
|
53
|
+
/** Explicit domain synonym dictionary grounded in engineering tasks and repository knowledge. */
|
|
54
|
+
const DOMAIN_SYNONYMS = {
|
|
55
|
+
// Database, migrations, schema and persistence
|
|
56
|
+
table: ['database', 'schema', 'orm', 'migration', 'sql'],
|
|
57
|
+
column: ['database', 'schema', 'migration', 'sql'],
|
|
58
|
+
schema: ['database', 'orm', 'migration', 'sql', 'drizzle', 'postgres'],
|
|
59
|
+
migration: ['database', 'schema', 'migrate', 'sql', 'drizzle'],
|
|
60
|
+
migrate: ['database', 'schema', 'migration', 'sql'],
|
|
61
|
+
sql: ['database', 'postgres', 'drizzle', 'query'],
|
|
62
|
+
db: ['database', 'postgres', 'drizzle', 'orm'],
|
|
63
|
+
database: ['db', 'schema', 'orm', 'postgres', 'drizzle'],
|
|
64
|
+
drizzle: ['database', 'orm', 'schema'],
|
|
65
|
+
postgres: ['database', 'sql'],
|
|
66
|
+
// Authentication, tenancy, and authorization
|
|
67
|
+
auth: ['jwt', 'session', 'security', 'tenant', 'permission'],
|
|
68
|
+
jwt: ['auth', 'session', 'token', 'security'],
|
|
69
|
+
password: ['hash', 'argon2', 'auth', 'security'],
|
|
70
|
+
hash: ['password', 'argon2', 'security'],
|
|
71
|
+
tenant: ['tenancy', 'isolation', 'security', 'auth'],
|
|
72
|
+
tenancy: ['tenant', 'isolation', 'security'],
|
|
73
|
+
isolation: ['tenant', 'tenancy', 'security'],
|
|
74
|
+
// Billing and financial
|
|
75
|
+
invoice: ['billing', 'cents', 'precision'],
|
|
76
|
+
billing: ['invoice', 'cents', 'precision'],
|
|
77
|
+
cents: ['billing', 'invoice', 'precision'],
|
|
78
|
+
payment: ['stripe', 'gateway'],
|
|
79
|
+
// API, HTTP, and Backend Services
|
|
80
|
+
endpoint: ['api', 'controller', 'service', 'dto'],
|
|
81
|
+
api: ['endpoint', 'controller', 'service', 'dto'],
|
|
82
|
+
supplier: ['supplier', 'dto', 'service'],
|
|
83
|
+
controller: ['service', 'dto', 'api', 'endpoint'],
|
|
84
|
+
dto: ['validation', 'typebox', 'schema', 'controller'],
|
|
85
|
+
// Frontend and UI
|
|
86
|
+
component: ['ui', 'frontend', 'page', 'react'],
|
|
87
|
+
pagination: ['ui', 'component', 'frontend', 'table'],
|
|
88
|
+
frontend: ['ui', 'component', 'react'],
|
|
89
|
+
ui: ['component', 'frontend', 'react'],
|
|
90
|
+
react: ['ui', 'component', 'frontend'],
|
|
91
|
+
// Inventory and Stock
|
|
92
|
+
stock: ['inventory', 'product', 'service'],
|
|
93
|
+
inventory: ['stock', 'product', 'service'],
|
|
94
|
+
product: ['inventory', 'stock', 'service'],
|
|
95
|
+
sku: ['product', 'inventory', 'barcode'],
|
|
96
|
+
barcode: ['sku', 'product', 'inventory']
|
|
97
|
+
};
|
|
98
|
+
/** Extracts words from text without punctuation. */
|
|
99
|
+
const words = (text) => [...new Set((text.toLowerCase().match(/[a-z0-9_][a-z0-9_.-]{1,}/g) ?? []).filter((w) => !STOP.has(w)))].sort();
|
|
100
|
+
/** Expands terms using word stemming and explicit domain synonym clusters. */
|
|
101
|
+
function expandQueryTerms(rawWords) {
|
|
102
|
+
const expanded = new Set(rawWords);
|
|
103
|
+
for (const w of rawWords) {
|
|
104
|
+
const stem = normalizeStem(w);
|
|
105
|
+
if (stem.length >= 2)
|
|
106
|
+
expanded.add(stem);
|
|
107
|
+
const syns = DOMAIN_SYNONYMS[w] ?? DOMAIN_SYNONYMS[stem];
|
|
108
|
+
if (syns) {
|
|
109
|
+
for (const s of syns)
|
|
110
|
+
expanded.add(s);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return [...expanded].sort();
|
|
114
|
+
}
|
|
115
|
+
/** Matches terms against text with token/boundary precision. */
|
|
116
|
+
function matchesQuery(text, terms) {
|
|
117
|
+
const lower = text.toLowerCase();
|
|
118
|
+
const matched = [];
|
|
119
|
+
for (const term of terms) {
|
|
120
|
+
if (term.includes('.') || term.includes('/')) {
|
|
121
|
+
if (lower.includes(term))
|
|
122
|
+
matched.push(term);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
const re = new RegExp(`(?:^|[\\s._/:-])${term}(?:$|[\\s._/:-])`, 'i');
|
|
126
|
+
if (re.test(lower))
|
|
127
|
+
matched.push(term);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return matched;
|
|
131
|
+
}
|
|
27
132
|
const norm = (s) => s.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
28
133
|
/** Which context documents are worth pointing at for a task type. */
|
|
29
134
|
const DOCS_BY_TYPE = {
|
|
@@ -47,27 +152,100 @@ async function buildBaseTaskContext(o, request) {
|
|
|
47
152
|
const cls = classifyRequest(request);
|
|
48
153
|
const type = cls.type;
|
|
49
154
|
const kw = words(request);
|
|
155
|
+
const expandedTerms = expandQueryTerms(kw);
|
|
50
156
|
const included = [];
|
|
51
|
-
const hit = (text) =>
|
|
157
|
+
const hit = (text) => matchesQuery(text, expandedTerms);
|
|
158
|
+
// Packages and the testing contract
|
|
159
|
+
let allChecks = [];
|
|
160
|
+
if (await pathExists(ws.commands))
|
|
161
|
+
allChecks = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;
|
|
162
|
+
const pkgReason = new Map();
|
|
163
|
+
for (const d of packageDirs(allChecks)) {
|
|
164
|
+
const m = matchesQuery(request, [d]);
|
|
165
|
+
if (m.length > 0)
|
|
166
|
+
pkgReason.set(d, `request names "${m[0]}"`);
|
|
167
|
+
}
|
|
168
|
+
// Enhanced package discovery from domain context when not explicitly named
|
|
169
|
+
if (pkgReason.size === 0 && packageDirs(allChecks).length > 1) {
|
|
170
|
+
const hasBackend = matchesQuery(request, ['api', 'endpoint', 'endpoints', 'controller', 'controllers', 'dto', 'dtos', 'database', 'migration', 'migrations', 'migrate', 'sql', 'postgres', 'drizzle', 'orm', 'fastify', 'server', 'jwt', 'argon2', 'service', 'services', 'invoice']).length > 0;
|
|
171
|
+
const hasFrontend = matchesQuery(request, ['ui', 'component', 'components', 'frontend', 'page', 'pages', 'pagination', 'react', 'vite', 'view', 'views', 'button', 'modal']).length > 0;
|
|
172
|
+
const available = packageDirs(allChecks);
|
|
173
|
+
if (hasBackend && !hasFrontend && available.includes('backend')) {
|
|
174
|
+
pkgReason.set('backend', 'inferred from backend domain terminology');
|
|
175
|
+
}
|
|
176
|
+
else if (hasFrontend && !hasBackend && available.includes('frontend')) {
|
|
177
|
+
pkgReason.set('frontend', 'inferred from frontend UI terminology');
|
|
178
|
+
}
|
|
179
|
+
else if (hasBackend && hasFrontend) {
|
|
180
|
+
if (available.includes('backend'))
|
|
181
|
+
pkgReason.set('backend', 'request spans backend');
|
|
182
|
+
if (available.includes('frontend'))
|
|
183
|
+
pkgReason.set('frontend', 'request spans frontend');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// dirtyFiles already leaves out documentation and tool-managed files, so a docs-only change selects no package.
|
|
187
|
+
// Only worth the Git calls when the request did not already pick a package and there is more than one to choose from.
|
|
188
|
+
const dirty = type !== 'QUESTION' && type !== 'DOCUMENTATION' && pkgReason.size === 0 && packageDirs(allChecks).length > 1 ? await dirtyFiles(ws.root) : null;
|
|
189
|
+
for (const f of Object.keys(dirty?.files ?? {})) {
|
|
190
|
+
const d = packageDirs(allChecks).find((x) => f === x || f.startsWith(`${x}/`));
|
|
191
|
+
if (d && !pkgReason.has(d))
|
|
192
|
+
pkgReason.set(d, 'has uncommitted code changes');
|
|
193
|
+
}
|
|
52
194
|
// Facts
|
|
53
195
|
const all = (await loadFacts(ws)).facts;
|
|
54
196
|
const picked = new Map();
|
|
197
|
+
const isSinglePackage = pkgReason.size === 1;
|
|
198
|
+
const targetPkg = isSinglePackage ? [...pkgReason.keys()][0] : null;
|
|
55
199
|
for (const f of all) {
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
200
|
+
// If request confidently targets a single package, avoid pulling in unrelated package facts
|
|
201
|
+
if (targetPkg === 'backend') {
|
|
202
|
+
if (f.source.startsWith('frontend/') || f.key === 'stack.ui' || f.key.startsWith('convention.frontend')) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (targetPkg === 'frontend') {
|
|
207
|
+
if (f.source.startsWith('backend/') || f.key === 'stack.database' || f.key === 'stack.orm' || f.key.startsWith('testing.db')) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Match terms against fact key and value; only match source path against specific non-structural request words
|
|
212
|
+
const mText = hit(`${f.key} ${f.value}`);
|
|
213
|
+
const mSource = matchesQuery(f.source, kw.filter((w) => !PATH_STRUCTURAL_TERMS.has(w)));
|
|
214
|
+
const m = [...new Set([...mText, ...mSource])];
|
|
215
|
+
const nonWeak = m.filter(w => !WEAK_TERMS.has(w));
|
|
216
|
+
if (nonWeak.length > 0)
|
|
217
|
+
picked.set(f.key, `matches "${nonWeak.slice(0, 3).join('", "')}"`);
|
|
59
218
|
}
|
|
60
219
|
const group = (re, why, also) => {
|
|
61
|
-
for (const f of all)
|
|
62
|
-
if (
|
|
220
|
+
for (const f of all) {
|
|
221
|
+
if (picked.has(f.key))
|
|
222
|
+
continue;
|
|
223
|
+
if (targetPkg === 'backend' && (f.source.startsWith('frontend/') || f.key === 'stack.ui' || f.key.startsWith('convention.frontend')))
|
|
224
|
+
continue;
|
|
225
|
+
if (targetPkg === 'frontend' && (f.source.startsWith('backend/') || f.key === 'stack.database' || f.key === 'stack.orm' || f.key.startsWith('testing.db')))
|
|
226
|
+
continue;
|
|
227
|
+
if (re.test(f.key) || also?.(f))
|
|
63
228
|
picked.set(f.key, why);
|
|
229
|
+
}
|
|
64
230
|
};
|
|
65
|
-
|
|
66
|
-
|
|
231
|
+
// Package layout facts: include in multi-package/cross-package/uncertain contexts, omit global entry points in single-package tasks
|
|
232
|
+
if (type !== 'QUESTION' && type !== 'DOCUMENTATION') {
|
|
233
|
+
if (!isSinglePackage || type === 'ARCHITECTURE') {
|
|
234
|
+
group(/^repo\.(?:packages|entry-points|monorepo)$/, `package layout (${type})`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
67
237
|
if (type === 'BUG' || type === 'SECURITY')
|
|
68
238
|
group(ISSUE_KEY, 'known issue / limitation', (f) => f.status === 'STALE' && f.sourceType !== 'detector');
|
|
69
|
-
if (BROAD_TYPES.includes(type))
|
|
70
|
-
group(
|
|
239
|
+
if (BROAD_TYPES.includes(type)) {
|
|
240
|
+
group(/^stack\.ecosystem$/, `stack and conventions (${type})`);
|
|
241
|
+
if (targetPkg === 'backend' || !isSinglePackage) {
|
|
242
|
+
group(/^(?:arch\.modules|convention\.service-layer)$/, `architecture conventions (${type})`);
|
|
243
|
+
group(/^(?:stack\.framework|stack\.database|stack\.orm)$/, `backend stack (${type})`);
|
|
244
|
+
}
|
|
245
|
+
if (targetPkg === 'frontend' || !isSinglePackage) {
|
|
246
|
+
group(/^(?:convention\.frontend-components|stack\.ui)$/, `frontend stack (${type})`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
71
249
|
if (type === 'SECURITY')
|
|
72
250
|
group(/^$/, 'security / authorization rule', (f) => SECURITY_WORDS.test(`${f.key} ${f.value}`));
|
|
73
251
|
if (type === 'DOCUMENTATION')
|
|
@@ -91,24 +269,6 @@ async function buildBaseTaskContext(o, request) {
|
|
|
91
269
|
facts.push(clip ? { ...f, value: f.value.slice(0, CLIP), clipped: f.value.length - CLIP } : f);
|
|
92
270
|
included.push({ kind: 'fact', id: f.key, reason: picked.get(f.key) });
|
|
93
271
|
}
|
|
94
|
-
// Packages and the testing contract
|
|
95
|
-
let allChecks = [];
|
|
96
|
-
if (await pathExists(ws.commands))
|
|
97
|
-
allChecks = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;
|
|
98
|
-
const pkgReason = new Map();
|
|
99
|
-
for (const d of packageDirs(allChecks)) {
|
|
100
|
-
const m = hit(d.toLowerCase());
|
|
101
|
-
if (m.length > 0)
|
|
102
|
-
pkgReason.set(d, `request names "${m[0]}"`);
|
|
103
|
-
}
|
|
104
|
-
// dirtyFiles already leaves out documentation and tool-managed files, so a docs-only change selects no package.
|
|
105
|
-
// Only worth the Git calls when the request did not already pick a package and there is more than one to choose from.
|
|
106
|
-
const dirty = type !== 'QUESTION' && type !== 'DOCUMENTATION' && pkgReason.size === 0 && packageDirs(allChecks).length > 1 ? await dirtyFiles(ws.root) : null;
|
|
107
|
-
for (const f of Object.keys(dirty?.files ?? {})) {
|
|
108
|
-
const d = packageDirs(allChecks).find((x) => f === x || f.startsWith(`${x}/`));
|
|
109
|
-
if (d && !pkgReason.has(d))
|
|
110
|
-
pkgReason.set(d, 'has uncommitted code changes');
|
|
111
|
-
}
|
|
112
272
|
const usable = allChecks.filter((c) => c.available);
|
|
113
273
|
const scoped = pkgReason.size > 0 ? usable.filter((c) => !c.cwd || c.cwd === '.' || pkgReason.has(c.cwd)) : usable;
|
|
114
274
|
const checks = type === 'QUESTION' || type === 'DOCUMENTATION' ? [] : scoped;
|
|
@@ -122,17 +282,19 @@ async function buildBaseTaskContext(o, request) {
|
|
|
122
282
|
safety.push({ package: c.cwd ?? '.', check: c.id, command: c.command, safety: s.safety, reasons: s.reasons });
|
|
123
283
|
}
|
|
124
284
|
SAFETY_RULES.forEach((_, i) => included.push({ kind: 'rule', id: `safety-${i + 1}`, reason: 'safety rule, included in every context' }));
|
|
125
|
-
// Decisions: titles and file references
|
|
285
|
+
// Decisions: titles, context, decision, consequences, and file references
|
|
126
286
|
const decs = (await listDecisions(ws)).decisions;
|
|
127
287
|
const wantAll = type === 'ARCHITECTURE' || type === 'SECURITY';
|
|
128
288
|
const decisions = [];
|
|
129
289
|
for (const d of decs) {
|
|
130
|
-
const
|
|
131
|
-
|
|
290
|
+
const fullText = `${d.title} ${d.decision} ${d.context} ${d.consequences} ${d.file}`;
|
|
291
|
+
const m = matchesQuery(fullText, expandedTerms);
|
|
292
|
+
const nonWeak = m.filter(w => !WEAK_TERMS.has(w));
|
|
293
|
+
if (d.status === 'superseded' && nonWeak.length === 0)
|
|
132
294
|
continue;
|
|
133
|
-
if (
|
|
295
|
+
if (nonWeak.length > 0 || wantAll) {
|
|
134
296
|
decisions.push({ number: d.number, title: d.title, status: d.status, file: d.file });
|
|
135
|
-
included.push({ kind: 'decision', id: String(d.number).padStart(4, '0'), reason:
|
|
297
|
+
included.push({ kind: 'decision', id: String(d.number).padStart(4, '0'), reason: nonWeak.length > 0 ? `matches "${nonWeak[0]}"` : `${type} tasks review all decisions` });
|
|
136
298
|
}
|
|
137
299
|
}
|
|
138
300
|
// Documents: referenced, never embedded
|
|
@@ -142,7 +304,7 @@ async function buildBaseTaskContext(o, request) {
|
|
|
142
304
|
for (const name of (await fs.readdir(ws.contextDir)).filter((n) => n.endsWith('.md')).sort()) {
|
|
143
305
|
docCount++;
|
|
144
306
|
const byType = (DOCS_BY_TYPE[type] ?? []).includes(name);
|
|
145
|
-
const m =
|
|
307
|
+
const m = matchesQuery(name, expandedTerms);
|
|
146
308
|
if (byType || m.length > 0) {
|
|
147
309
|
documents.push({ name, bytes: (await fs.stat(path.join(ws.contextDir, name))).size });
|
|
148
310
|
included.push({ kind: 'document', id: name, reason: byType ? `reference for ${type}` : `request names "${m[0]}"` });
|
|
@@ -178,7 +340,8 @@ export async function getAgentContextSlice(o, opts) {
|
|
|
178
340
|
const base = opts.base ?? (await buildBaseTaskContext(o, opts.request));
|
|
179
341
|
const role = opts.role;
|
|
180
342
|
const kw = words(opts.request);
|
|
181
|
-
const
|
|
343
|
+
const expandedTerms = expandQueryTerms(kw);
|
|
344
|
+
const hit = (text) => matchesQuery(text, expandedTerms);
|
|
182
345
|
let slicedFacts = [...base.facts];
|
|
183
346
|
let slicedChecks = [...base.checks];
|
|
184
347
|
let slicedDecisions = [...base.decisions];
|
|
@@ -194,10 +357,10 @@ export async function getAgentContextSlice(o, opts) {
|
|
|
194
357
|
return true;
|
|
195
358
|
if (STACK_KEY.test(f.key) && !/^convention\.test/i.test(f.key))
|
|
196
359
|
return true;
|
|
197
|
-
const m = hit(`${f.key} ${f.value}
|
|
360
|
+
const m = hit(`${f.key} ${f.value}`);
|
|
198
361
|
return m.length > 0 && !/^convention\.test/i.test(f.key);
|
|
199
362
|
});
|
|
200
|
-
slicedDecisions = base.decisions.
|
|
363
|
+
slicedDecisions = base.decisions.slice(0, 3);
|
|
201
364
|
slicedDocuments = base.documents.filter((d) => ['architecture.md', 'integrations.md'].includes(d.name));
|
|
202
365
|
// Entry points from facts or packages
|
|
203
366
|
const epFact = base.facts.find((f) => f.key === 'repo.entry-points');
|
|
@@ -217,7 +380,7 @@ export async function getAgentContextSlice(o, opts) {
|
|
|
217
380
|
try {
|
|
218
381
|
const featFile = await loadFeatures(ws);
|
|
219
382
|
const matchedFeats = featFile.features.filter((f) => {
|
|
220
|
-
const text = `${f.id} ${f.name} ${f.description ?? ''} ${(f.tags ?? []).join(' ')}
|
|
383
|
+
const text = `${f.id} ${f.name} ${f.description ?? ''} ${(f.tags ?? []).join(' ')}`;
|
|
221
384
|
return hit(text).length > 0;
|
|
222
385
|
});
|
|
223
386
|
if (matchedFeats.length > 0) {
|
|
@@ -236,7 +399,7 @@ export async function getAgentContextSlice(o, opts) {
|
|
|
236
399
|
const graph = await loadGraphData(ws.root);
|
|
237
400
|
if (graph.exists && graph.data && graph.data.nodes) {
|
|
238
401
|
const matchedNodes = [];
|
|
239
|
-
for (const w of
|
|
402
|
+
for (const w of expandedTerms) {
|
|
240
403
|
const n = findMatchingStartNode(graph.data.nodes, w);
|
|
241
404
|
if (n && !matchedNodes.some((x) => x.id === n.id)) {
|
|
242
405
|
matchedNodes.push({
|
|
@@ -1 +1 @@
|
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M,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpD,SAAS,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7D,SAAS,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SAC9D;QACD,YAAY;QACZ,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { SCHEMA_VERSION, validateCommands, type CommandEntry, type Fact } from '../config/schemas.js';\nimport { loadProject, requireWorkspace } from '../core/workspace.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { listDecisions } from '../decisions/decision.js';\nimport { loadFacts } from '../knowledge/facts.js';\nimport { classifyRequest } from '../tasks/routing.js';\nimport type { TaskType } from '../tasks/task.js';\nimport { pathExists } from '../utils/fs.js';\nimport { classifyCommand, readManifestEvidence } from '../verification/safety.js';\nimport { dirtyFiles, packageDirs } from '../verification/scope.js';\nimport { SAFETY_RULES, type ContextResult } from './knowledge.js';\nimport type { ServiceOptions } from './common.js';\nimport { loadFeatures } from './features.js';\nimport { loadGraphData, findMatchingStartNode } from './graph.js';\n\nexport const CONTEXT_ROLES = ['explorer', 'tester', 'reviewer'] as const;\nexport type ContextRole = (typeof CONTEXT_ROLES)[number];\n\nexport function isContextRole(v: unknown): v is ContextRole {\n return typeof v === 'string' && (CONTEXT_ROLES as readonly string[]).includes(v);\n}\n\nexport interface ContextItem {\n kind: 'fact' | 'check' | 'decision' | 'document' | 'rule';\n id: string;\n /** Why this item is in the context; every item carries one. */\n reason: string;\n}\n\nexport interface TaskContextResult {\n project: { name: string; id: string };\n request: string;\n type: TaskType;\n confidence: 'high' | 'low';\n readOnly: boolean;\n /** `clipped` = characters left out of a long detector-derived value; the full value is in facts.json. */\n facts: (Fact & { clipped?: number })[];\n /** Detector facts folded into another fact with the identical value; nothing is deleted from facts.json. */\n aliases: { key: string; sameAs: string }[];\n checks: CommandEntry[];\n safety: ContextResult['safety'];\n rules: string[];\n decisions: { number: number; title: string; status: string; file: string }[];\n /** Detailed documents are referenced by name, never embedded. */\n documents: { name: string; bytes: number }[];\n packages: string[];\n included: ContextItem[];\n counts: { facts: [number, number]; checks: [number, number]; decisions: [number, number]; documents: [number, number] };\n role?: ContextRole;\n roleGuidance?: string[];\n roleFindings?: {\n entryPoints?: string[];\n graphNodes?: { id: string; status: string; path: string | null; symbol: string | null }[];\n features?: { id: string; name: string; status?: string }[];\n testFrameworks?: string[];\n zeroTestSafeguards?: string[];\n diffNotice?: string;\n };\n}\n\nconst STOP = new Set(['the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'does', 'how', 'what', 'where', 'why', 'when', 'which', 'fix', 'add', 'bug', 'make', 'new', 'can', 'are', 'not', 'our', 'all', 'use', 'get', 'set']);\nconst CLIP = 400;\nconst SECURITY_WORDS = /auth|tenant|permission|rbac|security|isolation|role|session|ownership/i;\nconst ISSUE_KEY = /^(?:issue|limit|known|bug|risk)/i;\n/** Facts that describe the stack and layout; implementation-style tasks need them, a lookup question does not. */\nconst STACK_KEY = /^(?:stack\\.|repo\\.packages|repo\\.monorepo|repo\\.entry-points|convention|style|arch|pattern|testing)/i;\nconst BROAD_TYPES: TaskType[] = ['FEATURE', 'REFACTOR', 'ARCHITECTURE', 'TESTING', 'PERFORMANCE', 'MAINTENANCE', 'RELEASE'];\n\nconst words = (text: string): string[] => [...new Set((text.toLowerCase().match(/[a-z0-9_][a-z0-9_.-]{2,}/g) ?? []).filter((w) => !STOP.has(w)))].sort();\nconst norm = (s: string): string => s.toLowerCase().replace(/\\s+/g, ' ').trim();\n\n/** Which context documents are worth pointing at for a task type. */\nconst DOCS_BY_TYPE: Partial<Record<TaskType, string[]>> = {\n ARCHITECTURE: ['architecture.md', 'integrations.md'],\n REFACTOR: ['architecture.md', 'conventions.md'],\n FEATURE: ['architecture.md', 'conventions.md'],\n BUG: ['testing.md'],\n TESTING: ['testing.md'],\n SECURITY: ['testing.md', 'architecture.md'],\n PERFORMANCE: ['architecture.md'],\n RELEASE: ['testing.md'],\n};\n\n/**\n * Task-aware context. Selection is deterministic (sorted inputs, no clocks, no randomness) and rule-based: the request is\n * classified, its keywords select facts/decisions/packages, and the type decides which broader groups come along.\n * Safety rules are included for every type; the per-package \"not run automatically\" list whenever checks are included.\n */\nasync function buildBaseTaskContext(o: ServiceOptions, request: string): Promise<TaskContextResult> {\n const ws = await requireWorkspace(o.cwd);\n const project = await loadProject(ws);\n const cls = classifyRequest(request);\n const type = cls.type;\n const kw = words(request);\n const included: ContextItem[] = [];\n const hit = (text: string): string[] => kw.filter((w) => text.includes(w));\n\n // Facts\n const all = (await loadFacts(ws)).facts;\n const picked = new Map<string, string>();\n for (const f of all) {\n const m = hit(`${f.key} ${f.value} ${f.source}`.toLowerCase());\n if (m.length > 0) picked.set(f.key, `matches \"${m.slice(0, 3).join('\", \"')}\"`);\n }\n const group = (re: RegExp, why: string, also?: (f: Fact) => boolean): void => {\n for (const f of all) if (!picked.has(f.key) && (re.test(f.key) || also?.(f))) picked.set(f.key, why);\n };\n if (type !== 'QUESTION' && type !== 'DOCUMENTATION') group(/^repo\\.(?:packages|entry-points)$/, `package layout (${type})`);\n if (type === 'BUG' || type === 'SECURITY') group(ISSUE_KEY, 'known issue / limitation', (f) => f.status === 'STALE' && f.sourceType !== 'detector');\n if (BROAD_TYPES.includes(type)) group(STACK_KEY, `stack and conventions (${type})`);\n if (type === 'SECURITY') group(/^$/, 'security / authorization rule', (f) => SECURITY_WORDS.test(`${f.key} ${f.value}`));\n if (type === 'DOCUMENTATION') group(/^repo\\.docs$/, 'documentation index');\n const selected = all.filter((f) => picked.has(f.key));\n\n // Compaction: a detector fact whose value equals another selected fact's is folded into it. Human-authored facts are never folded or clipped.\n const aliases: TaskContextResult['aliases'] = [];\n const owners = new Map<string, string>();\n for (const f of [...selected].sort((a, b) => Number(a.sourceType === 'detector') - Number(b.sourceType === 'detector') || a.key.localeCompare(b.key))) {\n if (!owners.has(norm(f.value))) owners.set(norm(f.value), f.key);\n }\n const facts: TaskContextResult['facts'] = [];\n for (const f of [...selected].sort((a, b) => a.key.localeCompare(b.key))) {\n const owner = owners.get(norm(f.value))!;\n if (owner !== f.key && f.sourceType === 'detector') {\n aliases.push({ key: f.key, sameAs: owner });\n continue;\n }\n const clip = f.sourceType === 'detector' && f.value.length > CLIP;\n facts.push(clip ? { ...f, value: f.value.slice(0, CLIP), clipped: f.value.length - CLIP } : f);\n included.push({ kind: 'fact', id: f.key, reason: picked.get(f.key)! });\n }\n\n // Packages and the testing contract\n let allChecks: CommandEntry[] = [];\n if (await pathExists(ws.commands)) allChecks = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;\n const pkgReason = new Map<string, string>();\n for (const d of packageDirs(allChecks)) {\n const m = hit(d.toLowerCase());\n if (m.length > 0) pkgReason.set(d, `request names \"${m[0]}\"`);\n }\n // dirtyFiles already leaves out documentation and tool-managed files, so a docs-only change selects no package.\n // Only worth the Git calls when the request did not already pick a package and there is more than one to choose from.\n const dirty = type !== 'QUESTION' && type !== 'DOCUMENTATION' && pkgReason.size === 0 && packageDirs(allChecks).length > 1 ? await dirtyFiles(ws.root) : null;\n for (const f of Object.keys(dirty?.files ?? {})) {\n const d = packageDirs(allChecks).find((x) => f === x || f.startsWith(`${x}/`));\n if (d && !pkgReason.has(d)) pkgReason.set(d, 'has uncommitted code changes');\n }\n const usable = allChecks.filter((c) => c.available);\n const scoped = pkgReason.size > 0 ? usable.filter((c) => !c.cwd || c.cwd === '.' || pkgReason.has(c.cwd)) : usable;\n const checks = type === 'QUESTION' || type === 'DOCUMENTATION' ? [] : scoped;\n for (const c of checks) included.push({ kind: 'check', id: `${c.cwd ?? '.'}:${c.id}`, reason: c.cwd && pkgReason.has(c.cwd) ? `package: ${pkgReason.get(c.cwd)}` : `testing contract (${type})` });\n\n // Commands that must not run unguarded stay visible whenever their package's checks are in play.\n const safety: ContextResult['safety'] = [];\n for (const c of checks) {\n const s = classifyCommand(c, await readManifestEvidence(ws.root, c));\n if (s.safety !== 'safe') safety.push({ package: c.cwd ?? '.', check: c.id, command: c.command, safety: s.safety, reasons: s.reasons });\n }\n SAFETY_RULES.forEach((_, i) => included.push({ kind: 'rule', id: `safety-${i + 1}`, reason: 'safety rule, included in every context' }));\n\n // Decisions: titles and file references only\n const decs = (await listDecisions(ws)).decisions;\n const wantAll = type === 'ARCHITECTURE' || type === 'SECURITY';\n const decisions: TaskContextResult['decisions'] = [];\n for (const d of decs) {\n const m = hit(`${d.title} ${d.decision} ${d.context}`.toLowerCase());\n if (d.status === 'superseded' && m.length === 0) continue;\n if (m.length > 0 || wantAll) {\n decisions.push({ number: d.number, title: d.title, status: d.status, file: d.file });\n included.push({ kind: 'decision', id: String(d.number).padStart(4, '0'), reason: m.length > 0 ? `matches \"${m[0]}\"` : `${type} tasks review all decisions` });\n }\n }\n\n // Documents: referenced, never embedded\n const documents: TaskContextResult['documents'] = [];\n let docCount = 0;\n if (await pathExists(ws.contextDir)) {\n for (const name of (await fs.readdir(ws.contextDir)).filter((n) => n.endsWith('.md')).sort()) {\n docCount++;\n const byType = (DOCS_BY_TYPE[type] ?? []).includes(name);\n const m = hit(name.toLowerCase());\n if (byType || m.length > 0) {\n documents.push({ name, bytes: (await fs.stat(path.join(ws.contextDir, name))).size });\n included.push({ kind: 'document', id: name, reason: byType ? `reference for ${type}` : `request names \"${m[0]}\"` });\n }\n }\n }\n\n return {\n project: { name: project.name, id: project.projectId },\n request,\n type,\n confidence: cls.confidence,\n readOnly: cls.readOnly,\n facts,\n aliases,\n checks,\n safety,\n rules: SAFETY_RULES,\n decisions,\n documents,\n packages: [...pkgReason.keys()].sort(),\n included,\n counts: { facts: [facts.length, all.length], checks: [checks.length, usable.length], decisions: [decisions.length, decs.length], documents: [documents.length, docCount] },\n };\n}\n\nexport async function getTaskContext(\n o: ServiceOptions,\n opts: { request: string; role?: ContextRole },\n): Promise<TaskContextResult> {\n const base = await buildBaseTaskContext(o, opts.request);\n if (!opts.role) return base;\n return getAgentContextSlice(o, { request: opts.request, role: opts.role, base });\n}\n\nexport async function getAgentContextSlice(\n o: ServiceOptions,\n opts: { request: string; role: ContextRole; base?: TaskContextResult },\n): Promise<TaskContextResult> {\n const ws = await requireWorkspace(o.cwd);\n const base = opts.base ?? (await buildBaseTaskContext(o, opts.request));\n const role = opts.role;\n const kw = words(opts.request);\n const hit = (text: string): string[] => kw.filter((w) => text.includes(w));\n\n let slicedFacts = [...base.facts];\n let slicedChecks = [...base.checks];\n let slicedDecisions = [...base.decisions];\n let slicedDocuments = [...base.documents];\n let roleGuidance: string[] = [];\n const roleFindings: NonNullable<TaskContextResult['roleFindings']> = {};\n\n if (role === 'explorer') {\n // Explorer: Prioritize entry points, symbols, features, graph connections.\n // Avoid unrelated test commands, entire file contents, complete repo dumps.\n slicedChecks = [];\n slicedFacts = base.facts.filter((f) => {\n if (/^repo\\.(?:entry-points|packages|monorepo)$/.test(f.key)) return true;\n if (STACK_KEY.test(f.key) && !/^convention\\.test/i.test(f.key)) return true;\n const m = hit(`${f.key} ${f.value}`.toLowerCase());\n return m.length > 0 && !/^convention\\.test/i.test(f.key);\n });\n\n slicedDecisions = base.decisions.filter((d) => hit(`${d.title} ${d.file}`.toLowerCase()).length > 0).slice(0, 3);\n slicedDocuments = base.documents.filter((d) => ['architecture.md', 'integrations.md'].includes(d.name));\n\n // Entry points from facts or packages\n const epFact = base.facts.find((f) => f.key === 'repo.entry-points');\n const entryPoints: string[] = [];\n if (epFact && epFact.value) {\n for (const p of epFact.value.split(',').map((x) => x.trim()).filter(Boolean)) {\n if (!entryPoints.includes(p)) entryPoints.push(p);\n }\n }\n if (entryPoints.length === 0 && base.packages.length > 0) {\n entryPoints.push(...base.packages);\n }\n if (entryPoints.length > 0) roleFindings.entryPoints = entryPoints.slice(0, 10);\n\n // Feature knowledge map references\n try {\n const featFile = await loadFeatures(ws);\n const matchedFeats = featFile.features.filter((f) => {\n const text = `${f.id} ${f.name} ${f.description ?? ''} ${(f.tags ?? []).join(' ')}`.toLowerCase();\n return hit(text).length > 0;\n });\n if (matchedFeats.length > 0) {\n roleFindings.features = matchedFeats.slice(0, 8).map((f) => ({\n id: f.id,\n name: f.name,\n status: f.status,\n }));\n }\n } catch {\n // Graceful fallback if features file unreadable\n }\n\n // Graphify graph lookup\n try {\n const graph = await loadGraphData(ws.root);\n if (graph.exists && graph.data && graph.data.nodes) {\n const matchedNodes: NonNullable<TaskContextResult['roleFindings']>['graphNodes'] = [];\n for (const w of kw) {\n const n = findMatchingStartNode(graph.data.nodes, w);\n if (n && !matchedNodes.some((x) => x.id === n.id)) {\n matchedNodes.push({\n id: n.id,\n status: typeof n.status === 'string' ? n.status : 'symbol',\n path: n.path || n.file || null,\n symbol: typeof n.name === 'string' ? n.name : null,\n });\n }\n if (matchedNodes.length >= 6) break;\n }\n if (matchedNodes.length > 0) roleFindings.graphNodes = matchedNodes;\n }\n } catch {\n // Graceful fallback if graph lookup fails\n }\n\n roleGuidance = [\n 'Investigate referenced entry points and feature components before reading full files.',\n 'Trace deep call dependencies with \"devworkspace graph trace <symbol>\".',\n 'Conclude exploration with a concise handoff: identified files, uncertainty, and next step.',\n ];\n } else if (role === 'tester') {\n // Tester: Prioritize test files, test framework conventions, verification contracts, zero-test safeguards.\n slicedFacts = base.facts.filter((f) => {\n if (/^convention\\.test/i.test(f.key) || ISSUE_KEY.test(f.key)) return true;\n if (STACK_KEY.test(f.key) && /test/i.test(f.key + f.value)) return true;\n const m = hit(`${f.key} ${f.value}`.toLowerCase());\n return m.length > 0;\n });\n\n slicedChecks = base.checks;\n slicedDocuments = base.documents.filter((d) => d.name === 'testing.md');\n slicedDecisions = base.decisions.filter((d) => /test|verify|quality/i.test(d.title));\n\n roleFindings.zeroTestSafeguards = [\n 'Zero-test pass detection active across Vitest, Jest, Pytest, Mocha, Go, and Cargo.',\n 'Commands exiting code 0 with 0 tests executed are classified as unverified false passes.',\n 'Record baseline before modifications: devworkspace task tests <id> --phase baseline --passed <n> --failed <n>.',\n \"Execute verification via 'devworkspace task run <id> <check>'.\",\n ];\n\n roleGuidance = [\n 'Verify required contract commands for affected packages before claiming completion.',\n 'Write focused regression tests covering defect reproduction or feature acceptance criteria.',\n 'Never run destructive commands or test suites touching unmanaged databases without \"testenv declare\".',\n ];\n } else if (role === 'reviewer') {\n // Reviewer: Prioritize git diff/changed files, permanent safety rules, ADRs, potential regressions.\n slicedFacts = base.facts.filter((f) => {\n if (SECURITY_WORDS.test(`${f.key} ${f.value}`)) return true;\n if (/^convention\\./i.test(f.key)) return true;\n const m = hit(`${f.key} ${f.value}`.toLowerCase());\n return m.length > 0;\n });\n\n // Keep review-relevant checks (lint, typecheck, review, and test suites)\n if (base.checks.length > 0) {\n slicedChecks = base.checks.filter((c) => /lint|typecheck|review|test/i.test(c.id));\n } else {\n try {\n if (await pathExists(ws.commands)) {\n const contract = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;\n const usable = contract.filter((c) => c.available && /lint|typecheck|review|test/i.test(c.id));\n slicedChecks = base.packages.length > 0\n ? usable.filter((c) => !c.cwd || c.cwd === '.' || base.packages.includes(c.cwd))\n : usable;\n }\n } catch {\n slicedChecks = [];\n }\n }\n slicedDecisions = base.decisions;\n slicedDocuments = base.documents.filter((d) => ['conventions.md', 'architecture.md'].includes(d.name));\n\n try {\n const dirty = await dirtyFiles(ws.root);\n const dirtyList = dirty ? Object.keys(dirty.files) : [];\n if (dirtyList.length > 0) {\n const preview = dirtyList.slice(0, 5).join(', ') + (dirtyList.length > 5 ? ` (+${dirtyList.length - 5} more)` : '');\n roleFindings.diffNotice = `${dirtyList.length} uncommitted file(s) detected: ${preview}. Inspect exact diff with \"git diff\".`;\n } else {\n roleFindings.diffNotice = 'No uncommitted changes detected in working tree. When reviewing a branch or PR, the caller must supply the target diff or commit range.';\n }\n } catch {\n roleFindings.diffNotice = 'Could not inspect git working tree status. The caller must supply the diff or commit range.';\n }\n\n roleGuidance = [\n 'Audit diff against permanent SAFETY_RULES (no secrets in code/logs, no path traversals, untrusted commands).',\n 'Verify changes strictly comply with recorded decisions (ADRs) and feature contracts.',\n 'Ensure required verification checks have executed results before approving the completion gate.',\n ];\n }\n\n const factKeys = new Set(slicedFacts.map((f) => f.key));\n const checkIds = new Set(slicedChecks.map((c) => `${c.cwd ?? '.'}:${c.id}`));\n const decIds = new Set(slicedDecisions.map((d) => String(d.number).padStart(4, '0')));\n const docNames = new Set(slicedDocuments.map((d) => d.name));\n\n const included: ContextItem[] = base.included.filter((item) => {\n if (item.kind === 'rule') return true;\n if (item.kind === 'fact') return factKeys.has(item.id);\n if (item.kind === 'check') return checkIds.has(item.id);\n if (item.kind === 'decision') return decIds.has(item.id);\n if (item.kind === 'document') return docNames.has(item.id);\n return false;\n });\n\n included.push({\n kind: 'rule',\n id: `role:${role}`,\n reason: `context tailored for ${role} role (Phase 1 role-based context slicing)`,\n });\n\n return {\n ...base,\n role,\n facts: slicedFacts,\n checks: slicedChecks,\n decisions: slicedDecisions,\n documents: slicedDocuments,\n rules: SAFETY_RULES,\n included,\n counts: {\n facts: [slicedFacts.length, base.counts.facts[1]],\n checks: [slicedChecks.length, base.counts.checks[1]],\n decisions: [slicedDecisions.length, base.counts.decisions[1]],\n documents: [slicedDocuments.length, base.counts.documents[1]],\n },\n roleGuidance,\n roleFindings,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"taskContext.js","sourceRoot":"","sources":["../../src/services/taskContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAgC,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAs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;QACJ,KAAK,EAAE,WAAW;QAClB,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,eAAe;QAC1B,SAAS,EAAE,eAAe;QAC1B,KAAK,EAAE,YAAY;QACnB,QAAQ;QACR,MAAM,EAAE;YACN,KAAK,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACpD,SAAS,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7D,SAAS,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SAC9D;QACD,YAAY;QACZ,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { SCHEMA_VERSION, validateCommands, type CommandEntry, type Fact } from '../config/schemas.js';\nimport { loadProject, requireWorkspace } from '../core/workspace.js';\nimport { readVersioned } from '../core/versioned.js';\nimport { listDecisions } from '../decisions/decision.js';\nimport { loadFacts } from '../knowledge/facts.js';\nimport { classifyRequest } from '../tasks/routing.js';\nimport type { TaskType } from '../tasks/task.js';\nimport { pathExists } from '../utils/fs.js';\nimport { classifyCommand, readManifestEvidence } from '../verification/safety.js';\nimport { dirtyFiles, packageDirs } from '../verification/scope.js';\nimport { SAFETY_RULES, type ContextResult } from './knowledge.js';\nimport type { ServiceOptions } from './common.js';\nimport { loadFeatures } from './features.js';\nimport { loadGraphData, findMatchingStartNode } from './graph.js';\n\nexport const CONTEXT_ROLES = ['explorer', 'tester', 'reviewer'] as const;\nexport type ContextRole = (typeof CONTEXT_ROLES)[number];\n\nexport function isContextRole(v: unknown): v is ContextRole {\n return typeof v === 'string' && (CONTEXT_ROLES as readonly string[]).includes(v);\n}\n\nexport interface ContextItem {\n kind: 'fact' | 'check' | 'decision' | 'document' | 'rule';\n id: string;\n /** Why this item is in the context; every item carries one. */\n reason: string;\n}\n\nexport interface TaskContextResult {\n project: { name: string; id: string };\n request: string;\n type: TaskType;\n confidence: 'high' | 'low';\n readOnly: boolean;\n /** `clipped` = characters left out of a long detector-derived value; the full value is in facts.json. */\n facts: (Fact & { clipped?: number })[];\n /** Detector facts folded into another fact with the identical value; nothing is deleted from facts.json. */\n aliases: { key: string; sameAs: string }[];\n checks: CommandEntry[];\n safety: ContextResult['safety'];\n rules: string[];\n decisions: { number: number; title: string; status: string; file: string }[];\n /** Detailed documents are referenced by name, never embedded. */\n documents: { name: string; bytes: number }[];\n packages: string[];\n included: ContextItem[];\n counts: { facts: [number, number]; checks: [number, number]; decisions: [number, number]; documents: [number, number] };\n role?: ContextRole;\n roleGuidance?: string[];\n roleFindings?: {\n entryPoints?: string[];\n graphNodes?: { id: string; status: string; path: string | null; symbol: string | null }[];\n features?: { id: string; name: string; status?: string }[];\n testFrameworks?: string[];\n zeroTestSafeguards?: string[];\n diffNotice?: string;\n };\n}\n\nconst STOP = new Set([\n 'the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'does', 'how',\n 'what', 'where', 'why', 'when', 'which', 'fix', 'add', 'bug', 'make', 'new',\n 'can', 'are', 'not', 'our', 'all', 'use', 'get', 'set', 'let', 'may'\n]);\nconst WEAK_TERMS = new Set(['error', 'errors', 'check', 'checks', 'data', 'improve', 'update', 'run', 'test', 'handle', 'handling', 'code']);\nconst PATH_STRUCTURAL_TERMS = new Set([\n 'backend', 'frontend', 'service', 'services', 'controller', 'controllers',\n 'worker', 'workers', 'dto', 'dtos', 'src', 'modules', 'app', 'tests',\n 'unit', 'integration', 'test', 'spec', 'ts', 'tsx', 'js', 'jsx', 'json', 'md'\n]);\nconst CLIP = 400;\nconst SECURITY_WORDS = /auth|tenant|permission|rbac|security|isolation|role|session|ownership/i;\nconst ISSUE_KEY = /^(?:issue|limit|known|bug|risk)/i;\n/** Facts that describe the stack and layout; implementation-style tasks need them, a lookup question does not. */\nconst STACK_KEY = /^(?:stack\\.|repo\\.packages|repo\\.monorepo|repo\\.entry-points|convention|style|arch|pattern|testing)/i;\nconst BROAD_TYPES: TaskType[] = ['FEATURE', 'REFACTOR', 'ARCHITECTURE', 'TESTING', 'PERFORMANCE', 'MAINTENANCE', 'RELEASE'];\n\n/** Normalizes words by stripping standard English inflectional suffixes deterministically. */\nfunction normalizeStem(w: string): string {\n const s = w.toLowerCase().trim();\n if (s.endsWith('ies') && s.length > 4) return s.slice(0, -3) + 'y';\n if (s.endsWith('es') && s.length > 4 && /[sxz]|ch|sh$/.test(s.slice(0, -2))) return s.slice(0, -2);\n if (s.endsWith('s') && s.length > 3 && !s.endsWith('ss')) return s.slice(0, -1);\n if (s.endsWith('ing') && s.length > 5) return s.slice(0, -3);\n if (s.endsWith('tion') && s.length > 6) return s.slice(0, -4);\n if (s.endsWith('ed') && s.length > 4) return s.slice(0, -2);\n return s;\n}\n\n/** Explicit domain synonym dictionary grounded in engineering tasks and repository knowledge. */\nconst DOMAIN_SYNONYMS: Record<string, string[]> = {\n // Database, migrations, schema and persistence\n table: ['database', 'schema', 'orm', 'migration', 'sql'],\n column: ['database', 'schema', 'migration', 'sql'],\n schema: ['database', 'orm', 'migration', 'sql', 'drizzle', 'postgres'],\n migration: ['database', 'schema', 'migrate', 'sql', 'drizzle'],\n migrate: ['database', 'schema', 'migration', 'sql'],\n sql: ['database', 'postgres', 'drizzle', 'query'],\n db: ['database', 'postgres', 'drizzle', 'orm'],\n database: ['db', 'schema', 'orm', 'postgres', 'drizzle'],\n drizzle: ['database', 'orm', 'schema'],\n postgres: ['database', 'sql'],\n\n // Authentication, tenancy, and authorization\n auth: ['jwt', 'session', 'security', 'tenant', 'permission'],\n jwt: ['auth', 'session', 'token', 'security'],\n password: ['hash', 'argon2', 'auth', 'security'],\n hash: ['password', 'argon2', 'security'],\n tenant: ['tenancy', 'isolation', 'security', 'auth'],\n tenancy: ['tenant', 'isolation', 'security'],\n isolation: ['tenant', 'tenancy', 'security'],\n\n // Billing and financial\n invoice: ['billing', 'cents', 'precision'],\n billing: ['invoice', 'cents', 'precision'],\n cents: ['billing', 'invoice', 'precision'],\n payment: ['stripe', 'gateway'],\n\n // API, HTTP, and Backend Services\n endpoint: ['api', 'controller', 'service', 'dto'],\n api: ['endpoint', 'controller', 'service', 'dto'],\n supplier: ['supplier', 'dto', 'service'],\n controller: ['service', 'dto', 'api', 'endpoint'],\n dto: ['validation', 'typebox', 'schema', 'controller'],\n\n // Frontend and UI\n component: ['ui', 'frontend', 'page', 'react'],\n pagination: ['ui', 'component', 'frontend', 'table'],\n frontend: ['ui', 'component', 'react'],\n ui: ['component', 'frontend', 'react'],\n react: ['ui', 'component', 'frontend'],\n\n // Inventory and Stock\n stock: ['inventory', 'product', 'service'],\n inventory: ['stock', 'product', 'service'],\n product: ['inventory', 'stock', 'service'],\n sku: ['product', 'inventory', 'barcode'],\n barcode: ['sku', 'product', 'inventory']\n};\n\n/** Extracts words from text without punctuation. */\nconst words = (text: string): string[] =>\n [...new Set((text.toLowerCase().match(/[a-z0-9_][a-z0-9_.-]{1,}/g) ?? []).filter((w) => !STOP.has(w)))].sort();\n\n/** Expands terms using word stemming and explicit domain synonym clusters. */\nfunction expandQueryTerms(rawWords: string[]): string[] {\n const expanded = new Set<string>(rawWords);\n for (const w of rawWords) {\n const stem = normalizeStem(w);\n if (stem.length >= 2) expanded.add(stem);\n const syns = DOMAIN_SYNONYMS[w] ?? DOMAIN_SYNONYMS[stem];\n if (syns) {\n for (const s of syns) expanded.add(s);\n }\n }\n return [...expanded].sort();\n}\n\n/** Matches terms against text with token/boundary precision. */\nfunction matchesQuery(text: string, terms: string[]): string[] {\n const lower = text.toLowerCase();\n const matched: string[] = [];\n for (const term of terms) {\n if (term.includes('.') || term.includes('/')) {\n if (lower.includes(term)) matched.push(term);\n } else {\n const re = new RegExp(`(?:^|[\\\\s._/:-])${term}(?:$|[\\\\s._/:-])`, 'i');\n if (re.test(lower)) matched.push(term);\n }\n }\n return matched;\n}\n\nconst norm = (s: string): string => s.toLowerCase().replace(/\\s+/g, ' ').trim();\n\n/** Which context documents are worth pointing at for a task type. */\nconst DOCS_BY_TYPE: Partial<Record<TaskType, string[]>> = {\n ARCHITECTURE: ['architecture.md', 'integrations.md'],\n REFACTOR: ['architecture.md', 'conventions.md'],\n FEATURE: ['architecture.md', 'conventions.md'],\n BUG: ['testing.md'],\n TESTING: ['testing.md'],\n SECURITY: ['testing.md', 'architecture.md'],\n PERFORMANCE: ['architecture.md'],\n RELEASE: ['testing.md'],\n};\n\n/**\n * Task-aware context. Selection is deterministic (sorted inputs, no clocks, no randomness) and rule-based: the request is\n * classified, its keywords select facts/decisions/packages, and the type decides which broader groups come along.\n * Safety rules are included for every type; the per-package \"not run automatically\" list whenever checks are included.\n */\nasync function buildBaseTaskContext(o: ServiceOptions, request: string): Promise<TaskContextResult> {\n const ws = await requireWorkspace(o.cwd);\n const project = await loadProject(ws);\n const cls = classifyRequest(request);\n const type = cls.type;\n const kw = words(request);\n const expandedTerms = expandQueryTerms(kw);\n const included: ContextItem[] = [];\n const hit = (text: string): string[] => matchesQuery(text, expandedTerms);\n\n // Packages and the testing contract\n let allChecks: CommandEntry[] = [];\n if (await pathExists(ws.commands)) allChecks = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;\n const pkgReason = new Map<string, string>();\n for (const d of packageDirs(allChecks)) {\n const m = matchesQuery(request, [d]);\n if (m.length > 0) pkgReason.set(d, `request names \"${m[0]}\"`);\n }\n\n // Enhanced package discovery from domain context when not explicitly named\n if (pkgReason.size === 0 && packageDirs(allChecks).length > 1) {\n const hasBackend = matchesQuery(request, ['api', 'endpoint', 'endpoints', 'controller', 'controllers', 'dto', 'dtos', 'database', 'migration', 'migrations', 'migrate', 'sql', 'postgres', 'drizzle', 'orm', 'fastify', 'server', 'jwt', 'argon2', 'service', 'services', 'invoice']).length > 0;\n const hasFrontend = matchesQuery(request, ['ui', 'component', 'components', 'frontend', 'page', 'pages', 'pagination', 'react', 'vite', 'view', 'views', 'button', 'modal']).length > 0;\n const available = packageDirs(allChecks);\n if (hasBackend && !hasFrontend && available.includes('backend')) {\n pkgReason.set('backend', 'inferred from backend domain terminology');\n } else if (hasFrontend && !hasBackend && available.includes('frontend')) {\n pkgReason.set('frontend', 'inferred from frontend UI terminology');\n } else if (hasBackend && hasFrontend) {\n if (available.includes('backend')) pkgReason.set('backend', 'request spans backend');\n if (available.includes('frontend')) pkgReason.set('frontend', 'request spans frontend');\n }\n }\n\n // dirtyFiles already leaves out documentation and tool-managed files, so a docs-only change selects no package.\n // Only worth the Git calls when the request did not already pick a package and there is more than one to choose from.\n const dirty = type !== 'QUESTION' && type !== 'DOCUMENTATION' && pkgReason.size === 0 && packageDirs(allChecks).length > 1 ? await dirtyFiles(ws.root) : null;\n for (const f of Object.keys(dirty?.files ?? {})) {\n const d = packageDirs(allChecks).find((x) => f === x || f.startsWith(`${x}/`));\n if (d && !pkgReason.has(d)) pkgReason.set(d, 'has uncommitted code changes');\n }\n\n // Facts\n const all = (await loadFacts(ws)).facts;\n const picked = new Map<string, string>();\n const isSinglePackage = pkgReason.size === 1;\n const targetPkg = isSinglePackage ? [...pkgReason.keys()][0] : null;\n\n for (const f of all) {\n // If request confidently targets a single package, avoid pulling in unrelated package facts\n if (targetPkg === 'backend') {\n if (f.source.startsWith('frontend/') || f.key === 'stack.ui' || f.key.startsWith('convention.frontend')) {\n continue;\n }\n } else if (targetPkg === 'frontend') {\n if (f.source.startsWith('backend/') || f.key === 'stack.database' || f.key === 'stack.orm' || f.key.startsWith('testing.db')) {\n continue;\n }\n }\n\n // Match terms against fact key and value; only match source path against specific non-structural request words\n const mText = hit(`${f.key} ${f.value}`);\n const mSource = matchesQuery(f.source, kw.filter((w) => !PATH_STRUCTURAL_TERMS.has(w)));\n const m = [...new Set([...mText, ...mSource])];\n const nonWeak = m.filter(w => !WEAK_TERMS.has(w));\n if (nonWeak.length > 0) picked.set(f.key, `matches \"${nonWeak.slice(0, 3).join('\", \"')}\"`);\n }\n\n const group = (re: RegExp, why: string, also?: (f: Fact) => boolean): void => {\n for (const f of all) {\n if (picked.has(f.key)) continue;\n if (targetPkg === 'backend' && (f.source.startsWith('frontend/') || f.key === 'stack.ui' || f.key.startsWith('convention.frontend'))) continue;\n if (targetPkg === 'frontend' && (f.source.startsWith('backend/') || f.key === 'stack.database' || f.key === 'stack.orm' || f.key.startsWith('testing.db'))) continue;\n if (re.test(f.key) || also?.(f)) picked.set(f.key, why);\n }\n };\n\n // Package layout facts: include in multi-package/cross-package/uncertain contexts, omit global entry points in single-package tasks\n if (type !== 'QUESTION' && type !== 'DOCUMENTATION') {\n if (!isSinglePackage || type === 'ARCHITECTURE') {\n group(/^repo\\.(?:packages|entry-points|monorepo)$/, `package layout (${type})`);\n }\n }\n\n if (type === 'BUG' || type === 'SECURITY') group(ISSUE_KEY, 'known issue / limitation', (f) => f.status === 'STALE' && f.sourceType !== 'detector');\n\n if (BROAD_TYPES.includes(type)) {\n group(/^stack\\.ecosystem$/, `stack and conventions (${type})`);\n if (targetPkg === 'backend' || !isSinglePackage) {\n group(/^(?:arch\\.modules|convention\\.service-layer)$/, `architecture conventions (${type})`);\n group(/^(?:stack\\.framework|stack\\.database|stack\\.orm)$/, `backend stack (${type})`);\n }\n if (targetPkg === 'frontend' || !isSinglePackage) {\n group(/^(?:convention\\.frontend-components|stack\\.ui)$/, `frontend stack (${type})`);\n }\n }\n\n if (type === 'SECURITY') group(/^$/, 'security / authorization rule', (f) => SECURITY_WORDS.test(`${f.key} ${f.value}`));\n if (type === 'DOCUMENTATION') group(/^repo\\.docs$/, 'documentation index');\n const selected = all.filter((f) => picked.has(f.key));\n\n // Compaction: a detector fact whose value equals another selected fact's is folded into it. Human-authored facts are never folded or clipped.\n const aliases: TaskContextResult['aliases'] = [];\n const owners = new Map<string, string>();\n for (const f of [...selected].sort((a, b) => Number(a.sourceType === 'detector') - Number(b.sourceType === 'detector') || a.key.localeCompare(b.key))) {\n if (!owners.has(norm(f.value))) owners.set(norm(f.value), f.key);\n }\n const facts: TaskContextResult['facts'] = [];\n for (const f of [...selected].sort((a, b) => a.key.localeCompare(b.key))) {\n const owner = owners.get(norm(f.value))!;\n if (owner !== f.key && f.sourceType === 'detector') {\n aliases.push({ key: f.key, sameAs: owner });\n continue;\n }\n const clip = f.sourceType === 'detector' && f.value.length > CLIP;\n facts.push(clip ? { ...f, value: f.value.slice(0, CLIP), clipped: f.value.length - CLIP } : f);\n included.push({ kind: 'fact', id: f.key, reason: picked.get(f.key)! });\n }\n\n const usable = allChecks.filter((c) => c.available);\n const scoped = pkgReason.size > 0 ? usable.filter((c) => !c.cwd || c.cwd === '.' || pkgReason.has(c.cwd)) : usable;\n const checks = type === 'QUESTION' || type === 'DOCUMENTATION' ? [] : scoped;\n for (const c of checks) included.push({ kind: 'check', id: `${c.cwd ?? '.'}:${c.id}`, reason: c.cwd && pkgReason.has(c.cwd) ? `package: ${pkgReason.get(c.cwd)}` : `testing contract (${type})` });\n\n // Commands that must not run unguarded stay visible whenever their package's checks are in play.\n const safety: ContextResult['safety'] = [];\n for (const c of checks) {\n const s = classifyCommand(c, await readManifestEvidence(ws.root, c));\n if (s.safety !== 'safe') safety.push({ package: c.cwd ?? '.', check: c.id, command: c.command, safety: s.safety, reasons: s.reasons });\n }\n SAFETY_RULES.forEach((_, i) => included.push({ kind: 'rule', id: `safety-${i + 1}`, reason: 'safety rule, included in every context' }));\n\n // Decisions: titles, context, decision, consequences, and file references\n const decs = (await listDecisions(ws)).decisions;\n const wantAll = type === 'ARCHITECTURE' || type === 'SECURITY';\n const decisions: TaskContextResult['decisions'] = [];\n for (const d of decs) {\n const fullText = `${d.title} ${d.decision} ${d.context} ${d.consequences} ${d.file}`;\n const m = matchesQuery(fullText, expandedTerms);\n const nonWeak = m.filter(w => !WEAK_TERMS.has(w));\n if (d.status === 'superseded' && nonWeak.length === 0) continue;\n if (nonWeak.length > 0 || wantAll) {\n decisions.push({ number: d.number, title: d.title, status: d.status, file: d.file });\n included.push({ kind: 'decision', id: String(d.number).padStart(4, '0'), reason: nonWeak.length > 0 ? `matches \"${nonWeak[0]}\"` : `${type} tasks review all decisions` });\n }\n }\n\n // Documents: referenced, never embedded\n const documents: TaskContextResult['documents'] = [];\n let docCount = 0;\n if (await pathExists(ws.contextDir)) {\n for (const name of (await fs.readdir(ws.contextDir)).filter((n) => n.endsWith('.md')).sort()) {\n docCount++;\n const byType = (DOCS_BY_TYPE[type] ?? []).includes(name);\n const m = matchesQuery(name, expandedTerms);\n if (byType || m.length > 0) {\n documents.push({ name, bytes: (await fs.stat(path.join(ws.contextDir, name))).size });\n included.push({ kind: 'document', id: name, reason: byType ? `reference for ${type}` : `request names \"${m[0]}\"` });\n }\n }\n }\n\n return {\n project: { name: project.name, id: project.projectId },\n request,\n type,\n confidence: cls.confidence,\n readOnly: cls.readOnly,\n facts,\n aliases,\n checks,\n safety,\n rules: SAFETY_RULES,\n decisions,\n documents,\n packages: [...pkgReason.keys()].sort(),\n included,\n counts: { facts: [facts.length, all.length], checks: [checks.length, usable.length], decisions: [decisions.length, decs.length], documents: [documents.length, docCount] },\n };\n}\n\nexport async function getTaskContext(\n o: ServiceOptions,\n opts: { request: string; role?: ContextRole },\n): Promise<TaskContextResult> {\n const base = await buildBaseTaskContext(o, opts.request);\n if (!opts.role) return base;\n return getAgentContextSlice(o, { request: opts.request, role: opts.role, base });\n}\n\nexport async function getAgentContextSlice(\n o: ServiceOptions,\n opts: { request: string; role: ContextRole; base?: TaskContextResult },\n): Promise<TaskContextResult> {\n const ws = await requireWorkspace(o.cwd);\n const base = opts.base ?? (await buildBaseTaskContext(o, opts.request));\n const role = opts.role;\n const kw = words(opts.request);\n const expandedTerms = expandQueryTerms(kw);\n const hit = (text: string): string[] => matchesQuery(text, expandedTerms);\n\n let slicedFacts = [...base.facts];\n let slicedChecks = [...base.checks];\n let slicedDecisions = [...base.decisions];\n let slicedDocuments = [...base.documents];\n let roleGuidance: string[] = [];\n const roleFindings: NonNullable<TaskContextResult['roleFindings']> = {};\n\n if (role === 'explorer') {\n // Explorer: Prioritize entry points, symbols, features, graph connections.\n // Avoid unrelated test commands, entire file contents, complete repo dumps.\n slicedChecks = [];\n slicedFacts = base.facts.filter((f) => {\n if (/^repo\\.(?:entry-points|packages|monorepo)$/.test(f.key)) return true;\n if (STACK_KEY.test(f.key) && !/^convention\\.test/i.test(f.key)) return true;\n const m = hit(`${f.key} ${f.value}`);\n return m.length > 0 && !/^convention\\.test/i.test(f.key);\n });\n\n slicedDecisions = base.decisions.slice(0, 3);\n slicedDocuments = base.documents.filter((d) => ['architecture.md', 'integrations.md'].includes(d.name));\n\n // Entry points from facts or packages\n const epFact = base.facts.find((f) => f.key === 'repo.entry-points');\n const entryPoints: string[] = [];\n if (epFact && epFact.value) {\n for (const p of epFact.value.split(',').map((x) => x.trim()).filter(Boolean)) {\n if (!entryPoints.includes(p)) entryPoints.push(p);\n }\n }\n if (entryPoints.length === 0 && base.packages.length > 0) {\n entryPoints.push(...base.packages);\n }\n if (entryPoints.length > 0) roleFindings.entryPoints = entryPoints.slice(0, 10);\n\n // Feature knowledge map references\n try {\n const featFile = await loadFeatures(ws);\n const matchedFeats = featFile.features.filter((f) => {\n const text = `${f.id} ${f.name} ${f.description ?? ''} ${(f.tags ?? []).join(' ')}`;\n return hit(text).length > 0;\n });\n if (matchedFeats.length > 0) {\n roleFindings.features = matchedFeats.slice(0, 8).map((f) => ({\n id: f.id,\n name: f.name,\n status: f.status,\n }));\n }\n } catch {\n // Graceful fallback if features file unreadable\n }\n\n // Graphify graph lookup\n try {\n const graph = await loadGraphData(ws.root);\n if (graph.exists && graph.data && graph.data.nodes) {\n const matchedNodes: NonNullable<TaskContextResult['roleFindings']>['graphNodes'] = [];\n for (const w of expandedTerms) {\n const n = findMatchingStartNode(graph.data.nodes, w);\n if (n && !matchedNodes.some((x) => x.id === n.id)) {\n matchedNodes.push({\n id: n.id,\n status: typeof n.status === 'string' ? n.status : 'symbol',\n path: n.path || n.file || null,\n symbol: typeof n.name === 'string' ? n.name : null,\n });\n }\n if (matchedNodes.length >= 6) break;\n }\n if (matchedNodes.length > 0) roleFindings.graphNodes = matchedNodes;\n }\n } catch {\n // Graceful fallback if graph lookup fails\n }\n\n roleGuidance = [\n 'Investigate referenced entry points and feature components before reading full files.',\n 'Trace deep call dependencies with \"devworkspace graph trace <symbol>\".',\n 'Conclude exploration with a concise handoff: identified files, uncertainty, and next step.',\n ];\n } else if (role === 'tester') {\n // Tester: Prioritize test files, test framework conventions, verification contracts, zero-test safeguards.\n slicedFacts = base.facts.filter((f) => {\n if (/^convention\\.test/i.test(f.key) || ISSUE_KEY.test(f.key)) return true;\n if (STACK_KEY.test(f.key) && /test/i.test(f.key + f.value)) return true;\n const m = hit(`${f.key} ${f.value}`.toLowerCase());\n return m.length > 0;\n });\n\n slicedChecks = base.checks;\n slicedDocuments = base.documents.filter((d) => d.name === 'testing.md');\n slicedDecisions = base.decisions.filter((d) => /test|verify|quality/i.test(d.title));\n\n roleFindings.zeroTestSafeguards = [\n 'Zero-test pass detection active across Vitest, Jest, Pytest, Mocha, Go, and Cargo.',\n 'Commands exiting code 0 with 0 tests executed are classified as unverified false passes.',\n 'Record baseline before modifications: devworkspace task tests <id> --phase baseline --passed <n> --failed <n>.',\n \"Execute verification via 'devworkspace task run <id> <check>'.\",\n ];\n\n roleGuidance = [\n 'Verify required contract commands for affected packages before claiming completion.',\n 'Write focused regression tests covering defect reproduction or feature acceptance criteria.',\n 'Never run destructive commands or test suites touching unmanaged databases without \"testenv declare\".',\n ];\n } else if (role === 'reviewer') {\n // Reviewer: Prioritize git diff/changed files, permanent safety rules, ADRs, potential regressions.\n slicedFacts = base.facts.filter((f) => {\n if (SECURITY_WORDS.test(`${f.key} ${f.value}`)) return true;\n if (/^convention\\./i.test(f.key)) return true;\n const m = hit(`${f.key} ${f.value}`.toLowerCase());\n return m.length > 0;\n });\n\n // Keep review-relevant checks (lint, typecheck, review, and test suites)\n if (base.checks.length > 0) {\n slicedChecks = base.checks.filter((c) => /lint|typecheck|review|test/i.test(c.id));\n } else {\n try {\n if (await pathExists(ws.commands)) {\n const contract = (await readVersioned(ws.commands, 'commands', SCHEMA_VERSION, validateCommands)).data.checks;\n const usable = contract.filter((c) => c.available && /lint|typecheck|review|test/i.test(c.id));\n slicedChecks = base.packages.length > 0\n ? usable.filter((c) => !c.cwd || c.cwd === '.' || base.packages.includes(c.cwd))\n : usable;\n }\n } catch {\n slicedChecks = [];\n }\n }\n slicedDecisions = base.decisions;\n slicedDocuments = base.documents.filter((d) => ['conventions.md', 'architecture.md'].includes(d.name));\n\n try {\n const dirty = await dirtyFiles(ws.root);\n const dirtyList = dirty ? Object.keys(dirty.files) : [];\n if (dirtyList.length > 0) {\n const preview = dirtyList.slice(0, 5).join(', ') + (dirtyList.length > 5 ? ` (+${dirtyList.length - 5} more)` : '');\n roleFindings.diffNotice = `${dirtyList.length} uncommitted file(s) detected: ${preview}. Inspect exact diff with \"git diff\".`;\n } else {\n roleFindings.diffNotice = 'No uncommitted changes detected in working tree. When reviewing a branch or PR, the caller must supply the target diff or commit range.';\n }\n } catch {\n roleFindings.diffNotice = 'Could not inspect git working tree status. The caller must supply the diff or commit range.';\n }\n\n roleGuidance = [\n 'Audit diff against permanent SAFETY_RULES (no secrets in code/logs, no path traversals, untrusted commands).',\n 'Verify changes strictly comply with recorded decisions (ADRs) and feature contracts.',\n 'Ensure required verification checks have executed results before approving the completion gate.',\n ];\n }\n\n const factKeys = new Set(slicedFacts.map((f) => f.key));\n const checkIds = new Set(slicedChecks.map((c) => `${c.cwd ?? '.'}:${c.id}`));\n const decIds = new Set(slicedDecisions.map((d) => String(d.number).padStart(4, '0')));\n const docNames = new Set(slicedDocuments.map((d) => d.name));\n\n const included: ContextItem[] = base.included.filter((item) => {\n if (item.kind === 'rule') return true;\n if (item.kind === 'fact') return factKeys.has(item.id);\n if (item.kind === 'check') return checkIds.has(item.id);\n if (item.kind === 'decision') return decIds.has(item.id);\n if (item.kind === 'document') return docNames.has(item.id);\n return false;\n });\n\n included.push({\n kind: 'rule',\n id: `role:${role}`,\n reason: `context tailored for ${role} role (Phase 1 role-based context slicing)`,\n });\n\n return {\n ...base,\n role,\n facts: slicedFacts,\n checks: slicedChecks,\n decisions: slicedDecisions,\n documents: slicedDocuments,\n rules: SAFETY_RULES,\n included,\n counts: {\n facts: [slicedFacts.length, base.counts.facts[1]],\n checks: [slicedChecks.length, base.counts.checks[1]],\n decisions: [slicedDecisions.length, base.counts.decisions[1]],\n documents: [slicedDocuments.length, base.counts.documents[1]],\n },\n roleGuidance,\n roleFindings,\n };\n}\n"]}
|
package/docs/agents.md
CHANGED
|
@@ -50,6 +50,38 @@ Every adapter implements the `AgentAdapter` contract defined in `src/agents/type
|
|
|
50
50
|
- **Doctor & Readiness (`devworkspace doctor`)**:
|
|
51
51
|
`doctor` checks for the presence and freshness of installed instructions for whichever agents are configured in the project. Projects using Cursor, Copilot, or Codex achieve `Core workspace: READY` without requiring `CLAUDE.md`.
|
|
52
52
|
|
|
53
|
+
## Model Context Protocol (MCP) Integration
|
|
54
|
+
|
|
55
|
+
For agents that support the Model Context Protocol (such as Claude Code, OpenAI Codex, and Google Antigravity), DevWorkspace can be configured as a local stdio MCP server:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Configure Claude Code (.mcp.json)
|
|
59
|
+
devworkspace setup --agent claude-code
|
|
60
|
+
|
|
61
|
+
# Configure OpenAI Codex (mcp.json)
|
|
62
|
+
devworkspace setup --agent codex
|
|
63
|
+
|
|
64
|
+
# Configure Google Antigravity (.antigravity/mcp.json)
|
|
65
|
+
devworkspace setup --agent antigravity
|
|
66
|
+
|
|
67
|
+
# Preview planned configuration changes without modifying files:
|
|
68
|
+
devworkspace setup --agent claude-code --check
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
See [docs/mcp.md](mcp.md) for full protocol details, security boundaries, and debugging instructions.
|
|
72
|
+
|
|
73
|
+
### Instruction Markers Coexistence
|
|
74
|
+
|
|
75
|
+
DevWorkspace strictly segregates standard CLI instructions from MCP instructions using dedicated HTML comment markers:
|
|
76
|
+
- Standard Agent Instructions: `<!-- devworkspace:start -->` ... `<!-- devworkspace:end -->`
|
|
77
|
+
- MCP Agent Instructions: `<!-- devworkspace-mcp:start -->` ... `<!-- devworkspace-mcp:end -->`
|
|
78
|
+
|
|
79
|
+
Both sets of instructions can coexist in the same project files (e.g. `CLAUDE.md`, `AGENTS.md`, or `.antigravity/rules`). Running `devworkspace agent install` or `devworkspace setup --agent <name>` will never overwrite or clobber the other block, and all custom user notes outside the blocks are preserved byte-for-byte.
|
|
80
|
+
|
|
81
|
+
### MCP PATH Requirements
|
|
82
|
+
|
|
83
|
+
The generated agent configurations register `"command": "devworkspace"`. Ensure that `devworkspace` is available in your system `PATH` (such as via `npm install -g devworkspace`). If you prefer running without global binaries, modify the command in `.mcp.json` / `mcp.json` / `.antigravity/mcp.json` to `"npx"` with arguments `["-y", "devworkspace", "mcp", "serve"]`.
|
|
84
|
+
|
|
53
85
|
## Adding a New Agent Adapter
|
|
54
86
|
|
|
55
87
|
To add support for a new coding agent:
|