@howaboua/pi-agent-board 0.0.4 → 0.0.6
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/CHANGELOG.md +15 -0
- package/README.md +3 -1
- package/dist/viewer/archive.js +24 -17
- package/dist/viewer/web/posts.js +0 -1
- package/index.ts +5 -69
- package/package.json +15 -14
- package/runtime.ts +2 -0
- package/scripts/build-viewer.mjs +9 -0
- package/src/board/AGENTS.md +12 -0
- package/src/{archive.ts → board/archive.ts} +17 -7
- package/src/{awareness.ts → board/awareness.ts} +6 -11
- package/src/board/briefing.ts +25 -0
- package/src/{contract.ts → board/contract.ts} +39 -29
- package/src/board/feature.ts +91 -0
- package/src/{identity.ts → board/identity.ts} +121 -37
- package/src/{integration.ts → board/integration.ts} +1 -0
- package/src/board/protocol.ts +117 -0
- package/src/{queries.ts → board/queries.ts} +9 -11
- package/src/{response.ts → board/response.ts} +7 -1
- package/src/board/runtime/activation.ts +50 -0
- package/src/{runtime → board/runtime}/coordinator.ts +76 -43
- package/src/board/runtime/engine.ts +40 -0
- package/src/board/runtime/index.ts +63 -0
- package/src/{runtime → board/runtime}/owner.ts +44 -15
- package/src/{runtime → board/runtime}/routing.ts +19 -4
- package/src/{runtime → board/runtime}/turns.ts +9 -1
- package/src/{search.ts → board/search.ts} +11 -9
- package/src/board/settings/panel.ts +193 -0
- package/src/{store.ts → board/store.ts} +45 -9
- package/src/{summarizer.ts → board/summarizer.ts} +3 -2
- package/src/{tool.ts → board/tool.ts} +5 -0
- package/src/board/viewer/AGENTS.md +1 -0
- package/src/{viewer → board/viewer}/archive.ts +24 -17
- package/src/{viewer → board/viewer}/index.ts +5 -1
- package/src/{viewer → board/viewer}/web/posts.js +0 -1
- package/src/guidance.ts +121 -0
- package/src/settings-navigation.ts +11 -0
- package/src/timestamps.ts +3 -0
- package/tsconfig.json +6 -2
- package/tsconfig.viewer.json +11 -0
- package/changelog.ts +0 -337
- package/src/briefing.ts +0 -32
- package/src/protocol.ts +0 -78
- package/src/runtime/index.ts +0 -113
- package/src/settings/panel.ts +0 -87
- /package/src/{activity.ts → board/activity.ts} +0 -0
- /package/src/{config.ts → board/config.ts} +0 -0
- /package/src/{consolidation.ts → board/consolidation.ts} +0 -0
- /package/src/{context-briefing.ts → board/context-briefing.ts} +0 -0
- /package/src/{delivery.ts → board/delivery.ts} +0 -0
- /package/src/{paging.ts → board/paging.ts} +0 -0
- /package/src/{runtime → board/runtime}/catchup.ts +0 -0
- /package/src/{summaries.ts → board/summaries.ts} +0 -0
- /package/src/{viewer → board/viewer}/config.ts +0 -0
- /package/src/{viewer → board/viewer}/contracts.ts +0 -0
- /package/src/{viewer → board/viewer}/server.ts +0 -0
- /package/src/{viewer → board/viewer}/source.ts +0 -0
- /package/src/{viewer → board/viewer}/web/app.js +0 -0
- /package/src/{viewer → board/viewer}/web/index.html +0 -0
- /package/src/{viewer → board/viewer}/web/navigation.js +0 -0
- /package/src/{viewer → board/viewer}/web/render.js +0 -0
- /package/src/{viewer → board/viewer}/web/session.js +0 -0
- /package/src/{viewer → board/viewer}/web/style.css +0 -0
- /package/src/{viewer → board/viewer}/web/updates.js +0 -0
package/changelog.ts
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
// Generated extension packages copy this file during changelog:extensions.
|
|
2
|
-
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
|
-
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
import {
|
|
9
|
-
DynamicBorder,
|
|
10
|
-
type ExtensionAPI,
|
|
11
|
-
getAgentDir,
|
|
12
|
-
getMarkdownTheme,
|
|
13
|
-
} from "@earendil-works/pi-coding-agent";
|
|
14
|
-
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
15
|
-
|
|
16
|
-
const ENTRY_TYPE = "@howaboua/pi-stuff/changelog";
|
|
17
|
-
const REGISTRATION_CHANNEL = "@howaboua/pi-stuff/changelog/register/v1";
|
|
18
|
-
const STATE_FILENAME = "howaboua-pi-stuff-changelog.json";
|
|
19
|
-
const SUPPRESS_KEY = "suppress";
|
|
20
|
-
const LOCK_STALE_MS = 30_000;
|
|
21
|
-
const LOCK_TIMEOUT_MS = 2_000;
|
|
22
|
-
|
|
23
|
-
interface PackageMetadata {
|
|
24
|
-
name: string;
|
|
25
|
-
version: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface PackageRegistration extends PackageMetadata {
|
|
29
|
-
changelogPath: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface RegistrationEvent {
|
|
33
|
-
accept: () => void;
|
|
34
|
-
registration: PackageRegistration;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface ChangelogEntry {
|
|
38
|
-
content: string;
|
|
39
|
-
version: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface ChangelogEntryData {
|
|
43
|
-
markdown: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type ChangelogState = Record<string, boolean | string>;
|
|
47
|
-
|
|
48
|
-
function packageRegistration(): PackageRegistration {
|
|
49
|
-
const packageDirectory = fileURLToPath(new URL(".", import.meta.url));
|
|
50
|
-
const metadata = JSON.parse(
|
|
51
|
-
readFileSync(join(packageDirectory, "package.json"), "utf8"),
|
|
52
|
-
) as Partial<PackageMetadata>;
|
|
53
|
-
if (typeof metadata.name !== "string" || typeof metadata.version !== "string")
|
|
54
|
-
throw new Error(`Invalid package metadata in ${packageDirectory}`);
|
|
55
|
-
return {
|
|
56
|
-
name: metadata.name,
|
|
57
|
-
version: metadata.version,
|
|
58
|
-
changelogPath: join(packageDirectory, "CHANGELOG.md"),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function isRegistrationEvent(value: unknown): value is RegistrationEvent {
|
|
63
|
-
if (!value || typeof value !== "object") return false;
|
|
64
|
-
const event = value as Partial<RegistrationEvent>;
|
|
65
|
-
return (
|
|
66
|
-
typeof event.accept === "function" &&
|
|
67
|
-
typeof event.registration?.name === "string" &&
|
|
68
|
-
typeof event.registration.version === "string" &&
|
|
69
|
-
typeof event.registration.changelogPath === "string"
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function parseChangelog(markdown: string): ChangelogEntry[] {
|
|
74
|
-
const entries: ChangelogEntry[] = [];
|
|
75
|
-
let currentLines: string[] = [];
|
|
76
|
-
let currentVersion: string | undefined;
|
|
77
|
-
|
|
78
|
-
for (const line of markdown.split("\n")) {
|
|
79
|
-
const version = line.match(/^##\s+\[?(\d+\.\d+\.\d+)\]?(?:\s.*)?$/)?.[1];
|
|
80
|
-
if (version) {
|
|
81
|
-
if (currentVersion)
|
|
82
|
-
entries.push({
|
|
83
|
-
content: currentLines.join("\n").trim(),
|
|
84
|
-
version: currentVersion,
|
|
85
|
-
});
|
|
86
|
-
currentVersion = version;
|
|
87
|
-
currentLines = [line];
|
|
88
|
-
} else if (currentVersion) {
|
|
89
|
-
currentLines.push(line);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (currentVersion)
|
|
94
|
-
entries.push({
|
|
95
|
-
content: currentLines.join("\n").trim(),
|
|
96
|
-
version: currentVersion,
|
|
97
|
-
});
|
|
98
|
-
return entries;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function compareVersions(left: string, right: string): number {
|
|
102
|
-
const leftParts = left.split(".").map(Number);
|
|
103
|
-
const rightParts = right.split(".").map(Number);
|
|
104
|
-
for (let index = 0; index < 3; index++) {
|
|
105
|
-
const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
|
|
106
|
-
if (difference !== 0) return difference;
|
|
107
|
-
}
|
|
108
|
-
return 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isStableVersion(version: string): boolean {
|
|
112
|
-
return /^\d+\.\d+\.\d+$/.test(version);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function statePath(): string {
|
|
116
|
-
return join(getAgentDir(), STATE_FILENAME);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function readState(path: string): Promise<ChangelogState> {
|
|
120
|
-
let text: string;
|
|
121
|
-
try {
|
|
122
|
-
text = await readFile(path, "utf8");
|
|
123
|
-
} catch (error) {
|
|
124
|
-
if ((error as NodeJS.ErrnoException).code === "ENOENT") return {};
|
|
125
|
-
throw error;
|
|
126
|
-
}
|
|
127
|
-
const parsed = JSON.parse(text) as unknown;
|
|
128
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
129
|
-
throw new Error(`${path} must contain a JSON object`);
|
|
130
|
-
for (const [name, value] of Object.entries(parsed)) {
|
|
131
|
-
if (name === SUPPRESS_KEY) {
|
|
132
|
-
if (typeof value !== "boolean")
|
|
133
|
-
throw new Error(`${path} ${SUPPRESS_KEY} must be a boolean`);
|
|
134
|
-
} else if (typeof value !== "string") {
|
|
135
|
-
throw new Error(`${path} version for ${name} must be a string`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return parsed as ChangelogState;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
async function acquireLock(path: string): Promise<() => Promise<void>> {
|
|
142
|
-
const deadline = Date.now() + LOCK_TIMEOUT_MS;
|
|
143
|
-
while (true) {
|
|
144
|
-
try {
|
|
145
|
-
await mkdir(path);
|
|
146
|
-
return () => rm(path, { force: true, recursive: true });
|
|
147
|
-
} catch (error) {
|
|
148
|
-
if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
|
|
149
|
-
const info = await stat(path).catch(() => undefined);
|
|
150
|
-
if (info && Date.now() - info.mtimeMs > LOCK_STALE_MS) {
|
|
151
|
-
await rm(path, { force: true, recursive: true });
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
if (Date.now() >= deadline)
|
|
155
|
-
throw new Error(`Timed out waiting for ${path}`);
|
|
156
|
-
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function writeState(path: string, state: ChangelogState): Promise<void> {
|
|
162
|
-
await mkdir(dirname(path), { mode: 0o700, recursive: true });
|
|
163
|
-
const temporaryPath = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
164
|
-
try {
|
|
165
|
-
const ordered = Object.fromEntries(
|
|
166
|
-
Object.entries(state).sort(([left], [right]) =>
|
|
167
|
-
left.localeCompare(right),
|
|
168
|
-
),
|
|
169
|
-
);
|
|
170
|
-
await writeFile(temporaryPath, `${JSON.stringify(ordered, null, 2)}\n`, {
|
|
171
|
-
encoding: "utf8",
|
|
172
|
-
mode: 0o600,
|
|
173
|
-
});
|
|
174
|
-
await rename(temporaryPath, path);
|
|
175
|
-
} catch (error) {
|
|
176
|
-
await rm(temporaryPath, { force: true });
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function packageMarkdown(
|
|
182
|
-
registration: PackageRegistration,
|
|
183
|
-
entries: ChangelogEntry[],
|
|
184
|
-
): string {
|
|
185
|
-
const body = (entry: ChangelogEntry) =>
|
|
186
|
-
entry.content
|
|
187
|
-
.replace(/^##[^\n]*\n*/, "")
|
|
188
|
-
.replace(/^###\s+(?:Changes|Minor Changes|Patch Changes)\s*\n*/gim, "")
|
|
189
|
-
.replace(/^###\s+(.+)$/gm, "**$1**");
|
|
190
|
-
if (entries.length === 1) {
|
|
191
|
-
const [entry] = entries;
|
|
192
|
-
if (!entry) return "";
|
|
193
|
-
return `## ${registration.name} ${entry.version}\n\n${body(entry)}`;
|
|
194
|
-
}
|
|
195
|
-
return [
|
|
196
|
-
`## ${registration.name}`,
|
|
197
|
-
...entries.map((entry) => `**${entry.version}**\n\n${body(entry)}`),
|
|
198
|
-
].join("\n\n");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async function claimUpdates(
|
|
202
|
-
registrations: Iterable<PackageRegistration>,
|
|
203
|
-
): Promise<{ errors: string[]; markdown?: string }> {
|
|
204
|
-
const stableRegistrations = [...registrations]
|
|
205
|
-
.filter((registration) => isStableVersion(registration.version))
|
|
206
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
207
|
-
if (stableRegistrations.length === 0) return { errors: [] };
|
|
208
|
-
const path = statePath();
|
|
209
|
-
await mkdir(dirname(path), { mode: 0o700, recursive: true });
|
|
210
|
-
const release = await acquireLock(`${path}.lock`);
|
|
211
|
-
try {
|
|
212
|
-
const state = await readState(path);
|
|
213
|
-
const errors: string[] = [];
|
|
214
|
-
const sections: string[] = [];
|
|
215
|
-
let changed = false;
|
|
216
|
-
if (state[SUPPRESS_KEY] === true) {
|
|
217
|
-
for (const registration of stableRegistrations) {
|
|
218
|
-
const seenVersion = state[registration.name];
|
|
219
|
-
if (
|
|
220
|
-
typeof seenVersion !== "string" ||
|
|
221
|
-
compareVersions(registration.version, seenVersion) > 0
|
|
222
|
-
) {
|
|
223
|
-
state[registration.name] = registration.version;
|
|
224
|
-
changed = true;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
if (changed) await writeState(path, state);
|
|
228
|
-
return { errors };
|
|
229
|
-
}
|
|
230
|
-
for (const registration of stableRegistrations) {
|
|
231
|
-
const seenVersion = state[registration.name];
|
|
232
|
-
if (
|
|
233
|
-
typeof seenVersion === "string" &&
|
|
234
|
-
compareVersions(registration.version, seenVersion) <= 0
|
|
235
|
-
)
|
|
236
|
-
continue;
|
|
237
|
-
try {
|
|
238
|
-
const entries = parseChangelog(
|
|
239
|
-
await readFile(registration.changelogPath, "utf8"),
|
|
240
|
-
).filter(
|
|
241
|
-
(entry) =>
|
|
242
|
-
compareVersions(entry.version, registration.version) <= 0 &&
|
|
243
|
-
(typeof seenVersion === "string"
|
|
244
|
-
? compareVersions(entry.version, seenVersion) > 0
|
|
245
|
-
: entry.version === registration.version),
|
|
246
|
-
);
|
|
247
|
-
if (entries.length === 0) {
|
|
248
|
-
errors.push(
|
|
249
|
-
`No ${registration.version} changelog entry found for ${registration.name}`,
|
|
250
|
-
);
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
sections.push(packageMarkdown(registration, entries));
|
|
254
|
-
state[registration.name] = registration.version;
|
|
255
|
-
changed = true;
|
|
256
|
-
} catch (error) {
|
|
257
|
-
errors.push(
|
|
258
|
-
`Could not read the ${registration.name} changelog: ${error instanceof Error ? error.message : String(error)}`,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
if (changed) await writeState(path, state);
|
|
263
|
-
return {
|
|
264
|
-
errors,
|
|
265
|
-
...(sections.length > 0 ? { markdown: sections.join("\n\n") } : {}),
|
|
266
|
-
};
|
|
267
|
-
} finally {
|
|
268
|
-
await release();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function registerCoordinator(
|
|
273
|
-
pi: ExtensionAPI,
|
|
274
|
-
registration: PackageRegistration,
|
|
275
|
-
): void {
|
|
276
|
-
let accepted = false;
|
|
277
|
-
pi.events.emit(REGISTRATION_CHANNEL, {
|
|
278
|
-
registration,
|
|
279
|
-
accept: () => {
|
|
280
|
-
accepted = true;
|
|
281
|
-
},
|
|
282
|
-
} satisfies RegistrationEvent);
|
|
283
|
-
if (accepted) return;
|
|
284
|
-
|
|
285
|
-
const registrations = new Map([[registration.name, registration]]);
|
|
286
|
-
pi.events.on(REGISTRATION_CHANNEL, (value) => {
|
|
287
|
-
if (!isRegistrationEvent(value)) return;
|
|
288
|
-
registrations.set(value.registration.name, value.registration);
|
|
289
|
-
value.accept();
|
|
290
|
-
});
|
|
291
|
-
pi.registerEntryRenderer<ChangelogEntryData>(
|
|
292
|
-
ENTRY_TYPE,
|
|
293
|
-
(entry, _options, theme) => {
|
|
294
|
-
if (!entry.data) return undefined;
|
|
295
|
-
const container = new Container();
|
|
296
|
-
container.addChild(new DynamicBorder());
|
|
297
|
-
container.addChild(
|
|
298
|
-
new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0),
|
|
299
|
-
);
|
|
300
|
-
container.addChild(new Spacer(1));
|
|
301
|
-
container.addChild(
|
|
302
|
-
new Markdown(entry.data.markdown.trim(), 1, 0, getMarkdownTheme()),
|
|
303
|
-
);
|
|
304
|
-
container.addChild(new Spacer(1));
|
|
305
|
-
container.addChild(new DynamicBorder());
|
|
306
|
-
return container;
|
|
307
|
-
},
|
|
308
|
-
);
|
|
309
|
-
pi.on("session_start", async (event, ctx) => {
|
|
310
|
-
if (event.reason === "reload" || ctx.mode !== "tui") return;
|
|
311
|
-
if (
|
|
312
|
-
ctx.sessionManager
|
|
313
|
-
.getEntries()
|
|
314
|
-
.some((entry) =>
|
|
315
|
-
["branch_summary", "compaction", "message"].includes(entry.type),
|
|
316
|
-
)
|
|
317
|
-
)
|
|
318
|
-
return;
|
|
319
|
-
try {
|
|
320
|
-
const update = await claimUpdates(registrations.values());
|
|
321
|
-
if (update.markdown)
|
|
322
|
-
pi.appendEntry<ChangelogEntryData>(ENTRY_TYPE, {
|
|
323
|
-
markdown: update.markdown,
|
|
324
|
-
});
|
|
325
|
-
for (const error of update.errors) ctx.ui.notify(error, "warning");
|
|
326
|
-
} catch (error) {
|
|
327
|
-
ctx.ui.notify(
|
|
328
|
-
`Could not update Howaboua changelog state: ${error instanceof Error ? error.message : String(error)}`,
|
|
329
|
-
"warning",
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export default function howabouaPackageChangelog(pi: ExtensionAPI): void {
|
|
336
|
-
registerCoordinator(pi, packageRegistration());
|
|
337
|
-
}
|
package/src/briefing.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export function boardBriefing(
|
|
2
|
-
member: boolean,
|
|
3
|
-
population: "empty" | "populated" | "unavailable",
|
|
4
|
-
gpt = false,
|
|
5
|
-
) {
|
|
6
|
-
const state =
|
|
7
|
-
population === "populated"
|
|
8
|
-
? "Read relevant board threads."
|
|
9
|
-
: population === "empty"
|
|
10
|
-
? gpt
|
|
11
|
-
? "Shared board available; posts=none."
|
|
12
|
-
: "Shared board available; no posts yet."
|
|
13
|
-
: gpt
|
|
14
|
-
? "Shared board status unavailable; board help→retry read when available."
|
|
15
|
-
: "Shared board status unavailable. Check board help and retry reading when available.";
|
|
16
|
-
return [
|
|
17
|
-
state,
|
|
18
|
-
member
|
|
19
|
-
? gpt
|
|
20
|
-
? "Root owns setup; follow assigned task."
|
|
21
|
-
: "The root agent owns setup; follow your assigned task."
|
|
22
|
-
: "",
|
|
23
|
-
gpt
|
|
24
|
-
? "Posts=work-changing ownership/decisions/findings/blockers only. Existing thread replies; link≠repeat. Personal checkpoints→notes. No ack/status spam/duplicate completion reports."
|
|
25
|
-
: "Post only new information that changes another agent's work: ownership, decisions, findings or blockers. Reply in existing threads; link rather than repeat. Keep personal checkpoints in notes. Skip acknowledgements, routine status and duplicated completion reports.",
|
|
26
|
-
gpt
|
|
27
|
-
? "Channels=workstreams; threads=topics. Reuse relevant channels≠catchalls. New channel requires distinct coordination purpose; never task/result announcement only."
|
|
28
|
-
: "Channels group shared workstreams; threads group topics. Reuse a relevant channel, not a catch-all. Create a channel only for a distinct coordination need, never just to announce a task or result.",
|
|
29
|
-
]
|
|
30
|
-
.filter(Boolean)
|
|
31
|
-
.join(" ");
|
|
32
|
-
}
|
package/src/protocol.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Type } from "@earendil-works/pi-ai";
|
|
2
|
-
import type { Static } from "typebox";
|
|
3
|
-
import { Check } from "typebox/value";
|
|
4
|
-
import { BindingSchema } from "./identity.js";
|
|
5
|
-
|
|
6
|
-
const NoticeSchema = Type.Object(
|
|
7
|
-
{
|
|
8
|
-
message_id: Type.String(),
|
|
9
|
-
channel_name: Type.String(),
|
|
10
|
-
author: Type.String(),
|
|
11
|
-
thread_id: Type.String(),
|
|
12
|
-
created_at: Type.String(),
|
|
13
|
-
text_preview: Type.String({ maxLength: 300 }),
|
|
14
|
-
n_chars: Type.Integer({ minimum: 0 }),
|
|
15
|
-
truncated: Type.Boolean(),
|
|
16
|
-
},
|
|
17
|
-
{ additionalProperties: false },
|
|
18
|
-
);
|
|
19
|
-
const Protocol = Type.Union([
|
|
20
|
-
Type.Object({
|
|
21
|
-
operation: Type.Literal("board-catchup"),
|
|
22
|
-
caller: BindingSchema,
|
|
23
|
-
seen: Type.Array(Type.String()),
|
|
24
|
-
}),
|
|
25
|
-
Type.Object({
|
|
26
|
-
operation: Type.Literal("board-bind"),
|
|
27
|
-
binding: BindingSchema,
|
|
28
|
-
}),
|
|
29
|
-
Type.Object({
|
|
30
|
-
operation: Type.Literal("board-register"),
|
|
31
|
-
caller: BindingSchema,
|
|
32
|
-
member: BindingSchema,
|
|
33
|
-
}),
|
|
34
|
-
Type.Object({
|
|
35
|
-
operation: Type.Literal("board-unregister"),
|
|
36
|
-
caller: BindingSchema,
|
|
37
|
-
member: BindingSchema,
|
|
38
|
-
}),
|
|
39
|
-
Type.Object({
|
|
40
|
-
operation: Type.Literal("board-enabled"),
|
|
41
|
-
boardId: Type.String(),
|
|
42
|
-
enabled: Type.Boolean(),
|
|
43
|
-
}),
|
|
44
|
-
Type.Object({
|
|
45
|
-
operation: Type.Literal("board-active"),
|
|
46
|
-
caller: BindingSchema,
|
|
47
|
-
turnId: Type.Union([Type.String(), Type.Null()]),
|
|
48
|
-
previousTurnId: Type.Optional(Type.String()),
|
|
49
|
-
}),
|
|
50
|
-
Type.Object({
|
|
51
|
-
operation: Type.Literal("board-call"),
|
|
52
|
-
caller: BindingSchema,
|
|
53
|
-
params: Type.Unknown(),
|
|
54
|
-
requestId: Type.String(),
|
|
55
|
-
}),
|
|
56
|
-
Type.Object({
|
|
57
|
-
operation: Type.Literal("board-notify"),
|
|
58
|
-
boardId: Type.String(),
|
|
59
|
-
target: Type.String(),
|
|
60
|
-
sessionId: Type.String(),
|
|
61
|
-
turnId: Type.String(),
|
|
62
|
-
notice: NoticeSchema,
|
|
63
|
-
}),
|
|
64
|
-
]);
|
|
65
|
-
export type BoardEnvelope = Static<typeof Protocol>;
|
|
66
|
-
export function parseEnvelope(value: unknown): BoardEnvelope {
|
|
67
|
-
if (!Check(Protocol, value)) throw new Error("Invalid board host request");
|
|
68
|
-
return value as BoardEnvelope;
|
|
69
|
-
}
|
|
70
|
-
export function isBoardEnvelope(value: unknown): boolean {
|
|
71
|
-
return (
|
|
72
|
-
!!value &&
|
|
73
|
-
typeof value === "object" &&
|
|
74
|
-
"operation" in value &&
|
|
75
|
-
typeof value.operation === "string" &&
|
|
76
|
-
value.operation.startsWith("board-")
|
|
77
|
-
);
|
|
78
|
-
}
|
package/src/runtime/index.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { registerBoardActivityRenderer } from "../activity.js";
|
|
3
|
-
import { initializeDelivery, isMissingOptionalModule } from "../delivery.js";
|
|
4
|
-
import { createBoardTool } from "../tool.js";
|
|
5
|
-
import { BoardRuntime } from "./coordinator.js";
|
|
6
|
-
|
|
7
|
-
export { BoardRuntime };
|
|
8
|
-
|
|
9
|
-
const CLAIM = "@howaboua/pi-agent-board.owner/v1";
|
|
10
|
-
const AVAILABLE = "@howaboua/pi-agent-board.available/v1";
|
|
11
|
-
interface OwnerClaim {
|
|
12
|
-
runtime: Promise<BoardRuntime>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** Discover an explicitly loaded owner, including one loaded after this adapter. */
|
|
16
|
-
export function discoverBoard(
|
|
17
|
-
pi: ExtensionAPI,
|
|
18
|
-
attach: (runtime: BoardRuntime) => void,
|
|
19
|
-
) {
|
|
20
|
-
let attached = false;
|
|
21
|
-
const accept = (runtime: BoardRuntime) => {
|
|
22
|
-
if (attached) return;
|
|
23
|
-
attached = true;
|
|
24
|
-
attach(runtime);
|
|
25
|
-
};
|
|
26
|
-
const request = () =>
|
|
27
|
-
pi.events.emit(CLAIM, {
|
|
28
|
-
accept: (claim: OwnerClaim) => {
|
|
29
|
-
void claim.runtime.then(accept);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
const stop = pi.events.on(AVAILABLE, request);
|
|
33
|
-
request();
|
|
34
|
-
pi.on("session_shutdown", stop);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Only the standalone extension creates and registers the board engine. */
|
|
38
|
-
export async function acquireBoard(pi: ExtensionAPI): Promise<BoardRuntime> {
|
|
39
|
-
let claim: OwnerClaim | undefined;
|
|
40
|
-
pi.events.emit(CLAIM, {
|
|
41
|
-
accept(value: OwnerClaim) {
|
|
42
|
-
claim = value;
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
if (!claim) {
|
|
46
|
-
const created: OwnerClaim = {
|
|
47
|
-
runtime: createRuntime(pi),
|
|
48
|
-
};
|
|
49
|
-
claim = created;
|
|
50
|
-
const stop = pi.events.on(CLAIM, (value) => {
|
|
51
|
-
if (
|
|
52
|
-
value &&
|
|
53
|
-
typeof value === "object" &&
|
|
54
|
-
"accept" in value &&
|
|
55
|
-
typeof value.accept === "function"
|
|
56
|
-
)
|
|
57
|
-
value.accept(created);
|
|
58
|
-
});
|
|
59
|
-
pi.on("session_shutdown", stop);
|
|
60
|
-
}
|
|
61
|
-
const runtime = await claim.runtime;
|
|
62
|
-
pi.events.emit(AVAILABLE, undefined);
|
|
63
|
-
return runtime;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function createRuntime(pi: ExtensionAPI) {
|
|
67
|
-
await initializeDelivery();
|
|
68
|
-
const runtime = new BoardRuntime(pi);
|
|
69
|
-
const tool = createBoardTool(runtime);
|
|
70
|
-
pi.registerTool(tool);
|
|
71
|
-
try {
|
|
72
|
-
const { registerGptPromptMode, prepareGptPromptMode } = await import(
|
|
73
|
-
"@howaboua/pi-codex-conversion/prompt-mode"
|
|
74
|
-
);
|
|
75
|
-
runtime.setPromptModePreparation((ctx) => prepareGptPromptMode(pi, ctx));
|
|
76
|
-
registerGptPromptMode(pi, (active) => {
|
|
77
|
-
runtime.gptPromptMode = active;
|
|
78
|
-
return [tool];
|
|
79
|
-
});
|
|
80
|
-
} catch (error) {
|
|
81
|
-
if (!isMissingOptionalModule(error, "prompt-mode")) throw error;
|
|
82
|
-
}
|
|
83
|
-
registerBoardActivityRenderer(pi);
|
|
84
|
-
try {
|
|
85
|
-
const { adaptToolForCodeMode, registerCodeModeExtensionTools } =
|
|
86
|
-
await import("@howaboua/pi-codex-conversion/code-mode");
|
|
87
|
-
const registration = registerCodeModeExtensionTools(
|
|
88
|
-
pi,
|
|
89
|
-
() => [
|
|
90
|
-
adaptToolForCodeMode(tool, {
|
|
91
|
-
prepareInput: (input) =>
|
|
92
|
-
input === undefined || input === null ? {} : input,
|
|
93
|
-
discovery: "help",
|
|
94
|
-
}),
|
|
95
|
-
],
|
|
96
|
-
{ isActive: (ctx) => runtime.enabled(ctx) },
|
|
97
|
-
);
|
|
98
|
-
runtime.setToolRefresh(() => registration.refresh());
|
|
99
|
-
pi.on("session_shutdown", () => registration.unregister());
|
|
100
|
-
} catch (error) {
|
|
101
|
-
if (!isMissingOptionalModule(error, "code-mode")) throw error;
|
|
102
|
-
if (
|
|
103
|
-
error instanceof Error &&
|
|
104
|
-
"code" in error &&
|
|
105
|
-
error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED"
|
|
106
|
-
)
|
|
107
|
-
throw new Error(
|
|
108
|
-
"Update Codex Conversion to use its Code and Notebook board tools",
|
|
109
|
-
{ cause: error },
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
return runtime;
|
|
113
|
-
}
|
package/src/settings/panel.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExtensionAPI,
|
|
3
|
-
ExtensionContext,
|
|
4
|
-
} from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import {
|
|
6
|
-
readBoardSummaryConfig,
|
|
7
|
-
resolveBoardSummaryModel,
|
|
8
|
-
writeBoardSummarySelection,
|
|
9
|
-
} from "../config.js";
|
|
10
|
-
import { requestBoardConsolidation } from "../consolidation.js";
|
|
11
|
-
import { binding } from "../identity.js";
|
|
12
|
-
import type { BoardRuntime } from "../runtime/coordinator.js";
|
|
13
|
-
|
|
14
|
-
export async function openBoardSettings(
|
|
15
|
-
pi: ExtensionAPI,
|
|
16
|
-
ctx: ExtensionContext,
|
|
17
|
-
board: BoardRuntime,
|
|
18
|
-
) {
|
|
19
|
-
if (!ctx.hasUI) {
|
|
20
|
-
ctx.ui.notify("Use /board settings in an interactive session", "warning");
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
if (binding(ctx).upstream)
|
|
25
|
-
throw new Error("Change Board settings in the owning root session");
|
|
26
|
-
const sessionId = ctx.sessionManager.getSessionId();
|
|
27
|
-
const consolidate =
|
|
28
|
-
"Consolidate one-off threads (sends a prompt to this session's agent)";
|
|
29
|
-
const setting = await ctx.ui.select("Board settings and actions", [
|
|
30
|
-
"Automatic summaries",
|
|
31
|
-
"Summary model",
|
|
32
|
-
consolidate,
|
|
33
|
-
]);
|
|
34
|
-
if (setting === consolidate) {
|
|
35
|
-
if (ctx.sessionManager.getSessionId() !== sessionId)
|
|
36
|
-
throw new Error("Session changed; reopen Board settings");
|
|
37
|
-
requestBoardConsolidation(pi, ctx);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!setting) return;
|
|
41
|
-
const config = readBoardSummaryConfig(ctx.cwd);
|
|
42
|
-
if (setting === "Automatic summaries") {
|
|
43
|
-
const selected = await ctx.ui.select(
|
|
44
|
-
`Automatic summaries: ${config.automatic ? "on" : "off"}. Summarise on closure? Uses model quota.`,
|
|
45
|
-
["Off", "On"],
|
|
46
|
-
);
|
|
47
|
-
if (selected !== "Off" && selected !== "On") return;
|
|
48
|
-
board.setAutomaticSummaries(ctx, selected === "On");
|
|
49
|
-
ctx.ui.notify(
|
|
50
|
-
`Automatic board summaries: ${selected.toLowerCase()}.`,
|
|
51
|
-
"info",
|
|
52
|
-
);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (setting !== "Summary model") return;
|
|
56
|
-
const selected = await ctx.ui.select(
|
|
57
|
-
`Board summary model (global; current: ${config.selection === "luna" ? "Luna" : "Custom"})`,
|
|
58
|
-
["Luna", "Custom"],
|
|
59
|
-
);
|
|
60
|
-
if (selected !== "Luna" && selected !== "Custom") return;
|
|
61
|
-
writeBoardSummarySelection(
|
|
62
|
-
ctx.cwd,
|
|
63
|
-
selected === "Luna" ? "luna" : "custom",
|
|
64
|
-
);
|
|
65
|
-
try {
|
|
66
|
-
resolveBoardSummaryModel(ctx.cwd);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
ctx.ui.notify(
|
|
69
|
-
`Custom selected. ${error instanceof Error ? error.message : String(error)}`,
|
|
70
|
-
"warning",
|
|
71
|
-
);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
ctx.ui.notify(
|
|
75
|
-
selected === "Custom"
|
|
76
|
-
? `Board summary model: Custom. Edit board.summary.custom in ${config.path}: set provider, model and reasoning.`
|
|
77
|
-
: "Board summary model: Luna (high).",
|
|
78
|
-
"info",
|
|
79
|
-
);
|
|
80
|
-
} catch (error) {
|
|
81
|
-
ctx.ui.notify(
|
|
82
|
-
error instanceof Error ? error.message : String(error),
|
|
83
|
-
"error",
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|