@rely-ai/caliber 1.20.0-dev.1773696964 → 1.20.0-dev.1773697587

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 +38 -28
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -6535,7 +6535,7 @@ function validateSetup(setup, dir, checkExists = existsSync9) {
6535
6535
  }
6536
6536
  function buildFeedbackMessage(issues) {
6537
6537
  const lines = [
6538
- "Your generated config has these scoring issues. Fix ONLY these \u2014 do not rewrite, restructure, or make cosmetic changes to anything else:\n"
6538
+ "Fix ONLY these scoring issues \u2014 do not rewrite, restructure, or make cosmetic changes:\n"
6539
6539
  ];
6540
6540
  for (let i = 0; i < issues.length; i++) {
6541
6541
  const issue = issues[i];
@@ -6543,7 +6543,6 @@ function buildFeedbackMessage(issues) {
6543
6543
  lines.push(` Action: ${issue.fixInstruction}
6544
6544
  `);
6545
6545
  }
6546
- lines.push("Return the complete updated AgentSetup JSON with only these fixes applied.");
6547
6546
  return lines.join("\n");
6548
6547
  }
6549
6548
  function countIssuePoints(issues) {
@@ -6576,12 +6575,20 @@ async function scoreAndRefine(setup, dir, sessionHistory, callbacks) {
6576
6575
  const issueNames = issues.map((i) => i.check).join(", ");
6577
6576
  callbacks.onStatus(`Fixing ${issues.length} scoring issue${issues.length === 1 ? "" : "s"}: ${issueNames}...`);
6578
6577
  }
6579
- const patched = await applyTargetedFixes(currentSetup, issues, sessionHistory);
6580
- if (!patched) {
6578
+ const refined = await applyTargetedFixes(currentSetup, issues);
6579
+ if (!refined) {
6581
6580
  if (callbacks?.onStatus) callbacks.onStatus("Refinement failed, keeping current setup");
6582
6581
  return bestSetup;
6583
6582
  }
6584
- currentSetup = patched;
6583
+ sessionHistory.push({
6584
+ role: "user",
6585
+ content: `Fix scoring issues: ${issues.map((i) => i.check).join(", ")}`
6586
+ });
6587
+ sessionHistory.push({
6588
+ role: "assistant",
6589
+ content: `Applied scoring fixes for: ${issues.map((i) => i.check).join(", ")}`
6590
+ });
6591
+ currentSetup = refined;
6585
6592
  }
6586
6593
  const finalIssues = validateSetup(currentSetup, dir, cachedExists);
6587
6594
  const finalLostPoints = countIssuePoints(finalIssues);
@@ -6590,41 +6597,44 @@ async function scoreAndRefine(setup, dir, sessionHistory, callbacks) {
6590
6597
  }
6591
6598
  return bestSetup;
6592
6599
  }
6593
- async function applyTargetedFixes(setup, issues, sessionHistory) {
6600
+ async function applyTargetedFixes(setup, issues) {
6594
6601
  const { claudeMd, agentsMd } = extractConfigContent(setup);
6595
- const content = claudeMd ?? agentsMd;
6596
- if (!content) return null;
6602
+ const targets = [];
6603
+ if (claudeMd) targets.push({ key: "claudeMd", label: "CLAUDE.md", content: claudeMd });
6604
+ if (agentsMd) targets.push({ key: "agentsMd", label: "AGENTS.md", content: agentsMd });
6605
+ if (targets.length === 0) return null;
6597
6606
  const feedbackMessage = buildFeedbackMessage(issues);
6598
- const contentLabel = claudeMd ? "CLAUDE.md" : "AGENTS.md";
6607
+ const contentBlock = targets.map(
6608
+ (t) => `### ${t.label}
6609
+ \`\`\`markdown
6610
+ ${t.content}
6611
+ \`\`\``
6612
+ ).join("\n\n");
6599
6613
  const prompt = [
6600
- `Here is the current ${contentLabel} content:
6601
- `,
6602
- "```markdown",
6603
- content,
6604
- "```\n",
6614
+ "Here are the config files with scoring issues:\n",
6615
+ contentBlock,
6616
+ "\n",
6605
6617
  feedbackMessage,
6606
6618
  `
6607
- Return ONLY the fixed ${contentLabel} content as raw markdown (no JSON, no code fences). Apply the fixes above and nothing else \u2014 do not rewrite, restructure, or make cosmetic changes.`
6619
+ Return ONLY the fixed content as a JSON object with keys ${targets.map((t) => `"${t.key}"`).join(", ")}. Each value is the fixed markdown string. No code fences, no explanations.`
6608
6620
  ].join("\n");
6609
6621
  try {
6610
6622
  const raw = await llmCall({
6611
- system: `You fix scoring issues in AI agent configuration files. Return only the fixed markdown content \u2014 no explanations, no JSON wrappers, no code fences.`,
6623
+ system: "You fix scoring issues in AI agent configuration files. Return only a JSON object with the fixed content \u2014 no explanations, no code fences.",
6612
6624
  prompt,
6613
6625
  maxTokens: 8e3
6614
6626
  });
6615
- const fixed = stripMarkdownFences(raw).trim();
6616
- if (!fixed || fixed.length < 50) return null;
6617
- const patched = JSON.parse(JSON.stringify(setup));
6618
- if (claudeMd) {
6619
- patched.claude.claudeMd = fixed;
6620
- } else {
6621
- patched.codex.agentsMd = fixed;
6627
+ const cleaned = stripMarkdownFences(raw);
6628
+ const jsonStart = cleaned.indexOf("{");
6629
+ const jsonToParse = jsonStart !== -1 ? cleaned.slice(jsonStart) : cleaned;
6630
+ const fixes = JSON.parse(jsonToParse);
6631
+ const patched = structuredClone(setup);
6632
+ for (const target of targets) {
6633
+ if (typeof fixes[target.key] === "string" && fixes[target.key].length > 50) {
6634
+ const parent = target.key === "claudeMd" ? patched.claude : patched.codex;
6635
+ if (parent) parent[target.key] = fixes[target.key];
6636
+ }
6622
6637
  }
6623
- sessionHistory.push({ role: "user", content: feedbackMessage });
6624
- sessionHistory.push({
6625
- role: "assistant",
6626
- content: `Applied scoring fixes for: ${issues.map((i) => i.check).join(", ")}`
6627
- });
6628
6638
  return patched;
6629
6639
  } catch {
6630
6640
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rely-ai/caliber",
3
- "version": "1.20.0-dev.1773696964",
3
+ "version": "1.20.0-dev.1773697587",
4
4
  "description": "Analyze your codebase and generate optimized AI agent configs (CLAUDE.md, .cursorrules, skills) — no API key needed",
5
5
  "type": "module",
6
6
  "bin": {