@agimon-ai/po-git 0.0.0-alpha.185 → 0.0.0-alpha.186

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,4 +1,4 @@
1
- import { C as READ_TIMEOUT_MS, E as runGit, S as NETWORK_TIMEOUT_MS, T as createWorktreeGit, a as GIT_WORKTREE_LIFECYCLE_EVENT, 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, w as REBASE_TIMEOUT_MS } from "../worktreeOperations-DA_dbDv8.mjs";
1
+ import { C as READ_TIMEOUT_MS, E as runGit, S as NETWORK_TIMEOUT_MS, T as createWorktreeGit, a as GIT_WORKTREE_LIFECYCLE_EVENT, 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, w as REBASE_TIMEOUT_MS } from "../worktreeOperations-hT6N8oSr.mjs";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import os from "node:os";
@@ -1096,8 +1096,8 @@ async function tighten(target, mode) {
1096
1096
  if (((await fs.stat(target)).mode & LOOSE_BITS) !== 0) await fs.chmod(target, mode);
1097
1097
  } catch {}
1098
1098
  }
1099
- function createGitAuthStore(homeDir = os.homedir()) {
1100
- const file = credentialsFile(homeDir);
1099
+ function createGitAuthStore(homeDir = os.homedir(), environment = {}) {
1100
+ const file = credentialsFile(homeDir, environment);
1101
1101
  const readFile = async () => {
1102
1102
  await tighten(file, OWNER_ONLY_FILE);
1103
1103
  const raw = await readJson(file);
@@ -1119,7 +1119,7 @@ function createGitAuthStore(homeDir = os.homedir()) {
1119
1119
  const key = await workspaceKey(workspaceRoot);
1120
1120
  const current = await readFile();
1121
1121
  const next = await parseGitAuthSave(request, current.workspaces[key] ?? { method: "none" }, homeDir);
1122
- const root = poGitRoot(homeDir);
1122
+ const root = poGitRoot(homeDir, environment);
1123
1123
  await fs.mkdir(root, {
1124
1124
  recursive: true,
1125
1125
  mode: OWNER_ONLY_DIRECTORY
@@ -1319,7 +1319,8 @@ function createGitApi(openDirectory) {
1319
1319
  const operations = createWorktreeOperations({
1320
1320
  git,
1321
1321
  sessionService: context.sessionService,
1322
- ...context.homeDirectory === void 0 ? {} : { homeDir: context.homeDirectory }
1322
+ ...context.homeDirectory === void 0 ? {} : { homeDir: context.homeDirectory },
1323
+ ...context.environment === void 0 ? {} : { environment: context.environment }
1323
1324
  });
1324
1325
  /**
1325
1326
  * The new-session dialog's routes: the workspace's branches, and a top-level
@@ -1399,7 +1400,7 @@ function createGitApi(openDirectory) {
1399
1400
  return root;
1400
1401
  };
1401
1402
  const homeDir = context.homeDirectory ?? context.environment?.HOME;
1402
- const gitAuth = homeDir === void 0 ? void 0 : createGitAuthStore(homeDir);
1403
+ const gitAuth = homeDir === void 0 ? void 0 : createGitAuthStore(homeDir, context.environment);
1403
1404
  const branchDiff = createBranchDiff();
1404
1405
  const pendingReviews = /* @__PURE__ */ new Map();
1405
1406
  /**
@@ -1441,7 +1442,7 @@ function createGitApi(openDirectory) {
1441
1442
  if (homeDir === void 0) throw new Error("Git review requires the admitted host home directory.");
1442
1443
  let recordedBaseRef;
1443
1444
  try {
1444
- recordedBaseRef = (await createWorktreeRegistry(await registryFile(cwd, homeDir)).list()).find((record) => record.sessionId === context.sessionId)?.baseRef;
1445
+ recordedBaseRef = (await createWorktreeRegistry(await registryFile(cwd, homeDir, context.environment)).list()).find((record) => record.sessionId === context.sessionId)?.baseRef;
1445
1446
  } catch {
1446
1447
  recordedBaseRef = void 0;
1447
1448
  }
@@ -1898,7 +1899,7 @@ function createGitChangesChannel(options = {}) {
1898
1899
  const homeDir = options.homeDir ?? os.homedir();
1899
1900
  const diff = options.diff ?? createBranchDiff();
1900
1901
  const sync = options.sync ?? createGitSync({ homeDir });
1901
- const auth = options.auth ?? createGitAuthStore(homeDir);
1902
+ const auth = options.auth ?? createGitAuthStore(homeDir, options.environment);
1902
1903
  const latest = /* @__PURE__ */ new Map();
1903
1904
  const subscriptions = /* @__PURE__ */ new Map();
1904
1905
  const scopes = /* @__PURE__ */ new Map();
@@ -1910,7 +1911,7 @@ function createGitChangesChannel(options = {}) {
1910
1911
  /** The base the session's own worktree was created from, when it has one. */
1911
1912
  const recordedBaseRef = async (scope) => {
1912
1913
  try {
1913
- return (await createWorktreeRegistry(await registryFile(scope.cwd, homeDir)).list()).find((record) => record.sessionId === scope.sessionId)?.baseRef;
1914
+ return (await createWorktreeRegistry(await registryFile(scope.cwd, homeDir, options.environment)).list()).find((record) => record.sessionId === scope.sessionId)?.baseRef;
1914
1915
  } catch {
1915
1916
  return;
1916
1917
  }
@@ -2071,7 +2072,7 @@ function payloadOf(state) {
2071
2072
  /** Worktrees visible to this session, using the hub's live session table for ownership. */
2072
2073
  async function viewsFor(scope, deps) {
2073
2074
  try {
2074
- return (await createWorktreeRegistry(await registryFile(scope.cwd, deps.homeDir)).list()).flatMap((record) => {
2075
+ return (await createWorktreeRegistry(await registryFile(scope.cwd, deps.homeDir, deps.environment)).list()).flatMap((record) => {
2075
2076
  if (record.parentSessionId === void 0 && record.sessionId !== scope.sessionId) return [];
2076
2077
  const owned = record.parentSessionId === void 0 || record.parentSessionId === scope.sessionId;
2077
2078
  const unowned = !owned && !deps.sessionService.isLive(record.parentSessionId);
@@ -2152,7 +2153,9 @@ function createWorktreesChannel(options = {}) {
2152
2153
  if (sessionService === void 0) throw new HubUnavailableError("The cockpit session service is unavailable. Start the cockpit and try again.");
2153
2154
  const worktrees = options.operations ?? createWorktreeOperations({
2154
2155
  git: createWorktreeGit(),
2155
- sessionService
2156
+ sessionService,
2157
+ ...options.homeDir === void 0 ? {} : { homeDir: options.homeDir },
2158
+ ...options.environment === void 0 ? {} : { environment: options.environment }
2156
2159
  });
2157
2160
  /** Announces a successful mutation to this session's lifecycle subscribers. */
2158
2161
  const publishLifecycle = (scope, repositoryRoot) => {
@@ -2181,6 +2184,7 @@ function createWorktreesChannel(options = {}) {
2181
2184
  });
2182
2185
  const views = {
2183
2186
  homeDir: options.homeDir,
2187
+ environment: options.environment,
2184
2188
  sessionService
2185
2189
  };
2186
2190
  const latest = /* @__PURE__ */ new Map();
@@ -2255,7 +2259,7 @@ function createWorktreesChannel(options = {}) {
2255
2259
  if (!isWorktreeLifecycleEvent(payload)) return;
2256
2260
  let sameRepository = false;
2257
2261
  try {
2258
- sameRepository = await registryFile(scope.cwd, options.homeDir) === await registryFile(payload.repositoryRoot, options.homeDir);
2262
+ sameRepository = await registryFile(scope.cwd, options.homeDir, options.environment) === await registryFile(payload.repositoryRoot, options.homeDir, options.environment);
2259
2263
  } catch {
2260
2264
  sameRepository = false;
2261
2265
  }