@agimon-ai/po-git 0.0.0-alpha.2 → 0.0.0-alpha.21

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.
@@ -1,5 +1,5 @@
1
1
  //#region generated/server.d.ts
2
- export declare const facet: import("@agimon-ai/po-core/serverFacet").DoomServerFacet;
2
+ export declare const serverPlugin: import("@agimon-ai/po-core/serverPlugin").PoServerPlugin;
3
3
  //#endregion
4
- export { facet as default };
4
+ export { serverPlugin as default };
5
5
  //# sourceMappingURL=server.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAsBa,gDAAK"}
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAyBa,wDAAY"}
@@ -1,10 +1,10 @@
1
- import { _ as NETWORK_TIMEOUT_MS, a as GIT_WORKTREE_LIFECYCLE_EVENT, b as createWorktreeGit, c as isWorktreeLifecycleEvent, d as registryFile, f as readJson, g as invalidRequest, h as HubUnavailableError, i as GIT_SESSION_CHANGED_EVENT, l as credentialsFile, m as DoomGitExpectedError, n as createWorktreeRegistry, o as createWorktreeMessageInbox, p as writeJsonAtomic, r as validRefName, s as isSessionChangedEvent, t as createWorktreeOperations, u as doomGitRoot, v as READ_TIMEOUT_MS, x as runGit, y as REBASE_TIMEOUT_MS } from "../worktreeOperations-CaqwGsD_.mjs";
1
+ import { _ as NETWORK_TIMEOUT_MS, a as GIT_WORKTREE_LIFECYCLE_EVENT, b as createWorktreeGit, c as isWorktreeLifecycleEvent, d as registryFile, f as readJson, g as invalidRequest, h as PoGitExpectedError, i as GIT_SESSION_CHANGED_EVENT, l as credentialsFile, m as HubUnavailableError, n as createWorktreeRegistry, o as createWorktreeMessageInbox, p as writeJsonAtomic, r as validRefName, s as isSessionChangedEvent, t as createWorktreeOperations, u as poGitRoot, v as READ_TIMEOUT_MS, x as runGit, y as REBASE_TIMEOUT_MS } from "../worktreeOperations-Cd8Q12L4.mjs";
2
2
  import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { composeServerProviderOverrides, defineServerPlugin, readPackageResource } from "@agimon-ai/po-core/serverFacet";
6
- import { composeRootHooks, defineChannel, defineHook, defineResource, defineRoot, defineRoute, defineServerTool } from "@agimon-ai/po-core/extensionFile";
7
- import { readDoomSessionDelivery } from "@agimon-ai/po-session";
5
+ import { composeServerProviderOverrides, defineServerPlugin, readPackageResource } from "@agimon-ai/po-core/serverPlugin";
6
+ import { composeRootHooks, composeRootInjects, defineChannel, defineHook, defineResource, defineRoot, defineRoute, defineServerTool } from "@agimon-ai/po-core/extensionFile";
7
+ import { readPoSessionDelivery } from "@agimon-ai/po-session";
8
8
  import { Type } from "typebox";
9
9
  //#region src/schemas/runWorktreeTool.ts
