@oh-my-dsh/auto-team 0.1.0 → 0.1.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/README.md +15 -5
- package/README.zh.md +15 -5
- package/lib/index.js +87 -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.1.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 steers the Lead to call `auto_team_score` again. 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.1.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 重新调用 `auto_team_score`;当前 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,78 @@ 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.`;
|
|
210
|
+
/** Steering text used after the user resets the frozen score. */
|
|
211
|
+
const RESET_STEER_TEXT = `Auto Team: the user reset the score. Call auto_team_score again with the current task's difficulty factors and objective before continuing.`;
|
|
201
212
|
/** System prompt section that states the Lead's auto-team obligations. */
|
|
202
213
|
function policyText(reportingAgentName, leadDeniedTools) {
|
|
203
214
|
return `Auto Team policy
|
|
204
215
|
|
|
205
|
-
You are the Team Lead for a long task.
|
|
216
|
+
You are the Team Lead for a long task. Call auto_team_score before anything else in the first round. The call takes:
|
|
206
217
|
- scope, parallelism, ambiguity, risk, expected_steps: integers from 1 (low) to 5 (high)
|
|
207
218
|
- objective: the task goal in its ordinary, universal meaning
|
|
208
219
|
|
|
209
|
-
The
|
|
220
|
+
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
221
|
|
|
211
222
|
If the decision is solo, continue as a normal single agent.
|
|
212
223
|
|
|
213
224
|
If the decision is team:
|
|
214
|
-
-
|
|
225
|
+
- 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
226
|
- 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
|
|
227
|
+
- 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.
|
|
228
|
+
- 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.
|
|
229
|
+
- Let the goal runtime drive multi-round continuation; follow its rounds.
|
|
230
|
+
- After the workers finish, review the final diff and run the tests in the main checkout.`;
|
|
220
231
|
}
|
|
221
232
|
/** Initial prompt for the dedicated reporting teammate. */
|
|
222
233
|
function reporterPrompt() {
|
|
223
|
-
return `You are the reporting agent for an auto-team task.
|
|
234
|
+
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.
|
|
235
|
+
|
|
236
|
+
Cover what changed, what is blocked, and what the user needs to decide. Address the user directly.
|
|
224
237
|
|
|
225
|
-
|
|
238
|
+
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
239
|
|
|
227
|
-
|
|
240
|
+
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.`;
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/reset-command.ts
|
|
244
|
+
/** Build the user-facing score reset command. */
|
|
245
|
+
function createResetCommand(autoTeam) {
|
|
246
|
+
return {
|
|
247
|
+
name: "auto-team-reset",
|
|
248
|
+
description: "Clear the frozen Auto Team score for this session and ask the Lead to score again.",
|
|
249
|
+
handler: (invocation) => {
|
|
250
|
+
if (autoTeam.decisionOf(invocation.agent) === void 0) return {
|
|
251
|
+
kind: "error",
|
|
252
|
+
text: "No frozen Auto Team score exists in this session."
|
|
253
|
+
};
|
|
254
|
+
autoTeam.reset(invocation.agent);
|
|
255
|
+
invocation.agent.steer(createMessage({
|
|
256
|
+
role: "user",
|
|
257
|
+
content: [{
|
|
258
|
+
type: "text",
|
|
259
|
+
text: RESET_STEER_TEXT
|
|
260
|
+
}],
|
|
261
|
+
source: { kind: "user" }
|
|
262
|
+
}));
|
|
263
|
+
return {
|
|
264
|
+
kind: "success",
|
|
265
|
+
text: "Auto Team score reset. The Lead will score again."
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/** Structural guard for the optional host commands service. */
|
|
271
|
+
function isCommandRuntime(value) {
|
|
272
|
+
if (typeof value !== "object" || value === null || !("register" in value)) return false;
|
|
273
|
+
return typeof value.register === "function";
|
|
228
274
|
}
|
|
229
275
|
//#endregion
|
|
230
276
|
//#region src/auto-team.ts
|
|
231
277
|
/** Host-side auto-team state and operations. */
|
|
232
278
|
var AutoTeam = class {
|
|
233
279
|
records = /* @__PURE__ */ new WeakMap();
|
|
280
|
+
resets = /* @__PURE__ */ new Set();
|
|
234
281
|
deps;
|
|
235
282
|
config;
|
|
236
283
|
constructor(deps, config) {
|
|
@@ -239,22 +286,30 @@ var AutoTeam = class {
|
|
|
239
286
|
}
|
|
240
287
|
/** Whether this agent already has a frozen score. */
|
|
241
288
|
hasScore(agent) {
|
|
242
|
-
return this.records.has(agent);
|
|
289
|
+
return !this.resets.has(agent) && this.records.has(agent);
|
|
243
290
|
}
|
|
244
291
|
/** Seed a record restored from durable storage without scoring again. */
|
|
245
292
|
restore(agent, record) {
|
|
246
|
-
if (!this.records.has(agent)) this.records.set(agent, record);
|
|
293
|
+
if (!this.resets.has(agent) && !this.records.has(agent)) this.records.set(agent, record);
|
|
247
294
|
}
|
|
248
295
|
/** The frozen team decision, when this agent has one. */
|
|
249
296
|
decisionOf(agent) {
|
|
297
|
+
if (this.resets.has(agent)) return;
|
|
250
298
|
return (this.records.get(agent) ?? this.deps.store.read(agent))?.decision;
|
|
251
299
|
}
|
|
300
|
+
/** Clear the frozen score after a user-triggered reset. */
|
|
301
|
+
reset(agent) {
|
|
302
|
+
this.deps.store.reset(agent);
|
|
303
|
+
this.records.delete(agent);
|
|
304
|
+
this.resets.add(agent);
|
|
305
|
+
}
|
|
252
306
|
/**
|
|
253
307
|
* Score one task, freeze the decision, then start or reuse its goal and
|
|
254
308
|
* ensure the reporting teammate.
|
|
255
309
|
*/
|
|
256
310
|
async score(agent, request) {
|
|
257
|
-
|
|
311
|
+
let existing = this.records.get(agent) ?? this.deps.store.read(agent);
|
|
312
|
+
if (this.resets.has(agent)) existing = void 0;
|
|
258
313
|
if (existing !== void 0) {
|
|
259
314
|
this.records.set(agent, existing);
|
|
260
315
|
return await this.finish(agent, existing, request.signal);
|
|
@@ -279,6 +334,7 @@ var AutoTeam = class {
|
|
|
279
334
|
};
|
|
280
335
|
this.deps.store.write(agent, record);
|
|
281
336
|
this.records.set(agent, record);
|
|
337
|
+
this.resets.delete(agent);
|
|
282
338
|
return await this.finish(agent, record, request.signal);
|
|
283
339
|
}
|
|
284
340
|
/** Create the auto-started goal and return the reported action. */
|
|
@@ -359,6 +415,9 @@ function createAutoTeam(ctx, config) {
|
|
|
359
415
|
read: (agent) => ctx.get("sessionProjections")?.stateOf(agent.session, "autoTeam")?.score,
|
|
360
416
|
write: (agent, record) => {
|
|
361
417
|
appendPluginRecord(agent.session, "plugin:auto-team/score", record);
|
|
418
|
+
},
|
|
419
|
+
reset: (agent) => {
|
|
420
|
+
appendPluginRecord(agent.session, "plugin:auto-team/reset", { at: Date.now() });
|
|
362
421
|
}
|
|
363
422
|
}
|
|
364
423
|
}, config);
|
|
@@ -375,7 +434,7 @@ function createAutoTeam(ctx, config) {
|
|
|
375
434
|
function createScoreTool(autoTeam) {
|
|
376
435
|
return defineTool({
|
|
377
436
|
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
|
|
437
|
+
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
438
|
parameters: {
|
|
380
439
|
scope: {
|
|
381
440
|
type: "integer",
|
|
@@ -645,6 +704,7 @@ function apply(ctx, config) {
|
|
|
645
704
|
const installed = /* @__PURE__ */ new Map();
|
|
646
705
|
let warned = false;
|
|
647
706
|
let projectionRegistered = false;
|
|
707
|
+
let resetCommandRegistered = false;
|
|
648
708
|
const ensureProjection = () => {
|
|
649
709
|
if (projectionRegistered) return;
|
|
650
710
|
const registry = ctx.get("sessionProjections");
|
|
@@ -653,6 +713,14 @@ function apply(ctx, config) {
|
|
|
653
713
|
projectionRegistered = true;
|
|
654
714
|
};
|
|
655
715
|
ensureProjection();
|
|
716
|
+
const ensureResetCommand = () => {
|
|
717
|
+
if (resetCommandRegistered) return;
|
|
718
|
+
const commands = ctx.get("commands");
|
|
719
|
+
if (!isCommandRuntime(commands)) return;
|
|
720
|
+
ctx.effect(() => commands.register(createResetCommand(autoTeam)), "auto-team.reset-command()");
|
|
721
|
+
resetCommandRegistered = true;
|
|
722
|
+
};
|
|
723
|
+
ensureResetCommand();
|
|
656
724
|
const install = (agent, source) => {
|
|
657
725
|
if (installed.has(agent)) return;
|
|
658
726
|
ensureProjection();
|
|
@@ -687,8 +755,9 @@ function apply(ctx, config) {
|
|
|
687
755
|
installed.delete(agent);
|
|
688
756
|
});
|
|
689
757
|
ctx.on("internal/service", (name) => {
|
|
690
|
-
if (name !== "agentTeams" && name !== "goals" && name !== "tools" && name !== "systemPrompt" && name !== "sessionProjections") return;
|
|
758
|
+
if (name !== "agentTeams" && name !== "goals" && name !== "tools" && name !== "systemPrompt" && name !== "sessionProjections" && name !== "commands") return;
|
|
691
759
|
ensureProjection();
|
|
760
|
+
ensureResetCommand();
|
|
692
761
|
for (const agent of ctx.get("agents")?.list() ?? []) install(agent);
|
|
693
762
|
});
|
|
694
763
|
ctx.effect(() => () => {
|