@cam5/baby-bird 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -6
- package/dist/{chunk-7ALXKEST.js → chunk-YI2UL4IC.js} +189 -39
- package/dist/chunk-YI2UL4IC.js.map +1 -0
- package/dist/cli.js +153 -48
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +89 -13
- package/dist/index.js +13 -1
- package/package.json +1 -1
- package/dist/chunk-7ALXKEST.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -4,32 +4,37 @@ import {
|
|
|
4
4
|
BbError,
|
|
5
5
|
CliRenderer,
|
|
6
6
|
CommandProvider,
|
|
7
|
+
ConfigError,
|
|
7
8
|
NotARepoError,
|
|
8
9
|
TourCache,
|
|
9
10
|
UsageError,
|
|
10
11
|
allPresets,
|
|
12
|
+
buildChatContext,
|
|
13
|
+
chatSlots,
|
|
11
14
|
describeSource2 as describeSource,
|
|
12
15
|
generateTour,
|
|
16
|
+
git,
|
|
13
17
|
gitRoot,
|
|
18
|
+
launchChat,
|
|
14
19
|
loadConfig,
|
|
15
20
|
prepareTour,
|
|
16
21
|
projectConfigPath,
|
|
17
22
|
relativeTime,
|
|
23
|
+
resolveChat,
|
|
18
24
|
resolveLlm,
|
|
19
|
-
supports256Colors,
|
|
20
25
|
wrap,
|
|
21
26
|
writeMaybePaged,
|
|
22
27
|
writeStdout
|
|
23
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-YI2UL4IC.js";
|
|
24
29
|
|
|
25
30
|
// src/cli/main.ts
|
|
26
31
|
import { Command, InvalidArgumentError } from "commander";
|
|
27
|
-
import
|
|
32
|
+
import pc6 from "picocolors";
|
|
28
33
|
|
|
29
34
|
// package.json
|
|
30
35
|
var package_default = {
|
|
31
36
|
name: "@cam5/baby-bird",
|
|
32
|
-
version: "0.1.
|
|
37
|
+
version: "0.1.2",
|
|
33
38
|
description: "Guided code tours for git changes, on the command line.",
|
|
34
39
|
license: "MIT",
|
|
35
40
|
type: "module",
|
|
@@ -105,7 +110,6 @@ function flagsToOverrides(flags) {
|
|
|
105
110
|
if (flags.cache === false) o.cache = { enabled: false };
|
|
106
111
|
if (flags.pager === false) o.render = { ...o.render ?? {}, pager: "never" };
|
|
107
112
|
if (flags.highlight === false) o.render = { ...o.render ?? {}, highlight: "never" };
|
|
108
|
-
if (flags.theme) o.render = { ...o.render ?? {}, theme: flags.theme };
|
|
109
113
|
return o;
|
|
110
114
|
}
|
|
111
115
|
async function openSession(flags, opts) {
|
|
@@ -132,9 +136,8 @@ function resolveColor(mode) {
|
|
|
132
136
|
return Boolean(process.stdout.isTTY) && process.env.TERM !== "dumb";
|
|
133
137
|
}
|
|
134
138
|
function resolveHighlight(mode, colorEnabled) {
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
return supports256Colors();
|
|
139
|
+
if (mode === "never") return false;
|
|
140
|
+
return colorEnabled;
|
|
138
141
|
}
|
|
139
142
|
function terminalWidth(configured, stream = process.stdout) {
|
|
140
143
|
return configured ?? (stream.columns || 80);
|
|
@@ -201,6 +204,13 @@ async function configCommand(flags) {
|
|
|
201
204
|
} catch (err) {
|
|
202
205
|
out.push(` ${c.red(err.message)}`);
|
|
203
206
|
}
|
|
207
|
+
try {
|
|
208
|
+
const chat = resolveChat(config);
|
|
209
|
+
const provider = new CommandProvider({ command: chat.command, promptVia: "arg", timeoutMs: 1 });
|
|
210
|
+
out.push(` chat: ${provider.describe()}${c.dim(" (bb ask)")}`);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
out.push(` chat: ${c.dim(`none: ${err.message}`)}`);
|
|
213
|
+
}
|
|
204
214
|
out.push("");
|
|
205
215
|
out.push(c.bold("Presets"));
|
|
206
216
|
const presets = allPresets(config);
|
|
@@ -215,32 +225,13 @@ async function configCommand(flags) {
|
|
|
215
225
|
process.stdout.write(out.join("\n") + "\n");
|
|
216
226
|
}
|
|
217
227
|
|
|
218
|
-
// src/cli/
|
|
219
|
-
import
|
|
220
|
-
import { dirname } from "path";
|
|
221
|
-
var STARTER = {
|
|
222
|
-
llm: { preset: "claude" },
|
|
223
|
-
codehost: { provider: "gh" }
|
|
224
|
-
};
|
|
225
|
-
async function initCommand(flags) {
|
|
226
|
-
const session = await openSession(flags, { requireRepo: true });
|
|
227
|
-
if (!session.root) throw new NotARepoError(session.cwd);
|
|
228
|
-
const path = projectConfigPath(session.root);
|
|
229
|
-
const existing = session.loaded.layers.find((l) => l.name === "project");
|
|
230
|
-
if (existing?.found && !flags.force) {
|
|
231
|
-
throw new UsageError(`${path} already exists.`, "Pass --force to overwrite it.");
|
|
232
|
-
}
|
|
233
|
-
await mkdir(dirname(path), { recursive: true });
|
|
234
|
-
await writeFile(path, JSON.stringify(STARTER, null, 2) + "\n", "utf8");
|
|
235
|
-
process.stdout.write(`Wrote ${path}
|
|
236
|
-
Run \`bb config\` to see the effective configuration and available presets.
|
|
237
|
-
`);
|
|
238
|
-
}
|
|
228
|
+
// src/cli/ask-cmd.ts
|
|
229
|
+
import pc5 from "picocolors";
|
|
239
230
|
|
|
240
231
|
// src/cli/progress.ts
|
|
241
232
|
import pc4 from "picocolors";
|
|
242
233
|
var SPINNER = ["\u2722", "\u2733", "\u2736", "\u273B", "\u273D", "\u273B", "\u2736", "\u2733"];
|
|
243
|
-
var VERBS = ["Hatching", "Pecking", "Nesting", "Chirping", "Preening", "Fledging", "Brooding", "Warbling", "Peeping"];
|
|
234
|
+
var VERBS = ["Hatching", "Pecking", "Nesting", "Chirping", "Preening", "Fledging", "Brooding", "Warbling", "Peeping", "Squawking", "Swooping", "Tweeting", "Xeeting", "Cawing", "Twiddling About", "Hopping", "\u{1F425}-ing", "\u{1F423}-ing", "Masticating"];
|
|
244
235
|
var THINKING_TAIL_CHARS = 2e3;
|
|
245
236
|
var VERB_INTERVAL_MS = 7500;
|
|
246
237
|
var LiveProgress = class {
|
|
@@ -463,6 +454,104 @@ function formatCount(n) {
|
|
|
463
454
|
return n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
|
|
464
455
|
}
|
|
465
456
|
|
|
457
|
+
// src/cli/ask-cmd.ts
|
|
458
|
+
async function splitAskArgs(words, opts) {
|
|
459
|
+
const [first, ...rest] = words;
|
|
460
|
+
if (first !== void 0 && opts.rangeAllowed && await isRange(first, opts.cwd)) {
|
|
461
|
+
return { range: first, message: joinMessage(rest) };
|
|
462
|
+
}
|
|
463
|
+
return { message: joinMessage(words) };
|
|
464
|
+
}
|
|
465
|
+
async function isRange(word, cwd) {
|
|
466
|
+
if (!word || /\s/.test(word)) return false;
|
|
467
|
+
const res = await git(["rev-parse", "--quiet", "--end-of-options", word], { cwd, allowFailure: true });
|
|
468
|
+
return res.code === 0;
|
|
469
|
+
}
|
|
470
|
+
function joinMessage(words) {
|
|
471
|
+
const text = words.join(" ").trim();
|
|
472
|
+
return text ? text : void 0;
|
|
473
|
+
}
|
|
474
|
+
async function askCommand(words, flags) {
|
|
475
|
+
const session = await openSession(flags, { requireRepo: true });
|
|
476
|
+
if (!session.root) throw new NotARepoError(session.cwd);
|
|
477
|
+
const { config } = session.loaded;
|
|
478
|
+
const c = pc5.createColors(session.colorEnabled);
|
|
479
|
+
const chat = resolveChat(config);
|
|
480
|
+
const slots = chatSlots(chat.command);
|
|
481
|
+
if (!slots.context) {
|
|
482
|
+
throw new ConfigError("The chat command has no {context-file} or {context} token, so the tour cannot be handed to it.", "Add one of them to the chatCommand; see the README.");
|
|
483
|
+
}
|
|
484
|
+
const llm = resolveLlm(config);
|
|
485
|
+
const { range, message } = await splitAskArgs(words, { cwd: session.root, rangeAllowed: !flags.working && !flags.staged });
|
|
486
|
+
session.debug(range ? `range: ${range}` : "no range argument");
|
|
487
|
+
session.debug(message ? `opening message: ${JSON.stringify(message)}` : "no opening message");
|
|
488
|
+
const live = flags.progress !== false && !flags.debug && Boolean(process.stderr.isTTY) && !flags.dumpContext;
|
|
489
|
+
const progress = live ? new LiveProgress(process.stderr, { color: session.colorEnabled, width: terminalWidth(null, process.stderr) }) : loggingProgress(session.debug);
|
|
490
|
+
const options = {
|
|
491
|
+
cwd: session.root,
|
|
492
|
+
config,
|
|
493
|
+
cacheDir: session.loaded.cacheDir,
|
|
494
|
+
range: { arg: range, working: flags.working, staged: flags.staged },
|
|
495
|
+
refresh: flags.refresh,
|
|
496
|
+
noCache: flags.cache === false,
|
|
497
|
+
debug: session.debug,
|
|
498
|
+
warn: session.warn,
|
|
499
|
+
progress
|
|
500
|
+
};
|
|
501
|
+
if (progress instanceof LiveProgress) progress.start();
|
|
502
|
+
let prepared;
|
|
503
|
+
let result;
|
|
504
|
+
try {
|
|
505
|
+
prepared = await prepareTour(options);
|
|
506
|
+
result = await generateTour(options, prepared);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
if (progress instanceof LiveProgress) progress.stop();
|
|
509
|
+
throw err;
|
|
510
|
+
}
|
|
511
|
+
if (progress instanceof LiveProgress) progress.stop(result.fromCache ? void 0 : progress.summary());
|
|
512
|
+
const context = buildChatContext({ tour: result.tour, change: prepared.context, maxBytes: llm.maxPromptBytes, tourPath: result.cachePath });
|
|
513
|
+
if (context.truncation.truncated.length || context.truncation.omitted.length) {
|
|
514
|
+
session.warn(`Chat context exceeded ${llm.maxPromptBytes} bytes; truncated ${context.truncation.truncated.length} and omitted ${context.truncation.omitted.length} file diff(s).`);
|
|
515
|
+
}
|
|
516
|
+
if (flags.dumpContext) {
|
|
517
|
+
await writeStdout(context.text.endsWith("\n") ? context.text : context.text + "\n");
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const tour = result.tour;
|
|
521
|
+
const when = result.fromCache ? `cached ${relativeTime(tour.generatedAt)}` : "generated just now";
|
|
522
|
+
process.stderr.write(`${c.bold(`\u{1F423} ${tour.title}`)}${c.dim(` \xB7 ${describeSource(tour.source)} \xB7 ${when}`)}
|
|
523
|
+
`);
|
|
524
|
+
if (message && !slots.message) {
|
|
525
|
+
session.warn("This chat command has no {message} slot; type your question into the chat once it opens.");
|
|
526
|
+
}
|
|
527
|
+
process.stderr.write(c.dim(`Opening ${chat.preset ?? chat.command[0]} with the tour as context\u2026
|
|
528
|
+
`));
|
|
529
|
+
const outcome = await launchChat({ command: chat.command, context: context.text, message, cwd: session.root, env: chat.env, debug: session.debug });
|
|
530
|
+
process.exitCode = outcome.exitCode;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/cli/init-cmd.ts
|
|
534
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
535
|
+
import { dirname } from "path";
|
|
536
|
+
var STARTER = {
|
|
537
|
+
llm: { preset: "claude" },
|
|
538
|
+
codehost: { provider: "gh" }
|
|
539
|
+
};
|
|
540
|
+
async function initCommand(flags) {
|
|
541
|
+
const session = await openSession(flags, { requireRepo: true });
|
|
542
|
+
if (!session.root) throw new NotARepoError(session.cwd);
|
|
543
|
+
const path = projectConfigPath(session.root);
|
|
544
|
+
const existing = session.loaded.layers.find((l) => l.name === "project");
|
|
545
|
+
if (existing?.found && !flags.force) {
|
|
546
|
+
throw new UsageError(`${path} already exists.`, "Pass --force to overwrite it.");
|
|
547
|
+
}
|
|
548
|
+
await mkdir(dirname(path), { recursive: true });
|
|
549
|
+
await writeFile(path, JSON.stringify(STARTER, null, 2) + "\n", "utf8");
|
|
550
|
+
process.stdout.write(`Wrote ${path}
|
|
551
|
+
Run \`bb config\` to see the effective configuration and available presets.
|
|
552
|
+
`);
|
|
553
|
+
}
|
|
554
|
+
|
|
466
555
|
// src/cli/tour.ts
|
|
467
556
|
async function tourCommand(rangeArg, flags) {
|
|
468
557
|
const session = await openSession(flags, { requireRepo: true });
|
|
@@ -505,8 +594,7 @@ async function tourCommand(rangeArg, flags) {
|
|
|
505
594
|
width: terminalWidth(config.render.width),
|
|
506
595
|
section: flags.section,
|
|
507
596
|
fromCache: result.fromCache,
|
|
508
|
-
highlight: resolveHighlight(config.render.highlight, session.colorEnabled)
|
|
509
|
-
theme: config.render.theme
|
|
597
|
+
highlight: resolveHighlight(config.render.highlight, session.colorEnabled)
|
|
510
598
|
});
|
|
511
599
|
await writeMaybePaged(output, {
|
|
512
600
|
mode: config.render.pager,
|
|
@@ -521,6 +609,9 @@ function positiveInt(value) {
|
|
|
521
609
|
if (!Number.isInteger(n) || n < 1) throw new InvalidArgumentError("must be a positive integer");
|
|
522
610
|
return n;
|
|
523
611
|
}
|
|
612
|
+
function optsWithGlobals(cmd) {
|
|
613
|
+
return cmd.optsWithGlobals();
|
|
614
|
+
}
|
|
524
615
|
function addGlobalFlags(cmd) {
|
|
525
616
|
return cmd.option("-C, --cwd <dir>", "run as if started in <dir>").option("--preset <name>", "LLM preset to use (see `bb config`)").option("--color", "force colored output").option("--no-color", "disable colored output").option("--debug", "print diagnostics (resolved range, prompt size, raw model output) to stderr");
|
|
526
617
|
}
|
|
@@ -529,11 +620,8 @@ process.stdout.on("error", (err) => {
|
|
|
529
620
|
throw err;
|
|
530
621
|
});
|
|
531
622
|
var program = new Command();
|
|
532
|
-
program.name("bb").description("Guided code tours for git changes, on the command line.").version(package_default.version, "-V, --version").configureOutput({ outputError: (str, write) => write(
|
|
533
|
-
addGlobalFlags(program).argument("[range]", "what to tour: A..B, A...B, or a single ref (compared at its merge-base with HEAD)").option("-w, --working", "tour uncommitted changes in the working tree (tracked and untracked)").option("-s, --staged", "tour staged changes only").option("--section <n>", "render only section <n>", positiveInt).option("--json", "print the tour as JSON instead of rendering it").option("--dump-prompt", "print the prompt that would be sent to the model and exit").option("--refresh", "ignore a cached tour and regenerate it").option("--no-cache", "neither read nor write the tour cache").option("--no-pager", "never pipe output through a pager").option("--no-highlight", "plain green/red
|
|
534
|
-
if (v !== "dark" && v !== "light") throw new InvalidArgumentError("must be dark or light");
|
|
535
|
-
return v;
|
|
536
|
-
}).option("--no-progress", "do not show the live status block while generating").addHelpText(
|
|
623
|
+
program.name("bb").description("Guided code tours for git changes, on the command line.").version(package_default.version, "-V, --version").enablePositionalOptions().configureOutput({ outputError: (str, write) => write(pc6.red(str)) }).showHelpAfterError("(run with --help for usage)");
|
|
624
|
+
addGlobalFlags(program).argument("[range]", "what to tour: A..B, A...B, or a single ref (compared at its merge-base with HEAD)").option("-w, --working", "tour uncommitted changes in the working tree (tracked and untracked)").option("-s, --staged", "tour staged changes only").option("--section <n>", "render only section <n>", positiveInt).option("--json", "print the tour as JSON instead of rendering it").option("--dump-prompt", "print the prompt that would be sent to the model and exit").option("--refresh", "ignore a cached tour and regenerate it").option("--no-cache", "neither read nor write the tour cache").option("--no-pager", "never pipe output through a pager").option("--no-highlight", "plain excerpts with green/red +/- signs instead of syntax colors").option("--no-progress", "do not show the live status block while generating").addHelpText(
|
|
537
625
|
"after",
|
|
538
626
|
`
|
|
539
627
|
Examples:
|
|
@@ -544,34 +632,51 @@ Examples:
|
|
|
544
632
|
bb --section 2 show only the second section
|
|
545
633
|
bb --json | jq machine-readable output
|
|
546
634
|
bb --preset claude-sonnet --refresh
|
|
635
|
+
bb ask HEAD~1 "what changed in progress.ts?" chat about a tour (see bb ask --help)
|
|
547
636
|
`
|
|
548
637
|
).action(async (range, flags) => {
|
|
549
638
|
await tourCommand(range, flags);
|
|
550
639
|
});
|
|
640
|
+
addGlobalFlags(program.command("ask").description("chat with the LLM about a tour (the tour is generated or taken from the cache first)")).argument("[range]", "what to tour, as for `bb`; omit it to tour the same thing bare `bb` would").argument("[message...]", "opening message for the chat").option("-w, --working", "tour uncommitted changes in the working tree (tracked and untracked)").option("-s, --staged", "tour staged changes only").option("--refresh", "ignore a cached tour and regenerate it").option("--no-cache", "neither read nor write the tour cache").option("--no-progress", "do not show the live status block while generating").option("--dump-context", "print the context that would be handed to the chat and exit").addHelpText(
|
|
641
|
+
"after",
|
|
642
|
+
`
|
|
643
|
+
The first word is taken as a range only when git can resolve it (HEAD~3, main..feature);
|
|
644
|
+
everything else is the opening message. The chat command comes from the preset (see \`bb config\`).
|
|
645
|
+
|
|
646
|
+
Examples:
|
|
647
|
+
bb ask chat about the current branch's tour
|
|
648
|
+
bb ask "why does the cache key include the command?"
|
|
649
|
+
bb ask HEAD~1 "what is going on in progress.ts?"
|
|
650
|
+
bb ask main..feature --preset claude-opus
|
|
651
|
+
bb ask --staged "is this safe to commit?"
|
|
652
|
+
`
|
|
653
|
+
).action(async (range, message, _flags, cmd) => {
|
|
654
|
+
await askCommand([range, ...message].filter((w) => w !== void 0), optsWithGlobals(cmd));
|
|
655
|
+
});
|
|
551
656
|
var cache = program.command("cache").description("manage cached tours");
|
|
552
|
-
addGlobalFlags(cache.command("ls").description("list cached tours")).action(cacheLsCommand);
|
|
553
|
-
addGlobalFlags(cache.command("clear").description("delete all cached tours")).action(cacheClearCommand);
|
|
554
|
-
addGlobalFlags(cache.command("path").description("print the cache directory")).action(cachePathCommand);
|
|
555
|
-
addGlobalFlags(program.command("config").description("show the effective configuration, its sources, and available presets")).option("--json", "print only the effective config as JSON").action(configCommand);
|
|
556
|
-
addGlobalFlags(program.command("init").description("write a starter .baby-bird/config.json in this repository")).option("--force", "overwrite an existing project config").action(initCommand);
|
|
657
|
+
addGlobalFlags(cache.command("ls").description("list cached tours")).action((_flags, cmd) => cacheLsCommand(optsWithGlobals(cmd)));
|
|
658
|
+
addGlobalFlags(cache.command("clear").description("delete all cached tours")).action((_flags, cmd) => cacheClearCommand(optsWithGlobals(cmd)));
|
|
659
|
+
addGlobalFlags(cache.command("path").description("print the cache directory")).action((_flags, cmd) => cachePathCommand(optsWithGlobals(cmd)));
|
|
660
|
+
addGlobalFlags(program.command("config").description("show the effective configuration, its sources, and available presets")).option("--json", "print only the effective config as JSON").action((_flags, cmd) => configCommand(optsWithGlobals(cmd)));
|
|
661
|
+
addGlobalFlags(program.command("init").description("write a starter .baby-bird/config.json in this repository")).option("--force", "overwrite an existing project config").action((_flags, cmd) => initCommand(optsWithGlobals(cmd)));
|
|
557
662
|
program.parseAsync(process.argv).catch((err) => {
|
|
558
663
|
const debug = process.argv.includes("--debug");
|
|
559
664
|
if (err instanceof BbError) {
|
|
560
|
-
process.stderr.write(
|
|
665
|
+
process.stderr.write(pc6.red(`error: ${err.message}
|
|
561
666
|
`));
|
|
562
|
-
if (err.hint) process.stderr.write(
|
|
667
|
+
if (err.hint) process.stderr.write(pc6.dim(`${err.hint}
|
|
563
668
|
`));
|
|
564
|
-
if (debug && err instanceof BadLlmOutputError) process.stderr.write(
|
|
669
|
+
if (debug && err instanceof BadLlmOutputError) process.stderr.write(pc6.dim(`--- raw model output ---
|
|
565
670
|
${err.raw}
|
|
566
671
|
`));
|
|
567
|
-
if (debug && err.cause) process.stderr.write(
|
|
672
|
+
if (debug && err.cause) process.stderr.write(pc6.dim(`${String(err.cause.stack ?? err.cause)}
|
|
568
673
|
`));
|
|
569
674
|
process.exitCode = err.exitCode;
|
|
570
675
|
return;
|
|
571
676
|
}
|
|
572
|
-
process.stderr.write(
|
|
677
|
+
process.stderr.write(pc6.red(`error: ${err.message ?? String(err)}
|
|
573
678
|
`));
|
|
574
|
-
if (debug && err.stack) process.stderr.write(
|
|
679
|
+
if (debug && err.stack) process.stderr.write(pc6.dim(`${err.stack}
|
|
575
680
|
`));
|
|
576
681
|
process.exitCode = 1;
|
|
577
682
|
});
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/main.ts","../package.json","../src/cli/cache-cmd.ts","../src/cli/shared.ts","../src/cli/config-cmd.ts","../src/cli/init-cmd.ts","../src/cli/progress.ts","../src/cli/tour.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command, InvalidArgumentError } from 'commander';\nimport pc from 'picocolors';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { BadLlmOutputError, BbError } from '../core/errors.js';\nimport { cacheClearCommand, cacheLsCommand, cachePathCommand } from './cache-cmd.js';\nimport { configCommand } from './config-cmd.js';\nimport { initCommand } from './init-cmd.js';\nimport { tourCommand } from './tour.js';\n\nfunction positiveInt(value: string): number {\n const n = Number(value);\n if (!Number.isInteger(n) || n < 1) throw new InvalidArgumentError('must be a positive integer');\n return n;\n}\n\nfunction addGlobalFlags(cmd: Command): Command {\n return cmd\n .option('-C, --cwd <dir>', 'run as if started in <dir>')\n .option('--preset <name>', 'LLM preset to use (see `bb config`)')\n .option('--color', 'force colored output')\n .option('--no-color', 'disable colored output')\n .option('--debug', 'print diagnostics (resolved range, prompt size, raw model output) to stderr');\n}\n\n// A reader that quits early (`bb | head`) is a normal end, not a crash.\nprocess.stdout.on('error', (err: NodeJS.ErrnoException) => {\n if (err.code === 'EPIPE') process.exit(0);\n throw err;\n});\n\nconst program = new Command();\n\nprogram\n .name('bb')\n .description('Guided code tours for git changes, on the command line.')\n .version(pkg.version, '-V, --version')\n .configureOutput({ outputError: (str, write) => write(pc.red(str)) })\n .showHelpAfterError('(run with --help for usage)');\n\naddGlobalFlags(program)\n .argument('[range]', 'what to tour: A..B, A...B, or a single ref (compared at its merge-base with HEAD)')\n .option('-w, --working', 'tour uncommitted changes in the working tree (tracked and untracked)')\n .option('-s, --staged', 'tour staged changes only')\n .option('--section <n>', 'render only section <n>', positiveInt)\n .option('--json', 'print the tour as JSON instead of rendering it')\n .option('--dump-prompt', 'print the prompt that would be sent to the model and exit')\n .option('--refresh', 'ignore a cached tour and regenerate it')\n .option('--no-cache', 'neither read nor write the tour cache')\n .option('--no-pager', 'never pipe output through a pager')\n .option('--no-highlight', 'plain green/red excerpts instead of syntax colors with tinted rows')\n .option('--theme <name>', 'background tint palette for added/removed lines: dark or light', (v: string) => {\n if (v !== 'dark' && v !== 'light') throw new InvalidArgumentError('must be dark or light');\n return v;\n })\n .option('--no-progress', 'do not show the live status block while generating')\n .addHelpText(\n 'after',\n `\nExamples:\n bb tour the current branch (dirty tree, PR base, nearest branch, or default branch)\n bb main..feature tour an explicit range\n bb HEAD~3 tour the last three commits\n bb --staged tour what you are about to commit\n bb --section 2 show only the second section\n bb --json | jq machine-readable output\n bb --preset claude-sonnet --refresh\n`,\n )\n .action(async (range: string | undefined, flags) => {\n await tourCommand(range, flags);\n });\n\nconst cache = program.command('cache').description('manage cached tours');\naddGlobalFlags(cache.command('ls').description('list cached tours')).action(cacheLsCommand);\naddGlobalFlags(cache.command('clear').description('delete all cached tours')).action(cacheClearCommand);\naddGlobalFlags(cache.command('path').description('print the cache directory')).action(cachePathCommand);\n\naddGlobalFlags(program.command('config').description('show the effective configuration, its sources, and available presets'))\n .option('--json', 'print only the effective config as JSON')\n .action(configCommand);\n\naddGlobalFlags(program.command('init').description('write a starter .baby-bird/config.json in this repository'))\n .option('--force', 'overwrite an existing project config')\n .action(initCommand);\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n const debug = process.argv.includes('--debug');\n if (err instanceof BbError) {\n process.stderr.write(pc.red(`error: ${err.message}\\n`));\n if (err.hint) process.stderr.write(pc.dim(`${err.hint}\\n`));\n if (debug && err instanceof BadLlmOutputError) process.stderr.write(pc.dim(`--- raw model output ---\\n${err.raw}\\n`));\n if (debug && err.cause) process.stderr.write(pc.dim(`${String((err.cause as Error).stack ?? err.cause)}\\n`));\n process.exitCode = err.exitCode;\n return;\n }\n process.stderr.write(pc.red(`error: ${(err as Error).message ?? String(err)}\\n`));\n if (debug && (err as Error).stack) process.stderr.write(pc.dim(`${(err as Error).stack}\\n`));\n process.exitCode = 1;\n});\n","{\n \"name\": \"@cam5/baby-bird\",\n \"version\": \"0.1.1\",\n \"description\": \"Guided code tours for git changes, on the command line.\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/cam5/baby-bird.git\"\n },\n \"keywords\": [\n \"git\",\n \"code-review\",\n \"diff\",\n \"llm\",\n \"cli\",\n \"code-tour\"\n ],\n \"bin\": {\n \"bb\": \"dist/cli.js\",\n \"baby-bird\": \"dist/cli.js\"\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"engines\": {\n \"node\": \">=22\"\n },\n \"packageManager\": \"pnpm@10.33.0\",\n \"scripts\": {\n \"dev\": \"tsx src/cli/main.ts\",\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm typecheck && pnpm test && pnpm build\"\n },\n \"dependencies\": {\n \"commander\": \"^15.0.0\",\n \"lowlight\": \"^3.3.0\",\n \"picocolors\": \"^1.1.1\",\n \"zod\": \"^4.6.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.20.2\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.23.13\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^5.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import pc from 'picocolors';\nimport { TourCache } from '../core/cache.js';\nimport { describeSource, relativeTime } from '../render/cli.js';\nimport { openSession, type GlobalFlags } from './shared.js';\n\nexport async function cacheLsCommand(flags: GlobalFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n const c = pc.createColors(session.colorEnabled);\n const cache = new TourCache(session.loaded.cacheDir);\n const entries = await cache.list();\n if (entries.length === 0) {\n process.stdout.write(`No cached tours in ${cache.toursDir}\\n`);\n return;\n }\n for (const e of entries) {\n const t = e.tour;\n process.stdout.write(\n `${c.dim(e.key.slice(0, 12))} ${relativeTime(t.generatedAt).padEnd(12)} ${c.bold(t.title)}\\n` +\n `${' '.repeat(14)}${c.dim(describeSource(t.source))}${t.generator.preset ? c.dim(` · ${t.generator.preset}`) : ''}\\n`,\n );\n }\n}\n\nexport async function cacheClearCommand(flags: GlobalFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n const cache = new TourCache(session.loaded.cacheDir);\n const n = await cache.clear();\n process.stdout.write(`Removed ${n} cached tour${n === 1 ? '' : 's'} from ${cache.toursDir}\\n`);\n}\n\nexport async function cachePathCommand(flags: GlobalFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n process.stdout.write(new TourCache(session.loaded.cacheDir).toursDir + '\\n');\n}\n","import pc from 'picocolors';\nimport { resolve } from 'node:path';\nimport type { PartialConfig } from '../core/config.js';\nimport { loadConfig, type LoadedConfig } from '../core/config.js';\nimport { gitRoot } from '../git/exec.js';\nimport { supports256Colors } from '../render/highlight.js';\n\nexport interface GlobalFlags {\n cwd?: string;\n debug?: boolean;\n color?: boolean;\n preset?: string;\n cache?: boolean;\n pager?: boolean;\n highlight?: boolean;\n theme?: 'dark' | 'light';\n}\n\nexport interface Session {\n /** Directory the user pointed at (resolved). */\n cwd: string;\n /** Git root, or null when not in a repository. */\n root: string | null;\n loaded: LoadedConfig;\n debug: (msg: string) => void;\n warn: (msg: string) => void;\n colorEnabled: boolean;\n}\n\nexport function flagsToOverrides(flags: GlobalFlags): PartialConfig {\n const o: PartialConfig = {};\n if (flags.preset) o.llm = { preset: flags.preset };\n if (flags.color === true) o.render = { color: 'always' };\n else if (flags.color === false) o.render = { color: 'never' };\n if (flags.cache === false) o.cache = { enabled: false };\n if (flags.pager === false) o.render = { ...(o.render ?? {}), pager: 'never' };\n if (flags.highlight === false) o.render = { ...(o.render ?? {}), highlight: 'never' };\n if (flags.theme) o.render = { ...(o.render ?? {}), theme: flags.theme };\n return o;\n}\n\nexport async function openSession(flags: GlobalFlags, opts: { requireRepo: boolean }): Promise<Session> {\n const cwd = resolve(flags.cwd ?? process.cwd());\n let root: string | null = null;\n try {\n root = await gitRoot(cwd);\n } catch (err) {\n if (opts.requireRepo) throw err;\n }\n const loaded = await loadConfig({ gitRoot: root, env: process.env, overrides: flagsToOverrides(flags) });\n const colorEnabled = resolveColor(loaded.config.render.color);\n const c = pc.createColors(colorEnabled);\n const debug = flags.debug ? (msg: string) => process.stderr.write(c.dim(`[bb] ${msg}\\n`)) : () => {};\n const warn = (msg: string) => process.stderr.write(c.yellow(`warning: ${msg}\\n`));\n return { cwd, root, loaded, debug, warn, colorEnabled };\n}\n\nexport function resolveColor(mode: 'auto' | 'always' | 'never'): boolean {\n if (mode === 'always') return true;\n if (mode === 'never') return false;\n return Boolean(process.stdout.isTTY) && process.env.TERM !== 'dumb';\n}\n\nexport function resolveHighlight(mode: 'auto' | 'always' | 'never', colorEnabled: boolean): boolean {\n if (!colorEnabled || mode === 'never') return false;\n if (mode === 'always') return true;\n return supports256Colors();\n}\n\nexport function terminalWidth(configured: number | null, stream: { columns?: number } = process.stdout): number {\n return configured ?? (stream.columns || 80);\n}\n","import pc from 'picocolors';\nimport { allPresets, resolveLlm } from '../core/config.js';\nimport { ConfigError } from '../core/errors.js';\nimport { CommandProvider } from '../llm/command.js';\nimport { openSession, type GlobalFlags } from './shared.js';\n\nexport async function configCommand(flags: GlobalFlags & { json?: boolean }): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n const { config, layers, cacheDir } = session.loaded;\n\n if (flags.json) {\n process.stdout.write(JSON.stringify(config, null, 2) + '\\n');\n return;\n }\n\n const c = pc.createColors(session.colorEnabled);\n const out: string[] = [];\n out.push(c.bold('Layers') + c.dim(' (later layers win; objects merge, arrays replace)'));\n for (const layer of layers) {\n const status = layer.found ? c.green('applied') : c.dim('not found');\n const where = layer.path ?? (layer.detail || (layer.name === 'defaults' ? 'built-in' : layer.name === 'flags' ? 'command line' : ''));\n out.push(` ${layer.name.padEnd(8)} ${status.padEnd(session.colorEnabled ? 18 : 9)} ${c.dim(where)}`);\n }\n out.push(` cache dir: ${cacheDir}`);\n out.push('');\n\n out.push(c.bold('LLM'));\n try {\n const llm = resolveLlm(config);\n const provider = new CommandProvider({ command: llm.command, promptVia: llm.promptVia, timeoutMs: llm.timeoutMs });\n out.push(` preset: ${llm.preset ?? c.dim('(custom command)')}`);\n out.push(` command: ${provider.describe()}`);\n out.push(` prompt: via ${llm.promptVia}`);\n } catch (err) {\n out.push(` ${c.red((err as ConfigError).message)}`);\n }\n out.push('');\n\n out.push(c.bold('Presets'));\n const presets = allPresets(config);\n const width = Math.max(...Object.keys(presets).map((k) => k.length));\n for (const [name, preset] of Object.entries(presets).sort(([a], [b]) => a.localeCompare(b))) {\n const custom = name in config.llm.presets ? c.dim(' (yours)') : '';\n out.push(` ${name.padEnd(width)} ${preset.description ?? c.dim(preset.command.join(' '))}${custom}`);\n }\n out.push('');\n\n out.push(c.bold('Effective config'));\n out.push(JSON.stringify(config, null, 2).split('\\n').map((l) => ' ' + l).join('\\n'));\n process.stdout.write(out.join('\\n') + '\\n');\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { projectConfigPath } from '../core/config.js';\nimport { NotARepoError, UsageError } from '../core/errors.js';\nimport { openSession, type GlobalFlags } from './shared.js';\n\nconst STARTER = {\n llm: { preset: 'claude' },\n codehost: { provider: 'gh' },\n};\n\nexport async function initCommand(flags: GlobalFlags & { force?: boolean }): Promise<void> {\n const session = await openSession(flags, { requireRepo: true });\n if (!session.root) throw new NotARepoError(session.cwd);\n const path = projectConfigPath(session.root);\n const existing = session.loaded.layers.find((l) => l.name === 'project');\n if (existing?.found && !flags.force) {\n throw new UsageError(`${path} already exists.`, 'Pass --force to overwrite it.');\n }\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, JSON.stringify(STARTER, null, 2) + '\\n', 'utf8');\n process.stdout.write(`Wrote ${path}\\nRun \\`bb config\\` to see the effective configuration and available presets.\\n`);\n}\n","import pc from 'picocolors';\nimport type { ProgressSink } from '../core/progress.js';\nimport type { LlmEvent } from '../llm/provider.js';\nimport { wrap } from '../render/cli.js';\n\nconst SPINNER = ['✢', '✳', '✶', '✻', '✽', '✻', '✶', '✳'];\nconst VERBS = ['Hatching', 'Pecking', 'Nesting', 'Chirping', 'Preening', 'Fledging', 'Brooding', 'Warbling', 'Peeping'];\nconst THINKING_TAIL_CHARS = 2000;\nconst VERB_INTERVAL_MS = 7500;\n\nexport interface LiveProgressOptions {\n color: boolean;\n width: number;\n /** How many lines of thinking / section titles to show under the status line. */\n windowLines?: number;\n now?: () => number;\n /** Pin a single verb (tests). */\n verb?: string;\n /** Verbs to rotate through; the built-in list is used, shuffled, when omitted. */\n verbs?: string[];\n /** How often the verb changes. */\n verbIntervalMs?: number;\n frameMs?: number;\n}\n\ninterface Usage {\n outputTokens?: number;\n thinkingTokens?: number;\n model?: string;\n}\n\ntype Stage = 'prep' | 'thinking' | 'writing' | 'output';\n\n/**\n * In-place status block on a TTY: a spinner line plus a small window showing\n * the model's reasoning as it streams, then section titles as the answer forms.\n */\nexport class LiveProgress implements ProgressSink {\n private phaseLabel = '';\n private stage: Stage = 'prep';\n private thinking = '';\n private pulses = 0;\n private answer = '';\n private titles: string[] = [];\n private notices: string[] = [];\n private outputBytes = 0;\n private usage: Usage = {};\n private readonly startedAt: number;\n private frameIndex = 0;\n private lastLines = 0;\n private timer: NodeJS.Timeout | null = null;\n private stopped = false;\n private readonly verbs: string[];\n private readonly now: () => number;\n private readonly windowLines: number;\n private readonly onSigint = () => {\n this.stop();\n process.exit(130);\n };\n\n constructor(\n private readonly stream: { write(chunk: string): boolean },\n private readonly opts: LiveProgressOptions,\n ) {\n this.now = opts.now ?? Date.now;\n this.startedAt = this.now();\n this.verbs = opts.verb ? [opts.verb] : opts.verbs && opts.verbs.length ? opts.verbs : shuffle(VERBS);\n this.windowLines = opts.windowLines ?? 5;\n }\n\n start(): void {\n this.stream.write('\\x1b[?25l');\n process.once('SIGINT', this.onSigint);\n this.timer = setInterval(() => {\n this.frameIndex++;\n this.render();\n }, this.opts.frameMs ?? 80);\n this.timer.unref?.();\n this.render();\n }\n\n phase(label: string): void {\n this.phaseLabel = label;\n if (/^asking/i.test(label)) {\n this.stage = 'thinking';\n this.thinking = '';\n this.pulses = 0;\n this.answer = '';\n this.titles = [];\n this.notices = [];\n this.outputBytes = 0;\n } else if (this.stage !== 'prep') {\n this.stage = 'prep';\n }\n this.render();\n }\n\n llm(event: LlmEvent): void {\n switch (event.type) {\n case 'thinking':\n this.thinking += event.text;\n this.stage = 'thinking'; // thinking after a rejected answer comes back into view\n break;\n case 'thinking-pulse':\n this.pulses++;\n this.stage = 'thinking';\n break;\n case 'answer-start':\n this.answer = '';\n this.titles = [];\n break;\n case 'notice':\n this.notices.push(event.text);\n break;\n case 'text':\n this.answer += event.text;\n this.titles = extractTitles(this.answer);\n this.stage = 'writing';\n break;\n case 'output':\n this.outputBytes = event.bytes;\n this.stage = 'output';\n break;\n case 'usage':\n if (event.outputTokens !== undefined) this.usage.outputTokens = event.outputTokens;\n if (event.thinkingTokens !== undefined) this.usage.thinkingTokens = event.thinkingTokens;\n if (event.model !== undefined) this.usage.model = event.model;\n break;\n default:\n break;\n }\n }\n\n /** The lines that make up the current status block. */\n frame(): string[] {\n const c = pc.createColors(this.opts.color);\n const width = Math.max(30, this.opts.width);\n const spin = c.magenta(SPINNER[this.frameIndex % SPINNER.length]!);\n const elapsed = this.elapsed();\n const fit = (s: string) => (s.length > width - 1 ? s.slice(0, width - 2) + '…' : s);\n const lines: string[] = [];\n\n switch (this.stage) {\n case 'prep':\n lines.push(`${spin} ${fit(this.phaseLabel || 'Starting')}… ${c.dim(elapsed)}`);\n break;\n case 'thinking': {\n const meta = [elapsed, this.phaseLabel.replace(/^asking\\s+/i, '')].filter(Boolean).join(' · ');\n lines.push(`${spin} ${this.verb()}… ${c.dim(meta)}`);\n for (const n of this.notices.slice(-1)) lines.push(` ${c.yellow('↻')} ${c.yellow(fit(n).slice(0, width - 4))}`);\n if (this.thinking) {\n const tail = this.thinking.slice(-THINKING_TAIL_CHARS).replace(/\\s+/g, ' ').trim();\n const wrapped = wrap(tail, width - 4).slice(-this.windowLines);\n for (const l of wrapped) lines.push(` ${c.dim('│')} ${c.dim(l)}`);\n } else if (this.pulses > 0) {\n // The runner reports reasoning heartbeats without text: show a trail that grows with each one.\n const room = Math.max(8, width - 16);\n const n = this.pulses % (room + 1);\n lines.push(` ${c.dim('│')} ${c.dim('reasoning')} ${c.magenta('·'.repeat(n))}`);\n }\n break;\n }\n case 'writing': {\n const n = Math.max(0, this.titles.length - 1);\n lines.push(`${spin} Writing the tour… ${c.dim(`${elapsed} · ${n} section${n === 1 ? '' : 's'} so far`)}`);\n for (const note of this.notices.slice(-1)) lines.push(` ${c.yellow('↻')} ${c.yellow(fit(note).slice(0, width - 4))}`);\n const [tourTitle, ...sections] = this.titles;\n const items: string[] = [];\n if (tourTitle) items.push(` 🐣 ${c.bold(fit(tourTitle).slice(0, width - 6))}`);\n sections.forEach((t) => items.push(` ${c.green('✓')} ${fit(t).slice(0, width - 5)}`));\n for (const l of items.slice(-this.windowLines)) lines.push(l);\n break;\n }\n case 'output':\n lines.push(`${spin} ${this.verb()}… ${c.dim(`${elapsed} · ${formatBytes(this.outputBytes)} received`)}`);\n break;\n }\n return lines;\n }\n\n render(): void {\n if (this.stopped) return;\n const lines = this.frame();\n this.stream.write(this.erase() + lines.join('\\n') + '\\n');\n this.lastLines = lines.length;\n }\n\n /** Clear the block, restore the cursor, and optionally leave a final line behind. */\n stop(finalLine?: string): void {\n if (this.stopped) return;\n this.stopped = true;\n if (this.timer) clearInterval(this.timer);\n process.removeListener('SIGINT', this.onSigint);\n this.stream.write(this.erase() + (finalLine ? finalLine + '\\n' : '') + '\\x1b[?25h');\n this.lastLines = 0;\n }\n\n /** A one-line summary of the model call, for the final line. */\n summary(): string {\n const c = pc.createColors(this.opts.color);\n const parts = [`Hatched in ${this.elapsed()}`];\n if (this.usage.outputTokens) {\n parts.push(`${formatCount(this.usage.outputTokens)} tokens${this.usage.thinkingTokens ? ` (${formatCount(this.usage.thinkingTokens)} thinking)` : ''}`);\n }\n if (this.usage.model) parts.push(this.usage.model);\n return c.dim(`✻ ${parts.join(' · ')}`);\n }\n\n /** The current verb; rotates every verbIntervalMs so long waits do not stare at one word. */\n private verb(): string {\n const step = Math.floor((this.now() - this.startedAt) / (this.opts.verbIntervalMs ?? VERB_INTERVAL_MS));\n return this.verbs[step % this.verbs.length]!;\n }\n\n private elapsed(): string {\n const s = Math.max(0, Math.round((this.now() - this.startedAt) / 1000));\n return s >= 60 ? `${Math.floor(s / 60)}m ${s % 60}s` : `${s}s`;\n }\n\n private erase(): string {\n return this.lastLines ? `\\x1b[${this.lastLines}A\\x1b[0J` : '';\n }\n}\n\n/** Every \"title\" string value in a (possibly partial) JSON document, in order. */\nexport function extractTitles(text: string): string[] {\n const out: string[] = [];\n for (const m of text.matchAll(/\"title\"\\s*:\\s*\"((?:[^\"\\\\]|\\\\.)*)\"/g)) {\n out.push(m[1]!.replace(/\\\\([\"\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, (_, esc: string) => {\n switch (esc[0]) {\n case '\"': return '\"';\n case '\\\\': return '\\\\';\n case '/': return '/';\n case 'n': return '\\n';\n case 't': return '\\t';\n case 'u': return String.fromCharCode(parseInt(esc.slice(1), 16));\n default: return '';\n }\n }));\n }\n return out;\n}\n\n/** A sink that logs phases as plain lines (used with --debug or without a TTY). */\nexport function loggingProgress(log: (msg: string) => void): ProgressSink {\n return {\n phase: (label) => log(label),\n llm: () => {},\n };\n}\n\nfunction shuffle<T>(items: readonly T[]): T[] {\n const out = [...items];\n for (let i = out.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [out[i], out[j]] = [out[j]!, out[i]!];\n }\n return out;\n}\n\nfunction formatBytes(n: number): string {\n return n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} KB`;\n}\n\nfunction formatCount(n: number): string {\n return n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n);\n}\n","import { NotARepoError } from '../core/errors.js';\nimport { generateTour, prepareTour } from '../core/tour.js';\nimport { CliRenderer } from '../render/cli.js';\nimport { writeMaybePaged, writeStdout } from '../render/pager.js';\nimport { LiveProgress, loggingProgress } from './progress.js';\nimport { openSession, resolveHighlight, terminalWidth, type GlobalFlags } from './shared.js';\n\nexport interface TourFlags extends GlobalFlags {\n working?: boolean;\n staged?: boolean;\n section?: number;\n json?: boolean;\n dumpPrompt?: boolean;\n refresh?: boolean;\n progress?: boolean;\n}\n\nexport async function tourCommand(rangeArg: string | undefined, flags: TourFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: true });\n if (!session.root) throw new NotARepoError(session.cwd);\n const { config } = session.loaded;\n\n const live = flags.progress !== false && !flags.debug && Boolean(process.stderr.isTTY) && !flags.dumpPrompt;\n const progress = live\n ? new LiveProgress(process.stderr, { color: session.colorEnabled, width: terminalWidth(null, process.stderr) })\n : loggingProgress(session.debug);\n\n const options = {\n cwd: session.root,\n config,\n cacheDir: session.loaded.cacheDir,\n range: { arg: rangeArg, working: flags.working, staged: flags.staged },\n refresh: flags.refresh,\n noCache: flags.cache === false,\n debug: session.debug,\n warn: session.warn,\n progress,\n };\n\n if (progress instanceof LiveProgress) progress.start();\n let result: Awaited<ReturnType<typeof generateTour>>;\n try {\n const prepared = await prepareTour(options);\n if (flags.dumpPrompt) {\n await writeStdout(prepared.built.prompt.endsWith('\\n') ? prepared.built.prompt : prepared.built.prompt + '\\n');\n return;\n }\n result = await generateTour(options, prepared);\n } catch (err) {\n if (progress instanceof LiveProgress) progress.stop();\n throw err;\n }\n if (progress instanceof LiveProgress) progress.stop(result.fromCache ? undefined : progress.summary());\n\n if (flags.json) {\n await writeStdout(JSON.stringify(result.tour, null, 2) + '\\n');\n return;\n }\n\n const renderer = new CliRenderer();\n const output = renderer.render(result.tour, {\n color: session.colorEnabled,\n width: terminalWidth(config.render.width),\n section: flags.section,\n fromCache: result.fromCache,\n highlight: resolveHighlight(config.render.highlight, session.colorEnabled),\n theme: config.render.theme,\n });\n await writeMaybePaged(output, {\n mode: config.render.pager,\n isTTY: Boolean(process.stdout.isTTY),\n rows: process.stdout.rows ?? 24,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,SAAS,4BAA4B;AAC9C,OAAOA,SAAQ;;;ACFf;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,EACX,MAAQ;AAAA,EAC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,OAAO,WAAW,sCAAsC,EACxD,OAAO,WAAW;AAErB,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACvD,QAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AAC7C,MAAI,eAAe,SAAS;AAC1B,YAAQ,OAAO,MAAMA,IAAG,IAAI,UAAU,IAAI,OAAO;AAAA,CAAI,CAAC;AACtD,QAAI,IAAI,KAAM,SAAQ,OAAO,MAAMA,IAAG,IAAI,GAAG,IAAI,IAAI;AAAA,CAAI,CAAC;AAC1D,QAAI,SAAS,eAAe,kBAAmB,SAAQ,OAAO,MAAMA,IAAG,IAAI;AAAA,EAA6B,IAAI,GAAG;AAAA,CAAI,CAAC;AACpH,QAAI,SAAS,IAAI,MAAO,SAAQ,OAAO,MAAMA,IAAG,IAAI,GAAG,OAAQ,IAAI,MAAgB,SAAS,IAAI,KAAK,CAAC;AAAA,CAAI,CAAC;AAC3G,YAAQ,WAAW,IAAI;AACvB;AAAA,EACF;AACA,UAAQ,OAAO,MAAMA,IAAG,IAAI,UAAW,IAAc,WAAW,OAAO,GAAG,CAAC;AAAA,CAAI,CAAC;AAChF,MAAI,SAAU,IAAc,MAAO,SAAQ,OAAO,MAAMA,IAAG,IAAI,GAAI,IAAc,KAAK;AAAA,CAAI,CAAC;AAC3F,UAAQ,WAAW;AACrB,CAAC;","names":["pc","pc","pc","cache","pc","pc","pc","pc","pc"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli/main.ts","../package.json","../src/cli/cache-cmd.ts","../src/cli/shared.ts","../src/cli/config-cmd.ts","../src/cli/ask-cmd.ts","../src/cli/progress.ts","../src/cli/init-cmd.ts","../src/cli/tour.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command, InvalidArgumentError } from 'commander';\nimport pc from 'picocolors';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { BadLlmOutputError, BbError } from '../core/errors.js';\nimport { cacheClearCommand, cacheLsCommand, cachePathCommand } from './cache-cmd.js';\nimport { configCommand } from './config-cmd.js';\nimport { askCommand } from './ask-cmd.js';\nimport { initCommand } from './init-cmd.js';\nimport { tourCommand } from './tour.js';\n\nfunction positiveInt(value: string): number {\n const n = Number(value);\n if (!Number.isInteger(n) || n < 1) throw new InvalidArgumentError('must be a positive integer');\n return n;\n}\n\n/** A subcommand's options plus any global flags given before its name (`bb -C dir cache ls`). */\nfunction optsWithGlobals<T>(cmd: Command): T {\n return cmd.optsWithGlobals() as T;\n}\n\nfunction addGlobalFlags(cmd: Command): Command {\n return cmd\n .option('-C, --cwd <dir>', 'run as if started in <dir>')\n .option('--preset <name>', 'LLM preset to use (see `bb config`)')\n .option('--color', 'force colored output')\n .option('--no-color', 'disable colored output')\n .option('--debug', 'print diagnostics (resolved range, prompt size, raw model output) to stderr');\n}\n\n// A reader that quits early (`bb | head`) is a normal end, not a crash.\nprocess.stdout.on('error', (err: NodeJS.ErrnoException) => {\n if (err.code === 'EPIPE') process.exit(0);\n throw err;\n});\n\nconst program = new Command();\n\nprogram\n .name('bb')\n .description('Guided code tours for git changes, on the command line.')\n .version(pkg.version, '-V, --version')\n // Options after a subcommand name belong to the subcommand; `bb ask --preset x` must not be eaten by the root.\n .enablePositionalOptions()\n .configureOutput({ outputError: (str, write) => write(pc.red(str)) })\n .showHelpAfterError('(run with --help for usage)');\n\naddGlobalFlags(program)\n .argument('[range]', 'what to tour: A..B, A...B, or a single ref (compared at its merge-base with HEAD)')\n .option('-w, --working', 'tour uncommitted changes in the working tree (tracked and untracked)')\n .option('-s, --staged', 'tour staged changes only')\n .option('--section <n>', 'render only section <n>', positiveInt)\n .option('--json', 'print the tour as JSON instead of rendering it')\n .option('--dump-prompt', 'print the prompt that would be sent to the model and exit')\n .option('--refresh', 'ignore a cached tour and regenerate it')\n .option('--no-cache', 'neither read nor write the tour cache')\n .option('--no-pager', 'never pipe output through a pager')\n .option('--no-highlight', 'plain excerpts with green/red +/- signs instead of syntax colors')\n .option('--no-progress', 'do not show the live status block while generating')\n .addHelpText(\n 'after',\n `\nExamples:\n bb tour the current branch (dirty tree, PR base, nearest branch, or default branch)\n bb main..feature tour an explicit range\n bb HEAD~3 tour the last three commits\n bb --staged tour what you are about to commit\n bb --section 2 show only the second section\n bb --json | jq machine-readable output\n bb --preset claude-sonnet --refresh\n bb ask HEAD~1 \"what changed in progress.ts?\" chat about a tour (see bb ask --help)\n`,\n )\n .action(async (range: string | undefined, flags) => {\n await tourCommand(range, flags);\n });\n\naddGlobalFlags(program.command('ask').description('chat with the LLM about a tour (the tour is generated or taken from the cache first)'))\n .argument('[range]', 'what to tour, as for `bb`; omit it to tour the same thing bare `bb` would')\n .argument('[message...]', 'opening message for the chat')\n .option('-w, --working', 'tour uncommitted changes in the working tree (tracked and untracked)')\n .option('-s, --staged', 'tour staged changes only')\n .option('--refresh', 'ignore a cached tour and regenerate it')\n .option('--no-cache', 'neither read nor write the tour cache')\n .option('--no-progress', 'do not show the live status block while generating')\n .option('--dump-context', 'print the context that would be handed to the chat and exit')\n .addHelpText(\n 'after',\n `\nThe first word is taken as a range only when git can resolve it (HEAD~3, main..feature);\neverything else is the opening message. The chat command comes from the preset (see \\`bb config\\`).\n\nExamples:\n bb ask chat about the current branch's tour\n bb ask \"why does the cache key include the command?\"\n bb ask HEAD~1 \"what is going on in progress.ts?\"\n bb ask main..feature --preset claude-opus\n bb ask --staged \"is this safe to commit?\"\n`,\n )\n .action(async (range: string | undefined, message: string[], _flags, cmd: Command) => {\n await askCommand([range, ...message].filter((w): w is string => w !== undefined), optsWithGlobals(cmd));\n });\n\nconst cache = program.command('cache').description('manage cached tours');\naddGlobalFlags(cache.command('ls').description('list cached tours')).action((_flags, cmd: Command) => cacheLsCommand(optsWithGlobals(cmd)));\naddGlobalFlags(cache.command('clear').description('delete all cached tours')).action((_flags, cmd: Command) => cacheClearCommand(optsWithGlobals(cmd)));\naddGlobalFlags(cache.command('path').description('print the cache directory')).action((_flags, cmd: Command) => cachePathCommand(optsWithGlobals(cmd)));\n\naddGlobalFlags(program.command('config').description('show the effective configuration, its sources, and available presets'))\n .option('--json', 'print only the effective config as JSON')\n .action((_flags, cmd: Command) => configCommand(optsWithGlobals(cmd)));\n\naddGlobalFlags(program.command('init').description('write a starter .baby-bird/config.json in this repository'))\n .option('--force', 'overwrite an existing project config')\n .action((_flags, cmd: Command) => initCommand(optsWithGlobals(cmd)));\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n const debug = process.argv.includes('--debug');\n if (err instanceof BbError) {\n process.stderr.write(pc.red(`error: ${err.message}\\n`));\n if (err.hint) process.stderr.write(pc.dim(`${err.hint}\\n`));\n if (debug && err instanceof BadLlmOutputError) process.stderr.write(pc.dim(`--- raw model output ---\\n${err.raw}\\n`));\n if (debug && err.cause) process.stderr.write(pc.dim(`${String((err.cause as Error).stack ?? err.cause)}\\n`));\n process.exitCode = err.exitCode;\n return;\n }\n process.stderr.write(pc.red(`error: ${(err as Error).message ?? String(err)}\\n`));\n if (debug && (err as Error).stack) process.stderr.write(pc.dim(`${(err as Error).stack}\\n`));\n process.exitCode = 1;\n});\n","{\n \"name\": \"@cam5/baby-bird\",\n \"version\": \"0.1.2\",\n \"description\": \"Guided code tours for git changes, on the command line.\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/cam5/baby-bird.git\"\n },\n \"keywords\": [\n \"git\",\n \"code-review\",\n \"diff\",\n \"llm\",\n \"cli\",\n \"code-tour\"\n ],\n \"bin\": {\n \"bb\": \"dist/cli.js\",\n \"baby-bird\": \"dist/cli.js\"\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n }\n },\n \"files\": [\n \"dist\",\n \"README.md\"\n ],\n \"engines\": {\n \"node\": \">=22\"\n },\n \"packageManager\": \"pnpm@10.33.0\",\n \"scripts\": {\n \"dev\": \"tsx src/cli/main.ts\",\n \"build\": \"tsup\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm typecheck && pnpm test && pnpm build\"\n },\n \"dependencies\": {\n \"commander\": \"^15.0.0\",\n \"lowlight\": \"^3.3.0\",\n \"picocolors\": \"^1.1.1\",\n \"zod\": \"^4.6.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.20.2\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.23.13\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^5.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import pc from 'picocolors';\nimport { TourCache } from '../core/cache.js';\nimport { describeSource, relativeTime } from '../render/cli.js';\nimport { openSession, type GlobalFlags } from './shared.js';\n\nexport async function cacheLsCommand(flags: GlobalFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n const c = pc.createColors(session.colorEnabled);\n const cache = new TourCache(session.loaded.cacheDir);\n const entries = await cache.list();\n if (entries.length === 0) {\n process.stdout.write(`No cached tours in ${cache.toursDir}\\n`);\n return;\n }\n for (const e of entries) {\n const t = e.tour;\n process.stdout.write(\n `${c.dim(e.key.slice(0, 12))} ${relativeTime(t.generatedAt).padEnd(12)} ${c.bold(t.title)}\\n` +\n `${' '.repeat(14)}${c.dim(describeSource(t.source))}${t.generator.preset ? c.dim(` · ${t.generator.preset}`) : ''}\\n`,\n );\n }\n}\n\nexport async function cacheClearCommand(flags: GlobalFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n const cache = new TourCache(session.loaded.cacheDir);\n const n = await cache.clear();\n process.stdout.write(`Removed ${n} cached tour${n === 1 ? '' : 's'} from ${cache.toursDir}\\n`);\n}\n\nexport async function cachePathCommand(flags: GlobalFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n process.stdout.write(new TourCache(session.loaded.cacheDir).toursDir + '\\n');\n}\n","import pc from 'picocolors';\nimport { resolve } from 'node:path';\nimport type { PartialConfig } from '../core/config.js';\nimport { loadConfig, type LoadedConfig } from '../core/config.js';\nimport { gitRoot } from '../git/exec.js';\n\nexport interface GlobalFlags {\n cwd?: string;\n debug?: boolean;\n color?: boolean;\n preset?: string;\n cache?: boolean;\n pager?: boolean;\n highlight?: boolean;\n}\n\nexport interface Session {\n /** Directory the user pointed at (resolved). */\n cwd: string;\n /** Git root, or null when not in a repository. */\n root: string | null;\n loaded: LoadedConfig;\n debug: (msg: string) => void;\n warn: (msg: string) => void;\n colorEnabled: boolean;\n}\n\nexport function flagsToOverrides(flags: GlobalFlags): PartialConfig {\n const o: PartialConfig = {};\n if (flags.preset) o.llm = { preset: flags.preset };\n if (flags.color === true) o.render = { color: 'always' };\n else if (flags.color === false) o.render = { color: 'never' };\n if (flags.cache === false) o.cache = { enabled: false };\n if (flags.pager === false) o.render = { ...(o.render ?? {}), pager: 'never' };\n if (flags.highlight === false) o.render = { ...(o.render ?? {}), highlight: 'never' };\n return o;\n}\n\nexport async function openSession(flags: GlobalFlags, opts: { requireRepo: boolean }): Promise<Session> {\n const cwd = resolve(flags.cwd ?? process.cwd());\n let root: string | null = null;\n try {\n root = await gitRoot(cwd);\n } catch (err) {\n if (opts.requireRepo) throw err;\n }\n const loaded = await loadConfig({ gitRoot: root, env: process.env, overrides: flagsToOverrides(flags) });\n const colorEnabled = resolveColor(loaded.config.render.color);\n const c = pc.createColors(colorEnabled);\n const debug = flags.debug ? (msg: string) => process.stderr.write(c.dim(`[bb] ${msg}\\n`)) : () => {};\n const warn = (msg: string) => process.stderr.write(c.yellow(`warning: ${msg}\\n`));\n return { cwd, root, loaded, debug, warn, colorEnabled };\n}\n\nexport function resolveColor(mode: 'auto' | 'always' | 'never'): boolean {\n if (mode === 'always') return true;\n if (mode === 'never') return false;\n return Boolean(process.stdout.isTTY) && process.env.TERM !== 'dumb';\n}\n\nexport function resolveHighlight(mode: 'auto' | 'always' | 'never', colorEnabled: boolean): boolean {\n if (mode === 'never') return false;\n return colorEnabled;\n}\n\nexport function terminalWidth(configured: number | null, stream: { columns?: number } = process.stdout): number {\n return configured ?? (stream.columns || 80);\n}\n","import pc from 'picocolors';\nimport { allPresets, resolveChat, resolveLlm } from '../core/config.js';\nimport { ConfigError } from '../core/errors.js';\nimport { CommandProvider } from '../llm/command.js';\nimport { openSession, type GlobalFlags } from './shared.js';\n\nexport async function configCommand(flags: GlobalFlags & { json?: boolean }): Promise<void> {\n const session = await openSession(flags, { requireRepo: false });\n const { config, layers, cacheDir } = session.loaded;\n\n if (flags.json) {\n process.stdout.write(JSON.stringify(config, null, 2) + '\\n');\n return;\n }\n\n const c = pc.createColors(session.colorEnabled);\n const out: string[] = [];\n out.push(c.bold('Layers') + c.dim(' (later layers win; objects merge, arrays replace)'));\n for (const layer of layers) {\n const status = layer.found ? c.green('applied') : c.dim('not found');\n const where = layer.path ?? (layer.detail || (layer.name === 'defaults' ? 'built-in' : layer.name === 'flags' ? 'command line' : ''));\n out.push(` ${layer.name.padEnd(8)} ${status.padEnd(session.colorEnabled ? 18 : 9)} ${c.dim(where)}`);\n }\n out.push(` cache dir: ${cacheDir}`);\n out.push('');\n\n out.push(c.bold('LLM'));\n try {\n const llm = resolveLlm(config);\n const provider = new CommandProvider({ command: llm.command, promptVia: llm.promptVia, timeoutMs: llm.timeoutMs });\n out.push(` preset: ${llm.preset ?? c.dim('(custom command)')}`);\n out.push(` command: ${provider.describe()}`);\n out.push(` prompt: via ${llm.promptVia}`);\n } catch (err) {\n out.push(` ${c.red((err as ConfigError).message)}`);\n }\n try {\n const chat = resolveChat(config);\n const provider = new CommandProvider({ command: chat.command, promptVia: 'arg', timeoutMs: 1 });\n out.push(` chat: ${provider.describe()}${c.dim(' (bb ask)')}`);\n } catch (err) {\n out.push(` chat: ${c.dim(`none: ${(err as ConfigError).message}`)}`);\n }\n out.push('');\n\n out.push(c.bold('Presets'));\n const presets = allPresets(config);\n const width = Math.max(...Object.keys(presets).map((k) => k.length));\n for (const [name, preset] of Object.entries(presets).sort(([a], [b]) => a.localeCompare(b))) {\n const custom = name in config.llm.presets ? c.dim(' (yours)') : '';\n out.push(` ${name.padEnd(width)} ${preset.description ?? c.dim(preset.command.join(' '))}${custom}`);\n }\n out.push('');\n\n out.push(c.bold('Effective config'));\n out.push(JSON.stringify(config, null, 2).split('\\n').map((l) => ' ' + l).join('\\n'));\n process.stdout.write(out.join('\\n') + '\\n');\n}\n","import pc from 'picocolors';\nimport { buildChatContext } from '../core/chat.js';\nimport { resolveChat, resolveLlm } from '../core/config.js';\nimport { ConfigError, NotARepoError } from '../core/errors.js';\nimport { generateTour, prepareTour } from '../core/tour.js';\nimport { git } from '../git/exec.js';\nimport { chatSlots, launchChat } from '../llm/chat.js';\nimport { describeSource, relativeTime } from '../render/cli.js';\nimport { writeStdout } from '../render/pager.js';\nimport { LiveProgress, loggingProgress } from './progress.js';\nimport { openSession, terminalWidth, type GlobalFlags } from './shared.js';\n\nexport interface AskFlags extends GlobalFlags {\n working?: boolean;\n staged?: boolean;\n refresh?: boolean;\n progress?: boolean;\n dumpContext?: boolean;\n}\n\nexport interface AskArgs {\n range?: string;\n message?: string;\n}\n\n/**\n * `bb ask [range] [message...]`: the first word is a range only when git can resolve it\n * (`HEAD~1`, `main..feat`); otherwise every word is part of the opening message.\n */\nexport async function splitAskArgs(words: string[], opts: { cwd: string; rangeAllowed: boolean }): Promise<AskArgs> {\n const [first, ...rest] = words;\n if (first !== undefined && opts.rangeAllowed && (await isRange(first, opts.cwd))) {\n return { range: first, message: joinMessage(rest) };\n }\n return { message: joinMessage(words) };\n}\n\nasync function isRange(word: string, cwd: string): Promise<boolean> {\n if (!word || /\\s/.test(word)) return false;\n const res = await git(['rev-parse', '--quiet', '--end-of-options', word], { cwd, allowFailure: true });\n return res.code === 0;\n}\n\nfunction joinMessage(words: string[]): string | undefined {\n const text = words.join(' ').trim();\n return text ? text : undefined;\n}\n\nexport async function askCommand(words: string[], flags: AskFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: true });\n if (!session.root) throw new NotARepoError(session.cwd);\n const { config } = session.loaded;\n const c = pc.createColors(session.colorEnabled);\n\n // Fail before any git or model work when there is nothing to chat with.\n const chat = resolveChat(config);\n const slots = chatSlots(chat.command);\n if (!slots.context) {\n throw new ConfigError('The chat command has no {context-file} or {context} token, so the tour cannot be handed to it.', 'Add one of them to the chatCommand; see the README.');\n }\n const llm = resolveLlm(config);\n\n const { range, message } = await splitAskArgs(words, { cwd: session.root, rangeAllowed: !flags.working && !flags.staged });\n session.debug(range ? `range: ${range}` : 'no range argument');\n session.debug(message ? `opening message: ${JSON.stringify(message)}` : 'no opening message');\n\n const live = flags.progress !== false && !flags.debug && Boolean(process.stderr.isTTY) && !flags.dumpContext;\n const progress = live\n ? new LiveProgress(process.stderr, { color: session.colorEnabled, width: terminalWidth(null, process.stderr) })\n : loggingProgress(session.debug);\n\n const options = {\n cwd: session.root,\n config,\n cacheDir: session.loaded.cacheDir,\n range: { arg: range, working: flags.working, staged: flags.staged },\n refresh: flags.refresh,\n noCache: flags.cache === false,\n debug: session.debug,\n warn: session.warn,\n progress,\n };\n\n if (progress instanceof LiveProgress) progress.start();\n let prepared: Awaited<ReturnType<typeof prepareTour>>;\n let result: Awaited<ReturnType<typeof generateTour>>;\n try {\n prepared = await prepareTour(options);\n result = await generateTour(options, prepared);\n } catch (err) {\n if (progress instanceof LiveProgress) progress.stop();\n throw err;\n }\n if (progress instanceof LiveProgress) progress.stop(result.fromCache ? undefined : progress.summary());\n\n const context = buildChatContext({ tour: result.tour, change: prepared.context, maxBytes: llm.maxPromptBytes, tourPath: result.cachePath });\n if (context.truncation.truncated.length || context.truncation.omitted.length) {\n session.warn(`Chat context exceeded ${llm.maxPromptBytes} bytes; truncated ${context.truncation.truncated.length} and omitted ${context.truncation.omitted.length} file diff(s).`);\n }\n if (flags.dumpContext) {\n await writeStdout(context.text.endsWith('\\n') ? context.text : context.text + '\\n');\n return;\n }\n\n const tour = result.tour;\n const when = result.fromCache ? `cached ${relativeTime(tour.generatedAt)}` : 'generated just now';\n process.stderr.write(`${c.bold(`🐣 ${tour.title}`)}${c.dim(` · ${describeSource(tour.source)} · ${when}`)}\\n`);\n if (message && !slots.message) {\n session.warn('This chat command has no {message} slot; type your question into the chat once it opens.');\n }\n process.stderr.write(c.dim(`Opening ${chat.preset ?? chat.command[0]} with the tour as context…\\n`));\n\n const outcome = await launchChat({ command: chat.command, context: context.text, message, cwd: session.root, env: chat.env, debug: session.debug });\n process.exitCode = outcome.exitCode;\n}\n","import pc from 'picocolors';\nimport type { ProgressSink } from '../core/progress.js';\nimport type { LlmEvent } from '../llm/provider.js';\nimport { wrap } from '../render/cli.js';\n\nconst SPINNER = ['✢', '✳', '✶', '✻', '✽', '✻', '✶', '✳'];\nconst VERBS = ['Hatching', 'Pecking', 'Nesting', 'Chirping', 'Preening', 'Fledging', 'Brooding', 'Warbling', 'Peeping', 'Squawking', 'Swooping', 'Tweeting', 'Xeeting', 'Cawing', 'Twiddling About', 'Hopping', '🐥-ing', '🐣-ing', 'Masticating'];\nconst THINKING_TAIL_CHARS = 2000;\nconst VERB_INTERVAL_MS = 7500;\n\nexport interface LiveProgressOptions {\n color: boolean;\n width: number;\n /** How many lines of thinking / section titles to show under the status line. */\n windowLines?: number;\n now?: () => number;\n /** Pin a single verb (tests). */\n verb?: string;\n /** Verbs to rotate through; the built-in list is used, shuffled, when omitted. */\n verbs?: string[];\n /** How often the verb changes. */\n verbIntervalMs?: number;\n frameMs?: number;\n}\n\ninterface Usage {\n outputTokens?: number;\n thinkingTokens?: number;\n model?: string;\n}\n\ntype Stage = 'prep' | 'thinking' | 'writing' | 'output';\n\n/**\n * In-place status block on a TTY: a spinner line plus a small window showing\n * the model's reasoning as it streams, then section titles as the answer forms.\n */\nexport class LiveProgress implements ProgressSink {\n private phaseLabel = '';\n private stage: Stage = 'prep';\n private thinking = '';\n private pulses = 0;\n private answer = '';\n private titles: string[] = [];\n private notices: string[] = [];\n private outputBytes = 0;\n private usage: Usage = {};\n private readonly startedAt: number;\n private frameIndex = 0;\n private lastLines = 0;\n private timer: NodeJS.Timeout | null = null;\n private stopped = false;\n private readonly verbs: string[];\n private readonly now: () => number;\n private readonly windowLines: number;\n private readonly onSigint = () => {\n this.stop();\n process.exit(130);\n };\n\n constructor(\n private readonly stream: { write(chunk: string): boolean },\n private readonly opts: LiveProgressOptions,\n ) {\n this.now = opts.now ?? Date.now;\n this.startedAt = this.now();\n this.verbs = opts.verb ? [opts.verb] : opts.verbs && opts.verbs.length ? opts.verbs : shuffle(VERBS);\n this.windowLines = opts.windowLines ?? 5;\n }\n\n start(): void {\n this.stream.write('\\x1b[?25l');\n process.once('SIGINT', this.onSigint);\n this.timer = setInterval(() => {\n this.frameIndex++;\n this.render();\n }, this.opts.frameMs ?? 80);\n this.timer.unref?.();\n this.render();\n }\n\n phase(label: string): void {\n this.phaseLabel = label;\n if (/^asking/i.test(label)) {\n this.stage = 'thinking';\n this.thinking = '';\n this.pulses = 0;\n this.answer = '';\n this.titles = [];\n this.notices = [];\n this.outputBytes = 0;\n } else if (this.stage !== 'prep') {\n this.stage = 'prep';\n }\n this.render();\n }\n\n llm(event: LlmEvent): void {\n switch (event.type) {\n case 'thinking':\n this.thinking += event.text;\n this.stage = 'thinking'; // thinking after a rejected answer comes back into view\n break;\n case 'thinking-pulse':\n this.pulses++;\n this.stage = 'thinking';\n break;\n case 'answer-start':\n this.answer = '';\n this.titles = [];\n break;\n case 'notice':\n this.notices.push(event.text);\n break;\n case 'text':\n this.answer += event.text;\n this.titles = extractTitles(this.answer);\n this.stage = 'writing';\n break;\n case 'output':\n this.outputBytes = event.bytes;\n this.stage = 'output';\n break;\n case 'usage':\n if (event.outputTokens !== undefined) this.usage.outputTokens = event.outputTokens;\n if (event.thinkingTokens !== undefined) this.usage.thinkingTokens = event.thinkingTokens;\n if (event.model !== undefined) this.usage.model = event.model;\n break;\n default:\n break;\n }\n }\n\n /** The lines that make up the current status block. */\n frame(): string[] {\n const c = pc.createColors(this.opts.color);\n const width = Math.max(30, this.opts.width);\n const spin = c.magenta(SPINNER[this.frameIndex % SPINNER.length]!);\n const elapsed = this.elapsed();\n const fit = (s: string) => (s.length > width - 1 ? s.slice(0, width - 2) + '…' : s);\n const lines: string[] = [];\n\n switch (this.stage) {\n case 'prep':\n lines.push(`${spin} ${fit(this.phaseLabel || 'Starting')}… ${c.dim(elapsed)}`);\n break;\n case 'thinking': {\n const meta = [elapsed, this.phaseLabel.replace(/^asking\\s+/i, '')].filter(Boolean).join(' · ');\n lines.push(`${spin} ${this.verb()}… ${c.dim(meta)}`);\n for (const n of this.notices.slice(-1)) lines.push(` ${c.yellow('↻')} ${c.yellow(fit(n).slice(0, width - 4))}`);\n if (this.thinking) {\n const tail = this.thinking.slice(-THINKING_TAIL_CHARS).replace(/\\s+/g, ' ').trim();\n const wrapped = wrap(tail, width - 4).slice(-this.windowLines);\n for (const l of wrapped) lines.push(` ${c.dim('│')} ${c.dim(l)}`);\n } else if (this.pulses > 0) {\n // The runner reports reasoning heartbeats without text: show a trail that grows with each one.\n const room = Math.max(8, width - 16);\n const n = this.pulses % (room + 1);\n lines.push(` ${c.dim('│')} ${c.dim('reasoning')} ${c.magenta('·'.repeat(n))}`);\n }\n break;\n }\n case 'writing': {\n const n = Math.max(0, this.titles.length - 1);\n lines.push(`${spin} Writing the tour… ${c.dim(`${elapsed} · ${n} section${n === 1 ? '' : 's'} so far`)}`);\n for (const note of this.notices.slice(-1)) lines.push(` ${c.yellow('↻')} ${c.yellow(fit(note).slice(0, width - 4))}`);\n const [tourTitle, ...sections] = this.titles;\n const items: string[] = [];\n if (tourTitle) items.push(` 🐣 ${c.bold(fit(tourTitle).slice(0, width - 6))}`);\n sections.forEach((t) => items.push(` ${c.green('✓')} ${fit(t).slice(0, width - 5)}`));\n for (const l of items.slice(-this.windowLines)) lines.push(l);\n break;\n }\n case 'output':\n lines.push(`${spin} ${this.verb()}… ${c.dim(`${elapsed} · ${formatBytes(this.outputBytes)} received`)}`);\n break;\n }\n return lines;\n }\n\n render(): void {\n if (this.stopped) return;\n const lines = this.frame();\n this.stream.write(this.erase() + lines.join('\\n') + '\\n');\n this.lastLines = lines.length;\n }\n\n /** Clear the block, restore the cursor, and optionally leave a final line behind. */\n stop(finalLine?: string): void {\n if (this.stopped) return;\n this.stopped = true;\n if (this.timer) clearInterval(this.timer);\n process.removeListener('SIGINT', this.onSigint);\n this.stream.write(this.erase() + (finalLine ? finalLine + '\\n' : '') + '\\x1b[?25h');\n this.lastLines = 0;\n }\n\n /** A one-line summary of the model call, for the final line. */\n summary(): string {\n const c = pc.createColors(this.opts.color);\n const parts = [`Hatched in ${this.elapsed()}`];\n if (this.usage.outputTokens) {\n parts.push(`${formatCount(this.usage.outputTokens)} tokens${this.usage.thinkingTokens ? ` (${formatCount(this.usage.thinkingTokens)} thinking)` : ''}`);\n }\n if (this.usage.model) parts.push(this.usage.model);\n return c.dim(`✻ ${parts.join(' · ')}`);\n }\n\n /** The current verb; rotates every verbIntervalMs so long waits do not stare at one word. */\n private verb(): string {\n const step = Math.floor((this.now() - this.startedAt) / (this.opts.verbIntervalMs ?? VERB_INTERVAL_MS));\n return this.verbs[step % this.verbs.length]!;\n }\n\n private elapsed(): string {\n const s = Math.max(0, Math.round((this.now() - this.startedAt) / 1000));\n return s >= 60 ? `${Math.floor(s / 60)}m ${s % 60}s` : `${s}s`;\n }\n\n private erase(): string {\n return this.lastLines ? `\\x1b[${this.lastLines}A\\x1b[0J` : '';\n }\n}\n\n/** Every \"title\" string value in a (possibly partial) JSON document, in order. */\nexport function extractTitles(text: string): string[] {\n const out: string[] = [];\n for (const m of text.matchAll(/\"title\"\\s*:\\s*\"((?:[^\"\\\\]|\\\\.)*)\"/g)) {\n out.push(m[1]!.replace(/\\\\([\"\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, (_, esc: string) => {\n switch (esc[0]) {\n case '\"': return '\"';\n case '\\\\': return '\\\\';\n case '/': return '/';\n case 'n': return '\\n';\n case 't': return '\\t';\n case 'u': return String.fromCharCode(parseInt(esc.slice(1), 16));\n default: return '';\n }\n }));\n }\n return out;\n}\n\n/** A sink that logs phases as plain lines (used with --debug or without a TTY). */\nexport function loggingProgress(log: (msg: string) => void): ProgressSink {\n return {\n phase: (label) => log(label),\n llm: () => {},\n };\n}\n\nfunction shuffle<T>(items: readonly T[]): T[] {\n const out = [...items];\n for (let i = out.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [out[i], out[j]] = [out[j]!, out[i]!];\n }\n return out;\n}\n\nfunction formatBytes(n: number): string {\n return n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} KB`;\n}\n\nfunction formatCount(n: number): string {\n return n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n);\n}\n","import { mkdir, writeFile } from 'node:fs/promises';\nimport { dirname } from 'node:path';\nimport { projectConfigPath } from '../core/config.js';\nimport { NotARepoError, UsageError } from '../core/errors.js';\nimport { openSession, type GlobalFlags } from './shared.js';\n\nconst STARTER = {\n llm: { preset: 'claude' },\n codehost: { provider: 'gh' },\n};\n\nexport async function initCommand(flags: GlobalFlags & { force?: boolean }): Promise<void> {\n const session = await openSession(flags, { requireRepo: true });\n if (!session.root) throw new NotARepoError(session.cwd);\n const path = projectConfigPath(session.root);\n const existing = session.loaded.layers.find((l) => l.name === 'project');\n if (existing?.found && !flags.force) {\n throw new UsageError(`${path} already exists.`, 'Pass --force to overwrite it.');\n }\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, JSON.stringify(STARTER, null, 2) + '\\n', 'utf8');\n process.stdout.write(`Wrote ${path}\\nRun \\`bb config\\` to see the effective configuration and available presets.\\n`);\n}\n","import { NotARepoError } from '../core/errors.js';\nimport { generateTour, prepareTour } from '../core/tour.js';\nimport { CliRenderer } from '../render/cli.js';\nimport { writeMaybePaged, writeStdout } from '../render/pager.js';\nimport { LiveProgress, loggingProgress } from './progress.js';\nimport { openSession, resolveHighlight, terminalWidth, type GlobalFlags } from './shared.js';\n\nexport interface TourFlags extends GlobalFlags {\n working?: boolean;\n staged?: boolean;\n section?: number;\n json?: boolean;\n dumpPrompt?: boolean;\n refresh?: boolean;\n progress?: boolean;\n}\n\nexport async function tourCommand(rangeArg: string | undefined, flags: TourFlags): Promise<void> {\n const session = await openSession(flags, { requireRepo: true });\n if (!session.root) throw new NotARepoError(session.cwd);\n const { config } = session.loaded;\n\n const live = flags.progress !== false && !flags.debug && Boolean(process.stderr.isTTY) && !flags.dumpPrompt;\n const progress = live\n ? new LiveProgress(process.stderr, { color: session.colorEnabled, width: terminalWidth(null, process.stderr) })\n : loggingProgress(session.debug);\n\n const options = {\n cwd: session.root,\n config,\n cacheDir: session.loaded.cacheDir,\n range: { arg: rangeArg, working: flags.working, staged: flags.staged },\n refresh: flags.refresh,\n noCache: flags.cache === false,\n debug: session.debug,\n warn: session.warn,\n progress,\n };\n\n if (progress instanceof LiveProgress) progress.start();\n let result: Awaited<ReturnType<typeof generateTour>>;\n try {\n const prepared = await prepareTour(options);\n if (flags.dumpPrompt) {\n await writeStdout(prepared.built.prompt.endsWith('\\n') ? prepared.built.prompt : prepared.built.prompt + '\\n');\n return;\n }\n result = await generateTour(options, prepared);\n } catch (err) {\n if (progress instanceof LiveProgress) progress.stop();\n throw err;\n }\n if (progress instanceof LiveProgress) progress.stop(result.fromCache ? undefined : progress.summary());\n\n if (flags.json) {\n await writeStdout(JSON.stringify(result.tour, null, 2) + '\\n');\n return;\n }\n\n const renderer = new CliRenderer();\n const output = renderer.render(result.tour, {\n color: session.colorEnabled,\n width: terminalWidth(config.render.width),\n section: flags.section,\n fromCache: result.fromCache,\n highlight: resolveHighlight(config.render.highlight, session.colorEnabled),\n });\n await writeMaybePaged(output, {\n mode: config.render.pager,\n isTTY: Boolean(process.stdout.isTTY),\n rows: process.stdout.rows ?? 24,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,SAAS,4BAA4B;AAC9C,OAAOA,SAAQ;;;ACFf;A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