cladogram 0.5.3 → 0.5.5-beta.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/README.md +25 -6
- package/bin/clado.js +17 -6
- package/docs/plugin-development.md +135 -0
- package/docs/plugin-ui.md +43 -0
- package/docs/release.md +14 -0
- package/package.json +7 -1
- package/plugins/agent/index.js +181 -0
- package/plugins/agent/style.css +105 -0
- package/plugins/brand/index.js +262 -0
- package/plugins/brand/style.css +162 -0
- package/plugins/directory/capabilities.json +27 -0
- package/plugins/directory/index.js +201 -0
- package/plugins/directory/style.css +59 -0
- package/plugins/view-controls/index.js +58 -0
- package/plugins/view-controls/style.css +66 -0
- package/skills/clado/SKILL.md +19 -15
- package/src/html/app-css.js +69 -47
- package/src/html/canvas-chain.js +7 -7
- package/src/html/canvas-focus.js +2 -4
- package/src/html/canvas-screenshot.js +199 -0
- package/src/html/canvas-ui.css +5 -9
- package/src/html/canvas-ui.js +35 -27
- package/src/html/page.js +11 -37
- package/src/html/plugin-assets.js +33 -0
- package/src/html/plugin-ui.css +188 -0
- package/src/html/plugin-ui.js +51 -0
- package/src/html/runtime-api.js +41 -0
- package/src/html/runtime.js +164 -87
- package/src/server/agent.js +223 -0
- package/src/server/assets/clado-plugin-sdk.js +111 -0
- package/src/server/assets/library-canvas.js +14 -10
- package/src/server/assets/library-plugin-bridge.js +84 -0
- package/src/server/assets/library-plugins.css +39 -0
- package/src/server/assets/library-plugins.js +200 -0
- package/src/server/assets/library.css +8 -6
- package/src/server/assets/library.html +3 -13
- package/src/server/assets/library.js +280 -47
- package/src/server/canvas-capture.js +47 -0
- package/src/server/export.js +6 -3
- package/src/server/mcp.js +40 -17
- package/src/server/plugin-capabilities.js +188 -0
- package/src/server/plugin-settings.js +117 -0
- package/src/server/plugins.js +236 -0
- package/src/server/workspace.js +222 -29
- package/src/skill/install.js +1 -1
- package/src/skill/targets.js +3 -3
- package/src/util/update.js +3 -2
- package/src/vendor/html-to-image.min.js +24 -0
- package/src/workspace/service.js +21 -13
- package/src/workspace/storage.js +88 -20
- package/templates/business-flow.mdc +1 -1
- package/templates/call-chain.mdc +1 -1
- package/templates/data-design.mdc +1 -1
- package/src/server/assets/tree.js +0 -26
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
function renderTree(container, documents, { selected='', query='', onOpen=()=>{}, folders=new Set() } = {}) {
|
|
3
|
+
const needle=query.trim().toLocaleLowerCase(), root={folders:new Map(),files:[]};
|
|
4
|
+
for(const doc of documents) {
|
|
5
|
+
if(needle && !(doc.title+' '+doc.file).toLocaleLowerCase().includes(needle))continue;
|
|
6
|
+
const parts=doc.file.split('/');let node=root;
|
|
7
|
+
parts.slice(0,-1).forEach((name,i)=>{const path=parts.slice(0,i+1).join('/');if(!node.folders.has(name))node.folders.set(name,{path,folders:new Map(),files:[]});node=node.folders.get(name);});node.files.push(doc);
|
|
8
|
+
}
|
|
9
|
+
container.replaceChildren();
|
|
10
|
+
function render(node, parent) {
|
|
11
|
+
for(const [name,folder] of node.folders) {
|
|
12
|
+
const details=document.createElement('details');details.className='tree-folder';details.open=!!needle||!folders.has('closed:'+folder.path);
|
|
13
|
+
const summary=document.createElement('summary');summary.textContent=name;details.append(summary);
|
|
14
|
+
details.addEventListener('toggle',()=>{if(!needle){if(details.open)folders.delete('closed:'+folder.path);else folders.add('closed:'+folder.path);}});
|
|
15
|
+
const children=document.createElement('div');children.className='tree-children';details.append(children);render(folder,children);parent.append(details);
|
|
16
|
+
}
|
|
17
|
+
for(const doc of node.files) {
|
|
18
|
+
const button=document.createElement('button');button.className='clado-ui-button document-button';button.dataset.file=doc.file;if(doc.file===selected)button.setAttribute('aria-current','page');
|
|
19
|
+
const strong=document.createElement('strong');strong.textContent=doc.title;
|
|
20
|
+
const small=document.createElement('small');small.textContent=doc.file.split('/').pop();button.append(strong,small);button.onclick=()=>onOpen(doc.file);parent.append(button);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
render(root,container);
|
|
24
|
+
if(!container.childElementCount){const empty=document.createElement('p');empty.className='tree-empty';empty.textContent=needle?'没有匹配的文档':'还没有可展示的文档';container.append(empty);}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
window.CladoDirectoryPlugin = (host, actions) => {
|
|
28
|
+
const content = document.createElement('div');
|
|
29
|
+
content.className = 'clado-directory-plugin';
|
|
30
|
+
content.innerHTML = `
|
|
31
|
+
<button type="button" id="directoryButton" class="clado-ui-glass clado-ui-button directory-toggle" aria-expanded="false" aria-controls="directory" title="切换 Markdown 画布">
|
|
32
|
+
<svg aria-hidden="true" viewBox="0 0 24 24"><path d="M4 7a2 2 0 0 1 2-2h4l2 2h6a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2Z"/></svg>
|
|
33
|
+
<span id="currentWorkspaceName" hidden></span>
|
|
34
|
+
文档 <span id="fileCount">…</span><span id="currentFileName" hidden></span>
|
|
35
|
+
</button>
|
|
36
|
+
<aside id="directory" class="clado-ui-glass clado-ui-glass-panel" aria-label="Markdown 画布目录" hidden>
|
|
37
|
+
<div class="directory-scroll">
|
|
38
|
+
<div id="workspaceSection" class="directory-workspaces" hidden>
|
|
39
|
+
<div class="directory-workspaces-title">工作区</div>
|
|
40
|
+
<div id="workspaceList" class="directory-workspace-list"></div>
|
|
41
|
+
</div>
|
|
42
|
+
<div class="directory-heading"><strong>Markdown/</strong></div>
|
|
43
|
+
<label class="directory-search"><input id="documentSearch" type="search" aria-label="搜索文档" placeholder="搜索名称或路径…"></label>
|
|
44
|
+
<nav id="documentList" aria-label="可用 Markdown"></nav>
|
|
45
|
+
<div class="directory-current"><span id="syncStatus" role="status">连接本地目录</span></div>
|
|
46
|
+
<div class="directory-actions"><button class="clado-ui-button" id="backButton" disabled>← 返回</button><button class="clado-ui-button" id="refreshButton" title="重新扫描目录并刷新当前文档">刷新</button><button class="clado-ui-button" id="sourceButton">源文</button></div>
|
|
47
|
+
<button id="skippedButton" class="clado-ui-button skipped" hidden></button>
|
|
48
|
+
</div>
|
|
49
|
+
</aside>
|
|
50
|
+
<dialog id="details" class="clado-ui-dialog"><header><strong id="detailsTitle"></strong><button id="closeDetails" class="clado-ui-button" aria-label="关闭详情">×</button></header><div id="detailsBody"></div></dialog>`;
|
|
51
|
+
host.mount('bottom-left', content, 'clado.directory');
|
|
52
|
+
host.capabilities('clado.directory', 'directory')?.provide(
|
|
53
|
+
({ input }) => actions.openFromCapability(input.file)).catch(error => console.warn('Clado 目录能力注册失败', error));
|
|
54
|
+
const $ = selector => content.querySelector(selector);
|
|
55
|
+
const trigger = $('#directoryButton'), directory = $('#directory'), search = $('#documentSearch'), dialog = $('#details');
|
|
56
|
+
const fileName = $('#currentFileName'), workspaceName = $('#currentWorkspaceName');
|
|
57
|
+
const folders = new Set();
|
|
58
|
+
let index = { documents: [], skipped: [] }, selected = '', canGoBack = false, signature = '', workspaceSignature = '', request = 0;
|
|
59
|
+
function setOpen(open) {
|
|
60
|
+
if (open && actions.isLocked()) return;
|
|
61
|
+
directory.hidden = !open;
|
|
62
|
+
trigger.setAttribute('aria-expanded', String(open));
|
|
63
|
+
if (open) search.focus();
|
|
64
|
+
}
|
|
65
|
+
function details(title, elements) {
|
|
66
|
+
if (actions.isLocked() || !content.isConnected) return;
|
|
67
|
+
$('#detailsTitle').textContent = title;
|
|
68
|
+
$('#detailsBody').replaceChildren(...elements);
|
|
69
|
+
if (!dialog.open) dialog.showModal();
|
|
70
|
+
}
|
|
71
|
+
function text(tag, value) {
|
|
72
|
+
const item = document.createElement(tag);
|
|
73
|
+
item.textContent = value;
|
|
74
|
+
return item;
|
|
75
|
+
}
|
|
76
|
+
function showMessage(title, message) { details(title, [text('p', message)]); }
|
|
77
|
+
function render() {
|
|
78
|
+
const query = search.value;
|
|
79
|
+
const next = JSON.stringify([index.documents.map(doc => [doc.file, doc.title]), index.skipped.length, selected, query, canGoBack, index.root]);
|
|
80
|
+
if (next === signature) return;
|
|
81
|
+
signature = next;
|
|
82
|
+
$('#fileCount').textContent = index.documents.length;
|
|
83
|
+
$('.directory-heading strong').textContent = index.root || 'Markdown';
|
|
84
|
+
renderTree($('#documentList'), index.documents, {
|
|
85
|
+
selected, query, folders, onOpen: file => { setOpen(false); actions.open(file); },
|
|
86
|
+
});
|
|
87
|
+
$('#skippedButton').hidden = !index.skipped.length;
|
|
88
|
+
$('#skippedButton').textContent = index.skipped.length + ' 份文档未收录 · 查看原因';
|
|
89
|
+
$('#backButton').disabled = actions.isLocked() || !canGoBack;
|
|
90
|
+
$('#sourceButton').disabled = actions.isLocked() || !selected;
|
|
91
|
+
}
|
|
92
|
+
function renderWorkspaces(current = '', items = []) {
|
|
93
|
+
const next = JSON.stringify([current, items.map(item => [item.id, item.name, item.documents])]);
|
|
94
|
+
if (next === workspaceSignature) return;
|
|
95
|
+
workspaceSignature = next;
|
|
96
|
+
if (current) {
|
|
97
|
+
workspaceName.textContent = current.split('/').pop();
|
|
98
|
+
workspaceName.title = current;
|
|
99
|
+
workspaceName.hidden = false;
|
|
100
|
+
} else {
|
|
101
|
+
workspaceName.hidden = true;
|
|
102
|
+
}
|
|
103
|
+
const section = $('#workspaceSection'), list = $('#workspaceList');
|
|
104
|
+
const show = items.length > 1 || !!current;
|
|
105
|
+
section.hidden = !show;
|
|
106
|
+
if (!show) return;
|
|
107
|
+
list.replaceChildren();
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
const row = document.createElement('div');
|
|
110
|
+
row.className = 'workspace-row';
|
|
111
|
+
const button = document.createElement('button');
|
|
112
|
+
button.type = 'button';
|
|
113
|
+
button.className = 'clado-ui-button workspace-button';
|
|
114
|
+
button.dataset.workspace = item.id;
|
|
115
|
+
if (item.id === current) button.setAttribute('aria-current', 'page');
|
|
116
|
+
const label = document.createElement('span');
|
|
117
|
+
label.className = 'workspace-label';
|
|
118
|
+
label.textContent = item.id || (item.name + '(根目录)');
|
|
119
|
+
label.title = item.workspace || item.id || item.name;
|
|
120
|
+
const count = document.createElement('small');
|
|
121
|
+
count.textContent = String(item.documents ?? 0);
|
|
122
|
+
button.append(label, count);
|
|
123
|
+
button.onclick = () => {
|
|
124
|
+
if (item.id === current) { setOpen(false); return; }
|
|
125
|
+
actions.switchWorkspace?.(item.id);
|
|
126
|
+
};
|
|
127
|
+
row.append(button);
|
|
128
|
+
if (actions.workspaceUrl) {
|
|
129
|
+
const openTab = document.createElement('a');
|
|
130
|
+
openTab.className = 'clado-ui-button workspace-open-tab';
|
|
131
|
+
openTab.href = actions.workspaceUrl(item.id);
|
|
132
|
+
openTab.target = '_blank';
|
|
133
|
+
openTab.rel = 'noopener';
|
|
134
|
+
openTab.title = '在新标签页打开';
|
|
135
|
+
openTab.textContent = '↗';
|
|
136
|
+
row.append(openTab);
|
|
137
|
+
}
|
|
138
|
+
list.append(row);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
trigger.onclick = () => setOpen(directory.hidden);
|
|
142
|
+
search.oninput = render;
|
|
143
|
+
document.addEventListener('pointerdown', event => {
|
|
144
|
+
if (!content.contains(event.target)) setOpen(false);
|
|
145
|
+
});
|
|
146
|
+
document.addEventListener('keydown', event => {
|
|
147
|
+
if (event.key === 'Escape' && !directory.hidden && !dialog.open) { setOpen(false); trigger.focus(); }
|
|
148
|
+
});
|
|
149
|
+
$('#refreshButton').onclick = actions.refresh;
|
|
150
|
+
$('#backButton').onclick = actions.back;
|
|
151
|
+
$('#closeDetails').onclick = () => dialog.close();
|
|
152
|
+
$('#skippedButton').onclick = () => details('扫描后未收录的 Markdown', index.skipped.map(item => {
|
|
153
|
+
const section = document.createElement('section');
|
|
154
|
+
section.className = 'skip-item';
|
|
155
|
+
section.append(text('strong', item.file), ...item.diagnostics.map(d => text('p', d.code + ' · ' + d.message)));
|
|
156
|
+
return section;
|
|
157
|
+
}));
|
|
158
|
+
$('#sourceButton').onclick = async () => {
|
|
159
|
+
if (actions.isLocked()) return;
|
|
160
|
+
const current = ++request;
|
|
161
|
+
try {
|
|
162
|
+
const result = await actions.readSource();
|
|
163
|
+
if (current !== request || selected !== result.file) return;
|
|
164
|
+
const note = result.offline ? '这是 HTML 内嵌的只读源文。通过 MCP 修改工作区后重新构建以更新交付文件。' : '源文只读预览。通过 Clado MCP 修改内容,当前画布会自动同步。';
|
|
165
|
+
details(result.file, [text('p', note), text('pre', result.source)]);
|
|
166
|
+
} catch {
|
|
167
|
+
if (current === request) showMessage('暂时读不到源文', '请检查文档是否已删除,或是否出现解析错误。');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
close: () => setOpen(false),
|
|
172
|
+
showMessage,
|
|
173
|
+
updateWorkspaces: renderWorkspaces,
|
|
174
|
+
update(next, file, hasHistory) {
|
|
175
|
+
if (file !== selected) {
|
|
176
|
+
request++;
|
|
177
|
+
fileName.textContent = file.split('/').pop();
|
|
178
|
+
fileName.title = file;
|
|
179
|
+
fileName.hidden = !file || actions.showFilename === false;
|
|
180
|
+
}
|
|
181
|
+
index = next; selected = file; canGoBack = hasHistory;
|
|
182
|
+
render();
|
|
183
|
+
},
|
|
184
|
+
status(message, error = false) {
|
|
185
|
+
const indicator = $('#syncStatus');
|
|
186
|
+
if (indicator.textContent !== message) indicator.textContent = message;
|
|
187
|
+
indicator.className = error ? 'sync-error' : 'sync-good';
|
|
188
|
+
trigger.dataset.sync = error ? 'error' : 'ok';
|
|
189
|
+
trigger.title = '切换 Markdown 画布 · ' + message;
|
|
190
|
+
},
|
|
191
|
+
setLocked(locked) {
|
|
192
|
+
if (locked) { setOpen(false); if (dialog.open) dialog.close(); request++; }
|
|
193
|
+
trigger.disabled = locked;
|
|
194
|
+
$('#refreshButton').disabled = locked;
|
|
195
|
+
$('#backButton').disabled = locked || !canGoBack;
|
|
196
|
+
$('#sourceButton').disabled = locked || !selected;
|
|
197
|
+
$('#skippedButton').disabled = locked;
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
})();
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.clado-directory-plugin { position: relative; }
|
|
2
|
+
.directory-toggle { display: inline-flex; align-items: center; gap: 8px; height: 42px; max-width: min(400px, calc(100vw - 32px)); padding: 7px 13px; border-radius: 15px; color: var(--clado-ui-text); font-size: 13px; }
|
|
3
|
+
.directory-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; width: 16px; height: 16px; flex: none; }
|
|
4
|
+
#fileCount { flex: none; font-size: 11px; color: var(--clado-ui-muted); }
|
|
5
|
+
#currentFileName { min-width: 0; padding-inline-start: 8px; border-inline-start: 1px solid var(--clado-ui-edge); color: var(--clado-ui-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
|
|
6
|
+
.directory-toggle[data-sync="error"] #fileCount { color: #a45900; }
|
|
7
|
+
[data-theme="dark"] .directory-toggle[data-sync="error"] #fileCount { color: #f1ba73; }
|
|
8
|
+
#directory { position: absolute; left: 0; bottom: calc(100% + 8px); width: min(308px, calc(100vw - 32px)); }
|
|
9
|
+
.directory-scroll { max-height: calc(100dvh - 94px); overflow: auto; border-radius: inherit; padding: 14px 10px 10px; }
|
|
10
|
+
.directory-heading{padding:0 9px 13px}.directory-heading strong{font-size:12px;font-weight:600}.directory-heading span{display:block;font-size:10px;color:var(--muted);margin-top:5px}#documentList{display:flex;flex-direction:column;gap:4px}.document-button{display:block;text-align:left;padding:9px 10px;white-space:normal;width:100%}.document-button strong{font-size:11px;font-weight:500;display:block;color:var(--ink)}.document-button small{font-size:9px;color:var(--muted);display:block;margin-top:4px;overflow-wrap:anywhere}.directory-current{padding:12px 10px 8px;margin-top:10px;border-top:1px solid var(--line)}.directory-current strong{font-size:10px;font-weight:500;display:block;color:var(--muted)}.directory-current span{display:block;color:var(--muted);font-size:9px;margin-top:4px;overflow-wrap:anywhere}.directory-actions{display:flex;gap:7px;padding:0 10px}.directory-actions button{min-height:28px;font-size:10px;padding:4px 7px}.directory-actions #sourceButton{margin-left:auto}.skipped{margin-top:10px;border:0;border-top:1px solid var(--line);border-radius:0;width:100%;text-align:left;padding:11px 10px 2px;font-size:9px;color:var(--muted);white-space:normal}
|
|
11
|
+
.document-button[aria-current="page"] strong {
|
|
12
|
+
color: var(--clado-ui-accent);
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.sync-error{color:#b88628!important}.sync-good:before{content:'';display:inline-block;width:4px;height:4px;border-radius:50%;background:#69a57f;vertical-align:middle;margin-right:5px}
|
|
17
|
+
.clado-directory-plugin dialog {
|
|
18
|
+
position: fixed;
|
|
19
|
+
width: min(660px, calc(100vw - 32px));
|
|
20
|
+
max-height: calc(100vh - 36px);
|
|
21
|
+
border: 1px solid var(--line);
|
|
22
|
+
border-radius: var(--clado-ui-radius);
|
|
23
|
+
padding: 0;
|
|
24
|
+
}
|
|
25
|
+
.clado-directory-plugin dialog > header {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 12px;
|
|
29
|
+
padding: 15px 20px;
|
|
30
|
+
border-bottom: 1px solid var(--line);
|
|
31
|
+
}
|
|
32
|
+
.clado-directory-plugin dialog > header strong { font-size: 13px; font-weight: 600; }
|
|
33
|
+
.clado-directory-plugin dialog > header button {
|
|
34
|
+
margin-left: auto;
|
|
35
|
+
font-size: 19px;
|
|
36
|
+
line-height: 1;
|
|
37
|
+
border: 0;
|
|
38
|
+
}
|
|
39
|
+
#detailsBody { padding: 18px 20px; max-height: calc(100vh - 130px); overflow: auto; }
|
|
40
|
+
#detailsBody p { font-size: 11px; color: var(--muted); line-height: 1.8; margin: 0 0 14px; }
|
|
41
|
+
#detailsBody pre {
|
|
42
|
+
font: 11px/1.9 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
43
|
+
white-space: pre-wrap;
|
|
44
|
+
overflow-wrap: anywhere;
|
|
45
|
+
margin: 0;
|
|
46
|
+
}
|
|
47
|
+
.skip-item{padding:10px 0;border-bottom:1px solid var(--line)}.skip-item strong{font-size:12px}.skip-item p{margin:5px 0!important}.skip-item code{font-size:10px}
|
|
48
|
+
.directory-search{display:block;padding:0 9px 10px}.directory-search input{box-sizing:border-box;width:100%;border:1px solid var(--line);border-radius:7px;background:var(--clado-ui-well);color:var(--ink);font:inherit;padding:8px 10px;outline-color:var(--accent)}.tree-folder>summary{cursor:pointer;padding:8px;color:var(--ink);font-size:12px;font-weight:550}.tree-children{margin-left:11px;padding-left:5px;border-left:1px solid var(--line)}.tree-empty{padding:8px;color:var(--muted);font-size:12px}
|
|
49
|
+
#currentWorkspaceName{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline-end:8px;border-inline-end:1px solid var(--clado-ui-edge);color:var(--clado-ui-accent);font-size:12px;font-weight:600}
|
|
50
|
+
.directory-workspaces{padding:0 9px 10px;margin-bottom:10px;border-bottom:1px solid var(--line)}
|
|
51
|
+
.directory-workspaces-title{font-size:10px;font-weight:600;color:var(--muted);margin-bottom:6px}
|
|
52
|
+
.directory-workspace-list{display:flex;flex-direction:column;gap:4px;max-height:160px;overflow:auto}
|
|
53
|
+
.workspace-row{display:flex;align-items:center;gap:4px}
|
|
54
|
+
.workspace-button{flex:1;min-width:0;display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 8px;text-align:left;font-size:11px}
|
|
55
|
+
.workspace-button[aria-current="page"]{color:var(--clado-ui-accent);font-weight:600}
|
|
56
|
+
.workspace-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
57
|
+
.workspace-button small{flex:none;font-size:10px;color:var(--muted)}
|
|
58
|
+
.workspace-open-tab{flex:none;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;font-size:11px;text-decoration:none;color:var(--muted)}
|
|
59
|
+
.workspace-open-tab:hover{color:var(--ink)}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const modes = [['cards', '卡片'], ['mindmap', '脑图'], ['doc', '文档']];
|
|
3
|
+
const button = (className, text) => {
|
|
4
|
+
const element = document.createElement('button');
|
|
5
|
+
element.type = 'button';
|
|
6
|
+
element.className = className;
|
|
7
|
+
element.textContent = text;
|
|
8
|
+
return element;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function mountViewControls(host, actions) {
|
|
12
|
+
const controls = document.createElement('div');
|
|
13
|
+
controls.className = 'clado-view-controls';
|
|
14
|
+
const bar = document.createElement('div');
|
|
15
|
+
bar.className = 'clado-ui-glass clado-view-bar';
|
|
16
|
+
const group = document.createElement('div');
|
|
17
|
+
group.className = 'clado-view-modes';
|
|
18
|
+
group.setAttribute('role', 'group');
|
|
19
|
+
group.setAttribute('aria-label', '画布视图');
|
|
20
|
+
const thumb = document.createElement('span');
|
|
21
|
+
thumb.className = 'clado-view-thumb';
|
|
22
|
+
thumb.setAttribute('aria-hidden', 'true');
|
|
23
|
+
group.append(thumb);
|
|
24
|
+
const modeButtons = modes.map(([mode, label]) => {
|
|
25
|
+
const item = button('clado-ui-button', label);
|
|
26
|
+
item.dataset.mode = mode;
|
|
27
|
+
item.onclick = () => actions.setMode(mode);
|
|
28
|
+
group.append(item);
|
|
29
|
+
return item;
|
|
30
|
+
});
|
|
31
|
+
bar.append(group);
|
|
32
|
+
|
|
33
|
+
const statuses = document.createElement('div');
|
|
34
|
+
statuses.className = 'clado-view-status';
|
|
35
|
+
const issues = button('clado-ui-glass clado-ui-button clado-issue-count', '');
|
|
36
|
+
issues.onclick = actions.showDiagnostics;
|
|
37
|
+
const exit = button('clado-ui-glass clado-ui-button', '退出聚焦');
|
|
38
|
+
exit.onclick = actions.clearFocus;
|
|
39
|
+
statuses.append(issues, exit);
|
|
40
|
+
controls.append(bar, statuses);
|
|
41
|
+
host.mount('top-right', controls, 'clado.view-controls');
|
|
42
|
+
return ({ mode, focused = false, errors = 0, warnings = 0 }) => {
|
|
43
|
+
group.style.setProperty('--clado-view-index', String(Math.max(0, modes.findIndex(entry => entry[0] === mode))));
|
|
44
|
+
for (const item of modeButtons) item.setAttribute('aria-pressed', String(item.dataset.mode === mode));
|
|
45
|
+
issues.hidden = errors + warnings === 0;
|
|
46
|
+
if (!issues.hidden) {
|
|
47
|
+
issues.textContent = errors + warnings + ' 项问题';
|
|
48
|
+
issues.title = errors + ' 个错误 · ' + warnings + ' 个警告';
|
|
49
|
+
issues.setAttribute('aria-label', issues.title + ',查看诊断');
|
|
50
|
+
issues.classList.toggle('has-errors', errors > 0);
|
|
51
|
+
}
|
|
52
|
+
exit.hidden = !focused;
|
|
53
|
+
statuses.hidden = issues.hidden && exit.hidden;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
window.CladoPluginUI.mountViewControls = mountViewControls;
|
|
58
|
+
})();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.clado-view-controls { display: flex; flex-direction: column; align-items: end; gap: 7px; pointer-events: none; }
|
|
2
|
+
.clado-view-bar { padding: 4px; }
|
|
3
|
+
.clado-view-modes {
|
|
4
|
+
position: relative;
|
|
5
|
+
display: grid;
|
|
6
|
+
grid-template-columns: repeat(3, 1fr);
|
|
7
|
+
}
|
|
8
|
+
.clado-view-modes .clado-ui-button,
|
|
9
|
+
.clado-view-modes .clado-ui-button:hover:where(:not(:disabled)),
|
|
10
|
+
.clado-view-modes .clado-ui-button[aria-pressed="true"] {
|
|
11
|
+
position: relative;
|
|
12
|
+
min-height: 34px;
|
|
13
|
+
padding-inline: 14px;
|
|
14
|
+
background: transparent;
|
|
15
|
+
border-color: transparent;
|
|
16
|
+
border-radius: calc(var(--clado-ui-radius) - 5px);
|
|
17
|
+
}
|
|
18
|
+
.clado-view-modes .clado-ui-button:hover:where(:not(:disabled):not([aria-pressed="true"])) {
|
|
19
|
+
color: var(--clado-ui-text);
|
|
20
|
+
}
|
|
21
|
+
.clado-view-modes .clado-ui-button[aria-pressed="true"] {
|
|
22
|
+
color: var(--clado-ui-text);
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
}
|
|
25
|
+
.clado-view-thumb {
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: 0 auto 0 0;
|
|
28
|
+
width: calc(100% / 3);
|
|
29
|
+
border-radius: calc(var(--clado-ui-radius) - 5px);
|
|
30
|
+
border: 1px solid color-mix(in srgb, var(--clado-ui-accent) 18%, transparent);
|
|
31
|
+
background: rgb(255 255 255 / .52);
|
|
32
|
+
box-shadow: none;
|
|
33
|
+
transform: translateX(calc(var(--clado-view-index, 0) * 100%));
|
|
34
|
+
transition: transform 220ms cubic-bezier(.22,.75,.24,1);
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
}
|
|
37
|
+
[data-theme="dark"] .clado-view-thumb {
|
|
38
|
+
border-color: rgb(255 255 255 / .22);
|
|
39
|
+
background: rgb(255 255 255 / .11);
|
|
40
|
+
}
|
|
41
|
+
@media (prefers-reduced-motion: reduce) {
|
|
42
|
+
.clado-view-thumb { transition: none; }
|
|
43
|
+
}
|
|
44
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
45
|
+
.clado-view-thumb { background: var(--clado-ui-active); }
|
|
46
|
+
}
|
|
47
|
+
.clado-view-status { display: flex; gap: 6px; }
|
|
48
|
+
.clado-view-bar, .clado-view-status > * { pointer-events: auto; }
|
|
49
|
+
.clado-view-status .clado-ui-button { border-radius: 12px; font-size: 12px; }
|
|
50
|
+
.clado-view-status .clado-issue-count {
|
|
51
|
+
color: #8a5000;
|
|
52
|
+
border-color: transparent;
|
|
53
|
+
background: transparent;
|
|
54
|
+
--clado-ui-glass-fill: var(--clado-ui-surface);
|
|
55
|
+
}
|
|
56
|
+
.clado-view-status .clado-issue-count::after { display: none; }
|
|
57
|
+
.clado-view-status .clado-issue-count:hover:where(:not(:disabled)) {
|
|
58
|
+
background: color-mix(in srgb, var(--clado-ui-accent) 6%, transparent);
|
|
59
|
+
}
|
|
60
|
+
.clado-view-status .has-errors { color: #b72e3c; }
|
|
61
|
+
[data-theme="dark"] .clado-view-status .clado-issue-count { color: #efb860; }
|
|
62
|
+
[data-theme="dark"] .clado-view-status .has-errors { color: #ffacb6; }
|
|
63
|
+
|
|
64
|
+
@media (max-width: 460px) {
|
|
65
|
+
.clado-view-modes .clado-ui-button { padding-inline: 9px; }
|
|
66
|
+
}
|
package/skills/clado/SKILL.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clado
|
|
3
|
-
description: 使用 Clado MCP
|
|
3
|
+
description: 使用 Clado MCP 按模板创建和修改需求、流程、调用链及数据设计画布,在卡片、脑图和文档视图中实时预览,并维护项目模板、系统归档和离线 HTML 交付。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Clado 使用指南
|
|
7
7
|
|
|
8
|
-
Clado 将本地 Markdown/MDC
|
|
8
|
+
Clado 将本地 Markdown/MDC 内容展示为卡片、脑图和文档三种视图(默认卡片视图)。用户描述需求并看效果,AI 通过 MCP 组织和修改内容,网页自动同步。本文件说明怎样操作;具体场景的内容规范读取模板 `prompt`。
|
|
9
9
|
|
|
10
10
|
## 1. 内容模型与文件位置
|
|
11
11
|
|
|
12
12
|
| 概念 | 含义 |
|
|
13
13
|
| --- | --- |
|
|
14
|
-
| 工作区 `workspace` |
|
|
14
|
+
| 工作区 `workspace` | 一个项目或子工作区的绝对路径,每次 MCP 调用必填,须在服务启动目录范围内 |
|
|
15
15
|
| 文档 | 一个 `.mdc` 文件就是一张画布;旧 `.md` 和无头文件也可使用 |
|
|
16
16
|
| 卡片与节点 | L1 标题是卡片;L2–L6 是卡内节点,层级表示内容包含关系 |
|
|
17
17
|
| 正文 | 文字、表格、代码围栏或局部 Mermaid;正文和子节点分别操作 |
|
|
18
|
-
| 链接 |
|
|
18
|
+
| 链接 | 同文档引用形成关系线(从具体内容行出发),跨文档链接用于导航,外部网址是普通正文链接 |
|
|
19
19
|
| 模板 | 含用途、约束、组织方式和起始正文;新文档会携带创建时的规则头 |
|
|
20
20
|
|
|
21
21
|
用户模板默认在 `~/.clado/templates/`,项目模板在 `.clado/templates/`,工作文档在 `.clado/doc/`。文档实际根目录以 `inspect` 返回的 `documentRoot` 为准。`file/targetFile/newFile` 都相对这个根目录,**不是相对当前文档所在目录**。
|
|
@@ -32,7 +32,7 @@ Clado 将本地 Markdown/MDC 内容展示为脑图、卡片和文档三个视图
|
|
|
32
32
|
| `clado install /项目路径 --list` | 列出支持的 AI 客户端与安装位置 |
|
|
33
33
|
| `clado install /项目路径 --to zcode` | 给该业务项目的指定客户端安装 Skill,准备用户模板库;也可交互选择其它客户端 |
|
|
34
34
|
| `clado init /项目路径` | 准备工作区,首次复制上级项目和用户模板,近处同名优先 |
|
|
35
|
-
| `clado serve /项目路径 --mode
|
|
35
|
+
| `clado serve /项目路径 --mode cards` | 启动网页和 Streamable HTTP MCP;`--port` 指定端口,`--entry` 指定入口 |
|
|
36
36
|
| `clado build --entry overview.mdc --mode cards --out clado.html` | 从项目根构建只读离线 HTML;`--split` 可分别输出文档 |
|
|
37
37
|
|
|
38
38
|
CLI 的 `--dry-run` 只预览安装,`--force` 仅在确认允许替换现有目标时使用。`--theme light/dark` 设置初始主题,build 的 `--strict` 将警告视为错误,`--json` 输出结构化结果,`--quiet` 减少构建输出。`--entry` 相对本次文档目录。
|
|
@@ -41,19 +41,21 @@ CLI 的 `--dry-run` 只预览安装,`--force` 仅在确认允许替换现有
|
|
|
41
41
|
|
|
42
42
|
全局命令在 Clado 源码仓库安装或更新;Skill 安装目标是业务项目,明确传入项目路径。安装后核对 `clado version` 和安装输出中的版本,不重复运行仍指向旧安装的命令。
|
|
43
43
|
|
|
44
|
-
`serve` 会自动准备工作区,日常不必先执行 `init`。模式可选 `mindmap/
|
|
44
|
+
`serve` 会自动准备工作区,日常不必先执行 `init`。模式可选 `cards/mindmap/doc`(默认 `cards`)。连接启动输出的 MCP 地址,通常为 `http://127.0.0.1:4317/mcp`。在大目录启动一个 `serve` 后,多个 Agent 可并行操作其下各自的子工作区(传各自子目录绝对路径作为 `workspace`),网页端也可在目录中切换或新标签页同时打开多个子工作区。
|
|
45
45
|
|
|
46
46
|
更新全局命令后,重启原来的 `serve`,在 AI 客户端重新连接 MCP,刷新工具定义。
|
|
47
47
|
|
|
48
48
|
## 3. 从没有上下文开始
|
|
49
49
|
|
|
50
|
-
1.
|
|
50
|
+
1. 使用服务允许范围内的 `workspace` 绝对路径。需要查目录时用 `clado_workspace inspect`,列举当前服务下的子工作区用 `workspaces`,新子工作区用 `init`。用户说“改我选的卡片”时直接查 `selection`。
|
|
51
51
|
2. 用 `clado_documents list/read` 查看相关旧文档,保留已有内容。读节点与位置可选 `view:"nodes"`,全文改写前选 `view:"source"`,只看概要选 `view:"summary"`;默认 `full` 兼容全部字段。若任务涉及实际代码,另外读取用户业务项目的真实材料;Clado 范例不能作为实现证据。
|
|
52
52
|
3. `clado_templates list` 按用途选模板,再 `read` 提示词。默认只返回 `prompt`;编辑模板用 `view:"source"`,确实需要所有字段才用 `view:"full"`。
|
|
53
53
|
4. 新文档用 `clado_documents create` 指定 `.mdc` 路径、标题和 `templateId`。`source` 可直接传多行正文,不能带 front matter;模板头由服务写入。省略正文时得到模板起始内容,之后须补充完整。
|
|
54
54
|
5. 通过节点、正文和链接工具逐步细化。每次处理返回的全量错误和警告,确认实际插入位置;必要时用 `dryRun:true` 先看候选结果。
|
|
55
55
|
6. 调用 `clado_workspace validate`,实际沿网页阅读关键路径,再按需要 `build`。归档依据实际交付,不能把提案完成写成系统已上线。
|
|
56
56
|
|
|
57
|
+
评审调用链布局时,打开刚生成的文档,用 `clado_screenshot` 的 `mode:"cards"` 和 `scope:"full"` 查看整图。沿入口向右看分支和汇聚。如果业务上有并列调用,图上却排成一条长线,核对这些卡片是否误连成了依次调用。按真实关系修正后再截图确认。
|
|
58
|
+
|
|
57
59
|
| 模板 | 当前任务 |
|
|
58
60
|
| --- | --- |
|
|
59
61
|
| `requirement-overview` | 本期范围与需求概览,先浅层展开 |
|
|
@@ -69,35 +71,37 @@ CLI 的 `--dry-run` 只预览安装,`--force` 仅在确认允许替换现有
|
|
|
69
71
|
|
|
70
72
|
| 工具 | action 与使用方式 |
|
|
71
73
|
| --- | --- |
|
|
72
|
-
| `clado_workspace` | `init/inspect/search/validate/selection`;搜索用 `query`,可给 `offset/limit/includeContent` |
|
|
74
|
+
| `clado_workspace` | `init/inspect/search/validate/selection/workspaces`;搜索用 `query`,可给 `offset/limit/includeContent` |
|
|
75
|
+
| `clado_capabilities` | `list/call` 实时发现、调用在线能力。用 `clado.directory/directory.open` 打开目标文档 |
|
|
76
|
+
| `clado_screenshot` | 返回当前画布 PNG,默认保留展开和聚焦状态。支持 `mode`(`cards/mindmap/doc`)、`scope:"full"` 和 `source:"latest"`。同工作区多标签页时用能力列表返回的 `viewId` |
|
|
73
77
|
| `clado_templates` | `list/read/create/update/delete/pull/push`;定位用 `templateId`,默认项目级,用户库加 `scope:"user"` |
|
|
74
78
|
| `clado_documents` | `list/read/create/copy/update/rename/delete`;定位用 `file`;复制、改名用 `newFile`;全文更新传完整 `source`,可用 `metadata` 替换头部 |
|
|
75
79
|
| `clado_nodes` | `read/query/create/insert/update/rename/move/delete`;定位用 `file/node`;新增用 `title/parent/content/index`;移动用 `parent/index/targetFile` |
|
|
76
|
-
| `clado_links` | `list/connect/disconnect`;源 `file/node`,目标 `targetFile/targetNode
|
|
80
|
+
| `clado_links` | `list/connect/disconnect`;源 `file/node`,目标 `targetFile/targetNode`;优先用 `sourcePoint` 或行内 `position:{mode:"replace",anchor}` 从内容行连出 |
|
|
77
81
|
| `clado_batch` | `operations` 中顺序执行1–100个项目操作,类型如 `document.copy/node.insert/link.connect/template.pull`;最终校验后保存 |
|
|
78
82
|
|
|
79
83
|
节点 `node/parent/targetNode` 使用读取返回的**标题数组**,如 `["OrderService#createOrder(UUID)","检查权限(新增)"]`。不用内部ID或手拼点号路径。新增根卡片时省略 `parent`;同级节点 `index` 从 **0** 开始,省略则追加在同级末尾。
|
|
80
84
|
|
|
81
85
|
`query` 的 `relation` 支持 `parent/children/ancestors/descendants/siblings/upstream/downstream`。可给 `depth` 控制深度、`offset/limit` 分页、`includeContent` 控制是否带正文。包含层级和调用关系分别查询。
|
|
82
86
|
|
|
83
|
-
`connect` 省略 `targetFile` 表示同文档,此时必须给 `targetNode`;跨文档可以省略 `targetNode
|
|
87
|
+
`connect` 省略 `targetFile` 表示同文档,此时必须给 `targetNode`;跨文档可以省略 `targetNode`,跳转整份文档。**建立同画布跨卡连线时,必须优先从具体内容行出发**——即通过 `sourcePoint` 从代码行、表格数据行、Mermaid 节点拉线,或通过 `position:{mode:"replace",anchor:"原文"}` 把步骤正文里具体的方法名/规则词变成行内链接;**不要在卡片末尾单独追加一条裸的 `[目标卡](目标卡)` 来做整卡连整卡**。省略 `label` 时取目标标题。跨文档导航不代替当前画布的跨卡关系线。
|
|
84
88
|
|
|
85
89
|
## 5. 选中的卡片与正文定位
|
|
86
90
|
|
|
87
|
-
在线画布上,Mac 用 Command 加左键点标题,其他平台用 Ctrl
|
|
91
|
+
在线画布上,Mac 用 Command 加左键点标题,其他平台用 Ctrl 加左键。可多选,再点同一标题取消,按住修饰键点画布空白清空。三种视图共用选区。内容刷新后,只保留标题路径仍可唯一定位的选中项。切换文档清空。标题下的正文和后代属于同一选中范围。
|
|
88
92
|
|
|
89
|
-
用户提到选区时,调用 `clado_workspace` 的 `action:"selection"`。`ready` 返回 `file`、文档 `version` 和所选节点的 `path/content/paragraphs/nodeVersion/descendants`,按用户点选的顺序排列。根据用户指示定位到具体节点,修改一句用所给正文作原文锚点,整段替换可带该节点的 `nodeVersion`。`empty/stale`
|
|
93
|
+
用户提到选区时,调用 `clado_workspace` 的 `action:"selection"`。`ready` 返回 `file`、文档 `version` 和所选节点的 `path/content/paragraphs/nodeVersion/descendants`,按用户点选的顺序排列。根据用户指示定位到具体节点,修改一句用所给正文作原文锚点,整段替换可带该节点的 `nodeVersion`。`empty/stale` 时请用户选中或重新选择。选区按各自工作区隔离,以该工作区最近更新选区的标签页为准。
|
|
90
94
|
|
|
91
95
|
|
|
92
96
|
`read` 返回每个节点的 `location` 和 `paragraphs`。段落编号从 **1** 开始,以空行分块;代码围栏包含内部空行整体算一块,表格通常也是一块。段落编号用读取结果。已知原文可以直接用 `anchor`。
|
|
93
97
|
|
|
94
98
|
| 需求 | 参数 |
|
|
95
99
|
| --- | --- |
|
|
96
|
-
| 在正文末尾新增一段 | `insert`
|
|
100
|
+
| 在正文末尾新增一段 | `insert` 省略 `position`,默认 `append` |
|
|
97
101
|
| 在正文开头新增一段 | `position:{mode:"prepend"}` |
|
|
98
102
|
| 在第二段之前或之后新增 | `position:{mode:"before",paragraph:2}` 或 `mode:"after"` |
|
|
99
103
|
| 紧贴某段唯一原文插入 | `position:{mode:"before",anchor:"唯一原文"}` 或 `mode:"after"` |
|
|
100
|
-
|
|
|
104
|
+
| 把原句里的方法名变成行内链接(推荐) | `connect` 加 `position:{mode:"replace",anchor:"原句中唯一的方法名"}` |
|
|
101
105
|
| 只替换第二段正文 | `update` 加 `position:{mode:"replace",paragraph:2}` |
|
|
102
106
|
| 替换本节点全部正文 | `update` 传 `content`,省略 `position`;孩子保持不变 |
|
|
103
107
|
|
|
@@ -109,7 +113,7 @@ CLI 的 `--dry-run` 只预览安装,`--force` 仅在确认允许替换现有
|
|
|
109
113
|
|
|
110
114
|
写入后的 `results` 返回最终文件、节点路径、同级位置、段落和行号。文件整体写入还返回节点位置摘要。批量内后续改名/移动会更新定位;内容被覆盖或删除会标明。`contentLocationStatus:"exact"` 表示能唯一定位;`multiple_matches` 或 `changed_by_later_operation` 时重新读取,不声称已经有唯一坐标。行号和编号只对对应文件 `version` 的快照有效。`nodeVersion` 用于后续覆盖或删除同一节点。
|
|
111
115
|
|
|
112
|
-
|
|
116
|
+
**首选内容行精确连线**:用 `clado_links connect` 的 `sourcePoint`,跟普通的 `file/node/targetNode` 一起传。代码、表格、Mermaid 保持连续。标注可以写在代码注释里,链接用工具挂到具体行上。点击画布中起点处的圆点可跳到目标。
|
|
113
117
|
|
|
114
118
|
| 起点 | `sourcePoint` 示例 |
|
|
115
119
|
| --- | --- |
|