@rely-ai/caliber 1.31.0-dev.1774711564 → 1.31.0-dev.1774711826

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 +189 -118
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -230,6 +230,140 @@ var init_types = __esm({
230
230
  }
231
231
  });
232
232
 
233
+ // src/writers/pre-commit-block.ts
234
+ var pre_commit_block_exports = {};
235
+ __export(pre_commit_block_exports, {
236
+ appendLearningsBlock: () => appendLearningsBlock,
237
+ appendPreCommitBlock: () => appendPreCommitBlock,
238
+ appendSyncBlock: () => appendSyncBlock,
239
+ getCursorLearningsRule: () => getCursorLearningsRule,
240
+ getCursorPreCommitRule: () => getCursorPreCommitRule,
241
+ getCursorSyncRule: () => getCursorSyncRule,
242
+ hasLearningsBlock: () => hasLearningsBlock,
243
+ hasPreCommitBlock: () => hasPreCommitBlock,
244
+ hasSyncBlock: () => hasSyncBlock
245
+ });
246
+ function getPreCommitBlock() {
247
+ const bin = resolveCaliber();
248
+ return `${BLOCK_START}
249
+ ## Before Committing
250
+
251
+ **IMPORTANT:** Before every git commit, you MUST ensure Caliber syncs agent configs with the latest code changes.
252
+
253
+ First, check if the pre-commit hook is already installed:
254
+ \`\`\`bash
255
+ grep -q "caliber" .git/hooks/pre-commit 2>/dev/null && echo "hook-active" || echo "no-hook"
256
+ \`\`\`
257
+
258
+ - If **hook-active**: the hook handles sync automatically \u2014 just commit normally. Tell the user: "Caliber will sync your agent configs automatically via the pre-commit hook."
259
+ - If **no-hook**: run Caliber manually before committing:
260
+ 1. Tell the user: "Caliber: Syncing agent configs with your latest changes..."
261
+ 2. Run: \`${bin} refresh && git add ${MANAGED_DOC_PATHS} 2>/dev/null\`
262
+ 3. After it completes, briefly tell the user what Caliber updated. Then proceed with the commit.
263
+
264
+ If \`${bin}\` is not found, tell the user: "This project uses Caliber for agent config sync. Install it with: npm install -g @rely-ai/caliber"
265
+ ${BLOCK_END}`;
266
+ }
267
+ function getCursorRuleContent() {
268
+ const bin = resolveCaliber();
269
+ return `---
270
+ description: Run Caliber sync before git commits to keep agent configs up to date
271
+ alwaysApply: true
272
+ ---
273
+ Before every git commit, check if the Caliber pre-commit hook is installed:
274
+ Run: \`grep -q "caliber" .git/hooks/pre-commit 2>/dev/null && echo "hook-active" || echo "no-hook"\`
275
+
276
+ If hook-active: just commit normally \u2014 Caliber syncs automatically via the hook. Tell the user: "Caliber will sync your agent configs automatically."
277
+ If no-hook: run \`${bin} refresh && git add ${MANAGED_DOC_PATHS} 2>/dev/null\` before committing, and tell the user what was updated.
278
+
279
+ If \`${bin}\` is not found, tell the user: "This project uses Caliber for agent config sync. Install with: npm install -g @rely-ai/caliber"
280
+ `;
281
+ }
282
+ function hasPreCommitBlock(content) {
283
+ return content.includes(BLOCK_START);
284
+ }
285
+ function appendPreCommitBlock(content) {
286
+ if (hasPreCommitBlock(content)) return content;
287
+ const trimmed = content.trimEnd();
288
+ return trimmed + "\n\n" + getPreCommitBlock() + "\n";
289
+ }
290
+ function getCursorPreCommitRule() {
291
+ return { filename: CURSOR_RULE_FILENAME, content: getCursorRuleContent() };
292
+ }
293
+ function hasLearningsBlock(content) {
294
+ return content.includes(LEARNINGS_BLOCK_START);
295
+ }
296
+ function appendLearningsBlock(content) {
297
+ if (hasLearningsBlock(content)) return content;
298
+ const trimmed = content.trimEnd();
299
+ return trimmed + "\n\n" + LEARNINGS_BLOCK + "\n";
300
+ }
301
+ function getCursorLearningsRule() {
302
+ return { filename: CURSOR_LEARNINGS_FILENAME, content: CURSOR_LEARNINGS_CONTENT };
303
+ }
304
+ function getSyncBlock() {
305
+ const bin = resolveCaliber();
306
+ return `${SYNC_BLOCK_START}
307
+ ## Context Sync
308
+
309
+ This project uses [Caliber](https://github.com/rely-ai/caliber) to keep AI agent configs in sync across Claude Code, Cursor, Copilot, and Codex.
310
+ Configs update automatically before each commit via \`${bin} refresh\`.
311
+ If the pre-commit hook is not set up, run \`${bin} hooks --install\` to enable automatic sync.
312
+ ${SYNC_BLOCK_END}`;
313
+ }
314
+ function hasSyncBlock(content) {
315
+ return content.includes(SYNC_BLOCK_START);
316
+ }
317
+ function appendSyncBlock(content) {
318
+ if (hasSyncBlock(content)) return content;
319
+ const trimmed = content.trimEnd();
320
+ return trimmed + "\n\n" + getSyncBlock() + "\n";
321
+ }
322
+ function getCursorSyncContent() {
323
+ const bin = resolveCaliber();
324
+ return `---
325
+ description: This project uses Caliber for automatic AI agent context sync
326
+ alwaysApply: true
327
+ ---
328
+ This project uses Caliber to keep AI agent configs (CLAUDE.md, Cursor rules, Copilot instructions)
329
+ in sync with the codebase automatically. Before each commit, run \`${bin} refresh\` to sync configs.
330
+ If \`${bin}\` is not found, tell the user: "This project uses Caliber for agent config sync. Install with: npm install -g @rely-ai/caliber"
331
+ `;
332
+ }
333
+ function getCursorSyncRule() {
334
+ return { filename: CURSOR_SYNC_FILENAME, content: getCursorSyncContent() };
335
+ }
336
+ var BLOCK_START, BLOCK_END, MANAGED_DOC_PATHS, CURSOR_RULE_FILENAME, LEARNINGS_BLOCK_START, LEARNINGS_BLOCK_END, LEARNINGS_BLOCK, CURSOR_LEARNINGS_FILENAME, CURSOR_LEARNINGS_CONTENT, SYNC_BLOCK_START, SYNC_BLOCK_END, CURSOR_SYNC_FILENAME;
337
+ var init_pre_commit_block = __esm({
338
+ "src/writers/pre-commit-block.ts"() {
339
+ "use strict";
340
+ init_resolve_caliber();
341
+ BLOCK_START = "<!-- caliber:managed:pre-commit -->";
342
+ BLOCK_END = "<!-- /caliber:managed:pre-commit -->";
343
+ MANAGED_DOC_PATHS = "CLAUDE.md .claude/ .cursor/ .cursorrules .github/copilot-instructions.md .github/instructions/ AGENTS.md CALIBER_LEARNINGS.md";
344
+ CURSOR_RULE_FILENAME = "caliber-pre-commit.mdc";
345
+ LEARNINGS_BLOCK_START = "<!-- caliber:managed:learnings -->";
346
+ LEARNINGS_BLOCK_END = "<!-- /caliber:managed:learnings -->";
347
+ LEARNINGS_BLOCK = `${LEARNINGS_BLOCK_START}
348
+ ## Session Learnings
349
+
350
+ Read \`CALIBER_LEARNINGS.md\` for patterns and anti-patterns learned from previous sessions.
351
+ These are auto-extracted from real tool usage \u2014 treat them as project-specific rules.
352
+ ${LEARNINGS_BLOCK_END}`;
353
+ CURSOR_LEARNINGS_FILENAME = "caliber-learnings.mdc";
354
+ CURSOR_LEARNINGS_CONTENT = `---
355
+ description: Reference session-learned patterns from CALIBER_LEARNINGS.md
356
+ alwaysApply: true
357
+ ---
358
+ Read \`CALIBER_LEARNINGS.md\` for patterns and anti-patterns learned from previous sessions.
359
+ These are auto-extracted from real tool usage \u2014 treat them as project-specific rules.
360
+ `;
361
+ SYNC_BLOCK_START = "<!-- caliber:managed:sync -->";
362
+ SYNC_BLOCK_END = "<!-- /caliber:managed:sync -->";
363
+ CURSOR_SYNC_FILENAME = "caliber-sync.mdc";
364
+ }
365
+ });
366
+
233
367
  // src/lib/builtin-skills.ts
