@rely-ai/caliber 1.29.6 → 1.29.7
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 +92 -60
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -181,7 +181,7 @@ __export(resolve_caliber_exports, {
|
|
|
181
181
|
resolveCaliber: () => resolveCaliber
|
|
182
182
|
});
|
|
183
183
|
import fs20 from "fs";
|
|
184
|
-
import { execSync as
|
|
184
|
+
import { execSync as execSync7 } from "child_process";
|
|
185
185
|
function resolveCaliber() {
|
|
186
186
|
if (_resolved) return _resolved;
|
|
187
187
|
const isNpx = process.argv[1]?.includes("_npx") || process.env.npm_execpath?.includes("npx");
|
|
@@ -191,7 +191,7 @@ function resolveCaliber() {
|
|
|
191
191
|
}
|
|
192
192
|
try {
|
|
193
193
|
const whichCmd = process.platform === "win32" ? "where caliber" : "which caliber";
|
|
194
|
-
|
|
194
|
+
execSync7(whichCmd, {
|
|
195
195
|
encoding: "utf-8",
|
|
196
196
|
stdio: ["pipe", "pipe", "pipe"]
|
|
197
197
|
});
|
|
@@ -223,7 +223,7 @@ var init_resolve_caliber = __esm({
|
|
|
223
223
|
});
|
|
224
224
|
|
|
225
225
|
// src/utils/editor.ts
|
|
226
|
-
import { execSync as
|
|
226
|
+
import { execSync as execSync13, spawn as spawn3 } from "child_process";
|
|
227
227
|
import fs26 from "fs";
|
|
228
228
|
import path22 from "path";
|
|
229
229
|
import os6 from "os";
|
|
@@ -236,7 +236,7 @@ function getEmptyFilePath(proposedPath) {
|
|
|
236
236
|
function commandExists(cmd) {
|
|
237
237
|
try {
|
|
238
238
|
const check = process.platform === "win32" ? `where ${cmd}` : `which ${cmd}`;
|
|
239
|
-
|
|
239
|
+
execSync13(check, { stdio: "ignore" });
|
|
240
240
|
return true;
|
|
241
241
|
} catch {
|
|
242
242
|
return false;
|
|
@@ -662,11 +662,26 @@ import path3 from "path";
|
|
|
662
662
|
// src/constants.ts
|
|
663
663
|
import path2 from "path";
|
|
664
664
|
import os from "os";
|
|
665
|
+
import { execSync as execSync2 } from "child_process";
|
|
665
666
|
var AUTH_DIR = path2.join(os.homedir(), ".caliber");
|
|
666
667
|
var CALIBER_DIR = ".caliber";
|
|
667
668
|
var MANIFEST_FILE = path2.join(CALIBER_DIR, "manifest.json");
|
|
668
669
|
var BACKUPS_DIR = path2.join(CALIBER_DIR, "backups");
|
|
669
|
-
var
|
|
670
|
+
var _learningDirCache = null;
|
|
671
|
+
function getLearningDir() {
|
|
672
|
+
if (_learningDirCache) return _learningDirCache;
|
|
673
|
+
try {
|
|
674
|
+
const gitCommonDir = execSync2("git rev-parse --git-common-dir", {
|
|
675
|
+
encoding: "utf-8",
|
|
676
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
677
|
+
}).trim();
|
|
678
|
+
const mainRoot = path2.dirname(path2.resolve(gitCommonDir));
|
|
679
|
+
_learningDirCache = path2.join(mainRoot, CALIBER_DIR, "learning");
|
|
680
|
+
} catch {
|
|
681
|
+
_learningDirCache = path2.join(CALIBER_DIR, "learning");
|
|
682
|
+
}
|
|
683
|
+
return _learningDirCache;
|
|
684
|
+
}
|
|
670
685
|
var LEARNING_SESSION_FILE = "current-session.jsonl";
|
|
671
686
|
var LEARNING_STATE_FILE = "state.json";
|
|
672
687
|
var LEARNING_MAX_EVENTS = 500;
|
|
@@ -779,7 +794,7 @@ function readExistingConfigs(dir) {
|
|
|
779
794
|
// src/fingerprint/code-analysis.ts
|
|
780
795
|
import fs3 from "fs";
|
|
781
796
|
import path4 from "path";
|
|
782
|
-
import { execSync as
|
|
797
|
+
import { execSync as execSync3 } from "child_process";
|
|
783
798
|
var IGNORE_DIRS2 = /* @__PURE__ */ new Set([
|
|
784
799
|
"node_modules",
|
|
785
800
|
".git",
|
|
@@ -1126,7 +1141,7 @@ function buildImportCounts(files) {
|
|
|
1126
1141
|
function getGitFrequency(dir) {
|
|
1127
1142
|
const freq = /* @__PURE__ */ new Map();
|
|
1128
1143
|
try {
|
|
1129
|
-
const output =
|
|
1144
|
+
const output = execSync3(
|
|
1130
1145
|
'git log --since="6 months ago" --format="" --name-only --diff-filter=ACMR 2>/dev/null | head -10000',
|
|
1131
1146
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], timeout: 5e3 }
|
|
1132
1147
|
);
|
|
@@ -1575,7 +1590,7 @@ var OpenAICompatProvider = class {
|
|
|
1575
1590
|
};
|
|
1576
1591
|
|
|
1577
1592
|
// src/llm/cursor-acp.ts
|
|
1578
|
-
import { spawn, execSync as
|
|
1593
|
+
import { spawn, execSync as execSync4 } from "child_process";
|
|
1579
1594
|
import os3 from "os";
|
|
1580
1595
|
|
|
1581
1596
|
// src/llm/seat-based-errors.ts
|
|
@@ -1851,7 +1866,7 @@ var CursorAcpProvider = class {
|
|
|
1851
1866
|
function isCursorAgentAvailable() {
|
|
1852
1867
|
try {
|
|
1853
1868
|
const cmd = IS_WINDOWS ? `where ${AGENT_BIN}` : `which ${AGENT_BIN}`;
|
|
1854
|
-
|
|
1869
|
+
execSync4(cmd, { stdio: "ignore" });
|
|
1855
1870
|
return true;
|
|
1856
1871
|
} catch {
|
|
1857
1872
|
return false;
|
|
@@ -1859,7 +1874,7 @@ function isCursorAgentAvailable() {
|
|
|
1859
1874
|
}
|
|
1860
1875
|
function isCursorLoggedIn() {
|
|
1861
1876
|
try {
|
|
1862
|
-
const result =
|
|
1877
|
+
const result = execSync4(`${AGENT_BIN} status`, { stdio: ["ignore", "pipe", "ignore"], timeout: 5e3 });
|
|
1863
1878
|
return !result.toString().includes("not logged in");
|
|
1864
1879
|
} catch {
|
|
1865
1880
|
return false;
|
|
@@ -1867,7 +1882,7 @@ function isCursorLoggedIn() {
|
|
|
1867
1882
|
}
|
|
1868
1883
|
|
|
1869
1884
|
// src/llm/claude-cli.ts
|
|
1870
|
-
import { spawn as spawn2, execSync as
|
|
1885
|
+
import { spawn as spawn2, execSync as execSync5 } from "child_process";
|
|
1871
1886
|
var CLAUDE_CLI_BIN = "claude";
|
|
1872
1887
|
var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
|
|
1873
1888
|
var IS_WINDOWS2 = process.platform === "win32";
|
|
@@ -2002,7 +2017,7 @@ var ClaudeCliProvider = class {
|
|
|
2002
2017
|
function isClaudeCliAvailable() {
|
|
2003
2018
|
try {
|
|
2004
2019
|
const cmd = process.platform === "win32" ? `where ${CLAUDE_CLI_BIN}` : `which ${CLAUDE_CLI_BIN}`;
|
|
2005
|
-
|
|
2020
|
+
execSync5(cmd, { stdio: "ignore" });
|
|
2006
2021
|
return true;
|
|
2007
2022
|
} catch {
|
|
2008
2023
|
return false;
|
|
@@ -2742,7 +2757,7 @@ init_config();
|
|
|
2742
2757
|
import fs6 from "fs";
|
|
2743
2758
|
import path6 from "path";
|
|
2744
2759
|
import crypto from "crypto";
|
|
2745
|
-
import { execSync as
|
|
2760
|
+
import { execSync as execSync6 } from "child_process";
|
|
2746
2761
|
var CACHE_VERSION = 1;
|
|
2747
2762
|
var CACHE_DIR = ".caliber/cache";
|
|
2748
2763
|
var CACHE_FILE = "fingerprint.json";
|
|
@@ -2751,7 +2766,7 @@ function getCachePath(dir) {
|
|
|
2751
2766
|
}
|
|
2752
2767
|
function getGitHead(dir) {
|
|
2753
2768
|
try {
|
|
2754
|
-
return
|
|
2769
|
+
return execSync6("git rev-parse HEAD", {
|
|
2755
2770
|
cwd: dir,
|
|
2756
2771
|
encoding: "utf-8",
|
|
2757
2772
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -2763,7 +2778,7 @@ function getGitHead(dir) {
|
|
|
2763
2778
|
}
|
|
2764
2779
|
function getDirtySignature(dir) {
|
|
2765
2780
|
try {
|
|
2766
|
-
const output =
|
|
2781
|
+
const output = execSync6("git diff --name-only HEAD", {
|
|
2767
2782
|
cwd: dir,
|
|
2768
2783
|
encoding: "utf-8",
|
|
2769
2784
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -4989,7 +5004,7 @@ function removeLearningHooks() {
|
|
|
4989
5004
|
// src/lib/state.ts
|
|
4990
5005
|
import fs22 from "fs";
|
|
4991
5006
|
import path18 from "path";
|
|
4992
|
-
import { execSync as
|
|
5007
|
+
import { execSync as execSync8 } from "child_process";
|
|
4993
5008
|
var STATE_FILE = path18.join(CALIBER_DIR, ".caliber-state.json");
|
|
4994
5009
|
function normalizeTargetAgent(value) {
|
|
4995
5010
|
if (Array.isArray(value)) return value;
|
|
@@ -5017,7 +5032,7 @@ function writeState(state) {
|
|
|
5017
5032
|
}
|
|
5018
5033
|
function getCurrentHeadSha() {
|
|
5019
5034
|
try {
|
|
5020
|
-
return
|
|
5035
|
+
return execSync8("git rev-parse HEAD", {
|
|
5021
5036
|
encoding: "utf-8",
|
|
5022
5037
|
stdio: ["pipe", "pipe", "pipe"]
|
|
5023
5038
|
}).trim();
|
|
@@ -5630,7 +5645,7 @@ function checkGrounding(dir) {
|
|
|
5630
5645
|
|
|
5631
5646
|
// src/scoring/checks/accuracy.ts
|
|
5632
5647
|
import { existsSync as existsSync4, statSync as statSync2 } from "fs";
|
|
5633
|
-
import { execSync as
|
|
5648
|
+
import { execSync as execSync9 } from "child_process";
|
|
5634
5649
|
import { join as join5 } from "path";
|
|
5635
5650
|
function validateReferences(dir) {
|
|
5636
5651
|
const configContent = collectPrimaryConfigContent(dir);
|
|
@@ -5639,13 +5654,13 @@ function validateReferences(dir) {
|
|
|
5639
5654
|
}
|
|
5640
5655
|
function detectGitDrift(dir) {
|
|
5641
5656
|
try {
|
|
5642
|
-
|
|
5657
|
+
execSync9("git rev-parse --git-dir", { cwd: dir, stdio: ["pipe", "pipe", "pipe"] });
|
|
5643
5658
|
} catch {
|
|
5644
5659
|
return { commitsSinceConfigUpdate: 0, lastConfigCommit: null, isGitRepo: false };
|
|
5645
5660
|
}
|
|
5646
5661
|
const configFiles = ["CLAUDE.md", "AGENTS.md", ".cursorrules", ".cursor/rules"];
|
|
5647
5662
|
try {
|
|
5648
|
-
const headTimestamp =
|
|
5663
|
+
const headTimestamp = execSync9(
|
|
5649
5664
|
"git log -1 --format=%ct HEAD",
|
|
5650
5665
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5651
5666
|
).trim();
|
|
@@ -5666,7 +5681,7 @@ function detectGitDrift(dir) {
|
|
|
5666
5681
|
let latestConfigCommitHash = null;
|
|
5667
5682
|
for (const file of configFiles) {
|
|
5668
5683
|
try {
|
|
5669
|
-
const hash =
|
|
5684
|
+
const hash = execSync9(
|
|
5670
5685
|
`git log -1 --format=%H -- "${file}"`,
|
|
5671
5686
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5672
5687
|
).trim();
|
|
@@ -5675,7 +5690,7 @@ function detectGitDrift(dir) {
|
|
|
5675
5690
|
latestConfigCommitHash = hash;
|
|
5676
5691
|
} else {
|
|
5677
5692
|
try {
|
|
5678
|
-
|
|
5693
|
+
execSync9(
|
|
5679
5694
|
`git merge-base --is-ancestor ${latestConfigCommitHash} ${hash}`,
|
|
5680
5695
|
{ cwd: dir, stdio: ["pipe", "pipe", "pipe"] }
|
|
5681
5696
|
);
|
|
@@ -5690,12 +5705,12 @@ function detectGitDrift(dir) {
|
|
|
5690
5705
|
return { commitsSinceConfigUpdate: 0, lastConfigCommit: null, isGitRepo: true };
|
|
5691
5706
|
}
|
|
5692
5707
|
try {
|
|
5693
|
-
const countStr =
|
|
5708
|
+
const countStr = execSync9(
|
|
5694
5709
|
`git rev-list --count ${latestConfigCommitHash}..HEAD`,
|
|
5695
5710
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5696
5711
|
).trim();
|
|
5697
5712
|
const commitsSince = parseInt(countStr, 10) || 0;
|
|
5698
|
-
const lastDate =
|
|
5713
|
+
const lastDate = execSync9(
|
|
5699
5714
|
`git log -1 --format=%ci ${latestConfigCommitHash}`,
|
|
5700
5715
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5701
5716
|
).trim();
|
|
@@ -5767,12 +5782,12 @@ function checkAccuracy(dir) {
|
|
|
5767
5782
|
|
|
5768
5783
|
// src/scoring/checks/freshness.ts
|
|
5769
5784
|
import { existsSync as existsSync5, statSync as statSync3 } from "fs";
|
|
5770
|
-
import { execSync as
|
|
5785
|
+
import { execSync as execSync10 } from "child_process";
|
|
5771
5786
|
import { join as join6 } from "path";
|
|
5772
5787
|
function getCommitsSinceConfigUpdate(dir) {
|
|
5773
5788
|
const configFiles = ["CLAUDE.md", "AGENTS.md", ".cursorrules"];
|
|
5774
5789
|
try {
|
|
5775
|
-
const headTimestamp =
|
|
5790
|
+
const headTimestamp = execSync10(
|
|
5776
5791
|
"git log -1 --format=%ct HEAD",
|
|
5777
5792
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5778
5793
|
).trim();
|
|
@@ -5792,12 +5807,12 @@ function getCommitsSinceConfigUpdate(dir) {
|
|
|
5792
5807
|
}
|
|
5793
5808
|
for (const file of configFiles) {
|
|
5794
5809
|
try {
|
|
5795
|
-
const hash =
|
|
5810
|
+
const hash = execSync10(
|
|
5796
5811
|
`git log -1 --format=%H -- "${file}"`,
|
|
5797
5812
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5798
5813
|
).trim();
|
|
5799
5814
|
if (hash) {
|
|
5800
|
-
const countStr =
|
|
5815
|
+
const countStr = execSync10(
|
|
5801
5816
|
`git rev-list --count ${hash}..HEAD`,
|
|
5802
5817
|
{ cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
5803
5818
|
).trim();
|
|
@@ -5915,11 +5930,11 @@ function checkFreshness(dir) {
|
|
|
5915
5930
|
|
|
5916
5931
|
// src/scoring/checks/bonus.ts
|
|
5917
5932
|
import { existsSync as existsSync6, readdirSync as readdirSync3 } from "fs";
|
|
5918
|
-
import { execSync as
|
|
5933
|
+
import { execSync as execSync11 } from "child_process";
|
|
5919
5934
|
import { join as join7 } from "path";
|
|
5920
5935
|
function hasPreCommitHook(dir) {
|
|
5921
5936
|
try {
|
|
5922
|
-
const gitDir =
|
|
5937
|
+
const gitDir = execSync11("git rev-parse --git-dir", { cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
5923
5938
|
const hookPath = join7(gitDir, "hooks", "pre-commit");
|
|
5924
5939
|
const content = readFileOrNull(hookPath);
|
|
5925
5940
|
return content ? content.includes("caliber") : false;
|
|
@@ -6348,7 +6363,7 @@ import fs24 from "fs";
|
|
|
6348
6363
|
import path20 from "path";
|
|
6349
6364
|
import os5 from "os";
|
|
6350
6365
|
import crypto4 from "crypto";
|
|
6351
|
-
import { execSync as
|
|
6366
|
+
import { execSync as execSync12 } from "child_process";
|
|
6352
6367
|
var CONFIG_DIR2 = path20.join(os5.homedir(), ".caliber");
|
|
6353
6368
|
var CONFIG_FILE2 = path20.join(CONFIG_DIR2, "config.json");
|
|
6354
6369
|
var runtimeDisabled = false;
|
|
@@ -6375,7 +6390,7 @@ function getMachineId() {
|
|
|
6375
6390
|
}
|
|
6376
6391
|
function getGitEmailHash() {
|
|
6377
6392
|
try {
|
|
6378
|
-
const email =
|
|
6393
|
+
const email = execSync12("git config user.email", { encoding: "utf-8" }).trim();
|
|
6379
6394
|
if (!email) return void 0;
|
|
6380
6395
|
return crypto4.createHash("sha256").update(email).digest("hex");
|
|
6381
6396
|
} catch {
|
|
@@ -9469,7 +9484,7 @@ import chalk19 from "chalk";
|
|
|
9469
9484
|
import ora6 from "ora";
|
|
9470
9485
|
|
|
9471
9486
|
// src/lib/git-diff.ts
|
|
9472
|
-
import { execSync as
|
|
9487
|
+
import { execSync as execSync14 } from "child_process";
|
|
9473
9488
|
var MAX_DIFF_BYTES = 1e5;
|
|
9474
9489
|
var DOC_PATTERNS = [
|
|
9475
9490
|
"CLAUDE.md",
|
|
@@ -9484,7 +9499,7 @@ function excludeArgs() {
|
|
|
9484
9499
|
}
|
|
9485
9500
|
function safeExec(cmd) {
|
|
9486
9501
|
try {
|
|
9487
|
-
return
|
|
9502
|
+
return execSync14(cmd, {
|
|
9488
9503
|
encoding: "utf-8",
|
|
9489
9504
|
stdio: ["pipe", "pipe", "pipe"],
|
|
9490
9505
|
maxBuffer: 10 * 1024 * 1024
|
|
@@ -10005,7 +10020,7 @@ import fs39 from "fs";
|
|
|
10005
10020
|
init_resolve_caliber();
|
|
10006
10021
|
import fs38 from "fs";
|
|
10007
10022
|
import path30 from "path";
|
|
10008
|
-
import { execSync as
|
|
10023
|
+
import { execSync as execSync15 } from "child_process";
|
|
10009
10024
|
var SETTINGS_PATH2 = path30.join(".claude", "settings.json");
|
|
10010
10025
|
var REFRESH_TAIL = "refresh --quiet";
|
|
10011
10026
|
var HOOK_DESCRIPTION = "Caliber: auto-refreshing docs based on code changes";
|
|
@@ -10085,7 +10100,7 @@ ${PRECOMMIT_END}`;
|
|
|
10085
10100
|
}
|
|
10086
10101
|
function getGitHooksDir() {
|
|
10087
10102
|
try {
|
|
10088
|
-
const gitDir =
|
|
10103
|
+
const gitDir = execSync15("git rev-parse --git-dir", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
10089
10104
|
return path30.join(gitDir, "hooks");
|
|
10090
10105
|
} catch {
|
|
10091
10106
|
return null;
|
|
@@ -10398,15 +10413,15 @@ var DEFAULT_STATE = {
|
|
|
10398
10413
|
lastAnalysisEventCount: 0
|
|
10399
10414
|
};
|
|
10400
10415
|
function ensureLearningDir() {
|
|
10401
|
-
if (!fs40.existsSync(
|
|
10402
|
-
fs40.mkdirSync(
|
|
10416
|
+
if (!fs40.existsSync(getLearningDir())) {
|
|
10417
|
+
fs40.mkdirSync(getLearningDir(), { recursive: true });
|
|
10403
10418
|
}
|
|
10404
10419
|
}
|
|
10405
10420
|
function sessionFilePath() {
|
|
10406
|
-
return path31.join(
|
|
10421
|
+
return path31.join(getLearningDir(), LEARNING_SESSION_FILE);
|
|
10407
10422
|
}
|
|
10408
10423
|
function stateFilePath() {
|
|
10409
|
-
return path31.join(
|
|
10424
|
+
return path31.join(getLearningDir(), LEARNING_STATE_FILE);
|
|
10410
10425
|
}
|
|
10411
10426
|
function truncateResponse(response) {
|
|
10412
10427
|
const str = JSON.stringify(response);
|
|
@@ -10478,7 +10493,7 @@ function resetState() {
|
|
|
10478
10493
|
var LOCK_FILE2 = "finalize.lock";
|
|
10479
10494
|
var LOCK_STALE_MS = 5 * 60 * 1e3;
|
|
10480
10495
|
function lockFilePath() {
|
|
10481
|
-
return path31.join(
|
|
10496
|
+
return path31.join(getLearningDir(), LOCK_FILE2);
|
|
10482
10497
|
}
|
|
10483
10498
|
function acquireFinalizeLock() {
|
|
10484
10499
|
ensureLearningDir();
|
|
@@ -10565,19 +10580,21 @@ function sanitizeSecrets(text) {
|
|
|
10565
10580
|
import fs41 from "fs";
|
|
10566
10581
|
import path32 from "path";
|
|
10567
10582
|
import chalk22 from "chalk";
|
|
10568
|
-
|
|
10583
|
+
function notificationFilePath() {
|
|
10584
|
+
return path32.join(getLearningDir(), "last-finalize-summary.json");
|
|
10585
|
+
}
|
|
10569
10586
|
function writeFinalizeSummary(summary) {
|
|
10570
10587
|
try {
|
|
10571
10588
|
ensureLearningDir();
|
|
10572
|
-
fs41.writeFileSync(
|
|
10589
|
+
fs41.writeFileSync(notificationFilePath(), JSON.stringify(summary, null, 2));
|
|
10573
10590
|
} catch {
|
|
10574
10591
|
}
|
|
10575
10592
|
}
|
|
10576
10593
|
function checkPendingNotifications() {
|
|
10577
10594
|
try {
|
|
10578
|
-
if (!fs41.existsSync(
|
|
10579
|
-
const raw = fs41.readFileSync(
|
|
10580
|
-
fs41.unlinkSync(
|
|
10595
|
+
if (!fs41.existsSync(notificationFilePath())) return;
|
|
10596
|
+
const raw = fs41.readFileSync(notificationFilePath(), "utf-8");
|
|
10597
|
+
fs41.unlinkSync(notificationFilePath());
|
|
10581
10598
|
const summary = JSON.parse(raw);
|
|
10582
10599
|
if (!summary.newItemCount || summary.newItemCount === 0) return;
|
|
10583
10600
|
const wasteLabel = summary.wasteTokens > 0 ? ` (~${summary.wasteTokens.toLocaleString()} wasted tokens captured)` : "";
|
|
@@ -10593,7 +10610,7 @@ function checkPendingNotifications() {
|
|
|
10593
10610
|
console.log("");
|
|
10594
10611
|
} catch {
|
|
10595
10612
|
try {
|
|
10596
|
-
fs41.unlinkSync(
|
|
10613
|
+
fs41.unlinkSync(notificationFilePath());
|
|
10597
10614
|
} catch {
|
|
10598
10615
|
}
|
|
10599
10616
|
}
|
|
@@ -10632,10 +10649,25 @@ function trimEventsToFit(events, maxTokens) {
|
|
|
10632
10649
|
if (estimateTokens(formatted) <= maxTokens) return kept;
|
|
10633
10650
|
return kept.slice(-50);
|
|
10634
10651
|
}
|
|
10652
|
+
function normalizeAnalysisResult(parsed) {
|
|
10653
|
+
let section = parsed.claudeMdLearnedSection ?? null;
|
|
10654
|
+
if (Array.isArray(section)) {
|
|
10655
|
+
section = section.join("\n");
|
|
10656
|
+
}
|
|
10657
|
+
if (section !== null && typeof section !== "string") {
|
|
10658
|
+
section = String(section);
|
|
10659
|
+
}
|
|
10660
|
+
return {
|
|
10661
|
+
...parsed,
|
|
10662
|
+
claudeMdLearnedSection: section,
|
|
10663
|
+
skills: parsed.skills ?? null,
|
|
10664
|
+
explanations: parsed.explanations ?? []
|
|
10665
|
+
};
|
|
10666
|
+
}
|
|
10635
10667
|
function parseAnalysisResponse(raw) {
|
|
10636
10668
|
const cleaned = stripMarkdownFences(raw);
|
|
10637
10669
|
try {
|
|
10638
|
-
return JSON.parse(cleaned);
|
|
10670
|
+
return normalizeAnalysisResult(JSON.parse(cleaned));
|
|
10639
10671
|
} catch {
|
|
10640
10672
|
}
|
|
10641
10673
|
const json = extractJson(cleaned);
|
|
@@ -10643,7 +10675,7 @@ function parseAnalysisResponse(raw) {
|
|
|
10643
10675
|
return { claudeMdLearnedSection: null, skills: null, explanations: ["LLM response could not be parsed."] };
|
|
10644
10676
|
}
|
|
10645
10677
|
try {
|
|
10646
|
-
return JSON.parse(json);
|
|
10678
|
+
return normalizeAnalysisResult(JSON.parse(json));
|
|
10647
10679
|
} catch {
|
|
10648
10680
|
return { claudeMdLearnedSection: null, skills: null, explanations: ["LLM response contained invalid JSON."] };
|
|
10649
10681
|
}
|
|
@@ -10745,7 +10777,7 @@ var DEFAULT_TOTALS = {
|
|
|
10745
10777
|
lastSessionTimestamp: ""
|
|
10746
10778
|
};
|
|
10747
10779
|
function roiFilePath() {
|
|
10748
|
-
return path33.join(
|
|
10780
|
+
return path33.join(getLearningDir(), LEARNING_ROI_FILE);
|
|
10749
10781
|
}
|
|
10750
10782
|
function readROIStats() {
|
|
10751
10783
|
const filePath = roiFilePath();
|
|
@@ -10972,8 +11004,8 @@ var AUTO_SETTLE_MS = 200;
|
|
|
10972
11004
|
var INCREMENTAL_INTERVAL = 50;
|
|
10973
11005
|
function writeFinalizeError(message) {
|
|
10974
11006
|
try {
|
|
10975
|
-
const errorPath = path34.join(
|
|
10976
|
-
if (!fs43.existsSync(
|
|
11007
|
+
const errorPath = path34.join(getLearningDir(), LEARNING_LAST_ERROR_FILE);
|
|
11008
|
+
if (!fs43.existsSync(getLearningDir())) fs43.mkdirSync(getLearningDir(), { recursive: true });
|
|
10977
11009
|
fs43.writeFileSync(errorPath, JSON.stringify({
|
|
10978
11010
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10979
11011
|
error: message,
|
|
@@ -10984,7 +11016,7 @@ function writeFinalizeError(message) {
|
|
|
10984
11016
|
}
|
|
10985
11017
|
function readFinalizeError() {
|
|
10986
11018
|
try {
|
|
10987
|
-
const errorPath = path34.join(
|
|
11019
|
+
const errorPath = path34.join(getLearningDir(), LEARNING_LAST_ERROR_FILE);
|
|
10988
11020
|
if (!fs43.existsSync(errorPath)) return null;
|
|
10989
11021
|
return JSON.parse(fs43.readFileSync(errorPath, "utf-8"));
|
|
10990
11022
|
} catch {
|
|
@@ -11033,8 +11065,8 @@ async function learnObserveCommand(options) {
|
|
|
11033
11065
|
const { resolveCaliber: resolveCaliber2 } = await Promise.resolve().then(() => (init_resolve_caliber(), resolve_caliber_exports));
|
|
11034
11066
|
const bin = resolveCaliber2();
|
|
11035
11067
|
const { spawn: spawn4 } = await import("child_process");
|
|
11036
|
-
const logPath = path34.join(
|
|
11037
|
-
if (!fs43.existsSync(
|
|
11068
|
+
const logPath = path34.join(getLearningDir(), LEARNING_FINALIZE_LOG);
|
|
11069
|
+
if (!fs43.existsSync(getLearningDir())) fs43.mkdirSync(getLearningDir(), { recursive: true });
|
|
11038
11070
|
const logFd = fs43.openSync(logPath, "a");
|
|
11039
11071
|
spawn4(bin, ["learn", "finalize", "--auto", "--incremental"], {
|
|
11040
11072
|
detached: true,
|
|
@@ -11323,7 +11355,7 @@ async function learnStatusCommand() {
|
|
|
11323
11355
|
if (lastError) {
|
|
11324
11356
|
console.log(`Last error: ${chalk23.red(lastError.error)}`);
|
|
11325
11357
|
console.log(chalk23.dim(` at ${lastError.timestamp}`));
|
|
11326
|
-
const logPath = path34.join(
|
|
11358
|
+
const logPath = path34.join(getLearningDir(), LEARNING_FINALIZE_LOG);
|
|
11327
11359
|
if (fs43.existsSync(logPath)) {
|
|
11328
11360
|
console.log(chalk23.dim(` Full log: ${logPath}`));
|
|
11329
11361
|
}
|
|
@@ -11845,7 +11877,7 @@ learn.command("add <content>").description("Add a learning directly (used by age
|
|
|
11845
11877
|
import fs47 from "fs";
|
|
11846
11878
|
import path38 from "path";
|
|
11847
11879
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11848
|
-
import { execSync as
|
|
11880
|
+
import { execSync as execSync16 } from "child_process";
|
|
11849
11881
|
import chalk27 from "chalk";
|
|
11850
11882
|
import ora8 from "ora";
|
|
11851
11883
|
import confirm2 from "@inquirer/confirm";
|
|
@@ -11875,7 +11907,7 @@ function isNewer(registry, current) {
|
|
|
11875
11907
|
}
|
|
11876
11908
|
function getInstalledVersion() {
|
|
11877
11909
|
try {
|
|
11878
|
-
const globalRoot =
|
|
11910
|
+
const globalRoot = execSync16("npm root -g", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
11879
11911
|
const pkgPath = path38.join(globalRoot, "@rely-ai", "caliber", "package.json");
|
|
11880
11912
|
return JSON.parse(fs47.readFileSync(pkgPath, "utf-8")).version;
|
|
11881
11913
|
} catch {
|
|
@@ -11923,7 +11955,7 @@ Update available: ${current} -> ${latest}`)
|
|
|
11923
11955
|
const tag = channel === "latest" ? latest : channel;
|
|
11924
11956
|
const spinner = ora8("Updating caliber...").start();
|
|
11925
11957
|
try {
|
|
11926
|
-
|
|
11958
|
+
execSync16(`npm install -g @rely-ai/caliber@${tag}`, {
|
|
11927
11959
|
stdio: "pipe",
|
|
11928
11960
|
timeout: 12e4,
|
|
11929
11961
|
env: { ...process.env, npm_config_fund: "false", npm_config_audit: "false" }
|
|
@@ -11940,7 +11972,7 @@ Update available: ${current} -> ${latest}`)
|
|
|
11940
11972
|
console.log(chalk27.dim(`
|
|
11941
11973
|
Restarting: caliber ${args.join(" ")}
|
|
11942
11974
|
`));
|
|
11943
|
-
|
|
11975
|
+
execSync16(`caliber ${args.map((a) => JSON.stringify(a)).join(" ")}`, {
|
|
11944
11976
|
stdio: "inherit",
|
|
11945
11977
|
env: { ...process.env, CALIBER_SKIP_UPDATE_CHECK: "1" }
|
|
11946
11978
|
});
|
package/package.json
CHANGED