@archon-claw/cli 0.5.0 → 0.5.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/package.json +3 -2
- package/dist/scaffold.d.ts +0 -7
- package/dist/scaffold.js +0 -115
- package/dist/templates/agent/model.json +0 -6
- package/dist/templates/agent/system-prompt.md +0 -9
- package/dist/templates/agent/tool-impls/greeting.impl.js +0 -9
- package/dist/templates/agent/tools/greeting.json +0 -14
- package/dist/templates/workspace/.claude/skills/create-agent/SKILL.md +0 -90
- package/dist/templates/workspace/.claude/skills/create-dataset/SKILL.md +0 -57
- package/dist/templates/workspace/.claude/skills/create-eval-case/SKILL.md +0 -159
- package/dist/templates/workspace/.claude/skills/create-eval-judge/SKILL.md +0 -128
- package/dist/templates/workspace/.claude/skills/create-mcp-config/SKILL.md +0 -151
- package/dist/templates/workspace/.claude/skills/create-model-config/SKILL.md +0 -45
- package/dist/templates/workspace/.claude/skills/create-skill/SKILL.md +0 -63
- package/dist/templates/workspace/.claude/skills/create-system-prompt/SKILL.md +0 -168
- package/dist/templates/workspace/.claude/skills/create-tool/SKILL.md +0 -56
- package/dist/templates/workspace/.claude/skills/create-tool-impl/SKILL.md +0 -83
- package/dist/templates/workspace/.claude/skills/create-tool-test/SKILL.md +0 -117
- package/dist/templates/workspace/.claude/skills/create-tool-ui/SKILL.md +0 -218
- package/dist/templates/workspace/README.md +0 -13
- package/dist/templates/workspace/package.json +0 -19
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: create-tool-ui
|
|
3
|
-
description: 创建工具自定义 UI 组件。当用户需要为工具定制 Chat UI 中的展示效果时使用。
|
|
4
|
-
argument-hint: "[tool_name]"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
在 `agents/<agent>/tool-uis/` 目录下创建工具自定义 UI 文件。
|
|
8
|
-
|
|
9
|
-
## 背景
|
|
10
|
-
|
|
11
|
-
默认情况下,所有工具在 Chat UI 中以可折叠的 JSON 面板展示(args + result)。通过自定义 UI,可以用 Web Component 替代默认展示,提供更直观的交互体验。
|
|
12
|
-
|
|
13
|
-
## 规范
|
|
14
|
-
|
|
15
|
-
- 文件名格式:`<tool-name>.ui.js`,必须与 `tools/<tool-name>.json` 的 name 一致
|
|
16
|
-
- 文件内定义一个 **Custom Element**(Web Component),使用 Shadow DOM 隔离样式
|
|
17
|
-
- Custom Element 标签名必须是 `tool-ui-<tool-name>`
|
|
18
|
-
- 数据通过 **JS property**(不是 HTML attribute)传入:
|
|
19
|
-
- `args`:`Record<string, unknown>` — 工具调用参数
|
|
20
|
-
- `result`:`unknown` — 工具返回结果(运行中时为 `undefined`)
|
|
21
|
-
- `status`:`"running"` | `"done"` — 执行状态
|
|
22
|
-
- 每次 property 被赋值时应触发重新渲染
|
|
23
|
-
|
|
24
|
-
## 文件结构
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
agents/<agent>/
|
|
28
|
-
├── tools/search.json
|
|
29
|
-
├── tool-impls/search.impl.js
|
|
30
|
-
└── tool-uis/search.ui.js ← 新增:自定义 UI
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 模板
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
class <ToolName>UI extends HTMLElement {
|
|
37
|
-
constructor() {
|
|
38
|
-
super();
|
|
39
|
-
this.attachShadow({ mode: 'open' });
|
|
40
|
-
this._args = {};
|
|
41
|
-
this._result = undefined;
|
|
42
|
-
this._status = 'running';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
set args(v) { this._args = v; this.render(); }
|
|
46
|
-
set result(v) { this._result = v; this.render(); }
|
|
47
|
-
set status(v) { this._status = v; this.render(); }
|
|
48
|
-
get args() { return this._args; }
|
|
49
|
-
get result() { return this._result; }
|
|
50
|
-
get status() { return this._status; }
|
|
51
|
-
|
|
52
|
-
connectedCallback() { this.render(); }
|
|
53
|
-
|
|
54
|
-
render() {
|
|
55
|
-
const isRunning = this._status === 'running';
|
|
56
|
-
this.shadowRoot.innerHTML = `
|
|
57
|
-
<style>
|
|
58
|
-
:host { display: block; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; font-family: system-ui, sans-serif; font-size: 14px; }
|
|
59
|
-
.header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
|
|
60
|
-
.name { font-weight: 500; color: #374151; }
|
|
61
|
-
.status { color: #9ca3af; font-size: 12px; }
|
|
62
|
-
.body { padding: 8px 12px; }
|
|
63
|
-
</style>
|
|
64
|
-
<div class="header">
|
|
65
|
-
<span class="name"><tool-name></span>
|
|
66
|
-
<span class="status">${isRunning ? 'Running...' : 'Done'}</span>
|
|
67
|
-
</div>
|
|
68
|
-
<div class="body">
|
|
69
|
-
${isRunning ? '<span class="status">Processing...</span>' : this.renderResult()}
|
|
70
|
-
</div>
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
renderResult() {
|
|
75
|
-
// 根据 this._result 的结构自定义渲染
|
|
76
|
-
return `<pre style="margin:0;white-space:pre-wrap;font-size:12px;">${this.escapeHtml(JSON.stringify(this._result, null, 2))}</pre>`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
escapeHtml(str) {
|
|
80
|
-
const d = document.createElement('div');
|
|
81
|
-
d.textContent = String(str);
|
|
82
|
-
return d.innerHTML;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
customElements.define('tool-ui-<tool-name>', <ToolName>UI);
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## 示例
|
|
90
|
-
|
|
91
|
-
### 搜索工具(对应 tools/search.json)
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
class SearchUI extends HTMLElement {
|
|
95
|
-
constructor() {
|
|
96
|
-
super();
|
|
97
|
-
this.attachShadow({ mode: 'open' });
|
|
98
|
-
this._args = {};
|
|
99
|
-
this._result = undefined;
|
|
100
|
-
this._status = 'running';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
set args(v) { this._args = v; this.render(); }
|
|
104
|
-
set result(v) { this._result = v; this.render(); }
|
|
105
|
-
set status(v) { this._status = v; this.render(); }
|
|
106
|
-
get args() { return this._args; }
|
|
107
|
-
get result() { return this._result; }
|
|
108
|
-
get status() { return this._status; }
|
|
109
|
-
|
|
110
|
-
connectedCallback() { this.render(); }
|
|
111
|
-
|
|
112
|
-
render() {
|
|
113
|
-
const query = this._args?.query || '';
|
|
114
|
-
const isRunning = this._status === 'running';
|
|
115
|
-
this.shadowRoot.innerHTML = `
|
|
116
|
-
<style>
|
|
117
|
-
:host { display: block; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; font-family: system-ui, sans-serif; font-size: 14px; }
|
|
118
|
-
.header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fefce8; border-bottom: 1px solid #e5e7eb; }
|
|
119
|
-
.query { font-weight: 500; color: #92400e; }
|
|
120
|
-
.body { padding: 8px 12px; }
|
|
121
|
-
.item { padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
|
|
122
|
-
.item:last-child { border-bottom: none; }
|
|
123
|
-
.title { color: #1d4ed8; font-weight: 500; }
|
|
124
|
-
.url { color: #16a34a; font-size: 11px; margin-top: 1px; }
|
|
125
|
-
.status { color: #9ca3af; font-size: 12px; }
|
|
126
|
-
</style>
|
|
127
|
-
<div class="header">
|
|
128
|
-
<span>🔍</span>
|
|
129
|
-
<span class="query">${this.esc(query)}</span>
|
|
130
|
-
<span class="status">${isRunning ? '⏳' : 'Done'}</span>
|
|
131
|
-
</div>
|
|
132
|
-
${isRunning
|
|
133
|
-
? '<div class="body"><span class="status">Searching...</span></div>'
|
|
134
|
-
: (this._result ? this.renderResult() : '')}
|
|
135
|
-
`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
renderResult() {
|
|
139
|
-
const r = this._result;
|
|
140
|
-
const items = Array.isArray(r) ? r : (r && Array.isArray(r.results)) ? r.results : null;
|
|
141
|
-
if (items) {
|
|
142
|
-
return `<div class="body">${items.slice(0, 5).map(i => `
|
|
143
|
-
<div class="item">
|
|
144
|
-
<div class="title">${this.esc(i.title || '')}</div>
|
|
145
|
-
${i.url ? `<div class="url">${this.esc(i.url)}</div>` : ''}
|
|
146
|
-
</div>`).join('')}</div>`;
|
|
147
|
-
}
|
|
148
|
-
return `<div class="body"><pre style="margin:0;white-space:pre-wrap;font-size:12px;">${this.esc(JSON.stringify(r, null, 2))}</pre></div>`;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
esc(s) { const d = document.createElement('div'); d.textContent = String(s); return d.innerHTML; }
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
customElements.define('tool-ui-search', SearchUI);
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### 计算器(对应 tools/calculator.json)
|
|
158
|
-
|
|
159
|
-
```javascript
|
|
160
|
-
class CalculatorUI extends HTMLElement {
|
|
161
|
-
constructor() {
|
|
162
|
-
super();
|
|
163
|
-
this.attachShadow({ mode: 'open' });
|
|
164
|
-
this._args = {};
|
|
165
|
-
this._result = undefined;
|
|
166
|
-
this._status = 'running';
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
set args(v) { this._args = v; this.render(); }
|
|
170
|
-
set result(v) { this._result = v; this.render(); }
|
|
171
|
-
set status(v) { this._status = v; this.render(); }
|
|
172
|
-
get args() { return this._args; }
|
|
173
|
-
get result() { return this._result; }
|
|
174
|
-
get status() { return this._status; }
|
|
175
|
-
|
|
176
|
-
connectedCallback() { this.render(); }
|
|
177
|
-
|
|
178
|
-
render() {
|
|
179
|
-
const expr = this._args?.expression || '';
|
|
180
|
-
const isRunning = this._status === 'running';
|
|
181
|
-
const result = this._result;
|
|
182
|
-
this.shadowRoot.innerHTML = `
|
|
183
|
-
<style>
|
|
184
|
-
:host { display: block; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; font-family: system-ui, sans-serif; font-size: 14px; }
|
|
185
|
-
.calc { padding: 10px 14px; background: #f0fdf4; display: flex; align-items: center; gap: 8px; }
|
|
186
|
-
.expr { font-family: monospace; color: #374151; }
|
|
187
|
-
.eq { color: #9ca3af; }
|
|
188
|
-
.val { font-family: monospace; font-weight: 600; color: #15803d; }
|
|
189
|
-
.status { color: #9ca3af; font-size: 12px; }
|
|
190
|
-
</style>
|
|
191
|
-
<div class="calc">
|
|
192
|
-
<span>🧮</span>
|
|
193
|
-
<span class="expr">${this.esc(expr)}</span>
|
|
194
|
-
${isRunning
|
|
195
|
-
? '<span class="status">Computing...</span>'
|
|
196
|
-
: `<span class="eq">=</span> <span class="val">${this.esc(result?.result ?? '')}</span>`}
|
|
197
|
-
</div>
|
|
198
|
-
`;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
esc(s) { const d = document.createElement('div'); d.textContent = String(s); return d.innerHTML; }
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
customElements.define('tool-ui-calculator', CalculatorUI);
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## 注意
|
|
208
|
-
|
|
209
|
-
- 文件名必须是 `<tool-name>.ui.js`,且 `tools/<tool-name>.json` 必须存在,否则不会被加载
|
|
210
|
-
- Custom Element 标签名必须是 `tool-ui-<tool-name>`,使用 `customElements.define()` 注册
|
|
211
|
-
- 必须使用 `this.attachShadow({ mode: 'open' })` 创建 Shadow DOM,确保样式隔离
|
|
212
|
-
- 数据通过 JS property setter 传入(不是 attribute),每个 setter 内应调用 `this.render()`
|
|
213
|
-
- `result` 的类型取决于 tool-impl 的返回值,编写 `renderResult()` 时应处理多种可能的数据结构
|
|
214
|
-
- 组件运行在浏览器环境,可以使用所有 Web API(DOM、fetch 等)
|
|
215
|
-
- 不要依赖外部 CDN 资源,所有样式应内联在 Shadow DOM 的 `<style>` 中
|
|
216
|
-
- 使用 `escapeHtml` 防止 XSS — 永远不要直接拼接用户输入到 innerHTML
|
|
217
|
-
|
|
218
|
-
请根据用户的需求创建工具 UI 组件文件。$ARGUMENTS
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "{{name}}",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "archon-claw dev --agents-dir agents",
|
|
8
|
-
"start": "archon-claw start --agents-dir agents -p ${PORT:-5100}",
|
|
9
|
-
"test": "archon-claw test agents/my-agent",
|
|
10
|
-
"eval": "archon-claw eval agents/my-agent",
|
|
11
|
-
"create:agent": "archon-claw create-agent",
|
|
12
|
-
"export:skills": "archon-claw export-skills .claude/skills"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [],
|
|
15
|
-
"license": "ISC",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"@archon-claw/cli": "^{{cliVersion}}"
|
|
18
|
-
}
|
|
19
|
-
}
|