agent-blackboard 0.8.0 → 0.9.0
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/dist/cli/append.mjs +11 -1
- package/dist/cli/index.mjs +5 -1
- package/dist/cli/outbox.d.mts +2 -0
- package/dist/cli/outbox.mjs +60 -0
- package/dist/cli/snapshot-partition-options.d.mts +6 -0
- package/dist/cli/snapshot-partition-options.mjs +25 -0
- package/dist/cli/snapshot.mjs +3 -12
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +7 -3
- package/dist/client/append.d.mts +3 -1
- package/dist/client/append.mjs +39 -1
- package/dist/client/sessions.d.mts +2 -2
- package/dist/client/snapshot-digest-stage.d.mts +10 -0
- package/dist/client/snapshot-digest-stage.mjs +33 -0
- package/dist/client/snapshot-digest.d.mts +43 -0
- package/dist/client/snapshot-digest.mjs +130 -0
- package/dist/client/snapshot-partition-cleanup.d.mts +1 -1
- package/dist/client/snapshot-partition-copy.d.mts +1 -0
- package/dist/client/snapshot-partition-copy.mjs +8 -0
- package/dist/client/snapshot-partition-format.d.mts +1 -1
- package/dist/client/snapshot-partition-read.d.mts +3 -2
- package/dist/client/snapshot-partition-read.mjs +23 -1
- package/dist/client/snapshot-partition-write.d.mts +3 -2
- package/dist/client/snapshot-partition-write.mjs +16 -15
- package/dist/client/snapshot-partitions.d.mts +1 -1
- package/dist/client/snapshot-partitions.mjs +4 -2
- package/dist/client/snapshot-response.d.mts +1 -1
- package/dist/client/snapshot-types.d.mts +104 -0
- package/dist/client/snapshot-types.mjs +1 -0
- package/dist/client/snapshots.d.mts +2 -1
- package/dist/client/types.d.mts +24 -84
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +2 -0
- package/dist/mcp/dispatch.mjs +12 -1
- package/dist/mcp/schemas-outbox-tools.d.mts +2 -0
- package/dist/mcp/schemas-outbox-tools.mjs +45 -0
- package/dist/mcp/schemas-snapshot-tools.d.mts +2 -0
- package/dist/mcp/schemas-snapshot-tools.mjs +109 -0
- package/dist/mcp/schemas.mjs +9 -26
- package/dist/mcp/tool-append.mjs +7 -1
- package/dist/mcp/tool-outbox.d.mts +6 -0
- package/dist/mcp/tool-outbox.mjs +29 -0
- package/dist/mcp/tool-snapshot.d.mts +7 -0
- package/dist/mcp/tool-snapshot.mjs +62 -1
- package/dist/outbox/classify.d.mts +9 -0
- package/dist/outbox/classify.mjs +48 -0
- package/dist/outbox/client.d.mts +11 -0
- package/dist/outbox/client.mjs +90 -0
- package/dist/outbox/fs.d.mts +9 -0
- package/dist/outbox/fs.mjs +51 -0
- package/dist/outbox/store.d.mts +22 -0
- package/dist/outbox/store.mjs +128 -0
- package/dist/outbox/target.d.mts +10 -0
- package/dist/outbox/target.mjs +21 -0
- package/dist/outbox/types.d.mts +72 -0
- package/dist/outbox/types.mjs +1 -0
- package/dist/plugin/.claude-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.mcp.json +1 -1
- package/dist/plugin/skills/agent-blackboard/SKILL.md +26 -15
- package/dist/plugin/skills/distill/SKILL.md +120 -0
- package/dist/plugin/skills/distill/references/output-schema.md +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { rmSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { enclosingWorktreeRoot } from '../session-id/persist.mjs';
|
|
5
|
+
import { readValidatedRecords, writeJsonAtomic } from './fs.mjs';
|
|
6
|
+
export const DEFAULT_OUTBOX_RELATIVE = '.local/agent-blackboard/outbox';
|
|
7
|
+
const PENDING_DIR = 'pending';
|
|
8
|
+
const REJECTED_DIR = 'rejected';
|
|
9
|
+
function isPlainObject(value) {
|
|
10
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function isValidTarget(value) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return true;
|
|
15
|
+
return (isPlainObject(value) &&
|
|
16
|
+
typeof value.server === 'string' &&
|
|
17
|
+
(value.credentialId === undefined || typeof value.credentialId === 'string'));
|
|
18
|
+
}
|
|
19
|
+
function isPendingRecord(value) {
|
|
20
|
+
return (isPlainObject(value) &&
|
|
21
|
+
typeof value.id === 'string' &&
|
|
22
|
+
typeof value.queuedAt === 'string' &&
|
|
23
|
+
typeof value.sessionId === 'string' &&
|
|
24
|
+
isPlainObject(value.data) &&
|
|
25
|
+
typeof value.sourceEventId === 'string' &&
|
|
26
|
+
typeof value.lastError === 'string' &&
|
|
27
|
+
isValidTarget(value.target));
|
|
28
|
+
}
|
|
29
|
+
function isRejectedRecord(value) {
|
|
30
|
+
return (isPendingRecord(value) &&
|
|
31
|
+
typeof value.rejectedAt === 'string' &&
|
|
32
|
+
typeof value.error === 'string');
|
|
33
|
+
}
|
|
34
|
+
/** Resolves the worktree-scoped or overridden local outbox directory. */
|
|
35
|
+
export function resolveOutboxDir(cwd, env, explicitDir) {
|
|
36
|
+
if (explicitDir)
|
|
37
|
+
return resolve(cwd, explicitDir);
|
|
38
|
+
const envDir = env.AGENT_BLACKBOARD_OUTBOX_DIR?.trim();
|
|
39
|
+
if (envDir)
|
|
40
|
+
return resolve(cwd, envDir);
|
|
41
|
+
return join(enclosingWorktreeRoot(cwd), DEFAULT_OUTBOX_RELATIVE);
|
|
42
|
+
}
|
|
43
|
+
/** Appends a failed entry write into `<dir>/pending/` atomically. */
|
|
44
|
+
export function enqueueOutboxEntry(dir, input, lastError, now = () => new Date(), target) {
|
|
45
|
+
const id = randomUUID();
|
|
46
|
+
const timestamp = now();
|
|
47
|
+
const record = {
|
|
48
|
+
id,
|
|
49
|
+
queuedAt: timestamp.toISOString(),
|
|
50
|
+
sessionId: input.sessionId,
|
|
51
|
+
data: input.data,
|
|
52
|
+
...(input.schemaId !== undefined ? { schemaId: input.schemaId } : {}),
|
|
53
|
+
...(input.schemaVersion !== undefined ? { schemaVersion: input.schemaVersion } : {}),
|
|
54
|
+
sourceEventId: input.sourceEventId ?? `outbox-${id}`,
|
|
55
|
+
lastError,
|
|
56
|
+
...(target !== undefined ? { target } : {}),
|
|
57
|
+
};
|
|
58
|
+
const fileName = `${String(timestamp.getTime()).padStart(15, '0')}-${id}.json`;
|
|
59
|
+
writeJsonAtomic(join(dir, PENDING_DIR, fileName), record);
|
|
60
|
+
return record;
|
|
61
|
+
}
|
|
62
|
+
export function readOutboxPending(dir) {
|
|
63
|
+
return readValidatedRecords(join(dir, PENDING_DIR), isPendingRecord).records;
|
|
64
|
+
}
|
|
65
|
+
export function updatePendingError(dir, fileName, record, lastError) {
|
|
66
|
+
writeJsonAtomic(join(dir, PENDING_DIR, fileName), { ...record, lastError });
|
|
67
|
+
}
|
|
68
|
+
export function removePendingRecord(dir, fileName) {
|
|
69
|
+
rmSync(join(dir, PENDING_DIR, fileName), { force: true });
|
|
70
|
+
}
|
|
71
|
+
export function movePendingToRejected(dir, fileName, record, rejection, now = () => new Date()) {
|
|
72
|
+
const rejected = {
|
|
73
|
+
...record,
|
|
74
|
+
rejectedAt: now().toISOString(),
|
|
75
|
+
...(rejection.status !== undefined ? { status: rejection.status } : {}),
|
|
76
|
+
error: rejection.error,
|
|
77
|
+
...(rejection.errorBody !== undefined ? { errorBody: rejection.errorBody } : {}),
|
|
78
|
+
};
|
|
79
|
+
writeJsonAtomic(join(dir, REJECTED_DIR, fileName), rejected);
|
|
80
|
+
removePendingRecord(dir, fileName);
|
|
81
|
+
return rejected;
|
|
82
|
+
}
|
|
83
|
+
function ensureCounts(sessions, sessionId) {
|
|
84
|
+
let counts = Object.hasOwn(sessions, sessionId) ? sessions[sessionId] : undefined;
|
|
85
|
+
if (!counts) {
|
|
86
|
+
counts = { pending: 0, rejected: 0 };
|
|
87
|
+
Object.defineProperty(sessions, sessionId, {
|
|
88
|
+
value: counts,
|
|
89
|
+
enumerable: true,
|
|
90
|
+
writable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return counts;
|
|
95
|
+
}
|
|
96
|
+
/** Summarizes pending and rejected entry counts per session plus rejected error details. */
|
|
97
|
+
export function getOutboxStatus(dir) {
|
|
98
|
+
const pending = readValidatedRecords(join(dir, PENDING_DIR), isPendingRecord);
|
|
99
|
+
const rejected = readValidatedRecords(join(dir, REJECTED_DIR), isRejectedRecord);
|
|
100
|
+
const sessions = Object.create(null);
|
|
101
|
+
for (const { record } of pending.records)
|
|
102
|
+
ensureCounts(sessions, record.sessionId).pending += 1;
|
|
103
|
+
for (const { record } of rejected.records)
|
|
104
|
+
ensureCounts(sessions, record.sessionId).rejected += 1;
|
|
105
|
+
const corruptFiles = [...pending.corruptFiles, ...rejected.corruptFiles];
|
|
106
|
+
return {
|
|
107
|
+
dir,
|
|
108
|
+
pending: pending.records.length,
|
|
109
|
+
rejected: rejected.records.length,
|
|
110
|
+
sessions,
|
|
111
|
+
rejectedRecords: rejected.records.map(({ record }) => record),
|
|
112
|
+
...(corruptFiles.length > 0 ? { corruptFiles } : {}),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Removes matching rejected records from `<dir>/rejected/`. */
|
|
116
|
+
export function pruneOutboxRejected(dir, options = {}) {
|
|
117
|
+
const rejected = readValidatedRecords(join(dir, REJECTED_DIR), isRejectedRecord).records;
|
|
118
|
+
let removed = 0;
|
|
119
|
+
for (const { fileName, record } of rejected) {
|
|
120
|
+
const matchesId = options.id === undefined || record.id === options.id;
|
|
121
|
+
const matchesSession = options.sessionId === undefined || record.sessionId === options.sessionId;
|
|
122
|
+
if (matchesId && matchesSession) {
|
|
123
|
+
rmSync(join(dir, REJECTED_DIR, fileName), { force: true });
|
|
124
|
+
removed += 1;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { dir, removed, remainingRejected: rejected.length - removed };
|
|
128
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClientConfig } from '../client/types.mjs';
|
|
2
|
+
import type { OutboxTarget } from './types.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Derives a non-secret target namespace from client configuration so queued outbox entries
|
|
5
|
+
* are only flushed to the server and credential namespace that queued them. Never stores
|
|
6
|
+
* the raw token or secret.
|
|
7
|
+
*/
|
|
8
|
+
export declare function outboxTargetFromConfig(config: Pick<ClientConfig, 'baseUrl' | 'token'>): OutboxTarget;
|
|
9
|
+
/** Returns true when a queued record's target matches the active client configuration. */
|
|
10
|
+
export declare function matchesOutboxTarget(recorded: OutboxTarget | undefined, current: OutboxTarget): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const CLIENT_TOKEN_CRED_ID = /^abb_sk_([^_]+)_/;
|
|
2
|
+
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
3
|
+
/**
|
|
4
|
+
* Derives a non-secret target namespace from client configuration so queued outbox entries
|
|
5
|
+
* are only flushed to the server and credential namespace that queued them. Never stores
|
|
6
|
+
* the raw token or secret.
|
|
7
|
+
*/
|
|
8
|
+
export function outboxTargetFromConfig(config) {
|
|
9
|
+
const url = new URL(config.baseUrl);
|
|
10
|
+
const server = LOOPBACK_HOSTS.has(url.hostname) ? 'loopback' : url.origin;
|
|
11
|
+
const match = CLIENT_TOKEN_CRED_ID.exec(config.token);
|
|
12
|
+
return match?.[1] ? { server, credentialId: match[1] } : { server };
|
|
13
|
+
}
|
|
14
|
+
/** Returns true when a queued record's target matches the active client configuration. */
|
|
15
|
+
export function matchesOutboxTarget(recorded, current) {
|
|
16
|
+
if (!recorded)
|
|
17
|
+
return true;
|
|
18
|
+
if (recorded.server !== current.server)
|
|
19
|
+
return false;
|
|
20
|
+
return (recorded.credentialId ?? null) === (current.credentialId ?? null);
|
|
21
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export interface OutboxTarget {
|
|
2
|
+
/** Normalized server origin, or `'loopback'` for local loopback servers. */
|
|
3
|
+
server: string;
|
|
4
|
+
/** Non-secret credential id extracted from `abb_sk_<credId>_<secret>` when present. */
|
|
5
|
+
credentialId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface OutboxPendingRecord {
|
|
8
|
+
id: string;
|
|
9
|
+
queuedAt: string;
|
|
10
|
+
sessionId: string;
|
|
11
|
+
data: Record<string, unknown>;
|
|
12
|
+
schemaId?: string;
|
|
13
|
+
schemaVersion?: number;
|
|
14
|
+
sourceEventId: string;
|
|
15
|
+
lastError: string;
|
|
16
|
+
/** Non-secret server + credential namespace that queued this entry. */
|
|
17
|
+
target?: OutboxTarget;
|
|
18
|
+
}
|
|
19
|
+
export interface OutboxRejectedRecord extends OutboxPendingRecord {
|
|
20
|
+
rejectedAt: string;
|
|
21
|
+
status?: number;
|
|
22
|
+
error: string;
|
|
23
|
+
errorBody?: unknown;
|
|
24
|
+
}
|
|
25
|
+
export interface OutboxSessionCounts {
|
|
26
|
+
pending: number;
|
|
27
|
+
rejected: number;
|
|
28
|
+
}
|
|
29
|
+
export interface OutboxStatus {
|
|
30
|
+
dir: string;
|
|
31
|
+
pending: number;
|
|
32
|
+
rejected: number;
|
|
33
|
+
sessions: Record<string, OutboxSessionCounts>;
|
|
34
|
+
rejectedRecords: OutboxRejectedRecord[];
|
|
35
|
+
/** Paths of unreadable or malformed `.json` files skipped in `pending/` or `rejected/`. */
|
|
36
|
+
corruptFiles?: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface OutboxFlushOptions {
|
|
39
|
+
/** Only flush pending entries for this session id. */
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
dir?: string;
|
|
42
|
+
cwd?: string;
|
|
43
|
+
env?: NodeJS.ProcessEnv;
|
|
44
|
+
}
|
|
45
|
+
export interface OutboxFlushResult {
|
|
46
|
+
dir: string;
|
|
47
|
+
delivered: number;
|
|
48
|
+
duplicates: number;
|
|
49
|
+
rejected: number;
|
|
50
|
+
/** Count of pending records skipped because they belong to a different server or credential namespace. */
|
|
51
|
+
skipped?: number;
|
|
52
|
+
remaining: number;
|
|
53
|
+
}
|
|
54
|
+
export interface OutboxPruneOptions {
|
|
55
|
+
/** Remove only the rejected record with this outbox id. */
|
|
56
|
+
id?: string;
|
|
57
|
+
/** Remove rejected records belonging to this session id. */
|
|
58
|
+
sessionId?: string;
|
|
59
|
+
dir?: string;
|
|
60
|
+
cwd?: string;
|
|
61
|
+
env?: NodeJS.ProcessEnv;
|
|
62
|
+
}
|
|
63
|
+
export interface OutboxPruneResult {
|
|
64
|
+
dir: string;
|
|
65
|
+
removed: number;
|
|
66
|
+
remainingRejected: number;
|
|
67
|
+
}
|
|
68
|
+
export interface OutboxLocationOptions {
|
|
69
|
+
dir?: string;
|
|
70
|
+
cwd?: string;
|
|
71
|
+
env?: NodeJS.ProcessEnv;
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"agent-blackboard": {
|
|
4
4
|
"command": "npx",
|
|
5
|
-
"args": ["-y", "agent-blackboard@0.
|
|
5
|
+
"args": ["-y", "agent-blackboard@0.9.0", "mcp"],
|
|
6
6
|
"env": {
|
|
7
7
|
"AGENT_BLACKBOARD_URL": "${AGENT_BLACKBOARD_URL}",
|
|
8
8
|
"AGENT_BLACKBOARD_TOKEN": "${AGENT_BLACKBOARD_TOKEN}"
|
package/dist/plugin/.mcp.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-blackboard
|
|
3
|
-
description: Create sessions and record entries in agent-blackboard, an append-only stream for autonomous agent work. Use when recording
|
|
3
|
+
description: Create sessions and record entries in agent-blackboard, an append-only stream for autonomous agent work. Use when recording friction, decisions, or findings, or reviewing a known session later.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# agent-blackboard
|
|
@@ -39,6 +39,8 @@ If the `agent-blackboard` MCP server is connected, use its tools directly:
|
|
|
39
39
|
|
|
40
40
|
- `session_create` — create a root or subagent session with explicit `sessionId` and
|
|
41
41
|
`parentSessionId` (use `null` for a root), plus `agent` and `version`.
|
|
42
|
+
- `session_ensure` — the idempotent form of `session_create`: returns `"exists"` instead of an error
|
|
43
|
+
when the session is already there with the same `parentSessionId`, `agent`, and `version`.
|
|
42
44
|
- `session_search` — find undistilled or archived sessions with exact metadata, data, and optional
|
|
43
45
|
`inactiveForHours` filters (a session without entries counts as last active at its `createdAt`).
|
|
44
46
|
When supported, `dataArrayContains` matches exact array membership,
|
|
@@ -50,7 +52,13 @@ If the `agent-blackboard` MCP server is connected, use its tools directly:
|
|
|
50
52
|
supply `schemaId` (and `schemaVersion`) for server-side JSON Schema validation.
|
|
51
53
|
- `entry_get` — read entries from one explicit session.
|
|
52
54
|
- `snapshot_export` — stream all selected active sessions and entries to a private read-only JSONL
|
|
53
|
-
file, returning
|
|
55
|
+
file, returning its path, counts, checksum, manifest, and (when `path` is omitted) `cleanupToken`.
|
|
56
|
+
- `snapshot_partition` — split a generated temporary snapshot into bounded session-preserving
|
|
57
|
+
read-only partitions using its `cleanupToken`.
|
|
58
|
+
- `snapshot_cleanup` — delete a generated temporary snapshot file and/or partition directory using
|
|
59
|
+
its `cleanupToken`.
|
|
60
|
+
- `outbox_status`, `outbox_flush`, `outbox_prune_rejected` — inspect, deliver, or drop entry writes
|
|
61
|
+
queued in the local outbox while the server was unreachable.
|
|
54
62
|
- `schema_list` — list registered JSON Schemas and the current schema registry revision.
|
|
55
63
|
- `schema_get` — inspect one registered schema (latest version or an explicit `version`).
|
|
56
64
|
- `schema_pull` — sync the full schema registry into the local cache (`If-None-Match`).
|
|
@@ -62,26 +70,28 @@ Without MCP, or from a shell/script, run the published CLI through `npx`. This d
|
|
|
62
70
|
local clone of the agent-blackboard repository:
|
|
63
71
|
|
|
64
72
|
```bash
|
|
65
|
-
npx -y agent-blackboard@0.
|
|
66
|
-
npx -y agent-blackboard@0.
|
|
73
|
+
npx -y agent-blackboard@0.9.0 sessions create root-123 --agent claude-code --version 1.0.13
|
|
74
|
+
npx -y agent-blackboard@0.9.0 sessions create worker-456 --parent-session-id root-123 \
|
|
67
75
|
--agent claude-code --version 1.0.13
|
|
68
|
-
npx -y agent-blackboard@0.
|
|
69
|
-
npx -y agent-blackboard@0.
|
|
70
|
-
npx -y agent-blackboard@0.
|
|
71
|
-
npx -y agent-blackboard@0.
|
|
72
|
-
npx -y agent-blackboard@0.
|
|
73
|
-
npx -y agent-blackboard@0.
|
|
76
|
+
npx -y agent-blackboard@0.9.0 sessions patch worker-456 --data '{"branch":"fix/retry"}'
|
|
77
|
+
npx -y agent-blackboard@0.9.0 sessions patch worker-456 --data '{"repositories":["owner/name"]}'
|
|
78
|
+
npx -y agent-blackboard@0.9.0 append --session-id worker-456 '{"repositories":["owner/name"],"note":"found the failing edge case"}'
|
|
79
|
+
npx -y agent-blackboard@0.9.0 get --session-id worker-456 --format markdown
|
|
80
|
+
npx -y agent-blackboard@0.9.0 snapshot export --root-only --inactive-for-hours 8
|
|
81
|
+
npx -y agent-blackboard@0.9.0 snapshot partition --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
|
|
74
82
|
--cleanup-token <cleanup-token>
|
|
75
|
-
npx -y agent-blackboard@0.
|
|
83
|
+
npx -y agent-blackboard@0.9.0 snapshot cleanup --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
|
|
76
84
|
--directory /tmp/agent-blackboard-partitions-<suffix> --cleanup-token <cleanup-token>
|
|
77
85
|
```
|
|
78
86
|
|
|
79
87
|
Output defaults to JSON; pass `--format jsonl` or `--format markdown` for streaming or
|
|
80
88
|
human-readable reads.
|
|
81
89
|
|
|
82
|
-
Before appending a repository-tagged entry,
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
Before appending a repository-tagged entry, read the session's current `data.repositories`
|
|
91
|
+
(`sessions get <id>`) and merge the entry's tags into that list: a patch replaces the whole
|
|
92
|
+
array, so patching only the new repository drops the ones already there. Normalize the list and
|
|
93
|
+
wait for `sessions patch` to succeed. If it fails, do not append; start a new session after
|
|
94
|
+
archival because archived metadata cannot be patched. The entry tag remains the
|
|
85
95
|
authority for repository-scoped evidence. A session can span repositories, so a repository-scoped
|
|
86
96
|
review includes only entries whose tag array contains the selected repository and does not archive
|
|
87
97
|
the shared session until all of its tagged repositories have been reviewed.
|
|
@@ -102,4 +112,5 @@ the pure-Node package boundary.
|
|
|
102
112
|
|
|
103
113
|
This skill only covers **how** to create sessions and append and get entries. It does not prescribe
|
|
104
114
|
**what** to record — write, or look for, a project-specific skill that layers that guidance on top
|
|
105
|
-
of this one.
|
|
115
|
+
of this one. For turning accumulated sessions into evidence-backed follow-ups via snapshots, use the
|
|
116
|
+
companion [`distill`](../distill/SKILL.md) skill.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: distill
|
|
3
|
+
description: Use when distilling accumulated agent-blackboard sessions into concrete follow-ups, sweeping finished sessions after a time window or repository filter, or turning journal snapshots into evidence-backed action items. Exports, filters and digests snapshots, has small models read the partitions, groups entries by root cause, archives only when asked, and cleans up.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Distill
|
|
7
|
+
|
|
8
|
+
Read every applicable `AGENTS.md` first. Repository-local policy overrides these defaults.
|
|
9
|
+
|
|
10
|
+
Turn finished `agent-blackboard` sessions into evidence-backed follow-ups without loading raw
|
|
11
|
+
snapshots across MCP or leaving temporary files behind. Filing follow-ups as tickets or issues stays
|
|
12
|
+
the caller's job.
|
|
13
|
+
|
|
14
|
+
## Inputs
|
|
15
|
+
|
|
16
|
+
Collect or confirm these parameters before starting:
|
|
17
|
+
|
|
18
|
+
- **Selection window**: an optional `inactiveForHours` threshold (passed to `snapshot_export`)
|
|
19
|
+
and/or a `since` ISO-8601 cursor (passed to `snapshot_partition`, which applies it to each
|
|
20
|
+
session's `lastEntryAt ?? createdAt`).
|
|
21
|
+
- **Data filters**: optional repository filter (`dataArrayContains: { "repositories": "owner/name" }`
|
|
22
|
+
or `data: { "repository": "owner/name" }` on export, and `repository` on `snapshot_partition`),
|
|
23
|
+
plus any `agent`, `version`, or `parentSessionId` filter on export.
|
|
24
|
+
- **Archival flag**: `archive` (`false` by default). Never archive sessions unless the caller
|
|
25
|
+
explicitly asks.
|
|
26
|
+
- **Partition limits**: optional `maxSessions` (default `25`) and `maxBytes` (this skill defaults to
|
|
27
|
+
`262144`, small enough for a small model's context).
|
|
28
|
+
|
|
29
|
+
## Procedure
|
|
30
|
+
|
|
31
|
+
Run cleanup in a `finally`-style step regardless of success, empty results, or errors.
|
|
32
|
+
|
|
33
|
+
1. **Export a generated snapshot.**
|
|
34
|
+
Call `snapshot_export` **without** `path` so the tool creates a private temporary file and
|
|
35
|
+
returns `{ path, counts, checksum, manifest, cleanupToken }`. Pass all requested selection
|
|
36
|
+
filters (`inactiveForHours`, `data`, `dataArrayContains`, `agent`, `version`, `parentSessionId`).
|
|
37
|
+
Never pass an explicit `path` if you intend to partition or clean up through MCP.
|
|
38
|
+
|
|
39
|
+
2. **Partition into digests.**
|
|
40
|
+
Always call `snapshot_partition`, even for a small export, so readers get a pre-filtered digest
|
|
41
|
+
instead of raw records:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"path": "<export.path>",
|
|
46
|
+
"cleanupToken": "<export.cleanupToken>",
|
|
47
|
+
"maxBytes": "<caller's maxBytes, or 262144>",
|
|
48
|
+
"maxSessions": "<caller's maxSessions, or omit>",
|
|
49
|
+
"since": "<iso-or-omit>",
|
|
50
|
+
"repository": "<owner/name-or-omit>",
|
|
51
|
+
"digest": true,
|
|
52
|
+
"checksum": "<export.checksum.value>",
|
|
53
|
+
"counts": "<export.counts>"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The tool applies `since` and `repository` itself and writes one `digest-<n>.jsonl` file per
|
|
58
|
+
partition: session lines (`sessionId`, `parentSessionId`, `agent`, `lastEntryAt`,
|
|
59
|
+
`repositories`) each followed
|
|
60
|
+
by that session's entries (`createdAt`, `data`). Cite an entry by its session line's `sessionId`
|
|
61
|
+
plus the entry's `createdAt`.
|
|
62
|
+
If it fails because one session is too large for one partition, report that session's id and
|
|
63
|
+
stop (cleanup still runs); do not raise `maxBytes` past what a small model can read.
|
|
64
|
+
Untagged entries are dropped for a repository sweep (tags are never inferred), and an empty
|
|
65
|
+
`partitions` list means nothing matched. Record `directory` from the response so cleanup removes
|
|
66
|
+
both the snapshot and the partition directory.
|
|
67
|
+
|
|
68
|
+
3. **Read partitions with small models, then group by root cause.**
|
|
69
|
+
Dispatch one subagent per partition file, using a small, inexpensive model (such as Haiku) with
|
|
70
|
+
the prompt in the [output schema reference](references/output-schema.md). Do not read or filter
|
|
71
|
+
partitions in the coordinating model. Then, as the coordinator:
|
|
72
|
+
- Merge candidate observations across partitions. Entries may carry a short friction name
|
|
73
|
+
(e.g. `ci:lockfile-drift`); when present, group by it first.
|
|
74
|
+
- Cluster entries across root and child sessions by shared root cause, not by session or
|
|
75
|
+
surface symptom.
|
|
76
|
+
- Promote a group to a follow-up when it recurs in at least **2 distinct sessions**, or when a
|
|
77
|
+
one-off represents high severity (data loss, credential exposure, security boundary failure,
|
|
78
|
+
irreversible external mutation, or a standard-workflow blocker). Leave routine one-offs as
|
|
79
|
+
unpromoted evidence.
|
|
80
|
+
- Keep exact `sessionId` and `createdAt` citations; set missing fields to `null` rather than
|
|
81
|
+
inventing them.
|
|
82
|
+
|
|
83
|
+
4. **Return structured follow-ups.**
|
|
84
|
+
Emit follow-ups with concrete changes, evidence citations, and source session ids (see
|
|
85
|
+
[output schema and subagent prompt](references/output-schema.md)). Do not file issues, edit
|
|
86
|
+
source code, or append distillation output back into source sessions — return the structured
|
|
87
|
+
result to the caller.
|
|
88
|
+
|
|
89
|
+
5. **Archive sessions only when asked.**
|
|
90
|
+
- By default, leave every session unarchived (`archivedSessions: []`).
|
|
91
|
+
- Only when the caller explicitly requested archival, re-read each eligible distilled session via
|
|
92
|
+
`session_search({ "sessionId": "<id>" })`. Call `session_archive({ "sessionId": "<id>" })`
|
|
93
|
+
only when its current `lastEntryAt` equals the exported `lastEntryAt` that the readers copied
|
|
94
|
+
from its session line. Otherwise skip it
|
|
95
|
+
and leave it out of `archivedSessions`. Record `archivedAt` for each archived session.
|
|
96
|
+
- In a repository-scoped sweep, do **not** archive a session whose `data.repositories` lists
|
|
97
|
+
other repositories that were not part of this sweep.
|
|
98
|
+
|
|
99
|
+
6. **Always clean up snapshot artifacts.**
|
|
100
|
+
Call `snapshot_cleanup` before returning, even if zero sessions matched or an earlier step
|
|
101
|
+
failed:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"path": "<export.path>",
|
|
106
|
+
"directory": "<partition.directory-if-created>",
|
|
107
|
+
"cleanupToken": "<export.cleanupToken>"
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Confirm `{ "removed": true }` so no snapshot or partition files remain on disk.
|
|
112
|
+
|
|
113
|
+
## CLI fallback
|
|
114
|
+
|
|
115
|
+
When MCP is unavailable, run the identical sequence through the published CLI:
|
|
116
|
+
|
|
117
|
+
- `npx -y agent-blackboard@0.9.0 snapshot export [filters...]`
|
|
118
|
+
- `npx -y agent-blackboard@0.9.0 snapshot partition --path <path> --cleanup-token <token> --max-bytes <caller's maxBytes, or 262144> [--max-sessions <n>] --digest [--since <iso>] [--repository <owner/name>]`
|
|
119
|
+
- `npx -y agent-blackboard@0.9.0 sessions get <id>` and `npx -y agent-blackboard@0.9.0 sessions archive <id>` (only when explicitly asked and `lastEntryAt` still matches the export)
|
|
120
|
+
- `npx -y agent-blackboard@0.9.0 snapshot cleanup --path <path> [--directory <dir>] --cleanup-token <token>`
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Distill output schema and subagent prompt
|
|
2
|
+
|
|
3
|
+
Read this reference when formatting the final distillation output or delegating read-only
|
|
4
|
+
partition inspection to parallel subagents.
|
|
5
|
+
|
|
6
|
+
## Output JSON shape
|
|
7
|
+
|
|
8
|
+
Return one JSON object to the caller:
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"followUps": [
|
|
13
|
+
{
|
|
14
|
+
"title": "Imperative, owner-ready follow-up title",
|
|
15
|
+
"rootCause": "Shared underlying cause across cited entries",
|
|
16
|
+
"change": "Concrete change to implement",
|
|
17
|
+
"benefit": "Expected outcome after the change",
|
|
18
|
+
"destination": "ticket | AGENTS.md | test | lint | docs | skill",
|
|
19
|
+
"severity": "high | medium | low",
|
|
20
|
+
"sessions": ["root-1", "root-2"],
|
|
21
|
+
"evidence": [
|
|
22
|
+
{
|
|
23
|
+
"sessionId": "root-1",
|
|
24
|
+
"createdAt": "2026-01-01T00:10:00.000Z",
|
|
25
|
+
"summary": "Concrete finding summary from the entry"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"distilledSessions": ["root-1", "root-2"],
|
|
31
|
+
"archivedSessions": [{ "sessionId": "root-1", "archivedAt": "2026-01-02T00:00:00.000Z" }],
|
|
32
|
+
"skippedOneOffs": 1,
|
|
33
|
+
"cleanedUp": true
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- `followUps`: sorted with recurring and high-severity items first. Reject vague titles like
|
|
38
|
+
"improve reliability".
|
|
39
|
+
- `archivedSessions`: always `[]` unless the caller explicitly requested archival.
|
|
40
|
+
- `cleanedUp`: `true` once `snapshot_cleanup` succeeds.
|
|
41
|
+
|
|
42
|
+
## Parallel partition inspection prompt
|
|
43
|
+
|
|
44
|
+
`snapshot_partition` is called with `digest: true`, so each `digest-<n>.jsonl` file is already
|
|
45
|
+
filtered by `since` and `repository`. Give each read-only subagent one non-overlapping partition
|
|
46
|
+
path, running on a small, inexpensive model (such as Haiku):
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
Read only this local file: <partition-path>. It is a pre-filtered digest: a header line, then
|
|
50
|
+
session lines ({ type: "session", sessionId, parentSessionId, agent, lastEntryAt, repositories }) each followed
|
|
51
|
+
by that session's entries ({ createdAt, schemaId?, data }), then a summary line. Every entry in it
|
|
52
|
+
is in scope; do not filter by date or repository. Cite an entry with the sessionId of the session
|
|
53
|
+
line before it plus the entry's createdAt.
|
|
54
|
+
Return one JSON object:
|
|
55
|
+
{ "observations": [{ "sessionId", "createdAt", "rootCause", "summary", "evidence", "severity",
|
|
56
|
+
"repositories" }], "sessions": [{ "sessionId", "lastEntryAt", "repositories" }] }, with one
|
|
57
|
+
"sessions" item per session line, its values copied exactly.
|
|
58
|
+
Use null for any missing field; never invent values.
|
|
59
|
+
Do not call session_archive, snapshot_cleanup, file tickets, or edit repository files.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The coordinating agent merges observations across partitions, deduplicates root causes, applies the
|
|
63
|
+
promotion threshold, optionally archives eligible sessions when explicitly requested, and runs
|
|
64
|
+
`snapshot_cleanup`.
|
package/package.json
CHANGED