feat: full 6-app integration — DSH client UI (composer chip + settings panel), skills for Claude Code/Codex/ZCode/WorkBuddy/MiMo, updated installer
Browse files- README.md +11 -12
- ext/dsh-plugin/client.js +268 -0
- ext/dsh-plugin/index.js +113 -23
- ext/dsh-plugin/package.json +9 -3
- ext/skill/SKILL.md +47 -0
- src/cli/commands/install.ts +33 -1
README.md
CHANGED
|
@@ -53,18 +53,17 @@ agentlens install
|
|
| 53 |
|
| 54 |
### 支持矩阵
|
| 55 |
|
| 56 |
-
| Agent | 配置
|
| 57 |
-
|---|---|
|
| 58 |
-
| Claude Code | `
|
| 59 |
-
| Cursor |
|
| 60 |
-
| Codex | `
|
| 61 |
-
| ZCode | `~/.zcode/mcp.json`
|
| 62 |
-
| WorkBuddy | `~/.workbuddy/mcp.json`
|
| 63 |
-
| MiMo Desktop | `~/.config/mimocode/mimocode.jsonc`
|
| 64 |
-
|
|
| 65 |
-
|
|
| 66 |
-
|
| 67 |
-
另有 VS Code / Cursor 扩展(`.vsix`)和 DSH 插件(cordis),见仓库 `ext/` 目录。
|
| 68 |
|
| 69 |
## 安装
|
| 70 |
|
|
|
|
| 53 |
|
| 54 |
### 支持矩阵
|
| 55 |
|
| 56 |
+
| Agent | 集成方式 | MCP 配置 | Skill |
|
| 57 |
+
|---|---|---|---|
|
| 58 |
+
| Claude Code | MCP + Skill | `~/.claude/settings.json` | `~/.claude/skills/agentlens` |
|
| 59 |
+
| Cursor | VS Code 扩展 (.vsix) + MCP | `.cursor/mcp.json` | — |
|
| 60 |
+
| Codex | MCP + Skill | `.mcp.json` | `~/.codex/skills/agentlens` |
|
| 61 |
+
| ZCode | MCP + Skill | `~/.zcode/mcp.json` | `~/.zcode/skills/agentlens` |
|
| 62 |
+
| WorkBuddy | MCP + Skill | `~/.workbuddy/mcp.json` | `~/.workbuddy/skills/agentlens` |
|
| 63 |
+
| MiMo Desktop | MCP + Skill | `~/.config/mimocode/mimocode.jsonc` | `~/.agents/skills/agentlens` |
|
| 64 |
+
| DSH | 客户端插件(输入区「体检」按钮 + 设置页「AgentLens 迁移」面板)+ Host 工具 | `~/.dsh/profiles/desktop/package.json` | — |
|
| 65 |
+
| Windsurf | 规则文件 | `.windsurfrules` | — |
|
| 66 |
+
| GitHub Copilot | 规则文件 | `.github/copilot-instructions.md` | — |
|
|
|
|
| 67 |
|
| 68 |
## 安装
|
| 69 |
|
ext/dsh-plugin/client.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @local/agentlens — Client half.
|
| 3 |
+
*
|
| 4 |
+
* Two surfaces:
|
| 5 |
+
* 1. A compact "体检" chip in the composer tool row
|
| 6 |
+
* (`conversation.input.left` list slot — rendered right after the
|
| 7 |
+
* permission control 完全访问 and the plan seat). Clicking it scans the
|
| 8 |
+
* current project and shows the agent-config summary in a small popover.
|
| 9 |
+
* 2. An "AgentLens 迁移" section in Settings (`settings.section` slot) with
|
| 10 |
+
* a path picker, a scan shortcut, and one-click rule migration between
|
| 11 |
+
* agent formats (claude / cursor / codex / windsurf / copilot).
|
| 12 |
+
*
|
| 13 |
+
* All data flows through the host's local HTTP routes (/agentlens/*), which
|
| 14 |
+
* shell out to the AgentLens CLI. Nothing leaves the machine.
|
| 15 |
+
*/
|
| 16 |
+
window.__ModuleLoader__.load({
|
| 17 |
+
id: '@local/agentlens',
|
| 18 |
+
factory(require) {
|
| 19 |
+
const React = require('react');
|
| 20 |
+
const h = React.createElement;
|
| 21 |
+
const { useCallback, useEffect, useRef, useState } = React;
|
| 22 |
+
|
| 23 |
+
const STYLE_ID = 'agentlens-client-style';
|
| 24 |
+
const STYLE_TEXT = `
|
| 25 |
+
.agentlens-chip{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border-radius:14px;border:1px solid rgba(255,255,255,.14);background:rgba(255,255,255,.06);color:inherit;font:inherit;font-size:12px;line-height:1;cursor:pointer;white-space:nowrap;transition:background .15s ease,border-color .15s ease}
|
| 26 |
+
.agentlens-chip:hover{background:rgba(255,255,255,.12);border-color:rgba(255,255,255,.24)}
|
| 27 |
+
.agentlens-chip:disabled{opacity:.5;cursor:default}
|
| 28 |
+
.agentlens-pop{position:absolute;bottom:calc(100% + 8px);left:0;z-index:60;width:min(560px,80vw);max-height:50vh;overflow:auto;padding:12px 14px;border-radius:12px;border:1px solid rgba(255,255,255,.16);background:rgba(24,27,34,.98);color:#e8eaf0;font:12px/1.55 ui-monospace,Menlo,Consolas,monospace;white-space:pre-wrap;box-shadow:0 12px 40px rgba(0,0,0,.45)}
|
| 29 |
+
.agentlens-pop-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;font-family:-apple-system,'PingFang SC',sans-serif;font-weight:600}
|
| 30 |
+
.agentlens-pop-close{border:0;background:transparent;color:#9aa3b2;cursor:pointer;font-size:14px;padding:2px 6px;border-radius:6px}
|
| 31 |
+
.agentlens-pop-close:hover{background:rgba(255,255,255,.1);color:#fff}
|
| 32 |
+
.agentlens-anchor{position:relative;display:inline-flex}
|
| 33 |
+
.agentlens-panel{display:grid;gap:14px;max-width:720px}
|
| 34 |
+
.agentlens-panel h3{margin:0;font-size:15px}
|
| 35 |
+
.agentlens-panel .row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
|
| 36 |
+
.agentlens-panel input,.agentlens-panel select{padding:6px 9px;border-radius:8px;border:1px solid rgba(255,255,255,.18);background:rgba(255,255,255,.06);color:inherit;font:inherit;font-size:13px}
|
| 37 |
+
.agentlens-panel input[type=text]{flex:1 1 260px}
|
| 38 |
+
.agentlens-panel button{padding:6px 14px;border-radius:8px;border:1px solid rgba(255,255,255,.18);background:rgba(255,255,255,.08);color:inherit;font:inherit;font-size:13px;cursor:pointer}
|
| 39 |
+
.agentlens-panel button:hover{background:rgba(255,255,255,.14)}
|
| 40 |
+
.agentlens-panel button:disabled{opacity:.5;cursor:default}
|
| 41 |
+
.agentlens-out{margin:0;padding:10px 12px;border-radius:10px;background:rgba(0,0,0,.35);border:1px solid rgba(255,255,255,.1);font:12px/1.55 ui-monospace,Menlo,Consolas,monospace;white-space:pre-wrap;max-height:320px;overflow:auto}
|
| 42 |
+
.agentlens-hint{margin:0;font-size:12px;opacity:.65}
|
| 43 |
+
`;
|
| 44 |
+
|
| 45 |
+
const AGENTS = ['claude', 'cursor', 'codex', 'windsurf', 'copilot'];
|
| 46 |
+
|
| 47 |
+
function rememberedPath() {
|
| 48 |
+
try {
|
| 49 |
+
return localStorage.getItem('agentlens.path') || '';
|
| 50 |
+
} catch {
|
| 51 |
+
return '';
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function rememberPath(value) {
|
| 56 |
+
try {
|
| 57 |
+
if (value) localStorage.setItem('agentlens.path', value);
|
| 58 |
+
else localStorage.removeItem('agentlens.path');
|
| 59 |
+
} catch {
|
| 60 |
+
/* ignore */
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
async function callScan(path) {
|
| 65 |
+
const query = path ? `?path=${encodeURIComponent(path)}` : '';
|
| 66 |
+
const r = await fetch(`/agentlens/scan${query}`, { credentials: 'same-origin' });
|
| 67 |
+
const d = await r.json();
|
| 68 |
+
if (!r.ok || d.ok === false) throw new Error(d.error || `HTTP ${r.status}`);
|
| 69 |
+
return String(d.text || '');
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
async function callMigrate(path, from, to) {
|
| 73 |
+
const r = await fetch('/agentlens/migrate', {
|
| 74 |
+
method: 'POST',
|
| 75 |
+
credentials: 'same-origin',
|
| 76 |
+
headers: { 'content-type': 'application/json' },
|
| 77 |
+
body: JSON.stringify({ path, from, to }),
|
| 78 |
+
});
|
| 79 |
+
const d = await r.json();
|
| 80 |
+
if (!r.ok || d.ok === false) throw new Error(d.error || `HTTP ${r.status}`);
|
| 81 |
+
return String(d.text || '');
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
// ------------------------------------------------------------ scan chip
|
| 85 |
+
|
| 86 |
+
function ScanChip() {
|
| 87 |
+
const [busy, setBusy] = useState(false);
|
| 88 |
+
const [open, setOpen] = useState(false);
|
| 89 |
+
const [text, setText] = useState('');
|
| 90 |
+
const [error, setError] = useState('');
|
| 91 |
+
|
| 92 |
+
const run = useCallback(async () => {
|
| 93 |
+
setBusy(true);
|
| 94 |
+
setError('');
|
| 95 |
+
setText('');
|
| 96 |
+
try {
|
| 97 |
+
const result = await callScan(rememberedPath());
|
| 98 |
+
setText(result);
|
| 99 |
+
setOpen(true);
|
| 100 |
+
} catch (err) {
|
| 101 |
+
setError(String((err && err.message) || err));
|
| 102 |
+
setOpen(true);
|
| 103 |
+
} finally {
|
| 104 |
+
setBusy(false);
|
| 105 |
+
}
|
| 106 |
+
}, []);
|
| 107 |
+
|
| 108 |
+
return h(
|
| 109 |
+
'span',
|
| 110 |
+
{ className: 'agentlens-anchor' },
|
| 111 |
+
h(
|
| 112 |
+
'button',
|
| 113 |
+
{
|
| 114 |
+
type: 'button',
|
| 115 |
+
className: 'agentlens-chip',
|
| 116 |
+
title: '扫描当前项目的 AI Agent 配置(agentlens)',
|
| 117 |
+
disabled: busy,
|
| 118 |
+
onClick: run,
|
| 119 |
+
},
|
| 120 |
+
h('span', null, '🩺'),
|
| 121 |
+
h('span', null, busy ? '扫描中…' : '体检')
|
| 122 |
+
),
|
| 123 |
+
open
|
| 124 |
+
? h(
|
| 125 |
+
'div',
|
| 126 |
+
{ className: 'agentlens-pop' },
|
| 127 |
+
h(
|
| 128 |
+
'div',
|
| 129 |
+
{ className: 'agentlens-pop-head' },
|
| 130 |
+
h('span', null, 'AgentLens 扫描结果'),
|
| 131 |
+
h(
|
| 132 |
+
'button',
|
| 133 |
+
{
|
| 134 |
+
type: 'button',
|
| 135 |
+
className: 'agentlens-pop-close',
|
| 136 |
+
onClick: () => setOpen(false),
|
| 137 |
+
title: '关闭',
|
| 138 |
+
},
|
| 139 |
+
'✕'
|
| 140 |
+
)
|
| 141 |
+
),
|
| 142 |
+
error ? `扫描失败:${error}` : text
|
| 143 |
+
)
|
| 144 |
+
: null
|
| 145 |
+
);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
// ------------------------------------------------------ settings panel
|
| 149 |
+
|
| 150 |
+
function MigratePanel() {
|
| 151 |
+
const [path, setPath] = useState(rememberedPath());
|
| 152 |
+
const [from, setFrom] = useState('claude');
|
| 153 |
+
const [to, setTo] = useState('cursor');
|
| 154 |
+
const [busy, setBusy] = useState('');
|
| 155 |
+
const [out, setOut] = useState('');
|
| 156 |
+
const [error, setError] = useState('');
|
| 157 |
+
|
| 158 |
+
const savePath = useCallback((value) => {
|
| 159 |
+
setPath(value);
|
| 160 |
+
rememberPath(value);
|
| 161 |
+
}, []);
|
| 162 |
+
|
| 163 |
+
const doScan = useCallback(async () => {
|
| 164 |
+
setBusy('scan');
|
| 165 |
+
setError('');
|
| 166 |
+
try {
|
| 167 |
+
setOut(await callScan(path));
|
| 168 |
+
} catch (err) {
|
| 169 |
+
setError(String((err && err.message) || err));
|
| 170 |
+
setOut('');
|
| 171 |
+
} finally {
|
| 172 |
+
setBusy('');
|
| 173 |
+
}
|
| 174 |
+
}, [path]);
|
| 175 |
+
|
| 176 |
+
const doMigrate = useCallback(async () => {
|
| 177 |
+
setBusy('migrate');
|
| 178 |
+
setError('');
|
| 179 |
+
try {
|
| 180 |
+
setOut(await callMigrate(path, from, to));
|
| 181 |
+
} catch (err) {
|
| 182 |
+
setError(String((err && err.message) || err));
|
| 183 |
+
} finally {
|
| 184 |
+
setBusy('');
|
| 185 |
+
}
|
| 186 |
+
}, [path, from, to]);
|
| 187 |
+
|
| 188 |
+
return h(
|
| 189 |
+
'div',
|
| 190 |
+
{ className: 'agentlens-panel' },
|
| 191 |
+
h('h3', null, 'AgentLens 迁移'),
|
| 192 |
+
h(
|
| 193 |
+
'p',
|
| 194 |
+
{ className: 'agentlens-hint' },
|
| 195 |
+
'把 AI Agent 的规则配置在 Claude Code / Cursor / Codex / Windsurf / Copilot 之间一键迁移;也可以先扫描项目里现有的配置。所有操作都在本机完成。'
|
| 196 |
+
),
|
| 197 |
+
h(
|
| 198 |
+
'div',
|
| 199 |
+
{ className: 'row' },
|
| 200 |
+
h('input', {
|
| 201 |
+
type: 'text',
|
| 202 |
+
placeholder: '项目路径(留空扫描默认目录)',
|
| 203 |
+
value: path,
|
| 204 |
+
onChange: (e) => savePath(e.target.value),
|
| 205 |
+
}),
|
| 206 |
+
h(
|
| 207 |
+
'button',
|
| 208 |
+
{ type: 'button', disabled: busy !== '', onClick: doScan },
|
| 209 |
+
busy === 'scan' ? '扫描中…' : '扫描'
|
| 210 |
+
)
|
| 211 |
+
),
|
| 212 |
+
h(
|
| 213 |
+
'div',
|
| 214 |
+
{ className: 'row' },
|
| 215 |
+
h('span', { style: { opacity: 0.75 } }, '迁移规则:'),
|
| 216 |
+
h(
|
| 217 |
+
'select',
|
| 218 |
+
{ value: from, onChange: (e) => setFrom(e.target.value) },
|
| 219 |
+
AGENTS.map((a) => h('option', { key: a, value: a }, a))
|
| 220 |
+
),
|
| 221 |
+
h('span', { style: { opacity: 0.75 } }, '→'),
|
| 222 |
+
h(
|
| 223 |
+
'select',
|
| 224 |
+
{ value: to, onChange: (e) => setTo(e.target.value) },
|
| 225 |
+
AGENTS.map((a) => h('option', { key: a, value: a }, a))
|
| 226 |
+
),
|
| 227 |
+
h(
|
| 228 |
+
'button',
|
| 229 |
+
{ type: 'button', disabled: busy !== '' || from === to, onClick: doMigrate },
|
| 230 |
+
busy === 'migrate' ? '迁移中…' : '开始迁移'
|
| 231 |
+
)
|
| 232 |
+
),
|
| 233 |
+
error ? h('p', { className: 'agentlens-hint', style: { color: '#ff8a80' } }, `出错了:${error}`) : null,
|
| 234 |
+
out ? h('pre', { className: 'agentlens-out' }, out) : null
|
| 235 |
+
);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
// ----------------------------------------------------------------- apply
|
| 239 |
+
|
| 240 |
+
return {
|
| 241 |
+
inject: ['slots'],
|
| 242 |
+
apply(ctx) {
|
| 243 |
+
if (typeof document !== 'undefined' && !document.getElementById(STYLE_ID)) {
|
| 244 |
+
const tag = document.createElement('style');
|
| 245 |
+
tag.id = STYLE_ID;
|
| 246 |
+
tag.textContent = STYLE_TEXT;
|
| 247 |
+
document.head.appendChild(tag);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
// Composer tool row: the permission seat (完全访问) is a `single` slot,
|
| 251 |
+
// so the nearest injectable list slot rendered right after it is
|
| 252 |
+
// `conversation.input.left`. No explicit order → appended after any
|
| 253 |
+
// existing items (偏移一位 by design).
|
| 254 |
+
ctx.slots.inject('conversation.input.left', () =>
|
| 255 |
+
ctx.slots.register({ name: 'conversation.input.left' }, () => h(ScanChip))
|
| 256 |
+
);
|
| 257 |
+
|
| 258 |
+
// Settings page section for migration.
|
| 259 |
+
ctx.slots.inject('settings.section', () =>
|
| 260 |
+
ctx.slots.register(
|
| 261 |
+
{ name: 'settings.section', id: 'agentlens', order: 43, label: () => 'AgentLens 迁移' },
|
| 262 |
+
MigratePanel
|
| 263 |
+
)
|
| 264 |
+
);
|
| 265 |
+
},
|
| 266 |
+
};
|
| 267 |
+
},
|
| 268 |
+
});
|
ext/dsh-plugin/index.js
CHANGED
|
@@ -1,46 +1,132 @@
|
|
| 1 |
/**
|
| 2 |
-
* @local/agentlens —
|
| 3 |
*
|
| 4 |
-
* Registers four model-facing tools
|
| 5 |
-
*
|
| 6 |
-
* agentlens_move — migrate rules between agent formats
|
| 7 |
-
* agentlens_drift — detect config drift across agents
|
| 8 |
-
* agentlens_check — adversarial code QA on a file or git diff
|
| 9 |
*
|
| 10 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
*/
|
| 12 |
import { execFile } from "node:child_process";
|
| 13 |
import { promisify } from "node:util";
|
|
|
|
| 14 |
|
| 15 |
const execFileAsync = promisify(execFile);
|
| 16 |
|
| 17 |
-
export const inject = ["tools"];
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
function
|
| 20 |
-
return
|
| 21 |
}
|
| 22 |
|
| 23 |
/** Run the agentlens CLI and return its combined output. */
|
| 24 |
-
async function runAgentlens(args, cwd) {
|
| 25 |
try {
|
| 26 |
-
const { stdout, stderr } = await execFileAsync(
|
| 27 |
cwd,
|
| 28 |
timeout: 120_000,
|
| 29 |
maxBuffer: 4 * 1024 * 1024,
|
| 30 |
});
|
| 31 |
return (stdout || "") + (stderr ? `\n${stderr}` : "");
|
| 32 |
} catch (err) {
|
| 33 |
-
|
| 34 |
}
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
/**
|
| 38 |
* @param ctx - owning Host context.
|
| 39 |
-
* @param config -
|
| 40 |
*/
|
| 41 |
export function apply(ctx, config = {}) {
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
|
|
|
| 44 |
ctx.effect(() => {
|
| 45 |
const tools = ctx.get("tools");
|
| 46 |
if (tools === void 0) return;
|
|
@@ -57,9 +143,10 @@ export function apply(ctx, config = {}) {
|
|
| 57 |
},
|
| 58 |
additionalProperties: false,
|
| 59 |
},
|
|
|
|
| 60 |
async execute(args) {
|
| 61 |
-
const path = typeof args?.path === "string" ? args.path :
|
| 62 |
-
return
|
| 63 |
},
|
| 64 |
}),
|
| 65 |
tools.register({
|
|
@@ -76,10 +163,11 @@ export function apply(ctx, config = {}) {
|
|
| 76 |
required: ["from", "to"],
|
| 77 |
additionalProperties: false,
|
| 78 |
},
|
|
|
|
| 79 |
async execute(args) {
|
| 80 |
-
const path = typeof args?.path === "string" ? args.path :
|
| 81 |
const cmd = ["move", "--from", String(args.from), "--to", String(args.to), "--path", path];
|
| 82 |
-
return
|
| 83 |
},
|
| 84 |
}),
|
| 85 |
tools.register({
|
|
@@ -93,9 +181,10 @@ export function apply(ctx, config = {}) {
|
|
| 93 |
},
|
| 94 |
additionalProperties: false,
|
| 95 |
},
|
|
|
|
| 96 |
async execute(args) {
|
| 97 |
-
const path = typeof args?.path === "string" ? args.path :
|
| 98 |
-
return
|
| 99 |
},
|
| 100 |
}),
|
| 101 |
tools.register({
|
|
@@ -110,10 +199,11 @@ export function apply(ctx, config = {}) {
|
|
| 110 |
},
|
| 111 |
additionalProperties: false,
|
| 112 |
},
|
|
|
|
| 113 |
async execute(args) {
|
| 114 |
-
const path = typeof args?.path === "string" ? args.path :
|
| 115 |
const target = typeof args?.target === "string" ? args.target : "HEAD~1..HEAD";
|
| 116 |
-
return
|
| 117 |
},
|
| 118 |
}),
|
| 119 |
];
|
|
|
|
| 1 |
/**
|
| 2 |
+
* @local/agentlens — Host half.
|
| 3 |
*
|
| 4 |
+
* Registers four model-facing tools plus two local HTTP routes that back the
|
| 5 |
+
* client UI (composer chip + Settings panel):
|
|
|
|
|
|
|
|
|
|
| 6 |
*
|
| 7 |
+
* tools: agentlens_scan / agentlens_move / agentlens_drift / agentlens_check
|
| 8 |
+
* routes: GET /agentlens/scan?path=…
|
| 9 |
+
* POST /agentlens/migrate {path, from, to}
|
| 10 |
+
*
|
| 11 |
+
* Everything shells out to the AgentLens CLI on this machine; nothing leaves it.
|
| 12 |
*/
|
| 13 |
import { execFile } from "node:child_process";
|
| 14 |
import { promisify } from "node:util";
|
| 15 |
+
import { existsSync, readFileSync } from "node:fs";
|
| 16 |
|
| 17 |
const execFileAsync = promisify(execFile);
|
| 18 |
|
| 19 |
+
export const inject = ["tools", "webServer"];
|
| 20 |
+
|
| 21 |
+
const DEFAULT_ENTRY = '/Users/apple/Downloads/mimo/agentlens/dist/cli/index.js';
|
| 22 |
|
| 23 |
+
function resolveEntry(config) {
|
| 24 |
+
return config?.entry || process.env.AGENTLENS_ENTRY || DEFAULT_ENTRY;
|
| 25 |
}
|
| 26 |
|
| 27 |
/** Run the agentlens CLI and return its combined output. */
|
| 28 |
+
async function runAgentlens(entry, args, cwd) {
|
| 29 |
try {
|
| 30 |
+
const { stdout, stderr } = await execFileAsync(process.execPath, [entry, ...args], {
|
| 31 |
cwd,
|
| 32 |
timeout: 120_000,
|
| 33 |
maxBuffer: 4 * 1024 * 1024,
|
| 34 |
});
|
| 35 |
return (stdout || "") + (stderr ? `\n${stderr}` : "");
|
| 36 |
} catch (err) {
|
| 37 |
+
throw new Error(`AgentLens 执行失败: ${err?.message ?? String(err)}`);
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
| 41 |
+
|
| 42 |
+
/** Shared output contract: tools return { text } and render it as text content. */
|
| 43 |
+
const TEXT_OUTPUT = {
|
| 44 |
+
schema: { type: "object", properties: { text: { type: "string" } }, required: ["text"], additionalProperties: false },
|
| 45 |
+
render: (_args, value) => text(value?.text ?? ""),
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
/** Wrap a runAgentlens result into the { text } output shape. */
|
| 49 |
+
async function runTool(entry, args, cwd) {
|
| 50 |
+
return { text: await runAgentlens(entry, args, cwd) };
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/** Exact-path route that never throws past registration. */
|
| 54 |
+
function mountRoutes(server, entry, fallbackCwd) {
|
| 55 |
+
const json = (res, status, body) => {
|
| 56 |
+
res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
| 57 |
+
res.end(JSON.stringify(body));
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
const scanRoute = {
|
| 61 |
+
kind: "exact",
|
| 62 |
+
path: "/agentlens/scan",
|
| 63 |
+
async handler(req, res) {
|
| 64 |
+
try {
|
| 65 |
+
const url = new URL(req.url ?? "/agentlens/scan", "http://127.0.0.1");
|
| 66 |
+
const path = url.searchParams.get("path") || fallbackCwd;
|
| 67 |
+
const text = await runAgentlens(entry, ["scan", "--path", path], path);
|
| 68 |
+
json(res, 200, { ok: true, text });
|
| 69 |
+
} catch (error) {
|
| 70 |
+
json(res, 500, { ok: false, error: String((error && error.message) || error) });
|
| 71 |
+
}
|
| 72 |
+
},
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
const migrateRoute = {
|
| 76 |
+
kind: "exact",
|
| 77 |
+
path: "/agentlens/migrate",
|
| 78 |
+
async handler(req, res) {
|
| 79 |
+
try {
|
| 80 |
+
const body = await new Promise((resolve) => {
|
| 81 |
+
let raw = "";
|
| 82 |
+
req.on("data", (chunk) => {
|
| 83 |
+
raw += chunk;
|
| 84 |
+
});
|
| 85 |
+
req.on("end", () => resolve(raw));
|
| 86 |
+
});
|
| 87 |
+
const payload = body ? JSON.parse(body) : {};
|
| 88 |
+
const path = String(payload.path || fallbackCwd);
|
| 89 |
+
const from = String(payload.from || "");
|
| 90 |
+
const to = String(payload.to || "");
|
| 91 |
+
if (!from || !to) {
|
| 92 |
+
json(res, 400, { ok: false, error: "缺少 from / to 参数" });
|
| 93 |
+
return;
|
| 94 |
+
}
|
| 95 |
+
const text = await runAgentlens(entry, ["move", "--from", from, "--to", to, "--path", path], path);
|
| 96 |
+
json(res, 200, { ok: true, text });
|
| 97 |
+
} catch (error) {
|
| 98 |
+
json(res, 500, { ok: false, error: String((error && error.message) || error) });
|
| 99 |
+
}
|
| 100 |
+
},
|
| 101 |
+
};
|
| 102 |
+
|
| 103 |
+
const disposers = [];
|
| 104 |
+
for (const route of [scanRoute, migrateRoute]) {
|
| 105 |
+
try {
|
| 106 |
+
disposers.push(server.register(route));
|
| 107 |
+
} catch (error) {
|
| 108 |
+
console.warn?.("agentlens: route %s was not registered: %s", route.path, error?.message ?? error);
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
return () => disposers.forEach((dispose) => dispose?.());
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
/**
|
| 115 |
* @param ctx - owning Host context.
|
| 116 |
+
* @param config - { entry?: string } optional CLI entry override.
|
| 117 |
*/
|
| 118 |
export function apply(ctx, config = {}) {
|
| 119 |
+
const entry = resolveEntry(config);
|
| 120 |
+
const fallbackCwd = process.cwd();
|
| 121 |
+
|
| 122 |
+
// --- Local HTTP routes for the client UI ---
|
| 123 |
+
ctx.effect(() => {
|
| 124 |
+
const server = ctx.get("webServer");
|
| 125 |
+
if (!server) return;
|
| 126 |
+
return mountRoutes(server, entry, fallbackCwd);
|
| 127 |
+
}, "agentlens: local routes");
|
| 128 |
|
| 129 |
+
// --- Model-facing tools ---
|
| 130 |
ctx.effect(() => {
|
| 131 |
const tools = ctx.get("tools");
|
| 132 |
if (tools === void 0) return;
|
|
|
|
| 143 |
},
|
| 144 |
additionalProperties: false,
|
| 145 |
},
|
| 146 |
+
output: TEXT_OUTPUT,
|
| 147 |
async execute(args) {
|
| 148 |
+
const path = typeof args?.path === "string" ? args.path : fallbackCwd;
|
| 149 |
+
return runTool(entry, ["scan", "--path", path], path);
|
| 150 |
},
|
| 151 |
}),
|
| 152 |
tools.register({
|
|
|
|
| 163 |
required: ["from", "to"],
|
| 164 |
additionalProperties: false,
|
| 165 |
},
|
| 166 |
+
output: TEXT_OUTPUT,
|
| 167 |
async execute(args) {
|
| 168 |
+
const path = typeof args?.path === "string" ? args.path : fallbackCwd;
|
| 169 |
const cmd = ["move", "--from", String(args.from), "--to", String(args.to), "--path", path];
|
| 170 |
+
return runTool(entry, cmd, path);
|
| 171 |
},
|
| 172 |
}),
|
| 173 |
tools.register({
|
|
|
|
| 181 |
},
|
| 182 |
additionalProperties: false,
|
| 183 |
},
|
| 184 |
+
output: TEXT_OUTPUT,
|
| 185 |
async execute(args) {
|
| 186 |
+
const path = typeof args?.path === "string" ? args.path : fallbackCwd;
|
| 187 |
+
return runTool(entry, ["drift", "--path", path], path);
|
| 188 |
},
|
| 189 |
}),
|
| 190 |
tools.register({
|
|
|
|
| 199 |
},
|
| 200 |
additionalProperties: false,
|
| 201 |
},
|
| 202 |
+
output: TEXT_OUTPUT,
|
| 203 |
async execute(args) {
|
| 204 |
+
const path = typeof args?.path === "string" ? args.path : fallbackCwd;
|
| 205 |
const target = typeof args?.target === "string" ? args.target : "HEAD~1..HEAD";
|
| 206 |
+
return runTool(entry, ["check", target, "--path", path], path);
|
| 207 |
},
|
| 208 |
}),
|
| 209 |
];
|
ext/dsh-plugin/package.json
CHANGED
|
@@ -1,19 +1,25 @@
|
|
| 1 |
{
|
| 2 |
"name": "@local/agentlens",
|
| 3 |
-
"version": "1.
|
| 4 |
"private": true,
|
| 5 |
"type": "module",
|
| 6 |
-
"description": "AgentLens for DSH:
|
| 7 |
"exports": {
|
| 8 |
-
".": "./index.js"
|
|
|
|
| 9 |
},
|
| 10 |
"files": [
|
| 11 |
"index.js",
|
|
|
|
| 12 |
"cordis.patch.yml"
|
| 13 |
],
|
| 14 |
"dsh": {
|
| 15 |
"bundle": {
|
| 16 |
"patch": "./cordis.patch.yml"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
}
|
| 19 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@local/agentlens",
|
| 3 |
+
"version": "1.1.0",
|
| 4 |
"private": true,
|
| 5 |
"type": "module",
|
| 6 |
+
"description": "AgentLens for DSH: composer scan chip + Settings migration panel + model-facing tools",
|
| 7 |
"exports": {
|
| 8 |
+
".": "./index.js",
|
| 9 |
+
"./client": "./client.js"
|
| 10 |
},
|
| 11 |
"files": [
|
| 12 |
"index.js",
|
| 13 |
+
"client.js",
|
| 14 |
"cordis.patch.yml"
|
| 15 |
],
|
| 16 |
"dsh": {
|
| 17 |
"bundle": {
|
| 18 |
"patch": "./cordis.patch.yml"
|
| 19 |
+
},
|
| 20 |
+
"client": {
|
| 21 |
+
"platform": "web",
|
| 22 |
+
"immediately": true
|
| 23 |
}
|
| 24 |
}
|
| 25 |
}
|
ext/skill/SKILL.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: agentlens
|
| 3 |
+
description: AI 编程 Agent 配置迁移与代码体检。扫描项目里的 Agent 规则文件(CLAUDE.md / .cursor/rules / AGENTS.md / .windsurfrules / copilot-instructions),在 Claude Code / Cursor / Codex / Windsurf / Copilot 之间一键迁移规则,检测配置漂移,并对 AI 写的代码做对抗式体检(安全漏洞、正确性 bug、风格问题)。当用户提到 AgentLens、扫描 Agent 配置、迁移规则、配置漂移、代码体检、检查 AI 生成的代码时使用。
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# AgentLens
|
| 7 |
+
|
| 8 |
+
本机已安装 AgentLens(CLI + MCP Server + DSH 插件)。MiMo Desktop 中优先使用已注册的 MCP 工具;工具不可用时回退到本地 CLI。
|
| 9 |
+
|
| 10 |
+
## 工具选择
|
| 11 |
+
|
| 12 |
+
优先调用 MCP 工具(本会话已连接):
|
| 13 |
+
|
| 14 |
+
| 工具名 | 用途 |
|
| 15 |
+
|---|---|
|
| 16 |
+
| `agentlens_agentlens_scan` | 扫描项目的 Agent 配置,返回各 Agent 的规则数量和类别统计 |
|
| 17 |
+
| `agentlens_agentlens_move` | 迁移规则:`from` → `to`(claude / cursor / codex / windsurf / copilot) |
|
| 18 |
+
| `agentlens_agentlens_drift` | 检测配置漂移(措辞不一致的规则、缺失的类别) |
|
| 19 |
+
| `agentlens_agentlens_check` | 体检代码:传 `code` + `filename`,返回安全/正确性/风格问题 |
|
| 20 |
+
|
| 21 |
+
MCP 工具不可用时,回退到 CLI:
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
node /Users/apple/Downloads/mimo/agentlens/dist/cli/index.js scan --path <项目路径>
|
| 25 |
+
node /Users/apple/Downloads/mimo/agentlens/dist/cli/index.js move --from <源> --to <目标> --path <项目路径>
|
| 26 |
+
node /Users/apple/Downloads/mimo/agentlens/dist/cli/index.js drift --path <项目路径>
|
| 27 |
+
node /Users/apple/Downloads/mimo/agentlens/dist/cli/index.js check <文件或 git diff 范围> --path <项目路径>
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## 使用流程
|
| 31 |
+
|
| 32 |
+
1. **扫描**:用户问"项目里有哪些 Agent 配置"→ 调 `agentlens_scan`,用 path 指定项目根目录(默认当前目录)。
|
| 33 |
+
2. **迁移**:用户说"把 Cursor 的规则搬到 Claude Code"→ 调 `agentlens_move`,from=cursor, to=claude。迁移前可先 scan 确认源规则存在。
|
| 34 |
+
3. **漂移**:用户问"我的配置有没有不一致"→ 调 `agentlens_drift`。
|
| 35 |
+
4. **体检**:用户贴了一段代码或问"这段代码有没有问题"→ 调 `agentlens_check`,把代码原文放入 `code`,文件名放入 `filename`(用于语言识别)。
|
| 36 |
+
|
| 37 |
+
## 结果解读
|
| 38 |
+
|
| 39 |
+
- 体检严重级别:🔴 critical(安全漏洞,必须修)、🟡 warning(正确性问题,建议修)、⚪ info(风格/提示)。
|
| 40 |
+
- 扫描结果中每个 Agent 显示规则数和类别分布(context/tooling/workflow/constraint/style)。
|
| 41 |
+
- 迁移会写入目标 Agent 的标准配置文件(CLAUDE.md / .cursor/rules/agentlens.mdc / AGENTS.md / .windsurfrules / .github/copilot-instructions.md)。
|
| 42 |
+
|
| 43 |
+
## 注意
|
| 44 |
+
|
| 45 |
+
- 所有操作纯本地,不上传任何代码。
|
| 46 |
+
- 迁移是语义级转换(统一 IR 再生成),不是字符串复制;源文件不会被删除。
|
| 47 |
+
- 体检基于规则库(命令注入、SQL 注入、硬编码密钥、XSS、空 catch、宽松比较等),不是全量静态分析,报告是建议性质。
|
src/cli/commands/install.ts
CHANGED
|
@@ -22,6 +22,8 @@ interface Detection {
|
|
| 22 |
configPath: string;
|
| 23 |
detectDirs: string[];
|
| 24 |
format: "mcpServers" | "mimocode";
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
export function detectAgents(): Detection[] {
|
|
@@ -34,6 +36,7 @@ export function detectAgents(): Detection[] {
|
|
| 34 |
configPath: join(home, ".claude", "settings.json"),
|
| 35 |
detectDirs: [join(home, ".claude")],
|
| 36 |
format: "mcpServers",
|
|
|
|
| 37 |
},
|
| 38 |
{
|
| 39 |
key: "cursor",
|
|
@@ -48,6 +51,7 @@ export function detectAgents(): Detection[] {
|
|
| 48 |
configPath: join(cwd, ".mcp.json"),
|
| 49 |
detectDirs: [cwd],
|
| 50 |
format: "mcpServers",
|
|
|
|
| 51 |
},
|
| 52 |
{
|
| 53 |
key: "zcode",
|
|
@@ -55,6 +59,7 @@ export function detectAgents(): Detection[] {
|
|
| 55 |
configPath: join(home, ".zcode", "mcp.json"),
|
| 56 |
detectDirs: [join(home, ".zcode")],
|
| 57 |
format: "mcpServers",
|
|
|
|
| 58 |
},
|
| 59 |
{
|
| 60 |
key: "workbuddy",
|
|
@@ -62,6 +67,7 @@ export function detectAgents(): Detection[] {
|
|
| 62 |
configPath: join(home, ".workbuddy", "mcp.json"),
|
| 63 |
detectDirs: [join(home, ".workbuddy"), join(home, ".workbuddy-ai")],
|
| 64 |
format: "mcpServers",
|
|
|
|
| 65 |
},
|
| 66 |
{
|
| 67 |
key: "mimo",
|
|
@@ -69,6 +75,7 @@ export function detectAgents(): Detection[] {
|
|
| 69 |
configPath: join(home, ".config", "mimocode", "mimocode.jsonc"),
|
| 70 |
detectDirs: [join(home, ".config", "mimocode"), join(home, "Library", "Application Support", "Xiaomi MiMo")],
|
| 71 |
format: "mimocode",
|
|
|
|
| 72 |
},
|
| 73 |
];
|
| 74 |
}
|
|
@@ -134,6 +141,30 @@ function writeMimocodeConfig(configPath: string, serverName = "agentlens"): void
|
|
| 134 |
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
| 135 |
}
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
export async function installTo(target: string): Promise<void> {
|
| 138 |
console.log("AgentLens 安装器\n");
|
| 139 |
|
|
@@ -146,7 +177,8 @@ export async function installTo(target: string): Promise<void> {
|
|
| 146 |
} else {
|
| 147 |
writeMcpServersConfig(d.configPath);
|
| 148 |
}
|
| 149 |
-
|
|
|
|
| 150 |
return true;
|
| 151 |
} catch (err: any) {
|
| 152 |
console.log(` ❌ ${d.label}: ${err.message}`);
|
|
|
|
| 22 |
configPath: string;
|
| 23 |
detectDirs: string[];
|
| 24 |
format: "mcpServers" | "mimocode";
|
| 25 |
+
/** Where the AgentLens skill (SKILL.md) is installed, if the app supports skills. */
|
| 26 |
+
skillsDir?: string;
|
| 27 |
}
|
| 28 |
|
| 29 |
export function detectAgents(): Detection[] {
|
|
|
|
| 36 |
configPath: join(home, ".claude", "settings.json"),
|
| 37 |
detectDirs: [join(home, ".claude")],
|
| 38 |
format: "mcpServers",
|
| 39 |
+
skillsDir: join(home, ".claude", "skills"),
|
| 40 |
},
|
| 41 |
{
|
| 42 |
key: "cursor",
|
|
|
|
| 51 |
configPath: join(cwd, ".mcp.json"),
|
| 52 |
detectDirs: [cwd],
|
| 53 |
format: "mcpServers",
|
| 54 |
+
skillsDir: join(home, ".codex", "skills"),
|
| 55 |
},
|
| 56 |
{
|
| 57 |
key: "zcode",
|
|
|
|
| 59 |
configPath: join(home, ".zcode", "mcp.json"),
|
| 60 |
detectDirs: [join(home, ".zcode")],
|
| 61 |
format: "mcpServers",
|
| 62 |
+
skillsDir: join(home, ".zcode", "skills"),
|
| 63 |
},
|
| 64 |
{
|
| 65 |
key: "workbuddy",
|
|
|
|
| 67 |
configPath: join(home, ".workbuddy", "mcp.json"),
|
| 68 |
detectDirs: [join(home, ".workbuddy"), join(home, ".workbuddy-ai")],
|
| 69 |
format: "mcpServers",
|
| 70 |
+
skillsDir: join(home, ".workbuddy", "skills"),
|
| 71 |
},
|
| 72 |
{
|
| 73 |
key: "mimo",
|
|
|
|
| 75 |
configPath: join(home, ".config", "mimocode", "mimocode.jsonc"),
|
| 76 |
detectDirs: [join(home, ".config", "mimocode"), join(home, "Library", "Application Support", "Xiaomi MiMo")],
|
| 77 |
format: "mimocode",
|
| 78 |
+
skillsDir: join(home, ".agents", "skills"),
|
| 79 |
},
|
| 80 |
];
|
| 81 |
}
|
|
|
|
| 141 |
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
| 142 |
}
|
| 143 |
|
| 144 |
+
/** Locate the bundled SKILL.md (repo ext/skill or installed copy). */
|
| 145 |
+
function bundledSkillPath(): string | undefined {
|
| 146 |
+
const here = dirname(new URL(import.meta.url).pathname);
|
| 147 |
+
const candidates = [
|
| 148 |
+
resolve(here, "../../../ext/skill/SKILL.md"),
|
| 149 |
+
resolve(here, "../../../../ext/skill/SKILL.md"),
|
| 150 |
+
];
|
| 151 |
+
for (const p of candidates) {
|
| 152 |
+
if (existsSync(p)) return p;
|
| 153 |
+
}
|
| 154 |
+
return undefined;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
/** Install the AgentLens skill into an app's skills root. */
|
| 158 |
+
function installSkill(d: Detection): string | undefined {
|
| 159 |
+
if (!d.skillsDir) return undefined;
|
| 160 |
+
const src = bundledSkillPath();
|
| 161 |
+
if (!src) return undefined;
|
| 162 |
+
const dest = join(d.skillsDir, "agentlens", "SKILL.md");
|
| 163 |
+
mkdirSync(dirname(dest), { recursive: true });
|
| 164 |
+
writeFileSync(dest, readFileSync(src, "utf-8"), "utf-8");
|
| 165 |
+
return dest;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
export async function installTo(target: string): Promise<void> {
|
| 169 |
console.log("AgentLens 安装器\n");
|
| 170 |
|
|
|
|
| 177 |
} else {
|
| 178 |
writeMcpServersConfig(d.configPath);
|
| 179 |
}
|
| 180 |
+
const skillPath = installSkill(d);
|
| 181 |
+
console.log(` ✅ ${d.label} → ${d.configPath}${skillPath ? ` (+skill: ${skillPath})` : ""}`);
|
| 182 |
return true;
|
| 183 |
} catch (err: any) {
|
| 184 |
console.log(` ❌ ${d.label}: ${err.message}`);
|