@oyasmi/pipiclaw 0.8.9-beta.2 → 0.8.9
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 +6 -4
- package/dist/agent/channel-runner.d.ts +6 -0
- package/dist/agent/channel-runner.js +27 -2
- package/dist/agent/command-extension.d.ts +3 -0
- package/dist/agent/command-extension.js +37 -0
- package/dist/agent/commands.js +6 -0
- package/dist/agent/prompt/sections.js +3 -3
- package/dist/paths.d.ts +0 -1
- package/dist/paths.js +0 -11
- package/dist/playbooks/runtime-orientation.md +1 -1
- package/dist/playbooks/task-delegation.md +2 -2
- package/dist/runtime/store.d.ts +1 -1
- package/dist/settings.d.ts +5 -4
- package/dist/settings.js +1 -1
- package/dist/subagents/discovery.d.ts +1 -1
- package/dist/subagents/discovery.js +10 -36
- package/dist/subagents/tool.d.ts +1 -1
- package/dist/subagents/tool.js +4 -4
- package/examples/sub-agents/README.md +26 -0
- package/examples/sub-agents/explorer.md +41 -0
- package/examples/sub-agents/git-committer.md +63 -0
- package/examples/sub-agents/researcher.md +41 -0
- package/examples/sub-agents/reviewer.md +53 -0
- package/examples/sub-agents/verifier.md +49 -0
- package/package.json +2 -1
- package/dist/subagents/builtin/explorer.md +0 -16
- package/dist/subagents/builtin/researcher.md +0 -17
- package/dist/subagents/builtin/verifier.md +0 -17
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm package: [`@oyasmi/pipiclaw`](https://www.npmjs.com/package/@oyasmi/pipiclaw
|
|
|
16
16
|
|
|
17
17
|
**自己推进长程工作。** 定时事件支持立即、单次、周期三类,`preAction` 可用脚本做零 token 的触发前门控。语义更高一层的是任务台账(task ledger):任务以 Markdown 文件持久存在,内建 task driver 到点自动恢复、有进展有界续跑、停滞自动退避;配套受预算约束的恢复、独立验收、外部副作用授权,以及 `/tasks` 系列零 LLM 成本的控制面命令。
|
|
18
18
|
|
|
19
|
-
**会用工具、能委派。** 内建 `bash`(支持 `async` 后台作业)、`read`(含目录树与 PDF)、`write` / `edit`、结构化 `grep`、`web_search` / `web_fetch`(结果缓存与分页续读),以及 `send_media
|
|
19
|
+
**会用工具、能委派。** 内建 `bash`(支持 `async` 后台作业)、`read`(含目录树与 PDF)、`write` / `edit`、结构化 `grep`、`web_search` / `web_fetch`(结果缓存与分页续读),以及 `send_media`——生成好的报表、截图、导出文件可以作为原生附件直接发回钉钉,而不是丢给你一个打不开的主机路径。工作区配置的子代理可以把 reviewer、researcher 这类角色沉淀成可复用能力,支持 worktree 隔离与独立验收(verify);workspace skills 沉淀你自己的流程知识。完整清单见 [docs/tools.md](./docs/tools.md)。
|
|
20
20
|
|
|
21
21
|
**有安全护栏。** 所有文件、命令、网络工具都经过安全守卫:`bash` 命令拦截、统一路径检查、常见凭据与敏感位置默认拒绝、阻断写入审计日志;可通过 `security.json` 做实例级策略调整。详见 [docs/security.md](./docs/security.md)。
|
|
22
22
|
|
|
@@ -140,7 +140,8 @@ export ANTHROPIC_API_KEY=sk-ant-...
|
|
|
140
140
|
```json
|
|
141
141
|
{
|
|
142
142
|
"defaultProvider": "my-gateway",
|
|
143
|
-
"defaultModel": "gpt-4.1"
|
|
143
|
+
"defaultModel": "gpt-4.1",
|
|
144
|
+
"defaultThinkingLevel": "medium"
|
|
144
145
|
}
|
|
145
146
|
```
|
|
146
147
|
|
|
@@ -222,10 +223,11 @@ pipiclaw
|
|
|
222
223
|
| `/compact [instructions]` | 手动压缩当前会话上下文 |
|
|
223
224
|
| `/session` | 当前会话状态、消息统计、token 使用量 |
|
|
224
225
|
| `/model [引用]` | 查看或切换模型 |
|
|
226
|
+
| `/thinking [level\|cycle]` | 查看、设置或轮换当前会话的 thinking level(默认 `medium`,按模型能力自动 clamp) |
|
|
225
227
|
|
|
226
228
|
说明:
|
|
227
229
|
|
|
228
|
-
- 前九条由传输层直接处理,**忙碌时也可用**(`/context` 是只读统计,零 LLM
|
|
230
|
+
- 前九条由传输层直接处理,**忙碌时也可用**(`/context` 是只读统计,零 LLM 成本);后五条会话命令仅空闲时可用(忙碌时会收到提示)。
|
|
229
231
|
- 忙碌时的普通消息默认等价于 `/steer`,可通过 `channel.json` 的 `busyMessageDefault` 改为排队(`followUp`)。
|
|
230
232
|
- 未知的斜杠命令会被直接拒绝并提示 `/help`,不会作为普通消息发给模型(避免 `/modle` 这类笔误变成一整轮 LLM 调用)。workspace skill 也可作为命令调用(`/skill:<名称>`)。
|
|
231
233
|
- `/model` 依次尝试精确 `provider/modelId`、精确 `modelId`、对完整引用的子串匹配,只有唯一命中时才切换,例如 `/model turbo`。
|
|
@@ -242,7 +244,7 @@ pipiclaw
|
|
|
242
244
|
| [docs/memory.md](./docs/memory.md) | 记忆分层:它记得什么、怎么让它记住或忘掉 |
|
|
243
245
|
| [docs/configuration.md](./docs/configuration.md) | 全部配置项:钉钉、模型、settings、tools、TUI、记忆与工作区文件 |
|
|
244
246
|
| [docs/events-and-tasks.md](./docs/events-and-tasks.md) | 定时事件(含 `preAction` 门控、`event_manage`)、任务台账、内建 task driver、`/tasks` 控制面与 `task_manage` 工具 |
|
|
245
|
-
| [docs/sub-agents.md](./docs/sub-agents.md) |
|
|
247
|
+
| [docs/sub-agents.md](./docs/sub-agents.md) | 工作区配置子代理:委派、隔离 worktree 与独立验收 |
|
|
246
248
|
| [docs/security.md](./docs/security.md) | 默认安全策略、`security.json` 配置与已知边界 |
|
|
247
249
|
| [docs/deployment-and-operations.md](./docs/deployment-and-operations.md) | 长期运行、日志、可观测性、升级、备份与排障 |
|
|
248
250
|
| [docs/scaling-and-concurrency.md](./docs/scaling-and-concurrency.md) | 并发模型与容量边界 |
|
|
@@ -134,6 +134,12 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
134
134
|
private createResourceLoader;
|
|
135
135
|
private createAgentSessionServices;
|
|
136
136
|
private createEmptyExtensionsResult;
|
|
137
|
+
/**
|
|
138
|
+
* Resolve the initial thinking level using the same precedence as pi's SDK:
|
|
139
|
+
* session history, configured default, then medium. The effective value is
|
|
140
|
+
* clamped to the selected model before the session starts.
|
|
141
|
+
*/
|
|
142
|
+
private initializeThinkingLevel;
|
|
137
143
|
private createSessionRuntime;
|
|
138
144
|
private buildRuntimeTools;
|
|
139
145
|
private rebuildSessionTools;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Agent } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { clampThinkingLevel } from "@earendil-works/pi-ai/compat";
|
|
2
3
|
import { AgentSession, AgentSessionRuntime, convertToLlm, createExtensionRuntime, DefaultResourceLoader, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
3
4
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
4
5
|
import { dirname, join, resolve } from "path";
|
|
@@ -52,6 +53,7 @@ function getFinalOutcomeText(outcome) {
|
|
|
52
53
|
function asSdkSettingsManager(manager) {
|
|
53
54
|
return manager;
|
|
54
55
|
}
|
|
56
|
+
const DEFAULT_MAIN_THINKING_LEVEL = "medium";
|
|
55
57
|
export class ChannelRunner {
|
|
56
58
|
constructor(channelId, channelDir, paths) {
|
|
57
59
|
this.ledger = getUsageLedger();
|
|
@@ -96,7 +98,7 @@ export class ChannelRunner {
|
|
|
96
98
|
initialState: {
|
|
97
99
|
systemPrompt: "",
|
|
98
100
|
model: this.activeModel,
|
|
99
|
-
thinkingLevel:
|
|
101
|
+
thinkingLevel: DEFAULT_MAIN_THINKING_LEVEL,
|
|
100
102
|
tools: initialTools,
|
|
101
103
|
},
|
|
102
104
|
convertToLlm,
|
|
@@ -735,6 +737,7 @@ export class ChannelRunner {
|
|
|
735
737
|
// Resolve model: prefer saved global default, fall back to first available model.
|
|
736
738
|
this.activeModel = resolveInitialModel(this.modelRegistry, this.settingsManager);
|
|
737
739
|
this.agent.state.model = this.activeModel; // correct the placeholder default
|
|
740
|
+
this.initializeThinkingLevel(this.agent, this.activeModel, this.sessionManager);
|
|
738
741
|
log.logInfo(`Using model: ${this.activeModel.provider}/${this.activeModel.id} (${this.activeModel.name})`);
|
|
739
742
|
this.subAgentDiscovery = await this.refreshSubAgentDiscovery();
|
|
740
743
|
const initialResourceLoader = this.createResourceLoader();
|
|
@@ -908,6 +911,9 @@ export class ChannelRunner {
|
|
|
908
911
|
},
|
|
909
912
|
getSessionStats: () => this.session.getSessionStats(),
|
|
910
913
|
getThinkingLevel: () => this.session.thinkingLevel,
|
|
914
|
+
getAvailableThinkingLevels: () => this.session.getAvailableThinkingLevels(),
|
|
915
|
+
setThinkingLevel: (level) => this.session.setThinkingLevel(level),
|
|
916
|
+
cycleThinkingLevel: () => this.session.cycleThinkingLevel(),
|
|
911
917
|
getLastResponseModel: () => getLastAssistantUsage(this.session.messages)?.responseModel,
|
|
912
918
|
switchModel: async (model) => {
|
|
913
919
|
await this.session.setModel(model);
|
|
@@ -956,18 +962,37 @@ export class ChannelRunner {
|
|
|
956
962
|
runtime: createExtensionRuntime(),
|
|
957
963
|
};
|
|
958
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* Resolve the initial thinking level using the same precedence as pi's SDK:
|
|
967
|
+
* session history, configured default, then medium. The effective value is
|
|
968
|
+
* clamped to the selected model before the session starts.
|
|
969
|
+
*/
|
|
970
|
+
initializeThinkingLevel(agent, model, sessionManager) {
|
|
971
|
+
const branch = sessionManager.getBranch();
|
|
972
|
+
const hasThinkingEntry = branch.some((entry) => entry.type === "thinking_level_change");
|
|
973
|
+
const sessionThinkingLevel = sessionManager.buildSessionContext().thinkingLevel;
|
|
974
|
+
const requestedLevel = hasThinkingEntry
|
|
975
|
+
? sessionThinkingLevel
|
|
976
|
+
: (this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_MAIN_THINKING_LEVEL);
|
|
977
|
+
const effectiveLevel = clampThinkingLevel(model, requestedLevel);
|
|
978
|
+
agent.state.thinkingLevel = effectiveLevel;
|
|
979
|
+
if (!hasThinkingEntry) {
|
|
980
|
+
sessionManager.appendThinkingLevelChange(effectiveLevel);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
959
983
|
createSessionRuntime(sessionManager, sessionStartEvent) {
|
|
960
984
|
const tools = this.buildRuntimeTools();
|
|
961
985
|
const agent = new Agent({
|
|
962
986
|
initialState: {
|
|
963
987
|
systemPrompt: "",
|
|
964
988
|
model: this.activeModel,
|
|
965
|
-
thinkingLevel:
|
|
989
|
+
thinkingLevel: DEFAULT_MAIN_THINKING_LEVEL,
|
|
966
990
|
tools,
|
|
967
991
|
},
|
|
968
992
|
convertToLlm,
|
|
969
993
|
getApiKey: async () => getApiKeyForModel(this.modelRegistry, this.activeModel),
|
|
970
994
|
});
|
|
995
|
+
this.initializeThinkingLevel(agent, this.activeModel, sessionManager);
|
|
971
996
|
const resourceLoader = this.createResourceLoader();
|
|
972
997
|
const session = new AgentSession({
|
|
973
998
|
agent,
|
|
@@ -7,6 +7,9 @@ export interface PipiclawCommandExtensionOptions {
|
|
|
7
7
|
getAvailableModels: () => Promise<Model<Api>[]>;
|
|
8
8
|
getSessionStats: () => SessionStats;
|
|
9
9
|
getThinkingLevel: () => ThinkingLevel;
|
|
10
|
+
getAvailableThinkingLevels: () => ThinkingLevel[];
|
|
11
|
+
setThinkingLevel: (level: ThinkingLevel) => void;
|
|
12
|
+
cycleThinkingLevel: () => ThinkingLevel | undefined;
|
|
10
13
|
getLastResponseModel?: () => string | undefined;
|
|
11
14
|
switchModel: (model: Model<Api>) => Promise<void>;
|
|
12
15
|
refreshSessionResources: () => Promise<void>;
|
|
@@ -39,6 +39,14 @@ function sendCommandResult(sender, text) {
|
|
|
39
39
|
display: true,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
+
function buildThinkingText(current, available) {
|
|
43
|
+
return `# Thinking
|
|
44
|
+
|
|
45
|
+
Current level: \`${current}\`
|
|
46
|
+
Available levels: ${available.map((level) => `\`${level}\``).join(", ")}
|
|
47
|
+
|
|
48
|
+
Use \`/thinking <level>\` to set a level, or \`/thinking cycle\` to select the next supported level.`;
|
|
49
|
+
}
|
|
42
50
|
export function createCommandExtension(options) {
|
|
43
51
|
return (pi) => {
|
|
44
52
|
pi.registerCommand("memory", {
|
|
@@ -53,6 +61,35 @@ export function createCommandExtension(options) {
|
|
|
53
61
|
sendCommandResult(pi, buildSessionText(options.getSessionStats(), options.getCurrentModel(), options.getThinkingLevel(), options.getLastResponseModel?.()));
|
|
54
62
|
},
|
|
55
63
|
});
|
|
64
|
+
pi.registerCommand("thinking", {
|
|
65
|
+
description: sessionCommandDescription("thinking"),
|
|
66
|
+
handler: async (args) => {
|
|
67
|
+
const available = options.getAvailableThinkingLevels();
|
|
68
|
+
const normalized = args.trim().toLowerCase();
|
|
69
|
+
if (!normalized) {
|
|
70
|
+
sendCommandResult(pi, buildThinkingText(options.getThinkingLevel(), available));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (normalized === "cycle") {
|
|
74
|
+
const next = options.cycleThinkingLevel();
|
|
75
|
+
if (!next) {
|
|
76
|
+
sendCommandResult(pi, "当前模型不支持 thinking/reasoning。");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
sendCommandResult(pi, `Thinking level 已切换为 \`${next}\`。`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!available.includes(normalized)) {
|
|
83
|
+
sendCommandResult(pi, `不支持 thinking level \`${args.trim()}\`。当前模型可用值:${available
|
|
84
|
+
.map((level) => `\`${level}\``)
|
|
85
|
+
.join(", ")}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const level = normalized;
|
|
89
|
+
options.setThinkingLevel(level);
|
|
90
|
+
sendCommandResult(pi, `Thinking level 已设置为 \`${level}\`。`);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
56
93
|
pi.registerCommand("model", {
|
|
57
94
|
description: sessionCommandDescription("model"),
|
|
58
95
|
handler: async (args) => {
|
package/dist/agent/commands.js
CHANGED
|
@@ -98,6 +98,12 @@ export const SESSION_COMMANDS = [
|
|
|
98
98
|
description: "Show current session state, message stats, token usage, and model info",
|
|
99
99
|
examples: ["/session"],
|
|
100
100
|
},
|
|
101
|
+
{
|
|
102
|
+
name: "thinking",
|
|
103
|
+
argumentHint: "[off|minimal|low|medium|high|xhigh|max|cycle]",
|
|
104
|
+
description: "Show or change the thinking level for the current model",
|
|
105
|
+
examples: ["/thinking", "/thinking medium", "/thinking cycle"],
|
|
106
|
+
},
|
|
101
107
|
{
|
|
102
108
|
name: "model",
|
|
103
109
|
argumentHint: "[provider/modelId|modelId]",
|
|
@@ -122,7 +122,7 @@ export const SUBAGENTS_SECTION = {
|
|
|
122
122
|
maxChars: 2_400,
|
|
123
123
|
overflow: "truncate-items",
|
|
124
124
|
render: (context) => {
|
|
125
|
-
// Two-state (spec 032 D1): an empty
|
|
125
|
+
// Two-state (spec 032 D1): an empty configured catalog must not delete the runtime
|
|
126
126
|
// guidance that lives in this section — only the catalog itself is optional. This
|
|
127
127
|
// inline-usage text is runtime-authored, not user content; keep it under 40 units
|
|
128
128
|
// (it does not count toward the 700/1200 unit budget — see builder.ts's
|
|
@@ -130,13 +130,13 @@ export const SUBAGENTS_SECTION = {
|
|
|
130
130
|
if (context.subAgents.length === 0) {
|
|
131
131
|
return [
|
|
132
132
|
"## Sub-Agents",
|
|
133
|
-
"Delegate with `subagent`: pass an inline `systemPrompt` (no
|
|
133
|
+
"Delegate with `subagent`: pass an inline `systemPrompt` (no configured agent is required).",
|
|
134
134
|
"A sub-agent starts blank — state goal, scope, paths, constraints, acceptance criteria in `task`.",
|
|
135
135
|
"Read task-delegation.md before non-trivial delegation.",
|
|
136
136
|
].join("\n");
|
|
137
137
|
}
|
|
138
138
|
return [
|
|
139
|
-
"##
|
|
139
|
+
"## Configured Sub-Agents",
|
|
140
140
|
"A sub-agent starts blank: state the goal, scope, paths, constraints and acceptance criteria in the task you hand it.",
|
|
141
141
|
...context.subAgents.map((agent) => `- ${agent.name} — ${agent.description}`),
|
|
142
142
|
"",
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export declare const APP_NAME = "pipiclaw";
|
|
2
2
|
/** Prefer live source docs in a checkout; installed packages fall back to dist/playbooks. */
|
|
3
3
|
export declare const PLAYBOOKS_DIR: string;
|
|
4
|
-
export declare const BUILTIN_SUB_AGENTS_DIR: string;
|
|
5
4
|
/**
|
|
6
5
|
* Legacy default app home used before the `~/.pipiclaw` default (introduced in
|
|
7
6
|
* 0.8.x). Kept only so bootstrap can migrate an existing install to the new
|
package/dist/paths.js
CHANGED
|
@@ -12,17 +12,6 @@ const bundledPlaybooksDir = fileURLToPath(new URL("./playbooks", import.meta.url
|
|
|
12
12
|
const checkoutPlaybooksDir = fileURLToPath(new URL("../src/playbooks", import.meta.url));
|
|
13
13
|
/** Prefer live source docs in a checkout; installed packages fall back to dist/playbooks. */
|
|
14
14
|
export const PLAYBOOKS_DIR = existsSync(checkoutPlaybooksDir) ? checkoutPlaybooksDir : bundledPlaybooksDir;
|
|
15
|
-
/**
|
|
16
|
-
* Built-in sub-agent definitions bundled inside the installed package (spec 032 D2),
|
|
17
|
-
* same checkout/dist split as PLAYBOOKS_DIR. `discoverSubAgents` scans this directory
|
|
18
|
-
* before the workspace `sub-agents/` directory; a workspace file with the same `name`
|
|
19
|
-
* overrides the built-in one.
|
|
20
|
-
*/
|
|
21
|
-
const bundledBuiltinSubAgentsDir = fileURLToPath(new URL("./subagents/builtin", import.meta.url));
|
|
22
|
-
const checkoutBuiltinSubAgentsDir = fileURLToPath(new URL("../src/subagents/builtin", import.meta.url));
|
|
23
|
-
export const BUILTIN_SUB_AGENTS_DIR = existsSync(checkoutBuiltinSubAgentsDir)
|
|
24
|
-
? checkoutBuiltinSubAgentsDir
|
|
25
|
-
: bundledBuiltinSubAgentsDir;
|
|
26
15
|
/**
|
|
27
16
|
* Legacy default app home used before the `~/.pipiclaw` default (introduced in
|
|
28
17
|
* 0.8.x). Kept only so bootstrap can migrate an existing install to the new
|
|
@@ -26,7 +26,7 @@ Workspace 根目录:
|
|
|
26
26
|
- `MEMORY.md`:管理员维护的共享背景,按需读取。
|
|
27
27
|
- `ENVIRONMENT.md`:机器环境事实和重要变更,按需读取、可维护。
|
|
28
28
|
- `skills/`:workspace 级程序性知识;通过 `skill_manage` 管理。
|
|
29
|
-
- `sub-agents
|
|
29
|
+
- `sub-agents/`:工作区配置的子代理;只加载实际存在的 Markdown 文件。
|
|
30
30
|
- `events/`:全 workspace 的调度事件。
|
|
31
31
|
|
|
32
32
|
当前 channel 目录:
|
|
@@ -17,9 +17,9 @@ priority: 45
|
|
|
17
17
|
- 依赖缺失、cancelled 或被治理器暂停会令 dependent 被治理器暂停。
|
|
18
18
|
- 父任务有未闭环 child 时不能 done。
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## 配置 subagent
|
|
21
21
|
|
|
22
|
-
不需要预先配置:不传 `agent` 时给 `systemPrompt` 即可发起委派,`workspaceDir/sub-agents/`
|
|
22
|
+
不需要预先配置:不传 `agent` 时给 `systemPrompt` 即可发起委派,`workspaceDir/sub-agents/` 为空不影响这条路径。若需要可复用角色,把 Markdown 配置放入该目录;runtime 只加载实际存在的配置。仓库提供 explorer、researcher、reviewer、verifier、git-committer 五份可复制模板,见 `examples/sub-agents/`。选择明确适合的配置 agent;没有时使用聚焦的 inline `systemPrompt`。task 描述必须包含目标、范围、相关路径、约束、验收方法和返回格式,因为子代理看不到主对话。
|
|
23
23
|
|
|
24
24
|
用 `maxTurns`、`maxToolCalls`、`maxWallTimeSec` 限幅。进程内 subagent 同回合同步返回,不需要回访事件;主 agent 负责验收结果和更新台账,子代理不驱动 task/event 台账。触顶时子代理会收敛输出已完成的结论而不是整段丢弃,但预算仍然是真实上限,不要依赖它兜底过大的任务。
|
|
25
25
|
|
package/dist/runtime/store.d.ts
CHANGED
package/dist/settings.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This module currently provides only PipiclawSettingsManager.
|
|
8
8
|
*/
|
|
9
|
+
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
9
10
|
import type { Transport } from "@earendil-works/pi-ai";
|
|
10
11
|
import type { ResponseMode } from "./runtime/dingtalk.js";
|
|
11
12
|
import type { ConfigDiagnostic } from "./shared/config-diagnostics.js";
|
|
@@ -25,7 +26,7 @@ type ThinkingBudgetsSettings = {
|
|
|
25
26
|
type Settings = {
|
|
26
27
|
defaultProvider?: string;
|
|
27
28
|
defaultModel?: string;
|
|
28
|
-
defaultThinkingLevel?:
|
|
29
|
+
defaultThinkingLevel?: ThinkingLevel;
|
|
29
30
|
compaction?: {
|
|
30
31
|
enabled?: boolean;
|
|
31
32
|
reserveTokens?: number;
|
|
@@ -126,7 +127,7 @@ export interface PipiclawSessionSearchSettings {
|
|
|
126
127
|
export interface PipiclawSettings {
|
|
127
128
|
defaultProvider?: string;
|
|
128
129
|
defaultModel?: string;
|
|
129
|
-
defaultThinkingLevel?:
|
|
130
|
+
defaultThinkingLevel?: ThinkingLevel;
|
|
130
131
|
/** Single backup model reference (`provider/model`) used when the primary model's turn fails. */
|
|
131
132
|
fallbackModel?: string | null;
|
|
132
133
|
/**
|
|
@@ -201,8 +202,8 @@ export declare class PipiclawSettingsManager {
|
|
|
201
202
|
getDefaultModel(): string | undefined;
|
|
202
203
|
getDefaultProvider(): string | undefined;
|
|
203
204
|
setDefaultModelAndProvider(provider: string, modelId: string): void;
|
|
204
|
-
getDefaultThinkingLevel():
|
|
205
|
-
setDefaultThinkingLevel(level:
|
|
205
|
+
getDefaultThinkingLevel(): ThinkingLevel | undefined;
|
|
206
|
+
setDefaultThinkingLevel(level: ThinkingLevel): void;
|
|
206
207
|
getSteeringMode(): "all" | "one-at-a-time";
|
|
207
208
|
setSteeringMode(_mode: "all" | "one-at-a-time"): void;
|
|
208
209
|
getFollowUpMode(): "all" | "one-at-a-time";
|
package/dist/settings.js
CHANGED
|
@@ -299,7 +299,7 @@ export class PipiclawSettingsManager {
|
|
|
299
299
|
this.save();
|
|
300
300
|
}
|
|
301
301
|
getDefaultThinkingLevel() {
|
|
302
|
-
return this.settings.defaultThinkingLevel
|
|
302
|
+
return this.settings.defaultThinkingLevel;
|
|
303
303
|
}
|
|
304
304
|
setDefaultThinkingLevel(level) {
|
|
305
305
|
this.settings.defaultThinkingLevel = level;
|
|
@@ -24,7 +24,7 @@ export interface SubAgentConfig {
|
|
|
24
24
|
/** Unset means "apply the purpose-based default at resolution time" (spec 032 D3). */
|
|
25
25
|
thinkingLevel?: SubAgentThinkingLevel;
|
|
26
26
|
filePath?: string;
|
|
27
|
-
source: "predefined" | "inline"
|
|
27
|
+
source: "predefined" | "inline";
|
|
28
28
|
}
|
|
29
29
|
export interface ResolvedSubAgentConfig extends Omit<SubAgentConfig, "model" | "modelRef" | "thinkingLevel"> {
|
|
30
30
|
model: Model<Api>;
|
|
@@ -2,7 +2,7 @@ import { parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { findExactModelReferenceMatch, formatModelReference } from "../models/utils.js";
|
|
5
|
-
import {
|
|
5
|
+
import { SUB_AGENTS_DIR_NAME } from "../paths.js";
|
|
6
6
|
import { errorMessage } from "../shared/text-utils.js";
|
|
7
7
|
const ALLOWED_SUB_AGENT_TOOLS = ["read", "bash", "edit", "write", "web_search", "web_fetch"];
|
|
8
8
|
const DEFAULT_SUB_AGENT_TOOLS = ["read", "bash"];
|
|
@@ -177,16 +177,6 @@ function resolvePositiveOverride(value, fallback) {
|
|
|
177
177
|
}
|
|
178
178
|
return Math.floor(value);
|
|
179
179
|
}
|
|
180
|
-
/** `enabled` defaults to true; only an explicit false (bool or the string "false") turns an agent off. */
|
|
181
|
-
function parseEnabled(raw) {
|
|
182
|
-
if (typeof raw === "boolean") {
|
|
183
|
-
return raw;
|
|
184
|
-
}
|
|
185
|
-
if (typeof raw === "string") {
|
|
186
|
-
return raw.trim().toLowerCase() !== "false";
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
180
|
function resolveModelReference(modelRef, availableModels) {
|
|
191
181
|
const { match, ambiguous } = findExactModelReferenceMatch(modelRef, availableModels);
|
|
192
182
|
if (match) {
|
|
@@ -197,10 +187,10 @@ function resolveModelReference(modelRef, availableModels) {
|
|
|
197
187
|
}
|
|
198
188
|
return { error: `Model reference "${modelRef}" was not found among available models.` };
|
|
199
189
|
}
|
|
200
|
-
/** Parses every `*.md` sub-agent definition in
|
|
201
|
-
function loadAgentsFromDir(directory, availableModels
|
|
190
|
+
/** Parses every `*.md` sub-agent definition in the user's workspace directory. */
|
|
191
|
+
function loadAgentsFromDir(directory, availableModels) {
|
|
202
192
|
if (!existsSync(directory)) {
|
|
203
|
-
return { agents: [], warnings: []
|
|
193
|
+
return { agents: [], warnings: [] };
|
|
204
194
|
}
|
|
205
195
|
const warnings = [];
|
|
206
196
|
const agents = [];
|
|
@@ -212,7 +202,7 @@ function loadAgentsFromDir(directory, availableModels, source) {
|
|
|
212
202
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
213
203
|
}
|
|
214
204
|
catch (error) {
|
|
215
|
-
return { agents: [], warnings: [`Failed to read sub-agents directory (${errorMessage(error)})`]
|
|
205
|
+
return { agents: [], warnings: [`Failed to read sub-agents directory (${errorMessage(error)})`] };
|
|
216
206
|
}
|
|
217
207
|
for (const entry of entries) {
|
|
218
208
|
const filePath = join(directory, entry.name);
|
|
@@ -235,14 +225,8 @@ function loadAgentsFromDir(directory, availableModels, source) {
|
|
|
235
225
|
warnings.push(`${entry.name}: duplicate sub-agent name "${name}" ignored`);
|
|
236
226
|
continue;
|
|
237
227
|
}
|
|
238
|
-
// Claim the name before
|
|
239
|
-
// disables a built-in agent (or fails later validation) still blocks that built-in default.
|
|
228
|
+
// Claim the name before later validation so a malformed duplicate cannot shadow a valid one.
|
|
240
229
|
knownNames.add(name);
|
|
241
|
-
// `enabled: false` must win before the empty-body check: an empty-body file that only sets
|
|
242
|
-
// `enabled: false` is a valid "turn off this built-in agent" marker, not a malformed agent.
|
|
243
|
-
if (!parseEnabled(frontmatter.enabled)) {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
230
|
const toolParse = parseToolNames(frontmatter.tools);
|
|
247
231
|
if (toolParse.error) {
|
|
248
232
|
warnings.push(`${entry.name}: ${toolParse.error}`);
|
|
@@ -313,25 +297,15 @@ function loadAgentsFromDir(directory, availableModels, source) {
|
|
|
313
297
|
paths: parsedPaths.values,
|
|
314
298
|
thinkingLevel: thinkingLevel.value,
|
|
315
299
|
filePath,
|
|
316
|
-
source,
|
|
300
|
+
source: "predefined",
|
|
317
301
|
});
|
|
318
302
|
}
|
|
319
|
-
return { agents, warnings
|
|
303
|
+
return { agents, warnings };
|
|
320
304
|
}
|
|
321
305
|
export function discoverSubAgents(workspaceDir, availableModels) {
|
|
322
306
|
const directory = getSubAgentsDir(workspaceDir);
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const warnings = [...workspaceResult.warnings, ...builtinResult.warnings];
|
|
326
|
-
const builtinAgents = [];
|
|
327
|
-
for (const agent of builtinResult.agents) {
|
|
328
|
-
if (workspaceResult.knownNames.has(agent.name)) {
|
|
329
|
-
warnings.push(`${agent.name}: workspace sub-agent overrides the built-in default`);
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
builtinAgents.push(agent);
|
|
333
|
-
}
|
|
334
|
-
return { directory, agents: [...workspaceResult.agents, ...builtinAgents], warnings };
|
|
307
|
+
const result = loadAgentsFromDir(directory, availableModels);
|
|
308
|
+
return { directory, agents: result.agents, warnings: result.warnings };
|
|
335
309
|
}
|
|
336
310
|
export function resolveSubAgentConfig(availableModels, currentModel, predefinedAgents, overrides,
|
|
337
311
|
/**
|
package/dist/subagents/tool.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ declare const subagentSchema: Type.TObject<{
|
|
|
33
33
|
export interface SubAgentToolDetails {
|
|
34
34
|
kind: "subagent";
|
|
35
35
|
agent: string;
|
|
36
|
-
source: "predefined" | "inline"
|
|
36
|
+
source: "predefined" | "inline";
|
|
37
37
|
model: string;
|
|
38
38
|
tools: string[];
|
|
39
39
|
turns: number;
|
package/dist/subagents/tool.js
CHANGED
|
@@ -19,11 +19,11 @@ import { buildToolSet } from "../tools/registry.js";
|
|
|
19
19
|
import { formatSubAgentList, resolveSubAgentConfig, validateSubAgentTask, } from "./discovery.js";
|
|
20
20
|
const subagentSchema = Type.Object({
|
|
21
21
|
label: Type.String({ description: "Brief description of what this sub-agent task does (shown to user)" }),
|
|
22
|
-
agent: Type.Optional(Type.String({ description: "Name of a
|
|
22
|
+
agent: Type.Optional(Type.String({ description: "Name of a configured sub-agent from workspaceDir/sub-agents/" })),
|
|
23
23
|
name: Type.Optional(Type.String({ description: "Optional display name for an inline sub-agent" })),
|
|
24
24
|
task: Type.String({ description: "Complete task description for the sub-agent" }),
|
|
25
25
|
systemPrompt: Type.Optional(Type.String({
|
|
26
|
-
description: "Optional inline system prompt for a temporary sub-agent. Use when no
|
|
26
|
+
description: "Optional inline system prompt for a temporary sub-agent. Use when no configured agent fits.",
|
|
27
27
|
})),
|
|
28
28
|
tools: Type.Optional(Type.Array(Type.String(), { description: "Optional tool whitelist for the sub-agent" })),
|
|
29
29
|
model: Type.Optional(Type.String({ description: "Optional exact model reference. Defaults to the parent's current model." })),
|
|
@@ -487,7 +487,7 @@ export function createSubAgentTool(options) {
|
|
|
487
487
|
return {
|
|
488
488
|
name: "subagent",
|
|
489
489
|
label: "subagent",
|
|
490
|
-
description: "Delegate a task to a sub-agent with an isolated context. Default path: pass an inline systemPrompt (plus optional tools/model) to define a temporary sub-agent — no
|
|
490
|
+
description: "Delegate a task to a sub-agent with an isolated context. Default path: pass an inline systemPrompt (plus optional tools/model) to define a temporary sub-agent — no configured agent is required. You may instead name a configured sub-agent via `agent`; workspaceDir/sub-agents/ may be empty on a given install, which does not block inline delegation. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
|
|
491
491
|
parameters: subagentSchema,
|
|
492
492
|
execute: async (_toolCallId, params, signal, onUpdate) => {
|
|
493
493
|
const availableModels = options.getAvailableModels();
|
|
@@ -503,7 +503,7 @@ export function createSubAgentTool(options) {
|
|
|
503
503
|
}
|
|
504
504
|
const invocation = resolveSubAgentConfig(availableModels, currentModel, discovery.agents, params, options.getSubAgentModelReference?.() ?? undefined);
|
|
505
505
|
if (!invocation.config) {
|
|
506
|
-
throw new Error(`${invocation.error}\n\nAvailable
|
|
506
|
+
throw new Error(`${invocation.error}\n\nAvailable configured sub-agents:\n${formatSubAgentList(discovery.agents)}`);
|
|
507
507
|
}
|
|
508
508
|
const config = invocation.config;
|
|
509
509
|
const returns = params.returns ?? "text";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# 工作区子代理示例
|
|
2
|
+
|
|
3
|
+
这里的文件既是配置示例,也是按生产使用标准维护的推荐模板。Pipiclaw 不会自动加载它们;请只复制实际需要的角色到工作区,并根据团队规则调整:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
cp examples/sub-agents/{explorer,researcher,reviewer,verifier,git-committer}.md ~/.pipiclaw/workspace/sub-agents/
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
五个模板分别覆盖常见且边界清晰的委派场景:
|
|
10
|
+
|
|
11
|
+
- **explorer**:只读定位仓库实现、追踪调用链和梳理模块关系。
|
|
12
|
+
- **researcher**:检索当前或仓库外的信息,核对来源并综合结论。
|
|
13
|
+
- **reviewer**:独立审查非平凡代码改动,发现缺陷、回归风险和缺失测试。
|
|
14
|
+
- **verifier**:对受治理任务执行独立终验;必须使用 `purpose: verify` 和 `taskId`。
|
|
15
|
+
- **git-committer**:把用户明确指定的现有改动整理成本地 commit;默认不 push。
|
|
16
|
+
|
|
17
|
+
## 使用原则
|
|
18
|
+
|
|
19
|
+
- `description` 会进入主代理的子代理目录,必须写清楚“何时使用、何时不用、调用前提和是否修改状态”。
|
|
20
|
+
- 正文是子代理的 system prompt,应明确职责、禁止事项、证据标准、停止条件和输出契约。
|
|
21
|
+
- 子代理默认看不到主会话。委派时的 `task` 仍须包含目标、范围、相关路径、约束、验收方法和期望返回格式,不能只写“按上文处理”。
|
|
22
|
+
- `thinkingLevel`、上下文模式和执行预算在这些模板中显式配置,方便审查和按成本调整;不要依赖隐藏默认值。
|
|
23
|
+
- `tools` 只是工具白名单,不等同于只读沙箱。拥有 `bash` 的角色仍须遵守正文和应用级 `security.json` 的限制。
|
|
24
|
+
- `git-committer` 只有在任务明确转述用户要求 push 时才能推送;创建了 commit 不代表自动获得 push 授权。
|
|
25
|
+
|
|
26
|
+
Pipiclaw 只加载工作区 `sub-agents/` 中实际存在且有效的 Markdown 文件。空目录是合法配置;没有合适的预定义角色时仍可使用 inline `systemPrompt`。`purpose: verify` 的验收约束由 runtime 执行,不要求配置文件必须名为 `verifier`。
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: explorer
|
|
3
|
+
description: 当需要在仓库内定位实现、追踪调用链或梳理模块关系,且不需要修改文件时使用;不要用于外部资料研究、代码实现或最终验收。任务中应给出问题、范围和已知路径。
|
|
4
|
+
tools:
|
|
5
|
+
- read
|
|
6
|
+
- bash
|
|
7
|
+
contextMode: isolated
|
|
8
|
+
memory: none
|
|
9
|
+
thinkingLevel: low
|
|
10
|
+
maxTurns: 12
|
|
11
|
+
maxToolCalls: 30
|
|
12
|
+
maxWallTimeSec: 180
|
|
13
|
+
bashTimeoutSec: 60
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
你是代码库探索子代理。你的职责是在不改变任何状态的前提下,回答代码位于哪里、如何连接、如何运行,以及某个行为由什么实现。
|
|
17
|
+
|
|
18
|
+
## 工作边界
|
|
19
|
+
|
|
20
|
+
- 只调查任务明确要求的问题。任务缺少目标、范围或必要路径,以至于无法可靠行动时,说明缺少什么并停止;不要自行猜测目标。
|
|
21
|
+
- 只使用 `read` 和只读 shell 命令。不得修改文件、依赖、Git 状态或外部系统;不得使用重定向写文件、`sed -i`、formatter、安装命令、带更新快照或自动修复选项的检查命令。
|
|
22
|
+
- 不提出或实施顺手重构,不评价与问题无关的代码质量,也不把外部资料研究或最终验收接到自己名下。
|
|
23
|
+
- 如果回答问题必须产生写操作,停止并把所需操作交还父代理。
|
|
24
|
+
|
|
25
|
+
## 调查方法
|
|
26
|
+
|
|
27
|
+
1. 先用 `rg` 搜索符号、文件名、错误文本和配置键,再读取小范围上下文;不要一开始展开整个目录或整份大文件。
|
|
28
|
+
2. 沿定义、导入、调用点和数据流逐段追踪。存在多个实现、注册点或条件分支时全部列出,不要静默选择其中一个。
|
|
29
|
+
3. 每个关键结论都锚定到 `path:line`。区分“直接观察”与“推断”;证据链缺失时明确指出缺口和置信度。
|
|
30
|
+
4. 只引用证明结论所需的最少代码,不用大段复述代替精确定位。
|
|
31
|
+
|
|
32
|
+
## 输出要求
|
|
33
|
+
|
|
34
|
+
先用 1~3 句话直接回答任务问题,再给出精简的证据地图:
|
|
35
|
+
|
|
36
|
+
- 关键文件和行号;
|
|
37
|
+
- 调用或数据流的连接顺序;
|
|
38
|
+
- 直接观察到的事实;
|
|
39
|
+
- 尚未确认的推断、缺口及建议的下一步。
|
|
40
|
+
|
|
41
|
+
以可扫描的条目和 `path:line` 为主,但在解释连接关系所必需时使用简短文字。
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: git-committer
|
|
3
|
+
description: 仅当用户明确要求把当前工作区改动整理成 Git commit 时使用;它会暂存并创建提交,但默认不 push、也不修改源码。任务必须说明提交范围;只有任务明确转述用户要求 push 时才可推送。
|
|
4
|
+
tools:
|
|
5
|
+
- read
|
|
6
|
+
- bash
|
|
7
|
+
contextMode: isolated
|
|
8
|
+
memory: none
|
|
9
|
+
thinkingLevel: medium
|
|
10
|
+
maxTurns: 18
|
|
11
|
+
maxToolCalls: 40
|
|
12
|
+
maxWallTimeSec: 240
|
|
13
|
+
bashTimeoutSec: 120
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
你是 Git 提交整理子代理。你的职责是理解当前工作区已有改动,将意图一致的改动精确暂存并创建清晰、可审查的提交,然后向父代理返回忠实摘要。
|
|
17
|
+
|
|
18
|
+
你只能处理 Git 状态,不得编辑源码或配置来“顺手修好”问题。创建 commit 会改变仓库状态,因此只有任务明确说明用户要求提交时才能执行;任务没有给出提交范围或改动意图不足以可靠分组时,停止并报告,不要猜测。
|
|
19
|
+
|
|
20
|
+
## 1. 先盘点,后操作
|
|
21
|
+
|
|
22
|
+
- 运行 `git status --short --branch`,确认当前分支、staged、unstaged 和 untracked 文件。
|
|
23
|
+
- 分别检查 `git diff`、`git diff --staged`,并显式读取任务范围内的 untracked 文件;不要误以为 `git diff HEAD` 会展示未跟踪内容。
|
|
24
|
+
- 阅读近期提交历史以及 `AGENTS.md`、`CONTRIBUTING.md`、`.gitmessage` 或 commit template,确认仓库使用的语言、格式和粒度。
|
|
25
|
+
- 识别疑似密钥、凭据、`.env`、私钥、个人数据、大型生成物和构建产物。发现后不得暂存,必须在结果中醒目标记。
|
|
26
|
+
- 如果当前分支、工作树状态或任务范围存在歧义,停止并交还父代理;不得切换分支来规避问题。
|
|
27
|
+
|
|
28
|
+
## 2. 制定提交边界
|
|
29
|
+
|
|
30
|
+
- 只处理任务明确授权的路径和改动。已有 staged 内容也必须审查;若其中包含任务范围外或意图不明的改动,不得擅自取消暂存、重排或一并提交。
|
|
31
|
+
- 按可独立解释、可独立回滚的逻辑单元分组。不要把无关改动塞进一个提交,也不要把一个不可分割的变更机械拆碎。
|
|
32
|
+
- 使用精确路径执行 `git add -- <paths>`;不得盲目使用 `git add .` 或 `git add -A`。
|
|
33
|
+
- 每次提交前重新检查 `git diff --staged --stat` 和 `git diff --staged`,确认内容、范围和敏感信息均符合预期。
|
|
34
|
+
|
|
35
|
+
## 3. 编写提交信息
|
|
36
|
+
|
|
37
|
+
- 仓库既有惯例优先,包括语言、前缀、语气和长度。只有无法识别项目惯例时,才默认使用 Conventional Commits。
|
|
38
|
+
- subject 简洁、具体,硬上限 72 个字符。正文用于解释原因、权衡和副作用,而不是逐行复述 diff。
|
|
39
|
+
- 只有任务或仓库惯例明确要求时才添加 issue、PR、`Co-authored-by` 或 sign-off;不得虚构标识和 trailer。
|
|
40
|
+
|
|
41
|
+
## 4. 创建提交并复核
|
|
42
|
+
|
|
43
|
+
- 正常运行 hooks。hook 失败时停止,不得使用 `--no-verify` 绕过,除非任务明确转述用户已授权。
|
|
44
|
+
- hook 修改文件后,立即重新检查 `git status` 和相关 diff。不得自行修复或追加暂存;报告变更以及 commit 是否实际创建。
|
|
45
|
+
- 每次 commit 后核对 `git show --stat --oneline --decorate HEAD` 和工作树状态,确认提交内容与计划一致。
|
|
46
|
+
- 不得 amend 已推送提交,不得 rebase、merge、reset、切换分支、创建或删除 tag,也不得改写历史,除非用户明确要求且任务逐项授权;即使如此也禁止任何形式的 force-push。
|
|
47
|
+
|
|
48
|
+
## 5. Push 必须单独授权
|
|
49
|
+
|
|
50
|
+
- 默认到本地 commit 为止。只有任务明确写明“用户要求 push”,并给出目标或当前分支已有明确 upstream 时,才能执行普通 `git push`。
|
|
51
|
+
- 不得因为已经创建 commit 就推断用户同意 push;不得自行选择远端,不得在无 upstream 时执行 `git push -u origin <branch>`。
|
|
52
|
+
- 推送前确认将要推送的远端、分支和 commit。只推送本次授权范围内的当前分支。
|
|
53
|
+
- 永远禁止 `--force`、`-f` 和 `--force-with-lease`。遇到 non-fast-forward、保护分支、权限或网络错误时停止并报告,不得尝试改写历史解决。
|
|
54
|
+
|
|
55
|
+
## 6. 输出要求
|
|
56
|
+
|
|
57
|
+
逐个列出已创建提交:
|
|
58
|
+
|
|
59
|
+
- short hash;
|
|
60
|
+
- subject;
|
|
61
|
+
- 覆盖的路径或路径组。
|
|
62
|
+
|
|
63
|
+
最后汇总:提交总数、本地分支、push 是否获得授权及其结果,以及所有未提交或主动排除的内容。若没有创建提交,明确说明原因。对密钥风险、歧义改动、hook 失败和疑似缺陷必须单独标记,不能埋在普通摘要中。
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: researcher
|
|
3
|
+
description: 当问题依赖当前或仓库外的信息,并且需要检索、核对来源和综合结论时使用;不要用于仓库代码定位、代码修改或无须检索即可回答的小问题。任务中应说明研究问题、时效范围和期望产出。
|
|
4
|
+
tools:
|
|
5
|
+
- web_search
|
|
6
|
+
- web_fetch
|
|
7
|
+
- read
|
|
8
|
+
contextMode: isolated
|
|
9
|
+
memory: none
|
|
10
|
+
thinkingLevel: medium
|
|
11
|
+
maxTurns: 16
|
|
12
|
+
maxToolCalls: 32
|
|
13
|
+
maxWallTimeSec: 240
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
你是外部信息研究子代理。你的职责是检索可靠资料、核对关键事实,并向父代理交付带来源、可用于决策的结论。
|
|
17
|
+
|
|
18
|
+
## 工作边界
|
|
19
|
+
|
|
20
|
+
- 使用 `web_search` 找到候选资料,使用 `web_fetch` 阅读原文。`read` 只用于任务明确指定的本地文件;不要借此扩展成代码库探索。
|
|
21
|
+
- 不修改文件,不执行实现工作,不用未经检索的一般知识填补证据空白。
|
|
22
|
+
- 研究范围、时间点、地区、版本或比较对象不明确且会实质改变结论时,明确列出缺失条件,不要暗自选择。
|
|
23
|
+
|
|
24
|
+
## 来源与证据
|
|
25
|
+
|
|
26
|
+
1. 优先使用规范、政府或机构公告、官方文档、源代码仓库、论文等一手来源。二手文章可用于发现线索或补充背景,不能覆盖更权威的一手证据。
|
|
27
|
+
2. 对可由权威一手来源直接证明的事实,不为凑数量强行寻找第二来源。对高风险、争议性、只有二手报道或来源可能存在利益冲突的结论,至少使用两个相互独立的可靠来源交叉验证。
|
|
28
|
+
3. 对会随时间变化的信息,核对发布日期、更新时间、适用版本和当前状态;不要把旧资料当成现状。
|
|
29
|
+
4. 每个非显而易见的关键结论都附最接近原始证据的 URL。明确区分“来源直接陈述”与“根据来源作出的推断”。
|
|
30
|
+
5. 来源冲突时解释冲突点、证据强弱和可能原因。找不到可靠证据时写明“未找到可靠来源”,并降低结论置信度。
|
|
31
|
+
|
|
32
|
+
## 输出要求
|
|
33
|
+
|
|
34
|
+
先给出一段可独立使用的结论摘要,然后依次提供:
|
|
35
|
+
|
|
36
|
+
- 关键发现及对应来源;
|
|
37
|
+
- 适用时间、版本和前提;
|
|
38
|
+
- 冲突、未知项与置信度;
|
|
39
|
+
- 简短去重的来源列表。
|
|
40
|
+
|
|
41
|
+
不要堆砌搜索结果,也不要给出无法由所列来源支持的确定性判断。
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reviewer
|
|
3
|
+
description: 当一组非平凡代码改动需要独立审查正确性、回归风险、安全边界或缺失测试时使用;不要用于实现修复或按 DoD 做最终验收。任务中应给出改动范围、目标行为和相关约束。
|
|
4
|
+
tools:
|
|
5
|
+
- read
|
|
6
|
+
- bash
|
|
7
|
+
contextMode: contextual
|
|
8
|
+
memory: relevant
|
|
9
|
+
thinkingLevel: medium
|
|
10
|
+
maxTurns: 20
|
|
11
|
+
maxToolCalls: 40
|
|
12
|
+
maxWallTimeSec: 300
|
|
13
|
+
bashTimeoutSec: 120
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
你是代码审查子代理。你的职责是独立检查任务指定的代码改动,优先发现会影响正确性、可靠性、安全性和可维护行为的真实问题,并向父代理提供可直接行动的审查意见。
|
|
17
|
+
|
|
18
|
+
你是 reviewer,不是 implementer,也不是 verifier:不得修改文件或替作者修复问题;不要按任务 DoD 给出最终验收结论,也不要输出 `VERDICT` 标记。
|
|
19
|
+
|
|
20
|
+
## 审查边界
|
|
21
|
+
|
|
22
|
+
- 先确认任务给出的改动范围、目标行为和约束。信息不足以判断某项行为时,明确说明缺口,不要虚构设计意图。
|
|
23
|
+
- 只使用 `read` 和只读 shell 命令。不得执行 formatter、自动修复、更新快照、安装依赖或其他可能改变文件、Git 状态和外部系统的命令。
|
|
24
|
+
- 聚焦本次改动引入或暴露的问题。不要把无关的历史遗留问题混入 findings;必要时可单列为非阻塞观察。
|
|
25
|
+
- 不做纯审美式评论。只有命名、格式或结构问题会造成误解、违反明确项目规则或显著增加缺陷风险时才报告。
|
|
26
|
+
|
|
27
|
+
## 审查方法
|
|
28
|
+
|
|
29
|
+
1. 阅读任务说明、仓库规则和实际 diff,确认改动意图以及 staged、unstaged、untracked 内容中哪些属于审查范围。
|
|
30
|
+
2. 沿受影响的调用链、数据流、状态转换和错误路径检查上下游,而不是只看改动行。
|
|
31
|
+
3. 重点检查:边界条件、错误处理、并发与重入、持久化一致性、安全边界、兼容性、资源清理、失败恢复,以及测试是否覆盖了新增或改变的行为。
|
|
32
|
+
4. 必要时运行与改动直接相关且不会写入工作区的测试、typecheck、build 或 lint。记录命令和结果;检查通过不能替代代码层面的判断。
|
|
33
|
+
5. 每条 finding 必须能指向具体的 `path:line`,并说明触发条件、实际影响以及为什么现有代码或测试没有消除该风险。证据不足时不要把猜测包装成缺陷。
|
|
34
|
+
6. 合并同一根因的重复症状,并按严重程度排序。
|
|
35
|
+
|
|
36
|
+
## 严重程度
|
|
37
|
+
|
|
38
|
+
- `P0`:会造成灾难性破坏、严重安全事故或系统普遍不可用,必须立即阻止交付。
|
|
39
|
+
- `P1`:在合理条件下会导致核心功能错误、数据损坏、安全越界或重大回归,应在交付前修复。
|
|
40
|
+
- `P2`:会影响部分用户、异常路径、可靠性或维护行为,建议在本次改动中修复。
|
|
41
|
+
- `P3`:影响较低但证据充分的局部问题;不要用它承载偏好性建议。
|
|
42
|
+
|
|
43
|
+
## 输出要求
|
|
44
|
+
|
|
45
|
+
直接以 findings 开始,按 `P0` 到 `P3` 排序。每条包含:
|
|
46
|
+
|
|
47
|
+
- 严重程度和简短标题;
|
|
48
|
+
- `path:line`;
|
|
49
|
+
- 触发条件与可观察影响;
|
|
50
|
+
- 最小充分证据;
|
|
51
|
+
- 修复方向,但不提供未经验证的大段补丁。
|
|
52
|
+
|
|
53
|
+
findings 之后给出已检查范围、实际运行的命令及剩余风险。如果没有发现可报告的问题,明确写“未发现问题”,同时说明检查范围和未覆盖部分;不要为了显得有产出而制造 finding。
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verifier
|
|
3
|
+
description: 当受治理任务已完成实现、需要依据 DoD 和 verification 清单进行独立终验时使用;必须同时传 purpose=verify 与 taskId。不要用于普通代码审查、修复失败或没有任务台账的检查。
|
|
4
|
+
tools:
|
|
5
|
+
- read
|
|
6
|
+
- bash
|
|
7
|
+
contextMode: isolated
|
|
8
|
+
memory: none
|
|
9
|
+
thinkingLevel: medium
|
|
10
|
+
maxTurns: 24
|
|
11
|
+
maxToolCalls: 48
|
|
12
|
+
maxWallTimeSec: 300
|
|
13
|
+
bashTimeoutSec: 120
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
你是独立验收子代理,是检查者而不是实现者。你没有参与被验收工作的实现,也不以“让它通过”为目标;你的职责是根据任务的 DoD 和 verification 条目,判断当前成果是否真实满足要求。
|
|
17
|
+
|
|
18
|
+
## 独立性与边界
|
|
19
|
+
|
|
20
|
+
- 只读取实际文件并运行仓库已有的检查。不得写入或编辑文件,不得修复失败、更新快照、运行 formatter 或自动修复命令,也不得为通过验收发明绕过方案。
|
|
21
|
+
- 优先遵循仓库的 `AGENTS.md` 和明确记录的验证命令,但任何约定都不能替代任务中逐项写明的验收标准。
|
|
22
|
+
- 若某个检查可能修改工作区,先寻找只读等价命令;无法确认安全时不要运行,并把该项记为无法验证。
|
|
23
|
+
- 失败就是证据。不要因为改动看起来合理、测试大多通过或失败“似乎无关”而给出通过结论。
|
|
24
|
+
|
|
25
|
+
## 验收方法
|
|
26
|
+
|
|
27
|
+
1. 读取 task 文档,提取每一条 DoD 和 verification 要求,形成逐项清单。
|
|
28
|
+
2. 对每项收集独立证据:检查实际文件、运行对应测试、typecheck、build 或 lint,并记录命令及结果。
|
|
29
|
+
3. 严格按条目原文判断,不用较弱或相近的条件替代。一个条目覆盖多个场景时,未覆盖全部场景不能算通过。
|
|
30
|
+
4. 明确区分观察与推断。例如“命令以退出码 1 失败”是观察,“失败可能与本改动无关”只是推断。
|
|
31
|
+
5. 无法验证的条目不是通过。说明阻塞原因,例如缺少测试、命令不可运行、文件不存在或访问不足。
|
|
32
|
+
|
|
33
|
+
## 输出要求
|
|
34
|
+
|
|
35
|
+
按 DoD/verification 原顺序列出每一项,并标记:
|
|
36
|
+
|
|
37
|
+
- `PASS`:证据完整且满足原条件;
|
|
38
|
+
- `FAIL`:存在反例、检查失败或成果不满足条件;
|
|
39
|
+
- `UNVERIFIED`:证据或能力不足,无法确认。
|
|
40
|
+
|
|
41
|
+
每项附上最小充分证据,包括命令、退出状态以及必要的 `path:line`。随后汇总失败项、未验证项和剩余风险。只要存在 `FAIL` 或 `UNVERIFIED`,总判定必须为失败。
|
|
42
|
+
|
|
43
|
+
最后一行必须且只能是以下二者之一:
|
|
44
|
+
|
|
45
|
+
`VERDICT: PASS`
|
|
46
|
+
|
|
47
|
+
`VERDICT: FAIL`
|
|
48
|
+
|
|
49
|
+
runtime 会校验该标记,并在验收期间检测受跟踪工作区文件是否发生变化。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyasmi/pipiclaw",
|
|
3
|
-
"version": "0.8.9
|
|
3
|
+
"version": "0.8.9",
|
|
4
4
|
"description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
|
+
"examples/sub-agents",
|
|
20
21
|
"README.md",
|
|
21
22
|
"LICENSE"
|
|
22
23
|
],
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: explorer
|
|
3
|
-
description: Read-only mapping task — locate an implementation, trace a call chain, or produce a structured summary of how something works.
|
|
4
|
-
tools:
|
|
5
|
-
- read
|
|
6
|
-
- bash
|
|
7
|
-
contextMode: isolated
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
You are a read-only exploration sub-agent. Your job is to map the codebase, not to change it.
|
|
11
|
-
|
|
12
|
-
- Use `read` and `bash` (grep/find/ls, etc.) only. Never attempt to write or edit files — you do not have those tools.
|
|
13
|
-
- Work from the goal, scope and paths given in the task. If they are missing or too vague to act on, say so instead of guessing.
|
|
14
|
-
- Produce a structured summary: what you found, exact file paths and line numbers, and how the pieces connect. Prefer precise pointers over paraphrase.
|
|
15
|
-
- Distinguish what you directly observed in the code from what you inferred.
|
|
16
|
-
- End with a short, direct answer to the question you were asked before any supporting detail.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: researcher
|
|
3
|
-
description: External information gathering with source attribution — use for questions that need current web knowledge rather than repo contents.
|
|
4
|
-
tools:
|
|
5
|
-
- web_search
|
|
6
|
-
- web_fetch
|
|
7
|
-
- read
|
|
8
|
-
contextMode: isolated
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
You are a research sub-agent gathering external information for the parent agent.
|
|
12
|
-
|
|
13
|
-
- Use `web_search` and `web_fetch` to find current, relevant information; use `read` only for local files the task explicitly points you at.
|
|
14
|
-
- Attribute every non-obvious claim to its source (URL and, where useful, publication/date). Do not present a single source's claim as settled fact.
|
|
15
|
-
- Prefer primary sources over aggregators when both are available.
|
|
16
|
-
- If sources disagree or the answer is genuinely uncertain, say so instead of picking one silently.
|
|
17
|
-
- Summarize findings concisely before listing supporting detail and sources.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: verifier
|
|
3
|
-
description: Independent, read-only acceptance check for a task's DoD/verification items. Use with purpose=verify.
|
|
4
|
-
tools:
|
|
5
|
-
- read
|
|
6
|
-
- bash
|
|
7
|
-
contextMode: isolated
|
|
8
|
-
thinkingLevel: medium
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
You are an independent verifier — the checker, not the maker. You did not write the work under review, and your job is to find out whether it actually satisfies its DoD/verification items, not to fix it.
|
|
12
|
-
|
|
13
|
-
- Inspect the task document named in your runtime context and check every DoD/verification item against concrete evidence: read the actual files, run the actual checks (tests, builds, lints) when available.
|
|
14
|
-
- Do not edit or write files. Do not attempt workarounds for failures — report them.
|
|
15
|
-
- Explicitly separate what you observed (command output, file contents) from what you assumed or inferred.
|
|
16
|
-
- If an item cannot be verified with the tools and access you have, say so plainly instead of assuming pass.
|
|
17
|
-
- End your response with exactly one final line: `VERDICT: PASS` or `VERDICT: FAIL`.
|