10
10
  /**
@@ -303,8 +303,8 @@ function progressResult(action, label) {
303
303
  };
304
304
  }
305
305
  function createGitSession({ context, host: serverHost }) {
306
- if (serverHost.context.directEvents === void 0) throw new Error("Git headless facet requires the session direct event bus.");
307
- if (serverHost.context.sessionId === void 0) throw new Error("Git headless facet requires a session identity.");
306
+ if (serverHost.context.directEvents === void 0) throw new Error("Git server plugin requires the session direct event bus.");
307
+ if (serverHost.context.sessionId === void 0) throw new Error("Git server plugin requires a session identity.");
308
308
  const sessionId = serverHost.context.sessionId;
309
309
  const directEvents = serverHost.context.directEvents;
310
310
  const messageInbox = createWorktreeMessageInbox(directEvents, sessionId);
@@ -312,7 +312,7 @@ function createGitSession({ context, host: serverHost }) {
312
312
  git: createWorktreeGit(),
313
313
  sessionService: serverHost.context.sessionService,
314
314
  messageInbox,
315
- sessionDelivery: () => readDoomSessionDelivery(context)
315
+ sessionDelivery: () => readPoSessionDelivery(context)
316
316
  });
317
317
  const resources = [{
318
318
  when: {
@@ -928,7 +928,7 @@ function createGitAuthStore(homeDir = os.homedir()) {
928
928
  const key = workspaceKey(workspaceRoot);
929
929
  const current = readFile();
930
930
  const next = parseGitAuthSave(request, current.workspaces[key] ?? { method: "none" }, homeDir);
931
- const root = doomGitRoot(homeDir);
931
+ const root = poGitRoot(homeDir);
932
932
  fs.mkdirSync(root, {
933
933
  recursive: true,
934
934
  mode: OWNER_ONLY_DIRECTORY
@@ -1100,7 +1100,7 @@ function badRequest(message) {
1100
1100
  return Response.json({ error: message }, { status: 400 });
1101
1101
  }
1102
1102
  function failed(error) {
1103
- if (error instanceof DoomGitExpectedError) return Response.json({
1103
+ if (error instanceof PoGitExpectedError) return Response.json({
1104
1104
  error: error.message,
1105
1105
  code: error.code
1106
1106
  }, { status: error.retryable ? 503 : 409 });
@@ -1191,7 +1191,7 @@ var route_server_default = defineRoute({
1191
1191
  try {
1192
1192
  return Response.json(gitAuth.save(root, await request.json().catch(() => void 0)));
1193
1193
  } catch (error) {
1194
- if (error instanceof DoomGitExpectedError && error.code === "invalid_request") {
1194
+ if (error instanceof PoGitExpectedError && error.code === "invalid_request") {
1195
1195
  const text = error.message.replace(/^\[[a-z_]+\] /u, "").replace("\nRecovery: ", " ");
1196
1196
  return Response.json({
1197
1197
  error: text,
@@ -1366,12 +1366,12 @@ const RULES = [
1366
1366
  }
1367
1367
  ];
1368
1368
  function classifyGitFailure(operation, result, mismatch) {
1369
- if (result.timedOut) return new DoomGitExpectedError("git_timeout", `git ${operation} took too long and was stopped.`, true, "Check the network, then try again.");
1369
+ if (result.timedOut) return new PoGitExpectedError("git_timeout", `git ${operation} took too long and was stopped.`, true, "Check the network, then try again.");
1370
1370
  const text = `${result.stderr}\n${result.stdout}`.toLowerCase();
1371
1371
  const rule = RULES.find((candidate) => candidate.phrases.some((phrase) => text.includes(phrase)));
1372
- if (rule === void 0) return new DoomGitExpectedError("git_failed", `git ${operation} failed (exit ${String(result.code)}).`, false, "Run the same command in a terminal in this checkout to see what git says.");
1372
+ if (rule === void 0) return new PoGitExpectedError("git_failed", `git ${operation} failed (exit ${String(result.code)}).`, false, "Run the same command in a terminal in this checkout to see what git says.");
1373
1373
  const recovery = rule.code === "auth_failed" && mismatch !== void 0 ? `${mismatch} ${rule.recovery}` : rule.recovery;
1374
- return new DoomGitExpectedError(rule.code, rule.message, rule.retryable, recovery);
1374
+ return new PoGitExpectedError(rule.code, rule.message, rule.retryable, recovery);
1375
1375
  }
1376
1376
  //#endregion
1377
1377
  //#region src/services/gitSync/index.ts
@@ -1394,7 +1394,7 @@ function classifyGitFailure(operation, result, mismatch) {
1394
1394
  */
1395
1395
  const DONE = { outcome: "done" };
1396
1396
  function expected(code, message, recovery) {
1397
- return new DoomGitExpectedError(code, message, false, recovery);
1397
+ return new PoGitExpectedError(code, message, false, recovery);
1398
1398
  }
