gitnexus 1.6.8-rc.52 → 1.6.8-rc.53

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,7 +1,7 @@
1
1
  /**
2
2
  * Server Mapping Configuration
3
3
  *
4
- * Reads ~/.gitnexus/server-mapping.json to map repo names to service names.
4
+ * Reads getGlobalDir()/server-mapping.json to map repo names to service names.
5
5
  * Used in embedding text to enrich metadata with microservice context.
6
6
  */
7
7
  /**
@@ -1,13 +1,17 @@
1
1
  /**
2
2
  * Server Mapping Configuration
3
3
  *
4
- * Reads ~/.gitnexus/server-mapping.json to map repo names to service names.
4
+ * Reads getGlobalDir()/server-mapping.json to map repo names to service names.
5
5
  * Used in embedding text to enrich metadata with microservice context.
6
6
  */
7
7
  import fs from 'fs/promises';
8
8
  import path from 'path';
9
- import os from 'os';
10
- const MAPPING_FILE = path.join(os.homedir(), '.gitnexus', 'server-mapping.json');
9
+ import { getGlobalDir } from '../../storage/repo-manager.js';
10
+ // Sourced from getGlobalDir() so it honors GITNEXUS_HOME (the Docker image sets
11
+ // GITNEXUS_HOME=/data/gitnexus); falls back to ~/.gitnexus when unset. Wrapped in
12
+ // path.resolve() for parity with the clone/upload roots (git-clone.ts CLONE_ROOT,
13
+ // upload-paths.ts UPLOAD_ROOT) so a relative GITNEXUS_HOME still yields an absolute path.
14
+ const MAPPING_FILE = path.resolve(path.join(getGlobalDir(), 'server-mapping.json'));
11
15
  let cachedMapping = null;
12
16
  /**
13
17
  * Read the server mapping file and return the serverName for a given repoName.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Git Clone Utility
3
3
  *
4
- * Shallow-clones repositories into ~/.gitnexus/repos/{name}/.
4
+ * Shallow-clones repositories into the clone root (getGlobalDir()/repos/{name}/).
5
5
  * If already cloned, does git pull instead.
6
6
  */
7
7
  export declare const REPO_NAME_PATTERN: RegExp;
@@ -1,18 +1,27 @@
1
1
  /**
2
2
  * Git Clone Utility
3
3
  *
4
- * Shallow-clones repositories into ~/.gitnexus/repos/{name}/.
4
+ * Shallow-clones repositories into the clone root (getGlobalDir()/repos/{name}/).
5
5
  * If already cloned, does git pull instead.
6
6
  */
7
7
  import { spawn } from 'child_process';
8
8
  import path from 'path';
9
- import os from 'os';
10
9
  import fs from 'fs/promises';
11
10
  import { isIP } from 'net';
12
11
  import { logger } from '../core/logger.js';
13
12
  import { parseRepoNameFromUrl } from '../storage/git.js';
14
- /** Root directory for all cloned repositories. Targets must resolve inside this. */
15
- const CLONE_ROOT = path.resolve(path.join(os.homedir(), '.gitnexus', 'repos'));
13
+ import { getGlobalDir } from '../storage/repo-manager.js';
14
+ /**
15
+ * Root directory for all cloned repositories. Targets must resolve inside this.
16
+ *
17
+ * Sourced from getGlobalDir() so it honors GITNEXUS_HOME — the Docker image sets
18
+ * GITNEXUS_HOME=/data/gitnexus, the persistent volume that also holds the
19
+ * registry and indexes. Without this, clones landed in the container's
20
+ * ephemeral ~/.gitnexus/repos and were lost on container recreation while the
21
+ * registry still pointed at the dead path. Falls back to ~/.gitnexus when the
22
+ * env var is unset (CLI / local installs), matching the prior behavior exactly.
23
+ */
24
+ const CLONE_ROOT = path.resolve(path.join(getGlobalDir(), 'repos'));
16
25
  // A valid git repository name is filesystem-safe: alphanumerics plus `. _ -`.
17
26
  // Rejecting anything else (including `..`, `/`, `\`, shell metacharacters)
18
27
  // guarantees getCloneDir(repoName) cannot escape CLONE_ROOT regardless of
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Upload working-directory paths.
3
3
  *
4
- * Browser folder uploads are written into ~/.gitnexus/uploads/{name}/ — a
4
+ * Browser folder uploads are written into getGlobalDir()/uploads/{name}/ — a
5
5
  * sibling of the clone root (git-clone.ts CLONE_ROOT) — so an uploaded repo
6
6
  * persists and behaves like a cloned one (the graph UI's /api/file reads its
7
7
  * files after analysis, and DELETE /api/repo removes it). Staging happens in
@@ -10,7 +10,13 @@
10
10
  * the exact Docker case this feature targets; see bridge-db.ts for the same
11
11
  * anchored-staging pattern).
12
12
  */
13
- /** Root directory for all uploaded repositories. Targets must resolve inside this. */
13
+ /**
14
+ * Root directory for all uploaded repositories. Targets must resolve inside this.
15
+ *
16
+ * Sourced from getGlobalDir() so it honors GITNEXUS_HOME and stays a sibling of
17
+ * the clone root on the same (in Docker, persistent) volume. Falls back to
18
+ * ~/.gitnexus when the env var is unset.
19
+ */
14
20
  export declare const UPLOAD_ROOT: string;
15
21
  /** Prefix for per-upload staging directories created under UPLOAD_ROOT. */
16
22
  export declare const STAGING_PREFIX = ".staging-";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Upload working-directory paths.
3
3
  *
4
- * Browser folder uploads are written into ~/.gitnexus/uploads/{name}/ — a
4
+ * Browser folder uploads are written into getGlobalDir()/uploads/{name}/ — a
5
5
  * sibling of the clone root (git-clone.ts CLONE_ROOT) — so an uploaded repo
6
6
  * persists and behaves like a cloned one (the graph UI's /api/file reads its
7
7
  * files after analysis, and DELETE /api/repo removes it). Staging happens in
@@ -11,11 +11,17 @@
11
11
  * anchored-staging pattern).
12
12
  */
13
13
  import path from 'path';
14
- import os from 'os';
15
14
  import { sanitizeRepoName } from '../storage/git.js';
16
15
  import { REPO_NAME_PATTERN } from './git-clone.js';
17
- /** Root directory for all uploaded repositories. Targets must resolve inside this. */
18
- export const UPLOAD_ROOT = path.resolve(path.join(os.homedir(), '.gitnexus', 'uploads'));
16
+ import { getGlobalDir } from '../storage/repo-manager.js';
17
+ /**
18
+ * Root directory for all uploaded repositories. Targets must resolve inside this.
19
+ *
20
+ * Sourced from getGlobalDir() so it honors GITNEXUS_HOME and stays a sibling of
21
+ * the clone root on the same (in Docker, persistent) volume. Falls back to
22
+ * ~/.gitnexus when the env var is unset.
23
+ */
24
+ export const UPLOAD_ROOT = path.resolve(path.join(getGlobalDir(), 'uploads'));
19
25
  /** Prefix for per-upload staging directories created under UPLOAD_ROOT. */
20
26
  export const STAGING_PREFIX = '.staging-';
21
27
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.8-rc.52",
3
+ "version": "1.6.8-rc.53",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",