@rely-ai/caliber 1.45.3 → 1.46.0

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.
Files changed (2) hide show
  1. package/dist/bin.js +78 -49
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -2433,6 +2433,15 @@ var VertexProvider = class {
2433
2433
 
2434
2434
  // src/llm/openai-compat.ts
2435
2435
  import OpenAI from "openai";
2436
+ var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
2437
+ function resolveTimeoutMs() {
2438
+ const raw = process.env.CALIBER_OPENAI_TIMEOUT_MS;
2439
+ if (raw) {
2440
+ const parsed = parseInt(raw, 10);
2441
+ if (Number.isFinite(parsed) && parsed >= 1e3) return parsed;
2442
+ }
2443
+ return DEFAULT_TIMEOUT_MS;
2444
+ }
2436
2445
  var OpenAICompatProvider = class {
2437
2446
  client;
2438
2447
  defaultModel;
@@ -2440,7 +2449,8 @@ var OpenAICompatProvider = class {
2440
2449
  constructor(config, options) {
2441
2450
  this.client = new OpenAI({
2442
2451
  apiKey: config.apiKey,
2443
- ...config.baseUrl && { baseURL: config.baseUrl }
2452
+ ...config.baseUrl && { baseURL: config.baseUrl },
2453
+ timeout: resolveTimeoutMs()
2444
2454
  });
2445
2455
  this.defaultModel = config.model;
2446
2456
  this.temperature = options?.temperature;
@@ -2623,7 +2633,7 @@ function resolveAgentBin() {
2623
2633
  _agentBin = "agent";
2624
2634
  return _agentBin;
2625
2635
  }
2626
- var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
2636
+ var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
2627
2637
  var SIGKILL_DELAY_MS = 5e3;
2628
2638
  var STDERR_MAX_BYTES = 10 * 1024;
2629
2639
  var CursorAcpProvider = class {
@@ -2636,9 +2646,9 @@ var CursorAcpProvider = class {
2636
2646
  this.defaultModel = config.model || "sonnet-4.6";
2637
2647
  this.cursorApiKey = process.env.CURSOR_API_KEY ?? process.env.CURSOR_AUTH_TOKEN;
2638
2648
  const envTimeout = process.env.CALIBER_CURSOR_TIMEOUT_MS;
2639
- this.timeoutMs = envTimeout ? parseInt(envTimeout, 10) : DEFAULT_TIMEOUT_MS;
2649
+ this.timeoutMs = envTimeout ? parseInt(envTimeout, 10) : DEFAULT_TIMEOUT_MS2;
2640
2650
  if (!Number.isFinite(this.timeoutMs) || this.timeoutMs < 1e3) {
2641
- this.timeoutMs = DEFAULT_TIMEOUT_MS;
2651
+ this.timeoutMs = DEFAULT_TIMEOUT_MS2;
2642
2652
  }
2643
2653
  }
2644
2654
  async call(options) {
@@ -2925,7 +2935,7 @@ function isCursorLoggedIn() {
2925
2935
  // src/llm/claude-cli.ts
2926
2936
  import fs7 from "fs";
2927
2937
  import { spawn as spawn2, execSync as execSync7, execFileSync as execFileSync2 } from "child_process";
2928
- var DEFAULT_TIMEOUT_MS2 = 10 * 60 * 1e3;
2938
+ var DEFAULT_TIMEOUT_MS3 = 10 * 60 * 1e3;
2929
2939
  var IS_WINDOWS2 = process.platform === "win32";
2930
2940
  function candidateClaudePaths() {
2931
2941
  if (IS_WINDOWS2) return [];
@@ -2974,7 +2984,7 @@ function cleanClaudeEnv() {
2974
2984
  }
2975
2985
  function spawnClaude(args) {
2976
2986
  const bin = resolveClaudeBin();
2977
- const env = cleanClaudeEnv();
2987
+ const env = { ...cleanClaudeEnv(), CALIBER_SPAWNED: "1" };
2978
2988
  return IS_WINDOWS2 ? spawn2([bin, ...args].join(" "), {
2979
2989
  cwd: process.cwd(),
2980
2990
  stdio: ["pipe", "pipe", "pipe"],
@@ -2992,9 +3002,9 @@ var ClaudeCliProvider = class {
2992
3002
  constructor(config) {
2993
3003
  this.defaultModel = config.model || "default";
2994
3004
  const envTimeout = process.env.CALIBER_CLAUDE_CLI_TIMEOUT_MS;
2995
- this.timeoutMs = envTimeout ? parseInt(envTimeout, 10) : DEFAULT_TIMEOUT_MS2;
3005
+ this.timeoutMs = envTimeout ? parseInt(envTimeout, 10) : DEFAULT_TIMEOUT_MS3;
2996
3006
  if (!Number.isFinite(this.timeoutMs) || this.timeoutMs < 1e3) {
2997
- this.timeoutMs = DEFAULT_TIMEOUT_MS2;
3007
+ this.timeoutMs = DEFAULT_TIMEOUT_MS3;
2998
3008
  }
2999
3009
  }
3000
3010
  async call(options) {
@@ -3160,7 +3170,7 @@ function isClaudeCliLoggedIn() {
3160
3170
  // src/llm/opencode.ts
3161
3171
  import { spawn as spawn3, execSync as execSync8 } from "child_process";
3162
3172
  var OPENCODE_BIN = "opencode";
3163
- var DEFAULT_TIMEOUT_MS3 = 10 * 60 * 1e3;
3173
+ var DEFAULT_TIMEOUT_MS4 = 10 * 60 * 1e3;
3164
3174
  var IS_WINDOWS3 = process.platform === "win32";
3165
3175
  var cachedLoggedIn2 = null;
3166
3176
  function isOpenCodeAvailable() {
@@ -3322,9 +3332,9 @@ var OpenCodeProvider = class {
3322
3332
  constructor(config) {
3323
3333
  this.defaultModel = config.model || "default";
3324
3334
  const envTimeout = process.env.CALIBER_OPENCODE_TIMEOUT_MS;
3325
- this.timeoutMs = envTimeout ? parseInt(envTimeout, 10) : DEFAULT_TIMEOUT_MS3;
3335
+ this.timeoutMs = envTimeout ? parseInt(envTimeout, 10) : DEFAULT_TIMEOUT_MS4;
3326
3336
  if (!Number.isFinite(this.timeoutMs) || this.timeoutMs < 1e3) {
3327
- this.timeoutMs = DEFAULT_TIMEOUT_MS3;
3337
+ this.timeoutMs = DEFAULT_TIMEOUT_MS4;
3328
3338
  }
3329
3339
  }
3330
3340
  async call(options) {
@@ -12084,6 +12094,7 @@ import pLimit from "p-limit";
12084
12094
  // src/lib/git-diff.ts
12085
12095
  import { execSync as execSync17 } from "child_process";
12086
12096
  var MAX_DIFF_BYTES = 1e5;
12097
+ var MAX_CHANGED_FILES = 500;
12087
12098
  var DOC_PATTERNS = [
12088
12099
  "CLAUDE.md",
12089
12100
  "AGENTS.md",
@@ -12145,9 +12156,7 @@ function collectDiff(lastSha) {
12145
12156
  if (untrackedFiles) {
12146
12157
  changedFiles.push(...untrackedFiles.split("\n").filter(Boolean));
12147
12158
  }
12148
- changedFiles = [...new Set(changedFiles)].filter(
12149
- (f) => !DOC_PATTERNS.some((p) => f === p || f.startsWith(p))
12150
- );
12159
+ changedFiles = [...new Set(changedFiles)].filter((f) => !DOC_PATTERNS.some((p) => f === p || f.startsWith(p))).slice(0, MAX_CHANGED_FILES);
12151
12160
  const totalSize = committedDiff.length + stagedDiff.length + unstagedDiff.length;
12152
12161
  if (totalSize > MAX_DIFF_BYTES) {
12153
12162
  const ratio = MAX_DIFF_BYTES / totalSize;
@@ -12256,6 +12265,13 @@ function writeRefreshDocs(docs, dir = ".") {
12256
12265
  // src/ai/refresh.ts
12257
12266
  init_config();
12258
12267
  init_pre_commit_block();
12268
+ var MAX_EXISTING_DOCS_CHARS = 6e4;
12269
+ var MIN_CHARS_PER_ENTRY = 2e3;
12270
+ function truncateAtLineEnd2(text, maxChars) {
12271
+ if (text.length <= maxChars) return text;
12272
+ const cut = text.lastIndexOf("\n", maxChars);
12273
+ return (cut === -1 ? text.slice(0, maxChars) : text.slice(0, cut)) + "\n...[truncated]";
12274
+ }
12259
12275
  async function refreshDocs(diff, existingDocs, projectContext, learnedSection, sources2, scope) {
12260
12276
  const prompt = buildRefreshPrompt(
12261
12277
  diff,
@@ -12312,56 +12328,66 @@ Changed files: ${diff.changedFiles.join(", ")}`);
12312
12328
  parts.push(diff.unstaged);
12313
12329
  }
12314
12330
  parts.push("\n--- Current Documentation ---");
12315
- if (existingDocs.agentsMd) {
12316
- parts.push("\n[AGENTS.md]");
12317
- parts.push(stripManagedBlocks(existingDocs.agentsMd));
12318
- }
12319
- if (existingDocs.claudeMd) {
12320
- parts.push("\n[CLAUDE.md]");
12321
- parts.push(stripManagedBlocks(existingDocs.claudeMd));
12322
- }
12323
- if (existingDocs.readmeMd) {
12324
- parts.push("\n[README.md]");
12325
- parts.push(existingDocs.readmeMd);
12326
- }
12327
- if (existingDocs.cursorrules) {
12328
- parts.push("\n[.cursorrules]");
12329
- parts.push(existingDocs.cursorrules);
12330
- }
12331
+ const docEntries = [];
12332
+ if (existingDocs.agentsMd)
12333
+ docEntries.push({
12334
+ header: "\n[AGENTS.md]",
12335
+ content: stripManagedBlocks(existingDocs.agentsMd)
12336
+ });
12337
+ if (existingDocs.claudeMd)
12338
+ docEntries.push({
12339
+ header: "\n[CLAUDE.md]",
12340
+ content: stripManagedBlocks(existingDocs.claudeMd)
12341
+ });
12342
+ if (existingDocs.readmeMd)
12343
+ docEntries.push({ header: "\n[README.md]", content: existingDocs.readmeMd });
12344
+ if (existingDocs.cursorrules)
12345
+ docEntries.push({ header: "\n[.cursorrules]", content: existingDocs.cursorrules });
12331
12346
  if (existingDocs.claudeSkills?.length) {
12332
- for (const skill of existingDocs.claudeSkills) {
12333
- parts.push(`
12334
- [.claude/skills/${skill.filename}]`);
12335
- parts.push(skill.content);
12336
- }
12347
+ for (const skill of existingDocs.claudeSkills)
12348
+ docEntries.push({ header: `
12349
+ [.claude/skills/${skill.filename}]`, content: skill.content });
12337
12350
  }
12338
12351
  if (existingDocs.claudeRules?.length) {
12339
12352
  for (const rule of existingDocs.claudeRules) {
12340
12353
  if (rule.filename.startsWith(CALIBER_MANAGED_PREFIX)) continue;
12341
- parts.push(`
12342
- [.claude/rules/${rule.filename}]`);
12343
- parts.push(rule.content);
12354
+ docEntries.push({ header: `
12355
+ [.claude/rules/${rule.filename}]`, content: rule.content });
12344
12356
  }
12345
12357
  }
12346
12358
  if (existingDocs.cursorRules?.length) {
12347
12359
  for (const rule of existingDocs.cursorRules) {
12348
12360
  if (rule.filename.startsWith(CALIBER_MANAGED_PREFIX)) continue;
12349
- parts.push(`
12350
- [.cursor/rules/${rule.filename}]`);
12351
- parts.push(rule.content);
12361
+ docEntries.push({ header: `
12362
+ [.cursor/rules/${rule.filename}]`, content: rule.content });
12352
12363
  }
12353
12364
  }
12354
- if (existingDocs.copilotInstructions) {
12355
- parts.push("\n[.github/copilot-instructions.md]");
12356
- parts.push(stripManagedBlocks(existingDocs.copilotInstructions));
12357
- }
12365
+ if (existingDocs.copilotInstructions)
12366
+ docEntries.push({
12367
+ header: "\n[.github/copilot-instructions.md]",
12368
+ content: stripManagedBlocks(existingDocs.copilotInstructions)
12369
+ });
12358
12370
  if (existingDocs.copilotInstructionFiles?.length) {
12359
- for (const file of existingDocs.copilotInstructionFiles) {
12360
- parts.push(`
12361
- [.github/instructions/${file.filename}]`);
12362
- parts.push(file.content);
12371
+ for (const file of existingDocs.copilotInstructionFiles)
12372
+ docEntries.push({
12373
+ header: `
12374
+ [.github/instructions/${file.filename}]`,
12375
+ content: file.content
12376
+ });
12377
+ }
12378
+ const totalDocChars = docEntries.reduce((sum, e) => sum + e.content.length, 0);
12379
+ if (totalDocChars > MAX_EXISTING_DOCS_CHARS) {
12380
+ const ratio = MAX_EXISTING_DOCS_CHARS / totalDocChars;
12381
+ for (const entry of docEntries) {
12382
+ const proportional = Math.floor(entry.content.length * ratio);
12383
+ const floor = Math.min(MIN_CHARS_PER_ENTRY, entry.content.length);
12384
+ entry.content = truncateAtLineEnd2(entry.content, Math.max(proportional, floor));
12363
12385
  }
12364
12386
  }
12387
+ for (const { header, content } of docEntries) {
12388
+ parts.push(header);
12389
+ parts.push(content);
12390
+ }
12365
12391
  if (existingDocs.includableDocs?.length) {
12366
12392
  parts.push(`
12367
12393
  --- Existing Documentation Files (use @include) ---`);
@@ -12967,6 +12993,7 @@ async function refreshSingleRepo(repoDir, options) {
12967
12993
  }
12968
12994
  async function refreshCommand(options) {
12969
12995
  const quiet = !!options.quiet;
12996
+ if (quiet && process.env.CALIBER_SPAWNED === "1") return;
12970
12997
  if (quiet) {
12971
12998
  const { isCaliberRunning: isCaliberRunning2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
12972
12999
  if (isCaliberRunning2()) return;
@@ -13934,6 +13961,7 @@ function readFinalizeError() {
13934
13961
  }
13935
13962
  }
13936
13963
  async function learnObserveCommand(options) {
13964
+ if (process.env.CALIBER_SPAWNED === "1") return;
13937
13965
  try {
13938
13966
  const raw = await readStdin();
13939
13967
  if (!raw.trim()) return;
@@ -14014,6 +14042,7 @@ async function learnObserveCommand(options) {
14014
14042
  async function learnFinalizeCommand(options) {
14015
14043
  const isAuto = options?.auto === true;
14016
14044
  const isIncremental = options?.incremental === true;
14045
+ if (isAuto && process.env.CALIBER_SPAWNED === "1") return;
14017
14046
  if (!options?.force && !isAuto) {
14018
14047
  const { isCaliberRunning: isCaliberRunning2 } = await Promise.resolve().then(() => (init_lock(), lock_exports));
14019
14048
  if (isCaliberRunning2()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rely-ai/caliber",
3
- "version": "1.45.3",
3
+ "version": "1.46.0",
4
4
  "description": "AI context infrastructure for coding agents — keeps CLAUDE.md, Cursor rules, and skills in sync as your codebase evolves",
5
5
  "type": "module",
6
6
  "bin": {