234
368
  var builtin_skills_exports = {};
235
369
  __export(builtin_skills_exports, {
@@ -4718,126 +4852,9 @@ ${f.content}
4718
4852
  import fs19 from "fs";
4719
4853
 
4720
4854
  // src/writers/claude/index.ts
4855
+ init_pre_commit_block();
4721
4856
  import fs12 from "fs";
4722
4857
  import path11 from "path";
4723
-
4724
- // src/writers/pre-commit-block.ts
4725
- init_resolve_caliber();
4726
- var BLOCK_START = "<!-- caliber:managed:pre-commit -->";
4727
- var BLOCK_END = "<!-- /caliber:managed:pre-commit -->";
4728
- var MANAGED_DOC_PATHS = "CLAUDE.md .claude/ .cursor/ .cursorrules .github/copilot-instructions.md .github/instructions/ AGENTS.md CALIBER_LEARNINGS.md";
4729
- function getPreCommitBlock() {
4730
- const bin = resolveCaliber();
4731
- return `${BLOCK_START}
4732
- ## Before Committing
4733
-
4734
- **IMPORTANT:** Before every git commit, you MUST ensure Caliber syncs agent configs with the latest code changes.
4735
-
4736
- First, check if the pre-commit hook is already installed:
4737
- \`\`\`bash
4738
- grep -q "caliber" .git/hooks/pre-commit 2>/dev/null && echo "hook-active" || echo "no-hook"
4739
- \`\`\`
4740
-
4741
- - If **hook-active**: the hook handles sync automatically \u2014 just commit normally. Tell the user: "Caliber will sync your agent configs automatically via the pre-commit hook."
4742
- - If **no-hook**: run Caliber manually before committing:
4743
- 1. Tell the user: "Caliber: Syncing agent configs with your latest changes..."
4744
- 2. Run: \`${bin} refresh && git add ${MANAGED_DOC_PATHS} 2>/dev/null\`
4745
- 3. After it completes, briefly tell the user what Caliber updated. Then proceed with the commit.
4746
-
4747
- If \`${bin}\` is not found, tell the user: "This project uses Caliber for agent config sync. Install it with: npm install -g @rely-ai/caliber"
4748
- ${BLOCK_END}`;
4749
- }
4750
- var CURSOR_RULE_FILENAME = "caliber-pre-commit.mdc";
4751
- function getCursorRuleContent() {
4752
- const bin = resolveCaliber();
4753
- return `---
4754
- description: Run Caliber sync before git commits to keep agent configs up to date
4755
- alwaysApply: true
4756
- ---
4757
- Before every git commit, check if the Caliber pre-commit hook is installed:
4758
- Run: \`grep -q "caliber" .git/hooks/pre-commit 2>/dev/null && echo "hook-active" || echo "no-hook"\`
4759
-
4760
- If hook-active: just commit normally \u2014 Caliber syncs automatically via the hook. Tell the user: "Caliber will sync your agent configs automatically."
4761
- If no-hook: run \`${bin} refresh && git add ${MANAGED_DOC_PATHS} 2>/dev/null\` before committing, and tell the user what was updated.
4762
-
4763
- If \`${bin}\` is not found, tell the user: "This project uses Caliber for agent config sync. Install with: npm install -g @rely-ai/caliber"
4764
- `;
4765
- }
4766
- function hasPreCommitBlock(content) {
4767
- return content.includes(BLOCK_START);
4768
- }
4769
- function appendPreCommitBlock(content) {
4770
- if (hasPreCommitBlock(content)) return content;
4771
- const trimmed = content.trimEnd();
4772
- return trimmed + "\n\n" + getPreCommitBlock() + "\n";
4773
- }
4774
- function getCursorPreCommitRule() {
4775
- return { filename: CURSOR_RULE_FILENAME, content: getCursorRuleContent() };
4776
- }
4777
- var LEARNINGS_BLOCK_START = "<!-- caliber:managed:learnings -->";
4778
- var LEARNINGS_BLOCK_END = "<!-- /caliber:managed:learnings -->";
4779
- var LEARNINGS_BLOCK = `${LEARNINGS_BLOCK_START}
4780
- ## Session Learnings
4781
-
4782
- Read \`CALIBER_LEARNINGS.md\` for patterns and anti-patterns learned from previous sessions.
4783
- These are auto-extracted from real tool usage \u2014 treat them as project-specific rules.
4784
- ${LEARNINGS_BLOCK_END}`;
4785
- var CURSOR_LEARNINGS_FILENAME = "caliber-learnings.mdc";
4786
- var CURSOR_LEARNINGS_CONTENT = `---
4787
- description: Reference session-learned patterns from CALIBER_LEARNINGS.md
4788
- alwaysApply: true
4789
- ---
4790
- Read \`CALIBER_LEARNINGS.md\` for patterns and anti-patterns learned from previous sessions.
4791
- These are auto-extracted from real tool usage \u2014 treat them as project-specific rules.
4792
- `;
4793
- function hasLearningsBlock(content) {
4794
- return content.includes(LEARNINGS_BLOCK_START);
4795
- }
4796
- function appendLearningsBlock(content) {
4797
- if (hasLearningsBlock(content)) return content;
4798
- const trimmed = content.trimEnd();
4799
- return trimmed + "\n\n" + LEARNINGS_BLOCK + "\n";
4800
- }
4801
- function getCursorLearningsRule() {
4802
- return { filename: CURSOR_LEARNINGS_FILENAME, content: CURSOR_LEARNINGS_CONTENT };
4803
- }
4804
- var SYNC_BLOCK_START = "<!-- caliber:managed:sync -->";
4805
- var SYNC_BLOCK_END = "<!-- /caliber:managed:sync -->";
4806
- function getSyncBlock() {
4807
- const bin = resolveCaliber();
4808
- return `${SYNC_BLOCK_START}
4809
- ## Context Sync
4810
-
4811
- This project uses [Caliber](https://github.com/rely-ai/caliber) to keep AI agent configs in sync across Claude Code, Cursor, Copilot, and Codex.
4812
- Configs update automatically before each commit via \`${bin} refresh\`.
4813
- If the pre-commit hook is not set up, run \`${bin} hooks --install\` to enable automatic sync.
4814
- ${SYNC_BLOCK_END}`;
4815
- }
4816
- function hasSyncBlock(content) {
4817
- return content.includes(SYNC_BLOCK_START);
4818
- }
4819
- function appendSyncBlock(content) {
4820
- if (hasSyncBlock(content)) return content;
4821
- const trimmed = content.trimEnd();
4822
- return trimmed + "\n\n" + getSyncBlock() + "\n";
4823
- }
4824
- var CURSOR_SYNC_FILENAME = "caliber-sync.mdc";
4825
- function getCursorSyncContent() {
4826
- const bin = resolveCaliber();
4827
- return `---
4828
- description: This project uses Caliber for automatic AI agent context sync
4829
- alwaysApply: true
4830
- ---
4831
- This project uses Caliber to keep AI agent configs (CLAUDE.md, Cursor rules, Copilot instructions)
4832
- in sync with the codebase automatically. Before each commit, run \`${bin} refresh\` to sync configs.
4833
- If \`${bin}\` is not found, tell the user: "This project uses Caliber for agent config sync. Install with: npm install -g @rely-ai/caliber"
4834
- `;
4835
- }
4836
- function getCursorSyncRule() {
4837
- return { filename: CURSOR_SYNC_FILENAME, content: getCursorSyncContent() };
4838
- }
4839
-
4840
- // src/writers/claude/index.ts
4841
4858
  function writeClaudeConfig(config) {
4842
4859
  const written = [];
4843
4860
  fs12.writeFileSync("CLAUDE.md", appendSyncBlock(appendLearningsBlock(appendPreCommitBlock(config.claudeMd))));
@@ -4875,6 +4892,7 @@ function writeClaudeConfig(config) {
4875
4892
  }
4876
4893
 
4877
4894
  // src/writers/cursor/index.ts
4895
+ init_pre_commit_block();
4878
4896
  import fs13 from "fs";
4879
4897
  import path12 from "path";
4880
4898
  function writeCursorConfig(config) {
@@ -4930,6 +4948,7 @@ function writeCursorConfig(config) {
4930
4948
  }
4931
4949
 
4932
4950
  // src/writers/codex/index.ts
4951
+ init_pre_commit_block();
4933
4952
  import fs14 from "fs";
4934
4953
  import path13 from "path";
4935
4954
  function writeCodexConfig(config) {
@@ -4956,6 +4975,7 @@ function writeCodexConfig(config) {
4956
4975
  }
4957
4976
 
4958
4977
  // src/writers/github-copilot/index.ts
4978
+ init_pre_commit_block();
4959
4979
  import fs15 from "fs";
4960
4980
  import path14 from "path";
4961
4981
  function writeGithubCopilotConfig(config) {
@@ -6355,6 +6375,7 @@ import { existsSync as existsSync6, readdirSync as readdirSync3 } from "fs";
6355
6375
  import { execSync as execSync12 } from "child_process";
6356
6376
  import { join as join7 } from "path";
6357
6377
  init_resolve_caliber();
6378
+ init_pre_commit_block();
6358
6379
  function hasPreCommitHook(dir) {
6359
6380
  try {
6360
6381
  const gitDir = execSync12("git rev-parse --git-dir", { cwd: dir, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
@@ -9249,6 +9270,55 @@ async function initCommand(options) {
9249
9270
  trackInitScoreComputed(baselineScore.score, passingCount, failingCount, false);
9250
9271
  }
9251
9272
  if (skipGeneration) {
9273
+ const {
9274
+ appendPreCommitBlock: appendPreCommitBlock2,
9275
+ appendLearningsBlock: appendLearningsBlock2,
9276
+ appendSyncBlock: appendSyncBlock2,
9277
+ getCursorPreCommitRule: getCursorPreCommitRule2,
9278
+ getCursorLearningsRule: getCursorLearningsRule2,
9279
+ getCursorSyncRule: getCursorSyncRule2
9280
+ } = await Promise.resolve().then(() => (init_pre_commit_block(), pre_commit_block_exports));
9281
+ const claudeMdPath = "CLAUDE.md";
9282
+ let claudeContent = "";
9283
+ try {
9284
+ claudeContent = fs33.readFileSync(claudeMdPath, "utf-8");
9285
+ } catch {
9286
+ }
9287
+ if (!claudeContent) {
9288
+ claudeContent = `# ${path26.basename(process.cwd())}
9289
+ `;
9290
+ }
9291
+ const updatedClaude = appendSyncBlock2(appendLearningsBlock2(appendPreCommitBlock2(claudeContent)));
9292
+ if (updatedClaude !== claudeContent || !fs33.existsSync(claudeMdPath)) {
9293
+ fs33.writeFileSync(claudeMdPath, updatedClaude);
9294
+ console.log(` ${chalk14.green("\u2713")} CLAUDE.md \u2014 added Caliber sync instructions`);
9295
+ }
9296
+ if (targetAgent.includes("cursor")) {
9297
+ const rulesDir = path26.join(".cursor", "rules");
9298
+ if (!fs33.existsSync(rulesDir)) fs33.mkdirSync(rulesDir, { recursive: true });
9299
+ for (const rule of [getCursorPreCommitRule2(), getCursorLearningsRule2(), getCursorSyncRule2()]) {
9300
+ fs33.writeFileSync(path26.join(rulesDir, rule.filename), rule.content);
9301
+ }
9302
+ console.log(` ${chalk14.green("\u2713")} Cursor rules \u2014 added Caliber sync rules`);
9303
+ }
9304
+ if (targetAgent.includes("github-copilot")) {
9305
+ const copilotPath = path26.join(".github", "copilot-instructions.md");
9306
+ let copilotContent = "";
9307
+ try {
9308
+ copilotContent = fs33.readFileSync(copilotPath, "utf-8");
9309
+ } catch {
9310
+ }
9311
+ if (!copilotContent) {
9312
+ fs33.mkdirSync(".github", { recursive: true });
9313
+ copilotContent = `# ${path26.basename(process.cwd())}
9314
+ `;
9315
+ }
9316
+ const updatedCopilot = appendSyncBlock2(appendLearningsBlock2(appendPreCommitBlock2(copilotContent)));
9317
+ if (updatedCopilot !== copilotContent) {
9318
+ fs33.writeFileSync(copilotPath, updatedCopilot);
9319
+ console.log(` ${chalk14.green("\u2713")} Copilot instructions \u2014 added Caliber sync instructions`);
9320
+ }
9321
+ }
9252
9322
  const sha2 = getCurrentHeadSha();
9253
9323
  writeState({
9254
9324
  lastRefreshSha: sha2 ?? "",
@@ -10086,6 +10156,7 @@ function collectDiff(lastSha) {
10086
10156
  }
10087
10157
 
10088
10158
  // src/writers/refresh.ts
10159
+ init_pre_commit_block();
10089
10160
  import fs36 from "fs";
10090
10161
  import path28 from "path";
10091
10162
  function writeRefreshDocs(docs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rely-ai/caliber",
3
- "version": "1.31.0-dev.1774711564",
3
+ "version": "1.31.0-dev.1774711826",
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": {