@cam5/baby-bird 0.1.0 → 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 +56 -4
- package/dist/{chunk-RWSCST2I.js → chunk-YI2UL4IC.js} +706 -52
- package/dist/chunk-YI2UL4IC.js.map +1 -0
- package/dist/cli.js +380 -23
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +317 -6
- package/dist/index.js +21 -1
- package/package.json +2 -1
- package/dist/chunk-RWSCST2I.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -135,7 +135,7 @@ declare const LlmTourOutputSchema: z.ZodObject<{
|
|
|
135
135
|
files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
136
136
|
excerpts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
137
137
|
hunk: z.ZodString;
|
|
138
|
-
lines: z.ZodOptional<z.
|
|
138
|
+
lines: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
139
139
|
note: z.ZodOptional<z.ZodString>;
|
|
140
140
|
}, z.core.$strip>>>;
|
|
141
141
|
}, z.core.$strip>>;
|
|
@@ -214,10 +214,24 @@ declare const TourSchema: z.ZodObject<{
|
|
|
214
214
|
declare function formatIssues(error: z.ZodError): string;
|
|
215
215
|
|
|
216
216
|
type PromptVia = 'stdin' | 'arg';
|
|
217
|
+
type LlmKind = 'plain' | 'claude';
|
|
217
218
|
interface LlmPreset {
|
|
218
219
|
/** argv; when promptVia is "arg", any "{prompt}" token is replaced with the prompt. */
|
|
219
220
|
command: string[];
|
|
221
|
+
/**
|
|
222
|
+
* argv for `bb ask`: an interactive chat about a tour. Tokens: "{context-file}" is the path of a
|
|
223
|
+
* file holding the tour context (a system prompt), "{context}" is that text inline, and
|
|
224
|
+
* "{message}" is the user's opening message (argv entries that are only "{message}" are dropped
|
|
225
|
+
* when there is none).
|
|
226
|
+
*/
|
|
227
|
+
chatCommand?: string[];
|
|
220
228
|
promptVia?: PromptVia;
|
|
229
|
+
/**
|
|
230
|
+
* "claude": the Claude Code CLI; streaming flags and --json-schema are added
|
|
231
|
+
* automatically so thinking can be shown live and the answer is schema-checked.
|
|
232
|
+
* "plain" (default): stdout is the answer.
|
|
233
|
+
*/
|
|
234
|
+
kind?: LlmKind;
|
|
221
235
|
description?: string;
|
|
222
236
|
}
|
|
223
237
|
declare const BUILTIN_PRESETS: Readonly<Record<string, LlmPreset>>;
|
|
@@ -226,18 +240,29 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
226
240
|
preset: z.ZodString;
|
|
227
241
|
presets: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
228
242
|
command: z.ZodArray<z.ZodString>;
|
|
243
|
+
chatCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
229
244
|
promptVia: z.ZodOptional<z.ZodEnum<{
|
|
230
245
|
stdin: "stdin";
|
|
231
246
|
arg: "arg";
|
|
232
247
|
}>>;
|
|
248
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
249
|
+
plain: "plain";
|
|
250
|
+
claude: "claude";
|
|
251
|
+
}>>;
|
|
233
252
|
description: z.ZodOptional<z.ZodString>;
|
|
234
253
|
}, z.core.$strip>>;
|
|
235
254
|
args: z.ZodArray<z.ZodString>;
|
|
236
255
|
command: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
256
|
+
chatCommand: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
237
257
|
promptVia: z.ZodNullable<z.ZodEnum<{
|
|
238
258
|
stdin: "stdin";
|
|
239
259
|
arg: "arg";
|
|
240
260
|
}>>;
|
|
261
|
+
kind: z.ZodNullable<z.ZodEnum<{
|
|
262
|
+
plain: "plain";
|
|
263
|
+
claude: "claude";
|
|
264
|
+
}>>;
|
|
265
|
+
jsonSchema: z.ZodBoolean;
|
|
241
266
|
timeoutMs: z.ZodNumber;
|
|
242
267
|
maxPromptBytes: z.ZodNumber;
|
|
243
268
|
env: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
@@ -265,6 +290,11 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
265
290
|
}>;
|
|
266
291
|
maxExcerptLines: z.ZodNumber;
|
|
267
292
|
width: z.ZodNullable<z.ZodNumber>;
|
|
293
|
+
highlight: z.ZodEnum<{
|
|
294
|
+
never: "never";
|
|
295
|
+
auto: "auto";
|
|
296
|
+
always: "always";
|
|
297
|
+
}>;
|
|
268
298
|
}, z.core.$strip>;
|
|
269
299
|
cache: z.ZodObject<{
|
|
270
300
|
enabled: z.ZodBoolean;
|
|
@@ -277,18 +307,29 @@ declare const PartialConfigSchema: z.ZodObject<{
|
|
|
277
307
|
preset: z.ZodOptional<z.ZodString>;
|
|
278
308
|
presets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
279
309
|
command: z.ZodArray<z.ZodString>;
|
|
310
|
+
chatCommand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
280
311
|
promptVia: z.ZodOptional<z.ZodEnum<{
|
|
281
312
|
stdin: "stdin";
|
|
282
313
|
arg: "arg";
|
|
283
314
|
}>>;
|
|
315
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
316
|
+
plain: "plain";
|
|
317
|
+
claude: "claude";
|
|
318
|
+
}>>;
|
|
284
319
|
description: z.ZodOptional<z.ZodString>;
|
|
285
320
|
}, z.core.$strip>>>;
|
|
286
321
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
287
322
|
command: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
323
|
+
chatCommand: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
288
324
|
promptVia: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
289
325
|
stdin: "stdin";
|
|
290
326
|
arg: "arg";
|
|
291
327
|
}>>>;
|
|
328
|
+
kind: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
329
|
+
plain: "plain";
|
|
330
|
+
claude: "claude";
|
|
331
|
+
}>>>;
|
|
332
|
+
jsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
292
333
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
293
334
|
maxPromptBytes: z.ZodOptional<z.ZodNumber>;
|
|
294
335
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -316,6 +357,11 @@ declare const PartialConfigSchema: z.ZodObject<{
|
|
|
316
357
|
}>>;
|
|
317
358
|
maxExcerptLines: z.ZodOptional<z.ZodNumber>;
|
|
318
359
|
width: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
360
|
+
highlight: z.ZodOptional<z.ZodEnum<{
|
|
361
|
+
never: "never";
|
|
362
|
+
auto: "auto";
|
|
363
|
+
always: "always";
|
|
364
|
+
}>>;
|
|
319
365
|
}, z.core.$strip>>;
|
|
320
366
|
cache: z.ZodOptional<z.ZodObject<{
|
|
321
367
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -356,6 +402,9 @@ declare function loadConfig(opts?: LoadConfigOptions): Promise<LoadedConfig>;
|
|
|
356
402
|
interface ResolvedLlm {
|
|
357
403
|
command: string[];
|
|
358
404
|
promptVia: PromptVia;
|
|
405
|
+
kind: LlmKind;
|
|
406
|
+
/** Whether to hand the answer schema to the runner (Claude kind only). */
|
|
407
|
+
jsonSchema: boolean;
|
|
359
408
|
/** Preset name, or null when a custom command is in use. */
|
|
360
409
|
preset: string | null;
|
|
361
410
|
timeoutMs: number;
|
|
@@ -364,6 +413,15 @@ interface ResolvedLlm {
|
|
|
364
413
|
}
|
|
365
414
|
declare function allPresets(config: Config): Record<string, LlmPreset>;
|
|
366
415
|
declare function resolveLlm(config: Config): ResolvedLlm;
|
|
416
|
+
interface ResolvedChat {
|
|
417
|
+
/** argv template; see LlmPreset.chatCommand for the tokens. */
|
|
418
|
+
command: string[];
|
|
419
|
+
/** Preset name the command came from, or null for llm.chatCommand / a custom command. */
|
|
420
|
+
preset: string | null;
|
|
421
|
+
env: Record<string, string>;
|
|
422
|
+
}
|
|
423
|
+
/** The interactive command `bb ask` runs. Errors when neither the preset nor llm.chatCommand provides one. */
|
|
424
|
+
declare function resolveChat(config: Config): ResolvedChat;
|
|
367
425
|
/** Minimal POSIX-ish shell splitting: whitespace separated, single/double quotes, backslash escapes. */
|
|
368
426
|
declare function shellSplit(input: string): string[];
|
|
369
427
|
|
|
@@ -452,14 +510,19 @@ declare function materializeTour(input: MaterializeInput): Tour;
|
|
|
452
510
|
*/
|
|
453
511
|
declare function sliceHunk(hunk: Hunk, range: [number, number] | undefined, maxLines: number): HunkLine[];
|
|
454
512
|
|
|
455
|
-
|
|
513
|
+
/** The change as gathered from git and the code host. */
|
|
514
|
+
interface ChangeInput {
|
|
456
515
|
source: TourSource;
|
|
457
516
|
branch: string | null;
|
|
458
517
|
diff: ParsedDiff;
|
|
459
518
|
commits: CommitInfo[];
|
|
460
519
|
pullRequest?: PullRequestInfo;
|
|
520
|
+
}
|
|
521
|
+
interface PromptInput extends ChangeInput {
|
|
461
522
|
/** Soft budget for the whole prompt, in bytes. */
|
|
462
523
|
maxBytes: number;
|
|
524
|
+
/** The runner enforces the JSON schema itself (e.g. claude --json-schema); adjusts the output instruction. */
|
|
525
|
+
structured?: boolean;
|
|
463
526
|
}
|
|
464
527
|
interface TruncationReport {
|
|
465
528
|
/** Files whose diff was cut down to the start of their first hunk. */
|
|
@@ -472,10 +535,20 @@ interface BuiltPrompt {
|
|
|
472
535
|
truncation: TruncationReport;
|
|
473
536
|
}
|
|
474
537
|
declare function buildPrompt(input: PromptInput): BuiltPrompt;
|
|
538
|
+
/**
|
|
539
|
+
* The change itself: source, PR text, commit subjects, the file table, and the diff with every
|
|
540
|
+
* hunk labeled by id. Diffs are shortened biggest-file-first to fit `maxBytes`.
|
|
541
|
+
*/
|
|
542
|
+
declare function renderChange(input: ChangeInput, maxBytes: number): {
|
|
543
|
+
text: string;
|
|
544
|
+
truncation: TruncationReport;
|
|
545
|
+
};
|
|
475
546
|
declare function describeSource(source: TourSource, branch: string | null): string;
|
|
476
547
|
|
|
477
548
|
/** Bump whenever the prompt text or its assembly changes materially; it is part of the cache key. */
|
|
478
|
-
declare const PROMPT_VERSION =
|
|
549
|
+
declare const PROMPT_VERSION = 3;
|
|
550
|
+
/** The fixed part of the prompt; `structured` picks the wording for CLIs that enforce a schema themselves. */
|
|
551
|
+
declare function promptHeader(structured: boolean): string;
|
|
479
552
|
|
|
480
553
|
interface CodeHost {
|
|
481
554
|
readonly name: string;
|
|
@@ -527,17 +600,67 @@ interface ResolvedRange {
|
|
|
527
600
|
declare function resolveRange(req: RangeRequest, opts: ResolveOptions): Promise<ResolvedRange>;
|
|
528
601
|
declare function detectDefaultBranch(configured: string | null, cwd: string): Promise<string | null>;
|
|
529
602
|
|
|
603
|
+
/** Events a provider may emit while a completion is in flight. */
|
|
604
|
+
type LlmEvent = {
|
|
605
|
+
type: 'started';
|
|
606
|
+
}
|
|
607
|
+
/** A chunk of the model's (summarized) reasoning, when the runner exposes it. */
|
|
608
|
+
| {
|
|
609
|
+
type: 'thinking';
|
|
610
|
+
text: string;
|
|
611
|
+
}
|
|
612
|
+
/** The model is reasoning but the runner does not expose the text (Claude Code's print mode sends empty deltas). */
|
|
613
|
+
| {
|
|
614
|
+
type: 'thinking-pulse';
|
|
615
|
+
}
|
|
616
|
+
/** A chunk of the answer as it is produced. */
|
|
617
|
+
| {
|
|
618
|
+
type: 'text';
|
|
619
|
+
text: string;
|
|
620
|
+
}
|
|
621
|
+
/** The model started a (new) answer; any previously streamed answer text is superseded. */
|
|
622
|
+
| {
|
|
623
|
+
type: 'answer-start';
|
|
624
|
+
}
|
|
625
|
+
/** Something worth telling the user, e.g. the CLI rejected an answer and the model is retrying. */
|
|
626
|
+
| {
|
|
627
|
+
type: 'notice';
|
|
628
|
+
text: string;
|
|
629
|
+
}
|
|
630
|
+
/** Opaque progress for commands we cannot parse: total stdout bytes so far. */
|
|
631
|
+
| {
|
|
632
|
+
type: 'output';
|
|
633
|
+
bytes: number;
|
|
634
|
+
} | {
|
|
635
|
+
type: 'usage';
|
|
636
|
+
outputTokens?: number;
|
|
637
|
+
thinkingTokens?: number;
|
|
638
|
+
costUsd?: number;
|
|
639
|
+
model?: string;
|
|
640
|
+
};
|
|
641
|
+
interface CompleteOptions {
|
|
642
|
+
onEvent?: (event: LlmEvent) => void;
|
|
643
|
+
}
|
|
530
644
|
interface LlmProvider {
|
|
531
645
|
/** Human-readable description of how the model is invoked, for headers and debug output. */
|
|
532
646
|
describe(): string;
|
|
533
647
|
/** Send a prompt and return the raw text the model produced. */
|
|
534
|
-
complete(prompt: string): Promise<string>;
|
|
648
|
+
complete(prompt: string, opts?: CompleteOptions): Promise<string>;
|
|
535
649
|
}
|
|
536
650
|
|
|
651
|
+
type CommandKind = 'plain' | 'claude';
|
|
537
652
|
interface CommandProviderOptions {
|
|
538
653
|
command: string[];
|
|
539
654
|
promptVia: 'stdin' | 'arg';
|
|
540
655
|
timeoutMs: number;
|
|
656
|
+
/**
|
|
657
|
+
* "plain": stdout is the answer. "claude": the command is the Claude Code CLI;
|
|
658
|
+
* streaming flags (and --json-schema when a schema is given) are appended and
|
|
659
|
+
* the stream-json output is parsed for live thinking/text events.
|
|
660
|
+
*/
|
|
661
|
+
kind?: CommandKind;
|
|
662
|
+
/** JSON Schema the answer must satisfy (Claude kind only). */
|
|
663
|
+
jsonSchema?: object;
|
|
541
664
|
env?: Record<string, string>;
|
|
542
665
|
cwd?: string;
|
|
543
666
|
debug?: (msg: string) => void;
|
|
@@ -546,8 +669,55 @@ interface CommandProviderOptions {
|
|
|
546
669
|
declare class CommandProvider implements LlmProvider {
|
|
547
670
|
private readonly opts;
|
|
548
671
|
constructor(opts: CommandProviderOptions);
|
|
672
|
+
get kind(): CommandKind;
|
|
549
673
|
describe(): string;
|
|
550
|
-
|
|
674
|
+
/** The full argv that will run, including any flags added for the command kind. */
|
|
675
|
+
argv(prompt?: string): string[];
|
|
676
|
+
complete(prompt: string, opts?: CompleteOptions): Promise<string>;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Incremental parser for `claude -p --output-format stream-json --verbose
|
|
681
|
+
* --include-partial-messages`. Emits thinking/text events as deltas arrive and
|
|
682
|
+
* collects the final result (structured output when --json-schema is in use).
|
|
683
|
+
*/
|
|
684
|
+
interface ClaudeStreamUsage {
|
|
685
|
+
outputTokens?: number;
|
|
686
|
+
thinkingTokens?: number;
|
|
687
|
+
costUsd?: number;
|
|
688
|
+
model?: string;
|
|
689
|
+
}
|
|
690
|
+
interface ClaudeStreamOutcome {
|
|
691
|
+
/** Final answer text; structured output is serialized as JSON. */
|
|
692
|
+
result: string | null;
|
|
693
|
+
isError: boolean;
|
|
694
|
+
errorMessage?: string;
|
|
695
|
+
usage: ClaudeStreamUsage;
|
|
696
|
+
/** Lines on stdout that were not JSON (for debugging). */
|
|
697
|
+
unparsedLines: number;
|
|
698
|
+
}
|
|
699
|
+
declare class ClaudeStreamParser {
|
|
700
|
+
private readonly onEvent;
|
|
701
|
+
private buffer;
|
|
702
|
+
private text;
|
|
703
|
+
private partialJson;
|
|
704
|
+
private messageStructured;
|
|
705
|
+
private resultStructured;
|
|
706
|
+
private resultText;
|
|
707
|
+
private isError;
|
|
708
|
+
private errorMessage;
|
|
709
|
+
private usage;
|
|
710
|
+
private unparsed;
|
|
711
|
+
constructor(onEvent?: (event: LlmEvent) => void);
|
|
712
|
+
push(chunk: string): void;
|
|
713
|
+
finish(): ClaudeStreamOutcome;
|
|
714
|
+
private handleLine;
|
|
715
|
+
private handleStreamEvent;
|
|
716
|
+
private handleAssistant;
|
|
717
|
+
/** Tool results the CLI feeds back, e.g. a structured-output validation failure. */
|
|
718
|
+
private handleUser;
|
|
719
|
+
private handleResult;
|
|
720
|
+
private recordUsage;
|
|
551
721
|
}
|
|
552
722
|
|
|
553
723
|
declare function createProvider(llm: ResolvedLlm, opts?: {
|
|
@@ -555,6 +725,15 @@ declare function createProvider(llm: ResolvedLlm, opts?: {
|
|
|
555
725
|
debug?: (msg: string) => void;
|
|
556
726
|
}): LlmProvider;
|
|
557
727
|
|
|
728
|
+
/** Where the pipeline reports what it is doing. The CLI renders this live; other consumers may ignore it. */
|
|
729
|
+
interface ProgressSink {
|
|
730
|
+
/** A new stage began (e.g. "Collecting the diff"). */
|
|
731
|
+
phase(label: string): void;
|
|
732
|
+
/** Something happened inside the model call. */
|
|
733
|
+
llm(event: LlmEvent): void;
|
|
734
|
+
}
|
|
735
|
+
declare const noProgress: ProgressSink;
|
|
736
|
+
|
|
558
737
|
interface TourOptions {
|
|
559
738
|
/** Git root (or any directory inside the repository). */
|
|
560
739
|
cwd: string;
|
|
@@ -567,6 +746,8 @@ interface TourOptions {
|
|
|
567
746
|
noCache?: boolean;
|
|
568
747
|
debug?: (msg: string) => void;
|
|
569
748
|
warn?: (msg: string) => void;
|
|
749
|
+
/** Receives stage changes and model events; the CLI renders these live. */
|
|
750
|
+
progress?: ProgressSink;
|
|
570
751
|
/** Injectable for tests. */
|
|
571
752
|
provider?: LlmProvider;
|
|
572
753
|
codehost?: CodeHost;
|
|
@@ -589,6 +770,23 @@ interface TourResult {
|
|
|
589
770
|
declare function prepareTour(opts: TourOptions): Promise<PreparedTour>;
|
|
590
771
|
declare function generateTour(opts: TourOptions, prepared?: PreparedTour): Promise<TourResult>;
|
|
591
772
|
|
|
773
|
+
interface ChatContextInput {
|
|
774
|
+
tour: Tour;
|
|
775
|
+
/** The change the tour was built from, as gathered by prepareTour. */
|
|
776
|
+
change: ChangeInput;
|
|
777
|
+
/** Soft budget for the whole context, in bytes; the tour is always kept and the diff is shortened to fit. */
|
|
778
|
+
maxBytes: number;
|
|
779
|
+
/** Where the tour JSON lives on disk, when cached, so a tool-using assistant can open it. */
|
|
780
|
+
tourPath?: string | null;
|
|
781
|
+
}
|
|
782
|
+
interface ChatContext {
|
|
783
|
+
/** Markdown meant for a system prompt: framing, the tour, then the change and its diff. */
|
|
784
|
+
text: string;
|
|
785
|
+
truncation: TruncationReport;
|
|
786
|
+
}
|
|
787
|
+
/** The text `bb ask` hands to the chat command as context. */
|
|
788
|
+
declare function buildChatContext(input: ChatContextInput): ChatContext;
|
|
789
|
+
|
|
592
790
|
interface CollectOptions {
|
|
593
791
|
cwd: string;
|
|
594
792
|
exclude: string[];
|
|
@@ -615,6 +813,117 @@ declare function diffStats(diff: ParsedDiff): {
|
|
|
615
813
|
deletions: number;
|
|
616
814
|
};
|
|
617
815
|
|
|
816
|
+
interface ChatArgvInput {
|
|
817
|
+
command: string[];
|
|
818
|
+
contextFile: string;
|
|
819
|
+
context: string;
|
|
820
|
+
message?: string;
|
|
821
|
+
}
|
|
822
|
+
/** Fill the tokens in a chat command. Entries that are exactly "{message}" are dropped when there is no message. */
|
|
823
|
+
declare function chatArgv(input: ChatArgvInput): string[];
|
|
824
|
+
/** Which tokens a chat command uses, so the caller can warn about a message or context that would go nowhere. */
|
|
825
|
+
declare function chatSlots(command: string[]): {
|
|
826
|
+
context: boolean;
|
|
827
|
+
message: boolean;
|
|
828
|
+
};
|
|
829
|
+
interface LaunchChatOptions {
|
|
830
|
+
/** argv template; see chatArgv for the tokens. */
|
|
831
|
+
command: string[];
|
|
832
|
+
/** The system-prompt-like context, written to a temp file for "{context-file}". */
|
|
833
|
+
context: string;
|
|
834
|
+
/** Opening message, if any. */
|
|
835
|
+
message?: string;
|
|
836
|
+
cwd: string;
|
|
837
|
+
env?: Record<string, string>;
|
|
838
|
+
debug?: (msg: string) => void;
|
|
839
|
+
/** Defaults to the terminal ("inherit"); tests use "ignore". */
|
|
840
|
+
stdio?: 'inherit' | 'ignore';
|
|
841
|
+
}
|
|
842
|
+
interface ChatOutcome {
|
|
843
|
+
/** The command's exit code, or 128 + signal number when a signal ended it. */
|
|
844
|
+
exitCode: number;
|
|
845
|
+
signal: NodeJS.Signals | null;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Run an interactive chat command in the foreground, attached to this terminal, and resolve when it
|
|
849
|
+
* exits. Ctrl+C reaches the child through the terminal, so bb ignores SIGINT itself while the chat
|
|
850
|
+
* runs; SIGTERM and SIGHUP are forwarded.
|
|
851
|
+
*/
|
|
852
|
+
declare function launchChat(opts: LaunchChatOptions): Promise<ChatOutcome>;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* JSON Schema for the model's answer, handed to `claude --json-schema` so the
|
|
856
|
+
* CLI enforces the shape itself. Kept deliberately simple (no tuples, no
|
|
857
|
+
* optionals) for structured-output compatibility; zod does the final check.
|
|
858
|
+
*/
|
|
859
|
+
declare const TOUR_JSON_SCHEMA: {
|
|
860
|
+
readonly type: "object";
|
|
861
|
+
readonly description: "The tour itself. Its fields (title, summary, sections) are the top-level properties of this object; do not wrap them in another key.";
|
|
862
|
+
readonly additionalProperties: false;
|
|
863
|
+
readonly required: readonly ["title", "summary", "sections"];
|
|
864
|
+
readonly properties: {
|
|
865
|
+
readonly title: {
|
|
866
|
+
readonly type: "string";
|
|
867
|
+
readonly description: "Short imperative title naming the change, like a good commit subject.";
|
|
868
|
+
};
|
|
869
|
+
readonly summary: {
|
|
870
|
+
readonly type: "string";
|
|
871
|
+
readonly description: "2 to 4 sentences describing the whole change and its motivation.";
|
|
872
|
+
};
|
|
873
|
+
readonly sections: {
|
|
874
|
+
readonly type: "array";
|
|
875
|
+
readonly description: "Ordered sections of the tour, 2 to 8 of them.";
|
|
876
|
+
readonly items: {
|
|
877
|
+
readonly type: "object";
|
|
878
|
+
readonly additionalProperties: false;
|
|
879
|
+
readonly required: readonly ["title", "description", "files", "excerpts"];
|
|
880
|
+
readonly properties: {
|
|
881
|
+
readonly title: {
|
|
882
|
+
readonly type: "string";
|
|
883
|
+
};
|
|
884
|
+
readonly description: {
|
|
885
|
+
readonly type: "string";
|
|
886
|
+
readonly description: "Why, then what, then what to watch. 2 to 5 sentences.";
|
|
887
|
+
};
|
|
888
|
+
readonly files: {
|
|
889
|
+
readonly type: "array";
|
|
890
|
+
readonly items: {
|
|
891
|
+
readonly type: "string";
|
|
892
|
+
};
|
|
893
|
+
readonly description: "Paths this section is about, exactly as listed.";
|
|
894
|
+
};
|
|
895
|
+
readonly excerpts: {
|
|
896
|
+
readonly type: "array";
|
|
897
|
+
readonly description: "1 to 3 hunks that best show the idea.";
|
|
898
|
+
readonly items: {
|
|
899
|
+
readonly type: "object";
|
|
900
|
+
readonly additionalProperties: false;
|
|
901
|
+
readonly required: readonly ["hunk", "lines", "note"];
|
|
902
|
+
readonly properties: {
|
|
903
|
+
readonly hunk: {
|
|
904
|
+
readonly type: "string";
|
|
905
|
+
readonly description: "A hunk id exactly as given in the diff, e.g. \"F2.H1\".";
|
|
906
|
+
};
|
|
907
|
+
readonly lines: {
|
|
908
|
+
readonly type: "array";
|
|
909
|
+
readonly items: {
|
|
910
|
+
readonly type: "integer";
|
|
911
|
+
};
|
|
912
|
+
readonly description: "Empty for the whole hunk, or [start, end] new-file line numbers to narrow it.";
|
|
913
|
+
};
|
|
914
|
+
readonly note: {
|
|
915
|
+
readonly type: "string";
|
|
916
|
+
readonly description: "Under 15 words: what to look at. May be empty.";
|
|
917
|
+
};
|
|
918
|
+
};
|
|
919
|
+
};
|
|
920
|
+
};
|
|
921
|
+
};
|
|
922
|
+
};
|
|
923
|
+
};
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
|
|
618
927
|
interface RenderOptions {
|
|
619
928
|
/** Emit ANSI colors. */
|
|
620
929
|
color: boolean;
|
|
@@ -624,6 +933,8 @@ interface RenderOptions {
|
|
|
624
933
|
section?: number;
|
|
625
934
|
/** Whether the tour came from the cache, for the header note. */
|
|
626
935
|
fromCache?: boolean;
|
|
936
|
+
/** Language-aware token colors in excerpts. Needs color. */
|
|
937
|
+
highlight?: boolean;
|
|
627
938
|
}
|
|
628
939
|
interface Renderer {
|
|
629
940
|
render(tour: Tour, opts: RenderOptions): string;
|
|
@@ -645,4 +956,4 @@ interface PagerOptions {
|
|
|
645
956
|
/** Write output to stdout, through $PAGER (default `less -RFX`) when it would not fit the screen. */
|
|
646
957
|
declare function writeMaybePaged(output: string, opts: PagerOptions): Promise<void>;
|
|
647
958
|
|
|
648
|
-
export { BUILTIN_PRESETS, BadLlmOutputError, BbError, type BuiltPrompt, type CacheEntry, CliRenderer, type CodeHost, CommandProvider, type CommitInfo, type Config, ConfigError, type ConfigLayer, ConfigSchema, DEFAULT_CONFIG, type DiffFile, type Excerpt, type FileStatus, GhCodeHost, GitError, type Hunk, type HunkLine, type LineType, LlmFailedError, type LlmPreset, type LlmProvider, type LlmTourOutput, LlmTourOutputSchema, type LoadedConfig, NoChangesError, NoCodeHost, NotARepoError, OTHER_CHANGES_TITLE, PROMPT_VERSION, type ParsedDiff, type PartialConfig, PartialConfigSchema, type PreparedTour, type PromptInput, type PullRequestInfo, type RangeRequest, type RangeResolvedBy, type RenderOptions, type Renderer, type ResolveOptions, type ResolvedLlm, type ResolvedRange, type Section, type Tour, TourCache, type TourContext, type TourGenerator, type TourOptions, type TourResult, TourSchema, type TourSource, type TourStats, type TruncationReport, UsageError, type WorkingResolvedBy, allPresets, buildPrompt, collectCommits, collectDiff, createCodeHost, createProvider, currentBranch, deepMerge, defaultCacheDir, describeSource, detectDefaultBranch, diffStats, extractJson, formatIssues, generateTour, gitRoot, loadConfig, materializeTour, parseDiff, prepareTour, projectConfigPath, relativeTime, resolveLlm, resolveRange, revParse, shellSplit, sliceHunk, userConfigPath, wrap, writeMaybePaged };
|
|
959
|
+
export { BUILTIN_PRESETS, BadLlmOutputError, BbError, type BuiltPrompt, type CacheEntry, type ChangeInput, type ChatContext, type ChatContextInput, type ChatOutcome, ClaudeStreamParser, CliRenderer, type CodeHost, type CommandKind, CommandProvider, type CommitInfo, type CompleteOptions, type Config, ConfigError, type ConfigLayer, ConfigSchema, DEFAULT_CONFIG, type DiffFile, type Excerpt, type FileStatus, GhCodeHost, GitError, type Hunk, type HunkLine, type LaunchChatOptions, type LineType, type LlmEvent, LlmFailedError, type LlmKind, type LlmPreset, type LlmProvider, type LlmTourOutput, LlmTourOutputSchema, type LoadedConfig, NoChangesError, NoCodeHost, NotARepoError, OTHER_CHANGES_TITLE, PROMPT_VERSION, type ParsedDiff, type PartialConfig, PartialConfigSchema, type PreparedTour, type ProgressSink, type PromptInput, type PullRequestInfo, type RangeRequest, type RangeResolvedBy, type RenderOptions, type Renderer, type ResolveOptions, type ResolvedChat, type ResolvedLlm, type ResolvedRange, type Section, TOUR_JSON_SCHEMA, type Tour, TourCache, type TourContext, type TourGenerator, type TourOptions, type TourResult, TourSchema, type TourSource, type TourStats, type TruncationReport, UsageError, type WorkingResolvedBy, allPresets, buildChatContext, buildPrompt, chatArgv, chatSlots, collectCommits, collectDiff, createCodeHost, createProvider, currentBranch, deepMerge, defaultCacheDir, describeSource, detectDefaultBranch, diffStats, extractJson, formatIssues, generateTour, gitRoot, launchChat, loadConfig, materializeTour, noProgress, parseDiff, prepareTour, projectConfigPath, promptHeader, relativeTime, renderChange, resolveChat, resolveLlm, resolveRange, revParse, shellSplit, sliceHunk, userConfigPath, wrap, writeMaybePaged };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
BUILTIN_PRESETS,
|
|
3
3
|
BadLlmOutputError,
|
|
4
4
|
BbError,
|
|
5
|
+
ClaudeStreamParser,
|
|
5
6
|
CliRenderer,
|
|
6
7
|
CommandProvider,
|
|
7
8
|
ConfigError,
|
|
@@ -17,11 +18,15 @@ import {
|
|
|
17
18
|
OTHER_CHANGES_TITLE,
|
|
18
19
|
PROMPT_VERSION,
|
|
19
20
|
PartialConfigSchema,
|
|
21
|
+
TOUR_JSON_SCHEMA,
|
|
20
22
|
TourCache,
|
|
21
23
|
TourSchema,
|
|
22
24
|
UsageError,
|
|
23
25
|
allPresets,
|
|
26
|
+
buildChatContext,
|
|
24
27
|
buildPrompt,
|
|
28
|
+
chatArgv,
|
|
29
|
+
chatSlots,
|
|
25
30
|
collectCommits,
|
|
26
31
|
collectDiff,
|
|
27
32
|
createCodeHost,
|
|
@@ -36,12 +41,17 @@ import {
|
|
|
36
41
|
formatIssues,
|
|
37
42
|
generateTour,
|
|
38
43
|
gitRoot,
|
|
44
|
+
launchChat,
|
|
39
45
|
loadConfig,
|
|
40
46
|
materializeTour,
|
|
47
|
+
noProgress,
|
|
41
48
|
parseDiff,
|
|
42
49
|
prepareTour,
|
|
43
50
|
projectConfigPath,
|
|
51
|
+
promptHeader,
|
|
44
52
|
relativeTime,
|
|
53
|
+
renderChange,
|
|
54
|
+
resolveChat,
|
|
45
55
|
resolveLlm,
|
|
46
56
|
resolveRange,
|
|
47
57
|
revParse,
|
|
@@ -50,11 +60,12 @@ import {
|
|
|
50
60
|
userConfigPath,
|
|
51
61
|
wrap,
|
|
52
62
|
writeMaybePaged
|
|
53
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-YI2UL4IC.js";
|
|
54
64
|
export {
|
|
55
65
|
BUILTIN_PRESETS,
|
|
56
66
|
BadLlmOutputError,
|
|
57
67
|
BbError,
|
|
68
|
+
ClaudeStreamParser,
|
|
58
69
|
CliRenderer,
|
|
59
70
|
CommandProvider,
|
|
60
71
|
ConfigError,
|
|
@@ -70,11 +81,15 @@ export {
|
|
|
70
81
|
OTHER_CHANGES_TITLE,
|
|
71
82
|
PROMPT_VERSION,
|
|
72
83
|
PartialConfigSchema,
|
|
84
|
+
TOUR_JSON_SCHEMA,
|
|
73
85
|
TourCache,
|
|
74
86
|
TourSchema,
|
|
75
87
|
UsageError,
|
|
76
88
|
allPresets,
|
|
89
|
+
buildChatContext,
|
|
77
90
|
buildPrompt,
|
|
91
|
+
chatArgv,
|
|
92
|
+
chatSlots,
|
|
78
93
|
collectCommits,
|
|
79
94
|
collectDiff,
|
|
80
95
|
createCodeHost,
|
|
@@ -89,12 +104,17 @@ export {
|
|
|
89
104
|
formatIssues,
|
|
90
105
|
generateTour,
|
|
91
106
|
gitRoot,
|
|
107
|
+
launchChat,
|
|
92
108
|
loadConfig,
|
|
93
109
|
materializeTour,
|
|
110
|
+
noProgress,
|
|
94
111
|
parseDiff,
|
|
95
112
|
prepareTour,
|
|
96
113
|
projectConfigPath,
|
|
114
|
+
promptHeader,
|
|
97
115
|
relativeTime,
|
|
116
|
+
renderChange,
|
|
117
|
+
resolveChat,
|
|
98
118
|
resolveLlm,
|
|
99
119
|
resolveRange,
|
|
100
120
|
revParse,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cam5/baby-bird",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Guided code tours for git changes, on the command line.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"commander": "^15.0.0",
|
|
49
|
+
"lowlight": "^3.3.0",
|
|
49
50
|
"picocolors": "^1.1.1",
|
|
50
51
|
"zod": "^4.6.2"
|
|
51
52
|
},
|