@rely-ai/caliber 1.20.0-dev.1773690658 → 1.20.0-dev.1773691540
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +414 -238
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -227,7 +227,7 @@ import { fileURLToPath } from "url";
|
|
|
227
227
|
|
|
228
228
|
// src/commands/init.ts
|
|
229
229
|
import path20 from "path";
|
|
230
|
-
import
|
|
230
|
+
import chalk11 from "chalk";
|
|
231
231
|
import ora2 from "ora";
|
|
232
232
|
import select5 from "@inquirer/select";
|
|
233
233
|
import checkbox from "@inquirer/checkbox";
|
|
@@ -6516,9 +6516,101 @@ function formatMs(ms) {
|
|
|
6516
6516
|
}
|
|
6517
6517
|
|
|
6518
6518
|
// src/utils/parallel-tasks.ts
|
|
6519
|
+
import chalk10 from "chalk";
|
|
6520
|
+
|
|
6521
|
+
// src/utils/waiting-content.ts
|
|
6519
6522
|
import chalk9 from "chalk";
|
|
6523
|
+
|
|
6524
|
+
// src/utils/waiting-cards.json
|
|
6525
|
+
var waiting_cards_default = [
|
|
6526
|
+
{
|
|
6527
|
+
title: "What is Caliber?",
|
|
6528
|
+
icon: "?",
|
|
6529
|
+
lines: [
|
|
6530
|
+
"Caliber scans your project and generates tailored configs",
|
|
6531
|
+
"for Claude Code, Cursor, and Codex \u2014 so your AI agent",
|
|
6532
|
+
"understands your codebase from the start."
|
|
6533
|
+
]
|
|
6534
|
+
},
|
|
6535
|
+
{
|
|
6536
|
+
title: "Generated Configs",
|
|
6537
|
+
icon: "\u2699",
|
|
6538
|
+
lines: [
|
|
6539
|
+
"CLAUDE.md and .cursor/rules/ tell your AI agent about",
|
|
6540
|
+
"your build commands, conventions, architecture, and tools.",
|
|
6541
|
+
"Think of them as onboarding docs \u2014 but for your copilot."
|
|
6542
|
+
]
|
|
6543
|
+
},
|
|
6544
|
+
{
|
|
6545
|
+
title: "Skills",
|
|
6546
|
+
icon: "\u26A1",
|
|
6547
|
+
lines: [
|
|
6548
|
+
"Skills are reusable task-specific instructions your agent",
|
|
6549
|
+
"loads on demand \u2014 deploy scripts, migration patterns, etc.",
|
|
6550
|
+
"Run `caliber skills` to search the community registry."
|
|
6551
|
+
]
|
|
6552
|
+
},
|
|
6553
|
+
{
|
|
6554
|
+
title: "Keep Configs Fresh",
|
|
6555
|
+
icon: "\u21BB",
|
|
6556
|
+
lines: [
|
|
6557
|
+
"As your code evolves, configs drift. `caliber refresh`",
|
|
6558
|
+
"reads your recent git diffs and updates configs to match.",
|
|
6559
|
+
"Add it as a post-commit hook for hands-free updates."
|
|
6560
|
+
]
|
|
6561
|
+
},
|
|
6562
|
+
{
|
|
6563
|
+
title: "Score Your Setup",
|
|
6564
|
+
icon: "\u2605",
|
|
6565
|
+
lines: [
|
|
6566
|
+
"`caliber score` runs 20+ checks against your config \u2014",
|
|
6567
|
+
"grounding, accuracy, freshness \u2014 and gives a letter grade.",
|
|
6568
|
+
"Aim for an A to get the most out of your AI agent."
|
|
6569
|
+
]
|
|
6570
|
+
},
|
|
6571
|
+
{
|
|
6572
|
+
title: "Quick Health Check",
|
|
6573
|
+
icon: "\u2764",
|
|
6574
|
+
lines: [
|
|
6575
|
+
"`caliber status` shows what you have configured,",
|
|
6576
|
+
"which hooks are active, and if anything needs attention.",
|
|
6577
|
+
"It runs in under a second \u2014 great for CI checks too."
|
|
6578
|
+
]
|
|
6579
|
+
}
|
|
6580
|
+
];
|
|
6581
|
+
|
|
6582
|
+
// src/utils/waiting-content.ts
|
|
6583
|
+
var ACCENT = chalk9.hex("#83D1EB");
|
|
6584
|
+
var BRAND = chalk9.hex("#EB9D83");
|
|
6585
|
+
var WAITING_CARDS = waiting_cards_default;
|
|
6586
|
+
function highlightCommands(text) {
|
|
6587
|
+
return text.replace(/`([^`]+)`/g, (_, cmd) => ACCENT(cmd));
|
|
6588
|
+
}
|
|
6589
|
+
function renderCard(card, index, total, cols) {
|
|
6590
|
+
const prefix = " ";
|
|
6591
|
+
const maxWidth = Math.min(cols - 8, 65);
|
|
6592
|
+
const lines = [];
|
|
6593
|
+
lines.push(chalk9.dim(`${prefix}${"\u2500".repeat(maxWidth)}`));
|
|
6594
|
+
lines.push("");
|
|
6595
|
+
const dots = Array.from(
|
|
6596
|
+
{ length: total },
|
|
6597
|
+
(_, i) => i === index ? ACCENT("\u25CF") : chalk9.dim("\u25CB")
|
|
6598
|
+
).join(" ");
|
|
6599
|
+
lines.push(`${prefix}${chalk9.dim("While you wait...")} ${dots}`);
|
|
6600
|
+
lines.push("");
|
|
6601
|
+
lines.push(`${prefix}${BRAND(card.icon)} ${chalk9.bold(card.title)}`);
|
|
6602
|
+
for (const line of card.lines) {
|
|
6603
|
+
lines.push(`${prefix} ${chalk9.dim(highlightCommands(line))}`);
|
|
6604
|
+
}
|
|
6605
|
+
lines.push("");
|
|
6606
|
+
lines.push(`${prefix}${chalk9.dim("\u2190 \u2192 navigate auto-advances every 15s")}`);
|
|
6607
|
+
return lines;
|
|
6608
|
+
}
|
|
6609
|
+
|
|
6610
|
+
// src/utils/parallel-tasks.ts
|
|
6520
6611
|
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
6521
6612
|
var SPINNER_INTERVAL_MS = 80;
|
|
6613
|
+
var CARD_ADVANCE_MS = 15e3;
|
|
6522
6614
|
var NAME_COL_WIDTH = 26;
|
|
6523
6615
|
var PREFIX = " ";
|
|
6524
6616
|
var ParallelTaskDisplay = class {
|
|
@@ -6528,6 +6620,14 @@ var ParallelTaskDisplay = class {
|
|
|
6528
6620
|
timer = null;
|
|
6529
6621
|
startTime = 0;
|
|
6530
6622
|
rendered = false;
|
|
6623
|
+
waitingEnabled = false;
|
|
6624
|
+
waitingCards = [];
|
|
6625
|
+
currentCard = 0;
|
|
6626
|
+
cardTimer = null;
|
|
6627
|
+
keypressHandler = null;
|
|
6628
|
+
cachedCardLines = null;
|
|
6629
|
+
cachedCardIndex = -1;
|
|
6630
|
+
cachedCardCols = -1;
|
|
6531
6631
|
add(name) {
|
|
6532
6632
|
const index = this.tasks.length;
|
|
6533
6633
|
this.tasks.push({ name, status: "pending", message: "" });
|
|
@@ -6553,13 +6653,78 @@ var ParallelTaskDisplay = class {
|
|
|
6553
6653
|
task.status = status;
|
|
6554
6654
|
if (message !== void 0) task.message = message;
|
|
6555
6655
|
}
|
|
6656
|
+
enableWaitingContent() {
|
|
6657
|
+
if (!process.stdin.isTTY) return;
|
|
6658
|
+
this.waitingCards = WAITING_CARDS;
|
|
6659
|
+
if (this.waitingCards.length === 0) return;
|
|
6660
|
+
this.waitingEnabled = true;
|
|
6661
|
+
this.currentCard = 0;
|
|
6662
|
+
this.cardTimer = setInterval(() => {
|
|
6663
|
+
this.advanceCard(1);
|
|
6664
|
+
}, CARD_ADVANCE_MS);
|
|
6665
|
+
const { stdin } = process;
|
|
6666
|
+
stdin.setRawMode(true);
|
|
6667
|
+
stdin.resume();
|
|
6668
|
+
stdin.setEncoding("utf8");
|
|
6669
|
+
this.keypressHandler = (key) => {
|
|
6670
|
+
const str = String(key);
|
|
6671
|
+
switch (str) {
|
|
6672
|
+
case "\x1B[C":
|
|
6673
|
+
case "n":
|
|
6674
|
+
this.advanceCard(1);
|
|
6675
|
+
this.resetCardTimer();
|
|
6676
|
+
break;
|
|
6677
|
+
case "\x1B[D":
|
|
6678
|
+
case "p":
|
|
6679
|
+
this.advanceCard(-1);
|
|
6680
|
+
this.resetCardTimer();
|
|
6681
|
+
break;
|
|
6682
|
+
case "":
|
|
6683
|
+
this.disableWaitingContent();
|
|
6684
|
+
process.kill(process.pid, "SIGINT");
|
|
6685
|
+
break;
|
|
6686
|
+
}
|
|
6687
|
+
};
|
|
6688
|
+
stdin.on("data", this.keypressHandler);
|
|
6689
|
+
}
|
|
6556
6690
|
stop() {
|
|
6691
|
+
this.disableWaitingContent();
|
|
6557
6692
|
if (this.timer) {
|
|
6558
6693
|
clearInterval(this.timer);
|
|
6559
6694
|
this.timer = null;
|
|
6560
6695
|
}
|
|
6561
6696
|
this.draw(false);
|
|
6562
6697
|
}
|
|
6698
|
+
advanceCard(offset) {
|
|
6699
|
+
this.currentCard = (this.currentCard + offset + this.waitingCards.length) % this.waitingCards.length;
|
|
6700
|
+
this.cachedCardLines = null;
|
|
6701
|
+
}
|
|
6702
|
+
disableWaitingContent() {
|
|
6703
|
+
if (!this.waitingEnabled) return;
|
|
6704
|
+
if (this.cardTimer) {
|
|
6705
|
+
clearInterval(this.cardTimer);
|
|
6706
|
+
this.cardTimer = null;
|
|
6707
|
+
}
|
|
6708
|
+
if (this.keypressHandler) {
|
|
6709
|
+
const { stdin } = process;
|
|
6710
|
+
stdin.removeListener("data", this.keypressHandler);
|
|
6711
|
+
if (stdin.isTTY) {
|
|
6712
|
+
stdin.setRawMode(false);
|
|
6713
|
+
stdin.pause();
|
|
6714
|
+
}
|
|
6715
|
+
this.keypressHandler = null;
|
|
6716
|
+
}
|
|
6717
|
+
this.waitingEnabled = false;
|
|
6718
|
+
this.cachedCardLines = null;
|
|
6719
|
+
}
|
|
6720
|
+
resetCardTimer() {
|
|
6721
|
+
if (this.cardTimer) {
|
|
6722
|
+
clearInterval(this.cardTimer);
|
|
6723
|
+
this.cardTimer = setInterval(() => {
|
|
6724
|
+
this.advanceCard(1);
|
|
6725
|
+
}, CARD_ADVANCE_MS);
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6563
6728
|
formatTime(ms) {
|
|
6564
6729
|
const secs = Math.floor(ms / 1e3);
|
|
6565
6730
|
if (secs < 60) return `${secs}s`;
|
|
@@ -6575,31 +6740,31 @@ var ParallelTaskDisplay = class {
|
|
|
6575
6740
|
renderLine(task) {
|
|
6576
6741
|
const cols = process.stdout.columns || 80;
|
|
6577
6742
|
const elapsed = task.startTime ? this.formatTime((task.endTime ?? Date.now()) - task.startTime) : "";
|
|
6578
|
-
const timeStr = elapsed ? ` ${
|
|
6743
|
+
const timeStr = elapsed ? ` ${chalk10.dim(elapsed)}` : "";
|
|
6579
6744
|
const timePlain = elapsed ? ` ${elapsed}` : "";
|
|
6580
6745
|
let icon;
|
|
6581
6746
|
let nameStyle;
|
|
6582
6747
|
let msgStyle;
|
|
6583
6748
|
switch (task.status) {
|
|
6584
6749
|
case "pending":
|
|
6585
|
-
icon =
|
|
6586
|
-
nameStyle =
|
|
6587
|
-
msgStyle =
|
|
6750
|
+
icon = chalk10.dim("\u25CB");
|
|
6751
|
+
nameStyle = chalk10.dim;
|
|
6752
|
+
msgStyle = chalk10.dim;
|
|
6588
6753
|
break;
|
|
6589
6754
|
case "running":
|
|
6590
|
-
icon =
|
|
6591
|
-
nameStyle =
|
|
6592
|
-
msgStyle =
|
|
6755
|
+
icon = chalk10.cyan(SPINNER_FRAMES[this.spinnerFrame]);
|
|
6756
|
+
nameStyle = chalk10.white;
|
|
6757
|
+
msgStyle = chalk10.dim;
|
|
6593
6758
|
break;
|
|
6594
6759
|
case "done":
|
|
6595
|
-
icon =
|
|
6596
|
-
nameStyle =
|
|
6597
|
-
msgStyle =
|
|
6760
|
+
icon = chalk10.green("\u2713");
|
|
6761
|
+
nameStyle = chalk10.white;
|
|
6762
|
+
msgStyle = chalk10.dim;
|
|
6598
6763
|
break;
|
|
6599
6764
|
case "failed":
|
|
6600
|
-
icon =
|
|
6601
|
-
nameStyle =
|
|
6602
|
-
msgStyle =
|
|
6765
|
+
icon = chalk10.red("\u2717");
|
|
6766
|
+
nameStyle = chalk10.white;
|
|
6767
|
+
msgStyle = chalk10.red;
|
|
6603
6768
|
break;
|
|
6604
6769
|
}
|
|
6605
6770
|
const paddedName = task.name.padEnd(NAME_COL_WIDTH);
|
|
@@ -6615,6 +6780,16 @@ var ParallelTaskDisplay = class {
|
|
|
6615
6780
|
}
|
|
6616
6781
|
stdout.write("\x1B[0J");
|
|
6617
6782
|
const lines = this.tasks.map((t) => this.renderLine(t));
|
|
6783
|
+
if (this.waitingEnabled && this.waitingCards.length > 0 && stdout.isTTY) {
|
|
6784
|
+
const cols = stdout.columns || 80;
|
|
6785
|
+
if (this.currentCard !== this.cachedCardIndex || cols !== this.cachedCardCols || !this.cachedCardLines) {
|
|
6786
|
+
const card = this.waitingCards[this.currentCard];
|
|
6787
|
+
this.cachedCardLines = renderCard(card, this.currentCard, this.waitingCards.length, cols);
|
|
6788
|
+
this.cachedCardIndex = this.currentCard;
|
|
6789
|
+
this.cachedCardCols = cols;
|
|
6790
|
+
}
|
|
6791
|
+
lines.push(...this.cachedCardLines);
|
|
6792
|
+
}
|
|
6618
6793
|
const output = lines.join("\n");
|
|
6619
6794
|
stdout.write(output + "\n");
|
|
6620
6795
|
this.lineCount = output.split("\n").length;
|
|
@@ -6624,11 +6799,11 @@ var ParallelTaskDisplay = class {
|
|
|
6624
6799
|
|
|
6625
6800
|
// src/commands/init.ts
|
|
6626
6801
|
function log(verbose, ...args) {
|
|
6627
|
-
if (verbose) console.log(
|
|
6802
|
+
if (verbose) console.log(chalk11.dim(` [verbose] ${args.map(String).join(" ")}`));
|
|
6628
6803
|
}
|
|
6629
6804
|
async function initCommand(options) {
|
|
6630
|
-
const brand =
|
|
6631
|
-
const title =
|
|
6805
|
+
const brand = chalk11.hex("#EB9D83");
|
|
6806
|
+
const title = chalk11.hex("#83D1EB");
|
|
6632
6807
|
console.log(brand.bold(`
|
|
6633
6808
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
6634
6809
|
\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
|
|
@@ -6637,33 +6812,33 @@ async function initCommand(options) {
|
|
|
6637
6812
|
\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551
|
|
6638
6813
|
\u255A\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
|
|
6639
6814
|
`));
|
|
6640
|
-
console.log(
|
|
6641
|
-
console.log(
|
|
6815
|
+
console.log(chalk11.dim(" Scan your project and generate tailored config files for"));
|
|
6816
|
+
console.log(chalk11.dim(" Claude Code, Cursor, and Codex.\n"));
|
|
6642
6817
|
const report = options.debugReport ? new DebugReport() : null;
|
|
6643
6818
|
console.log(title.bold(" How it works:\n"));
|
|
6644
|
-
console.log(
|
|
6645
|
-
console.log(
|
|
6646
|
-
console.log(
|
|
6647
|
-
console.log(
|
|
6819
|
+
console.log(chalk11.dim(" 1. Setup Connect your LLM provider and select your agents"));
|
|
6820
|
+
console.log(chalk11.dim(" 2. Engine Detect stack, generate configs & skills in parallel"));
|
|
6821
|
+
console.log(chalk11.dim(" 3. Review See all changes \u2014 accept, refine, or decline"));
|
|
6822
|
+
console.log(chalk11.dim(" 4. Finalize Score check and auto-sync hooks\n"));
|
|
6648
6823
|
console.log(title.bold(" Step 1/4 \u2014 Setup\n"));
|
|
6649
6824
|
let config = loadConfig();
|
|
6650
6825
|
if (!config) {
|
|
6651
|
-
console.log(
|
|
6826
|
+
console.log(chalk11.dim(" No LLM provider configured yet.\n"));
|
|
6652
6827
|
await runInteractiveProviderSetup({
|
|
6653
6828
|
selectMessage: "How do you want to use Caliber? (choose LLM provider)"
|
|
6654
6829
|
});
|
|
6655
6830
|
config = loadConfig();
|
|
6656
6831
|
if (!config) {
|
|
6657
|
-
console.log(
|
|
6832
|
+
console.log(chalk11.red(" Setup was cancelled or failed.\n"));
|
|
6658
6833
|
throw new Error("__exit__");
|
|
6659
6834
|
}
|
|
6660
|
-
console.log(
|
|
6835
|
+
console.log(chalk11.green(" \u2713 Provider saved\n"));
|
|
6661
6836
|
}
|
|
6662
6837
|
trackInitProviderSelected(config.provider, config.model);
|
|
6663
6838
|
const displayModel = getDisplayModel(config);
|
|
6664
6839
|
const fastModel = getFastModel();
|
|
6665
6840
|
const modelLine = fastModel ? ` Provider: ${config.provider} | Model: ${displayModel} | Scan: ${fastModel}` : ` Provider: ${config.provider} | Model: ${displayModel}`;
|
|
6666
|
-
console.log(
|
|
6841
|
+
console.log(chalk11.dim(modelLine + "\n"));
|
|
6667
6842
|
if (report) {
|
|
6668
6843
|
report.markStep("Provider setup");
|
|
6669
6844
|
report.addSection("LLM Provider", `- **Provider**: ${config.provider}
|
|
@@ -6680,7 +6855,7 @@ async function initCommand(options) {
|
|
|
6680
6855
|
} else {
|
|
6681
6856
|
targetAgent = await promptAgent();
|
|
6682
6857
|
}
|
|
6683
|
-
console.log(
|
|
6858
|
+
console.log(chalk11.dim(` Target: ${targetAgent.join(", ")}
|
|
6684
6859
|
`));
|
|
6685
6860
|
trackInitAgentSelected(targetAgent);
|
|
6686
6861
|
let wantsSkills = false;
|
|
@@ -6694,7 +6869,7 @@ async function initCommand(options) {
|
|
|
6694
6869
|
});
|
|
6695
6870
|
}
|
|
6696
6871
|
let baselineScore = computeLocalScore(process.cwd(), targetAgent);
|
|
6697
|
-
console.log(
|
|
6872
|
+
console.log(chalk11.dim("\n Current setup score:"));
|
|
6698
6873
|
displayScoreSummary(baselineScore);
|
|
6699
6874
|
if (options.verbose) {
|
|
6700
6875
|
for (const c of baselineScore.checks) {
|
|
@@ -6723,29 +6898,29 @@ async function initCommand(options) {
|
|
|
6723
6898
|
const failingCount = baselineScore.checks.filter((c) => !c.passed).length;
|
|
6724
6899
|
if (hasExistingConfig && baselineScore.score === 100) {
|
|
6725
6900
|
trackInitScoreComputed(baselineScore.score, passingCount, failingCount, true);
|
|
6726
|
-
console.log(
|
|
6727
|
-
console.log(
|
|
6901
|
+
console.log(chalk11.bold.green(" Your setup is already optimal \u2014 nothing to change.\n"));
|
|
6902
|
+
console.log(chalk11.dim(" Run ") + chalk11.hex("#83D1EB")("caliber init --force") + chalk11.dim(" to regenerate anyway.\n"));
|
|
6728
6903
|
if (!options.force) return;
|
|
6729
6904
|
}
|
|
6730
6905
|
const allFailingChecks = baselineScore.checks.filter((c) => !c.passed && c.maxPoints > 0);
|
|
6731
6906
|
const llmFixableChecks = allFailingChecks.filter((c) => !NON_LLM_CHECKS.has(c.id));
|
|
6732
6907
|
trackInitScoreComputed(baselineScore.score, passingCount, failingCount, false);
|
|
6733
6908
|
if (hasExistingConfig && llmFixableChecks.length === 0 && allFailingChecks.length > 0 && !options.force) {
|
|
6734
|
-
console.log(
|
|
6735
|
-
console.log(
|
|
6909
|
+
console.log(chalk11.bold.green("\n Your config is fully optimized for LLM generation.\n"));
|
|
6910
|
+
console.log(chalk11.dim(" Remaining items need CLI actions:\n"));
|
|
6736
6911
|
for (const check of allFailingChecks) {
|
|
6737
|
-
console.log(
|
|
6912
|
+
console.log(chalk11.dim(` \u2022 ${check.name}`));
|
|
6738
6913
|
if (check.suggestion) {
|
|
6739
|
-
console.log(` ${
|
|
6914
|
+
console.log(` ${chalk11.hex("#83D1EB")(check.suggestion)}`);
|
|
6740
6915
|
}
|
|
6741
6916
|
}
|
|
6742
6917
|
console.log("");
|
|
6743
|
-
console.log(
|
|
6918
|
+
console.log(chalk11.dim(" Run ") + chalk11.hex("#83D1EB")("caliber init --force") + chalk11.dim(" to regenerate anyway.\n"));
|
|
6744
6919
|
return;
|
|
6745
6920
|
}
|
|
6746
6921
|
console.log(title.bold(" Step 2/4 \u2014 Engine\n"));
|
|
6747
6922
|
const genModelInfo = fastModel ? ` Using ${displayModel} for docs, ${fastModel} for skills` : ` Using ${displayModel}`;
|
|
6748
|
-
console.log(
|
|
6923
|
+
console.log(chalk11.dim(genModelInfo + "\n"));
|
|
6749
6924
|
if (report) report.markStep("Generation");
|
|
6750
6925
|
trackInitGenerationStarted(false);
|
|
6751
6926
|
const genStartTime = Date.now();
|
|
@@ -6760,6 +6935,7 @@ async function initCommand(options) {
|
|
|
6760
6935
|
const TASK_SKILLS_GEN = display.add("Generating skills");
|
|
6761
6936
|
const TASK_SKILLS_SEARCH = wantsSkills ? display.add("Searching community skills") : -1;
|
|
6762
6937
|
display.start();
|
|
6938
|
+
display.enableWaitingContent();
|
|
6763
6939
|
try {
|
|
6764
6940
|
display.update(TASK_STACK, "running");
|
|
6765
6941
|
fingerprint = await collectFingerprint(process.cwd());
|
|
@@ -6869,7 +7045,7 @@ async function initCommand(options) {
|
|
|
6869
7045
|
} catch (err) {
|
|
6870
7046
|
display.stop();
|
|
6871
7047
|
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
6872
|
-
console.log(
|
|
7048
|
+
console.log(chalk11.red(`
|
|
6873
7049
|
Engine failed: ${msg}
|
|
6874
7050
|
`));
|
|
6875
7051
|
writeErrorLog(config, void 0, msg, "exception");
|
|
@@ -6881,15 +7057,15 @@ async function initCommand(options) {
|
|
|
6881
7057
|
const mins = Math.floor(elapsedMs / 6e4);
|
|
6882
7058
|
const secs = Math.floor(elapsedMs % 6e4 / 1e3);
|
|
6883
7059
|
const timeStr = mins > 0 ? `${mins}m ${secs}s` : `${secs}s`;
|
|
6884
|
-
console.log(
|
|
7060
|
+
console.log(chalk11.dim(`
|
|
6885
7061
|
Done in ${timeStr}
|
|
6886
7062
|
`));
|
|
6887
7063
|
if (!generatedSetup) {
|
|
6888
|
-
console.log(
|
|
7064
|
+
console.log(chalk11.red(" Failed to generate setup."));
|
|
6889
7065
|
writeErrorLog(config, rawOutput, void 0, genStopReason);
|
|
6890
7066
|
if (rawOutput) {
|
|
6891
|
-
console.log(
|
|
6892
|
-
console.log(
|
|
7067
|
+
console.log(chalk11.dim("\nRaw LLM output (JSON parse failed):"));
|
|
7068
|
+
console.log(chalk11.dim(rawOutput.slice(0, 500)));
|
|
6893
7069
|
}
|
|
6894
7070
|
throw new Error("__exit__");
|
|
6895
7071
|
}
|
|
@@ -6908,9 +7084,9 @@ async function initCommand(options) {
|
|
|
6908
7084
|
const setupFiles = collectSetupFiles(generatedSetup, targetAgent);
|
|
6909
7085
|
const staged = stageFiles(setupFiles, process.cwd());
|
|
6910
7086
|
const totalChanges = staged.newFiles + staged.modifiedFiles;
|
|
6911
|
-
console.log(
|
|
7087
|
+
console.log(chalk11.dim(` ${chalk11.green(`${staged.newFiles} new`)} / ${chalk11.yellow(`${staged.modifiedFiles} modified`)} file${totalChanges !== 1 ? "s" : ""}`));
|
|
6912
7088
|
if (skillSearchResult.results.length > 0) {
|
|
6913
|
-
console.log(
|
|
7089
|
+
console.log(chalk11.dim(` ${chalk11.cyan(`${skillSearchResult.results.length}`)} community skills available to install
|
|
6914
7090
|
`));
|
|
6915
7091
|
} else {
|
|
6916
7092
|
console.log("");
|
|
@@ -6918,7 +7094,7 @@ async function initCommand(options) {
|
|
|
6918
7094
|
const hasSkillResults = skillSearchResult.results.length > 0;
|
|
6919
7095
|
let action;
|
|
6920
7096
|
if (totalChanges === 0 && !hasSkillResults) {
|
|
6921
|
-
console.log(
|
|
7097
|
+
console.log(chalk11.dim(" No changes needed \u2014 your configs are already up to date.\n"));
|
|
6922
7098
|
cleanupStaging();
|
|
6923
7099
|
action = "accept";
|
|
6924
7100
|
} else if (options.autoApprove) {
|
|
@@ -6950,12 +7126,12 @@ async function initCommand(options) {
|
|
|
6950
7126
|
trackInitRefinementRound(refinementRound, !!generatedSetup);
|
|
6951
7127
|
if (!generatedSetup) {
|
|
6952
7128
|
cleanupStaging();
|
|
6953
|
-
console.log(
|
|
7129
|
+
console.log(chalk11.dim("Refinement cancelled. No files were modified."));
|
|
6954
7130
|
return;
|
|
6955
7131
|
}
|
|
6956
7132
|
const updatedFiles = collectSetupFiles(generatedSetup, targetAgent);
|
|
6957
7133
|
const restaged = stageFiles(updatedFiles, process.cwd());
|
|
6958
|
-
console.log(
|
|
7134
|
+
console.log(chalk11.dim(` ${chalk11.green(`${restaged.newFiles} new`)} / ${chalk11.yellow(`${restaged.modifiedFiles} modified`)} file${restaged.newFiles + restaged.modifiedFiles !== 1 ? "s" : ""}
|
|
6959
7135
|
`));
|
|
6960
7136
|
printSetupSummary(generatedSetup);
|
|
6961
7137
|
await openReview("terminal", restaged.stagedFiles);
|
|
@@ -6964,12 +7140,12 @@ async function initCommand(options) {
|
|
|
6964
7140
|
}
|
|
6965
7141
|
cleanupStaging();
|
|
6966
7142
|
if (action === "decline") {
|
|
6967
|
-
console.log(
|
|
7143
|
+
console.log(chalk11.dim("Setup declined. No files were modified."));
|
|
6968
7144
|
return;
|
|
6969
7145
|
}
|
|
6970
7146
|
console.log(title.bold("\n Step 4/4 \u2014 Finalize\n"));
|
|
6971
7147
|
if (options.dryRun) {
|
|
6972
|
-
console.log(
|
|
7148
|
+
console.log(chalk11.yellow("\n[Dry run] Would write the following files:"));
|
|
6973
7149
|
console.log(JSON.stringify(generatedSetup, null, 2));
|
|
6974
7150
|
return;
|
|
6975
7151
|
}
|
|
@@ -6998,23 +7174,23 @@ ${agentRefs.join(" ")}
|
|
|
6998
7174
|
0,
|
|
6999
7175
|
result.deleted.length
|
|
7000
7176
|
);
|
|
7001
|
-
console.log(
|
|
7177
|
+
console.log(chalk11.bold("\nFiles created/updated:"));
|
|
7002
7178
|
for (const file of result.written) {
|
|
7003
|
-
console.log(` ${
|
|
7179
|
+
console.log(` ${chalk11.green("\u2713")} ${file}`);
|
|
7004
7180
|
}
|
|
7005
7181
|
if (result.deleted.length > 0) {
|
|
7006
|
-
console.log(
|
|
7182
|
+
console.log(chalk11.bold("\nFiles removed:"));
|
|
7007
7183
|
for (const file of result.deleted) {
|
|
7008
|
-
console.log(` ${
|
|
7184
|
+
console.log(` ${chalk11.red("\u2717")} ${file}`);
|
|
7009
7185
|
}
|
|
7010
7186
|
}
|
|
7011
7187
|
if (result.backupDir) {
|
|
7012
|
-
console.log(
|
|
7188
|
+
console.log(chalk11.dim(`
|
|
7013
7189
|
Backups saved to ${result.backupDir}`));
|
|
7014
7190
|
}
|
|
7015
7191
|
} catch (err) {
|
|
7016
7192
|
writeSpinner.fail("Failed to write files");
|
|
7017
|
-
console.error(
|
|
7193
|
+
console.error(chalk11.red(err instanceof Error ? err.message : "Unknown error"));
|
|
7018
7194
|
throw new Error("__exit__");
|
|
7019
7195
|
}
|
|
7020
7196
|
if (fingerprint) ensurePermissions(fingerprint);
|
|
@@ -7028,15 +7204,15 @@ ${agentRefs.join(" ")}
|
|
|
7028
7204
|
if (afterScore.score < baselineScore.score) {
|
|
7029
7205
|
trackInitScoreRegression(baselineScore.score, afterScore.score);
|
|
7030
7206
|
console.log("");
|
|
7031
|
-
console.log(
|
|
7207
|
+
console.log(chalk11.yellow(` Score would drop from ${baselineScore.score} to ${afterScore.score} \u2014 reverting changes.`));
|
|
7032
7208
|
try {
|
|
7033
7209
|
const { restored, removed } = undoSetup();
|
|
7034
7210
|
if (restored.length > 0 || removed.length > 0) {
|
|
7035
|
-
console.log(
|
|
7211
|
+
console.log(chalk11.dim(` Reverted ${restored.length + removed.length} file${restored.length + removed.length === 1 ? "" : "s"} from backup.`));
|
|
7036
7212
|
}
|
|
7037
7213
|
} catch {
|
|
7038
7214
|
}
|
|
7039
|
-
console.log(
|
|
7215
|
+
console.log(chalk11.dim(" Run ") + chalk11.hex("#83D1EB")("caliber init --force") + chalk11.dim(" to override.\n"));
|
|
7040
7216
|
return;
|
|
7041
7217
|
}
|
|
7042
7218
|
if (report) {
|
|
@@ -7055,7 +7231,7 @@ ${agentRefs.join(" ")}
|
|
|
7055
7231
|
}
|
|
7056
7232
|
}
|
|
7057
7233
|
if (skillSearchResult.results.length > 0 && !options.autoApprove) {
|
|
7058
|
-
console.log(
|
|
7234
|
+
console.log(chalk11.dim(" Community skills matched to your project:\n"));
|
|
7059
7235
|
const selected = await interactiveSelect(skillSearchResult.results);
|
|
7060
7236
|
if (selected?.length) {
|
|
7061
7237
|
await installSkills(selected, targetAgent, skillSearchResult.contentMap);
|
|
@@ -7074,37 +7250,37 @@ ${agentRefs.join(" ")}
|
|
|
7074
7250
|
if (hookChoice === "claude" || hookChoice === "both") {
|
|
7075
7251
|
const hookResult = installHook();
|
|
7076
7252
|
if (hookResult.installed) {
|
|
7077
|
-
console.log(` ${
|
|
7078
|
-
console.log(
|
|
7253
|
+
console.log(` ${chalk11.green("\u2713")} Claude Code hook installed \u2014 docs update on session end`);
|
|
7254
|
+
console.log(chalk11.dim(" Run ") + chalk11.hex("#83D1EB")("caliber hooks --remove") + chalk11.dim(" to disable"));
|
|
7079
7255
|
} else if (hookResult.alreadyInstalled) {
|
|
7080
|
-
console.log(
|
|
7256
|
+
console.log(chalk11.dim(" Claude Code hook already installed"));
|
|
7081
7257
|
}
|
|
7082
7258
|
const learnResult = installLearningHooks();
|
|
7083
7259
|
if (learnResult.installed) {
|
|
7084
|
-
console.log(` ${
|
|
7085
|
-
console.log(
|
|
7260
|
+
console.log(` ${chalk11.green("\u2713")} Learning hooks installed \u2014 session insights captured automatically`);
|
|
7261
|
+
console.log(chalk11.dim(" Run ") + chalk11.hex("#83D1EB")("caliber learn remove") + chalk11.dim(" to disable"));
|
|
7086
7262
|
} else if (learnResult.alreadyInstalled) {
|
|
7087
|
-
console.log(
|
|
7263
|
+
console.log(chalk11.dim(" Learning hooks already installed"));
|
|
7088
7264
|
}
|
|
7089
7265
|
}
|
|
7090
7266
|
if (hookChoice === "precommit" || hookChoice === "both") {
|
|
7091
7267
|
const precommitResult = installPreCommitHook();
|
|
7092
7268
|
if (precommitResult.installed) {
|
|
7093
|
-
console.log(` ${
|
|
7094
|
-
console.log(
|
|
7269
|
+
console.log(` ${chalk11.green("\u2713")} Pre-commit hook installed \u2014 docs refresh before each commit`);
|
|
7270
|
+
console.log(chalk11.dim(" Run ") + chalk11.hex("#83D1EB")("caliber hooks --remove") + chalk11.dim(" to disable"));
|
|
7095
7271
|
} else if (precommitResult.alreadyInstalled) {
|
|
7096
|
-
console.log(
|
|
7272
|
+
console.log(chalk11.dim(" Pre-commit hook already installed"));
|
|
7097
7273
|
} else {
|
|
7098
|
-
console.log(
|
|
7274
|
+
console.log(chalk11.yellow(" Could not install pre-commit hook (not a git repository?)"));
|
|
7099
7275
|
}
|
|
7100
7276
|
}
|
|
7101
7277
|
if (hookChoice === "skip") {
|
|
7102
|
-
console.log(
|
|
7278
|
+
console.log(chalk11.dim(" Skipped auto-sync hooks. Run ") + chalk11.hex("#83D1EB")("caliber hooks --install") + chalk11.dim(" later to enable."));
|
|
7103
7279
|
}
|
|
7104
|
-
console.log(
|
|
7105
|
-
console.log(
|
|
7106
|
-
console.log(
|
|
7107
|
-
console.log(
|
|
7280
|
+
console.log(chalk11.bold.green("\n Setup complete!"));
|
|
7281
|
+
console.log(chalk11.dim(" Your AI agents now understand your project's architecture, build commands,"));
|
|
7282
|
+
console.log(chalk11.dim(" testing patterns, and conventions. All changes are backed up automatically.\n"));
|
|
7283
|
+
console.log(chalk11.bold(" Next steps:\n"));
|
|
7108
7284
|
console.log(` ${title("caliber score")} See your full config breakdown`);
|
|
7109
7285
|
console.log(` ${title("caliber refresh")} Update docs after code changes`);
|
|
7110
7286
|
console.log(` ${title("caliber hooks")} Toggle auto-refresh hooks`);
|
|
@@ -7118,7 +7294,7 @@ ${agentRefs.join(" ")}
|
|
|
7118
7294
|
report.markStep("Finished");
|
|
7119
7295
|
const reportPath = path20.join(process.cwd(), ".caliber", "debug-report.md");
|
|
7120
7296
|
report.write(reportPath);
|
|
7121
|
-
console.log(
|
|
7297
|
+
console.log(chalk11.dim(` Debug report written to ${path20.relative(process.cwd(), reportPath)}
|
|
7122
7298
|
`));
|
|
7123
7299
|
}
|
|
7124
7300
|
}
|
|
@@ -7133,9 +7309,9 @@ async function refineLoop(currentSetup, _targetAgent, sessionHistory) {
|
|
|
7133
7309
|
}
|
|
7134
7310
|
const isValid = await classifyRefineIntent(message);
|
|
7135
7311
|
if (!isValid) {
|
|
7136
|
-
console.log(
|
|
7137
|
-
console.log(
|
|
7138
|
-
console.log(
|
|
7312
|
+
console.log(chalk11.dim(" This doesn't look like a config change request."));
|
|
7313
|
+
console.log(chalk11.dim(" Describe what to add, remove, or modify in your configs."));
|
|
7314
|
+
console.log(chalk11.dim(' Type "done" to accept the current setup.\n'));
|
|
7139
7315
|
continue;
|
|
7140
7316
|
}
|
|
7141
7317
|
const refineSpinner = ora2("Refining setup...").start();
|
|
@@ -7156,10 +7332,10 @@ async function refineLoop(currentSetup, _targetAgent, sessionHistory) {
|
|
|
7156
7332
|
});
|
|
7157
7333
|
refineSpinner.succeed("Setup updated");
|
|
7158
7334
|
printSetupSummary(refined);
|
|
7159
|
-
console.log(
|
|
7335
|
+
console.log(chalk11.dim('Type "done" to accept, or describe more changes.'));
|
|
7160
7336
|
} else {
|
|
7161
7337
|
refineSpinner.fail("Refinement failed \u2014 could not parse AI response.");
|
|
7162
|
-
console.log(
|
|
7338
|
+
console.log(chalk11.dim('Try rephrasing your request, or type "done" to keep the current setup.'));
|
|
7163
7339
|
}
|
|
7164
7340
|
}
|
|
7165
7341
|
}
|
|
@@ -7274,26 +7450,26 @@ function printSetupSummary(setup) {
|
|
|
7274
7450
|
const fileDescriptions = setup.fileDescriptions;
|
|
7275
7451
|
const deletions = setup.deletions;
|
|
7276
7452
|
console.log("");
|
|
7277
|
-
console.log(
|
|
7453
|
+
console.log(chalk11.bold(" Your tailored setup:\n"));
|
|
7278
7454
|
const getDescription = (filePath) => {
|
|
7279
7455
|
return fileDescriptions?.[filePath];
|
|
7280
7456
|
};
|
|
7281
7457
|
if (claude) {
|
|
7282
7458
|
if (claude.claudeMd) {
|
|
7283
|
-
const icon = fs25.existsSync("CLAUDE.md") ?
|
|
7459
|
+
const icon = fs25.existsSync("CLAUDE.md") ? chalk11.yellow("~") : chalk11.green("+");
|
|
7284
7460
|
const desc = getDescription("CLAUDE.md");
|
|
7285
|
-
console.log(` ${icon} ${
|
|
7286
|
-
if (desc) console.log(
|
|
7461
|
+
console.log(` ${icon} ${chalk11.bold("CLAUDE.md")}`);
|
|
7462
|
+
if (desc) console.log(chalk11.dim(` ${desc}`));
|
|
7287
7463
|
console.log("");
|
|
7288
7464
|
}
|
|
7289
7465
|
const skills = claude.skills;
|
|
7290
7466
|
if (Array.isArray(skills) && skills.length > 0) {
|
|
7291
7467
|
for (const skill of skills) {
|
|
7292
7468
|
const skillPath = `.claude/skills/${skill.name}/SKILL.md`;
|
|
7293
|
-
const icon = fs25.existsSync(skillPath) ?
|
|
7469
|
+
const icon = fs25.existsSync(skillPath) ? chalk11.yellow("~") : chalk11.green("+");
|
|
7294
7470
|
const desc = getDescription(skillPath);
|
|
7295
|
-
console.log(` ${icon} ${
|
|
7296
|
-
console.log(
|
|
7471
|
+
console.log(` ${icon} ${chalk11.bold(skillPath)}`);
|
|
7472
|
+
console.log(chalk11.dim(` ${desc || skill.description || skill.name}`));
|
|
7297
7473
|
console.log("");
|
|
7298
7474
|
}
|
|
7299
7475
|
}
|
|
@@ -7301,40 +7477,40 @@ function printSetupSummary(setup) {
|
|
|
7301
7477
|
const codex = setup.codex;
|
|
7302
7478
|
if (codex) {
|
|
7303
7479
|
if (codex.agentsMd) {
|
|
7304
|
-
const icon = fs25.existsSync("AGENTS.md") ?
|
|
7480
|
+
const icon = fs25.existsSync("AGENTS.md") ? chalk11.yellow("~") : chalk11.green("+");
|
|
7305
7481
|
const desc = getDescription("AGENTS.md");
|
|
7306
|
-
console.log(` ${icon} ${
|
|
7307
|
-
if (desc) console.log(
|
|
7482
|
+
console.log(` ${icon} ${chalk11.bold("AGENTS.md")}`);
|
|
7483
|
+
if (desc) console.log(chalk11.dim(` ${desc}`));
|
|
7308
7484
|
console.log("");
|
|
7309
7485
|
}
|
|
7310
7486
|
const codexSkills = codex.skills;
|
|
7311
7487
|
if (Array.isArray(codexSkills) && codexSkills.length > 0) {
|
|
7312
7488
|
for (const skill of codexSkills) {
|
|
7313
7489
|
const skillPath = `.agents/skills/${skill.name}/SKILL.md`;
|
|
7314
|
-
const icon = fs25.existsSync(skillPath) ?
|
|
7490
|
+
const icon = fs25.existsSync(skillPath) ? chalk11.yellow("~") : chalk11.green("+");
|
|
7315
7491
|
const desc = getDescription(skillPath);
|
|
7316
|
-
console.log(` ${icon} ${
|
|
7317
|
-
console.log(
|
|
7492
|
+
console.log(` ${icon} ${chalk11.bold(skillPath)}`);
|
|
7493
|
+
console.log(chalk11.dim(` ${desc || skill.description || skill.name}`));
|
|
7318
7494
|
console.log("");
|
|
7319
7495
|
}
|
|
7320
7496
|
}
|
|
7321
7497
|
}
|
|
7322
7498
|
if (cursor) {
|
|
7323
7499
|
if (cursor.cursorrules) {
|
|
7324
|
-
const icon = fs25.existsSync(".cursorrules") ?
|
|
7500
|
+
const icon = fs25.existsSync(".cursorrules") ? chalk11.yellow("~") : chalk11.green("+");
|
|
7325
7501
|
const desc = getDescription(".cursorrules");
|
|
7326
|
-
console.log(` ${icon} ${
|
|
7327
|
-
if (desc) console.log(
|
|
7502
|
+
console.log(` ${icon} ${chalk11.bold(".cursorrules")}`);
|
|
7503
|
+
if (desc) console.log(chalk11.dim(` ${desc}`));
|
|
7328
7504
|
console.log("");
|
|
7329
7505
|
}
|
|
7330
7506
|
const cursorSkills = cursor.skills;
|
|
7331
7507
|
if (Array.isArray(cursorSkills) && cursorSkills.length > 0) {
|
|
7332
7508
|
for (const skill of cursorSkills) {
|
|
7333
7509
|
const skillPath = `.cursor/skills/${skill.name}/SKILL.md`;
|
|
7334
|
-
const icon = fs25.existsSync(skillPath) ?
|
|
7510
|
+
const icon = fs25.existsSync(skillPath) ? chalk11.yellow("~") : chalk11.green("+");
|
|
7335
7511
|
const desc = getDescription(skillPath);
|
|
7336
|
-
console.log(` ${icon} ${
|
|
7337
|
-
console.log(
|
|
7512
|
+
console.log(` ${icon} ${chalk11.bold(skillPath)}`);
|
|
7513
|
+
console.log(chalk11.dim(` ${desc || skill.description || skill.name}`));
|
|
7338
7514
|
console.log("");
|
|
7339
7515
|
}
|
|
7340
7516
|
}
|
|
@@ -7342,14 +7518,14 @@ function printSetupSummary(setup) {
|
|
|
7342
7518
|
if (Array.isArray(rules) && rules.length > 0) {
|
|
7343
7519
|
for (const rule of rules) {
|
|
7344
7520
|
const rulePath = `.cursor/rules/${rule.filename}`;
|
|
7345
|
-
const icon = fs25.existsSync(rulePath) ?
|
|
7521
|
+
const icon = fs25.existsSync(rulePath) ? chalk11.yellow("~") : chalk11.green("+");
|
|
7346
7522
|
const desc = getDescription(rulePath);
|
|
7347
|
-
console.log(` ${icon} ${
|
|
7523
|
+
console.log(` ${icon} ${chalk11.bold(rulePath)}`);
|
|
7348
7524
|
if (desc) {
|
|
7349
|
-
console.log(
|
|
7525
|
+
console.log(chalk11.dim(` ${desc}`));
|
|
7350
7526
|
} else {
|
|
7351
7527
|
const firstLine = rule.content.split("\n").filter((l) => l.trim() && !l.trim().startsWith("#"))[0];
|
|
7352
|
-
if (firstLine) console.log(
|
|
7528
|
+
if (firstLine) console.log(chalk11.dim(` ${firstLine.trim().slice(0, 80)}`));
|
|
7353
7529
|
}
|
|
7354
7530
|
console.log("");
|
|
7355
7531
|
}
|
|
@@ -7357,12 +7533,12 @@ function printSetupSummary(setup) {
|
|
|
7357
7533
|
}
|
|
7358
7534
|
if (Array.isArray(deletions) && deletions.length > 0) {
|
|
7359
7535
|
for (const del of deletions) {
|
|
7360
|
-
console.log(` ${
|
|
7361
|
-
console.log(
|
|
7536
|
+
console.log(` ${chalk11.red("-")} ${chalk11.bold(del.filePath)}`);
|
|
7537
|
+
console.log(chalk11.dim(` ${del.reason}`));
|
|
7362
7538
|
console.log("");
|
|
7363
7539
|
}
|
|
7364
7540
|
}
|
|
7365
|
-
console.log(` ${
|
|
7541
|
+
console.log(` ${chalk11.green("+")} ${chalk11.dim("new")} ${chalk11.yellow("~")} ${chalk11.dim("modified")} ${chalk11.red("-")} ${chalk11.dim("removed")}`);
|
|
7366
7542
|
console.log("");
|
|
7367
7543
|
}
|
|
7368
7544
|
function derivePermissions(fingerprint) {
|
|
@@ -7422,20 +7598,20 @@ function ensurePermissions(fingerprint) {
|
|
|
7422
7598
|
function displayTokenUsage() {
|
|
7423
7599
|
const summary = getUsageSummary();
|
|
7424
7600
|
if (summary.length === 0) {
|
|
7425
|
-
console.log(
|
|
7601
|
+
console.log(chalk11.dim(" Token tracking not available for this provider.\n"));
|
|
7426
7602
|
return;
|
|
7427
7603
|
}
|
|
7428
|
-
console.log(
|
|
7604
|
+
console.log(chalk11.bold(" Token usage:\n"));
|
|
7429
7605
|
let totalIn = 0;
|
|
7430
7606
|
let totalOut = 0;
|
|
7431
7607
|
for (const m of summary) {
|
|
7432
7608
|
totalIn += m.inputTokens;
|
|
7433
7609
|
totalOut += m.outputTokens;
|
|
7434
|
-
const cacheInfo = m.cacheReadTokens > 0 || m.cacheWriteTokens > 0 ?
|
|
7435
|
-
console.log(` ${
|
|
7610
|
+
const cacheInfo = m.cacheReadTokens > 0 || m.cacheWriteTokens > 0 ? chalk11.dim(` (cache: ${m.cacheReadTokens.toLocaleString()} read, ${m.cacheWriteTokens.toLocaleString()} write)`) : "";
|
|
7611
|
+
console.log(` ${chalk11.dim(m.model)}: ${m.inputTokens.toLocaleString()} in / ${m.outputTokens.toLocaleString()} out (${m.calls} call${m.calls === 1 ? "" : "s"})${cacheInfo}`);
|
|
7436
7612
|
}
|
|
7437
7613
|
if (summary.length > 1) {
|
|
7438
|
-
console.log(` ${
|
|
7614
|
+
console.log(` ${chalk11.dim("Total")}: ${totalIn.toLocaleString()} in / ${totalOut.toLocaleString()} out`);
|
|
7439
7615
|
}
|
|
7440
7616
|
console.log("");
|
|
7441
7617
|
}
|
|
@@ -7456,14 +7632,14 @@ function writeErrorLog(config, rawOutput, error, stopReason) {
|
|
|
7456
7632
|
lines.push("## Raw LLM Output", "```", rawOutput || "(empty)", "```");
|
|
7457
7633
|
fs25.mkdirSync(path20.join(process.cwd(), ".caliber"), { recursive: true });
|
|
7458
7634
|
fs25.writeFileSync(logPath, lines.join("\n"));
|
|
7459
|
-
console.log(
|
|
7635
|
+
console.log(chalk11.dim(`
|
|
7460
7636
|
Error log written to .caliber/error-log.md`));
|
|
7461
7637
|
} catch {
|
|
7462
7638
|
}
|
|
7463
7639
|
}
|
|
7464
7640
|
|
|
7465
7641
|
// src/commands/undo.ts
|
|
7466
|
-
import
|
|
7642
|
+
import chalk12 from "chalk";
|
|
7467
7643
|
import ora3 from "ora";
|
|
7468
7644
|
function undoCommand() {
|
|
7469
7645
|
const spinner = ora3("Reverting setup...").start();
|
|
@@ -7476,26 +7652,26 @@ function undoCommand() {
|
|
|
7476
7652
|
trackUndoExecuted();
|
|
7477
7653
|
spinner.succeed("Setup reverted successfully.\n");
|
|
7478
7654
|
if (restored.length > 0) {
|
|
7479
|
-
console.log(
|
|
7655
|
+
console.log(chalk12.cyan(" Restored from backup:"));
|
|
7480
7656
|
for (const file of restored) {
|
|
7481
|
-
console.log(` ${
|
|
7657
|
+
console.log(` ${chalk12.green("\u21A9")} ${file}`);
|
|
7482
7658
|
}
|
|
7483
7659
|
}
|
|
7484
7660
|
if (removed.length > 0) {
|
|
7485
|
-
console.log(
|
|
7661
|
+
console.log(chalk12.cyan(" Removed:"));
|
|
7486
7662
|
for (const file of removed) {
|
|
7487
|
-
console.log(` ${
|
|
7663
|
+
console.log(` ${chalk12.red("\u2717")} ${file}`);
|
|
7488
7664
|
}
|
|
7489
7665
|
}
|
|
7490
7666
|
console.log("");
|
|
7491
7667
|
} catch (err) {
|
|
7492
|
-
spinner.fail(
|
|
7668
|
+
spinner.fail(chalk12.red(err instanceof Error ? err.message : "Undo failed"));
|
|
7493
7669
|
throw new Error("__exit__");
|
|
7494
7670
|
}
|
|
7495
7671
|
}
|
|
7496
7672
|
|
|
7497
7673
|
// src/commands/status.ts
|
|
7498
|
-
import
|
|
7674
|
+
import chalk13 from "chalk";
|
|
7499
7675
|
import fs26 from "fs";
|
|
7500
7676
|
init_config();
|
|
7501
7677
|
async function statusCommand(options) {
|
|
@@ -7510,40 +7686,40 @@ async function statusCommand(options) {
|
|
|
7510
7686
|
}, null, 2));
|
|
7511
7687
|
return;
|
|
7512
7688
|
}
|
|
7513
|
-
console.log(
|
|
7689
|
+
console.log(chalk13.bold("\nCaliber Status\n"));
|
|
7514
7690
|
if (config) {
|
|
7515
|
-
console.log(` LLM: ${
|
|
7691
|
+
console.log(` LLM: ${chalk13.green(config.provider)} (${config.model})`);
|
|
7516
7692
|
} else {
|
|
7517
|
-
console.log(` LLM: ${
|
|
7693
|
+
console.log(` LLM: ${chalk13.yellow("Not configured")} \u2014 run ${chalk13.hex("#83D1EB")("caliber config")}`);
|
|
7518
7694
|
}
|
|
7519
7695
|
if (!manifest) {
|
|
7520
|
-
console.log(` Setup: ${
|
|
7521
|
-
console.log(
|
|
7696
|
+
console.log(` Setup: ${chalk13.dim("No setup applied")}`);
|
|
7697
|
+
console.log(chalk13.dim("\n Run ") + chalk13.hex("#83D1EB")("caliber init") + chalk13.dim(" to get started.\n"));
|
|
7522
7698
|
return;
|
|
7523
7699
|
}
|
|
7524
|
-
console.log(` Files managed: ${
|
|
7700
|
+
console.log(` Files managed: ${chalk13.cyan(manifest.entries.length.toString())}`);
|
|
7525
7701
|
for (const entry of manifest.entries) {
|
|
7526
7702
|
const exists = fs26.existsSync(entry.path);
|
|
7527
|
-
const icon = exists ?
|
|
7703
|
+
const icon = exists ? chalk13.green("\u2713") : chalk13.red("\u2717");
|
|
7528
7704
|
console.log(` ${icon} ${entry.path} (${entry.action})`);
|
|
7529
7705
|
}
|
|
7530
7706
|
console.log("");
|
|
7531
7707
|
}
|
|
7532
7708
|
|
|
7533
7709
|
// src/commands/regenerate.ts
|
|
7534
|
-
import
|
|
7710
|
+
import chalk14 from "chalk";
|
|
7535
7711
|
import ora4 from "ora";
|
|
7536
7712
|
import select6 from "@inquirer/select";
|
|
7537
7713
|
init_config();
|
|
7538
7714
|
async function regenerateCommand(options) {
|
|
7539
7715
|
const config = loadConfig();
|
|
7540
7716
|
if (!config) {
|
|
7541
|
-
console.log(
|
|
7717
|
+
console.log(chalk14.red("No LLM provider configured. Run ") + chalk14.hex("#83D1EB")("caliber config") + chalk14.red(" first."));
|
|
7542
7718
|
throw new Error("__exit__");
|
|
7543
7719
|
}
|
|
7544
7720
|
const manifest = readManifest();
|
|
7545
7721
|
if (!manifest) {
|
|
7546
|
-
console.log(
|
|
7722
|
+
console.log(chalk14.yellow("No existing setup found. Run ") + chalk14.hex("#83D1EB")("caliber init") + chalk14.yellow(" first."));
|
|
7547
7723
|
throw new Error("__exit__");
|
|
7548
7724
|
}
|
|
7549
7725
|
const targetAgent = readState()?.targetAgent ?? ["claude", "cursor"];
|
|
@@ -7554,7 +7730,7 @@ async function regenerateCommand(options) {
|
|
|
7554
7730
|
const baselineScore = computeLocalScore(process.cwd(), targetAgent);
|
|
7555
7731
|
displayScoreSummary(baselineScore);
|
|
7556
7732
|
if (baselineScore.score === 100) {
|
|
7557
|
-
console.log(
|
|
7733
|
+
console.log(chalk14.green(" Your setup is already at 100/100 \u2014 nothing to regenerate.\n"));
|
|
7558
7734
|
return;
|
|
7559
7735
|
}
|
|
7560
7736
|
const genSpinner = ora4("Regenerating setup...").start();
|
|
@@ -7595,18 +7771,18 @@ async function regenerateCommand(options) {
|
|
|
7595
7771
|
const setupFiles = collectSetupFiles(generatedSetup, targetAgent);
|
|
7596
7772
|
const staged = stageFiles(setupFiles, process.cwd());
|
|
7597
7773
|
const totalChanges = staged.newFiles + staged.modifiedFiles;
|
|
7598
|
-
console.log(
|
|
7599
|
-
${
|
|
7774
|
+
console.log(chalk14.dim(`
|
|
7775
|
+
${chalk14.green(`${staged.newFiles} new`)} / ${chalk14.yellow(`${staged.modifiedFiles} modified`)} file${totalChanges !== 1 ? "s" : ""}
|
|
7600
7776
|
`));
|
|
7601
7777
|
if (totalChanges === 0) {
|
|
7602
|
-
console.log(
|
|
7778
|
+
console.log(chalk14.dim(" No changes needed \u2014 your configs are already up to date.\n"));
|
|
7603
7779
|
cleanupStaging();
|
|
7604
7780
|
return;
|
|
7605
7781
|
}
|
|
7606
7782
|
if (options.dryRun) {
|
|
7607
|
-
console.log(
|
|
7783
|
+
console.log(chalk14.yellow("[Dry run] Would write:"));
|
|
7608
7784
|
for (const f of staged.stagedFiles) {
|
|
7609
|
-
console.log(` ${f.isNew ?
|
|
7785
|
+
console.log(` ${f.isNew ? chalk14.green("+") : chalk14.yellow("~")} ${f.relativePath}`);
|
|
7610
7786
|
}
|
|
7611
7787
|
cleanupStaging();
|
|
7612
7788
|
return;
|
|
@@ -7625,7 +7801,7 @@ async function regenerateCommand(options) {
|
|
|
7625
7801
|
});
|
|
7626
7802
|
cleanupStaging();
|
|
7627
7803
|
if (action === "decline") {
|
|
7628
|
-
console.log(
|
|
7804
|
+
console.log(chalk14.dim("Regeneration cancelled. No files were modified."));
|
|
7629
7805
|
return;
|
|
7630
7806
|
}
|
|
7631
7807
|
const writeSpinner = ora4("Writing config files...").start();
|
|
@@ -7633,20 +7809,20 @@ async function regenerateCommand(options) {
|
|
|
7633
7809
|
const result = writeSetup(generatedSetup);
|
|
7634
7810
|
writeSpinner.succeed("Config files written");
|
|
7635
7811
|
for (const file of result.written) {
|
|
7636
|
-
console.log(` ${
|
|
7812
|
+
console.log(` ${chalk14.green("\u2713")} ${file}`);
|
|
7637
7813
|
}
|
|
7638
7814
|
if (result.deleted.length > 0) {
|
|
7639
7815
|
for (const file of result.deleted) {
|
|
7640
|
-
console.log(` ${
|
|
7816
|
+
console.log(` ${chalk14.red("\u2717")} ${file}`);
|
|
7641
7817
|
}
|
|
7642
7818
|
}
|
|
7643
7819
|
if (result.backupDir) {
|
|
7644
|
-
console.log(
|
|
7820
|
+
console.log(chalk14.dim(`
|
|
7645
7821
|
Backups saved to ${result.backupDir}`));
|
|
7646
7822
|
}
|
|
7647
7823
|
} catch (err) {
|
|
7648
7824
|
writeSpinner.fail("Failed to write files");
|
|
7649
|
-
console.error(
|
|
7825
|
+
console.error(chalk14.red(err instanceof Error ? err.message : "Unknown error"));
|
|
7650
7826
|
throw new Error("__exit__");
|
|
7651
7827
|
}
|
|
7652
7828
|
const sha = getCurrentHeadSha();
|
|
@@ -7658,25 +7834,25 @@ async function regenerateCommand(options) {
|
|
|
7658
7834
|
const afterScore = computeLocalScore(process.cwd(), targetAgent);
|
|
7659
7835
|
if (afterScore.score < baselineScore.score) {
|
|
7660
7836
|
console.log("");
|
|
7661
|
-
console.log(
|
|
7837
|
+
console.log(chalk14.yellow(` Score would drop from ${baselineScore.score} to ${afterScore.score} \u2014 reverting changes.`));
|
|
7662
7838
|
try {
|
|
7663
7839
|
const { restored, removed } = undoSetup();
|
|
7664
7840
|
if (restored.length > 0 || removed.length > 0) {
|
|
7665
|
-
console.log(
|
|
7841
|
+
console.log(chalk14.dim(` Reverted ${restored.length + removed.length} file${restored.length + removed.length === 1 ? "" : "s"} from backup.`));
|
|
7666
7842
|
}
|
|
7667
7843
|
} catch {
|
|
7668
7844
|
}
|
|
7669
|
-
console.log(
|
|
7845
|
+
console.log(chalk14.dim(" Run ") + chalk14.hex("#83D1EB")("caliber init --force") + chalk14.dim(" to override.\n"));
|
|
7670
7846
|
return;
|
|
7671
7847
|
}
|
|
7672
7848
|
displayScoreDelta(baselineScore, afterScore);
|
|
7673
7849
|
trackRegenerateCompleted(action, Date.now());
|
|
7674
|
-
console.log(
|
|
7675
|
-
console.log(
|
|
7850
|
+
console.log(chalk14.bold.green(" Regeneration complete!"));
|
|
7851
|
+
console.log(chalk14.dim(" Run ") + chalk14.hex("#83D1EB")("caliber undo") + chalk14.dim(" to revert changes.\n"));
|
|
7676
7852
|
}
|
|
7677
7853
|
|
|
7678
7854
|
// src/commands/score.ts
|
|
7679
|
-
import
|
|
7855
|
+
import chalk15 from "chalk";
|
|
7680
7856
|
async function scoreCommand(options) {
|
|
7681
7857
|
const dir = process.cwd();
|
|
7682
7858
|
const target = options.agent ?? readState()?.targetAgent;
|
|
@@ -7691,14 +7867,14 @@ async function scoreCommand(options) {
|
|
|
7691
7867
|
return;
|
|
7692
7868
|
}
|
|
7693
7869
|
displayScore(result);
|
|
7694
|
-
const separator =
|
|
7870
|
+
const separator = chalk15.gray(" " + "\u2500".repeat(53));
|
|
7695
7871
|
console.log(separator);
|
|
7696
7872
|
if (result.score < 40) {
|
|
7697
|
-
console.log(
|
|
7873
|
+
console.log(chalk15.gray(" Run ") + chalk15.hex("#83D1EB")("caliber init") + chalk15.gray(" to generate a complete, optimized setup."));
|
|
7698
7874
|
} else if (result.score < 70) {
|
|
7699
|
-
console.log(
|
|
7875
|
+
console.log(chalk15.gray(" Run ") + chalk15.hex("#83D1EB")("caliber init") + chalk15.gray(" to improve your setup."));
|
|
7700
7876
|
} else {
|
|
7701
|
-
console.log(
|
|
7877
|
+
console.log(chalk15.green(" Looking good!") + chalk15.gray(" Run ") + chalk15.hex("#83D1EB")("caliber regenerate") + chalk15.gray(" to rebuild from scratch."));
|
|
7702
7878
|
}
|
|
7703
7879
|
console.log("");
|
|
7704
7880
|
}
|
|
@@ -7706,7 +7882,7 @@ async function scoreCommand(options) {
|
|
|
7706
7882
|
// src/commands/refresh.ts
|
|
7707
7883
|
import fs30 from "fs";
|
|
7708
7884
|
import path24 from "path";
|
|
7709
|
-
import
|
|
7885
|
+
import chalk16 from "chalk";
|
|
7710
7886
|
import ora5 from "ora";
|
|
7711
7887
|
|
|
7712
7888
|
// src/lib/git-diff.ts
|
|
@@ -8049,7 +8225,7 @@ function discoverGitRepos(parentDir) {
|
|
|
8049
8225
|
}
|
|
8050
8226
|
async function refreshSingleRepo(repoDir, options) {
|
|
8051
8227
|
const quiet = !!options.quiet;
|
|
8052
|
-
const prefix = options.label ? `${
|
|
8228
|
+
const prefix = options.label ? `${chalk16.bold(options.label)} ` : "";
|
|
8053
8229
|
const state = readState();
|
|
8054
8230
|
const lastSha = state?.lastRefreshSha ?? null;
|
|
8055
8231
|
const diff = collectDiff(lastSha);
|
|
@@ -8058,7 +8234,7 @@ async function refreshSingleRepo(repoDir, options) {
|
|
|
8058
8234
|
if (currentSha) {
|
|
8059
8235
|
writeState({ lastRefreshSha: currentSha, lastRefreshTimestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
8060
8236
|
}
|
|
8061
|
-
log2(quiet,
|
|
8237
|
+
log2(quiet, chalk16.dim(`${prefix}No changes since last refresh.`));
|
|
8062
8238
|
return;
|
|
8063
8239
|
}
|
|
8064
8240
|
const spinner = quiet ? null : ora5(`${prefix}Analyzing changes...`).start();
|
|
@@ -8092,10 +8268,10 @@ async function refreshSingleRepo(repoDir, options) {
|
|
|
8092
8268
|
if (options.dryRun) {
|
|
8093
8269
|
spinner?.info(`${prefix}Dry run \u2014 would update:`);
|
|
8094
8270
|
for (const doc of response.docsUpdated) {
|
|
8095
|
-
console.log(` ${
|
|
8271
|
+
console.log(` ${chalk16.yellow("~")} ${doc}`);
|
|
8096
8272
|
}
|
|
8097
8273
|
if (response.changesSummary) {
|
|
8098
|
-
console.log(
|
|
8274
|
+
console.log(chalk16.dim(`
|
|
8099
8275
|
${response.changesSummary}`));
|
|
8100
8276
|
}
|
|
8101
8277
|
return;
|
|
@@ -8104,10 +8280,10 @@ async function refreshSingleRepo(repoDir, options) {
|
|
|
8104
8280
|
trackRefreshCompleted(written.length, Date.now());
|
|
8105
8281
|
spinner?.succeed(`${prefix}Updated ${written.length} doc${written.length === 1 ? "" : "s"}`);
|
|
8106
8282
|
for (const file of written) {
|
|
8107
|
-
log2(quiet, ` ${
|
|
8283
|
+
log2(quiet, ` ${chalk16.green("\u2713")} ${file}`);
|
|
8108
8284
|
}
|
|
8109
8285
|
if (response.changesSummary) {
|
|
8110
|
-
log2(quiet,
|
|
8286
|
+
log2(quiet, chalk16.dim(`
|
|
8111
8287
|
${response.changesSummary}`));
|
|
8112
8288
|
}
|
|
8113
8289
|
if (currentSha) {
|
|
@@ -8124,7 +8300,7 @@ async function refreshCommand(options) {
|
|
|
8124
8300
|
const config = loadConfig();
|
|
8125
8301
|
if (!config) {
|
|
8126
8302
|
if (quiet) return;
|
|
8127
|
-
console.log(
|
|
8303
|
+
console.log(chalk16.red("No LLM provider configured. Run ") + chalk16.hex("#83D1EB")("caliber config") + chalk16.red(" (e.g. choose Cursor) or set an API key."));
|
|
8128
8304
|
throw new Error("__exit__");
|
|
8129
8305
|
}
|
|
8130
8306
|
await validateModel({ fast: true });
|
|
@@ -8135,10 +8311,10 @@ async function refreshCommand(options) {
|
|
|
8135
8311
|
const repos = discoverGitRepos(process.cwd());
|
|
8136
8312
|
if (repos.length === 0) {
|
|
8137
8313
|
if (quiet) return;
|
|
8138
|
-
console.log(
|
|
8314
|
+
console.log(chalk16.red("Not inside a git repository and no git repos found in child directories."));
|
|
8139
8315
|
throw new Error("__exit__");
|
|
8140
8316
|
}
|
|
8141
|
-
log2(quiet,
|
|
8317
|
+
log2(quiet, chalk16.dim(`Found ${repos.length} git repo${repos.length === 1 ? "" : "s"}
|
|
8142
8318
|
`));
|
|
8143
8319
|
const originalDir = process.cwd();
|
|
8144
8320
|
for (const repo of repos) {
|
|
@@ -8148,7 +8324,7 @@ async function refreshCommand(options) {
|
|
|
8148
8324
|
await refreshSingleRepo(repo, { ...options, label: repoName });
|
|
8149
8325
|
} catch (err) {
|
|
8150
8326
|
if (err instanceof Error && err.message === "__exit__") continue;
|
|
8151
|
-
log2(quiet,
|
|
8327
|
+
log2(quiet, chalk16.yellow(`${repoName}: refresh failed \u2014 ${err instanceof Error ? err.message : "unknown error"}`));
|
|
8152
8328
|
}
|
|
8153
8329
|
}
|
|
8154
8330
|
process.chdir(originalDir);
|
|
@@ -8156,13 +8332,13 @@ async function refreshCommand(options) {
|
|
|
8156
8332
|
if (err instanceof Error && err.message === "__exit__") throw err;
|
|
8157
8333
|
if (quiet) return;
|
|
8158
8334
|
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
8159
|
-
console.log(
|
|
8335
|
+
console.log(chalk16.red(`Refresh failed: ${msg}`));
|
|
8160
8336
|
throw new Error("__exit__");
|
|
8161
8337
|
}
|
|
8162
8338
|
}
|
|
8163
8339
|
|
|
8164
8340
|
// src/commands/hooks.ts
|
|
8165
|
-
import
|
|
8341
|
+
import chalk17 from "chalk";
|
|
8166
8342
|
var HOOKS = [
|
|
8167
8343
|
{
|
|
8168
8344
|
id: "session-end",
|
|
@@ -8182,13 +8358,13 @@ var HOOKS = [
|
|
|
8182
8358
|
}
|
|
8183
8359
|
];
|
|
8184
8360
|
function printStatus() {
|
|
8185
|
-
console.log(
|
|
8361
|
+
console.log(chalk17.bold("\n Hooks\n"));
|
|
8186
8362
|
for (const hook of HOOKS) {
|
|
8187
8363
|
const installed = hook.isInstalled();
|
|
8188
|
-
const icon = installed ?
|
|
8189
|
-
const state = installed ?
|
|
8364
|
+
const icon = installed ? chalk17.green("\u2713") : chalk17.dim("\u2717");
|
|
8365
|
+
const state = installed ? chalk17.green("enabled") : chalk17.dim("disabled");
|
|
8190
8366
|
console.log(` ${icon} ${hook.label.padEnd(26)} ${state}`);
|
|
8191
|
-
console.log(
|
|
8367
|
+
console.log(chalk17.dim(` ${hook.description}`));
|
|
8192
8368
|
}
|
|
8193
8369
|
console.log("");
|
|
8194
8370
|
}
|
|
@@ -8197,9 +8373,9 @@ async function hooksCommand(options) {
|
|
|
8197
8373
|
for (const hook of HOOKS) {
|
|
8198
8374
|
const result = hook.install();
|
|
8199
8375
|
if (result.alreadyInstalled) {
|
|
8200
|
-
console.log(
|
|
8376
|
+
console.log(chalk17.dim(` ${hook.label} already enabled.`));
|
|
8201
8377
|
} else {
|
|
8202
|
-
console.log(
|
|
8378
|
+
console.log(chalk17.green(" \u2713") + ` ${hook.label} enabled`);
|
|
8203
8379
|
}
|
|
8204
8380
|
}
|
|
8205
8381
|
return;
|
|
@@ -8208,9 +8384,9 @@ async function hooksCommand(options) {
|
|
|
8208
8384
|
for (const hook of HOOKS) {
|
|
8209
8385
|
const result = hook.remove();
|
|
8210
8386
|
if (result.notFound) {
|
|
8211
|
-
console.log(
|
|
8387
|
+
console.log(chalk17.dim(` ${hook.label} already disabled.`));
|
|
8212
8388
|
} else {
|
|
8213
|
-
console.log(
|
|
8389
|
+
console.log(chalk17.green(" \u2713") + ` ${hook.label} removed`);
|
|
8214
8390
|
}
|
|
8215
8391
|
}
|
|
8216
8392
|
return;
|
|
@@ -8225,18 +8401,18 @@ async function hooksCommand(options) {
|
|
|
8225
8401
|
const states = HOOKS.map((h) => h.isInstalled());
|
|
8226
8402
|
function render() {
|
|
8227
8403
|
const lines = [];
|
|
8228
|
-
lines.push(
|
|
8404
|
+
lines.push(chalk17.bold(" Hooks"));
|
|
8229
8405
|
lines.push("");
|
|
8230
8406
|
for (let i = 0; i < HOOKS.length; i++) {
|
|
8231
8407
|
const hook = HOOKS[i];
|
|
8232
8408
|
const enabled = states[i];
|
|
8233
|
-
const toggle = enabled ?
|
|
8234
|
-
const ptr = i === cursor ?
|
|
8409
|
+
const toggle = enabled ? chalk17.green("[on] ") : chalk17.dim("[off]");
|
|
8410
|
+
const ptr = i === cursor ? chalk17.cyan(">") : " ";
|
|
8235
8411
|
lines.push(` ${ptr} ${toggle} ${hook.label}`);
|
|
8236
|
-
lines.push(
|
|
8412
|
+
lines.push(chalk17.dim(` ${hook.description}`));
|
|
8237
8413
|
}
|
|
8238
8414
|
lines.push("");
|
|
8239
|
-
lines.push(
|
|
8415
|
+
lines.push(chalk17.dim(" \u2191\u2193 navigate \u23B5 toggle a all on n all off \u23CE apply q cancel"));
|
|
8240
8416
|
return lines.join("\n");
|
|
8241
8417
|
}
|
|
8242
8418
|
function draw(initial) {
|
|
@@ -8267,16 +8443,16 @@ async function hooksCommand(options) {
|
|
|
8267
8443
|
const wantEnabled = states[i];
|
|
8268
8444
|
if (wantEnabled && !wasInstalled) {
|
|
8269
8445
|
hook.install();
|
|
8270
|
-
console.log(
|
|
8446
|
+
console.log(chalk17.green(" \u2713") + ` ${hook.label} enabled`);
|
|
8271
8447
|
changed++;
|
|
8272
8448
|
} else if (!wantEnabled && wasInstalled) {
|
|
8273
8449
|
hook.remove();
|
|
8274
|
-
console.log(
|
|
8450
|
+
console.log(chalk17.green(" \u2713") + ` ${hook.label} disabled`);
|
|
8275
8451
|
changed++;
|
|
8276
8452
|
}
|
|
8277
8453
|
}
|
|
8278
8454
|
if (changed === 0) {
|
|
8279
|
-
console.log(
|
|
8455
|
+
console.log(chalk17.dim(" No changes."));
|
|
8280
8456
|
}
|
|
8281
8457
|
console.log("");
|
|
8282
8458
|
}
|
|
@@ -8312,7 +8488,7 @@ async function hooksCommand(options) {
|
|
|
8312
8488
|
case "\x1B":
|
|
8313
8489
|
case "":
|
|
8314
8490
|
cleanup();
|
|
8315
|
-
console.log(
|
|
8491
|
+
console.log(chalk17.dim("\n Cancelled.\n"));
|
|
8316
8492
|
resolve2();
|
|
8317
8493
|
break;
|
|
8318
8494
|
}
|
|
@@ -8323,51 +8499,51 @@ async function hooksCommand(options) {
|
|
|
8323
8499
|
|
|
8324
8500
|
// src/commands/config.ts
|
|
8325
8501
|
init_config();
|
|
8326
|
-
import
|
|
8502
|
+
import chalk18 from "chalk";
|
|
8327
8503
|
async function configCommand() {
|
|
8328
8504
|
const existing = loadConfig();
|
|
8329
8505
|
if (existing) {
|
|
8330
8506
|
const displayModel = getDisplayModel(existing);
|
|
8331
8507
|
const fastModel = getFastModel();
|
|
8332
|
-
console.log(
|
|
8333
|
-
console.log(` Provider: ${
|
|
8334
|
-
console.log(` Model: ${
|
|
8508
|
+
console.log(chalk18.bold("\nCurrent Configuration\n"));
|
|
8509
|
+
console.log(` Provider: ${chalk18.cyan(existing.provider)}`);
|
|
8510
|
+
console.log(` Model: ${chalk18.cyan(displayModel)}`);
|
|
8335
8511
|
if (fastModel) {
|
|
8336
|
-
console.log(` Scan: ${
|
|
8512
|
+
console.log(` Scan: ${chalk18.cyan(fastModel)}`);
|
|
8337
8513
|
}
|
|
8338
8514
|
if (existing.apiKey) {
|
|
8339
8515
|
const masked = existing.apiKey.slice(0, 8) + "..." + existing.apiKey.slice(-4);
|
|
8340
|
-
console.log(` API Key: ${
|
|
8516
|
+
console.log(` API Key: ${chalk18.dim(masked)}`);
|
|
8341
8517
|
}
|
|
8342
8518
|
if (existing.provider === "cursor") {
|
|
8343
|
-
console.log(` Seat: ${
|
|
8519
|
+
console.log(` Seat: ${chalk18.dim("Cursor (agent acp)")}`);
|
|
8344
8520
|
}
|
|
8345
8521
|
if (existing.provider === "claude-cli") {
|
|
8346
|
-
console.log(` Seat: ${
|
|
8522
|
+
console.log(` Seat: ${chalk18.dim("Claude Code (claude -p)")}`);
|
|
8347
8523
|
}
|
|
8348
8524
|
if (existing.baseUrl) {
|
|
8349
|
-
console.log(` Base URL: ${
|
|
8525
|
+
console.log(` Base URL: ${chalk18.dim(existing.baseUrl)}`);
|
|
8350
8526
|
}
|
|
8351
8527
|
if (existing.vertexProjectId) {
|
|
8352
|
-
console.log(` Vertex Project: ${
|
|
8353
|
-
console.log(` Vertex Region: ${
|
|
8528
|
+
console.log(` Vertex Project: ${chalk18.dim(existing.vertexProjectId)}`);
|
|
8529
|
+
console.log(` Vertex Region: ${chalk18.dim(existing.vertexRegion || "us-east5")}`);
|
|
8354
8530
|
}
|
|
8355
|
-
console.log(` Source: ${
|
|
8531
|
+
console.log(` Source: ${chalk18.dim(process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY || process.env.VERTEX_PROJECT_ID || process.env.CALIBER_USE_CURSOR_SEAT || process.env.CALIBER_USE_CLAUDE_CLI ? "environment variables" : getConfigFilePath())}`);
|
|
8356
8532
|
console.log("");
|
|
8357
8533
|
}
|
|
8358
8534
|
await runInteractiveProviderSetup();
|
|
8359
8535
|
const updated = loadConfig();
|
|
8360
8536
|
if (updated) trackConfigProviderSet(updated.provider);
|
|
8361
|
-
console.log(
|
|
8362
|
-
console.log(
|
|
8537
|
+
console.log(chalk18.green("\n\u2713 Configuration saved"));
|
|
8538
|
+
console.log(chalk18.dim(` ${getConfigFilePath()}
|
|
8363
8539
|
`));
|
|
8364
|
-
console.log(
|
|
8365
|
-
console.log(
|
|
8540
|
+
console.log(chalk18.dim(" You can also set environment variables instead:"));
|
|
8541
|
+
console.log(chalk18.dim(" ANTHROPIC_API_KEY, OPENAI_API_KEY, VERTEX_PROJECT_ID, CALIBER_USE_CURSOR_SEAT=1, or CALIBER_USE_CLAUDE_CLI=1\n"));
|
|
8366
8542
|
}
|
|
8367
8543
|
|
|
8368
8544
|
// src/commands/learn.ts
|
|
8369
8545
|
import fs33 from "fs";
|
|
8370
|
-
import
|
|
8546
|
+
import chalk19 from "chalk";
|
|
8371
8547
|
|
|
8372
8548
|
// src/learner/stdin.ts
|
|
8373
8549
|
var STDIN_TIMEOUT_MS = 5e3;
|
|
@@ -8798,26 +8974,26 @@ async function learnFinalizeCommand(options) {
|
|
|
8798
8974
|
if (!options?.force) {
|
|
8799
8975
|
const { isCaliberRunning: isCaliberRunning2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
|
|
8800
8976
|
if (isCaliberRunning2()) {
|
|
8801
|
-
console.log(
|
|
8977
|
+
console.log(chalk19.dim("caliber: skipping finalize \u2014 another caliber process is running"));
|
|
8802
8978
|
return;
|
|
8803
8979
|
}
|
|
8804
8980
|
}
|
|
8805
8981
|
if (!acquireFinalizeLock()) {
|
|
8806
|
-
console.log(
|
|
8982
|
+
console.log(chalk19.dim("caliber: skipping finalize \u2014 another finalize is in progress"));
|
|
8807
8983
|
return;
|
|
8808
8984
|
}
|
|
8809
8985
|
let analyzed = false;
|
|
8810
8986
|
try {
|
|
8811
8987
|
const config = loadConfig();
|
|
8812
8988
|
if (!config) {
|
|
8813
|
-
console.log(
|
|
8989
|
+
console.log(chalk19.yellow("caliber: no LLM provider configured \u2014 run `caliber config` first"));
|
|
8814
8990
|
clearSession();
|
|
8815
8991
|
resetState();
|
|
8816
8992
|
return;
|
|
8817
8993
|
}
|
|
8818
8994
|
const events = readAllEvents();
|
|
8819
8995
|
if (events.length < MIN_EVENTS_FOR_ANALYSIS) {
|
|
8820
|
-
console.log(
|
|
8996
|
+
console.log(chalk19.dim(`caliber: ${events.length}/${MIN_EVENTS_FOR_ANALYSIS} events recorded \u2014 need more before analysis`));
|
|
8821
8997
|
return;
|
|
8822
8998
|
}
|
|
8823
8999
|
await validateModel({ fast: true });
|
|
@@ -8845,9 +9021,9 @@ async function learnFinalizeCommand(options) {
|
|
|
8845
9021
|
newLearningsProduced = result.newItemCount;
|
|
8846
9022
|
if (result.newItemCount > 0) {
|
|
8847
9023
|
const wasteLabel = waste.totalWasteTokens > 0 ? ` (~${waste.totalWasteTokens.toLocaleString()} wasted tokens captured)` : "";
|
|
8848
|
-
console.log(
|
|
9024
|
+
console.log(chalk19.dim(`caliber: learned ${result.newItemCount} new pattern${result.newItemCount === 1 ? "" : "s"}${wasteLabel}`));
|
|
8849
9025
|
for (const item of result.newItems) {
|
|
8850
|
-
console.log(
|
|
9026
|
+
console.log(chalk19.dim(` + ${item.replace(/^- /, "").slice(0, 80)}`));
|
|
8851
9027
|
}
|
|
8852
9028
|
const wastePerLearning = Math.round(waste.totalWasteTokens / result.newItemCount);
|
|
8853
9029
|
const TYPE_RE = /^\*\*\[([^\]]+)\]\*\*/;
|
|
@@ -8906,11 +9082,11 @@ async function learnFinalizeCommand(options) {
|
|
|
8906
9082
|
});
|
|
8907
9083
|
if (t.estimatedSavingsTokens > 0) {
|
|
8908
9084
|
const totalLearnings = existingLearnedItems + newLearningsProduced;
|
|
8909
|
-
console.log(
|
|
9085
|
+
console.log(chalk19.dim(`caliber: ${totalLearnings} learnings active \u2014 est. ~${t.estimatedSavingsTokens.toLocaleString()} tokens saved across ${t.totalSessionsWithLearnings} sessions`));
|
|
8910
9086
|
}
|
|
8911
9087
|
} catch (err) {
|
|
8912
9088
|
if (options?.force) {
|
|
8913
|
-
console.error(
|
|
9089
|
+
console.error(chalk19.red("caliber: finalize failed \u2014"), err instanceof Error ? err.message : err);
|
|
8914
9090
|
}
|
|
8915
9091
|
} finally {
|
|
8916
9092
|
if (analyzed) {
|
|
@@ -8925,45 +9101,45 @@ async function learnInstallCommand() {
|
|
|
8925
9101
|
if (fs33.existsSync(".claude")) {
|
|
8926
9102
|
const r = installLearningHooks();
|
|
8927
9103
|
if (r.installed) {
|
|
8928
|
-
console.log(
|
|
9104
|
+
console.log(chalk19.green("\u2713") + " Claude Code learning hooks installed");
|
|
8929
9105
|
anyInstalled = true;
|
|
8930
9106
|
} else if (r.alreadyInstalled) {
|
|
8931
|
-
console.log(
|
|
9107
|
+
console.log(chalk19.dim(" Claude Code hooks already installed"));
|
|
8932
9108
|
}
|
|
8933
9109
|
}
|
|
8934
9110
|
if (fs33.existsSync(".cursor")) {
|
|
8935
9111
|
const r = installCursorLearningHooks();
|
|
8936
9112
|
if (r.installed) {
|
|
8937
|
-
console.log(
|
|
9113
|
+
console.log(chalk19.green("\u2713") + " Cursor learning hooks installed");
|
|
8938
9114
|
anyInstalled = true;
|
|
8939
9115
|
} else if (r.alreadyInstalled) {
|
|
8940
|
-
console.log(
|
|
9116
|
+
console.log(chalk19.dim(" Cursor hooks already installed"));
|
|
8941
9117
|
}
|
|
8942
9118
|
}
|
|
8943
9119
|
if (!fs33.existsSync(".claude") && !fs33.existsSync(".cursor")) {
|
|
8944
|
-
console.log(
|
|
8945
|
-
console.log(
|
|
9120
|
+
console.log(chalk19.yellow("No .claude/ or .cursor/ directory found."));
|
|
9121
|
+
console.log(chalk19.dim(" Run `caliber init` first, or create the directory manually."));
|
|
8946
9122
|
return;
|
|
8947
9123
|
}
|
|
8948
9124
|
if (anyInstalled) {
|
|
8949
|
-
console.log(
|
|
8950
|
-
console.log(
|
|
9125
|
+
console.log(chalk19.dim(` Tool usage will be recorded and learnings extracted after \u2265${MIN_EVENTS_FOR_ANALYSIS} events.`));
|
|
9126
|
+
console.log(chalk19.dim(" Learnings written to CALIBER_LEARNINGS.md."));
|
|
8951
9127
|
}
|
|
8952
9128
|
}
|
|
8953
9129
|
async function learnRemoveCommand() {
|
|
8954
9130
|
let anyRemoved = false;
|
|
8955
9131
|
const r1 = removeLearningHooks();
|
|
8956
9132
|
if (r1.removed) {
|
|
8957
|
-
console.log(
|
|
9133
|
+
console.log(chalk19.green("\u2713") + " Claude Code learning hooks removed");
|
|
8958
9134
|
anyRemoved = true;
|
|
8959
9135
|
}
|
|
8960
9136
|
const r2 = removeCursorLearningHooks();
|
|
8961
9137
|
if (r2.removed) {
|
|
8962
|
-
console.log(
|
|
9138
|
+
console.log(chalk19.green("\u2713") + " Cursor learning hooks removed");
|
|
8963
9139
|
anyRemoved = true;
|
|
8964
9140
|
}
|
|
8965
9141
|
if (!anyRemoved) {
|
|
8966
|
-
console.log(
|
|
9142
|
+
console.log(chalk19.dim("No learning hooks found."));
|
|
8967
9143
|
}
|
|
8968
9144
|
}
|
|
8969
9145
|
async function learnStatusCommand() {
|
|
@@ -8971,40 +9147,40 @@ async function learnStatusCommand() {
|
|
|
8971
9147
|
const cursorInstalled = areCursorLearningHooksInstalled();
|
|
8972
9148
|
const state = readState2();
|
|
8973
9149
|
const eventCount = getEventCount();
|
|
8974
|
-
console.log(
|
|
9150
|
+
console.log(chalk19.bold("Session Learning Status"));
|
|
8975
9151
|
console.log();
|
|
8976
9152
|
if (claudeInstalled) {
|
|
8977
|
-
console.log(
|
|
9153
|
+
console.log(chalk19.green("\u2713") + " Claude Code hooks " + chalk19.green("installed"));
|
|
8978
9154
|
} else {
|
|
8979
|
-
console.log(
|
|
9155
|
+
console.log(chalk19.dim("\u2717") + " Claude Code hooks " + chalk19.dim("not installed"));
|
|
8980
9156
|
}
|
|
8981
9157
|
if (cursorInstalled) {
|
|
8982
|
-
console.log(
|
|
9158
|
+
console.log(chalk19.green("\u2713") + " Cursor hooks " + chalk19.green("installed"));
|
|
8983
9159
|
} else {
|
|
8984
|
-
console.log(
|
|
9160
|
+
console.log(chalk19.dim("\u2717") + " Cursor hooks " + chalk19.dim("not installed"));
|
|
8985
9161
|
}
|
|
8986
9162
|
if (!claudeInstalled && !cursorInstalled) {
|
|
8987
|
-
console.log(
|
|
9163
|
+
console.log(chalk19.dim(" Run `caliber learn install` to enable session learning."));
|
|
8988
9164
|
}
|
|
8989
9165
|
console.log();
|
|
8990
|
-
console.log(`Events recorded: ${
|
|
8991
|
-
console.log(`Threshold for analysis: ${
|
|
9166
|
+
console.log(`Events recorded: ${chalk19.cyan(String(eventCount))}`);
|
|
9167
|
+
console.log(`Threshold for analysis: ${chalk19.cyan(String(MIN_EVENTS_FOR_ANALYSIS))}`);
|
|
8992
9168
|
if (state.lastAnalysisTimestamp) {
|
|
8993
|
-
console.log(`Last analysis: ${
|
|
9169
|
+
console.log(`Last analysis: ${chalk19.cyan(state.lastAnalysisTimestamp)}`);
|
|
8994
9170
|
} else {
|
|
8995
|
-
console.log(`Last analysis: ${
|
|
9171
|
+
console.log(`Last analysis: ${chalk19.dim("none")}`);
|
|
8996
9172
|
}
|
|
8997
9173
|
const learnedSection = readLearnedSection();
|
|
8998
9174
|
if (learnedSection) {
|
|
8999
9175
|
const lineCount = learnedSection.split("\n").filter(Boolean).length;
|
|
9000
9176
|
console.log(`
|
|
9001
|
-
Learned items in CALIBER_LEARNINGS.md: ${
|
|
9177
|
+
Learned items in CALIBER_LEARNINGS.md: ${chalk19.cyan(String(lineCount))}`);
|
|
9002
9178
|
}
|
|
9003
9179
|
const roiStats = readROIStats();
|
|
9004
9180
|
const roiSummary = formatROISummary(roiStats);
|
|
9005
9181
|
if (roiSummary) {
|
|
9006
9182
|
console.log();
|
|
9007
|
-
console.log(
|
|
9183
|
+
console.log(chalk19.bold(roiSummary.split("\n")[0]));
|
|
9008
9184
|
for (const line of roiSummary.split("\n").slice(1)) {
|
|
9009
9185
|
console.log(line);
|
|
9010
9186
|
}
|
|
@@ -9092,7 +9268,7 @@ import fs35 from "fs";
|
|
|
9092
9268
|
import path28 from "path";
|
|
9093
9269
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
9094
9270
|
import { execSync as execSync14 } from "child_process";
|
|
9095
|
-
import
|
|
9271
|
+
import chalk20 from "chalk";
|
|
9096
9272
|
import ora6 from "ora";
|
|
9097
9273
|
import confirm2 from "@inquirer/confirm";
|
|
9098
9274
|
var __dirname_vc = path28.dirname(fileURLToPath2(import.meta.url));
|
|
@@ -9148,17 +9324,17 @@ async function checkForUpdates() {
|
|
|
9148
9324
|
if (!isInteractive) {
|
|
9149
9325
|
const installTag = channel === "latest" ? "" : `@${channel}`;
|
|
9150
9326
|
console.log(
|
|
9151
|
-
|
|
9327
|
+
chalk20.yellow(
|
|
9152
9328
|
`
|
|
9153
9329
|
Update available: ${current} -> ${latest}
|
|
9154
|
-
Run ${
|
|
9330
|
+
Run ${chalk20.bold(`npm install -g @rely-ai/caliber${installTag}`)} to upgrade.
|
|
9155
9331
|
`
|
|
9156
9332
|
)
|
|
9157
9333
|
);
|
|
9158
9334
|
return;
|
|
9159
9335
|
}
|
|
9160
9336
|
console.log(
|
|
9161
|
-
|
|
9337
|
+
chalk20.yellow(`
|
|
9162
9338
|
Update available: ${current} -> ${latest}`)
|
|
9163
9339
|
);
|
|
9164
9340
|
const shouldUpdate = await confirm2({ message: "Would you like to update now? (Y/n)", default: true });
|
|
@@ -9177,13 +9353,13 @@ Update available: ${current} -> ${latest}`)
|
|
|
9177
9353
|
const installed = getInstalledVersion();
|
|
9178
9354
|
if (installed !== latest) {
|
|
9179
9355
|
spinner.fail(`Update incomplete \u2014 got ${installed ?? "unknown"}, expected ${latest}`);
|
|
9180
|
-
console.log(
|
|
9356
|
+
console.log(chalk20.yellow(`Run ${chalk20.bold(`npm install -g @rely-ai/caliber@${tag}`)} manually.
|
|
9181
9357
|
`));
|
|
9182
9358
|
return;
|
|
9183
9359
|
}
|
|
9184
|
-
spinner.succeed(
|
|
9360
|
+
spinner.succeed(chalk20.green(`Updated to ${latest}`));
|
|
9185
9361
|
const args = process.argv.slice(2);
|
|
9186
|
-
console.log(
|
|
9362
|
+
console.log(chalk20.dim(`
|
|
9187
9363
|
Restarting: caliber ${args.join(" ")}
|
|
9188
9364
|
`));
|
|
9189
9365
|
execSync14(`caliber ${args.map((a) => JSON.stringify(a)).join(" ")}`, {
|
|
@@ -9196,11 +9372,11 @@ Restarting: caliber ${args.join(" ")}
|
|
|
9196
9372
|
if (err instanceof Error) {
|
|
9197
9373
|
const stderr = err.stderr;
|
|
9198
9374
|
const errMsg = stderr ? String(stderr).trim().split("\n").pop() : err.message.split("\n")[0];
|
|
9199
|
-
if (errMsg && !errMsg.includes("SIGTERM")) console.log(
|
|
9375
|
+
if (errMsg && !errMsg.includes("SIGTERM")) console.log(chalk20.dim(` ${errMsg}`));
|
|
9200
9376
|
}
|
|
9201
9377
|
console.log(
|
|
9202
|
-
|
|
9203
|
-
`Run ${
|
|
9378
|
+
chalk20.yellow(
|
|
9379
|
+
`Run ${chalk20.bold(`npm install -g @rely-ai/caliber@${tag}`)} manually to upgrade.
|
|
9204
9380
|
`
|
|
9205
9381
|
)
|
|
9206
9382
|
);
|