@clawos-dev/clawd 0.2.718 → 0.2.719

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/cli.cjs +38 -21
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -63286,6 +63286,26 @@ async function networkGit(exec, dir, auth, args, what) {
63286
63286
  async function gitPush(exec, dir, auth, refspec = "HEAD:refs/heads/integration") {
63287
63287
  await networkGit(exec, dir, auth, ["push", "-u", "origin", refspec], "\u63A8\u9001");
63288
63288
  }
63289
+ var REMOTE_INTEGRATION = "refs/remotes/origin/integration";
63290
+ async function fetchRemoteIntegration(exec, dir, auth) {
63291
+ const origin = await git(exec, dir, ["remote", "get-url", "origin"]);
63292
+ if (origin.spawnError || origin.code !== 0) return false;
63293
+ const listed = await networkGit(exec, dir, auth, ["ls-remote", "--heads", "origin", "refs/heads/integration"], "\u68C0\u67E5\u8FDC\u7AEF\u6D4B\u8BD5\u5206\u652F");
63294
+ if (!listed.trim()) return false;
63295
+ await networkGit(exec, dir, auth, ["fetch", "origin", `+refs/heads/integration:${REMOTE_INTEGRATION}`], "\u8BFB\u53D6\u8FDC\u7AEF\u6D4B\u8BD5\u5206\u652F");
63296
+ return true;
63297
+ }
63298
+ async function mergeRemoteIntegration(exec, dir) {
63299
+ const before = await mustGit(exec, dir, ["rev-parse", "HEAD"], "\u8BFB\u53D6\u5185\u5BB9\u7248\u672C");
63300
+ const identity = await identityArgs(exec, dir);
63301
+ const merged = await git(exec, dir, [...identity, "merge", "--ff", "--no-edit", "-m", "clawd: \u5408\u5E76\u8FDC\u7AEF integration", REMOTE_INTEGRATION]);
63302
+ if (merged.spawnError) throw new RepoError(`\u672C\u673A\u8DD1\u4E0D\u4E86 git\uFF1A${merged.spawnError}`);
63303
+ if (merged.code === 0) return await mustGit(exec, dir, ["rev-parse", "HEAD"], "\u8BFB\u53D6\u5185\u5BB9\u7248\u672C") !== before;
63304
+ const conflicts = (await git(exec, dir, ["diff", "--name-only", "--diff-filter=U"])).stdout.trim().split("\n").filter(Boolean);
63305
+ await git(exec, dir, ["merge", "--abort"]);
63306
+ if (conflicts.length) throw new RepoError(`\u672C\u5730\u4FEE\u6539\u548C\u8FDC\u7AEF integration \u6709\u51B2\u7A81\uFF08${conflicts.join("\u3001")}\uFF09\uFF0C\u5904\u7406\u540E\u518D\u8BD5\uFF1B\u672C\u5730\u5185\u5BB9\u5DF2\u9000\u56DE\u5408\u5E76\u524D`);
63307
+ throw new RepoError(`\u5408\u5E76\u8FDC\u7AEF integration \u6CA1\u6210\uFF08git \u9000\u51FA\u7801 ${merged.code}\uFF09\uFF1A${tail(merged.stderr) || tail(merged.stdout)}`);
63308
+ }
63289
63309
  async function prepareIntegration(exec, dir, auth) {
63290
63310
  const branch = await mustGit(exec, dir, ["branch", "--show-current"], "\u8BFB\u53D6\u53D1\u5E03\u5206\u652F");
63291
63311
  if (branch !== "main" && branch !== "integration") throw new RepoError("\u5F53\u524D\u4E0D\u662F main \u6216 integration \u5206\u652F\uFF0C\u8BF7\u5148\u6574\u7406\u5230\u53D1\u5E03\u5206\u652F");
@@ -63301,24 +63321,21 @@ async function prepareIntegration(exec, dir, auth) {
63301
63321
  await mustGit(exec, dir, ["status", "--porcelain"], "\u68C0\u67E5\u5B8C\u6574\u5DE5\u4F5C\u533A");
63302
63322
  await writeGitignore(dir);
63303
63323
  await commitAll(exec, { dir, message: "clawd: \u4FDD\u5B58\u6D4B\u8BD5\u53D1\u5E03\u524D\u7684\u4FEE\u6539" });
63304
- if (branch === "integration") return;
63305
- const current = await mustGit(exec, dir, ["rev-parse", "HEAD"], "\u8BFB\u53D6\u5185\u5BB9\u7248\u672C");
63306
- const origin = await git(exec, dir, ["remote", "get-url", "origin"]);
63307
- if (origin.code === 0) {
63308
- const remote2 = await networkGit(exec, dir, auth, ["ls-remote", "--heads", "origin", "refs/heads/integration"], "\u68C0\u67E5\u8FDC\u7AEF\u6D4B\u8BD5\u5206\u652F");
63309
- if (remote2.trim()) await networkGit(exec, dir, auth, ["fetch", "origin", "refs/heads/integration:refs/remotes/origin/integration"], "\u8BFB\u53D6\u8FDC\u7AEF\u6D4B\u8BD5\u5206\u652F");
63310
- }
63311
- const local = await git(exec, dir, ["rev-parse", "--verify", "refs/heads/integration"]);
63312
- const remote = await git(exec, dir, ["rev-parse", "--verify", "refs/remotes/origin/integration"]);
63313
- const candidate = local.code === 0 ? local.stdout.trim() : remote.code === 0 ? remote.stdout.trim() : void 0;
63314
- if (!candidate) {
63315
- await mustGit(exec, dir, ["switch", "-c", "integration"], "\u5EFA\u7ACB\u6D4B\u8BD5\u5206\u652F");
63316
- return;
63324
+ const hasRemote = await fetchRemoteIntegration(exec, dir, auth);
63325
+ if (branch !== "integration") {
63326
+ const current = await mustGit(exec, dir, ["rev-parse", "HEAD"], "\u8BFB\u53D6\u5185\u5BB9\u7248\u672C");
63327
+ const local = await git(exec, dir, ["rev-parse", "--verify", "refs/heads/integration"]);
63328
+ const remote = await git(exec, dir, ["rev-parse", "--verify", REMOTE_INTEGRATION]);
63329
+ const candidate = local.code === 0 ? local.stdout.trim() : remote.code === 0 ? remote.stdout.trim() : void 0;
63330
+ if (!candidate) await mustGit(exec, dir, ["switch", "-c", "integration"], "\u5EFA\u7ACB\u6D4B\u8BD5\u5206\u652F");
63331
+ else {
63332
+ const forward = await git(exec, dir, ["merge-base", "--is-ancestor", current, candidate]);
63333
+ if (forward.code !== 0) throw new RepoError("\u5DF2\u6709 integration \u4E0E\u5F53\u524D main \u5185\u5BB9\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u5148\u6574\u7406\u5206\u652F\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u5408\u5E76\u6216\u4E22\u5F03\u4FEE\u6539");
63334
+ if (local.code !== 0) await mustGit(exec, dir, ["branch", "integration", candidate], "\u5EFA\u7ACB\u672C\u5730\u6D4B\u8BD5\u5206\u652F");
63335
+ await mustGit(exec, dir, ["switch", "integration"], "\u5207\u6362\u6D4B\u8BD5\u5206\u652F");
63336
+ }
63317
63337
  }
63318
- const forward = await git(exec, dir, ["merge-base", "--is-ancestor", current, candidate]);
63319
- if (forward.code !== 0) throw new RepoError("\u5DF2\u6709 integration \u4E0E\u5F53\u524D main \u5185\u5BB9\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u5148\u6574\u7406\u5206\u652F\uFF1B\u4E0D\u4F1A\u81EA\u52A8\u5408\u5E76\u6216\u4E22\u5F03\u4FEE\u6539");
63320
- if (local.code !== 0) await mustGit(exec, dir, ["branch", "integration", candidate], "\u5EFA\u7ACB\u672C\u5730\u6D4B\u8BD5\u5206\u652F");
63321
- await mustGit(exec, dir, ["switch", "integration"], "\u5207\u6362\u6D4B\u8BD5\u5206\u652F");
63338
+ return hasRemote && await mergeRemoteIntegration(exec, dir);
63322
63339
  }
63323
63340
  async function pushRelease(exec, dir, auth, head) {
63324
63341
  if (!/^[a-f0-9]{40}$/.test(head)) throw new RepoError("\u53D1\u5E03\u63D0\u4EA4\u5FC5\u987B\u662F\u5B8C\u6574 SHA");
@@ -63527,7 +63544,7 @@ async function release(exec, api, args) {
63527
63544
  const info = await repoInfo(exec, args.dir);
63528
63545
  if (!info) throw new RepoError("\u8FD8\u6CA1\u6709\u4ED3\u5E93\uFF0C\u5148\u70B9\u4E00\u6B21\u300C\u53D1\u5E03\u5230\u4E91\u4E0A\u300D\u5EFA\u4ED3");
63529
63546
  const base = await readCurrentBase(api);
63530
- await prepareIntegration(exec, args.dir, args.auth);
63547
+ if (await prepareIntegration(exec, args.dir, args.auth) && args.rescanOnRemoteChange) throw new RepoError("\u8FDC\u7AEF integration \u6709\u65B0\u63D0\u4EA4\uFF0C\u5DF2\u5408\u5230\u672C\u5730\u2014\u2014\u91CD\u65B0\u626B\u63CF\u540E\u518D\u53D1\u5E03");
63531
63548
  const before = await readDeployFileRaw(args.dir);
63532
63549
  let committed = false;
63533
63550
  try {
@@ -64852,9 +64869,9 @@ function buildDeployHandlers(deps) {
64852
64869
  }
64853
64870
  if (await deps.claimPublisher(cloudPersonaIdOf(repo2.url), "integration") === "taken") throw invalid("\u6D4B\u8BD5\u73AF\u5883\u91CC\u7684\u8FD9\u4E2A\u540D\u5B57\u5DF2\u7531\u522B\u4EBA\u53D1\u5E03");
64854
64871
  const releaseId = (0, import_node_crypto15.randomUUID)();
64855
- armUndo(void 0);
64856
64872
  try {
64857
- const result = await release(deps.exec, api, { dir, now: deps.now, auth, manifest, onPrepared: async (head) => {
64873
+ const result = await release(deps.exec, api, { dir, now: deps.now, auth, manifest, rescanOnRemoteChange: !rollback2, onPrepared: async (head) => {
64874
+ armUndo(void 0);
64858
64875
  const latest2 = await readHistory(dir);
64859
64876
  await writeScanFile(dir, { ...latest2, releases: [...latest2.releases, { id: releaseId, environment: "integration", head, contentHead: entry.head, scanId: entry.id, at: deps.now(), pushed: false, config: configOfPersona(deps.personaEngine(personaId2) ?? {}), workflowVersion: DEPLOY_WORKFLOW_VERSION }] });
64860
64877
  } });
@@ -76051,7 +76068,7 @@ function computeMethodAccess(args) {
76051
76068
  }
76052
76069
 
76053
76070
  // src/version.ts
76054
- var version = "0.2.718".length > 0 ? "0.2.718" : "dev";
76071
+ var version = "0.2.719".length > 0 ? "0.2.719" : "dev";
76055
76072
 
76056
76073
  // src/cli-probe/probe.ts
76057
76074
  var fs87 = __toESM(require("fs"), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.718",
3
+ "version": "0.2.719",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",