@docyrus/docyrus 0.0.74 → 0.0.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docyrus/docyrus",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "private": false,
5
5
  "description": "Docyrus API CLI",
6
6
  "main": "./main.js",
package/server-loader.js CHANGED
@@ -47028,6 +47028,67 @@ async function createAgentServer(params) {
47028
47028
  return c.json({ error: message }, 500);
47029
47029
  }
47030
47030
  });
47031
+ app.post("/api/git/sync", async (c) => {
47032
+ const cwd = context.cwd;
47033
+ const body2 = await c.req.json().catch(() => ({}));
47034
+ try {
47035
+ let isRepo = false;
47036
+ try {
47037
+ const inside = (await gitExec(["rev-parse", "--is-inside-work-tree"], cwd)).trim();
47038
+ isRepo = inside === "true";
47039
+ } catch {
47040
+ isRepo = false;
47041
+ }
47042
+ if (!isRepo) {
47043
+ return c.json({ error: "Not a git repository", cwd }, 400);
47044
+ }
47045
+ const branch = body2.branch?.trim() || (await gitExec(["rev-parse", "--abbrev-ref", "HEAD"], cwd)).trim();
47046
+ if (!branch || branch === "HEAD") {
47047
+ return c.json({ error: "Cannot sync from a detached HEAD", cwd }, 409);
47048
+ }
47049
+ const remote = body2.remote?.trim() || "origin";
47050
+ await gitExec(["add", "-A"], cwd);
47051
+ const statusRaw = (await gitExec(["status", "--porcelain"], cwd)).trim();
47052
+ const hasStaged = (await gitExec(["diff", "--cached", "--name-only"], cwd)).trim().length > 0;
47053
+ let committed = false;
47054
+ let commitHash;
47055
+ const commitMessage = body2.message?.trim() || "chore: sync from docyrus coder";
47056
+ if (hasStaged) {
47057
+ await gitExec(["commit", "-m", commitMessage], cwd);
47058
+ commitHash = (await gitExec(["rev-parse", "HEAD"], cwd)).trim();
47059
+ committed = true;
47060
+ }
47061
+ let upstream;
47062
+ try {
47063
+ upstream = (await gitExec(["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"], cwd)).trim();
47064
+ } catch {
47065
+ upstream = void 0;
47066
+ }
47067
+ const pushArgs = upstream ? ["push", remote, branch] : ["push", "--set-upstream", remote, branch];
47068
+ const pushOutput = await gitExec(pushArgs, cwd);
47069
+ return c.json({
47070
+ ok: true,
47071
+ cwd,
47072
+ branch,
47073
+ remote,
47074
+ committed,
47075
+ commit: committed ? { hash: commitHash, message: commitMessage } : null,
47076
+ pushed: true,
47077
+ upstreamSet: !upstream,
47078
+ statusBeforeSync: statusRaw,
47079
+ pushOutput
47080
+ });
47081
+ } catch (error48) {
47082
+ const errAny = error48;
47083
+ const stderr = errAny.stderr ? errAny.stderr.toString() : "";
47084
+ const stdout = errAny.stdout ? errAny.stdout.toString() : "";
47085
+ const message = errAny.message || String(error48);
47086
+ return c.json({
47087
+ error: stderr.trim() || message,
47088
+ stdout: stdout.trim() || void 0
47089
+ }, 500);
47090
+ }
47091
+ });
47031
47092
  app.get("/api/mcp/servers", async (c) => {
47032
47093
  try {
47033
47094
  const [config2, cache, provenance] = await Promise.all([
@@ -47549,6 +47610,10 @@ async function createAgentServer(params) {
47549
47610
  process.stderr.write(` POST /api/env/stop \u2014 stop dev server
47550
47611
  `);
47551
47612
  process.stderr.write(` GET /api/git/diff \u2014 uncommitted file diffs
47613
+ `);
47614
+ process.stderr.write(` GET /api/git/commits \u2014 recent commits
47615
+ `);
47616
+ process.stderr.write(` POST /api/git/sync \u2014 stage, commit, and push working tree
47552
47617
  `);
47553
47618
  process.stderr.write(` GET /api/mcp/servers \u2014 list MCP servers
47554
47619
  `);