gitnexus 1.6.8-rc.52 → 1.6.8-rc.54
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/core/embeddings/server-mapping.d.ts +1 -1
- package/dist/core/embeddings/server-mapping.js +7 -3
- package/dist/core/ingestion/languages/cpp/captures.js +2 -0
- package/dist/server/git-clone.d.ts +1 -1
- package/dist/server/git-clone.js +13 -4
- package/dist/server/upload-paths.d.ts +8 -2
- package/dist/server/upload-paths.js +10 -4
- package/hooks/claude/hook-db-lock-probe.cjs +17 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server Mapping Configuration
|
|
3
3
|
*
|
|
4
|
-
* Reads
|
|
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
|
|
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
|
|
10
|
-
|
|
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.
|
|
@@ -551,6 +551,8 @@ function isFollowedByPackExpansion(baseClause, childIndex) {
|
|
|
551
551
|
return true;
|
|
552
552
|
if (sibling.type === ',' || sibling.type === 'access_specifier')
|
|
553
553
|
return false;
|
|
554
|
+
if (sibling.type === 'comment')
|
|
555
|
+
continue;
|
|
554
556
|
if (sibling.isNamed)
|
|
555
557
|
return false;
|
|
556
558
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git Clone Utility
|
|
3
3
|
*
|
|
4
|
-
* Shallow-clones repositories into
|
|
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;
|
package/dist/server/git-clone.js
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git Clone Utility
|
|
3
3
|
*
|
|
4
|
-
* Shallow-clones repositories into
|
|
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
|
-
|
|
15
|
-
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
|
|
18
|
-
|
|
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
|
/**
|
|
@@ -99,6 +99,17 @@ function resolveHookBinary(tool) {
|
|
|
99
99
|
return tool;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
function hasMissingHookBinaryOverride(tool) {
|
|
103
|
+
const envKey = tool === 'lsof' ? 'GITNEXUS_HOOK_LSOF_PATH' : 'GITNEXUS_HOOK_PS_PATH';
|
|
104
|
+
const fromEnv = process.env[envKey];
|
|
105
|
+
if (!fromEnv || !String(fromEnv).trim()) return false;
|
|
106
|
+
try {
|
|
107
|
+
return !fs.existsSync(String(fromEnv).trim());
|
|
108
|
+
} catch {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
// Sentinel:
|
|
103
114
|
// undefined = not resolved yet (resolve lazily, on first lsof/ps fallback)
|
|
104
115
|
// string = self-tested coreutils timeout/gtimeout path (use as wrapper)
|
|
@@ -597,6 +608,9 @@ function linuxProcScanFindGitNexusServer(dbPathAbs, myPid) {
|
|
|
597
608
|
|
|
598
609
|
function unixLsofPsFindGitNexusServer(dbPathAbs, myPid) {
|
|
599
610
|
const guard = resolveUnixGuardTimeout();
|
|
611
|
+
// An explicit missing override models ENOENT and must fail open instead of
|
|
612
|
+
// falling through to a host binary with different process-table visibility.
|
|
613
|
+
if (hasMissingHookBinaryOverride('lsof')) return false;
|
|
600
614
|
const lsofPath = resolveHookBinary('lsof');
|
|
601
615
|
// The spawnSync timeouts below (lsof 1000ms / ps 500ms) are deliberately
|
|
602
616
|
// SHORTER than the wrapper budgets (2s / 1s): on the supervised path Node's
|
|
@@ -629,9 +643,12 @@ function unixLsofPsFindGitNexusServer(dbPathAbs, myPid) {
|
|
|
629
643
|
if (guard && (lsof.status === 124 || lsof.status === 137)) return true;
|
|
630
644
|
|
|
631
645
|
const pids = (lsof.stdout || '').split(/\s+/).filter(Boolean);
|
|
646
|
+
const psMissing = hasMissingHookBinaryOverride('ps');
|
|
632
647
|
const psPath = resolveHookBinary('ps');
|
|
633
648
|
for (const pid of pids) {
|
|
634
649
|
if (Number(pid) === myPid) continue;
|
|
650
|
+
// Missing ps means we cannot verify that this pid is a GitNexus server.
|
|
651
|
+
if (psMissing) continue;
|
|
635
652
|
const [psCmd, psArgs] = guard
|
|
636
653
|
? [guard, ['-k', '1', '1', psPath, '-p', pid, '-o', 'command=']]
|
|
637
654
|
: [psPath, ['-p', pid, '-o', 'command=']];
|
package/package.json
CHANGED