devworkspace 0.4.2 → 0.4.3
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 +24 -0
- package/README.md +213 -19
- package/dist/cli/args.d.ts +6 -0
- package/dist/cli/args.js +2 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/run.js +17 -0
- package/dist/cli/run.js.map +1 -1
- package/dist/mcp/setup.d.ts +24 -1
- package/dist/mcp/setup.js +51 -3
- package/dist/mcp/setup.js.map +1 -1
- package/dist/mcp/tools.js +73 -5
- package/dist/mcp/tools.js.map +1 -1
- package/dist/services/doctor.js +76 -0
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/graph.d.ts +7 -0
- package/dist/services/graph.js +18 -9
- package/dist/services/graph.js.map +1 -1
- package/dist/services/init.js +5 -1
- package/dist/services/init.js.map +1 -1
- package/dist/services/setup.js +1 -0
- package/dist/services/setup.js.map +1 -1
- package/dist/services/taskContext.d.ts +4 -0
- package/dist/services/taskContext.js +50 -18
- package/dist/services/taskContext.js.map +1 -1
- package/dist/tasks/routing.js +4 -1
- package/dist/tasks/routing.js.map +1 -1
- package/docs/agents.md +16 -2
- package/docs/mcp.md +4 -3
- package/package.json +1 -1
package/dist/mcp/tools.js
CHANGED
|
@@ -3,14 +3,14 @@ import path from 'node:path';
|
|
|
3
3
|
import { requireWorkspace, loadProject } from '../core/workspace.js';
|
|
4
4
|
import { loadFacts, evaluateStaleness, authorityRank } from '../knowledge/facts.js';
|
|
5
5
|
import { getStatus } from '../services/status.js';
|
|
6
|
-
import { getTaskContext, isContextRole, words, expandQueryTerms, matchesQuery, } from '../services/taskContext.js';
|
|
6
|
+
import { getTaskContext, isContextRole, words, expandQueryTerms, matchesQuery, STOP, WEAK_TERMS, PATH_STRUCTURAL_TERMS, } from '../services/taskContext.js';
|
|
7
7
|
import { loadFeatures } from '../services/features.js';
|
|
8
8
|
import { listDecisions } from '../decisions/decision.js';
|
|
9
9
|
import { packageVersion } from '../core/version.js';
|
|
10
10
|
import { MCP_SECTION_START, MCP_SECTION_END } from './setup.js';
|
|
11
11
|
import { IgnoreMatcher } from '../discovery/ignore.js';
|
|
12
|
-
import { ALWAYS_SKIP_DIRS } from '../discovery/scan.js';
|
|
13
|
-
import { traceGraphService } from '../services/graph.js';
|
|
12
|
+
import { ALWAYS_SKIP_DIRS, scanProject } from '../discovery/scan.js';
|
|
13
|
+
import { traceGraphService, loadGraphData } from '../services/graph.js';
|
|
14
14
|
import { isSensitiveFile, safeReadText } from '../security/files.js';
|
|
15
15
|
import { redact } from '../security/redact.js';
|
|
16
16
|
import { assertNoSymlinkEscape, isInside, looksAbsolute, resolveInside, toPosix, validateRelativePath, } from '../utils/paths.js';
|
|
@@ -240,7 +240,7 @@ function scoreFact(f, terms) {
|
|
|
240
240
|
score += valMatches * 15;
|
|
241
241
|
return score;
|
|
242
242
|
}
|
|
243
|
-
function formatTaskContextText(r, task, maxChars, extraFeatures) {
|
|
243
|
+
function formatTaskContextText(r, task, maxChars, extraFeatures, knownFiles, graphNotice) {
|
|
244
244
|
const parts = [];
|
|
245
245
|
const kw = words(task);
|
|
246
246
|
const terms = expandQueryTerms(kw);
|
|
@@ -269,11 +269,53 @@ function formatTaskContextText(r, task, maxChars, extraFeatures) {
|
|
|
269
269
|
return;
|
|
270
270
|
if (looksAbsolute(posixPath))
|
|
271
271
|
return;
|
|
272
|
+
// Reject non-path descriptions, labels, and detector summaries
|
|
273
|
+
if (posixPath.includes(',') || /^(?:package scripts|package manifests|workspace detector|unknown)/i.test(posixPath)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
// If knownFiles is provided, strictly enforce workspace containment
|
|
277
|
+
if (knownFiles && knownFiles.size > 0 && !knownFiles.has(posixPath)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// If knownFiles is not provided, ensure it resembles a valid path without spaces
|
|
281
|
+
if (posixPath.includes(' ') || (!posixPath.includes('/') && !posixPath.includes('.'))) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
272
284
|
const existing = fileCandidates.get(posixPath);
|
|
273
285
|
if (!existing || score > existing.score) {
|
|
274
286
|
fileCandidates.set(posixPath, { path: posixPath, reason, score });
|
|
275
287
|
}
|
|
276
288
|
};
|
|
289
|
+
// 1. Path-based candidate discovery from workspace files (works even without features/graph)
|
|
290
|
+
if (knownFiles && knownFiles.size > 0) {
|
|
291
|
+
const DOMAIN_TERMS = terms.filter((t) => !STOP.has(t) && !WEAK_TERMS.has(t) && !PATH_STRUCTURAL_TERMS.has(t) && t.length >= 3);
|
|
292
|
+
const activeTerms = DOMAIN_TERMS.length > 0 ? DOMAIN_TERMS : terms.filter((t) => t.length >= 3 && !STOP.has(t));
|
|
293
|
+
const targetPkg = r.packages.length > 0 ? r.packages[0] : null;
|
|
294
|
+
for (const filePath of knownFiles) {
|
|
295
|
+
if (filePath.startsWith('.devworkspace/') || isSensitiveFile(filePath))
|
|
296
|
+
continue;
|
|
297
|
+
const baseName = filePath.split('/').pop() ?? filePath;
|
|
298
|
+
const nameWithoutExt = baseName.replace(/\.[^.]+$/, '').toLowerCase();
|
|
299
|
+
const segments = filePath.toLowerCase().split('/');
|
|
300
|
+
const dirSegments = segments.slice(0, -1);
|
|
301
|
+
const subTokens = nameWithoutExt.split(/[^a-z0-9]+/).concat(nameWithoutExt.replace(/([a-z])([A-Z])/g, '$1 $2').toLowerCase().split(/\s+/));
|
|
302
|
+
const pkgBoost = targetPkg && filePath.startsWith(`${targetPkg}/`) ? 5 : 0;
|
|
303
|
+
for (const t of activeTerms) {
|
|
304
|
+
if (nameWithoutExt === t) {
|
|
305
|
+
addCandidate(filePath, `path matches "${t}"`, 65 + pkgBoost);
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
else if (subTokens.includes(t) || nameWithoutExt.startsWith(`${t}-`) || nameWithoutExt.startsWith(`${t}.`)) {
|
|
309
|
+
addCandidate(filePath, `path matches "${t}"`, 60 + pkgBoost);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
else if (dirSegments.some((seg) => seg === t || seg.split(/[^a-z0-9]+/).includes(t))) {
|
|
313
|
+
addCandidate(filePath, `path matches "${t}"`, 50 + pkgBoost);
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
277
319
|
const allFeatures = r.roleFindings?.features ?? extraFeatures;
|
|
278
320
|
if (allFeatures) {
|
|
279
321
|
for (const feat of allFeatures) {
|
|
@@ -341,6 +383,9 @@ function formatTaskContextText(r, task, maxChars, extraFeatures) {
|
|
|
341
383
|
parts.push(`- ${node.id} (${node.status})${node.path ? `: \`${node.path}\`` : ''}`);
|
|
342
384
|
}
|
|
343
385
|
}
|
|
386
|
+
else if (rf.graphNotice) {
|
|
387
|
+
parts.push(`\n### Graphify Knowledge Graph\n- ${rf.graphNotice}`);
|
|
388
|
+
}
|
|
344
389
|
if (rf.testFrameworks && rf.testFrameworks.length > 0) {
|
|
345
390
|
parts.push(`\n### Test Frameworks: ${rf.testFrameworks.join(', ')}`);
|
|
346
391
|
}
|
|
@@ -354,6 +399,9 @@ function formatTaskContextText(r, task, maxChars, extraFeatures) {
|
|
|
354
399
|
parts.push(`\n### Review Notice: ${rf.diffNotice}`);
|
|
355
400
|
}
|
|
356
401
|
}
|
|
402
|
+
else if (graphNotice) {
|
|
403
|
+
parts.push(`\n### Graphify Knowledge Graph\n- ${graphNotice}`);
|
|
404
|
+
}
|
|
357
405
|
// Display features if available
|
|
358
406
|
if (allFeatures && allFeatures.length > 0) {
|
|
359
407
|
parts.push('\n### Relevant Features');
|
|
@@ -540,7 +588,27 @@ export async function handleTaskContext(workspaceRoot, rawArgs) {
|
|
|
540
588
|
// Fallback gracefully
|
|
541
589
|
}
|
|
542
590
|
}
|
|
543
|
-
|
|
591
|
+
let knownFiles;
|
|
592
|
+
try {
|
|
593
|
+
const scan = await scanProject(ws.root, { maxFiles: 5000, maxDepth: 10 });
|
|
594
|
+
knownFiles = scan.files;
|
|
595
|
+
}
|
|
596
|
+
catch {
|
|
597
|
+
// Degrade gracefully if scanning fails
|
|
598
|
+
}
|
|
599
|
+
let graphNotice = result.roleFindings?.graphNotice;
|
|
600
|
+
if (!graphNotice && !result.roleFindings?.graphNodes) {
|
|
601
|
+
try {
|
|
602
|
+
const graph = await loadGraphData(ws.root);
|
|
603
|
+
if (!graph.exists) {
|
|
604
|
+
graphNotice = 'No Graphify knowledge graph found at graphify-out/graph.json. Run "graphify update ." or "/graphify ." in Claude Code to map symbol dependencies.';
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
catch (err) {
|
|
608
|
+
graphNotice = `Graphify knowledge graph unavailable (${err.message}). Retrieval continuing without graph symbol data.`;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
const formatted = formatTaskContextText(result, task, maxChars, extraFeatures, knownFiles, graphNotice);
|
|
544
612
|
return {
|
|
545
613
|
content: [{ type: 'text', text: formatted }],
|
|
546
614
|
isError: false,
|