@oh-my-dsh/auto-team 0.1.0 → 0.1.2
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 +15 -5
- package/README.zh.md +15 -5
- package/lib/index.js +83 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ The plugin turns the factors into a weighted score from 0 to 1. The model gets o
|
|
|
14
14
|
|
|
15
15
|
The first round must be scored. If the turn tries to close before the tool ran, an `agent/turn-stopping` listener steers the Lead back with a reminder.
|
|
16
16
|
|
|
17
|
-
The score is frozen for the task. It is written to the session log as a `plugin:auto-team/score` record and folded into the host-only `autoTeam` projection, so resuming a session keeps the decision and does not score again.
|
|
17
|
+
The score is frozen for the task. Only a user-triggered `/auto-team-reset` clears it; the next score becomes the new frozen decision. It is written to the session log as a `plugin:auto-team/score` record and folded into the host-only `autoTeam` projection, so resuming a session keeps the decision and does not score again.
|
|
18
18
|
|
|
19
19
|
On a team decision the plugin:
|
|
20
20
|
|
|
21
21
|
- reuses the current goal, or starts one when none exists;
|
|
22
|
-
- ensures a reporting teammate named `reporter`, which is configurable;
|
|
22
|
+
- ensures a user-facing reporting teammate named `reporter`, which is configurable; the Lead relays its updates to the user;
|
|
23
23
|
- tells the Lead to keep the main Git repository and the team, and not to write code;
|
|
24
24
|
- denies the Lead's `write` and `edit` calls by default;
|
|
25
25
|
- requires each execution teammate to complete `create_worktree` before its own `write` or `edit` is allowed, and checks that an edit path stays inside the registered worktree when the host returns one. The reporter is exempt.
|
|
@@ -35,8 +35,9 @@ The profile must compose these host services:
|
|
|
35
35
|
- `agents`, `tools`, `systemPrompt`, `sessionProjections`
|
|
36
36
|
- `agentTeams` from `@deepseek-ai/dsh-experimental-agent-team`
|
|
37
37
|
- `goals` from `@deepseek-ai/dsh-goal`
|
|
38
|
+
- `commands` (optional; enables `/auto-team-reset`)
|
|
38
39
|
|
|
39
|
-
The plugin loads without
|
|
40
|
+
The plugin loads without the required services but logs a warning and installs nothing. When a service arrives later, an `internal/service` listener retries the install. The `commands` service is optional: without it the score tool still works and `/auto-team-reset` is not registered.
|
|
40
41
|
|
|
41
42
|
## Install
|
|
42
43
|
|
|
@@ -59,7 +60,7 @@ dsh plugin --profile <profile> add @oh-my-dsh/auto-team
|
|
|
59
60
|
Or install a locally packed tarball:
|
|
60
61
|
|
|
61
62
|
```sh
|
|
62
|
-
dsh plugin --profile <profile> add ./oh-my-dsh-auto-team-0.1.
|
|
63
|
+
dsh plugin --profile <profile> add ./oh-my-dsh-auto-team-0.1.2.tgz
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
The package name is `@oh-my-dsh/auto-team`, published under the `@oh-my-dsh` scope.
|
|
@@ -97,6 +98,15 @@ The package adds one model-facing tool.
|
|
|
97
98
|
|
|
98
99
|
It returns `{ decision, goal, reporter? }`. The numeric score and threshold are not in the result. The host's Agent Teams tools handle spawning, messaging, and the shared task board. The host goal lifecycle handles completion and continuation.
|
|
99
100
|
|
|
101
|
+
## Commands
|
|
102
|
+
|
|
103
|
+
When the profile provides the host `commands` service, the plugin registers `auto-team-reset`:
|
|
104
|
+
|
|
105
|
+
- `/auto-team-reset` clears the frozen score for the current session.
|
|
106
|
+
- It appends a `plugin:auto-team/reset` record, so resuming the session does not restore the cleared score.
|
|
107
|
+
- It is silent by default. Any text after the command is sent to the Lead as a user message; use `/auto-team-reset call auto_team_score again` when you want the Lead to re-score. The current goal and reporter stay in place.
|
|
108
|
+
- The command is user-triggered; the model cannot invoke it.
|
|
109
|
+
|
|
100
110
|
## Guards and limits
|
|
101
111
|
|
|
102
112
|
- The Lead gate is a tool-name policy, not a sandbox. `pwsh`, `run_code`, and direct filesystem effects can bypass it. The policy tells the Lead not to use them as a workaround.
|
|
@@ -114,7 +124,7 @@ pnpm run build
|
|
|
114
124
|
pnpm pack --dry-run --json
|
|
115
125
|
```
|
|
116
126
|
|
|
117
|
-
The tests cover the scoring policy, configuration, goal and reporter orchestration, the durable score projection, the runtime install path, and the Loader export shape.
|
|
127
|
+
The tests cover the scoring policy, configuration, goal and reporter orchestration, the durable score projection and reset, the reset command, the runtime install path, and the Loader export shape.
|
|
118
128
|
|
|
119
129
|
Read [the design note](docs/auto-team-design.md) for the behavior and the flow chart, and [the plugin contracts](docs/dsh-plugin-contracts.md) for the package rules.
|
|
120
130
|
|
package/README.zh.md
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
首轮必须打分。如果这一轮想在没有调用工具时结束,`agent/turn-stopping` 监听器会把 Lead 拉回来,再发一次提醒。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
分数在任务内冻结。只有用户主动执行 `/auto-team-reset` 才能清空;下一次打分成为新的冻结决定。它以 `plugin:auto-team/score` 记录写进 session log,并折进宿主侧的 `autoTeam` 投影。resume 时恢复这个决定,不会重新打分。
|
|
18
18
|
|
|
19
19
|
决定使用团队后,插件会:
|
|
20
20
|
|
|
21
21
|
- 复用当前 goal;没有 goal 就启动一个;
|
|
22
|
-
- 确保存在名为 `reporter` 的汇报 Agent
|
|
22
|
+
- 确保存在名为 `reporter` 的汇报 Agent,名字可配置;它面向用户写更新,Lead 负责转达;
|
|
23
23
|
- 提示 Lead 维护主 Git 仓库和团队,不写代码;
|
|
24
24
|
- 默认拒绝 Lead 的 `write` 和 `edit`;
|
|
25
25
|
- 要求每个执行 Agent 先成功调用 `create_worktree`,之后才允许自己的 `write` 或 `edit`;宿主返回 worktree 路径时,还会检查编辑路径是否在该 worktree 内。汇报 Agent 不受这条限制。
|
|
@@ -35,8 +35,9 @@ profile 需要组合这些宿主服务:
|
|
|
35
35
|
- `agents`、`tools`、`systemPrompt`、`sessionProjections`
|
|
36
36
|
- `agentTeams`,来自 `@deepseek-ai/dsh-experimental-agent-team`
|
|
37
37
|
- `goals`,来自 `@deepseek-ai/dsh-goal`
|
|
38
|
+
- `commands`(可选;启用 `/auto-team-reset`)
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
必需服务缺失时插件仍会加载,但只打一条警告,不安装任何东西。之后某个服务到位,`internal/service` 监听器会重试安装。`commands` 服务是可选的:没有它,打分工具照常工作,但不会注册 `/auto-team-reset`。
|
|
40
41
|
|
|
41
42
|
## 安装
|
|
42
43
|
|
|
@@ -59,7 +60,7 @@ dsh plugin --profile <profile> add @oh-my-dsh/auto-team
|
|
|
59
60
|
或者安装本地打包的 tarball:
|
|
60
61
|
|
|
61
62
|
```sh
|
|
62
|
-
dsh plugin --profile <profile> add ./oh-my-dsh-auto-team-0.1.
|
|
63
|
+
dsh plugin --profile <profile> add ./oh-my-dsh-auto-team-0.1.2.tgz
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
包名是 `@oh-my-dsh/auto-team`,发布在 `@oh-my-dsh` scope 下。
|
|
@@ -97,6 +98,15 @@ dsh plugin --profile <profile> add ./oh-my-dsh-auto-team-0.1.0.tgz
|
|
|
97
98
|
|
|
98
99
|
返回 `{ decision, goal, reporter? }`。分数和阈值不在返回里。创建队友、发消息和共享任务板由宿主的 Agent Teams 工具负责;完成和续跑由宿主的 goal 生命周期负责。
|
|
99
100
|
|
|
101
|
+
## 命令
|
|
102
|
+
|
|
103
|
+
profile 提供宿主 `commands` 服务时,插件注册 `auto-team-reset`:
|
|
104
|
+
|
|
105
|
+
- `/auto-team-reset` 清空当前 session 的冻结分数。
|
|
106
|
+
- 它写入 `plugin:auto-team/reset` 记录,resume 时不会恢复被清掉的分数。
|
|
107
|
+
- 它默认静默,不发送消息;命令后附带的文字会作为用户消息发给 Lead。想让 Lead 重新打分就写 `/auto-team-reset call auto_team_score again`。当前 goal 和汇报 Agent 保留。
|
|
108
|
+
- 命令由用户触发,模型不能调用。
|
|
109
|
+
|
|
100
110
|
## 闸门与限制
|
|
101
111
|
|
|
102
112
|
- Lead 的闸门是工具名策略,不是沙箱。`pwsh`、`run_code` 和直接的文件系统操作可以绕过。策略文本会明确要求 Lead 不要拿它们绕路。
|
|
@@ -114,7 +124,7 @@ pnpm run build
|
|
|
114
124
|
pnpm pack --dry-run --json
|
|
115
125
|
```
|
|
116
126
|
|
|
117
|
-
测试覆盖评分策略、配置、goal 与汇报 Agent
|
|
127
|
+
测试覆盖评分策略、配置、goal 与汇报 Agent 编排、持久化分数投影与重设、重设命令、运行时安装路径,以及 Loader 导出形状。
|
|
118
128
|
|
|
119
129
|
行为说明和流程图见[设计文档](docs/auto-team-design.md),包规则见[插件契约](docs/dsh-plugin-contracts.md)。
|
|
120
130
|
|
package/lib/index.js
CHANGED
|
@@ -151,6 +151,7 @@ function resolveConfig(config = {}) {
|
|
|
151
151
|
//#endregion
|
|
152
152
|
//#region src/projection.ts
|
|
153
153
|
const SCORE_RECORD_TYPE = "plugin:auto-team/score";
|
|
154
|
+
const RESET_RECORD_TYPE = "plugin:auto-team/reset";
|
|
154
155
|
const scoreRecordSchema = z.object({
|
|
155
156
|
score: z.number().min(0).max(1),
|
|
156
157
|
threshold: z.number().min(0).max(1),
|
|
@@ -166,10 +167,18 @@ const autoTeamProjectionStateSchema = z.object({
|
|
|
166
167
|
score: scoreRecordSchema.optional(),
|
|
167
168
|
failure: z.string().optional()
|
|
168
169
|
});
|
|
169
|
-
/** Fold
|
|
170
|
+
/** Fold the first score after the latest reset into one durable decision. */
|
|
170
171
|
function applyAutoTeamProjection(state, event) {
|
|
171
172
|
const record = pluginRecordOf(event);
|
|
172
|
-
if (record === void 0
|
|
173
|
+
if (record === void 0) return state;
|
|
174
|
+
if (record.type === RESET_RECORD_TYPE) {
|
|
175
|
+
if (state.score === void 0) return state;
|
|
176
|
+
return {
|
|
177
|
+
...state,
|
|
178
|
+
score: void 0
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (record.type !== SCORE_RECORD_TYPE) return state;
|
|
173
182
|
if (state.score !== void 0) return state;
|
|
174
183
|
const parsed = scoreRecordSchema.safeParse(record.data);
|
|
175
184
|
if (!parsed.success) return {
|
|
@@ -197,40 +206,74 @@ const autoTeamProjectionDefinition = {
|
|
|
197
206
|
* @module @oh-my-dsh/auto-team/prompt
|
|
198
207
|
*/
|
|
199
208
|
/** First-round steering text used when the scoring tool has not run yet. */
|
|
200
|
-
const FIRST_ROUND_STEER_TEXT = `Auto Team:
|
|
209
|
+
const FIRST_ROUND_STEER_TEXT = `Auto Team: the first round has no score yet. Call auto_team_score now with the five difficulty factors and the task's universal-semantic objective; the turn stays open until the decision is recorded.`;
|
|
201
210
|
/** System prompt section that states the Lead's auto-team obligations. */
|
|
202
211
|
function policyText(reportingAgentName, leadDeniedTools) {
|
|
203
212
|
return `Auto Team policy
|
|
204
213
|
|
|
205
|
-
You are the Team Lead for a long task.
|
|
214
|
+
You are the Team Lead for a long task. Call auto_team_score before anything else in the first round. The call takes:
|
|
206
215
|
- scope, parallelism, ambiguity, risk, expected_steps: integers from 1 (low) to 5 (high)
|
|
207
216
|
- objective: the task goal in its ordinary, universal meaning
|
|
208
217
|
|
|
209
|
-
The
|
|
218
|
+
The first turn stays open until the tool records a decision. The result carries the team or solo decision and the goal and reporter status. The numeric score and threshold stay host-side; treat them as unavailable and act on the returned decision.
|
|
210
219
|
|
|
211
220
|
If the decision is solo, continue as a normal single agent.
|
|
212
221
|
|
|
213
222
|
If the decision is team:
|
|
214
|
-
-
|
|
223
|
+
- Your role is the Main Git repository and the team. Code changes belong to execution agents. The Lead's ${leadDeniedTools.join(", ")} calls are denied in Team mode. Treat that gate as a policy check: use pwsh, run_code, and other tools for review, tests, and inspection only.
|
|
215
224
|
- The plugin starts or reuses the goal and ensures a reporting agent named "${reportingAgentName}".
|
|
216
|
-
-
|
|
217
|
-
- Create shared tasks with disjoint write scopes, then spawn execution agents. Each execution agent
|
|
218
|
-
-
|
|
219
|
-
- After the workers finish, review the final diff and run the tests in the
|
|
225
|
+
- The reporter writes for the user. Relay each update to the user as a user-facing message, and keep execution moving while details are resolved.
|
|
226
|
+
- Create shared tasks with disjoint write scopes, then spawn execution agents. Each execution agent creates its own worktree for its task before editing; the Lead works in the main checkout.
|
|
227
|
+
- Let the goal runtime drive multi-round continuation; follow its rounds.
|
|
228
|
+
- After the workers finish, review the final diff and run the tests in the main checkout.`;
|
|
220
229
|
}
|
|
221
230
|
/** Initial prompt for the dedicated reporting teammate. */
|
|
222
231
|
function reporterPrompt() {
|
|
223
|
-
return `You are the reporting agent for an auto-team task.
|
|
232
|
+
return `You are the reporting agent for an auto-team task. Your reader is the user. The Lead relays each update to the user, so write every message as a user-facing status update in the user's language.
|
|
233
|
+
|
|
234
|
+
Cover what changed, what is blocked, and what the user needs to decide. Address the user directly.
|
|
224
235
|
|
|
225
|
-
|
|
236
|
+
Observe the roster and task board with list_agents and team_task_list. Hand each update to the Lead for relay with send_message({ target: "lead", message: "..." }). The Lead is the transport; the user is the reader.
|
|
226
237
|
|
|
227
|
-
|
|
238
|
+
Handle user-facing detail questions sent through the Lead. Record unresolved details, report the open question to the user, and keep execution moving. Your work is status, questions, and coordination; code changes belong to execution agents.`;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/reset-command.ts
|
|
242
|
+
/** Build the user-facing score reset command. */
|
|
243
|
+
function createResetCommand(autoTeam) {
|
|
244
|
+
return {
|
|
245
|
+
name: "auto-team-reset",
|
|
246
|
+
description: "Clear the frozen Auto Team score for this session.",
|
|
247
|
+
handler: (invocation) => {
|
|
248
|
+
if (autoTeam.decisionOf(invocation.agent) === void 0) return {
|
|
249
|
+
kind: "error",
|
|
250
|
+
text: "No frozen Auto Team score exists in this session."
|
|
251
|
+
};
|
|
252
|
+
autoTeam.reset(invocation.agent);
|
|
253
|
+
const message = invocation.rawInput.trim();
|
|
254
|
+
if (message.length > 0) invocation.agent.steer(createMessage({
|
|
255
|
+
role: "user",
|
|
256
|
+
content: [{
|
|
257
|
+
type: "text",
|
|
258
|
+
text: message
|
|
259
|
+
}],
|
|
260
|
+
source: { kind: "user" }
|
|
261
|
+
}));
|
|
262
|
+
return { kind: "success" };
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/** Structural guard for the optional host commands service. */
|
|
267
|
+
function isCommandRuntime(value) {
|
|
268
|
+
if (typeof value !== "object" || value === null || !("register" in value)) return false;
|
|
269
|
+
return typeof value.register === "function";
|
|
228
270
|
}
|
|
229
271
|
//#endregion
|
|
230
272
|
//#region src/auto-team.ts
|
|
231
273
|
/** Host-side auto-team state and operations. */
|
|
232
274
|
var AutoTeam = class {
|
|
233
275
|
records = /* @__PURE__ */ new WeakMap();
|
|
276
|
+
resets = /* @__PURE__ */ new Set();
|
|
234
277
|
deps;
|
|
235
278
|
config;
|
|
236
279
|
constructor(deps, config) {
|
|
@@ -239,22 +282,30 @@ var AutoTeam = class {
|
|
|
239
282
|
}
|
|
240
283
|
/** Whether this agent already has a frozen score. */
|
|
241
284
|
hasScore(agent) {
|
|
242
|
-
return this.records.has(agent);
|
|
285
|
+
return !this.resets.has(agent) && this.records.has(agent);
|
|
243
286
|
}
|
|
244
287
|
/** Seed a record restored from durable storage without scoring again. */
|
|
245
288
|
restore(agent, record) {
|
|
246
|
-
if (!this.records.has(agent)) this.records.set(agent, record);
|
|
289
|
+
if (!this.resets.has(agent) && !this.records.has(agent)) this.records.set(agent, record);
|
|
247
290
|
}
|
|
248
291
|
/** The frozen team decision, when this agent has one. */
|
|
249
292
|
decisionOf(agent) {
|
|
293
|
+
if (this.resets.has(agent)) return;
|
|
250
294
|
return (this.records.get(agent) ?? this.deps.store.read(agent))?.decision;
|
|
251
295
|
}
|
|
296
|
+
/** Clear the frozen score after a user-triggered reset. */
|
|
297
|
+
reset(agent) {
|
|
298
|
+
this.deps.store.reset(agent);
|
|
299
|
+
this.records.delete(agent);
|
|
300
|
+
this.resets.add(agent);
|
|
301
|
+
}
|
|
252
302
|
/**
|
|
253
303
|
* Score one task, freeze the decision, then start or reuse its goal and
|
|
254
304
|
* ensure the reporting teammate.
|
|
255
305
|
*/
|
|
256
306
|
async score(agent, request) {
|
|
257
|
-
|
|
307
|
+
let existing = this.records.get(agent) ?? this.deps.store.read(agent);
|
|
308
|
+
if (this.resets.has(agent)) existing = void 0;
|
|
258
309
|
if (existing !== void 0) {
|
|
259
310
|
this.records.set(agent, existing);
|
|
260
311
|
return await this.finish(agent, existing, request.signal);
|
|
@@ -279,6 +330,7 @@ var AutoTeam = class {
|
|
|
279
330
|
};
|
|
280
331
|
this.deps.store.write(agent, record);
|
|
281
332
|
this.records.set(agent, record);
|
|
333
|
+
this.resets.delete(agent);
|
|
282
334
|
return await this.finish(agent, record, request.signal);
|
|
283
335
|
}
|
|
284
336
|
/** Create the auto-started goal and return the reported action. */
|
|
@@ -359,6 +411,9 @@ function createAutoTeam(ctx, config) {
|
|
|
359
411
|
read: (agent) => ctx.get("sessionProjections")?.stateOf(agent.session, "autoTeam")?.score,
|
|
360
412
|
write: (agent, record) => {
|
|
361
413
|
appendPluginRecord(agent.session, "plugin:auto-team/score", record);
|
|
414
|
+
},
|
|
415
|
+
reset: (agent) => {
|
|
416
|
+
appendPluginRecord(agent.session, "plugin:auto-team/reset", { at: Date.now() });
|
|
362
417
|
}
|
|
363
418
|
}
|
|
364
419
|
}, config);
|
|
@@ -375,7 +430,7 @@ function createAutoTeam(ctx, config) {
|
|
|
375
430
|
function createScoreTool(autoTeam) {
|
|
376
431
|
return defineTool({
|
|
377
432
|
name: "auto_team_score",
|
|
378
|
-
description: "Record the first-round difficulty assessment and return the team or solo decision. Call once before any other action
|
|
433
|
+
description: "Record the first-round difficulty assessment and return the team or solo decision. Call once before any other action; the decision is frozen for the task.",
|
|
379
434
|
parameters: {
|
|
380
435
|
scope: {
|
|
381
436
|
type: "integer",
|
|
@@ -645,6 +700,7 @@ function apply(ctx, config) {
|
|
|
645
700
|
const installed = /* @__PURE__ */ new Map();
|
|
646
701
|
let warned = false;
|
|
647
702
|
let projectionRegistered = false;
|
|
703
|
+
let resetCommandRegistered = false;
|
|
648
704
|
const ensureProjection = () => {
|
|
649
705
|
if (projectionRegistered) return;
|
|
650
706
|
const registry = ctx.get("sessionProjections");
|
|
@@ -653,6 +709,14 @@ function apply(ctx, config) {
|
|
|
653
709
|
projectionRegistered = true;
|
|
654
710
|
};
|
|
655
711
|
ensureProjection();
|
|
712
|
+
const ensureResetCommand = () => {
|
|
713
|
+
if (resetCommandRegistered) return;
|
|
714
|
+
const commands = ctx.get("commands");
|
|
715
|
+
if (!isCommandRuntime(commands)) return;
|
|
716
|
+
ctx.effect(() => commands.register(createResetCommand(autoTeam)), "auto-team.reset-command()");
|
|
717
|
+
resetCommandRegistered = true;
|
|
718
|
+
};
|
|
719
|
+
ensureResetCommand();
|
|
656
720
|
const install = (agent, source) => {
|
|
657
721
|
if (installed.has(agent)) return;
|
|
658
722
|
ensureProjection();
|
|
@@ -687,8 +751,9 @@ function apply(ctx, config) {
|
|
|
687
751
|
installed.delete(agent);
|
|
688
752
|
});
|
|
689
753
|
ctx.on("internal/service", (name) => {
|
|
690
|
-
if (name !== "agentTeams" && name !== "goals" && name !== "tools" && name !== "systemPrompt" && name !== "sessionProjections") return;
|
|
754
|
+
if (name !== "agentTeams" && name !== "goals" && name !== "tools" && name !== "systemPrompt" && name !== "sessionProjections" && name !== "commands") return;
|
|
691
755
|
ensureProjection();
|
|
756
|
+
ensureResetCommand();
|
|
692
757
|
for (const agent of ctx.get("agents")?.list() ?? []) install(agent);
|
|
693
758
|
});
|
|
694
759
|
ctx.effect(() => () => {
|