@adhdev/daemon-standalone 0.9.62 → 0.9.64

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.
package/dist/index.js CHANGED
@@ -33496,7 +33496,8 @@ var require_dist2 = __commonJS({
33496
33496
  "git_stash_push",
33497
33497
  "git_stash_pop",
33498
33498
  "git_checkout_files",
33499
- "git_remote_url"
33499
+ "git_remote_url",
33500
+ "git_push"
33500
33501
  ]);
33501
33502
  var SNAPSHOT_REASONS = /* @__PURE__ */ new Set([
33502
33503
  "session_baseline",
@@ -33542,7 +33543,8 @@ var require_dist2 = __commonJS({
33542
33543
  stashPush: async ({ workspace, message, includeUntracked = false }) => gitStashPush(workspace, message, includeUntracked),
33543
33544
  stashPop: async ({ workspace, stashRef }) => gitStashPop(workspace, stashRef),
33544
33545
  checkoutFiles: async ({ workspace, paths }) => gitCheckoutFiles(workspace, paths),
33545
- getRemoteUrl: async ({ workspace, remote = "origin" }) => gitGetRemoteUrl(workspace, remote)
33546
+ getRemoteUrl: async ({ workspace, remote = "origin" }) => gitGetRemoteUrl(workspace, remote),
33547
+ push: async ({ workspace, remote = "origin", branch, setUpstream = false }) => gitPush(workspace, remote, branch, setUpstream)
33546
33548
  };
33547
33549
  }
33548
33550
  var defaultGitCommandServices = createDefaultGitCommandServices();
@@ -33710,6 +33712,20 @@ var require_dist2 = __commonJS({
33710
33712
  if ("success" in remoteResult) return remoteResult;
33711
33713
  return { success: true, remoteUrl: remoteResult.remoteUrl, remote: remoteResult.remote };
33712
33714
  }
33715
+ case "git_push": {
33716
+ if (!services.push) return serviceNotImplemented(command);
33717
+ const remote = typeof args?.remote === "string" && args.remote.trim() ? args.remote.trim() : "origin";
33718
+ const branch = typeof args?.branch === "string" && args.branch.trim() ? args.branch.trim() : void 0;
33719
+ const setUpstream = Boolean(args?.setUpstream);
33720
+ if (!/^[a-zA-Z0-9_.\-]+$/.test(remote)) {
33721
+ return failure("invalid_args", "remote must contain only alphanumeric characters, dots, hyphens, and underscores");
33722
+ }
33723
+ if (branch !== void 0 && !/^[a-zA-Z0-9/_.\-]+$/.test(branch)) {
33724
+ return failure("invalid_args", "branch must contain only alphanumeric characters, slashes, dots, hyphens, and underscores");
33725
+ }
33726
+ const pushResult = await runService(() => services.push({ workspace, remote, branch, setUpstream }));
33727
+ return "success" in pushResult ? pushResult : { success: true, push: pushResult };
33728
+ }
33713
33729
  default:
33714
33730
  return failure("invalid_args", `Unknown Git command: ${command}`);
33715
33731
  }
@@ -33812,6 +33828,49 @@ var require_dist2 = __commonJS({
33812
33828
  }
33813
33829
  return { remoteUrl, remote };
33814
33830
  }
33831
+ async function gitPush(workspace, remote, branch, setUpstream) {
33832
+ const lastCheckedAt = Date.now();
33833
+ const repo = await resolveGitRepository(workspace);
33834
+ const repoRoot = repo.repoRoot;
33835
+ let resolvedBranch = branch;
33836
+ if (!resolvedBranch) {
33837
+ const branchResult = await runGit(repo, ["symbolic-ref", "--short", "HEAD"], { cwd: repoRoot });
33838
+ resolvedBranch = branchResult.stdout.trim();
33839
+ if (!resolvedBranch) {
33840
+ throw new GitCommandError("git_command_failed", "Cannot push: not on a branch (detached HEAD)");
33841
+ }
33842
+ }
33843
+ const pushArgs = ["push"];
33844
+ if (setUpstream) pushArgs.push("--set-upstream");
33845
+ pushArgs.push(remote, resolvedBranch);
33846
+ let output = "";
33847
+ let newBranch = false;
33848
+ try {
33849
+ const result = await runGit(repo, pushArgs, { cwd: repoRoot });
33850
+ output = (result.stdout + result.stderr).trim();
33851
+ newBranch = /\[new branch\]/i.test(output);
33852
+ } catch (err) {
33853
+ const errOutput = (err?.stdout ?? "") + (err?.stderr ?? "");
33854
+ if (!setUpstream && /no upstream branch|set-upstream/i.test(errOutput)) {
33855
+ const retryArgs = ["push", "--set-upstream", remote, resolvedBranch];
33856
+ const retryResult = await runGit(repo, retryArgs, { cwd: repoRoot });
33857
+ output = (retryResult.stdout + retryResult.stderr).trim();
33858
+ newBranch = /\[new branch\]/i.test(output);
33859
+ } else {
33860
+ throw new GitCommandError("git_command_failed", errOutput || err?.message || "git push failed");
33861
+ }
33862
+ }
33863
+ return {
33864
+ workspace: repo.workspace,
33865
+ repoRoot,
33866
+ isGitRepo: true,
33867
+ remote,
33868
+ branch: resolvedBranch,
33869
+ output,
33870
+ newBranch,
33871
+ lastCheckedAt
33872
+ };
33873
+ }
33815
33874
  function formatOptionalGitLogRangeArg(flag, value) {
33816
33875
  return value ? [`${flag}=${value}`] : [];
33817
33876
  }
@@ -40051,9 +40110,34 @@ ${effect.notification.body || ""}`.trim();
40051
40110
  }
40052
40111
  return -1;
40053
40112
  }
40113
+ function isReadChatConversationAnchorMessage(message) {
40114
+ if (!message) return false;
40115
+ const role = String(message.role || "").trim().toLowerCase();
40116
+ if (role !== "user" && role !== "assistant") return false;
40117
+ const kind = String(message.kind || "standard").trim().toLowerCase();
40118
+ return !kind || kind === "standard";
40119
+ }
40120
+ function buildVisibleReadChatTailMessages(messages, tailLimit) {
40121
+ const totalMessages = messages.length;
40122
+ if (tailLimit <= 0 || totalMessages <= tailLimit) return messages;
40123
+ const tailMessages = messages.slice(-tailLimit);
40124
+ if (tailMessages.some(isReadChatConversationAnchorMessage)) return tailMessages;
40125
+ const hiddenMessages = messages.slice(0, totalMessages - tailLimit);
40126
+ const anchors = [];
40127
+ const seenRoles = /* @__PURE__ */ new Set();
40128
+ for (let index = hiddenMessages.length - 1; index >= 0 && anchors.length < 2; index -= 1) {
40129
+ const message = hiddenMessages[index];
40130
+ if (!isReadChatConversationAnchorMessage(message)) continue;
40131
+ const role = String(message.role || "").trim().toLowerCase();
40132
+ if (seenRoles.has(role)) continue;
40133
+ seenRoles.add(role);
40134
+ anchors.unshift(message);
40135
+ }
40136
+ return anchors.length > 0 ? [...anchors, ...tailMessages] : tailMessages;
40137
+ }
40054
40138
  function buildBoundedTailSync(messages, cursor) {
40055
40139
  const totalMessages = messages.length;
40056
- const tailMessages = cursor.tailLimit > 0 && totalMessages > cursor.tailLimit ? messages.slice(-cursor.tailLimit) : messages;
40140
+ const tailMessages = buildVisibleReadChatTailMessages(messages, cursor.tailLimit);
40057
40141
  return {
40058
40142
  syncMode: "full",
40059
40143
  replaceFrom: 0,
@@ -40175,8 +40259,8 @@ ${effect.notification.body || ""}`.trim();
40175
40259
  const messages = collapseReplayDuplicatesFromReadChat(normalizeReadChatMessages(validatedPayload));
40176
40260
  const cursor = normalizeReadChatCursor(args);
40177
40261
  if (!cursor.knownMessageCount && !cursor.lastMessageSignature && cursor.tailLimit > 0 && messages.length > cursor.tailLimit) {
40178
- const tailMessages = messages.slice(-cursor.tailLimit);
40179
- const lastMessageSignature = getChatMessageSignature(tailMessages[tailMessages.length - 1]);
40262
+ const tailMessages = buildVisibleReadChatTailMessages(messages, cursor.tailLimit);
40263
+ const lastMessageSignature = getChatMessageSignature(messages[messages.length - 1]);
40180
40264
  return {
40181
40265
  success: true,
40182
40266
  ...validatedPayload,