cladogram 0.6.0-beta.1 → 0.6.0-beta.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/bin/clado.js +34 -2
- package/docs/release.md +16 -0
- package/package.json +1 -1
- package/plugins/agent/index.js +1544 -127
- package/plugins/agent/style.css +859 -56
- package/plugins/view-controls/style.css +7 -7
- package/src/agent/clado-tools.js +437 -103
- package/src/agent/pi-bridge.js +669 -60
- package/src/agent/pi-config.js +367 -31
- package/src/html/canvas-chain.js +26 -2
- package/src/html/canvas-focus.js +19 -13
- package/src/html/canvas-live-diff.js +927 -0
- package/src/html/canvas-ui.css +365 -0
- package/src/html/canvas-wires.js +5 -1
- package/src/html/page.js +1 -1
- package/src/html/plugin-ui.css +1 -1
- package/src/html/runtime-api.js +140 -10
- package/src/html/runtime.js +93 -26
- package/src/server/agent.js +46 -8
- package/src/server/assets/library-canvas.js +240 -5
- package/src/server/assets/library.css +428 -12
- package/src/server/assets/library.html +2 -0
- package/src/server/assets/library.js +703 -14
- package/src/server/code-inspect.js +183 -0
- package/src/server/mcp.js +4 -4
- package/src/server/workspace.js +260 -18
- package/src/workspace/graph-snapshot.js +695 -0
- package/src/workspace/service.js +11 -1
package/src/workspace/service.js
CHANGED
|
@@ -9,6 +9,7 @@ import { editContent, paragraphs, paragraphLocations, contentLocation } from './
|
|
|
9
9
|
import { markdownLinks } from '../core/links.js';
|
|
10
10
|
import { blockMedia, findTargetLineOffset, formatTargetPoint, mediaBlockByIndex, mediaLinkLocations, mediaLinkTitle, mediaPointFits, mediaTargetPoint } from '../core/media-links.js';
|
|
11
11
|
import { sortDiagnostics, summarizeDiagnostics } from '../core/diagnostics.js';
|
|
12
|
+
import { buildDocumentGraph, buildWorkspaceGraph } from './graph-snapshot.js';
|
|
12
13
|
|
|
13
14
|
const copySnapshot = state => ({ ...state, documents: new Map(state.documents), templates: new Map(state.templates) });
|
|
14
15
|
const required = (value, name) => { if (value === undefined || value === null || value === '') fail('缺少参数:' + name); return value; };
|
|
@@ -454,12 +455,20 @@ export function createWorkspaceService(scope, { documentRoot, readSelection } =
|
|
|
454
455
|
}
|
|
455
456
|
if (args.action === 'init' || args.action === 'inspect') return { ...common, documentRoot: ctx.documents, templateRoot: ctx.templates, ancestorTemplateRoots: ancestorRoots, documents: [...state.documents].map(([file, source]) => ({ file, version: versionOf(source), title: parseDocument(source).doc.title })) };
|
|
456
457
|
if (args.action === 'validate') { const diagnostics = validate(state, state.documents.keys(), true); return { ...common, valid: !diagnostics.some(d => d.severity === 'error'), diagnostics }; }
|
|
458
|
+
if (args.action === 'graph') {
|
|
459
|
+
if (args.file) {
|
|
460
|
+
safeFile(ctx.documents, args.file);
|
|
461
|
+
if (!state.documents.has(args.file)) fail('文档不存在:' + args.file, 404);
|
|
462
|
+
return { ...common, ...buildDocumentGraph(args.file, state.documents) };
|
|
463
|
+
}
|
|
464
|
+
return { ...common, ...buildWorkspaceGraph(state.documents) };
|
|
465
|
+
}
|
|
457
466
|
if (args.action === 'search') {
|
|
458
467
|
const query = required(args.query, 'query').toLowerCase(), hits = [];
|
|
459
468
|
for (const [file, source] of state.documents) for (const record of records(treeOf(source, file))) if ((file + '\n' + record.node.title + '\n' + record.node.content).toLowerCase().includes(query)) hits.push({ file, ...publicNode(record, args.includeContent === true) });
|
|
460
469
|
return { ...common, total: hits.length, nodes: hits.slice(args.offset || 0, (args.offset || 0) + (args.limit || 50)) };
|
|
461
470
|
}
|
|
462
|
-
fail('workspace action 支持 init / inspect / validate / search / selection / workspaces。');
|
|
471
|
+
fail('workspace action 支持 init / inspect / validate / search / selection / workspaces / graph。');
|
|
463
472
|
}
|
|
464
473
|
if (tool === 'clado_templates' && ['list', 'read'].includes(args.action)) {
|
|
465
474
|
const scope = args.scope || 'project', visible = scope === 'user' ? { templates: new Map(), userTemplates: userState.templates, userTemplateRoot: user.templates } : state;
|
|
@@ -495,6 +504,7 @@ export function createWorkspaceService(scope, { documentRoot, readSelection } =
|
|
|
495
504
|
if (tool === 'clado_documents' && args.action === 'list') return { ...common, documents: [...state.documents].filter(([file, source]) => !args.query || (file + source).toLowerCase().includes(args.query.toLowerCase())).map(([file, source]) => { const item = treeOf(source, file); return { file, title: item.doc.title, version: item.version, hasHeader: splitFrontMatter(source).had, cards: item.doc.cards.length, diagnostics: item.diagnostics }; }) };
|
|
496
505
|
if (tool === 'clado_documents' && args.action === 'read') {
|
|
497
506
|
safeFile(ctx.documents, args.file); const source = state.documents.get(args.file); if (source === undefined) fail('文档不存在。', 404);
|
|
507
|
+
if (args.view === 'graph') return { ...common, ...buildDocumentGraph(args.file, state.documents) };
|
|
498
508
|
const item = treeOf(source, args.file), all = records(item), identity = { ...common, file: args.file, version: item.version, title: item.doc.title };
|
|
499
509
|
if (args.view === 'source') return { ...identity, source };
|
|
500
510
|
if (args.view === 'summary') return { ...identity, cards: item.doc.cards.length, nodeCount: all.length, hasHeader: splitFrontMatter(source).had, templateId: item.doc.meta.id || null, templateVersion: item.doc.meta.version || null };
|