ai-advisory-board 0.11.1 → 0.12.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/CHANGELOG.md +9 -0
- package/dist/bin/aab.js +91 -15
- package/dist/bin/aab.js.map +1 -1
- package/gui/app.js +105 -5
- package/gui/style.css +40 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# CHANGELOG — AI Advisory Board CLI
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f1b1edc: Decision Coach × Business Wiki: the **📚 wiki badge now explains itself**.
|
|
8
|
+
|
|
9
|
+
- **Sources used** — the badge expands ("📚 wiki · N sources ▸") to list exactly which wiki pages the coach read for that reply (each links to the Knowledge view), plus what it searched for. Captured per turn as `DecisionMessage.wikiUsage`.
|
|
10
|
+
- **Added to your wiki** — when your message is ingested back into the wiki, the user turn shows a **📥 Added to your wiki (N)** note listing the new/updated pages (or "nothing new to add"). Captured as `DecisionMessage.wikiIngest` and streamed live via a new `coach_wiki_ingested` event.
|
|
11
|
+
|
|
3
12
|
## 0.11.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/bin/aab.js
CHANGED
|
@@ -4250,7 +4250,7 @@ function createIngestQueue(runner = ingestUserFacts) {
|
|
|
4250
4250
|
const batch = state.pending.splice(0, state.pending.length);
|
|
4251
4251
|
for (const group of coalesce(batch)) {
|
|
4252
4252
|
try {
|
|
4253
|
-
await runner({
|
|
4253
|
+
const result = await runner({
|
|
4254
4254
|
text: group.text,
|
|
4255
4255
|
kind: group.kind,
|
|
4256
4256
|
workspace: group.workspace,
|
|
@@ -4259,8 +4259,20 @@ function createIngestQueue(runner = ingestUserFacts) {
|
|
|
4259
4259
|
sparringSessionId: group.sparringSessionId,
|
|
4260
4260
|
coachSessionId: group.coachSessionId
|
|
4261
4261
|
});
|
|
4262
|
+
if (group.onResult) {
|
|
4263
|
+
try {
|
|
4264
|
+
await group.onResult(result);
|
|
4265
|
+
} catch {
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4262
4268
|
} catch (error) {
|
|
4263
4269
|
logger.warn("[ingest-queue] user-fact ingest failed (non-blocking):", error);
|
|
4270
|
+
if (group.onResult) {
|
|
4271
|
+
try {
|
|
4272
|
+
await group.onResult(null);
|
|
4273
|
+
} catch {
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4264
4276
|
}
|
|
4265
4277
|
}
|
|
4266
4278
|
}
|
|
@@ -4328,7 +4340,8 @@ function maybeEnqueueUserInput(opts) {
|
|
|
4328
4340
|
discussionId: opts.discussionId,
|
|
4329
4341
|
sparringSessionId: opts.sparringSessionId,
|
|
4330
4342
|
coachSessionId: opts.coachSessionId,
|
|
4331
|
-
eventId: opts.eventId
|
|
4343
|
+
eventId: opts.eventId,
|
|
4344
|
+
onResult: opts.onResult
|
|
4332
4345
|
});
|
|
4333
4346
|
} catch (error) {
|
|
4334
4347
|
logger.debug("[ingest-queue] enqueue failed (non-blocking):", error);
|
|
@@ -11288,13 +11301,25 @@ function makeCoachEventForwarder(passthrough, onTool) {
|
|
|
11288
11301
|
if (event.type === "assistant" && event.message?.content) {
|
|
11289
11302
|
for (const block of event.message.content) {
|
|
11290
11303
|
if (block.type === "tool_use" && typeof block.name === "string") {
|
|
11291
|
-
onTool(block.name.toLowerCase());
|
|
11304
|
+
onTool(block.name.toLowerCase(), block.input);
|
|
11292
11305
|
}
|
|
11293
11306
|
}
|
|
11294
11307
|
}
|
|
11295
11308
|
passthrough?.(event);
|
|
11296
11309
|
};
|
|
11297
11310
|
}
|
|
11311
|
+
function toWikiRelPath(input) {
|
|
11312
|
+
if (typeof input !== "string" || !input) return void 0;
|
|
11313
|
+
const posix = input.replace(/\\/g, "/");
|
|
11314
|
+
const idx = posix.toLowerCase().lastIndexOf("/wiki/");
|
|
11315
|
+
let rel = idx >= 0 ? posix.slice(idx + 1) : posix.startsWith("wiki/") ? posix : void 0;
|
|
11316
|
+
if (!rel) return void 0;
|
|
11317
|
+
const tail = rel.replace(/^wiki\//, "");
|
|
11318
|
+
if (tail === "index.md" || tail === "log.md" || tail === "KNOWLEDGE.md" || tail.startsWith(".aab/") || !tail.endsWith(".md")) {
|
|
11319
|
+
return void 0;
|
|
11320
|
+
}
|
|
11321
|
+
return rel;
|
|
11322
|
+
}
|
|
11298
11323
|
function renderPrincipleForPrompt(p) {
|
|
11299
11324
|
const lines = [`**${p.title}** (priority ${p.priority}/10, ${p.category})`];
|
|
11300
11325
|
lines.push(`Description: ${p.description}`);
|
|
@@ -11351,8 +11376,18 @@ ${transcript}
|
|
|
11351
11376
|
Respond now as the Decision Coach. Use markdown. Reference principles by their **Title**. Always end with a question or call to reflection.`;
|
|
11352
11377
|
const model = opts.model ?? settings.primaryModel ?? "sonnet";
|
|
11353
11378
|
let usedWiki = false;
|
|
11354
|
-
const
|
|
11355
|
-
|
|
11379
|
+
const sourcesRead = [];
|
|
11380
|
+
const queries = [];
|
|
11381
|
+
const onEvent = makeCoachEventForwarder(opts.onEvent, (tool, input) => {
|
|
11382
|
+
if (tool !== "read" && tool !== "grep" && tool !== "glob") return;
|
|
11383
|
+
usedWiki = true;
|
|
11384
|
+
if (tool === "read") {
|
|
11385
|
+
const rel = toWikiRelPath(input?.file_path);
|
|
11386
|
+
if (rel && !sourcesRead.includes(rel)) sourcesRead.push(rel);
|
|
11387
|
+
} else {
|
|
11388
|
+
const q = typeof input?.pattern === "string" ? input.pattern : void 0;
|
|
11389
|
+
if (q && !queries.includes(q)) queries.push(q);
|
|
11390
|
+
}
|
|
11356
11391
|
});
|
|
11357
11392
|
const allowedTools = useWiki ? ["WebSearch", "WebFetch", "Read", "Grep", "Glob"] : ["WebSearch", "WebFetch"];
|
|
11358
11393
|
const addDirs = useWiki && opts.workspaceRoot ? [opts.workspaceRoot] : void 0;
|
|
@@ -11398,6 +11433,7 @@ Respond now as the Decision Coach. Use markdown. Reference principles by their *
|
|
|
11398
11433
|
content: cleaned,
|
|
11399
11434
|
principlesReferenced: referenced.length > 0 ? referenced : void 0,
|
|
11400
11435
|
usedWiki: usedWiki || void 0,
|
|
11436
|
+
wikiUsage: sourcesRead.length > 0 || queries.length > 0 ? { sourcesRead, queries } : void 0,
|
|
11401
11437
|
createdAt: nowIso()
|
|
11402
11438
|
};
|
|
11403
11439
|
const newMessages = [...session.messages];
|
|
@@ -14798,6 +14834,22 @@ async function startUiServer(opts) {
|
|
|
14798
14834
|
const root = opts.storage.getWorkspaceRoot();
|
|
14799
14835
|
return { useWiki: !!session.useBusinessWiki, workspaceRoot: root, wikiDir: paths(root).wiki };
|
|
14800
14836
|
};
|
|
14837
|
+
const recordCoachWikiIngest = async (storage, sessionId, messageId, result) => {
|
|
14838
|
+
if (!messageId) return null;
|
|
14839
|
+
const r = result ?? {};
|
|
14840
|
+
const ingest = {
|
|
14841
|
+
producedPages: Array.isArray(r.producedPages) ? r.producedPages : [],
|
|
14842
|
+
updatedPages: Array.isArray(r.updatedPages) ? r.updatedPages : [],
|
|
14843
|
+
notes: typeof r.notes === "string" ? r.notes : void 0
|
|
14844
|
+
};
|
|
14845
|
+
const session = await storage.loadDecisionSessionById(sessionId);
|
|
14846
|
+
if (!session) return null;
|
|
14847
|
+
const msg = session.messages.find((m) => m.id === messageId);
|
|
14848
|
+
if (!msg) return null;
|
|
14849
|
+
msg.wikiIngest = ingest;
|
|
14850
|
+
await storage.updateDecisionSession({ ...session, updatedAt: nowIso() });
|
|
14851
|
+
return ingest;
|
|
14852
|
+
};
|
|
14801
14853
|
app.get("/api/coach/sessions", async (_req, res) => {
|
|
14802
14854
|
try {
|
|
14803
14855
|
const sessions = await opts.storage.loadDecisionSessions();
|
|
@@ -14917,12 +14969,23 @@ async function startUiServer(opts) {
|
|
|
14917
14969
|
await opts.storage.updateDecisionSession(updated);
|
|
14918
14970
|
broadcast({ type: "coach_message", sessionId: updated.id, message: reply, session: updated });
|
|
14919
14971
|
if (updated.useBusinessWiki) {
|
|
14972
|
+
const userMsg = [...updated.messages].reverse().find((m) => m.role === "user");
|
|
14920
14973
|
maybeEnqueueUserInput({
|
|
14921
14974
|
text: content,
|
|
14922
14975
|
kind: "coach_message",
|
|
14923
14976
|
settings,
|
|
14924
14977
|
storage: opts.storage,
|
|
14925
|
-
coachSessionId: updated.id
|
|
14978
|
+
coachSessionId: updated.id,
|
|
14979
|
+
onResult: async (result) => {
|
|
14980
|
+
try {
|
|
14981
|
+
const ingest = await recordCoachWikiIngest(opts.storage, updated.id, userMsg?.id, result);
|
|
14982
|
+
if (ingest) {
|
|
14983
|
+
broadcast({ type: "coach_wiki_ingested", sessionId: updated.id, messageId: userMsg?.id, wikiIngest: ingest });
|
|
14984
|
+
}
|
|
14985
|
+
} catch (err) {
|
|
14986
|
+
logger.debug("[coach] record wiki ingest failed (non-blocking):", err);
|
|
14987
|
+
}
|
|
14988
|
+
}
|
|
14926
14989
|
});
|
|
14927
14990
|
}
|
|
14928
14991
|
} catch (error) {
|
|
@@ -18844,15 +18907,28 @@ function coachWikiRunOpts(session, root) {
|
|
|
18844
18907
|
return { useWiki: !!session.useBusinessWiki, workspaceRoot: root, wikiDir: paths(root).wiki };
|
|
18845
18908
|
}
|
|
18846
18909
|
function fireCoachIngest(session, settings, storage, text) {
|
|
18847
|
-
if (session.useBusinessWiki)
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18910
|
+
if (!session.useBusinessWiki) return;
|
|
18911
|
+
const userMsg = [...session.messages].reverse().find((m) => m.role === "user");
|
|
18912
|
+
maybeEnqueueUserInput({
|
|
18913
|
+
text,
|
|
18914
|
+
kind: "coach_message",
|
|
18915
|
+
settings,
|
|
18916
|
+
storage,
|
|
18917
|
+
coachSessionId: session.id,
|
|
18918
|
+
onResult: async (result) => {
|
|
18919
|
+
if (!userMsg) return;
|
|
18920
|
+
const r = result ?? {};
|
|
18921
|
+
const fresh = await storage.loadDecisionSessionById(session.id);
|
|
18922
|
+
const msg = fresh?.messages.find((m) => m.id === userMsg.id);
|
|
18923
|
+
if (!fresh || !msg) return;
|
|
18924
|
+
msg.wikiIngest = {
|
|
18925
|
+
producedPages: Array.isArray(r.producedPages) ? r.producedPages : [],
|
|
18926
|
+
updatedPages: Array.isArray(r.updatedPages) ? r.updatedPages : [],
|
|
18927
|
+
notes: typeof r.notes === "string" ? r.notes : void 0
|
|
18928
|
+
};
|
|
18929
|
+
await storage.updateDecisionSession({ ...fresh, updatedAt: nowIso() });
|
|
18930
|
+
}
|
|
18931
|
+
});
|
|
18856
18932
|
}
|
|
18857
18933
|
function renderMessage(role, content) {
|
|
18858
18934
|
if (role === "user") {
|