opencara 0.22.3 → 0.22.5

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/index.js +40 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3821,6 +3821,31 @@ function ghExec(args, cwd) {
3821
3821
  throw new Error(sanitizeTokens(message));
3822
3822
  }
3823
3823
  }
3824
+ function detectDefaultBranch(repoPath) {
3825
+ const candidates = [
3826
+ { ref: "origin/main", branch: "main" },
3827
+ { ref: "origin/master", branch: "master" },
3828
+ // Bare clone refs (local branches — no remote tracking in bare repos)
3829
+ { ref: "refs/heads/main", branch: "main" },
3830
+ { ref: "refs/heads/master", branch: "master" }
3831
+ ];
3832
+ for (const { ref, branch } of candidates) {
3833
+ try {
3834
+ gitExec2(["rev-parse", "--verify", ref], repoPath);
3835
+ return branch;
3836
+ } catch {
3837
+ }
3838
+ }
3839
+ throw new Error("Cannot determine default branch \u2014 neither main nor master exists");
3840
+ }
3841
+ function resolveStartRef(repoPath, branch) {
3842
+ try {
3843
+ gitExec2(["rev-parse", "--verify", `origin/${branch}`], repoPath);
3844
+ return `origin/${branch}`;
3845
+ } catch {
3846
+ return branch;
3847
+ }
3848
+ }
3824
3849
  function checkoutForImplement(owner, repo, issueNumber, branchName, baseDir) {
3825
3850
  validatePathSegment(owner, "owner");
3826
3851
  validatePathSegment(repo, "repo");
@@ -3853,20 +3878,9 @@ function checkoutForImplement(owner, repo, issueNumber, branchName, baseDir) {
3853
3878
  ).trim();
3854
3879
  defaultBranch = defaultBranch.replace(/^origin\//, "");
3855
3880
  } catch {
3856
- try {
3857
- gitExec2(["rev-parse", "--verify", "origin/main"], bareRepoPath);
3858
- defaultBranch = "main";
3859
- } catch {
3860
- try {
3861
- gitExec2(["rev-parse", "--verify", "origin/master"], bareRepoPath);
3862
- defaultBranch = "master";
3863
- } catch {
3864
- throw new Error(
3865
- "Cannot determine default branch \u2014 neither origin/main nor origin/master exists"
3866
- );
3867
- }
3868
- }
3881
+ defaultBranch = detectDefaultBranch(bareRepoPath);
3869
3882
  }
3883
+ const startRef = resolveStartRef(bareRepoPath, defaultBranch);
3870
3884
  const worktreeBase = path8.join(path8.dirname(bareRepoPath), `${repo}-worktrees`);
3871
3885
  const worktreeKey = `implement-${issueNumber}`;
3872
3886
  const worktreePath = path8.join(worktreeBase, worktreeKey);
@@ -3883,10 +3897,7 @@ function checkoutForImplement(owner, repo, issueNumber, branchName, baseDir) {
3883
3897
  } catch {
3884
3898
  }
3885
3899
  fs8.mkdirSync(worktreeBase, { recursive: true });
3886
- gitExec2(
3887
- ["worktree", "add", "-b", branchName, worktreePath, `origin/${defaultBranch}`],
3888
- bareRepoPath
3889
- );
3900
+ gitExec2(["worktree", "add", "-b", branchName, worktreePath, startRef], bareRepoPath);
3890
3901
  return { worktreePath, bareRepoPath };
3891
3902
  }
3892
3903
  function cleanupImplementWorktree(bareRepoPath, worktreePath) {
@@ -3938,6 +3949,12 @@ function createPR(worktreePath, issueNumber, issueTitle, summary) {
3938
3949
  const prNumber = parseInt(prNumberMatch[1], 10);
3939
3950
  return { prNumber, prUrl };
3940
3951
  }
3952
+ function ensurePromptViaArg(commandTemplate) {
3953
+ if (commandTemplate.includes("${PROMPT}")) return commandTemplate;
3954
+ const binaryName = commandTemplate.trim().split(/\s+/)[0];
3955
+ if (binaryName !== "claude") return commandTemplate;
3956
+ return commandTemplate + " -p '${PROMPT}'";
3957
+ }
3941
3958
  async function executeImplement(task, worktreePath, deps, timeoutSeconds, signal, runTool = executeTool) {
3942
3959
  const timeoutMs = timeoutSeconds * 1e3;
3943
3960
  if (timeoutMs <= TIMEOUT_SAFETY_MARGIN_MS6) {
@@ -3945,8 +3962,9 @@ async function executeImplement(task, worktreePath, deps, timeoutSeconds, signal
3945
3962
  }
3946
3963
  const effectiveTimeout = timeoutMs - TIMEOUT_SAFETY_MARGIN_MS6;
3947
3964
  const prompt2 = buildImplementPrompt(task);
3965
+ const effectiveCommand = ensurePromptViaArg(deps.commandTemplate);
3948
3966
  const result = await runTool(
3949
- deps.commandTemplate,
3967
+ effectiveCommand,
3950
3968
  prompt2,
3951
3969
  effectiveTimeout,
3952
3970
  signal,
@@ -5516,7 +5534,7 @@ function sleep2(ms, signal) {
5516
5534
  async function startAgent(agentId, platformUrl, agentInfo, reviewDeps, consumptionDeps, options) {
5517
5535
  const client = new ApiClient(platformUrl, {
5518
5536
  authToken: options?.authToken,
5519
- cliVersion: "0.22.3",
5537
+ cliVersion: "0.22.5",
5520
5538
  versionOverride: options?.versionOverride,
5521
5539
  onTokenRefresh: options?.onTokenRefresh
5522
5540
  });
@@ -5802,7 +5820,7 @@ async function startBatchAgents(config, agents, pollIntervalMs, oauthToken, opti
5802
5820
  const { versionOverride, verbose, instancesOverride, agentOwner, userOrgs } = options;
5803
5821
  const client = new ApiClient(config.platformUrl, {
5804
5822
  authToken: oauthToken,
5805
- cliVersion: "0.22.3",
5823
+ cliVersion: "0.22.5",
5806
5824
  versionOverride,
5807
5825
  onTokenRefresh: () => getValidToken(config.platformUrl, { configPath: config.authFile })
5808
5826
  });
@@ -6145,7 +6163,7 @@ agentCommand.command("start").description("Start agents in polling mode").option
6145
6163
  }
6146
6164
  config = loadConfig();
6147
6165
  }
6148
- console.log(formatVersionBanner("0.22.3", "3f36ad9"));
6166
+ console.log(formatVersionBanner("0.22.5", "dd7af5e"));
6149
6167
  if (config.agents && config.agents.length > 0) {
6150
6168
  const toolEntries = config.agents.map((a) => ({
6151
6169
  tool: a.tool,
@@ -6968,7 +6986,7 @@ var statusCommand = new Command4("status").description("Show agent config, conne
6968
6986
  });
6969
6987
 
6970
6988
  // src/index.ts
6971
- var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.22.3"} (${"3f36ad9"})`);
6989
+ var program = new Command5().name("opencara").description("OpenCara \u2014 distributed AI code review agent").version(`${"0.22.5"} (${"dd7af5e"})`);
6972
6990
  program.addCommand(agentCommand);
6973
6991
  program.addCommand(authCommand());
6974
6992
  program.addCommand(dedupCommand());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencara",
3
- "version": "0.22.3",
3
+ "version": "0.22.5",
4
4
  "description": "Distributed AI code review agent — poll, review, and submit PR reviews using your own AI tools",
5
5
  "type": "module",
6
6
  "license": "MIT",