@oisin-ee/pi-dogsled 0.36.1 → 0.37.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 +2 -2
- package/package.json +1 -1
- package/pi/index.ts +2 -0
- package/pi/settings.ts +216 -0
- package/plugins/dogsled/skills/dogsled/SKILL.md +19 -10
- package/plugins/dogsled/skills/dogsled/references/commands.md +1 -1
- package/plugins/dogsled/skills/dogsled/references/land.md +1 -1
- package/plugins/dogsled/skills/dogsled/references/review.md +1 -1
- package/plugins/dogsled/skills/dogsled/references/trouble.md +2 -2
package/README.md
CHANGED
|
@@ -13,13 +13,13 @@ Install the binary on each Herdr host. Use the same release tag in each command.
|
|
|
13
13
|
Binary:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
|
-
mise use github:oisin-ee/dogsled@v0.
|
|
16
|
+
mise use github:oisin-ee/dogsled@v0.37.1 # x-release-please-version
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Pi (extension, tools, the `todo` tool, and skill), from npm:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
pi install npm:@oisin-ee/pi-dogsled@0.
|
|
22
|
+
pi install npm:@oisin-ee/pi-dogsled@0.37.1 # x-release-please-version
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
At session start the extension compares its version with `dogsled --version` and warns when they differ.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oisin-ee/pi-dogsled",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "Pi extension for dogsled: the board, the /dogsled panel, the inbox reader, and the dogsled tools. Needs the dogsled binary of the same version.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/pi/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { registerInterview } from "./interview.ts";
|
|
|
14
14
|
import { registerPlanMode } from "./plan-mode.ts";
|
|
15
15
|
import { PortalClient } from "./portal-client.ts";
|
|
16
16
|
import { registerActivity } from "./activity.ts";
|
|
17
|
+
import { registerSettings } from "./settings.ts";
|
|
17
18
|
import { createTodo } from "./todo/src/index.ts";
|
|
18
19
|
|
|
19
20
|
const REFRESH_MS = 10_000;
|
|
@@ -61,6 +62,7 @@ export default function dogsled(pi: ExtensionAPI) {
|
|
|
61
62
|
// The portal owns the interactive parts of Pi: the interview form and the plan review.
|
|
62
63
|
const portal = new PortalClient();
|
|
63
64
|
registerActivity(pi, portal, owner);
|
|
65
|
+
registerSettings(pi, portal, owner);
|
|
64
66
|
const planMode = registerPlanMode(pi, todo.approve, portal);
|
|
65
67
|
const interviews = registerInterview(pi, portal);
|
|
66
68
|
// One handler owns the tool call: the unit bridge first, then the plan-mode gate.
|
package/pi/settings.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Live model settings use Pi's setters, independently of the activity protocol.
|
|
2
|
+
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
3
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { sleep, type PortalClient } from "./portal-client.ts";
|
|
5
|
+
|
|
6
|
+
type Thinking = ReturnType<ExtensionAPI["getThinkingLevel"]>;
|
|
7
|
+
interface ModelRef {
|
|
8
|
+
provider: string;
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
interface Evidence {
|
|
12
|
+
session_file: string;
|
|
13
|
+
session_id: string;
|
|
14
|
+
}
|
|
15
|
+
interface Settings {
|
|
16
|
+
model: ModelRef | null;
|
|
17
|
+
thinking: Thinking;
|
|
18
|
+
models: { model: ModelRef; name: string; thinking: Thinking[] }[];
|
|
19
|
+
}
|
|
20
|
+
interface Change {
|
|
21
|
+
model?: ModelRef;
|
|
22
|
+
thinking?: Thinking;
|
|
23
|
+
}
|
|
24
|
+
interface Request {
|
|
25
|
+
id: string;
|
|
26
|
+
evidence: Evidence;
|
|
27
|
+
change: Change;
|
|
28
|
+
}
|
|
29
|
+
type Client = Pick<PortalClient, "json" | "events">;
|
|
30
|
+
const levels = new Set<string>(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
31
|
+
const record = (value: unknown): value is Record<string, unknown> =>
|
|
32
|
+
typeof value === "object" && value !== null;
|
|
33
|
+
const text = (value: unknown, max: number): value is string =>
|
|
34
|
+
typeof value === "string" &&
|
|
35
|
+
value.length > 0 &&
|
|
36
|
+
Buffer.byteLength(value) <= max &&
|
|
37
|
+
!/\p{Cc}/u.test(value);
|
|
38
|
+
const modelRef = (value: unknown): value is ModelRef =>
|
|
39
|
+
record(value) && text(value["provider"], 256) && text(value["id"], 256);
|
|
40
|
+
const thinking = (value: unknown): value is Thinking =>
|
|
41
|
+
typeof value === "string" && levels.has(value);
|
|
42
|
+
|
|
43
|
+
function request(value: unknown): value is Request {
|
|
44
|
+
if (
|
|
45
|
+
!record(value) ||
|
|
46
|
+
!text(value["id"], 128) ||
|
|
47
|
+
!record(value["evidence"]) ||
|
|
48
|
+
!record(value["change"])
|
|
49
|
+
)
|
|
50
|
+
return false;
|
|
51
|
+
const evidence = value["evidence"],
|
|
52
|
+
change = value["change"];
|
|
53
|
+
return (
|
|
54
|
+
text(evidence["session_file"], 4096) &&
|
|
55
|
+
text(evidence["session_id"], 1024) &&
|
|
56
|
+
(change["model"] === undefined || modelRef(change["model"])) &&
|
|
57
|
+
(change["thinking"] === undefined || thinking(change["thinking"])) &&
|
|
58
|
+
(change["model"] !== undefined || change["thinking"] !== undefined)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** One subscription and publication lifetime per native session. */
|
|
63
|
+
export class SessionSettings {
|
|
64
|
+
private readonly controller = new AbortController();
|
|
65
|
+
private publication: Promise<void> = Promise.resolve();
|
|
66
|
+
private watching = false;
|
|
67
|
+
private readonly path: string;
|
|
68
|
+
|
|
69
|
+
private readonly pi: Pick<ExtensionAPI, "setModel" | "setThinkingLevel" | "getThinkingLevel">;
|
|
70
|
+
private readonly client: Client;
|
|
71
|
+
private readonly evidence: Evidence;
|
|
72
|
+
private readonly ctx: ExtensionContext;
|
|
73
|
+
|
|
74
|
+
constructor(
|
|
75
|
+
pi: Pick<ExtensionAPI, "setModel" | "setThinkingLevel" | "getThinkingLevel">,
|
|
76
|
+
client: Client,
|
|
77
|
+
pane: string,
|
|
78
|
+
evidence: Evidence,
|
|
79
|
+
ctx: ExtensionContext,
|
|
80
|
+
) {
|
|
81
|
+
this.pi = pi;
|
|
82
|
+
this.client = client;
|
|
83
|
+
this.evidence = evidence;
|
|
84
|
+
this.ctx = ctx;
|
|
85
|
+
this.path = `/api/agents/${encodeURIComponent(pane)}/settings`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
stop(): void {
|
|
89
|
+
this.controller.abort();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private current(): Settings {
|
|
93
|
+
const models = this.ctx.scopedModels.length
|
|
94
|
+
? this.ctx.scopedModels.map((choice) => choice.model)
|
|
95
|
+
: this.ctx.modelRegistry.getAvailable();
|
|
96
|
+
const ref = (model: ModelRef): ModelRef => ({ provider: model.provider, id: model.id });
|
|
97
|
+
return {
|
|
98
|
+
model: this.ctx.model ? ref(this.ctx.model) : null,
|
|
99
|
+
thinking: this.pi.getThinkingLevel(),
|
|
100
|
+
models: models
|
|
101
|
+
.filter(modelRef)
|
|
102
|
+
.slice(0, 1000)
|
|
103
|
+
.map((model) => ({
|
|
104
|
+
model: ref(model),
|
|
105
|
+
name: model.name.slice(0, 256),
|
|
106
|
+
thinking: getSupportedThinkingLevels(model),
|
|
107
|
+
})),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Hook publications stay ordered; failures are retried by the subscription loop. */
|
|
112
|
+
publish(): Promise<void> {
|
|
113
|
+
this.publication = this.publication
|
|
114
|
+
.catch(() => undefined)
|
|
115
|
+
.then(async () => {
|
|
116
|
+
if (this.controller.signal.aborted) return;
|
|
117
|
+
await this.client.json(
|
|
118
|
+
"PUT",
|
|
119
|
+
this.path,
|
|
120
|
+
{ evidence: this.evidence, settings: this.current() },
|
|
121
|
+
this.controller.signal,
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
return this.publication;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
start(): void {
|
|
128
|
+
if (this.watching) return;
|
|
129
|
+
this.watching = true;
|
|
130
|
+
void this.stream();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private async stream(): Promise<void> {
|
|
134
|
+
const signal = this.controller.signal;
|
|
135
|
+
let delay = 250;
|
|
136
|
+
const query = new URLSearchParams({ ...this.evidence });
|
|
137
|
+
while (!signal.aborted) {
|
|
138
|
+
try {
|
|
139
|
+
await this.publish();
|
|
140
|
+
const events = await this.client.events(`${this.path}/requests?${query}`, signal);
|
|
141
|
+
for await (const event of events) {
|
|
142
|
+
if (signal.aborted) break;
|
|
143
|
+
if (event.event !== "settings") continue;
|
|
144
|
+
await this.apply(JSON.parse(event.data));
|
|
145
|
+
delay = 250;
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
// The portal may be absent at startup. A settings hook never fails the session.
|
|
149
|
+
}
|
|
150
|
+
if (!signal.aborted) await sleep(delay, signal);
|
|
151
|
+
delay = Math.min(delay * 2, 10_000);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async apply(value: unknown): Promise<void> {
|
|
156
|
+
if (
|
|
157
|
+
this.controller.signal.aborted ||
|
|
158
|
+
!request(value) ||
|
|
159
|
+
value.evidence.session_file !== this.evidence.session_file ||
|
|
160
|
+
value.evidence.session_id !== this.evidence.session_id
|
|
161
|
+
)
|
|
162
|
+
return;
|
|
163
|
+
let error: string | undefined;
|
|
164
|
+
try {
|
|
165
|
+
if (value.change.model) {
|
|
166
|
+
const { provider, id } = value.change.model;
|
|
167
|
+
const model = this.ctx.modelRegistry.find(provider, id);
|
|
168
|
+
if (!model) throw new Error("unknown model");
|
|
169
|
+
if (!(await this.pi.setModel(model))) throw new Error(`no credentials for ${provider}`);
|
|
170
|
+
}
|
|
171
|
+
if (this.controller.signal.aborted) return;
|
|
172
|
+
if (value.change.thinking) this.pi.setThinkingLevel(value.change.thinking);
|
|
173
|
+
} catch (failure) {
|
|
174
|
+
error = failure instanceof Error ? failure.message : String(failure);
|
|
175
|
+
}
|
|
176
|
+
await this.publication.catch(() => undefined);
|
|
177
|
+
if (this.controller.signal.aborted) return;
|
|
178
|
+
await this.client.json(
|
|
179
|
+
"POST",
|
|
180
|
+
`${this.path}/requests/${encodeURIComponent(value.id)}/result`,
|
|
181
|
+
{
|
|
182
|
+
evidence: this.evidence,
|
|
183
|
+
...(error ? { error } : { settings: this.current() }),
|
|
184
|
+
},
|
|
185
|
+
this.controller.signal,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function registerSettings(pi: ExtensionAPI, client: Client, pane: string | undefined): void {
|
|
191
|
+
let session: SessionSettings | undefined;
|
|
192
|
+
pi.on("session_start", (_event, ctx) => {
|
|
193
|
+
session?.stop();
|
|
194
|
+
session = undefined;
|
|
195
|
+
if (!pane || !text(pane, 128)) return;
|
|
196
|
+
try {
|
|
197
|
+
const session_file = ctx.sessionManager.getSessionFile(),
|
|
198
|
+
session_id = ctx.sessionManager.getSessionId();
|
|
199
|
+
if (!text(session_file, 4096) || !text(session_id, 1024)) return;
|
|
200
|
+
session = new SessionSettings(pi, client, pane, { session_file, session_id }, ctx);
|
|
201
|
+
session.start();
|
|
202
|
+
} catch {
|
|
203
|
+
/* Missing session evidence leaves settings unavailable. */
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
pi.on("model_select", () => {
|
|
207
|
+
void session?.publish().catch(() => undefined);
|
|
208
|
+
});
|
|
209
|
+
pi.on("thinking_level_select", () => {
|
|
210
|
+
void session?.publish().catch(() => undefined);
|
|
211
|
+
});
|
|
212
|
+
pi.on("session_shutdown", () => {
|
|
213
|
+
session?.stop();
|
|
214
|
+
session = undefined;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dogsled
|
|
3
|
-
description: Lead procedure for a change to code, config, or Git. It covers
|
|
3
|
+
description: Lead procedure for a change to code, config, or Git. It covers when to start workers, how to split and brief the work, and how to land the change. Load it when a top-level session gets a change request. Do not load it in an exec session given prewalk. Do not load it in a worker session, because the worker profile prompt is your whole job.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Exec agents given prewalk
|
|
@@ -9,19 +9,27 @@ If you are an exec agent given prewalk, this procedure is not for you. Do not de
|
|
|
9
9
|
|
|
10
10
|
# Lead
|
|
11
11
|
|
|
12
|
-
You
|
|
12
|
+
You own the change from plan to landing. By default, you make it yourself in this session.
|
|
13
|
+
Start writers only when step 0 says the work needs them. Then you split the work, brief workers, check their results, and land them.
|
|
13
14
|
You may edit plans, briefs, and docs that you own.
|
|
14
15
|
|
|
15
|
-
## 0. Do
|
|
16
|
+
## 0. Do the work yourself unless it needs parallel writers
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
Plan, edit, and test the change in this session. Fix review and integration findings yourself.
|
|
19
|
+
Start writers only when all of these are true:
|
|
18
20
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
21
|
+
- The work splits into two or more units that can run at the same time.
|
|
22
|
+
- Each unit owns different files behind a fixed interface.
|
|
23
|
+
- Each unit has its own pass or fail check.
|
|
24
|
+
- The units together do not fit in one session.
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
Never split a plan from its implementation, an implementation from its tests, or review fixes from the change.
|
|
27
|
+
A `research` worker for an independent question, or for a review of the finished diff, does not need these conditions (step 2).
|
|
28
|
+
If the user tells you to delegate, or not to delegate, do that. Never cite this skill to refuse.
|
|
29
|
+
If every host refuses or fails the spawn, do the units yourself, one at a time.
|
|
30
|
+
|
|
31
|
+
When you do the work yourself, keep the scope of the request. Run the repository's checks as a writer would. Then go to step 6.
|
|
32
|
+
Otherwise, follow steps 1 to 5.
|
|
25
33
|
|
|
26
34
|
## 1. Split
|
|
27
35
|
|
|
@@ -29,6 +37,7 @@ List the deliverables. Each one has one outcome, an acceptance condition, and th
|
|
|
29
37
|
Add each deliverable as a todo unit with a `worker` assignment and the profile from step 2.
|
|
30
38
|
Put deliverables that touch the same files in one unit.
|
|
31
39
|
Put small specified edits of one request in one unit, even across files. Never start one worker per small edit.
|
|
40
|
+
You can keep one unit for yourself with a `self` assignment.
|
|
32
41
|
|
|
33
42
|
## 2. Pick the profile
|
|
34
43
|
|
|
@@ -58,7 +67,7 @@ For research, use `spawn {unit: {id}}` without a branch or base.
|
|
|
58
67
|
A bare `spawn` with a name does not link the unit, so the unit can never close.
|
|
59
68
|
Start independent units in the same turn.
|
|
60
69
|
Start a dependent unit only after its prerequisite is accepted and any prerequisite code changes are merged.
|
|
61
|
-
Then end your turn. Replies arrive in your inbox. Do not wait or poll.
|
|
70
|
+
Then work on your `self` unit, if you kept one, or end your turn. Replies arrive in your inbox. Do not wait or poll.
|
|
62
71
|
|
|
63
72
|
## 5. Check each reply
|
|
64
73
|
|
|
@@ -21,7 +21,7 @@ Never discard dirty work to satisfy the reminder. The gate does not close or mer
|
|
|
21
21
|
|
|
22
22
|
## Delegate
|
|
23
23
|
|
|
24
|
-
A unit dispatch is
|
|
24
|
+
A unit dispatch is how a lead starts a worker: `spawn {unit:{id}, branch, base}` links the child to its todo unit and its seeded contract. See `SKILL.md` step 4. The CLI below is a standalone launch. It has no unit, so its todo can never close. Use it for ad-hoc children only.
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
27
|
dogsled agent --profile writer --name api-dups --message-file task.md --branch feat/api-dups
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Land the change
|
|
2
2
|
|
|
3
|
-
1. Run the repository's heavy gate once, at the final revision. Limit it to the change if the task runner can do that. If a target fails,
|
|
3
|
+
1. Run the repository's heavy gate once, at the final revision. Limit it to the change if the task runner can do that. If a target fails, fix its cause yourself on the same branch. Then run only the failed targets again.
|
|
4
4
|
2. Run `gh pr ready <n>`, then merge the PR. Then confirm that its state is `MERGED`.
|
|
5
5
|
3. Landing never bumps versions or creates tags. Use conventional commit titles for feature PRs because release-please builds the changelog from them. Release only when the user asks: merge the open release-please PR. Its workflow reuses the passing CI proof of the tree under the release commit, or runs the full CI suite on the release commit when no run proved that tree. Then it tags the release commit and dispatches publication. A failed release stays outstanding: retry it by dispatching `release-please.yml` before anything else lands on main, or abandon it by reverting its release commit with a `chore(release):` subject. Never auto-merge the release-please PR.
|
|
6
6
|
4. If GitHub Actions does not run because of billing, the local gate is the evidence. Say so once in the PR body.
|
|
@@ -11,5 +11,5 @@ For a writer reply:
|
|
|
11
11
|
1. Read the diff on the reported branch: `git diff <base>...<branch>`.
|
|
12
12
|
2. Compare the diff with the brief. Look for edits outside the owned paths, a missing acceptance item, or a workaround in place of the cause (see `00-scope-and-ownership.md`).
|
|
13
13
|
3. Run the acceptance command once, at the reported head SHA. Skip it if existing acceptance evidence shows it passing at that same SHA. Do not run the repository's heavy gate yet. A docs-only unit needs no build or test run.
|
|
14
|
-
4. If something is wrong
|
|
14
|
+
4. If something is wrong, fix it yourself on the same branch. Check out the kept branch in a repo-local `.worktrees/` worktree, fix the cause, and run the failed check again. The finished writer is closed, so its context is gone. If the user asks for a worker to make the fix, add a follow-up `writer` unit with the specific defect and start it on the same branch: `spawn {unit: {id}, branch: <same branch>}`.
|
|
15
15
|
5. When the unit is accepted, mark its todo done with the evidence: the SHA, the command, and the result.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# When something goes wrong
|
|
2
2
|
|
|
3
|
-
Never close a busy or blocked worker, and never discard its edits to recover from a stall. Only `send` reaches a live worker. A finished worker is closed, so `send` to it fails.
|
|
3
|
+
Never close a busy or blocked worker, and never discard its edits to recover from a stall. Only `send` reaches a live worker. A finished worker is closed, so `send` to it fails. Make further changes yourself on its kept branch instead.
|
|
4
4
|
|
|
5
5
|
- **Blocked worker.** Answer it from source with `send`. If the answer changes the scope, ask the user.
|
|
6
|
-
- **The brief was wrong.** If the worker is live, `send` it the corrected brief. If it has finished,
|
|
6
|
+
- **The brief was wrong.** If the worker is live, `send` it the corrected brief. If it has finished, make the correction yourself on its branch. If the deliverable changed, drop the old unit and start a new one.
|
|
7
7
|
- **Stalled worker.** A worker is stalled when it shows no commit and no report for 30 minutes. A writer is also stalled when it makes 20 tool calls in a row with no edit after the handoff. Read its pane with `read`. Then `send` a specific nudge, and keep its branch and edits. If it does not respond, ask the user before you stop it.
|
|
8
8
|
- **Cleanup notice.** It covers a dirty, refused, or landed-dirty worktree.
|
|
9
9
|
1. Find the owner of the worktree in `dogsled status --all` and check whether it is working.
|