agent-lyceum 0.39.0 → 0.40.0
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 +1 -0
- package/README.zh-TW.md +1 -0
- package/dist/cli.js +2 -0
- package/dist/web-console.d.ts +28 -0
- package/dist/web-console.js +54 -0
- package/package.json +1 -1
- package/web/dist/commands.js +285 -0
- package/web/dist/public/assets/index-71AXqmZQ.js +10 -0
- package/web/dist/public/assets/index-BC6ou2wZ.css +2 -0
- package/web/dist/public/index.html +3 -2
- package/web/dist/server/api.js +184 -0
- package/web/dist/server/guard.js +35 -16
- package/web/dist/server/http.js +10 -4
- package/web/dist/server/runner.js +171 -0
- package/web/dist/start.js +39 -4
- package/web/dist/public/assets/index-C5Kk_orF.css +0 -2
- package/web/dist/public/assets/index-MnFKWkw_.js +0 -9
package/README.md
CHANGED
|
@@ -88,6 +88,7 @@ Likewise, older versions refuse a `project.yaml` that contains `verify` ("Unreco
|
|
|
88
88
|
| Run lifecycle, parallel agents, several runs at once, follow-ups, opening a PR | [How a run works](docs/how-it-works.md) |
|
|
89
89
|
| What agents may write, sandbox levels, known gaps | [Write scope](docs/write-scope.md) |
|
|
90
90
|
| Letting an agent search or fetch the web | [Web access](docs/web-access.md) |
|
|
91
|
+
| Running commands from the browser | [Web console](docs/web-console.md) |
|
|
91
92
|
| Live run status inside Claude Code (a framed, state-coloured tree of agents; pane or full-width band) | [Monitor mod](docs/monitor.md) |
|
|
92
93
|
| All commands in full | [Commands](docs/commands.md) |
|
|
93
94
|
| A task file template (scope, acceptance criteria, verification) | [Task template](docs/task-template.md) |
|
package/README.zh-TW.md
CHANGED
|
@@ -88,6 +88,7 @@ agents:
|
|
|
88
88
|
| run 的生命週期、平行 agent、同時多個 run、追加需求、開 PR | [一次執行如何運作](docs/how-it-works.zh-TW.md) |
|
|
89
89
|
| agent 能寫什麼、沙箱等級、已知缺口 | [寫入範圍](docs/write-scope.zh-TW.md) |
|
|
90
90
|
| 讓 agent 搜尋或讀取網頁 | [網路存取](docs/web-access.zh-TW.md) |
|
|
91
|
+
| 在瀏覽器執行指令 | [網頁操作台](docs/web-console.zh-TW.md) |
|
|
91
92
|
| 在 Claude Code 內看即時 run 狀態(每個 agent 一個依狀態上色的外框,樹狀排列;面板或整寬橫幅) | [監控 mod](docs/monitor.zh-TW.md) |
|
|
92
93
|
| 所有指令的完整說明 | [指令](docs/commands.zh-TW.md) |
|
|
93
94
|
| 任務檔範本(範圍、驗收條件、驗證指令) | [任務檔範本](docs/task-template.zh-TW.md) |
|
package/dist/cli.js
CHANGED
|
@@ -32,6 +32,7 @@ import { onlyAgent, soloProject } from "./solo.js";
|
|
|
32
32
|
import { DEMO_PROJECT, DEMO_TASK, defaultDemoDir, detectRuntime, prepareDemo } from "./demo.js";
|
|
33
33
|
import { claudeQuota, codexQuota } from "./quota.js";
|
|
34
34
|
import { summarizeProgress } from "./summarize.js";
|
|
35
|
+
import { createConsoleDeps } from "./web-console.js";
|
|
35
36
|
const program = new Command();
|
|
36
37
|
program
|
|
37
38
|
.name("agent-lyceum")
|
|
@@ -783,6 +784,7 @@ program
|
|
|
783
784
|
heartbeatMs: beat * 1000,
|
|
784
785
|
identity: { version, home: home() },
|
|
785
786
|
allowHosts: opts.allowHost,
|
|
787
|
+
console: createConsoleDeps(home(), fileURLToPath(import.meta.url)),
|
|
786
788
|
factory: {
|
|
787
789
|
list: () => listProjects(home()).map((item) => item.name),
|
|
788
790
|
watch: (name, onFrame) => createStatusWatcher({
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** What the web page's command console needs from this side of the package (`web/` cannot import `src/`). Same shape as `ConsoleDeps` in `web/src/server/api.ts`. */
|
|
2
|
+
export declare function createConsoleDeps(home: string, cliFile: string): {
|
|
3
|
+
home: string;
|
|
4
|
+
cli: {
|
|
5
|
+
execPath: string;
|
|
6
|
+
args: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
projectDir: (name: string) => string | undefined;
|
|
9
|
+
readAsk(project: string, runId: string): {
|
|
10
|
+
status: "answered" | "pending";
|
|
11
|
+
questions: {
|
|
12
|
+
id: string;
|
|
13
|
+
text: string;
|
|
14
|
+
asker: string;
|
|
15
|
+
options?: string[] | undefined;
|
|
16
|
+
suggested?: {
|
|
17
|
+
value: string;
|
|
18
|
+
reason?: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
answer?: string | undefined;
|
|
21
|
+
delivered: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
} | undefined;
|
|
24
|
+
saveAnswers(project: string, runId: string, answers: Record<string, string>, assumeDefaults: boolean): {
|
|
25
|
+
complete: boolean;
|
|
26
|
+
problems: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { prepareAnswers } from "./ask-answer.js";
|
|
4
|
+
import { readAskReply, writeAskReply } from "./ask-reply.js";
|
|
5
|
+
import { listProjects } from "./config.js";
|
|
6
|
+
import { NAME_RE, projectPaths } from "./paths.js";
|
|
7
|
+
/** What the web page's command console needs from this side of the package (`web/` cannot import `src/`). Same shape as `ConsoleDeps` in `web/src/server/api.ts`. */
|
|
8
|
+
export function createConsoleDeps(home, cliFile) {
|
|
9
|
+
const projectDir = (name) => listProjects(home).find((p) => p.name === name)?.dir;
|
|
10
|
+
const runDirOf = (project, runId) => {
|
|
11
|
+
if (!NAME_RE.test(project) || !NAME_RE.test(runId) || !projectDir(project))
|
|
12
|
+
return undefined;
|
|
13
|
+
const dir = path.join(projectPaths(home, project).runs, runId);
|
|
14
|
+
return fs.existsSync(dir) ? dir : undefined;
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
home,
|
|
18
|
+
cli: { execPath: process.execPath, args: [...process.execArgv, cliFile] },
|
|
19
|
+
projectDir,
|
|
20
|
+
readAsk(project, runId) {
|
|
21
|
+
const dir = runDirOf(project, runId);
|
|
22
|
+
const reply = dir ? readAskReply(dir) : undefined;
|
|
23
|
+
if (!reply)
|
|
24
|
+
return undefined;
|
|
25
|
+
return {
|
|
26
|
+
status: reply.status,
|
|
27
|
+
questions: reply.questions.map((q) => ({
|
|
28
|
+
id: q.id,
|
|
29
|
+
text: q.text,
|
|
30
|
+
asker: q.asker,
|
|
31
|
+
...(q.options ? { options: q.options } : {}),
|
|
32
|
+
...(q.suggested ? { suggested: q.suggested } : {}),
|
|
33
|
+
...(q.answer ? { answer: q.answer.value } : {}),
|
|
34
|
+
delivered: q.delivered === true,
|
|
35
|
+
})),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
saveAnswers(project, runId, answers, assumeDefaults) {
|
|
39
|
+
const dir = runDirOf(project, runId);
|
|
40
|
+
const reply = dir ? readAskReply(dir) : undefined;
|
|
41
|
+
if (!dir || !reply)
|
|
42
|
+
return { complete: false, problems: ["這次任務沒有待回答的問題。"] };
|
|
43
|
+
writeAskReply(dir, {
|
|
44
|
+
...reply,
|
|
45
|
+
questions: reply.questions.map((q) => {
|
|
46
|
+
const value = answers[q.id]?.trim();
|
|
47
|
+
return q.delivered || !value ? q : { ...q, answer: { value, by: "user" } };
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
const checked = prepareAnswers(dir, { assumeDefaults });
|
|
51
|
+
return { complete: checked.complete, problems: checked.problems };
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/** The command table shared by the server (validates a body, builds argv) and the page (draws the forms). Pure: no node imports. */
|
|
2
|
+
export class ArgError extends Error {
|
|
3
|
+
field;
|
|
4
|
+
constructor(field, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.field = field;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
10
|
+
const RUN_NAME_RE = /^[a-z0-9-]{1,30}$/;
|
|
11
|
+
const PATH_RE = /^(\/|~\/|[A-Za-z]:[\\/])/;
|
|
12
|
+
const RUNTIMES = ["claude-code", "codex"];
|
|
13
|
+
const LAYERS = ["project", "global"];
|
|
14
|
+
export const TEXT_LIMIT = 200_000;
|
|
15
|
+
function text(body, name, o) {
|
|
16
|
+
const raw = body[name];
|
|
17
|
+
const empty = raw === undefined || raw === null || (typeof raw === "string" && raw.trim() === "");
|
|
18
|
+
if (empty) {
|
|
19
|
+
if (o.required)
|
|
20
|
+
throw new ArgError(name, `${o.what}必填。`);
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (typeof raw !== "string")
|
|
24
|
+
throw new ArgError(name, `${o.what}格式不對。`);
|
|
25
|
+
const value = raw.trim();
|
|
26
|
+
if (value.includes("\u0000"))
|
|
27
|
+
throw new ArgError(name, `${o.what}含有不能用的字元。`);
|
|
28
|
+
if (value.length > (o.max ?? 256))
|
|
29
|
+
throw new ArgError(name, `${o.what}太長。`);
|
|
30
|
+
if (o.re && !o.re.test(value))
|
|
31
|
+
throw new ArgError(name, `${o.what}格式不對。`);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function flag(body, name) {
|
|
35
|
+
const raw = body[name];
|
|
36
|
+
if (raw === undefined || raw === null || raw === false)
|
|
37
|
+
return false;
|
|
38
|
+
if (raw !== true)
|
|
39
|
+
throw new ArgError(name, "這個選項只能是勾選或不勾選。");
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
const need = (value) => value;
|
|
43
|
+
const project = (b) => need(text(b, "project", { required: true, re: NAME_RE, what: "專案" }));
|
|
44
|
+
const oneOf = (b, name, allowed, what) => {
|
|
45
|
+
const v = text(b, name, { what });
|
|
46
|
+
if (v !== undefined && !allowed.includes(v))
|
|
47
|
+
throw new ArgError(name, `${what}只能是 ${allowed.join("、")}。`);
|
|
48
|
+
return v;
|
|
49
|
+
};
|
|
50
|
+
const PROJECT_FIELD = { name: "project", label: "專案", kind: "text", required: true };
|
|
51
|
+
const always = (m) => () => m;
|
|
52
|
+
const normal = () => "normal";
|
|
53
|
+
const noTarget = () => "";
|
|
54
|
+
export const COMMANDS = {
|
|
55
|
+
init: {
|
|
56
|
+
id: "init",
|
|
57
|
+
label: "初始化 home",
|
|
58
|
+
scope: "home",
|
|
59
|
+
fields: [],
|
|
60
|
+
mode: always("short"),
|
|
61
|
+
tier: normal,
|
|
62
|
+
target: noTarget,
|
|
63
|
+
argv: () => ["init", "-y"],
|
|
64
|
+
},
|
|
65
|
+
"project.list": {
|
|
66
|
+
id: "project.list",
|
|
67
|
+
label: "列出專案",
|
|
68
|
+
scope: "home",
|
|
69
|
+
fields: [],
|
|
70
|
+
mode: always("short"),
|
|
71
|
+
tier: normal,
|
|
72
|
+
target: noTarget,
|
|
73
|
+
argv: () => ["project"],
|
|
74
|
+
},
|
|
75
|
+
"project.add": {
|
|
76
|
+
id: "project.add",
|
|
77
|
+
label: "註冊專案",
|
|
78
|
+
scope: "home",
|
|
79
|
+
fields: [
|
|
80
|
+
{ name: "name", label: "專案名稱", kind: "text", required: true },
|
|
81
|
+
{ name: "dir", label: "repo 的絕對路徑", kind: "text", required: true, help: "agent 會在這個資料夾工作。" },
|
|
82
|
+
],
|
|
83
|
+
mode: always("short"),
|
|
84
|
+
tier: normal,
|
|
85
|
+
target: noTarget,
|
|
86
|
+
argv: (b) => {
|
|
87
|
+
const name = need(text(b, "name", { required: true, re: NAME_RE, what: "專案名稱" }));
|
|
88
|
+
const dir = need(text(b, "dir", { required: true, re: PATH_RE, what: "路徑", max: 1024 }));
|
|
89
|
+
if (dir.startsWith("~"))
|
|
90
|
+
throw new ArgError("dir", "路徑請用絕對路徑,不支援 ~。");
|
|
91
|
+
return ["project", "add", name, "--dir", dir];
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
"project.remove": {
|
|
95
|
+
id: "project.remove",
|
|
96
|
+
label: "移除專案",
|
|
97
|
+
scope: "home",
|
|
98
|
+
fields: [
|
|
99
|
+
{ name: "name", label: "專案名稱", kind: "text", required: true },
|
|
100
|
+
{ name: "purge", label: "連這個專案的所有 context 一起刪除", kind: "checkbox" },
|
|
101
|
+
],
|
|
102
|
+
mode: always("short"),
|
|
103
|
+
tier: (b) => (b.purge === true ? "typed" : "confirm"),
|
|
104
|
+
target: (b) => String(b.name ?? ""),
|
|
105
|
+
argv: (b) => {
|
|
106
|
+
const name = need(text(b, "name", { required: true, re: NAME_RE, what: "專案名稱" }));
|
|
107
|
+
return ["project", "remove", name, ...(flag(b, "purge") ? ["--purge"] : [])];
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
run: {
|
|
111
|
+
id: "run",
|
|
112
|
+
label: "新任務",
|
|
113
|
+
scope: "project",
|
|
114
|
+
fields: [
|
|
115
|
+
PROJECT_FIELD,
|
|
116
|
+
{ name: "task", label: "任務", kind: "textarea", required: true },
|
|
117
|
+
{ name: "name", label: "任務名稱(可留空)", kind: "text", help: "小寫英數與 -,最多 30 字。" },
|
|
118
|
+
{ name: "agent", label: "只交給這一位 agent(可留空)", kind: "text" },
|
|
119
|
+
{ name: "assumeDefaults", label: "有建議值的問題直接採用,不暫停", kind: "checkbox" },
|
|
120
|
+
],
|
|
121
|
+
mode: always("detached"),
|
|
122
|
+
tier: normal,
|
|
123
|
+
target: noTarget,
|
|
124
|
+
argv: (b) => {
|
|
125
|
+
const out = ["run", "-p", project(b)];
|
|
126
|
+
const name = text(b, "name", { re: RUN_NAME_RE, what: "任務名稱" });
|
|
127
|
+
if (name)
|
|
128
|
+
out.push("--name", name);
|
|
129
|
+
const agent = text(b, "agent", { re: NAME_RE, what: "agent" });
|
|
130
|
+
if (agent)
|
|
131
|
+
out.push("--agent", agent);
|
|
132
|
+
if (flag(b, "assumeDefaults"))
|
|
133
|
+
out.push("--assume-defaults");
|
|
134
|
+
out.push("--", need(text(b, "task", { required: true, what: "任務", max: TEXT_LIMIT })));
|
|
135
|
+
return out;
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
call: {
|
|
139
|
+
id: "call",
|
|
140
|
+
label: "呼叫單一 agent",
|
|
141
|
+
scope: "home",
|
|
142
|
+
fields: [
|
|
143
|
+
{ name: "agent", label: "agent(全域 library 裡的名稱)", kind: "text", required: true },
|
|
144
|
+
{ name: "dir", label: "工作目錄(絕對路徑)", kind: "text", required: true },
|
|
145
|
+
{ name: "task", label: "任務", kind: "textarea", required: true },
|
|
146
|
+
],
|
|
147
|
+
mode: always("detached"),
|
|
148
|
+
tier: normal,
|
|
149
|
+
target: noTarget,
|
|
150
|
+
argv: (b) => {
|
|
151
|
+
const agent = need(text(b, "agent", { required: true, re: NAME_RE, what: "agent" }));
|
|
152
|
+
const dir = need(text(b, "dir", { required: true, re: PATH_RE, what: "工作目錄", max: 1024 }));
|
|
153
|
+
return ["call", agent, "--dir", dir, "--", need(text(b, "task", { required: true, what: "任務", max: TEXT_LIMIT }))];
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
resume: {
|
|
157
|
+
id: "resume",
|
|
158
|
+
label: "續跑/追問",
|
|
159
|
+
scope: "project",
|
|
160
|
+
fields: [
|
|
161
|
+
PROJECT_FIELD,
|
|
162
|
+
{ name: "run", label: "任務 id", kind: "text", required: true },
|
|
163
|
+
{ name: "followup", label: "追問(只用在已完成的任務,可留空)", kind: "textarea" },
|
|
164
|
+
{ name: "assumeDefaults", label: "有建議值的問題直接採用", kind: "checkbox" },
|
|
165
|
+
],
|
|
166
|
+
mode: always("detached"),
|
|
167
|
+
tier: normal,
|
|
168
|
+
target: noTarget,
|
|
169
|
+
argv: (b) => {
|
|
170
|
+
const p = project(b);
|
|
171
|
+
const run = need(text(b, "run", { required: true, re: NAME_RE, what: "任務 id", max: 120 }));
|
|
172
|
+
const answer = flag(b, "answer");
|
|
173
|
+
const followup = text(b, "followup", { what: "追問", max: TEXT_LIMIT });
|
|
174
|
+
if (answer && followup)
|
|
175
|
+
throw new ArgError("followup", "回答問題時不能同時追問。");
|
|
176
|
+
const out = ["resume", "-p", p];
|
|
177
|
+
if (flag(b, "assumeDefaults"))
|
|
178
|
+
out.push("--assume-defaults");
|
|
179
|
+
if (answer)
|
|
180
|
+
out.push("--answer", "--no-edit");
|
|
181
|
+
out.push("--", run);
|
|
182
|
+
if (followup)
|
|
183
|
+
out.push(followup);
|
|
184
|
+
return out;
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
clear: {
|
|
188
|
+
id: "clear",
|
|
189
|
+
label: "刪除任務",
|
|
190
|
+
scope: "project",
|
|
191
|
+
fields: [
|
|
192
|
+
PROJECT_FIELD,
|
|
193
|
+
{ name: "run", label: "任務 id", kind: "text", required: true },
|
|
194
|
+
{ name: "dryRun", label: "只預覽,不刪除", kind: "checkbox" },
|
|
195
|
+
{ name: "keepWorktrees", label: "保留 agent 的 worktree 與分支", kind: "checkbox" },
|
|
196
|
+
],
|
|
197
|
+
mode: always("short"),
|
|
198
|
+
tier: (b) => (b.dryRun === true ? "normal" : "confirm"),
|
|
199
|
+
target: noTarget,
|
|
200
|
+
argv: (b) => {
|
|
201
|
+
const p = project(b);
|
|
202
|
+
const run = need(text(b, "run", { required: true, re: NAME_RE, what: "任務 id", max: 120 }));
|
|
203
|
+
return ["clear", "-p", p, ...(flag(b, "dryRun") ? ["--dry-run"] : []), ...(flag(b, "keepWorktrees") ? ["--keep-worktrees"] : []), "--", run];
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
"clear.lock": {
|
|
207
|
+
id: "clear.lock",
|
|
208
|
+
label: "清除殘留的 run lock",
|
|
209
|
+
scope: "project",
|
|
210
|
+
fields: [PROJECT_FIELD, { name: "run", label: "任務 id(只有一個 lock 時可留空)", kind: "text" }],
|
|
211
|
+
mode: always("short"),
|
|
212
|
+
tier: () => "typed",
|
|
213
|
+
target: (b) => (typeof b.run === "string" && b.run.trim() ? b.run.trim() : String(b.project ?? "")),
|
|
214
|
+
argv: (b) => {
|
|
215
|
+
const p = project(b);
|
|
216
|
+
const run = text(b, "run", { re: NAME_RE, what: "任務 id", max: 120 });
|
|
217
|
+
return ["clear", "-p", p, "--lock", "--force", ...(run ? ["--", run] : [])];
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
doctor: {
|
|
221
|
+
id: "doctor",
|
|
222
|
+
label: "檢查設定",
|
|
223
|
+
scope: "project",
|
|
224
|
+
fields: [PROJECT_FIELD, { name: "resolved", label: "顯示合併後的設定與來源", kind: "checkbox" }],
|
|
225
|
+
mode: always("short"),
|
|
226
|
+
tier: normal,
|
|
227
|
+
target: noTarget,
|
|
228
|
+
argv: (b) => ["doctor", "-p", project(b), ...(flag(b, "resolved") ? ["--resolved"] : [])],
|
|
229
|
+
},
|
|
230
|
+
tidy: {
|
|
231
|
+
id: "tidy",
|
|
232
|
+
label: "整理記憶",
|
|
233
|
+
scope: "project",
|
|
234
|
+
fields: [
|
|
235
|
+
PROJECT_FIELD,
|
|
236
|
+
{ name: "agent", label: "只整理這一位 agent(可留空)", kind: "text" },
|
|
237
|
+
{ name: "layer", label: "層級", kind: "select", options: LAYERS },
|
|
238
|
+
{ name: "dryRun", label: "只預覽,不整理", kind: "checkbox" },
|
|
239
|
+
{ name: "undo", label: "還原某次整理(填時間戳,需指定 agent)", kind: "text" },
|
|
240
|
+
],
|
|
241
|
+
mode: (b) => (b.dryRun === true || (typeof b.undo === "string" && b.undo.trim() !== "") ? "short" : "detached"),
|
|
242
|
+
tier: (b) => (b.dryRun === true ? "normal" : "confirm"),
|
|
243
|
+
target: noTarget,
|
|
244
|
+
argv: (b) => {
|
|
245
|
+
const p = project(b);
|
|
246
|
+
const agent = text(b, "agent", { re: NAME_RE, what: "agent" });
|
|
247
|
+
const layer = oneOf(b, "layer", LAYERS, "層級");
|
|
248
|
+
const dryRun = flag(b, "dryRun");
|
|
249
|
+
const undo = text(b, "undo", { re: NAME_RE, what: "時間戳", max: 64 });
|
|
250
|
+
if (undo !== undefined) {
|
|
251
|
+
if (dryRun)
|
|
252
|
+
throw new ArgError("undo", "還原不能和預覽一起用。");
|
|
253
|
+
if (!agent)
|
|
254
|
+
throw new ArgError("agent", "還原要指定是哪一位 agent。");
|
|
255
|
+
}
|
|
256
|
+
const out = ["tidy", "-p", p];
|
|
257
|
+
if (agent)
|
|
258
|
+
out.push("--agent", agent);
|
|
259
|
+
if (layer)
|
|
260
|
+
out.push("--layer", layer);
|
|
261
|
+
if (dryRun)
|
|
262
|
+
out.push("--dry-run");
|
|
263
|
+
if (undo !== undefined)
|
|
264
|
+
out.push("--undo", undo);
|
|
265
|
+
return out;
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
demo: {
|
|
269
|
+
id: "demo",
|
|
270
|
+
label: "示範",
|
|
271
|
+
scope: "home",
|
|
272
|
+
fields: [
|
|
273
|
+
{ name: "runtime", label: "執行環境(可留空,自動偵測)", kind: "select", options: RUNTIMES },
|
|
274
|
+
{ name: "setupOnly", label: "只建立沙盒,不跑 agent", kind: "checkbox" },
|
|
275
|
+
],
|
|
276
|
+
mode: (b) => (b.setupOnly === true ? "short" : "detached"),
|
|
277
|
+
tier: normal,
|
|
278
|
+
target: noTarget,
|
|
279
|
+
argv: (b) => {
|
|
280
|
+
const runtime = oneOf(b, "runtime", RUNTIMES, "執行環境");
|
|
281
|
+
return ["demo", "-y", ...(runtime ? ["--runtime", runtime] : []), ...(flag(b, "setupOnly") ? ["--setup-only"] : [])];
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
export const COMMAND_IDS = Object.keys(COMMANDS);
|