cladogram 0.5.2 → 0.5.4
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 +30 -2
- package/bin/clado.js +55 -3
- package/docs/plugin-development.md +135 -0
- package/docs/plugin-ui.md +43 -0
- package/docs/release.md +26 -0
- package/package.json +8 -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 +146 -0
- package/plugins/directory/style.css +48 -0
- package/plugins/view-controls/index.js +58 -0
- package/plugins/view-controls/style.css +46 -0
- package/skills/clado/SKILL.md +31 -17
- package/src/html/app-css.js +11 -42
- package/src/html/canvas-chain.js +5 -6
- package/src/html/canvas-focus.js +3 -4
- package/src/html/canvas-screenshot.js +199 -0
- package/src/html/canvas-ui.css +37 -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 +176 -0
- package/src/html/plugin-ui.js +45 -0
- package/src/html/runtime-api.js +47 -0
- package/src/html/runtime.js +15 -12
- package/src/server/agent.js +222 -0
- package/src/server/assets/clado-plugin-sdk.js +111 -0
- package/src/server/assets/library-canvas.js +72 -11
- 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 +3 -6
- package/src/server/assets/library.html +2 -12
- package/src/server/assets/library.js +280 -44
- package/src/server/canvas-capture.js +47 -0
- package/src/server/export.js +5 -2
- package/src/server/mcp.js +44 -19
- package/src/server/plugin-capabilities.js +172 -0
- package/src/server/plugin-settings.js +117 -0
- package/src/server/plugins.js +236 -0
- package/src/server/workspace.js +157 -12
- package/src/skill/targets.js +1 -1
- package/src/util/update.js +58 -0
- package/src/vendor/html-to-image.min.js +24 -0
- package/src/workspace/content.js +3 -2
- package/src/workspace/service.js +81 -21
- package/src/workspace/tree.js +38 -0
- package/src/server/assets/tree.js +0 -26
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
.clado-agent {
|
|
2
|
+
position: relative;
|
|
3
|
+
align-self: end;
|
|
4
|
+
}
|
|
5
|
+
.clado-agent-launch {
|
|
6
|
+
min-height: 34px;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 6px;
|
|
10
|
+
padding-inline: 10px;
|
|
11
|
+
color: var(--clado-ui-text);
|
|
12
|
+
}
|
|
13
|
+
.clado-agent-launch svg {
|
|
14
|
+
width: 15px;
|
|
15
|
+
height: 15px;
|
|
16
|
+
fill: none;
|
|
17
|
+
stroke: currentColor;
|
|
18
|
+
stroke-width: 1.5;
|
|
19
|
+
stroke-linejoin: round;
|
|
20
|
+
}
|
|
21
|
+
.clado-agent-panel {
|
|
22
|
+
position: absolute;
|
|
23
|
+
right: 0;
|
|
24
|
+
bottom: calc(100% + 8px);
|
|
25
|
+
width: min(392px, calc(100vw - 32px));
|
|
26
|
+
height: min(545px, calc(100dvh - 184px));
|
|
27
|
+
min-height: 220px;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
}
|
|
32
|
+
.clado-agent-panel header {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
border-bottom: 1px solid var(--clado-ui-edge);
|
|
37
|
+
padding: 9px 11px 9px 15px;
|
|
38
|
+
}
|
|
39
|
+
.clado-agent-panel h2 { margin: 0; font-size: 14px; font-weight: 650; }
|
|
40
|
+
.clado-agent-provider { color: var(--clado-ui-muted); font-size: 11px; }
|
|
41
|
+
.clado-agent-close { font-size: 18px; }
|
|
42
|
+
.clado-agent-log {
|
|
43
|
+
flex: 1;
|
|
44
|
+
min-height: 0;
|
|
45
|
+
overflow: auto;
|
|
46
|
+
overscroll-behavior: contain;
|
|
47
|
+
padding: 14px;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: 12px;
|
|
51
|
+
}
|
|
52
|
+
.clado-agent-message {
|
|
53
|
+
width: fit-content;
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
border-radius: 12px;
|
|
56
|
+
padding: 8px 11px;
|
|
57
|
+
overflow-wrap: anywhere;
|
|
58
|
+
}
|
|
59
|
+
.clado-agent-message.human {
|
|
60
|
+
align-self: end;
|
|
61
|
+
background: var(--clado-ui-active);
|
|
62
|
+
}
|
|
63
|
+
.clado-agent-message.assistant {
|
|
64
|
+
padding-inline: 3px;
|
|
65
|
+
}
|
|
66
|
+
.clado-agent-message strong, .clado-agent-message small {
|
|
67
|
+
color: var(--clado-ui-muted);
|
|
68
|
+
font-size: 11px;
|
|
69
|
+
}
|
|
70
|
+
.clado-agent-message p {
|
|
71
|
+
margin: 3px 0 0;
|
|
72
|
+
white-space: pre-wrap;
|
|
73
|
+
line-height: 1.55;
|
|
74
|
+
}
|
|
75
|
+
.clado-agent-status {
|
|
76
|
+
margin: 0 14px;
|
|
77
|
+
padding-block: 4px;
|
|
78
|
+
color: var(--clado-ui-muted);
|
|
79
|
+
font-size: 11px;
|
|
80
|
+
max-height: 65px;
|
|
81
|
+
overflow: auto;
|
|
82
|
+
overflow-wrap: anywhere;
|
|
83
|
+
}
|
|
84
|
+
.clado-agent-panel form {
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: end;
|
|
87
|
+
gap: 7px;
|
|
88
|
+
padding: 9px 12px 12px;
|
|
89
|
+
}
|
|
90
|
+
.clado-agent-panel textarea {
|
|
91
|
+
flex: 1;
|
|
92
|
+
min-width: 0;
|
|
93
|
+
max-height: 100px;
|
|
94
|
+
resize: vertical;
|
|
95
|
+
padding: 8px;
|
|
96
|
+
border: 1px solid var(--clado-ui-edge);
|
|
97
|
+
border-radius: 10px;
|
|
98
|
+
background: var(--clado-ui-well);
|
|
99
|
+
color: var(--clado-ui-text);
|
|
100
|
+
font: inherit;
|
|
101
|
+
}
|
|
102
|
+
.clado-agent-panel textarea:focus-visible { outline: 2px solid var(--clado-ui-accent); outline-offset: 1px; }
|
|
103
|
+
@media (max-width: 460px) {
|
|
104
|
+
.clado-agent-panel { width: min(392px, calc(100vw - 20px)); }
|
|
105
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const themes = [
|
|
3
|
+
['light', '日间模式', '<circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M2 12h2m16 0h2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4M6.3 17.7l-1.4 1.4M17.7 6.3l1.4-1.4"/>'],
|
|
4
|
+
['dark', '夜间模式', '<path d="M19.8 15.2A8.4 8.4 0 0 1 8.8 4.1 8.5 8.5 0 1 0 19.8 15.2Z"/>'],
|
|
5
|
+
];
|
|
6
|
+
const icon = shape => '<svg aria-hidden="true" viewBox="0 0 24 24">' + shape + '</svg>';
|
|
7
|
+
const camera = '<path d="M8 3H5a2 2 0 0 0-2 2v3m13-5h3a2 2 0 0 1 2 2v3M3 16v3a2 2 0 0 0 2 2h3m13-5v3a2 2 0 0 1-2 2h-3"/><rect x="8" y="8" width="8" height="8" rx="1.5"/>';
|
|
8
|
+
const pluginIcons = {
|
|
9
|
+
'clado.brand': '<circle cx="12" cy="12" r="7"/><circle cx="12" cy="12" r="2"/>',
|
|
10
|
+
'clado.view-controls': '<rect x="3" y="6" width="18" height="12" rx="3"/><path d="M9 6v12m6-12v12"/>',
|
|
11
|
+
'clado.directory': '<path d="M4 7h6l2 2h8v10H4z"/>',
|
|
12
|
+
'clado.agent': '<path d="M10 20h4m-4-3h4v-2c0-.7.3-1.2.9-1.7a4.5 4.5 0 1 0-5.8 0c.6.5.9 1 .9 1.7zM18 3v4m-2-2h4"/>',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function mountInstaller(dialog, plugins) {
|
|
16
|
+
const trigger = dialog.querySelector('[data-install-trigger]');
|
|
17
|
+
if (!plugins.install) { trigger.hidden = true; return () => {}; }
|
|
18
|
+
const pick = dialog.querySelector('[type="file"]');
|
|
19
|
+
const review = dialog.querySelector('.clado-plugin-install');
|
|
20
|
+
const status = review.querySelector('[role="status"]');
|
|
21
|
+
const confirm = review.querySelector('[data-install-confirm]');
|
|
22
|
+
let selected, epoch = 0;
|
|
23
|
+
const clear = () => {
|
|
24
|
+
epoch++;
|
|
25
|
+
selected = null;
|
|
26
|
+
pick.value = '';
|
|
27
|
+
confirm.disabled = false;
|
|
28
|
+
review.hidden = true;
|
|
29
|
+
};
|
|
30
|
+
trigger.onclick = () => { clear(); pick.click(); };
|
|
31
|
+
review.querySelector('[data-install-cancel]').onclick = clear;
|
|
32
|
+
pick.onchange = async () => {
|
|
33
|
+
const request = ++epoch;
|
|
34
|
+
review.hidden = false;
|
|
35
|
+
confirm.hidden = true;
|
|
36
|
+
status.textContent = '正在读取插件清单…';
|
|
37
|
+
const files = [...pick.files].map(file => ({ file, path: file.webkitRelativePath.split('/').slice(1).join('/') }))
|
|
38
|
+
.filter(({ path }) => path === 'clado-plugin.json' || path.startsWith('ui/') && !path.split('/').some(part => part.startsWith('.')));
|
|
39
|
+
try {
|
|
40
|
+
const manifest = files.find(({ path }) => path === 'clado-plugin.json');
|
|
41
|
+
if (!manifest) throw new Error('请选择包含 clado-plugin.json 的插件根目录。');
|
|
42
|
+
if (manifest.file.size > 65536 || files.length > 256 || files.reduce((sum, item) => sum + item.file.size, 0) > 8 * 1024 * 1024) throw new Error('插件目录超过安装大小限制。');
|
|
43
|
+
const data = JSON.parse(await manifest.file.text());
|
|
44
|
+
if (request !== epoch) return;
|
|
45
|
+
if (typeof data?.name !== 'string') throw new Error('插件清单缺少名称。');
|
|
46
|
+
selected = files;
|
|
47
|
+
const permissions = Array.isArray(data.permissions) ? data.permissions.join('、') : '';
|
|
48
|
+
status.textContent = data.name + (permissions ? ' · 请求权限:' + permissions : ' · 无额外权限');
|
|
49
|
+
confirm.hidden = false;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (request === epoch) status.textContent = error.message;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
confirm.onclick = async () => {
|
|
55
|
+
if (!selected || confirm.disabled) return;
|
|
56
|
+
confirm.disabled = true;
|
|
57
|
+
status.textContent = '正在安装…';
|
|
58
|
+
try {
|
|
59
|
+
const files = await Promise.all(selected.map(({ file, path }) => new Promise((resolve, reject) => {
|
|
60
|
+
const reader = new FileReader();
|
|
61
|
+
reader.onload = () => resolve({ path, data: reader.result.split(',')[1] });
|
|
62
|
+
reader.onerror = reject;
|
|
63
|
+
reader.readAsDataURL(file);
|
|
64
|
+
})));
|
|
65
|
+
await plugins.install(files);
|
|
66
|
+
plugins.refresh();
|
|
67
|
+
} catch (error) {
|
|
68
|
+
status.textContent = error.message || '安装失败。';
|
|
69
|
+
confirm.disabled = false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return clear;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function settingsEditor(brand, edit) {
|
|
76
|
+
const dialog = document.createElement('dialog');
|
|
77
|
+
dialog.className = 'clado-ui-dialog clado-plugin-editor';
|
|
78
|
+
dialog.setAttribute('aria-labelledby', 'clado-plugin-editor-title');
|
|
79
|
+
dialog.innerHTML = `
|
|
80
|
+
<header><h2 id="clado-plugin-editor-title"></h2><button type="button" class="clado-ui-button" aria-label="关闭配置">×</button></header>
|
|
81
|
+
<p class="clado-plugin-editor-path"></p>
|
|
82
|
+
<textarea rows="10" spellcheck="false" aria-label="插件配置 JSON"></textarea>
|
|
83
|
+
<details><summary>查看字段和默认值</summary><pre></pre></details>
|
|
84
|
+
<footer><span role="status"></span><button type="button" class="clado-ui-button clado-ui-button-primary">保存并应用</button></footer>`;
|
|
85
|
+
const field = dialog.querySelector('textarea'), save = dialog.querySelector('footer button');
|
|
86
|
+
const status = dialog.querySelector('[role="status"]');
|
|
87
|
+
let request = 0;
|
|
88
|
+
dialog.querySelector('header button').onclick = () => dialog.close();
|
|
89
|
+
dialog.addEventListener('close', () => { request++; });
|
|
90
|
+
brand.append(dialog);
|
|
91
|
+
return async plugin => {
|
|
92
|
+
const current = ++request;
|
|
93
|
+
dialog.querySelector('h2').textContent = plugin.name + '设置';
|
|
94
|
+
dialog.querySelector('.clado-plugin-editor-path').textContent = '.clado/plugin-settings.json';
|
|
95
|
+
dialog.querySelector('pre').textContent = '';
|
|
96
|
+
field.value = '';
|
|
97
|
+
field.disabled = save.disabled = true;
|
|
98
|
+
status.textContent = '正在读取配置…';
|
|
99
|
+
dialog.showModal();
|
|
100
|
+
try {
|
|
101
|
+
const { value, schema, defaults, path } = await edit(plugin.id);
|
|
102
|
+
if (current !== request) return;
|
|
103
|
+
field.value = JSON.stringify(value, null, 2);
|
|
104
|
+
dialog.querySelector('.clado-plugin-editor-path').textContent = path;
|
|
105
|
+
dialog.querySelector('pre').textContent = JSON.stringify({ schema, defaults }, null, 2);
|
|
106
|
+
field.disabled = save.disabled = false;
|
|
107
|
+
status.textContent = '';
|
|
108
|
+
save.onclick = async () => {
|
|
109
|
+
let next;
|
|
110
|
+
try { next = JSON.parse(field.value); }
|
|
111
|
+
catch { status.textContent = 'JSON 格式有误,请修改后再保存。'; field.focus(); return; }
|
|
112
|
+
field.disabled = save.disabled = true;
|
|
113
|
+
try { await edit(plugin.id, next, value); }
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (current !== request) return;
|
|
116
|
+
status.textContent = error.message;
|
|
117
|
+
field.disabled = save.disabled = false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (current === request) status.textContent = error.message;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function mountBrand(host, { setTheme, capture, plugins }) {
|
|
127
|
+
const brand = document.createElement('div');
|
|
128
|
+
brand.className = 'clado-brand-plugin';
|
|
129
|
+
brand.innerHTML = `
|
|
130
|
+
<button type="button" class="clado-ui-glass clado-ui-button clado-brand" aria-label="Clado 设置" aria-expanded="false" aria-controls="clado-brand-settings" title="Clado 设置">
|
|
131
|
+
<span class="clado-brand-mark" aria-hidden="true">C</span><strong>clado</strong>
|
|
132
|
+
</button>
|
|
133
|
+
<div class="clado-ui-glass clado-ui-glass-panel clado-brand-settings" id="clado-brand-settings" role="group" aria-labelledby="clado-brand-settings-title" hidden>
|
|
134
|
+
<p id="clado-brand-settings-title">设置</p>
|
|
135
|
+
</div>`;
|
|
136
|
+
const trigger = brand.querySelector('.clado-brand');
|
|
137
|
+
const panel = brand.querySelector('.clado-brand-settings');
|
|
138
|
+
function setOpen(open, returnFocus = false) {
|
|
139
|
+
panel.hidden = !open;
|
|
140
|
+
trigger.setAttribute('aria-expanded', String(open));
|
|
141
|
+
if (returnFocus) trigger.focus();
|
|
142
|
+
}
|
|
143
|
+
const choices = themes.map(([theme, label, shape]) => {
|
|
144
|
+
const choice = document.createElement('button');
|
|
145
|
+
choice.type = 'button';
|
|
146
|
+
choice.className = 'clado-ui-button clado-brand-choice';
|
|
147
|
+
choice.innerHTML = icon(shape) + '<span>' + label + '</span>' +
|
|
148
|
+
'<span class="clado-brand-check">' + icon('<path d="m5 12 4 4L19 6"/>') + '</span>';
|
|
149
|
+
choice.onclick = () => { setTheme(theme); setOpen(false, true); };
|
|
150
|
+
panel.append(choice);
|
|
151
|
+
return { theme, choice };
|
|
152
|
+
});
|
|
153
|
+
if (capture) {
|
|
154
|
+
const action = document.createElement('button');
|
|
155
|
+
action.type = 'button';
|
|
156
|
+
action.className = 'clado-ui-button clado-brand-choice clado-brand-capture';
|
|
157
|
+
action.innerHTML = icon(camera) + '<span>截取当前画布</span>';
|
|
158
|
+
action.onclick = async () => {
|
|
159
|
+
setOpen(false, true);
|
|
160
|
+
action.disabled = true;
|
|
161
|
+
action.querySelector('span').textContent = '正在截图…';
|
|
162
|
+
try { await capture(); }
|
|
163
|
+
finally {
|
|
164
|
+
action.disabled = false;
|
|
165
|
+
action.querySelector('span').textContent = '截取当前画布';
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
panel.append(action);
|
|
169
|
+
}
|
|
170
|
+
if (plugins) {
|
|
171
|
+
const action = document.createElement('button');
|
|
172
|
+
action.type = 'button';
|
|
173
|
+
action.className = 'clado-ui-button clado-brand-choice clado-brand-capture';
|
|
174
|
+
action.innerHTML = icon('<rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/>') + '<span>插件管理</span>';
|
|
175
|
+
const dialog = document.createElement('dialog');
|
|
176
|
+
dialog.className = 'clado-ui-dialog clado-plugin-manager';
|
|
177
|
+
dialog.setAttribute('aria-labelledby', 'clado-plugin-manager-title');
|
|
178
|
+
dialog.innerHTML = `
|
|
179
|
+
<header><h2 id="clado-plugin-manager-title">插件管理</h2><div class="clado-plugin-manager-actions">
|
|
180
|
+
<button type="button" class="clado-ui-button clado-plugin-install-trigger" data-install-trigger>安装插件</button>
|
|
181
|
+
<button type="button" class="clado-ui-button" aria-label="关闭插件管理">×</button>
|
|
182
|
+
</div></header>
|
|
183
|
+
<input type="file" webkitdirectory multiple hidden aria-label="选择本地插件文件夹">
|
|
184
|
+
<section class="clado-plugin-install" hidden><p role="status"></p><div class="clado-plugin-manager-actions">
|
|
185
|
+
<button type="button" class="clado-ui-button" data-install-cancel>取消</button>
|
|
186
|
+
<button type="button" class="clado-ui-button clado-plugin-install-trigger" data-install-confirm>确认安装</button>
|
|
187
|
+
</div></section>
|
|
188
|
+
<div class="clado-plugin-manager-list"></div>
|
|
189
|
+
<footer><span role="status"></span><button type="button" class="clado-ui-button clado-ui-button-primary" disabled>应用并刷新</button></footer>`;
|
|
190
|
+
const list = dialog.querySelector('.clado-plugin-manager-list');
|
|
191
|
+
const apply = dialog.querySelector('footer button');
|
|
192
|
+
const status = dialog.querySelector('footer [role="status"]');
|
|
193
|
+
const clearInstaller = mountInstaller(dialog, plugins);
|
|
194
|
+
const editSettings = plugins.edit && settingsEditor(brand, plugins.edit);
|
|
195
|
+
const controls = plugins.items.map(plugin => {
|
|
196
|
+
const row = document.createElement('article');
|
|
197
|
+
row.innerHTML = '<span class="clado-plugin-card-icon">' + icon(pluginIcons[plugin.id] || '<path d="m12 3 8 5v8l-8 5-8-5V8z"/>') + '</span>';
|
|
198
|
+
const name = document.createElement('strong');
|
|
199
|
+
name.textContent = plugin.name;
|
|
200
|
+
const toggle = document.createElement('input');
|
|
201
|
+
toggle.type = 'checkbox';
|
|
202
|
+
toggle.setAttribute('role', 'switch');
|
|
203
|
+
toggle.setAttribute('aria-label', plugin.name);
|
|
204
|
+
toggle.checked = plugins.isEnabled(plugin.id);
|
|
205
|
+
toggle.disabled = !!plugin.reason;
|
|
206
|
+
row.append(name);
|
|
207
|
+
if (plugin.reason || plugin.detail || plugin.version) {
|
|
208
|
+
const detail = document.createElement('small');
|
|
209
|
+
detail.textContent = plugin.reason || plugin.detail || 'v' + plugin.version;
|
|
210
|
+
row.append(detail);
|
|
211
|
+
}
|
|
212
|
+
row.append(toggle);
|
|
213
|
+
const settings = document.createElement('button');
|
|
214
|
+
settings.type = 'button';
|
|
215
|
+
settings.className = 'clado-ui-button';
|
|
216
|
+
settings.textContent = '设置';
|
|
217
|
+
settings.setAttribute('aria-label', plugin.name + '配置');
|
|
218
|
+
settings.disabled = !editSettings || !!plugin.pending;
|
|
219
|
+
if (settings.disabled) settings.title = '插件启用后可编辑配置';
|
|
220
|
+
settings.onclick = () => editSettings(plugin);
|
|
221
|
+
row.append(settings);
|
|
222
|
+
list.append(row);
|
|
223
|
+
return { plugin, toggle };
|
|
224
|
+
});
|
|
225
|
+
list.onchange = () => {
|
|
226
|
+
apply.disabled = controls.every(({ plugin, toggle }) => toggle.checked === plugins.isEnabled(plugin.id));
|
|
227
|
+
status.textContent = apply.disabled ? '' : '刷新会结束当前对话';
|
|
228
|
+
};
|
|
229
|
+
apply.onclick = () => {
|
|
230
|
+
try { plugins.save(controls.filter(({ toggle }) => !toggle.checked && !toggle.disabled).map(({ plugin }) => plugin.id)); }
|
|
231
|
+
catch { status.textContent = '保存失败,请检查浏览器的本地存储设置。'; }
|
|
232
|
+
};
|
|
233
|
+
dialog.querySelector('[aria-label="关闭插件管理"]').onclick = () => dialog.close();
|
|
234
|
+
dialog.onclose = () => { clearInstaller(); trigger.focus(); };
|
|
235
|
+
action.onclick = () => {
|
|
236
|
+
for (const { plugin, toggle } of controls) toggle.checked = plugins.isEnabled(plugin.id);
|
|
237
|
+
apply.disabled = true;
|
|
238
|
+
status.textContent = '';
|
|
239
|
+
setOpen(false);
|
|
240
|
+
dialog.showModal();
|
|
241
|
+
};
|
|
242
|
+
brand.append(dialog);
|
|
243
|
+
panel.append(action);
|
|
244
|
+
}
|
|
245
|
+
trigger.onclick = () => setOpen(panel.hidden);
|
|
246
|
+
document.addEventListener('pointerdown', event => {
|
|
247
|
+
if (!panel.hidden && !brand.contains(event.target)) setOpen(false);
|
|
248
|
+
});
|
|
249
|
+
document.addEventListener('keydown', event => {
|
|
250
|
+
if (event.key === 'Escape' && !panel.hidden) setOpen(false, true);
|
|
251
|
+
});
|
|
252
|
+
host.mount('top-left', brand, 'clado.brand');
|
|
253
|
+
return {
|
|
254
|
+
sync(theme) {
|
|
255
|
+
for (const entry of choices) entry.choice.setAttribute('aria-pressed', String(entry.theme === theme));
|
|
256
|
+
},
|
|
257
|
+
close: () => setOpen(false),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
window.CladoPluginUI.mountBrand = mountBrand;
|
|
262
|
+
})();
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
.clado-brand-plugin { position: relative; }
|
|
2
|
+
.clado-brand {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: 8px;
|
|
6
|
+
height: 44px;
|
|
7
|
+
padding: 6px 11px 6px 7px;
|
|
8
|
+
color: var(--clado-ui-text);
|
|
9
|
+
border-radius: var(--clado-ui-radius);
|
|
10
|
+
}
|
|
11
|
+
.clado-brand strong { font-size: 17px; font-weight: 680; letter-spacing: -.05em; }
|
|
12
|
+
.clado-brand-mark {
|
|
13
|
+
display: grid;
|
|
14
|
+
place-items: center;
|
|
15
|
+
width: 28px;
|
|
16
|
+
height: 28px;
|
|
17
|
+
border-radius: 9px;
|
|
18
|
+
background: linear-gradient(145deg, #424242, #1c1c1c 78%);
|
|
19
|
+
box-shadow: inset 0 1px 1px #fff4, 0 2px 4px #17171738;
|
|
20
|
+
color: #fff;
|
|
21
|
+
font-weight: 750;
|
|
22
|
+
font-size: 15px;
|
|
23
|
+
flex: none;
|
|
24
|
+
}
|
|
25
|
+
.clado-brand-settings {
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: calc(100% + 8px) auto auto 0;
|
|
28
|
+
width: min(182px, calc(100vw - 32px));
|
|
29
|
+
display: grid;
|
|
30
|
+
gap: 4px;
|
|
31
|
+
padding: 8px;
|
|
32
|
+
}
|
|
33
|
+
.clado-brand-settings p {
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 3px 8px 2px;
|
|
36
|
+
color: var(--clado-ui-muted);
|
|
37
|
+
font-size: 11px;
|
|
38
|
+
font-weight: 600;
|
|
39
|
+
}
|
|
40
|
+
.clado-brand-choice {
|
|
41
|
+
min-height: 34px;
|
|
42
|
+
padding-inline: 8px;
|
|
43
|
+
display: grid;
|
|
44
|
+
grid-template-columns: 16px 1fr 14px;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 8px;
|
|
47
|
+
text-align: start;
|
|
48
|
+
}
|
|
49
|
+
.clado-brand-choice[aria-pressed="true"] { font-weight: 600; }
|
|
50
|
+
.clado-brand-choice svg {
|
|
51
|
+
display: block;
|
|
52
|
+
width: 16px;
|
|
53
|
+
height: 16px;
|
|
54
|
+
fill: none;
|
|
55
|
+
stroke: currentColor;
|
|
56
|
+
stroke-width: 1.7;
|
|
57
|
+
stroke-linecap: round;
|
|
58
|
+
stroke-linejoin: round;
|
|
59
|
+
}
|
|
60
|
+
.clado-brand-check { visibility: hidden; }
|
|
61
|
+
.clado-brand-choice[aria-pressed="true"] .clado-brand-check { visibility: visible; }
|
|
62
|
+
.clado-brand-check svg { width: 14px; height: 14px; }
|
|
63
|
+
.clado-brand-capture {
|
|
64
|
+
margin-block-start: 3px;
|
|
65
|
+
grid-template-columns: 16px 1fr;
|
|
66
|
+
}
|
|
67
|
+
.clado-brand:is(:hover,[aria-expanded="true"]) { color: var(--clado-ui-text); }
|
|
68
|
+
.clado-plugin-manager, .clado-plugin-editor {
|
|
69
|
+
position: fixed;
|
|
70
|
+
inset: 0;
|
|
71
|
+
margin: auto;
|
|
72
|
+
width: min(454px, calc(100vw - 32px));
|
|
73
|
+
max-height: calc(100dvh - 40px);
|
|
74
|
+
padding: 20px;
|
|
75
|
+
overflow: auto;
|
|
76
|
+
}
|
|
77
|
+
:is(.clado-plugin-manager,.clado-plugin-editor) :is(header,footer) {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
gap: 12px;
|
|
82
|
+
}
|
|
83
|
+
.clado-plugin-editor { width: min(600px, calc(100vw - 32px)); }
|
|
84
|
+
:is(.clado-plugin-manager,.clado-plugin-editor) h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
|
|
85
|
+
.clado-plugin-manager-actions { display: flex; align-items: center; gap: 6px; }
|
|
86
|
+
.clado-plugin-manager .clado-plugin-install-trigger {
|
|
87
|
+
background: #242424;
|
|
88
|
+
border-color: #242424;
|
|
89
|
+
color: #fff;
|
|
90
|
+
}
|
|
91
|
+
.clado-plugin-manager .clado-plugin-install-trigger:hover { background: #444; }
|
|
92
|
+
.clado-plugin-install {
|
|
93
|
+
margin-top: 12px;
|
|
94
|
+
padding: 10px 12px;
|
|
95
|
+
border: 1px solid #dedede;
|
|
96
|
+
border-radius: 11px;
|
|
97
|
+
background: #f7f7f7;
|
|
98
|
+
}
|
|
99
|
+
.clado-plugin-install p { margin: 0 0 8px; overflow-wrap: anywhere; color: #454545; }
|
|
100
|
+
.clado-plugin-install .clado-plugin-manager-actions { justify-content: end; }
|
|
101
|
+
.clado-plugin-manager-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
|
|
102
|
+
.clado-plugin-manager-list article {
|
|
103
|
+
display: grid;
|
|
104
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
105
|
+
grid-template-rows: auto auto 1fr auto;
|
|
106
|
+
align-items: start;
|
|
107
|
+
gap: 6px;
|
|
108
|
+
min-height: 116px;
|
|
109
|
+
padding: 12px;
|
|
110
|
+
border: 1px solid #e4e4e4;
|
|
111
|
+
border-radius: calc(var(--clado-ui-radius) - 4px);
|
|
112
|
+
background: linear-gradient(150deg, #fbfbfb, #f2f2f2);
|
|
113
|
+
}
|
|
114
|
+
.clado-plugin-manager-list article:has(input:not(:checked)) { background: #fff; }
|
|
115
|
+
.clado-plugin-card-icon { grid-area: 1 / 1; display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #e0e0e0; border-radius: 9px; background: #fff; }
|
|
116
|
+
.clado-plugin-card-icon svg { width: 17px; height: 17px; fill: none; stroke: #343434; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
|
|
117
|
+
.clado-plugin-manager-list strong {
|
|
118
|
+
grid-area: 2 / 1 / auto / -1;
|
|
119
|
+
align-self: center;
|
|
120
|
+
overflow-wrap: anywhere;
|
|
121
|
+
}
|
|
122
|
+
.clado-plugin-manager-list small { grid-area: 3 / 1 / auto / -1; color: var(--clado-ui-muted); }
|
|
123
|
+
.clado-plugin-manager-list article button { grid-area: 4 / 2; min-height: 28px; padding: 4px 7px; }
|
|
124
|
+
.clado-plugin-manager-list input {
|
|
125
|
+
grid-area: 1 / 2;
|
|
126
|
+
align-self: center;
|
|
127
|
+
appearance: none;
|
|
128
|
+
position: relative;
|
|
129
|
+
width: 33px;
|
|
130
|
+
height: 19px;
|
|
131
|
+
margin: 0;
|
|
132
|
+
border-radius: 99px;
|
|
133
|
+
background: var(--clado-ui-edge);
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
}
|
|
136
|
+
.clado-plugin-manager-list input::before {
|
|
137
|
+
content: "";
|
|
138
|
+
position: absolute;
|
|
139
|
+
inset: 3px auto auto 3px;
|
|
140
|
+
width: 13px;
|
|
141
|
+
height: 13px;
|
|
142
|
+
border-radius: 50%;
|
|
143
|
+
background: white;
|
|
144
|
+
}
|
|
145
|
+
.clado-plugin-manager-list input:checked { background: var(--clado-ui-accent); }
|
|
146
|
+
.clado-plugin-manager-list input:checked::before { transform: translateX(14px); }
|
|
147
|
+
.clado-plugin-manager-list input:focus-visible { outline: 2px solid var(--clado-ui-accent); outline-offset: 2px; }
|
|
148
|
+
.clado-plugin-manager-list input:disabled { opacity: .5; cursor: default; }
|
|
149
|
+
:is(.clado-plugin-manager,.clado-plugin-editor) footer span { color: var(--clado-ui-muted); font-size: 12px; }
|
|
150
|
+
.clado-plugin-editor-path { color: var(--clado-ui-muted); font: 12px ui-monospace, monospace; }
|
|
151
|
+
.clado-plugin-editor textarea {
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
width: 100%;
|
|
154
|
+
padding: 10px;
|
|
155
|
+
border: 1px solid #dfdfdf;
|
|
156
|
+
border-radius: 10px;
|
|
157
|
+
background: #f8f8f8;
|
|
158
|
+
font: 13px/1.5 ui-monospace, monospace;
|
|
159
|
+
resize: vertical;
|
|
160
|
+
}
|
|
161
|
+
.clado-plugin-editor details { padding: 10px 0; color: var(--clado-ui-muted); }
|
|
162
|
+
.clado-plugin-editor pre { max-height: 180px; overflow: auto; }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "directory.open",
|
|
4
|
+
"mount": "directory",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "在指定 Clado 标签页打开工作区内的 Markdown 画布。沿用当前视图,并等待目标画布加载。",
|
|
7
|
+
"exposeToAgent": true,
|
|
8
|
+
"inputSchema": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"file": { "type": "string", "minLength": 1, "maxLength": 1500, "pattern": "\\.[mM][dD][cC]?$", "description": "文档目录下的相对文件路径,例如 design/checkout.mdc。" }
|
|
12
|
+
},
|
|
13
|
+
"required": ["file"],
|
|
14
|
+
"additionalProperties": false
|
|
15
|
+
},
|
|
16
|
+
"outputSchema": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"file": { "type": "string" },
|
|
20
|
+
"title": { "type": "string" },
|
|
21
|
+
"mode": { "enum": ["mindmap", "cards", "doc"] }
|
|
22
|
+
},
|
|
23
|
+
"required": ["file", "title", "mode"],
|
|
24
|
+
"additionalProperties": false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|