@rely-ai/caliber 1.45.3 → 1.45.4
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 +58 -39
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -2974,7 +2974,7 @@ function cleanClaudeEnv() {
|
|
|
2974
2974
|
}
|
|
2975
2975
|
function spawnClaude(args) {
|
|
2976
2976
|
const bin = resolveClaudeBin();
|
|
2977
|
-
const env = cleanClaudeEnv();
|
|
2977
|
+
const env = { ...cleanClaudeEnv(), CALIBER_SPAWNED: "1" };
|
|
2978
2978
|
return IS_WINDOWS2 ? spawn2([bin, ...args].join(" "), {
|
|
2979
2979
|
cwd: process.cwd(),
|
|
2980
2980
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -12084,6 +12084,7 @@ import pLimit from "p-limit";
|
|
|
12084
12084
|
// src/lib/git-diff.ts
|
|
12085
12085
|
import { execSync as execSync17 } from "child_process";
|
|
12086
12086
|
var MAX_DIFF_BYTES = 1e5;
|
|
12087
|
+
var MAX_CHANGED_FILES = 500;
|
|
12087
12088
|
var DOC_PATTERNS = [
|
|
12088
12089
|
"CLAUDE.md",
|
|
12089
12090
|
"AGENTS.md",
|
|
@@ -12145,9 +12146,7 @@ function collectDiff(lastSha) {
|
|
|
12145
12146
|
if (untrackedFiles) {
|
|
12146
12147
|
changedFiles.push(...untrackedFiles.split("\n").filter(Boolean));
|
|
12147
12148
|
}
|
|
12148
|
-
changedFiles = [...new Set(changedFiles)].filter(
|
|
12149
|
-
(f) => !DOC_PATTERNS.some((p) => f === p || f.startsWith(p))
|
|
12150
|
-
);
|
|
12149
|
+
changedFiles = [...new Set(changedFiles)].filter((f) => !DOC_PATTERNS.some((p) => f === p || f.startsWith(p))).slice(0, MAX_CHANGED_FILES);
|
|
12151
12150
|
const totalSize = committedDiff.length + stagedDiff.length + unstagedDiff.length;
|
|
12152
12151
|
if (totalSize > MAX_DIFF_BYTES) {
|
|
12153
12152
|
const ratio = MAX_DIFF_BYTES / totalSize;
|
|
@@ -12256,6 +12255,13 @@ function writeRefreshDocs(docs, dir = ".") {
|
|
|
12256
12255
|
// src/ai/refresh.ts
|
|
12257
12256
|
init_config();
|
|
12258
12257
|
init_pre_commit_block();
|
|
12258
|
+
var MAX_EXISTING_DOCS_CHARS = 6e4;
|
|
12259
|
+
var MIN_CHARS_PER_ENTRY = 2e3;
|
|
12260
|
+
function truncateAtLineEnd2(text, maxChars) {
|
|
12261
|
+
if (text.length <= maxChars) return text;
|
|
12262
|
+
const cut = text.lastIndexOf("\n", maxChars);
|
|
12263
|
+
return (cut === -1 ? text.slice(0, maxChars) : text.slice(0, cut)) + "\n...[truncated]";
|
|
12264
|
+
}
|
|
12259
12265
|
async function refreshDocs(diff, existingDocs, projectContext, learnedSection, sources2, scope) {
|
|
12260
12266
|
const prompt = buildRefreshPrompt(
|
|
12261
12267
|
diff,
|
|
@@ -12312,56 +12318,66 @@ Changed files: ${diff.changedFiles.join(", ")}`);
|
|
|
12312
12318
|
parts.push(diff.unstaged);
|
|
12313
12319
|
}
|
|
12314
12320
|
parts.push("\n--- Current Documentation ---");
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
}
|
|
12321
|
+
const docEntries = [];
|
|
12322
|
+
if (existingDocs.agentsMd)
|
|
12323
|
+
docEntries.push({
|
|
12324
|
+
header: "\n[AGENTS.md]",
|
|
12325
|
+
content: stripManagedBlocks(existingDocs.agentsMd)
|
|
12326
|
+
});
|
|
12327
|
+
if (existingDocs.claudeMd)
|
|
12328
|
+
docEntries.push({
|
|
12329
|
+
header: "\n[CLAUDE.md]",
|
|
12330
|
+
content: stripManagedBlocks(existingDocs.claudeMd)
|
|
12331
|
+
});
|
|
12332
|
+
if (existingDocs.readmeMd)
|
|
12333
|
+
docEntries.push({ header: "\n[README.md]", content: existingDocs.readmeMd });
|
|
12334
|
+
if (existingDocs.cursorrules)
|
|
12335
|
+
docEntries.push({ header: "\n[.cursorrules]", content: existingDocs.cursorrules });
|
|
12331
12336
|
if (existingDocs.claudeSkills?.length) {
|
|
12332
|
-
for (const skill of existingDocs.claudeSkills)
|
|
12333
|
-
|
|
12334
|
-
[.claude/skills/${skill.filename}]
|
|
12335
|
-
parts.push(skill.content);
|
|
12336
|
-
}
|
|
12337
|
+
for (const skill of existingDocs.claudeSkills)
|
|
12338
|
+
docEntries.push({ header: `
|
|
12339
|
+
[.claude/skills/${skill.filename}]`, content: skill.content });
|
|
12337
12340
|
}
|
|
12338
12341
|
if (existingDocs.claudeRules?.length) {
|
|
12339
12342
|
for (const rule of existingDocs.claudeRules) {
|
|
12340
12343
|
if (rule.filename.startsWith(CALIBER_MANAGED_PREFIX)) continue;
|
|
12341
|
-
|
|
12342
|
-
[.claude/rules/${rule.filename}]
|
|
12343
|
-
parts.push(rule.content);
|
|
12344
|
+
docEntries.push({ header: `
|
|
12345
|
+
[.claude/rules/${rule.filename}]`, content: rule.content });
|
|
12344
12346
|
}
|
|
12345
12347
|
}
|
|
12346
12348
|
if (existingDocs.cursorRules?.length) {
|
|
12347
12349
|
for (const rule of existingDocs.cursorRules) {
|
|
12348
12350
|
if (rule.filename.startsWith(CALIBER_MANAGED_PREFIX)) continue;
|
|
12349
|
-
|
|
12350
|
-
[.cursor/rules/${rule.filename}]
|
|
12351
|
-
parts.push(rule.content);
|
|
12351
|
+
docEntries.push({ header: `
|
|
12352
|
+
[.cursor/rules/${rule.filename}]`, content: rule.content });
|
|
12352
12353
|
}
|
|
12353
12354
|
}
|
|
12354
|
-
if (existingDocs.copilotInstructions)
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12355
|
+
if (existingDocs.copilotInstructions)
|
|
12356
|
+
docEntries.push({
|
|
12357
|
+
header: "\n[.github/copilot-instructions.md]",
|
|
12358
|
+
content: stripManagedBlocks(existingDocs.copilotInstructions)
|
|
12359
|
+
});
|
|
12358
12360
|
if (existingDocs.copilotInstructionFiles?.length) {
|
|
12359
|
-
for (const file of existingDocs.copilotInstructionFiles)
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12361
|
+
for (const file of existingDocs.copilotInstructionFiles)
|
|
12362
|
+
docEntries.push({
|
|
12363
|
+
header: `
|
|
12364
|
+
[.github/instructions/${file.filename}]`,
|
|
12365
|
+
content: file.content
|
|
12366
|
+
});
|
|
12367
|
+
}
|
|
12368
|
+
const totalDocChars = docEntries.reduce((sum, e) => sum + e.content.length, 0);
|
|
12369
|
+
if (totalDocChars > MAX_EXISTING_DOCS_CHARS) {
|
|
12370
|
+
const ratio = MAX_EXISTING_DOCS_CHARS / totalDocChars;
|
|
12371
|
+
for (const entry of docEntries) {
|
|
12372
|
+
const proportional = Math.floor(entry.content.length * ratio);
|
|
12373
|
+
const floor = Math.min(MIN_CHARS_PER_ENTRY, entry.content.length);
|
|
12374
|
+
entry.content = truncateAtLineEnd2(entry.content, Math.max(proportional, floor));
|
|
12363
12375
|
}
|
|
12364
12376
|
}
|
|
12377
|
+
for (const { header, content } of docEntries) {
|
|
12378
|
+
parts.push(header);
|
|
12379
|
+
parts.push(content);
|
|
12380
|
+
}
|
|
12365
12381
|
if (existingDocs.includableDocs?.length) {
|
|
12366
12382
|
parts.push(`
|
|
12367
12383
|
--- Existing Documentation Files (use @include) ---`);
|
|
@@ -12967,6 +12983,7 @@ async function refreshSingleRepo(repoDir, options) {
|
|
|
12967
12983
|
}
|
|
12968
12984
|
async function refreshCommand(options) {
|
|
12969
12985
|
const quiet = !!options.quiet;
|
|
12986
|
+
if (quiet && process.env.CALIBER_SPAWNED === "1") return;
|
|
12970
12987
|
if (quiet) {
|
|
12971
12988
|
const { isCaliberRunning: isCaliberRunning2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
|
|
12972
12989
|
if (isCaliberRunning2()) return;
|
|
@@ -13934,6 +13951,7 @@ function readFinalizeError() {
|
|
|
13934
13951
|
}
|
|
13935
13952
|
}
|
|
13936
13953
|
async function learnObserveCommand(options) {
|
|
13954
|
+
if (process.env.CALIBER_SPAWNED === "1") return;
|
|
13937
13955
|
try {
|
|
13938
13956
|
const raw = await readStdin();
|
|
13939
13957
|
if (!raw.trim()) return;
|
|
@@ -14014,6 +14032,7 @@ async function learnObserveCommand(options) {
|
|
|
14014
14032
|
async function learnFinalizeCommand(options) {
|
|
14015
14033
|
const isAuto = options?.auto === true;
|
|
14016
14034
|
const isIncremental = options?.incremental === true;
|
|
14035
|
+
if (isAuto && process.env.CALIBER_SPAWNED === "1") return;
|
|
14017
14036
|
if (!options?.force && !isAuto) {
|
|
14018
14037
|
const { isCaliberRunning: isCaliberRunning2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
|
|
14019
14038
|
if (isCaliberRunning2()) {
|
package/package.json
CHANGED