ai-advisory-board 0.13.0 → 0.14.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG — AI Advisory Board CLI
2
2
 
3
+ ## 0.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2d3c70f: Decisions remember what they rest on: `--criterion`, `--principle`, `--door`, `--review-days` and `--probability` on `aab decide record`, `aab decide from-discussion` and `aab coach decide`; a coach decision carries over the principles the coach used, and `decide show` lists criteria and principles. New `aab blindspots` (list/add/edit/remove): the decision coach checks every situation against your written-down blind spots. The coach also gets Ray Dalio's decision moves (another one of those, goal vs. desire, the criteria, the bet, second- and third-order consequences, value of information vs. cost of waiting; at most two per reply) and treats emotions as data instead of steering away from them. `aab coach decide` accepts a short session id.
8
+
3
9
  ## 0.13.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -198,6 +198,11 @@ aab discuss verdict <id> [--force] Board Verdict: recommendation, calibrated
198
198
  aab decide from-discussion <id> Turn a verdict into a tracked decision (with its forecast)
199
199
  aab decide list | show <id> | review Decision portfolio; review lists decisions past their review date
200
200
  aab decide record <id> "<what I did>" Mark a decision as acted on
201
+ [--criterion "<text>"] [--principle <idOrTitle>] What it rests on (repeatable)
202
+ [--door one-way|two-way] [--review-days N] [--probability 0-100]
203
+ aab coach decide <id> "<decision>" Record a coach decision (same flags; the coach's principles carry over)
204
+ aab blindspots list | add | edit | remove
205
+ Your known blind spots; the coach checks each situation against them
201
206
  aab decide outcome <id> <outcome> succeeded | partial | failed | learning (once per decision)
202
207
  aab decide calibration Brier score, reliability buckets, per-member calibration
203
208
 
package/dist/bin/aab.js CHANGED
@@ -1684,6 +1684,7 @@ function paths(root) {
1684
1684
  members: join2(root, "members.json"),
1685
1685
  boards: join2(root, "boards.json"),
1686
1686
  principles: join2(root, "principles.json"),
1687
+ blindSpots: join2(root, "blind-spots.json"),
1687
1688
  decisionSessions: join2(root, "decision-sessions"),
1688
1689
  explorerSessions: join2(root, "explorer-sessions"),
1689
1690
  decisions: join2(root, "decisions"),
@@ -2314,6 +2315,13 @@ var FsStorageService = class {
2314
2315
  async loadPrinciples() {
2315
2316
  return readJson(this.p.principles, []);
2316
2317
  }
2318
+ async loadBlindSpots() {
2319
+ const raw = readJson(this.p.blindSpots, []);
2320
+ return Array.isArray(raw) ? raw.filter((b) => b && typeof b.id === "string" && typeof b.text === "string") : [];
2321
+ }
2322
+ async saveBlindSpots(blindSpots) {
2323
+ writeJsonAtomic(this.p.blindSpots, blindSpots, { snapshotDir: this.p.snapshots });
2324
+ }
2317
2325
  async savePrinciple(principle) {
2318
2326
  const all = await this.loadPrinciples();
2319
2327
  all.push(principle);
@@ -8625,11 +8633,36 @@ function clampNumber2(value, min, max, fallback) {
8625
8633
  }
8626
8634
 
8627
8635
  // src/core/decisions/promote.ts
8628
- function reviewDueAt(createdAt, doorType) {
8636
+ function reviewDueAt(createdAt, doorType, days) {
8629
8637
  const d = new Date(createdAt);
8630
- d.setUTCDate(d.getUTCDate() + (doorType === "one-way" ? 14 : 60));
8638
+ const offset = typeof days === "number" && Number.isFinite(days) && days > 0 ? Math.round(days) : doorType === "one-way" ? 14 : 60;
8639
+ d.setUTCDate(d.getUTCDate() + offset);
8631
8640
  return d.toISOString();
8632
8641
  }
8642
+ function ownForecast(probability) {
8643
+ if (typeof probability !== "number" || !Number.isFinite(probability)) return void 0;
8644
+ const p = Math.min(100, Math.max(0, Math.round(probability)));
8645
+ return { panelProbability: p, verbalBand: `own estimate, ${verbalBand(p)}` };
8646
+ }
8647
+ function cleanList(values) {
8648
+ const out = [...new Set((values ?? []).map((v) => v.trim()).filter(Boolean))];
8649
+ return out.length > 0 ? out : void 0;
8650
+ }
8651
+ function applyDecisionContext(decision, input) {
8652
+ const doorType = input.doorType ?? decision.doorType;
8653
+ const criteria = cleanList([...decision.criteria ?? [], ...input.criteria ?? []]);
8654
+ const principleIds = cleanList([...decision.principleIds ?? [], ...input.principleIds ?? []]);
8655
+ const reviewChanged = input.reviewDays !== void 0 || doorType !== decision.doorType;
8656
+ return {
8657
+ ...decision,
8658
+ confidenceAtDecision: ownForecast(input.probability) ?? decision.confidenceAtDecision,
8659
+ doorType,
8660
+ criteria,
8661
+ principleIds,
8662
+ reviewDueAt: reviewChanged ? reviewDueAt(decision.decidedAt ?? decision.createdAt, doorType, input.reviewDays) : decision.reviewDueAt,
8663
+ updatedAt: nowIso()
8664
+ };
8665
+ }
8633
8666
  function decisionTitleFromDiscussion(discussion) {
8634
8667
  return (discussion.title?.trim() || discussion.frame?.decision || discussion.question).slice(0, 160);
8635
8668
  }
@@ -8657,45 +8690,60 @@ function promoteVerdictToDecision(discussion, verdict = discussion.verdict) {
8657
8690
  updatedAt: createdAt
8658
8691
  };
8659
8692
  }
8660
- function promoteCoachSessionToDecision(session, decisionText) {
8693
+ function promoteCoachSessionToDecision(session, decisionText, input = {}) {
8661
8694
  const createdAt = nowIso();
8695
+ const doorType = input.doorType ?? "two-way";
8662
8696
  return {
8663
8697
  id: generateUUID(),
8664
8698
  source: { decisionSessionId: session.id },
8665
8699
  title: (session.title?.trim() || session.situation).slice(0, 160),
8666
8700
  decisionText,
8667
- doorType: "two-way",
8701
+ doorType,
8668
8702
  domainValidity: "wicked",
8669
8703
  signalsToWatch: [],
8704
+ // The principles the coach actually used carry over to the decision, so the
8705
+ // outcome can later be traced back to them.
8706
+ principleIds: cleanList([...session.appliedPrinciples ?? [], ...input.principleIds ?? []]),
8707
+ criteria: cleanList(input.criteria),
8708
+ confidenceAtDecision: ownForecast(input.probability),
8670
8709
  status: "acted",
8671
8710
  decidedAt: createdAt,
8672
- reviewDueAt: reviewDueAt(createdAt, "two-way"),
8711
+ reviewDueAt: reviewDueAt(createdAt, doorType, input.reviewDays),
8673
8712
  createdAt,
8674
8713
  updatedAt: createdAt
8675
8714
  };
8676
8715
  }
8677
- async function ensureDecisionForDiscussion(storage, discussion) {
8716
+ async function ensureDecisionForDiscussion(storage, discussion, input) {
8678
8717
  if (!discussion.verdict) return void 0;
8718
+ const hasInput = !!input && Object.values(input).some((v) => v !== void 0 && !(Array.isArray(v) && v.length === 0));
8679
8719
  const existing = (await storage.loadDecisions()).find((d) => d.source.discussionId === discussion.id);
8680
- if (existing) return { decision: existing, created: false };
8681
- const decision = promoteVerdictToDecision(discussion, discussion.verdict);
8720
+ if (existing) {
8721
+ if (!hasInput) return { decision: existing, created: false };
8722
+ const updated = applyDecisionContext(existing, input);
8723
+ await storage.updateDecision(updated);
8724
+ return { decision: updated, created: false };
8725
+ }
8726
+ const base = promoteVerdictToDecision(discussion, discussion.verdict);
8727
+ const decision = hasInput ? applyDecisionContext(base, input) : base;
8682
8728
  await storage.saveDecision(decision);
8683
8729
  return { decision, created: true };
8684
8730
  }
8685
- async function ensureDecisionForCoachSession(storage, session, decisionText) {
8731
+ async function ensureDecisionForCoachSession(storage, session, decisionText, input = {}) {
8686
8732
  const existing = (await storage.loadDecisions()).find((d) => d.source.decisionSessionId === session.id);
8687
8733
  if (existing) {
8688
- const updated = {
8689
- ...existing,
8690
- decisionText,
8691
- status: existing.status === "resolved" ? existing.status : "acted",
8692
- decidedAt: existing.decidedAt ?? nowIso(),
8693
- updatedAt: nowIso()
8694
- };
8734
+ const updated = applyDecisionContext(
8735
+ {
8736
+ ...existing,
8737
+ decisionText,
8738
+ status: existing.status === "resolved" ? existing.status : "acted",
8739
+ decidedAt: existing.decidedAt ?? nowIso()
8740
+ },
8741
+ { ...input, principleIds: [...session.appliedPrinciples ?? [], ...input.principleIds ?? []] }
8742
+ );
8695
8743
  await storage.updateDecision(updated);
8696
8744
  return { decision: updated, created: false };
8697
8745
  }
8698
- const decision = promoteCoachSessionToDecision(session, decisionText);
8746
+ const decision = promoteCoachSessionToDecision(session, decisionText, input);
8699
8747
  await storage.saveDecision(decision);
8700
8748
  return { decision, created: true };
8701
8749
  }
@@ -12915,7 +12963,7 @@ init_claude_code_runner();
12915
12963
  init_logger();
12916
12964
  init_errors();
12917
12965
  import { join as join25 } from "path";
12918
- function buildDecisionCoachSystemPrompt(principles) {
12966
+ function buildDecisionCoachSystemPrompt(principles, blindSpots = []) {
12919
12967
  const activePrinciples = principles.filter((p) => p.isActive);
12920
12968
  const principlesBlock = activePrinciples.length === 0 ? "(no principles defined yet \u2014 ask the user what principles guide them)" : activePrinciples.sort((a, b) => b.priority - a.priority).map((p) => renderPrincipleForPrompt(p)).join("\n\n");
12921
12969
  return `You are a Principles-Based Decision Coach, inspired by Ray Dalio's approach at Bridgewater. Your role is to help the user make decisions based on their stated principles rather than emotional reactions.
@@ -12940,7 +12988,19 @@ You have **WebSearch** and **WebFetch**. The user's "Embrace Reality" instinct a
12940
12988
 
12941
12989
  5. **Use Trigger Questions**: Apply their own trigger questions back to them when relevant.
12942
12990
 
12943
- 6. **Weigh by Priority**: When multiple principles conflict, consider their stated priorities (1-10 scale).
12991
+ 6. **Weigh by Priority**: When multiple principles conflict, consider their stated priorities (1-10 scale), and weigh them in this specific case rather than by rank alone.
12992
+
12993
+ ## DALIO'S DECISION MOVES
12994
+ Use AT MOST TWO of these per reply: the ones that matter most right now. Save the rest for later turns, when the conversation gets there. A reply that walks through all of them is a checklist, not coaching.
12995
+ - **"Another one of those"**: Early on, name what *type* of situation this is ("this is another one of those: a client who wants the work without the budget"). Ask whether they have met it before and what they did and how it went. Their principles for that type apply.
12996
+ - **Goal vs. desire**: Ask what the goal is. A goal is what they really want to achieve; a desire is a want that can pull them away from it. Must-dos come before like-to-dos.
12997
+ - **The criteria**: Before they decide, ask which 2-4 criteria will decide this one, in their own words, and which principles those criteria come from. Suggest they write them down: that is what makes it possible to learn from the outcome later.
12998
+ - **The bet (expected value)**: Every decision is a bet. Ask: how likely is it to work, what do you gain if you are right, what does it cost if you are wrong? The most likely option is not always the best bet, and knowing when NOT to bet matters as much. Do not confuse what is possible with what is probable.
12999
+ - **Over time**: Ask about the second- and third-order consequences, not just the first. A choice that feels good now can cost later, and the other way around.
13000
+ - **Value of information vs. cost of waiting**: Ask whether more information would really change the decision, and what it costs not to decide yet.
13001
+
13002
+ ## EMOTIONS ARE DATA
13003
+ Strong feelings (frustration, fear, excitement, pain) are a signal, not noise. Name the feeling, and ask what it is pointing at: a real problem, a principle being violated, or a pattern that keeps repeating. Pain + reflection = progress. Do not let the feeling make the decision. If they are in the heat of it, suggest deciding after the feeling has settled, and say what to reflect on then.
12944
13004
 
12945
13005
  ## YOUR TONE
12946
13006
  - Be direct and honest (radical transparency)
@@ -12953,18 +13013,28 @@ You have **WebSearch** and **WebFetch**. The user's "Embrace Reality" instinct a
12953
13013
  - Use markdown for structure
12954
13014
  - Bold principle names when referencing them
12955
13015
  - Use bullet points for questions to consider
12956
- - Keep responses focused and actionable
13016
+ - Keep responses focused and actionable: as a rule under 200 words, with one main question
12957
13017
  - Always end with a question or call to reflection
12958
13018
 
12959
13019
  ## IMPORTANT
12960
13020
  - Never make the decision for them
12961
13021
  - Always ground guidance in THEIR principles
12962
- - If they're being emotional, redirect to principle-based thinking
13022
+ - If they're being emotional, treat the emotion as data (see above), then bring them back to their principles
12963
13023
  - Reference specific principles by name and priority
12964
13024
  - If no principles seem relevant, say so and ask clarifying questions
12965
13025
 
12966
13026
  USER'S PRINCIPLES:
12967
- ${principlesBlock}`;
13027
+ ${principlesBlock}${renderBlindSpotsBlock(blindSpots)}`;
13028
+ }
13029
+ function renderBlindSpotsBlock(blindSpots) {
13030
+ if (blindSpots.length === 0) return "";
13031
+ const lines = blindSpots.map((b) => `- ${b.text}${b.evidence ? ` (seen: ${b.evidence})` : ""}`);
13032
+ return `
13033
+
13034
+ USER'S KNOWN BLIND SPOTS (they wrote these down themselves):
13035
+ ${lines.join("\n")}
13036
+
13037
+ Check every situation against this list. When one is plausibly at play, name it plainly and ask about it ("Could this be your blind spot about \u2026?"). When none is, do not mention the list.`;
12968
13038
  }
12969
13039
  function buildCoachWikiInstruction(wikiDir) {
12970
13040
  const dir = wikiDir.replace(/\\/g, "/");
@@ -13048,7 +13118,7 @@ async function coachReply(session, principles, userMessage, settings, opts = {})
13048
13118
  const useWiki = !!opts.useWiki;
13049
13119
  const wikiDir = opts.wikiDir ?? (opts.workspaceRoot ? join25(opts.workspaceRoot, "wiki") : void 0);
13050
13120
  const transcript = buildTranscript(session, userTurn, isOpener);
13051
- const systemPrompt = buildDecisionCoachSystemPrompt(principles);
13121
+ const systemPrompt = buildDecisionCoachSystemPrompt(principles, opts.blindSpots ?? []);
13052
13122
  const wikiBlock = useWiki && wikiDir ? `
13053
13123
 
13054
13124
  ${buildCoachWikiInstruction(wikiDir)}` : "";
@@ -17014,7 +17084,7 @@ async function startUiServer(opts) {
17014
17084
  const settings = await opts.storage.loadSettings();
17015
17085
  const principles = await opts.storage.loadPrinciples();
17016
17086
  broadcast({ type: "coach_thinking", sessionId: session.id });
17017
- const { session: updated, reply } = await coachReply(session, principles, "", settings, coachWikiOpts(session));
17087
+ const { session: updated, reply } = await coachReply(session, principles, "", settings, { ...coachWikiOpts(session), blindSpots: await opts.storage.loadBlindSpots() });
17018
17088
  await opts.storage.updateDecisionSession(updated);
17019
17089
  broadcast({ type: "coach_message", sessionId: updated.id, message: reply, session: updated });
17020
17090
  } catch (error) {
@@ -17057,7 +17127,7 @@ async function startUiServer(opts) {
17057
17127
  const settings = await opts.storage.loadSettings();
17058
17128
  const principles = await opts.storage.loadPrinciples();
17059
17129
  const content = body.content.trim();
17060
- const { session: updated, reply } = await coachReply(session, principles, content, settings, coachWikiOpts(session));
17130
+ const { session: updated, reply } = await coachReply(session, principles, content, settings, { ...coachWikiOpts(session), blindSpots: await opts.storage.loadBlindSpots() });
17061
17131
  await opts.storage.updateDecisionSession(updated);
17062
17132
  broadcast({ type: "coach_message", sessionId: updated.id, message: reply, session: updated });
17063
17133
  if (updated.useBusinessWiki) {
@@ -21604,6 +21674,74 @@ function truncate5(text, max) {
21604
21674
 
21605
21675
  // src/commands/coach.ts
21606
21676
  init_errors();
21677
+
21678
+ // src/core/decisions/decision-context.ts
21679
+ init_errors();
21680
+ function collect2(value, previous = []) {
21681
+ return [...previous, value];
21682
+ }
21683
+ function addDecisionContextOptions(cmd) {
21684
+ return cmd.option("--criterion <text>", "a criterion that decides this one (repeatable)", collect2, []).option("--principle <idOrTitle>", "a principle the decision rests on: id, short id or title (repeatable)", collect2, []).option("--door <type>", "one-way (hard to undo) or two-way (easy to undo)").option("--review-days <n>", "look back at the outcome in this many days (default: 14 one-way, 60 two-way)").option("--probability <0-100>", "your own estimate that it works out; makes the decision count in calibration");
21685
+ }
21686
+ function resolvePrincipleRef(principles, ref) {
21687
+ const q = ref.trim();
21688
+ const lower = q.toLowerCase();
21689
+ const exact = principles.find((p) => p.id === q);
21690
+ if (exact) return exact;
21691
+ if (q.length >= 4) {
21692
+ const byShort = principles.filter((p) => p.id.startsWith(q));
21693
+ if (byShort.length === 1) return byShort[0];
21694
+ }
21695
+ const byTitle = principles.find((p) => p.title.toLowerCase() === lower);
21696
+ if (byTitle) return byTitle;
21697
+ const partial = principles.filter((p) => p.title.toLowerCase().includes(lower));
21698
+ if (partial.length === 1) return partial[0];
21699
+ const active = partial.filter((p) => p.isActive);
21700
+ if (active.length === 1) return active[0];
21701
+ if (partial.length > 1) {
21702
+ throw new UserError(
21703
+ `"${ref}" matches several principles: ${partial.map((p) => `${p.title} (${p.id.slice(0, 8)})`).join(", ")}`,
21704
+ "Use more of the title or the short id."
21705
+ );
21706
+ }
21707
+ throw new UserError(`No principle matches "${ref}"`, "Run `aab principles list`.");
21708
+ }
21709
+ function decisionContextFromFlags(flags, principles) {
21710
+ let doorType;
21711
+ if (flags.door !== void 0) {
21712
+ if (flags.door !== "one-way" && flags.door !== "two-way") {
21713
+ throw new UserError(`--door must be one-way or two-way, not "${flags.door}"`);
21714
+ }
21715
+ doorType = flags.door;
21716
+ }
21717
+ let reviewDays;
21718
+ if (flags.reviewDays !== void 0) {
21719
+ const n = Number(flags.reviewDays);
21720
+ if (!Number.isFinite(n) || n <= 0) throw new UserError("--review-days must be a positive number of days");
21721
+ reviewDays = n;
21722
+ }
21723
+ let probability;
21724
+ if (flags.probability !== void 0) {
21725
+ const n = Number(String(flags.probability).replace(/%$/, ""));
21726
+ if (!Number.isFinite(n) || n < 0 || n > 100) throw new UserError("--probability must be a number from 0 to 100");
21727
+ probability = n;
21728
+ }
21729
+ return {
21730
+ probability,
21731
+ criteria: flags.criterion ?? [],
21732
+ principleIds: (flags.principle ?? []).map((ref) => resolvePrincipleRef(principles, ref).id),
21733
+ doorType,
21734
+ reviewDays
21735
+ };
21736
+ }
21737
+ function principleTitles(ids, principles) {
21738
+ return (ids ?? []).map((id) => {
21739
+ const p = principles.find((pp) => pp.id === id);
21740
+ return p ? p.title : `${id.slice(0, 8)} (deleted principle)`;
21741
+ });
21742
+ }
21743
+
21744
+ // src/commands/coach.ts
21607
21745
  function registerCoachCommand(program) {
21608
21746
  const coach = program.command("coach").description("principle-based decision coach (Dalio-style)");
21609
21747
  coach.option("--resume <id>", "resume an existing decision session").option("--situation <text>", "situation prompt (for a brand-new session)").option("--title <text>", "title for a brand-new session").option("--no-stream", "disable token streaming (useful for testing)").option("--wiki", "wire the Business/Knowledge Wiki to the coach for this session (reads + ingests)").action(async (opts) => {
@@ -21657,7 +21795,7 @@ function registerCoachCommand(program) {
21657
21795
  principles,
21658
21796
  "",
21659
21797
  settings,
21660
- coachWikiRunOpts(session, ctx.workspace.root)
21798
+ { ...coachWikiRunOpts(session, ctx.workspace.root), blindSpots: await ctx.storage.loadBlindSpots() }
21661
21799
  );
21662
21800
  sp.stop();
21663
21801
  session = updated;
@@ -21685,7 +21823,7 @@ function registerCoachCommand(program) {
21685
21823
  principles,
21686
21824
  trimmed,
21687
21825
  settings,
21688
- coachWikiRunOpts(session, ctx.workspace.root)
21826
+ { ...coachWikiRunOpts(session, ctx.workspace.root), blindSpots: await ctx.storage.loadBlindSpots() }
21689
21827
  );
21690
21828
  sp.stop();
21691
21829
  session = updated;
@@ -21722,7 +21860,7 @@ function registerCoachCommand(program) {
21722
21860
  principles,
21723
21861
  message,
21724
21862
  settings,
21725
- coachWikiRunOpts(session, ctx.workspace.root)
21863
+ { ...coachWikiRunOpts(session, ctx.workspace.root), blindSpots: await ctx.storage.loadBlindSpots() }
21726
21864
  );
21727
21865
  await ctx.storage.updateDecisionSession(updated);
21728
21866
  fireCoachIngest(updated, settings, ctx.storage, message);
@@ -21817,11 +21955,19 @@ ${c.bold(session.title ?? "Decision session")} ${c.hint("\xB7 " + session.id.sli
21817
21955
  await closeContext(ctx);
21818
21956
  }
21819
21957
  });
21820
- coach.command("decide <sessionId> <decision>").description('record the decision the user made and flip status to "decided"').action(async (sessionId, decision) => {
21958
+ addDecisionContextOptions(
21959
+ coach.command("decide <sessionId> <decision>").description('record the decision the user made, with its criteria and principles, and flip status to "decided"')
21960
+ ).action(async (sessionId, decision, flags) => {
21821
21961
  const ctx = await openContext(coach);
21822
21962
  try {
21823
- const session = await ctx.storage.loadDecisionSessionById(sessionId);
21963
+ let session = await ctx.storage.loadDecisionSessionById(sessionId);
21964
+ if (!session && sessionId.length >= 4) {
21965
+ const matches = (await ctx.storage.loadDecisionSessions()).filter((s) => s.id.startsWith(sessionId));
21966
+ if (matches.length > 1) throw new UserError(`Several coach sessions match "${sessionId}"`, "Use more of the id.");
21967
+ session = matches[0] ?? null;
21968
+ }
21824
21969
  if (!session) throw new UserError(`No coach session matches "${sessionId}"`);
21970
+ const input = decisionContextFromFlags(flags, await ctx.storage.loadPrinciples());
21825
21971
  const updated = {
21826
21972
  ...session,
21827
21973
  decision,
@@ -21829,13 +21975,15 @@ ${c.bold(session.title ?? "Decision session")} ${c.hint("\xB7 " + session.id.sli
21829
21975
  updatedAt: nowIso()
21830
21976
  };
21831
21977
  await ctx.storage.updateDecisionSession(updated);
21832
- const tracked = await ensureDecisionForCoachSession(ctx.storage, updated, decision);
21978
+ const tracked = await ensureDecisionForCoachSession(ctx.storage, updated, decision, input);
21833
21979
  if (ctx.json) {
21834
21980
  process.stdout.write(JSON.stringify({ session: updated, decision: tracked.decision, decisionCreated: tracked.created }, null, 2) + "\n");
21835
21981
  return;
21836
21982
  }
21837
- process.stdout.write(`${c.ok("\u2713")} Decision recorded for ${updated.id.slice(0, 8)}
21838
- `);
21983
+ process.stdout.write(
21984
+ `${c.ok("\u2713")} Decision recorded for ${updated.id.slice(0, 8)} as ${tracked.decision.id.slice(0, 8)}. Review due ${tracked.decision.reviewDueAt?.slice(0, 10) ?? "n/a"}.
21985
+ `
21986
+ );
21839
21987
  } finally {
21840
21988
  await closeContext(ctx);
21841
21989
  }
@@ -21925,19 +22073,24 @@ function registerShow4(parent) {
21925
22073
  process.stdout.write(JSON.stringify({ decision }, null, 2) + "\n");
21926
22074
  return;
21927
22075
  }
21928
- process.stdout.write(renderDecisionDetail(decision));
22076
+ process.stdout.write(renderDecisionDetail(decision, await ctx.storage.loadPrinciples()));
21929
22077
  } finally {
21930
22078
  await closeContext(ctx);
21931
22079
  }
21932
22080
  });
21933
22081
  }
21934
22082
  function registerRecord(parent) {
21935
- parent.command("record <id> <decisionText>").description("mark an open decision as acted").action(async (id, decisionText) => {
22083
+ addDecisionContextOptions(
22084
+ parent.command("record <id> <decisionText>").description("mark an open decision as acted; add the criteria and principles it rests on")
22085
+ ).action(async (id, decisionText, flags) => {
21936
22086
  const ctx = await openContext(parent);
21937
22087
  try {
21938
22088
  const decision = await resolveDecisionByIdOrPrefix(ctx.storage, id);
21939
22089
  if (!decision) throw new UserError(`No decision matches "${id}"`);
21940
- const updated = await recordDecision({ storage: ctx.storage, decision, decisionText });
22090
+ const input = decisionContextFromFlags(flags, await ctx.storage.loadPrinciples());
22091
+ const recorded = await recordDecision({ storage: ctx.storage, decision, decisionText });
22092
+ const updated = applyDecisionContext(recorded, input);
22093
+ await ctx.storage.updateDecision(updated);
21941
22094
  if (ctx.json) {
21942
22095
  process.stdout.write(JSON.stringify({ decision: updated }, null, 2) + "\n");
21943
22096
  return;
@@ -21978,21 +22131,26 @@ function registerOutcome(parent) {
21978
22131
  });
21979
22132
  }
21980
22133
  function registerFromDiscussion(parent) {
21981
- parent.command("from-discussion <id>").description("promote a discussion verdict into an open Decision").action(async (id) => {
22134
+ addDecisionContextOptions(
22135
+ parent.command("from-discussion <id>").description("promote a discussion verdict into an open Decision (with its criteria and principles)")
22136
+ ).action(async (id, flags) => {
21982
22137
  const ctx = await openContext(parent);
21983
22138
  try {
21984
22139
  const discussion = await resolveDiscussion2(ctx.storage, id);
21985
22140
  if (!discussion.verdict) {
21986
22141
  throw new UserError("Discussion has no Board Verdict to promote.", "Run `aab discuss verdict <id>` first.");
21987
22142
  }
21988
- const result = await ensureDecisionForDiscussion(ctx.storage, discussion);
22143
+ const input = decisionContextFromFlags(flags, await ctx.storage.loadPrinciples());
22144
+ const result = await ensureDecisionForDiscussion(ctx.storage, discussion, input);
21989
22145
  if (!result) throw new UserError("Could not promote discussion verdict.");
21990
22146
  if (ctx.json) {
21991
22147
  process.stdout.write(JSON.stringify({ decision: result.decision, created: result.created }, null, 2) + "\n");
21992
22148
  return;
21993
22149
  }
21994
- process.stdout.write(`${c.ok("\u2713")} ${result.created ? "Created" : "Already tracking"} decision ${shortId(result.decision.id)}.
22150
+ const verb = result.created ? "Created" : "Updated";
22151
+ process.stdout.write(`${c.ok("\u2713")} ${verb} decision ${shortId(result.decision.id)}. Review due ${result.decision.reviewDueAt?.slice(0, 10) ?? "n/a"}.
21995
22152
  `);
22153
+ printMissingContext(result.decision);
21996
22154
  } finally {
21997
22155
  await closeContext(ctx);
21998
22156
  }
@@ -22047,7 +22205,18 @@ function renderDecisionRow(d) {
22047
22205
  const due = d.reviewDueAt && d.status !== "resolved" && d.reviewDueAt <= (/* @__PURE__ */ new Date()).toISOString() ? " review-due" : "";
22048
22206
  return `${shortId(d.id)} ${d.status.padEnd(8)} ${d.doorType.padEnd(7)}${conf.padEnd(18)} ${d.title}${due ? c.warn(` (${due.trim()})`) : ""}`;
22049
22207
  }
22050
- function renderDecisionDetail(d) {
22208
+ function printMissingContext(d) {
22209
+ const missing = [];
22210
+ if (!d.criteria?.length) missing.push("criteria (--criterion)");
22211
+ if (!d.principleIds?.length) missing.push("principles (--principle)");
22212
+ if (missing.length > 0) {
22213
+ process.stdout.write(
22214
+ c.hint(` No ${missing.join(" or ")} yet. Without them the outcome cannot be traced back to what you decided on.
22215
+ `)
22216
+ );
22217
+ }
22218
+ }
22219
+ function renderDecisionDetail(d, principles = []) {
22051
22220
  const lines = [
22052
22221
  `${c.brand("Decision")} ${shortId(d.id)}`,
22053
22222
  `${c.hint("status:")} ${d.status}`,
@@ -22061,6 +22230,8 @@ function renderDecisionDetail(d) {
22061
22230
  if (d.outcome) lines.push(`${c.hint("outcome:")} ${d.outcome}${d.brierScore !== void 0 ? ` \xB7 Brier ${d.brierScore}` : ""}`);
22062
22231
  if (d.outcomeNotes) lines.push(`${c.hint("notes:")} ${d.outcomeNotes}`);
22063
22232
  if (d.signalsToWatch.length > 0) lines.push(`${c.hint("signals:")} ${d.signalsToWatch.join("; ")}`);
22233
+ if (d.criteria?.length) lines.push(`${c.hint("criteria:")} ${d.criteria.join("; ")}`);
22234
+ if (d.principleIds?.length) lines.push(`${c.hint("principles:")} ${principleTitles(d.principleIds, principles).join("; ")}`);
22064
22235
  return lines.join("\n") + "\n";
22065
22236
  }
22066
22237
  function renderCalibration(summary) {
@@ -22080,6 +22251,105 @@ function renderCalibration(summary) {
22080
22251
  return lines.join("\n") + "\n";
22081
22252
  }
22082
22253
 
22254
+ // src/commands/blindspots.ts
22255
+ init_errors();
22256
+ function registerBlindSpotsCommand(program) {
22257
+ const cmd = program.command("blindspots").alias("blind-spots").description("your known blind spots; the decision coach checks each situation against them");
22258
+ cmd.command("list").description("list blind spots").action(async () => {
22259
+ const ctx = await openContext(cmd, { lock: false });
22260
+ try {
22261
+ const list = await ctx.storage.loadBlindSpots();
22262
+ if (ctx.json) {
22263
+ process.stdout.write(JSON.stringify({ blindSpots: list }, null, 2) + "\n");
22264
+ return;
22265
+ }
22266
+ if (list.length === 0) {
22267
+ process.stdout.write(c.hint('No blind spots written down yet. Add one with `aab blindspots add "<text>"`.\n'));
22268
+ return;
22269
+ }
22270
+ for (const b of list) {
22271
+ process.stdout.write(`${b.id.slice(0, 8)} ${b.text}
22272
+ `);
22273
+ if (b.evidence) process.stdout.write(c.hint(` seen: ${b.evidence}
22274
+ `));
22275
+ }
22276
+ } finally {
22277
+ await closeContext(ctx);
22278
+ }
22279
+ });
22280
+ cmd.command("add <text>").description("write down a blind spot").option("--evidence <text>", "where it showed up (keeps it grounded in a real case)").action(async (text, opts) => {
22281
+ const ctx = await openContext(cmd);
22282
+ try {
22283
+ const trimmed = text.trim();
22284
+ if (!trimmed) throw new UserError("The blind spot text is empty.");
22285
+ const list = await ctx.storage.loadBlindSpots();
22286
+ const now = nowIso();
22287
+ const item = {
22288
+ id: generateUUID(),
22289
+ text: trimmed,
22290
+ evidence: opts.evidence?.trim() || void 0,
22291
+ createdAt: now,
22292
+ updatedAt: now
22293
+ };
22294
+ await ctx.storage.saveBlindSpots([...list, item]);
22295
+ if (ctx.json) {
22296
+ process.stdout.write(JSON.stringify({ blindSpot: item }, null, 2) + "\n");
22297
+ return;
22298
+ }
22299
+ process.stdout.write(`${c.ok("\u2713")} Added ${item.id.slice(0, 8)}. The coach checks it from the next turn.
22300
+ `);
22301
+ } finally {
22302
+ await closeContext(ctx);
22303
+ }
22304
+ });
22305
+ cmd.command("edit <id> [text]").description("change the text or evidence of a blind spot").option("--evidence <text>", 'where it showed up ("" clears it)').action(async (id, text, opts) => {
22306
+ const ctx = await openContext(cmd);
22307
+ try {
22308
+ const list = await ctx.storage.loadBlindSpots();
22309
+ const target = findBlindSpot(list, id);
22310
+ const updated = {
22311
+ ...target,
22312
+ text: text?.trim() || target.text,
22313
+ evidence: opts.evidence !== void 0 ? opts.evidence.trim() || void 0 : target.evidence,
22314
+ updatedAt: nowIso()
22315
+ };
22316
+ await ctx.storage.saveBlindSpots(list.map((b) => b.id === target.id ? updated : b));
22317
+ if (ctx.json) {
22318
+ process.stdout.write(JSON.stringify({ blindSpot: updated }, null, 2) + "\n");
22319
+ return;
22320
+ }
22321
+ process.stdout.write(`${c.ok("\u2713")} Updated ${target.id.slice(0, 8)}.
22322
+ `);
22323
+ } finally {
22324
+ await closeContext(ctx);
22325
+ }
22326
+ });
22327
+ cmd.command("remove <id>").description("remove a blind spot").action(async (id) => {
22328
+ const ctx = await openContext(cmd);
22329
+ try {
22330
+ const list = await ctx.storage.loadBlindSpots();
22331
+ const target = findBlindSpot(list, id);
22332
+ await ctx.storage.saveBlindSpots(list.filter((b) => b.id !== target.id));
22333
+ if (ctx.json) {
22334
+ process.stdout.write(JSON.stringify({ removed: target.id }, null, 2) + "\n");
22335
+ return;
22336
+ }
22337
+ process.stdout.write(`${c.ok("\u2713")} Removed ${target.id.slice(0, 8)}.
22338
+ `);
22339
+ } finally {
22340
+ await closeContext(ctx);
22341
+ }
22342
+ });
22343
+ }
22344
+ function findBlindSpot(list, id) {
22345
+ const exact = list.find((b) => b.id === id);
22346
+ if (exact) return exact;
22347
+ const matches = id.length >= 4 ? list.filter((b) => b.id.startsWith(id)) : [];
22348
+ if (matches.length === 1) return matches[0];
22349
+ if (matches.length > 1) throw new UserError(`Several blind spots match "${id}"`, "Use more of the id.");
22350
+ throw new UserError(`No blind spot matches "${id}"`, "Run `aab blindspots list`.");
22351
+ }
22352
+
22083
22353
  // src/commands/actions.ts
22084
22354
  init_errors();
22085
22355
  import { writeFileSync as writeFileSync24 } from "fs";
@@ -22862,6 +23132,7 @@ async function runCli(argv) {
22862
23132
  registerPrinciplesCommand(program);
22863
23133
  registerCoachCommand(program);
22864
23134
  registerDecideCommand(program);
23135
+ registerBlindSpotsCommand(program);
22865
23136
  registerActionsCommand(program);
22866
23137
  registerSkillsCommand(program);
22867
23138
  program.action(() => {