@adhdev/daemon-core 0.9.62 → 0.9.63
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/git/git-commands.d.ts +16 -0
- package/dist/git/git-types.d.ts +1 -1
- package/dist/index.js +61 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -2
- package/dist/index.mjs.map +1 -1
- package/node_modules/@adhdev/session-host-core/package.json +1 -1
- package/package.json +1 -1
- package/src/git/git-commands.ts +84 -1
- package/src/git/git-types.ts +2 -1
package/dist/index.mjs
CHANGED
|
@@ -5462,7 +5462,8 @@ var GIT_COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
|
5462
5462
|
"git_stash_push",
|
|
5463
5463
|
"git_stash_pop",
|
|
5464
5464
|
"git_checkout_files",
|
|
5465
|
-
"git_remote_url"
|
|
5465
|
+
"git_remote_url",
|
|
5466
|
+
"git_push"
|
|
5466
5467
|
]);
|
|
5467
5468
|
var SNAPSHOT_REASONS = /* @__PURE__ */ new Set([
|
|
5468
5469
|
"session_baseline",
|
|
@@ -5508,7 +5509,8 @@ function createDefaultGitCommandServices() {
|
|
|
5508
5509
|
stashPush: async ({ workspace, message, includeUntracked = false }) => gitStashPush(workspace, message, includeUntracked),
|
|
5509
5510
|
stashPop: async ({ workspace, stashRef }) => gitStashPop(workspace, stashRef),
|
|
5510
5511
|
checkoutFiles: async ({ workspace, paths }) => gitCheckoutFiles(workspace, paths),
|
|
5511
|
-
getRemoteUrl: async ({ workspace, remote = "origin" }) => gitGetRemoteUrl(workspace, remote)
|
|
5512
|
+
getRemoteUrl: async ({ workspace, remote = "origin" }) => gitGetRemoteUrl(workspace, remote),
|
|
5513
|
+
push: async ({ workspace, remote = "origin", branch, setUpstream = false }) => gitPush(workspace, remote, branch, setUpstream)
|
|
5512
5514
|
};
|
|
5513
5515
|
}
|
|
5514
5516
|
var defaultGitCommandServices = createDefaultGitCommandServices();
|
|
@@ -5676,6 +5678,20 @@ async function handleGitCommand(command, args, services = defaultGitCommandServi
|
|
|
5676
5678
|
if ("success" in remoteResult) return remoteResult;
|
|
5677
5679
|
return { success: true, remoteUrl: remoteResult.remoteUrl, remote: remoteResult.remote };
|
|
5678
5680
|
}
|
|
5681
|
+
case "git_push": {
|
|
5682
|
+
if (!services.push) return serviceNotImplemented(command);
|
|
5683
|
+
const remote = typeof args?.remote === "string" && args.remote.trim() ? args.remote.trim() : "origin";
|
|
5684
|
+
const branch = typeof args?.branch === "string" && args.branch.trim() ? args.branch.trim() : void 0;
|
|
5685
|
+
const setUpstream = Boolean(args?.setUpstream);
|
|
5686
|
+
if (!/^[a-zA-Z0-9_.\-]+$/.test(remote)) {
|
|
5687
|
+
return failure("invalid_args", "remote must contain only alphanumeric characters, dots, hyphens, and underscores");
|
|
5688
|
+
}
|
|
5689
|
+
if (branch !== void 0 && !/^[a-zA-Z0-9/_.\-]+$/.test(branch)) {
|
|
5690
|
+
return failure("invalid_args", "branch must contain only alphanumeric characters, slashes, dots, hyphens, and underscores");
|
|
5691
|
+
}
|
|
5692
|
+
const pushResult = await runService(() => services.push({ workspace, remote, branch, setUpstream }));
|
|
5693
|
+
return "success" in pushResult ? pushResult : { success: true, push: pushResult };
|
|
5694
|
+
}
|
|
5679
5695
|
default:
|
|
5680
5696
|
return failure("invalid_args", `Unknown Git command: ${command}`);
|
|
5681
5697
|
}
|
|
@@ -5778,6 +5794,49 @@ async function gitGetRemoteUrl(workspace, remote) {
|
|
|
5778
5794
|
}
|
|
5779
5795
|
return { remoteUrl, remote };
|
|
5780
5796
|
}
|
|
5797
|
+
async function gitPush(workspace, remote, branch, setUpstream) {
|
|
5798
|
+
const lastCheckedAt = Date.now();
|
|
5799
|
+
const repo = await resolveGitRepository(workspace);
|
|
5800
|
+
const repoRoot = repo.repoRoot;
|
|
5801
|
+
let resolvedBranch = branch;
|
|
5802
|
+
if (!resolvedBranch) {
|
|
5803
|
+
const branchResult = await runGit(repo, ["symbolic-ref", "--short", "HEAD"], { cwd: repoRoot });
|
|
5804
|
+
resolvedBranch = branchResult.stdout.trim();
|
|
5805
|
+
if (!resolvedBranch) {
|
|
5806
|
+
throw new GitCommandError("git_command_failed", "Cannot push: not on a branch (detached HEAD)");
|
|
5807
|
+
}
|
|
5808
|
+
}
|
|
5809
|
+
const pushArgs = ["push"];
|
|
5810
|
+
if (setUpstream) pushArgs.push("--set-upstream");
|
|
5811
|
+
pushArgs.push(remote, resolvedBranch);
|
|
5812
|
+
let output = "";
|
|
5813
|
+
let newBranch = false;
|
|
5814
|
+
try {
|
|
5815
|
+
const result = await runGit(repo, pushArgs, { cwd: repoRoot });
|
|
5816
|
+
output = (result.stdout + result.stderr).trim();
|
|
5817
|
+
newBranch = /\[new branch\]/i.test(output);
|
|
5818
|
+
} catch (err) {
|
|
5819
|
+
const errOutput = (err?.stdout ?? "") + (err?.stderr ?? "");
|
|
5820
|
+
if (!setUpstream && /no upstream branch|set-upstream/i.test(errOutput)) {
|
|
5821
|
+
const retryArgs = ["push", "--set-upstream", remote, resolvedBranch];
|
|
5822
|
+
const retryResult = await runGit(repo, retryArgs, { cwd: repoRoot });
|
|
5823
|
+
output = (retryResult.stdout + retryResult.stderr).trim();
|
|
5824
|
+
newBranch = /\[new branch\]/i.test(output);
|
|
5825
|
+
} else {
|
|
5826
|
+
throw new GitCommandError("git_command_failed", errOutput || err?.message || "git push failed");
|
|
5827
|
+
}
|
|
5828
|
+
}
|
|
5829
|
+
return {
|
|
5830
|
+
workspace: repo.workspace,
|
|
5831
|
+
repoRoot,
|
|
5832
|
+
isGitRepo: true,
|
|
5833
|
+
remote,
|
|
5834
|
+
branch: resolvedBranch,
|
|
5835
|
+
output,
|
|
5836
|
+
newBranch,
|
|
5837
|
+
lastCheckedAt
|
|
5838
|
+
};
|
|
5839
|
+
}
|
|
5781
5840
|
function formatOptionalGitLogRangeArg(flag, value) {
|
|
5782
5841
|
return value ? [`${flag}=${value}`] : [];
|
|
5783
5842
|
}
|