1399
1399
  async function readLine(cwd, args) {
1400
1400
  const result = await runGit(cwd, args, { timeout: READ_TIMEOUT_MS });
@@ -1583,9 +1583,9 @@ const GIT_CHANGES_TYPE = "git_changes";
1583
1583
  * DESIGN PATTERNS:
1584
1584
  * - Apart from the worktrees channel. Worktrees are repository management;
1585
1585
  * this is the session's own code change.
1586
- * - Push, not poll. The session facet publishes a "changed" event after every
1587
- * tool call and settled turn; recounts are coalesced to one in flight plus
1588
- * one rerun, so a burst of tool calls costs at most two.
1586
+ * - Push, not poll. The session's server plugin publishes a "changed" event
1587
+ * after every tool call and settled turn; recounts are coalesced to one in
1588
+ * flight plus one rerun, so a burst of tool calls costs at most two.
1589
1589
  * - One sync command per session. A rebase and a push must never overlap.
1590
1590
  * - Auth is read fresh for each command from the session's workspace, and goes
1591
1591
  * only into that command's git child.
@@ -1621,13 +1621,13 @@ const PENDING = {
1621
1621
  /** The error target a failure maps to: a rejected plain push asks for a confirmed lease force. */
1622
1622
  function errorTargetFor$1(command, error) {
1623
1623
  if (command.action !== "push") return { action: command.action };
1624
- return error instanceof DoomGitExpectedError && error.code === "push_needs_force" && command.force !== true ? {
1624
+ return error instanceof PoGitExpectedError && error.code === "push_needs_force" && command.force !== true ? {
1625
1625
  action: "push",
1626
1626
  forceRequired: true
1627
1627
  } : { action: "push" };
1628
1628
  }
1629
1629
  function failureText$1(error) {
1630
- if (error instanceof DoomGitExpectedError) return error.message.replace(/^\[[a-z_]+\] /u, "").replace("\nRecovery: ", " ");
1630
+ if (error instanceof PoGitExpectedError) return error.message.replace(/^\[[a-z_]+\] /u, "").replace("\nRecovery: ", " ");
1631
1631
  return "The git command failed.";
1632
1632
  }
1633
1633
  function createGitChangesChannel(options = {}) {
@@ -1745,7 +1745,7 @@ function createGitChangesChannel(options = {}) {
1745
1745
  errorTarget: void 0
1746
1746
  });
1747
1747
  run(scope, command).then(() => update(scope.sessionId, { pending: void 0 })).catch((error) => {
1748
- host.onNotice(`git ${command.action} failed for ${scope.sessionId} (${error instanceof DoomGitExpectedError ? error.code : "unexpected"})`);
1748
+ host.onNotice(`git ${command.action} failed for ${scope.sessionId} (${error instanceof PoGitExpectedError ? error.code : "unexpected"})`);
1749
1749
  update(scope.sessionId, {
1750
1750
  pending: void 0,
1751
1751
  error: failureText$1(error),
@@ -1857,7 +1857,7 @@ function parseCommand(payload) {
1857
1857
  * echoed: a git error can carry a remote URL with a token in it.
1858
1858
  */
1859
1859
  function failureText(error) {
1860
- return error instanceof DoomGitExpectedError ? error.message : "The worktree operation failed.";
1860
+ return error instanceof PoGitExpectedError ? error.message : "The worktree operation failed.";
1861
1861
  }
1862
1862
  /** Starts one direct-event subscription per managed session. */
1863
1863
  function createWorktreesChannel(options = {}) {
@@ -2051,13 +2051,16 @@ var runWorktree_server_default = defineServerTool((context) => context.root.tool
2051
2051
  //#endregion
2052
2052
  //#region generated/server.ts
2053
2053
  const at = (value, context) => typeof value === "function" ? value(context) : value;
2054
+ /* v8 ignore next -- generated normalization branch */
2055
+ const defined = (values) => values.filter((value) => value !== void 0);
2054
2056
  const via = (identity, value) => value === void 0 ? void 0 : {
2055
2057
  ...identity,
2056
2058
  ...value
2057
2059
  };
2058
- const facet = defineServerPlugin({
2060
+ const serverPlugin = defineServerPlugin({
2059
2061
  name: "@agimon-ai/po-git",
2060
2062
  providerOverrides: composeServerProviderOverrides(root_server_default),
2063
+ injects: composeRootInjects({ session: [root_server_default] }),
2061
2064
  global: (context) => ({
2062
2065
  get api() {
2063
2066
  return [at(route_server_default, context)];
@@ -2071,11 +2074,11 @@ const facet = defineServerPlugin({
2071
2074
  return [at(route_server_default, context)];
2072
2075
  },
2073
2076
  get channels() {
2074
- return [() => via({ frameType: "git_changes" }, git_changes_server_default()), () => via({ frameType: "git_worktrees" }, git_worktrees_server_default())];
2077
+ return defined([context.hosted("global") ? void 0 : () => via({ frameType: "git_changes" }, git_changes_server_default()), context.hosted("global") ? void 0 : () => via({ frameType: "git_worktrees" }, git_worktrees_server_default())]);
2075
2078
  }
2076
2079
  }),
2077
2080
  session: async (context) => {
2078
- const scopeSession = await root_server_default(context);
2081
+ const scopeSession = await context.scopeRoot("session", root_server_default, context);
2079
2082
  const contextSession = {
2080
2083
  ...context,
2081
2084
  root: scopeSession.value
@@ -2086,7 +2089,7 @@ const facet = defineServerPlugin({
2086
2089
  return [at(route_server_default, context)];
2087
2090
  },
2088
2091
  get channels() {
2089
- return [() => via({ frameType: "git_changes" }, git_changes_server_default()), () => via({ frameType: "git_worktrees" }, git_worktrees_server_default())];
2092
+ return defined([context.hosted("global") ? void 0 : () => via({ frameType: "git_changes" }, git_changes_server_default()), context.hosted("global") ? void 0 : () => via({ frameType: "git_worktrees" }, git_worktrees_server_default())]);
2090
2093
  },
2091
2094
  get hooks() {
2092
2095
  return [via({ event: "agent_settled" }, at(agent_settled_server_default, contextSession)), via({ event: "tool_execution_end" }, at(tool_execution_end_server_default, contextSession))];
@@ -2109,6 +2112,6 @@ const facet = defineServerPlugin({
2109
2112
  }
2110
2113
  });
2111
2114
  //#endregion
2112
- export { facet as default, facet };
2115
+ export { serverPlugin as default, serverPlugin };
2113
2116
 
2114
2117
  //# sourceMappingURL=server.mjs.map