gitnexus 1.6.6-rc.122 → 1.6.6-rc.124

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.
Files changed (38) hide show
  1. package/dist/cli/analyze.js +14 -0
  2. package/dist/cli/cli-message.d.ts +1 -1
  3. package/dist/cli/doctor.d.ts +18 -0
  4. package/dist/cli/doctor.js +32 -0
  5. package/dist/core/embeddings/embedder.d.ts +1 -1
  6. package/dist/core/embeddings/embedder.js +14 -1
  7. package/dist/core/embeddings/runtime-support.d.ts +41 -0
  8. package/dist/core/embeddings/runtime-support.js +65 -0
  9. package/dist/mcp/core/embedder.d.ts +1 -1
  10. package/dist/mcp/core/embedder.js +13 -1
  11. package/package.json +1 -1
  12. package/web/assets/{agent-BIjzSQCZ.js → agent-Dn6FYhTz.js} +71 -46
  13. package/web/assets/{architectureDiagram-UL44E2DR-iwCqRE70.js → architectureDiagram-UL44E2DR-PLLrYbn8.js} +1 -1
  14. package/web/assets/{chunk-LCXTWHL2-D0OjJqd8.js → chunk-LCXTWHL2-92caKtfH.js} +1 -1
  15. package/web/assets/{chunk-RG4AUYOV-D951mFBS.js → chunk-RG4AUYOV-C-sakyh5.js} +1 -1
  16. package/web/assets/{classDiagram-KGZ6W3CR-D-tRsJ_I.js → classDiagram-KGZ6W3CR-CCPRO_fZ.js} +1 -1
  17. package/web/assets/{classDiagram-v2-72OJOZXJ-BN13pOzm.js → classDiagram-v2-72OJOZXJ-DjwcwGwL.js} +1 -1
  18. package/web/assets/{diagram-3NCE3AQN-NpcMAgdG.js → diagram-3NCE3AQN-qacGQhYr.js} +1 -1
  19. package/web/assets/{diagram-GF46GFSD-DO04aQPU.js → diagram-GF46GFSD-Cow1NWUQ.js} +1 -1
  20. package/web/assets/{diagram-QXG6HAR7-BFUtFOx0.js → diagram-QXG6HAR7-CdoHgN9O.js} +1 -1
  21. package/web/assets/{diagram-WEQXMOUZ-BNwS02x6.js → diagram-WEQXMOUZ-CeTAe_78.js} +1 -1
  22. package/web/assets/{erDiagram-L5TCEMPS-Ca_E740f.js → erDiagram-L5TCEMPS-C7Md4B_p.js} +1 -1
  23. package/web/assets/{flowDiagram-H6V6AXG4-Cwqp9d4U.js → flowDiagram-H6V6AXG4-B4i2kRp5.js} +1 -1
  24. package/web/assets/{index-BQYri8X3.js → index-CTE-KR7b.js} +5 -5
  25. package/web/assets/{infoDiagram-3YFTVSEB-3tCafsxk.js → infoDiagram-3YFTVSEB-DiiwWjLx.js} +1 -1
  26. package/web/assets/{ishikawaDiagram-BNXS4ZKH-D4vr9sIY.js → ishikawaDiagram-BNXS4ZKH-Bjdu0R5v.js} +1 -1
  27. package/web/assets/{kanban-definition-75IXJCU3-CSWwMhup.js → kanban-definition-75IXJCU3-BwzP88gz.js} +1 -1
  28. package/web/assets/{mindmap-definition-2TDM6QVE-D5JmCOZe.js → mindmap-definition-2TDM6QVE-CqDUnYoO.js} +1 -1
  29. package/web/assets/{pieDiagram-CU6KROY3-DbmhH11i.js → pieDiagram-CU6KROY3-BBRqBgKU.js} +1 -1
  30. package/web/assets/{requirementDiagram-JXO7QTGE-B2zOb0nl.js → requirementDiagram-JXO7QTGE-PwMFxMKU.js} +1 -1
  31. package/web/assets/{sequenceDiagram-VS2MUI6T-CTMLTnHi.js → sequenceDiagram-VS2MUI6T-rpwpZdlM.js} +1 -1
  32. package/web/assets/{stateDiagram-7D4R322I-Bu-_08ob.js → stateDiagram-7D4R322I-BxV0xf0i.js} +1 -1
  33. package/web/assets/{stateDiagram-v2-36443NZ5-BJGihtih.js → stateDiagram-v2-36443NZ5-DPtqNTSt.js} +1 -1
  34. package/web/assets/{timeline-definition-O6YCAMPW-BGf8oqMC.js → timeline-definition-O6YCAMPW-Dr74bGqt.js} +1 -1
  35. package/web/assets/{vennDiagram-MWXL3ELB-BjrffUrr.js → vennDiagram-MWXL3ELB-DgoJI9UE.js} +1 -1
  36. package/web/assets/{wardleyDiagram-CUQ6CDDI-BSF4U_D9.js → wardleyDiagram-CUQ6CDDI-fpDdFdbe.js} +1 -1
  37. package/web/assets/{xychartDiagram-N2JHSOCM-D0pKWEwv.js → xychartDiagram-N2JHSOCM-DyarviyC.js} +1 -1
  38. package/web/index.html +1 -1
@@ -23,6 +23,7 @@ import fs from 'fs/promises';
23
23
  import { cliError } from './cli-message.js';
24
24
  import { formatElapsed } from './format-elapsed.js';
25
25
  import { isHfDownloadFailure } from '../core/embeddings/hf-env.js';
26
+ import { isLocalEmbeddingRuntimeBlockerMessage } from '../core/embeddings/runtime-support.js';
26
27
  import { warnIfNpm11NpxRisk } from './resolve-invocation.js';
27
28
  // Capture stderr.write at module load BEFORE anything (LadybugDB native
28
29
  // init, progress bar, console redirection) can monkey-patch it. The
@@ -903,6 +904,19 @@ const analyzeCommandImpl = async (inputPath, options) => {
903
904
  process.exitCode = 1;
904
905
  return;
905
906
  }
907
+ // Local embedding runtime unsupported on this platform (macOS Intel ships no
908
+ // darwin/x64 ONNX native binding, #1515). The guard threw before importing
909
+ // transformers.js, so this is a clean, actionable GitNexus message. Checked
910
+ // before the network-heuristic isHfDownloadFailure branch below (and before
911
+ // the generic module-not-found "installation may be corrupt" hint) so the
912
+ // explicit platform message always takes priority.
913
+ if (isLocalEmbeddingRuntimeBlockerMessage(msg)) {
914
+ cliError(` ${msg.replace(/\n/g, '\n ')}\n`, {
915
+ recoveryHint: 'local-embedding-unsupported',
916
+ });
917
+ process.exitCode = 1;
918
+ return;
919
+ }
906
920
  // HF download failure — show clean guidance without the raw stack trace.
907
921
  // Checked before writeFatalToStderr so the user sees one focused message
908
922
  // rather than a stack-trace dump followed by a second remediation block.
@@ -12,7 +12,7 @@ import { type CliMessageKey, type CliMessageVars } from './i18n/index.js';
12
12
  * Consumers can import this type to narrow log-record `recoveryHint`
13
13
  * fields without restating the literal list.
14
14
  */
15
- export type RecoveryHint = 'wal-corruption' | 'wal-checkpoint-threshold' | 'heap-oom-respawn' | 'native-worker-abort' | 'hf-endpoint-unreachable' | 'large-repo' | 'npm-resolution' | 'module-not-found';
15
+ export type RecoveryHint = 'wal-corruption' | 'wal-checkpoint-threshold' | 'heap-oom-respawn' | 'native-worker-abort' | 'hf-endpoint-unreachable' | 'local-embedding-unsupported' | 'large-repo' | 'npm-resolution' | 'module-not-found';
16
16
  /**
17
17
  * Common shape for the optional structured-field bag passed to
18
18
  * `cliError`/`cliWarn`/`cliInfo`. Typed so the `recoveryHint` slot is
@@ -1,3 +1,21 @@
1
1
  export declare function displayWidth(value: string): number;
2
2
  export declare function padDisplayEnd(value: string, columns: number): string;
3
+ /**
4
+ * Embedding-runtime support status for the `doctor` Embeddings section.
5
+ * Pure and DI-friendly so it can be unit-tested without running the whole
6
+ * command. Delegates the platform decision to
7
+ * {@link getLocalEmbeddingRuntimeBlocker} so the wording stays in one place.
8
+ *
9
+ * - HTTP mode: always supported (never touches the native runtime).
10
+ * - Local mode on an unsupported platform (macOS Intel, #1515): reports the
11
+ * blocker as `detail` so the caller can surface the full guidance.
12
+ */
13
+ export declare function localEmbeddingDoctorStatus(opts: {
14
+ httpMode: boolean;
15
+ platform?: NodeJS.Platform;
16
+ arch?: NodeJS.Architecture;
17
+ }): {
18
+ status: string;
19
+ detail: string | null;
20
+ };
3
21
  export declare const doctorCommand: () => Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import { getRuntimeCapabilities, getRuntimeFingerprint } from '../core/platform/capabilities.js';
2
2
  import { resolveEmbeddingConfig } from '../core/embeddings/config.js';
3
3
  import { isHttpMode } from '../core/embeddings/http-client.js';
4
+ import { getLocalEmbeddingRuntimeBlocker } from '../core/embeddings/runtime-support.js';
4
5
  import { checkLbugNative } from '../core/lbug/native-check.js';
5
6
  import { getExtensionInstallPolicy } from '../core/lbug/extension-loader.js';
6
7
  import { t } from './i18n/index.js';
@@ -42,6 +43,28 @@ export function padDisplayEnd(value, columns) {
42
43
  return value + ' '.repeat(Math.max(0, columns - displayWidth(value)));
43
44
  }
44
45
  const label = (key, width) => padDisplayEnd(t(key), width);
46
+ /**
47
+ * Embedding-runtime support status for the `doctor` Embeddings section.
48
+ * Pure and DI-friendly so it can be unit-tested without running the whole
49
+ * command. Delegates the platform decision to
50
+ * {@link getLocalEmbeddingRuntimeBlocker} so the wording stays in one place.
51
+ *
52
+ * - HTTP mode: always supported (never touches the native runtime).
53
+ * - Local mode on an unsupported platform (macOS Intel, #1515): reports the
54
+ * blocker as `detail` so the caller can surface the full guidance.
55
+ */
56
+ export function localEmbeddingDoctorStatus(opts) {
57
+ if (opts.httpMode) {
58
+ return { status: '✓ http endpoint configured', detail: null };
59
+ }
60
+ const platform = opts.platform ?? process.platform;
61
+ const arch = opts.arch ?? process.arch;
62
+ const blocker = getLocalEmbeddingRuntimeBlocker({ platform, arch });
63
+ if (blocker) {
64
+ return { status: `✗ local embeddings unavailable on ${platform}/${arch}`, detail: blocker };
65
+ }
66
+ return { status: '✓ local embeddings supported', detail: null };
67
+ }
45
68
  export const doctorCommand = async () => {
46
69
  const fingerprint = getRuntimeFingerprint();
47
70
  const capabilities = getRuntimeCapabilities();
@@ -87,4 +110,13 @@ export const doctorCommand = async () => {
87
110
  console.log(` ${label('doctor.labels.threads', 12)}${embeddingConfig.threads}`);
88
111
  console.log(` ${label('doctor.labels.batch', 12)}${t('doctor.nodes', { count: embeddingConfig.batchSize })}`);
89
112
  console.log(` ${label('doctor.labels.subBatch', 12)}${t('doctor.chunks', { count: embeddingConfig.subBatchSize })}`);
113
+ // Surface local-runtime support so macOS Intel users see up front that local
114
+ // embeddings can't load here (the bundled ONNX Runtime ships no darwin/x64
115
+ // native binding, #1515) — rather than discovering it only when
116
+ // `analyze --embeddings` fails. Literal label like the 'native' line above.
117
+ const support = localEmbeddingDoctorStatus({ httpMode: isHttpMode() });
118
+ console.log(` ${padDisplayEnd('Support:', 12)}${support.status}`);
119
+ if (support.detail) {
120
+ process.stderr.write(`\n${support.detail.replace(/^/gm, ' ')}\n\n`);
121
+ }
90
122
  };
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * Uses snowflake-arctic-embed-xs by default (22M params, 384 dims, ~90MB)
8
8
  */
9
- import { type FeatureExtractionPipeline } from '@huggingface/transformers';
9
+ import type { FeatureExtractionPipeline } from '@huggingface/transformers';
10
10
  import { type EmbeddingConfig, type ModelProgress } from './types.js';
11
11
  /**
12
12
  * Progress callback type for model loading
@@ -12,7 +12,6 @@
12
12
  if (!process.env.ORT_LOG_LEVEL) {
13
13
  process.env.ORT_LOG_LEVEL = '3';
14
14
  }
15
- import { pipeline, env, } from '@huggingface/transformers';
16
15
  import { existsSync } from 'fs';
17
16
  import { execFileSync } from 'child_process';
18
17
  import { join, dirname } from 'path';
@@ -21,6 +20,7 @@ import { DEFAULT_EMBEDDING_CONFIG } from './types.js';
21
20
  import { isHttpMode, getHttpDimensions, httpEmbed } from './http-client.js';
22
21
  import { resolveEmbeddingConfig } from './config.js';
23
22
  import { applyHfEnvOverrides, isHfDownloadFailure, withHfDownloadRetry } from './hf-env.js';
23
+ import { getLocalEmbeddingRuntimeBlocker } from './runtime-support.js';
24
24
  import { logger } from '../logger.js';
25
25
  /**
26
26
  * Check whether the onnxruntime-node package that @huggingface/transformers
@@ -117,6 +117,16 @@ export const initEmbedder = async (onProgress, config = {}, forceDevice) => {
117
117
  throw new Error('initEmbedder() should not be called in HTTP mode. ' +
118
118
  'Use embedText()/embedBatch() which handle HTTP transparently.');
119
119
  }
120
+ // Fail fast on platforms where the bundled native ONNX Runtime binding is not
121
+ // shipped (macOS Intel, #1515). Must run before any transformers.js /
122
+ // onnxruntime-node import or resolution — otherwise the native module load
123
+ // crashes with a raw "Cannot find module ...onnxruntime_binding.node" that
124
+ // ONNX_WEB_BACKEND=wasm cannot rescue (#1516). HTTP mode was already handled
125
+ // above, so this only blocks the local-runtime path.
126
+ const runtimeBlocker = getLocalEmbeddingRuntimeBlocker();
127
+ if (runtimeBlocker) {
128
+ throw new Error(runtimeBlocker);
129
+ }
120
130
  // Return existing instance if available
121
131
  if (embedderInstance) {
122
132
  return embedderInstance;
@@ -135,6 +145,9 @@ export const initEmbedder = async (onProgress, config = {}, forceDevice) => {
135
145
  const requestedDevice = forceDevice || (finalConfig.device === 'auto' ? gpuDevice : finalConfig.device);
136
146
  initPromise = (async () => {
137
147
  try {
148
+ // Lazy-load transformers.js only after the runtime guard has passed, so
149
+ // unsupported platforms never reach the native ONNX import (#1515).
150
+ const { pipeline, env } = await import('@huggingface/transformers');
138
151
  // Configure transformers.js environment
139
152
  env.allowLocalModels = false;
140
153
  // Bridge user-controlled env vars to transformers.js: HF_HOME →
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Local embedding runtime support guard.
3
+ *
4
+ * The bundled local embedding stack (`@huggingface/transformers` →
5
+ * `onnxruntime-node`) only ships native ONNX Runtime bindings for a subset of
6
+ * platform/arch pairs. On macOS Intel (`darwin`/`x64`), `onnxruntime-node`
7
+ * ships no `bin/napi-v6/darwin/x64/onnxruntime_binding.node`, so *importing*
8
+ * transformers.js throws a raw `Cannot find module ...onnxruntime_binding.node`
9
+ * before any device/backend selection can run (#1515). `ONNX_WEB_BACKEND=wasm`
10
+ * cannot rescue this — the failure is at native-module import time, not backend
11
+ * selection (#1516).
12
+ *
13
+ * This module is intentionally free of any native or transformers.js import (at
14
+ * module scope or inside its functions) so it can be consulted *before* the
15
+ * dynamic import that would crash. HTTP embedding mode never touches the native
16
+ * runtime, so callers in HTTP mode must skip this guard.
17
+ */
18
+ export interface LocalEmbeddingRuntimeOptions {
19
+ platform?: NodeJS.Platform;
20
+ arch?: NodeJS.Architecture;
21
+ }
22
+ /**
23
+ * Return a human-readable explanation when the *local* embedding runtime cannot
24
+ * load on this platform, or `null` when local embeddings are expected to work.
25
+ *
26
+ * Only `darwin`/`x64` is blocked today: it is the one platform/arch pair where
27
+ * the bundled `onnxruntime-node` ships no native binding (#1515). Every other
28
+ * platform returns `null` and follows the normal device-probe path, so genuine
29
+ * ONNX failures on supported platforms are never masked by this message.
30
+ *
31
+ * Accepts an explicit `{ platform, arch }` for testing; defaults to the current
32
+ * process values.
33
+ */
34
+ export declare const getLocalEmbeddingRuntimeBlocker: (options?: LocalEmbeddingRuntimeOptions) => string | null;
35
+ /**
36
+ * True when `message` is the macOS-Intel local-embedding blocker produced by
37
+ * {@link getLocalEmbeddingRuntimeBlocker}. Lets the CLI surface a clean,
38
+ * actionable message instead of a raw stack trace, without coupling to the
39
+ * full wording.
40
+ */
41
+ export declare const isLocalEmbeddingRuntimeBlockerMessage: (message: string) => boolean;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Local embedding runtime support guard.
3
+ *
4
+ * The bundled local embedding stack (`@huggingface/transformers` →
5
+ * `onnxruntime-node`) only ships native ONNX Runtime bindings for a subset of
6
+ * platform/arch pairs. On macOS Intel (`darwin`/`x64`), `onnxruntime-node`
7
+ * ships no `bin/napi-v6/darwin/x64/onnxruntime_binding.node`, so *importing*
8
+ * transformers.js throws a raw `Cannot find module ...onnxruntime_binding.node`
9
+ * before any device/backend selection can run (#1515). `ONNX_WEB_BACKEND=wasm`
10
+ * cannot rescue this — the failure is at native-module import time, not backend
11
+ * selection (#1516).
12
+ *
13
+ * This module is intentionally free of any native or transformers.js import (at
14
+ * module scope or inside its functions) so it can be consulted *before* the
15
+ * dynamic import that would crash. HTTP embedding mode never touches the native
16
+ * runtime, so callers in HTTP mode must skip this guard.
17
+ */
18
+ /**
19
+ * Stable lead line of the macOS-Intel blocker message. Also used to recognise
20
+ * the thrown error in the CLI error handler without coupling to the full
21
+ * wording (see {@link isLocalEmbeddingRuntimeBlockerMessage}).
22
+ */
23
+ const LOCAL_EMBEDDING_BLOCKER_LEAD = 'Local semantic embeddings are unavailable on macOS Intel (darwin/x64).';
24
+ /**
25
+ * Return a human-readable explanation when the *local* embedding runtime cannot
26
+ * load on this platform, or `null` when local embeddings are expected to work.
27
+ *
28
+ * Only `darwin`/`x64` is blocked today: it is the one platform/arch pair where
29
+ * the bundled `onnxruntime-node` ships no native binding (#1515). Every other
30
+ * platform returns `null` and follows the normal device-probe path, so genuine
31
+ * ONNX failures on supported platforms are never masked by this message.
32
+ *
33
+ * Accepts an explicit `{ platform, arch }` for testing; defaults to the current
34
+ * process values.
35
+ */
36
+ export const getLocalEmbeddingRuntimeBlocker = (options = {}) => {
37
+ const platform = options.platform ?? process.platform;
38
+ const arch = options.arch ?? process.arch;
39
+ if (platform === 'darwin' && arch === 'x64') {
40
+ return [
41
+ LOCAL_EMBEDDING_BLOCKER_LEAD,
42
+ 'The bundled ONNX Runtime package (onnxruntime-node) does not ship a',
43
+ 'darwin/x64 native binding, so the local embedding model cannot load here.',
44
+ 'ONNX_WEB_BACKEND=wasm does not help: the failure happens while importing',
45
+ 'the native runtime, before any backend can be selected. Forcing',
46
+ 'GITNEXUS_EMBEDDING_DEVICE=wasm (or cpu) does not help either, for the same reason.',
47
+ '',
48
+ 'Use one of these instead:',
49
+ ' - Run analyze without --embeddings (all other indexing still works).',
50
+ ' - Point GITNEXUS_EMBEDDING_URL (with GITNEXUS_EMBEDDING_MODEL) at an',
51
+ ' OpenAI-compatible /v1/embeddings endpoint to embed over HTTP.',
52
+ ' - Run GitNexus on Linux or in Docker, where the native binding ships.',
53
+ ' - Run GitNexus on Apple Silicon (darwin/arm64), which ships a binding.',
54
+ ' - Use a future GitNexus build that restores darwin/x64 ONNX support.',
55
+ ].join('\n');
56
+ }
57
+ return null;
58
+ };
59
+ /**
60
+ * True when `message` is the macOS-Intel local-embedding blocker produced by
61
+ * {@link getLocalEmbeddingRuntimeBlocker}. Lets the CLI surface a clean,
62
+ * actionable message instead of a raw stack trace, without coupling to the
63
+ * full wording.
64
+ */
65
+ export const isLocalEmbeddingRuntimeBlockerMessage = (message) => message.includes(LOCAL_EMBEDDING_BLOCKER_LEAD);
@@ -4,7 +4,7 @@
4
4
  * Singleton factory for transformers.js embedding pipeline.
5
5
  * For MCP, we only need to compute query embeddings, not batch embed.
6
6
  */
7
- import { type FeatureExtractionPipeline } from '@huggingface/transformers';
7
+ import type { FeatureExtractionPipeline } from '@huggingface/transformers';
8
8
  /**
9
9
  * Initialize the embedding model (lazy, on first search)
10
10
  */
@@ -4,10 +4,10 @@
4
4
  * Singleton factory for transformers.js embedding pipeline.
5
5
  * For MCP, we only need to compute query embeddings, not batch embed.
6
6
  */
7
- import { pipeline, env } from '@huggingface/transformers';
8
7
  import { isHttpMode, getHttpDimensions, httpEmbedQuery, } from '../../core/embeddings/http-client.js';
9
8
  import { resolveEmbeddingConfig } from '../../core/embeddings/config.js';
10
9
  import { applyHfEnvOverrides, isHfDownloadFailure, withHfDownloadRetry, } from '../../core/embeddings/hf-env.js';
10
+ import { getLocalEmbeddingRuntimeBlocker } from '../../core/embeddings/runtime-support.js';
11
11
  import { silenceStdout, restoreStdout, realStderrWrite } from '../../core/lbug/pool-adapter.js';
12
12
  import { logger } from '../../core/logger.js';
13
13
  // Model config
@@ -23,6 +23,15 @@ export const initEmbedder = async () => {
23
23
  if (isHttpMode()) {
24
24
  throw new Error('initEmbedder() should not be called in HTTP mode.');
25
25
  }
26
+ // Fail fast on platforms where the bundled native ONNX Runtime binding is not
27
+ // shipped (macOS Intel, #1515). Must run before any transformers.js /
28
+ // onnxruntime-node import or resolution — otherwise the native module load
29
+ // crashes with a raw "Cannot find module ...onnxruntime_binding.node" that
30
+ // ONNX_WEB_BACKEND=wasm cannot rescue (#1516).
31
+ const runtimeBlocker = getLocalEmbeddingRuntimeBlocker();
32
+ if (runtimeBlocker) {
33
+ throw new Error(runtimeBlocker);
34
+ }
26
35
  if (embedderInstance) {
27
36
  return embedderInstance;
28
37
  }
@@ -32,6 +41,9 @@ export const initEmbedder = async () => {
32
41
  isInitializing = true;
33
42
  initPromise = (async () => {
34
43
  try {
44
+ // Lazy-load transformers.js only after the runtime guard has passed, so
45
+ // unsupported platforms never reach the native ONNX import (#1515).
46
+ const { pipeline, env } = await import('@huggingface/transformers');
35
47
  env.allowLocalModels = false;
36
48
  // Bridge user-controlled env vars to transformers.js: HF_HOME →
37
49
  // env.cacheDir, HF_ENDPOINT → env.remoteHost (#1205). Centralised in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.6-rc.122",
3
+ "version": "1.6.6-rc.124",
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",
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./chunk-CilyBKbf.js";import{o as n,s as r}from"./index-BQYri8X3.js";import{buildDynamicSystemPrompt as i}from"./context-builder-_HS0v2ma.js";var a=Object.defineProperty,o=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n};function s(e){let t=Symbol.for(e);return{brand(n,r){let i=r?Symbol.for(`${e}.${r}`):t;class a extends n{[i]=!0;constructor(...e){super(...e)}static isInstance(e){return typeof e==`object`&&!!e&&i in e&&e[i]===!0}}return Object.defineProperty(a,`name`,{value:n.name}),a},sub(t){return s(`${e}.${t}`)},isInstance(e){return typeof e==`object`&&!!e&&t in e&&e[t]===!0}}}var c=s(`langchain`),l=o({ContextOverflowError:()=>m,LangChainError:()=>f,ModelAbortError:()=>p,addLangChainErrorFields:()=>u,ns:()=>d});function u(e,t){return e.lc_error_code=t,e.message=`${e.message}\n\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/\n`,e}var d=c.sub(`error`),f=class extends d.brand(Error){name=`LangChainError`;constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},p=class extends d.brand(f,`model-abort`){name=`ModelAbortError`;partialOutput;constructor(e,t){super(e),this.partialOutput=t}},m=class e extends d.brand(f,`context-overflow`){name=`ContextOverflowError`;cause;constructor(e){super(e??`Input exceeded the model's context window.`)}static fromError(t){let n=new e(t.message);return n.cause=t,n}};function h(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`tool_call`)}function g(e){return!!(e&&typeof e==`object`&&`toolCall`in e&&e.toolCall!=null&&typeof e.toolCall==`object`&&`id`in e.toolCall&&typeof e.toolCall.id==`string`)}var _=class extends Error{output;constructor(e,t){super(e),this.output=t}};function v(e,t=b){e=e.trim();let n=e.indexOf("```");if(n===-1)return t(e);let r=e.substring(n+3);r.startsWith(`json
1
+ import{r as e,t}from"./chunk-CilyBKbf.js";import{o as n,s as r}from"./index-CTE-KR7b.js";import{buildDynamicSystemPrompt as i}from"./context-builder-_HS0v2ma.js";var a=Object.defineProperty,o=(e,t)=>{let n={};for(var r in e)a(n,r,{get:e[r],enumerable:!0});return t||a(n,Symbol.toStringTag,{value:`Module`}),n};function s(e){let t=Symbol.for(e);return{brand(n,r){let i=r?Symbol.for(`${e}.${r}`):t;class a extends n{[i]=!0;constructor(...e){super(...e)}static isInstance(e){return typeof e==`object`&&!!e&&i in e&&e[i]===!0}}return Object.defineProperty(a,`name`,{value:n.name}),a},sub(t){return s(`${e}.${t}`)},isInstance(e){return typeof e==`object`&&!!e&&t in e&&e[t]===!0}}}var c=s(`langchain`),l=o({ContextOverflowError:()=>m,LangChainError:()=>f,ModelAbortError:()=>p,addLangChainErrorFields:()=>u,ns:()=>d});function u(e,t){return e.lc_error_code=t,e.message=`${e.message}\n\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${t}/\n`,e}var d=c.sub(`error`),f=class extends d.brand(Error){name=`LangChainError`;constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},p=class extends d.brand(f,`model-abort`){name=`ModelAbortError`;partialOutput;constructor(e,t){super(e),this.partialOutput=t}},m=class e extends d.brand(f,`context-overflow`){name=`ContextOverflowError`;cause;constructor(e){super(e??`Input exceeded the model's context window.`)}static fromError(t){let n=new e(t.message);return n.cause=t,n}};function h(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`tool_call`)}function g(e){return!!(e&&typeof e==`object`&&`toolCall`in e&&e.toolCall!=null&&typeof e.toolCall==`object`&&`id`in e.toolCall&&typeof e.toolCall.id==`string`)}var _=class extends Error{output;constructor(e,t){super(e),this.output=t}};function v(e,t=b){e=e.trim();let n=e.indexOf("```");if(n===-1)return t(e);let r=e.substring(n+3);r.startsWith(`json
2
2
  `)?r=r.substring(5):r.startsWith(`json`)?r=r.substring(4):r.startsWith(`
3
3
  `)&&(r=r.substring(1));let i=r.indexOf("```"),a=r;return i!==-1&&(a=r.substring(0,i)),t(a.trim())}function y(e){try{return JSON.parse(e)}catch{}let t=e.trim();if(t.length===0)throw Error(`Unexpected end of JSON input`);let n=0;function r(){for(;n<t.length&&/\s/.test(t[n]);)n+=1}function i(){if(t[n]!==`"`)throw Error(`Expected '"' at position ${n}, got '${t[n]}'`);n+=1;let e=``,r=!1;for(;n<t.length;){let i=t[n];if(r){if(i===`n`)e+=`
4
4
  `;else if(i===`t`)e+=` `;else if(i===`r`)e+=`\r`;else if(i===`\\`)e+=`\\`;else if(i===`"`)e+=`"`;else if(i===`b`)e+=`\b`;else if(i===`f`)e+=`\f`;else if(i===`/`)e+=`/`;else if(i===`u`){let r=t.substring(n+1,n+5);if(/^[0-9A-Fa-f]{0,4}$/.test(r))r.length===4?e+=String.fromCharCode(Number.parseInt(r,16)):e+=`u${r}`,n+=r.length;else throw Error(`Invalid unicode escape sequence '\\u${r}' at position ${n}`)}else throw Error(`Invalid escape sequence '\\${i}' at position ${n}`);r=!1}else if(i===`\\`)r=!0;else if(i===`"`)return n+=1,e;else e+=i;n+=1}return r&&(e+=`\\`),e}function a(){let e=n,r=``;if(t[n]===`-`&&(r+=`-`,n+=1),n<t.length&&t[n]===`0`&&(r+=`0`,n+=1,t[n]>=`0`&&t[n]<=`9`))throw Error(`Invalid number at position ${e}`);if(n<t.length&&t[n]>=`1`&&t[n]<=`9`)for(;n<t.length&&t[n]>=`0`&&t[n]<=`9`;)r+=t[n],n+=1;if(n<t.length&&t[n]===`.`)for(r+=`.`,n+=1;n<t.length&&t[n]>=`0`&&t[n]<=`9`;)r+=t[n],n+=1;if(n<t.length&&(t[n]===`e`||t[n]===`E`))for(r+=t[n],n+=1,n<t.length&&(t[n]===`+`||t[n]===`-`)&&(r+=t[n],n+=1);n<t.length&&t[n]>=`0`&&t[n]<=`9`;)r+=t[n],n+=1;if(r===`-`)return-0;let i=Number.parseFloat(r);if(Number.isNaN(i))throw n=e,Error(`Invalid number '${r}' at position ${e}`);return i}function o(){if(r(),n>=t.length)throw Error(`Unexpected end of input at position ${n}`);let e=t[n];if(e===`{`)return c();if(e===`[`)return s();if(e===`"`)return i();if(`null`.startsWith(t.substring(n,n+4)))return n+=Math.min(4,t.length-n),null;if(`true`.startsWith(t.substring(n,n+4)))return n+=Math.min(4,t.length-n),!0;if(`false`.startsWith(t.substring(n,n+5)))return n+=Math.min(5,t.length-n),!1;if(e===`-`||e>=`0`&&e<=`9`)return a();throw Error(`Unexpected character '${e}' at position ${n}`)}function s(){if(t[n]!==`[`)throw Error(`Expected '[' at position ${n}, got '${t[n]}'`);let e=[];if(n+=1,r(),n>=t.length)return e;if(t[n]===`]`)return n+=1,e;for(;n<t.length;){if(r(),n>=t.length||(e.push(o()),r(),n>=t.length))return e;if(t[n]===`]`)return n+=1,e;if(t[n]===`,`){n+=1;continue}throw Error(`Expected ',' or ']' at position ${n}, got '${t[n]}'`)}return e}function c(){if(t[n]!==`{`)throw Error(`Expected '{' at position ${n}, got '${t[n]}'`);let e={};if(n+=1,r(),n>=t.length)return e;if(t[n]===`}`)return n+=1,e;for(;n<t.length;){if(r(),n>=t.length)return e;let a=i();if(r(),n>=t.length)return e;if(t[n]!==`:`)throw Error(`Expected ':' at position ${n}, got '${t[n]}'`);if(n+=1,r(),n>=t.length||(e[a]=o(),r(),n>=t.length))return e;if(t[n]===`}`)return n+=1,e;if(t[n]===`,`){n+=1;continue}throw Error(`Expected ',' or '}' at position ${n}, got '${t[n]}'`)}return e}let l=o();if(r(),n<t.length)throw Error(`Unexpected character '${t[n]}' at position ${n}`);return l}function b(e){try{return e===void 0?null:y(e)}catch{return null}}var ee=t(((e,t)=>{t.exports=function(e,t){if(typeof e!=`string`)throw TypeError(`Expected a string`);return t=t===void 0?`_`:t,e.replace(/([a-z\d])([A-Z])/g,`$1`+t+`$2`).replace(/([A-Z]+)([A-Z][a-z\d]+)/g,`$1`+t+`$2`).toLowerCase()}})),te=t(((e,t)=>{var n=/[\p{Lu}]/u,r=/[\p{Ll}]/u,i=/^[\p{Lu}](?![\p{Lu}])/gu,a=/([\p{Alpha}\p{N}_]|$)/u,o=/[_.\- ]+/,s=RegExp(`^`+o.source),c=new RegExp(o.source+a.source,`gu`),l=RegExp(`\\d+`+a.source,`gu`),u=(e,t,i)=>{let a=!1,o=!1,s=!1;for(let c=0;c<e.length;c++){let l=e[c];a&&n.test(l)?(e=e.slice(0,c)+`-`+e.slice(c),a=!1,s=o,o=!0,c++):o&&s&&r.test(l)?(e=e.slice(0,c-1)+`-`+e.slice(c-1),s=o,o=!1,a=!0):(a=t(l)===l&&i(l)!==l,s=o,o=i(l)===l&&t(l)!==l)}return e},d=(e,t)=>(i.lastIndex=0,e.replace(i,e=>t(e))),f=(e,t)=>(c.lastIndex=0,l.lastIndex=0,e.replace(c,(e,n)=>t(n)).replace(l,e=>t(e))),p=(e,t)=>{if(!(typeof e==`string`||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join(`-`):e.trim(),e.length===0)return``;let n=t.locale===!1?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),r=t.locale===!1?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);return e.length===1?t.pascalCase?r(e):n(e):(e!==n(e)&&(e=u(e,n,r)),e=e.replace(s,``),e=t.preserveConsecutiveUppercase?d(e,n):n(e),t.pascalCase&&(e=r(e.charAt(0))+e.slice(1)),f(e,r))};t.exports=p,t.exports.default=p})),ne=e(ee(),1),x=e(te(),1);function re(e,t){return t?.[e]||(0,ne.default)(e)}function ie(e,t){return t?.[e]||(0,x.default)(e)}function ae(e,t,n){let r={};for(let i in e)Object.hasOwn(e,i)&&(r[t(i,n)]=e[i]);return r}var oe=`__lc_escaped__`;function se(e){return`lc`in e||Object.keys(e).length===1&&`__lc_escaped__`in e}function ce(e){return{[oe]:e}}function le(e){return Object.keys(e).length===1&&`__lc_escaped__`in e}function S(e){return typeof e==`object`&&!!e&&`lc_serializable`in e&&typeof e.toJSON==`function`}function ue(e){let t;return t=typeof e==`object`&&e?`lc_id`in e&&Array.isArray(e.lc_id)?e.lc_id:[e.constructor?.name??`Object`]:[typeof e],{lc:1,type:`not_implemented`,id:t}}function de(e,t=new WeakSet){if(typeof e==`object`&&e&&!Array.isArray(e)){if(t.has(e))return ue(e);if(S(e))return e;t.add(e);let n=e;if(se(n))return t.delete(e),ce(n);let r={};for(let[e,i]of Object.entries(n))r[e]=de(i,t);return t.delete(e),r}return Array.isArray(e)?e.map(e=>de(e,t)):e}function fe(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e;if(le(t))return t[oe];let n={};for(let[e,r]of Object.entries(t))n[e]=fe(r);return n}return Array.isArray(e)?e.map(e=>fe(e)):e}var pe=o({Serializable:()=>_e,get_lc_unique_name:()=>ge});function me(e){return Array.isArray(e)?[...e]:{...e}}function he(e,t){let n=me(e);for(let[e,r]of Object.entries(t)){let[t,...i]=e.split(`.`).reverse(),a=n;for(let e of i.reverse()){if(a[e]===void 0)break;a[e]=me(a[e]),a=a[e]}a[t]!==void 0&&(a[t]={lc:1,type:`secret`,id:[r]})}return n}function ge(e){let t=Object.getPrototypeOf(e);return typeof e.lc_name==`function`&&(typeof t.lc_name!=`function`||e.lc_name()!==t.lc_name())?e.lc_name():e.name}var _e=class e{lc_serializable=!1;lc_kwargs;static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,ge(this.constructor)]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}constructor(e,...t){this.lc_serializable_keys===void 0?this.lc_kwargs=e??{}:this.lc_kwargs=Object.fromEntries(Object.entries(e||{}).filter(([e])=>this.lc_serializable_keys?.includes(e)))}toJSON(){if(!this.lc_serializable||this.lc_kwargs instanceof e||typeof this.lc_kwargs!=`object`||Array.isArray(this.lc_kwargs))return this.toJSONNotImplemented();let t={},n={},r=Object.keys(this.lc_kwargs).reduce((e,t)=>(e[t]=t in this?this[t]:this.lc_kwargs[t],e),{});for(let e=Object.getPrototypeOf(this);e;e=Object.getPrototypeOf(e))Object.assign(t,Reflect.get(e,`lc_aliases`,this)),Object.assign(n,Reflect.get(e,`lc_secrets`,this)),Object.assign(r,Reflect.get(e,`lc_attributes`,this));Object.keys(n).forEach(e=>{let t=this,n=r,[i,...a]=e.split(`.`).reverse();for(let e of a.reverse()){if(!(e in t)||t[e]===void 0)return;(!(e in n)||n[e]===void 0)&&(typeof t[e]==`object`&&t[e]!=null?n[e]={}:Array.isArray(t[e])&&(n[e]=[])),t=t[e],n=n[e]}i in t&&t[i]!==void 0&&(n[i]=n[i]||t[i])});let i={},a=new WeakSet;a.add(this);for(let[e,t]of Object.entries(r))i[e]=de(t,a);let o=ae(Object.keys(n).length?he(i,n):i,re,t);return{lc:1,type:`constructor`,id:this.lc_id,kwargs:o}}toJSONNotImplemented(){return{lc:1,type:`not_implemented`,id:this.lc_id}}};function ve(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`&&`source_type`in e&&(e.source_type===`url`||e.source_type===`base64`||e.source_type===`text`||e.source_type===`id`)}function ye(e){return ve(e)&&e.source_type===`url`&&`url`in e&&typeof e.url==`string`}function be(e){return ve(e)&&e.source_type===`base64`&&`data`in e&&typeof e.data==`string`}function xe(e){return ve(e)&&e.source_type===`text`&&`text`in e&&typeof e.text==`string`}function Se(e){return ve(e)&&e.source_type===`id`&&`id`in e&&typeof e.id==`string`}function Ce(e){if(ve(e)){if(e.source_type===`url`)return{type:`image_url`,image_url:{url:e.url}};if(e.source_type===`base64`){if(!e.mime_type)throw Error(`mime_type key is required for base64 data.`);return{type:`image_url`,image_url:{url:`data:${e.mime_type};base64,${e.data}`}}}}throw Error(`Unsupported source type. Only 'url' and 'base64' are supported.`)}function we(e){let t=e.split(`;`)[0].split(`/`);if(t.length!==2)throw Error(`Invalid mime type: "${e}" - does not match type/subtype format.`);let n=t[0].trim(),r=t[1].trim();if(n===``||r===``)throw Error(`Invalid mime type: "${e}" - type or subtype is empty.`);let i={};for(let t of e.split(`;`).slice(1)){let n=t.split(`=`);if(n.length!==2)throw Error(`Invalid parameter syntax in mime type: "${e}".`);let r=n[0].trim(),a=n[1].trim();if(r===``)throw Error(`Invalid parameter syntax in mime type: "${e}".`);i[r]=a}return{type:n,subtype:r,parameters:i}}function Te({dataUrl:e,asTypedArray:t=!1}){let n=e.match(/^data:(\w+\/\w+);base64,([A-Za-z0-9+/]+=*)$/),r;if(n){r=n[1].toLowerCase();let e=t?Uint8Array.from(atob(n[2]),e=>e.charCodeAt(0)):n[2];return{mime_type:r,data:e}}}function Ee(e,t){if(e.type===`text`){if(!t.fromStandardTextBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardTextBlock\` method.`);return t.fromStandardTextBlock(e)}if(e.type===`image`){if(!t.fromStandardImageBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardImageBlock\` method.`);return t.fromStandardImageBlock(e)}if(e.type===`audio`){if(!t.fromStandardAudioBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardAudioBlock\` method.`);return t.fromStandardAudioBlock(e)}if(e.type===`file`){if(!t.fromStandardFileBlock)throw Error(`Converter for ${t.providerName} does not implement \`fromStandardFileBlock\` method.`);return t.fromStandardFileBlock(e)}throw Error(`Unable to convert content block type '${e.type}' to provider-specific format: not recognized.`)}function C(e,t){return w(e)&&e.type===t}function w(e){return typeof e==`object`&&!!e}function De(e){return Array.isArray(e)}function T(e){return typeof e==`string`}function Oe(e){return typeof e==`number`}function ke(e){return e instanceof Uint8Array}function E(e){try{return JSON.parse(e)}catch{return}}var Ae=e=>e();function je(e){if(e.type===`char_location`&&T(e.document_title)&&Oe(e.start_char_index)&&Oe(e.end_char_index)&&T(e.cited_text)){let{document_title:t,start_char_index:n,end_char_index:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`char`,title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type===`page_location`&&T(e.document_title)&&Oe(e.start_page_number)&&Oe(e.end_page_number)&&T(e.cited_text)){let{document_title:t,start_page_number:n,end_page_number:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`page`,title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type===`content_block_location`&&T(e.document_title)&&Oe(e.start_block_index)&&Oe(e.end_block_index)&&T(e.cited_text)){let{document_title:t,start_block_index:n,end_block_index:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`block`,title:t??void 0,startIndex:n,endIndex:r,citedText:i}}if(e.type===`web_search_result_location`&&T(e.url)&&T(e.title)&&T(e.encrypted_index)&&T(e.cited_text)){let{url:t,title:n,encrypted_index:r,cited_text:i,...a}=e;return{...a,type:`citation`,source:`url`,url:t,title:n,startIndex:Number(r),endIndex:Number(r),citedText:i}}if(e.type===`search_result_location`&&T(e.source)&&T(e.title)&&Oe(e.start_block_index)&&Oe(e.end_block_index)&&T(e.cited_text)){let{source:t,title:n,start_block_index:r,end_block_index:i,cited_text:a,...o}=e;return{...o,type:`citation`,source:`search`,url:t,title:n??void 0,startIndex:r,endIndex:i,citedText:a}}}function Me(e){if(C(e,`document`)&&w(e.source)&&`type`in e.source){if(e.source.type===`base64`&&T(e.source.media_type)&&T(e.source.data))return{type:`file`,mimeType:e.source.media_type,data:e.source.data};if(e.source.type===`url`&&T(e.source.url))return{type:`file`,url:e.source.url};if(e.source.type===`file`&&T(e.source.file_id))return{type:`file`,fileId:e.source.file_id};if(e.source.type===`text`&&T(e.source.data))return{type:`file`,mimeType:String(e.source.media_type??`text/plain`),data:e.source.data}}else if(C(e,`image`)&&w(e.source)&&`type`in e.source){if(e.source.type===`base64`&&T(e.source.media_type)&&T(e.source.data))return{type:`image`,mimeType:e.source.media_type,data:e.source.data};if(e.source.type===`url`&&T(e.source.url))return{type:`image`,url:e.source.url};if(e.source.type===`file`&&T(e.source.file_id))return{type:`image`,fileId:e.source.file_id}}}function Ne(e){function*t(){for(let t of e){let e=Me(t);e?yield e:yield t}}return Array.from(t())}function Pe(e){function*t(){let t=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content;for(let n of t){if(C(n,`text`)&&T(n.text)){let{text:e,citations:t,...r}=n;if(De(t)&&t.length){let n=t.reduce((e,t)=>{let n=je(t);return n?[...e,n]:e},[]);yield{...r,type:`text`,text:e,annotations:n};continue}else{yield{...r,type:`text`,text:e};continue}}else if(C(n,`thinking`)&&T(n.thinking)){let{thinking:e,signature:t,...r}=n;yield{...r,type:`reasoning`,reasoning:e,signature:t};continue}else if(C(n,`redacted_thinking`)){yield{type:`non_standard`,value:n};continue}else if(C(n,`tool_use`)&&T(n.name)&&T(n.id)){yield{type:`tool_call`,id:n.id,name:n.name,args:n.input};continue}else if(C(n,`input_json_delta`)){if(Ie(e)&&e.tool_call_chunks?.length){let t=e.tool_call_chunks[0];yield{type:`tool_call_chunk`,id:t.id,name:t.name,args:t.args,index:t.index};continue}}else if(C(n,`server_tool_use`)&&T(n.name)&&T(n.id)){let{name:e,id:t}=n;if(e===`web_search`){yield{id:t,type:`server_tool_call`,name:`web_search`,args:{query:Ae(()=>{if(typeof n.input==`string`)return n.input;if(w(n.input)&&T(n.input.query))return n.input.query;if(T(n.partial_json)){let e=E(n.partial_json);if(e?.query)return e.query}return``})}};continue}else if(n.name===`code_execution`){yield{id:t,type:`server_tool_call`,name:`code_execution`,args:{code:Ae(()=>{if(typeof n.input==`string`)return n.input;if(w(n.input)&&T(n.input.code))return n.input.code;if(T(n.partial_json)){let e=E(n.partial_json);if(e?.code)return e.code}return``})}};continue}}else if(C(n,`web_search_tool_result`)&&T(n.tool_use_id)&&De(n.content)){let{content:e,tool_use_id:t}=n;yield{type:`server_tool_call_result`,name:`web_search`,toolCallId:t,status:`success`,output:{urls:e.reduce((e,t)=>C(t,`web_search_result`)?[...e,t.url]:e,[])}};continue}else if(C(n,`code_execution_tool_result`)&&T(n.tool_use_id)&&w(n.content)){yield{type:`server_tool_call_result`,name:`code_execution`,toolCallId:n.tool_use_id,status:`success`,output:n.content};continue}else if(C(n,`mcp_tool_use`)){yield{id:n.id,type:`server_tool_call`,name:`mcp_tool_use`,args:n.input};continue}else if(C(n,`mcp_tool_result`)&&T(n.tool_use_id)&&w(n.content)){yield{type:`server_tool_call_result`,name:`mcp_tool_use`,toolCallId:n.tool_use_id,status:`success`,output:n.content};continue}else if(C(n,`container_upload`)){yield{type:`server_tool_call`,name:`container_upload`,args:n.input};continue}else if(C(n,`search_result`)){yield{id:n.id,type:`non_standard`,value:n};continue}else if(C(n,`tool_result`)){yield{id:n.id,type:`non_standard`,value:n};continue}else{let e=Me(n);if(e){yield e;continue}}yield{type:`non_standard`,value:n}}}return Array.from(t())}var Fe={translateContent:Pe,translateContentChunk:Pe};function Ie(e){return typeof e?._getType==`function`&&typeof e.concat==`function`&&e._getType()===`ai`}function Le(e){return ye(e)?{type:e.type,mimeType:e.mime_type,url:e.url,metadata:e.metadata}:be(e)?{type:e.type,mimeType:e.mime_type??`application/octet-stream`,data:e.data,metadata:e.metadata}:Se(e)?{type:e.type,mimeType:e.mime_type,fileId:e.id,metadata:e.metadata}:e}function Re(e){return e.map(Le)}function ze(e){return!!(C(e,`image_url`)&&w(e.image_url)||C(e,`input_audio`)&&w(e.input_audio)||C(e,`file`)&&w(e.file))}function Be(e){if(C(e,`image_url`)&&w(e.image_url)&&T(e.image_url.url)){let t=Te({dataUrl:e.image_url.url});return t?{type:`image`,mimeType:t.mime_type,data:t.data}:{type:`image`,url:e.image_url.url}}else if(C(e,`input_audio`)&&w(e.input_audio)&&T(e.input_audio.data)&&T(e.input_audio.format))return{type:`audio`,data:e.input_audio.data,mimeType:`audio/${e.input_audio.format}`};else if(C(e,`file`)&&w(e.file)&&T(e.file.data)){let t=Te({dataUrl:e.file.data});if(t)return{type:`file`,data:t.data,mimeType:t.mime_type};if(T(e.file.file_id))return{type:`file`,fileId:e.file.file_id}}return e}function Ve(e){let t=[];typeof e.content==`string`?e.content.length>0&&t.push({type:`text`,text:e.content}):t.push(...Ue(e.content));for(let n of e.tool_calls??[])t.push({type:`tool_call`,id:n.id,name:n.name,args:n.args});return t}function He(e){let t=[];typeof e.content==`string`?e.content.length>0&&t.push({type:`text`,text:e.content}):t.push(...Ue(e.content));for(let n of e.tool_calls??[])t.push({type:`tool_call`,id:n.id,name:n.name,args:n.args});return t}function Ue(e){let t=[];for(let n of e)ze(n)?t.push(Be(n)):t.push(n);return t}function We(e){if(e.type===`url_citation`){let{url:t,title:n,start_index:r,end_index:i}=e;return{type:`citation`,url:t,title:n,startIndex:r,endIndex:i}}if(e.type===`file_citation`){let{file_id:t,filename:n,index:r}=e;return{type:`citation`,title:n,startIndex:r,endIndex:r,fileId:t}}return e}function Ge(e){function*t(){w(e.additional_kwargs?.reasoning)&&De(e.additional_kwargs.reasoning.summary)&&(yield{type:`reasoning`,reasoning:e.additional_kwargs.reasoning.summary.reduce((e,t)=>w(t)&&T(t.text)?`${e}${t.text}`:e,``)});let t=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content;for(let e of t)if(C(e,`text`)){let{text:t,annotations:n,phase:r,extras:i,...a}=e,o=w(i)?{...i}:{};T(r)&&(o.phase=r);let s=Object.keys(o).length>0?{extras:o}:{};Array.isArray(n)?yield{...a,...s,type:`text`,text:String(t),annotations:n.map(We)}:yield{...a,...s,type:`text`,text:String(t)}}for(let t of e.tool_calls??[])yield{type:`tool_call`,id:t.id,name:t.name,args:t.args};if(w(e.additional_kwargs)&&De(e.additional_kwargs.tool_outputs))for(let t of e.additional_kwargs.tool_outputs){if(C(t,`web_search_call`)){let e={};if(w(t.action)&&T(t.action.query)&&(e.query=t.action.query),yield{id:t.id,type:`server_tool_call`,name:`web_search`,args:e},t.status===`completed`||t.status===`failed`){let e={};w(t.action)&&(e.action=t.action),yield{type:`server_tool_call_result`,toolCallId:T(t.id)?t.id:``,status:t.status===`completed`?`success`:`error`,output:e}}continue}else if(C(t,`file_search_call`)){yield{id:t.id,type:`server_tool_call`,name:`file_search`,args:{queries:De(t.queries)?t.queries:[]}},(t.status===`completed`||t.status===`failed`)&&(yield{type:`server_tool_call_result`,toolCallId:T(t.id)?t.id:``,status:t.status===`completed`?`success`:`error`,output:De(t.results)?{results:t.results}:{}});continue}else if(C(t,`computer_call`)){yield{type:`non_standard`,value:t};continue}else if(C(t,`code_interpreter_call`)){if(T(t.code)&&(yield{id:t.id,type:`server_tool_call`,name:`code_interpreter`,args:{code:t.code}}),De(t.outputs)){let e=Ae(()=>{if(t.status!==`in_progress`){if(t.status===`completed`)return 0;if(t.status===`incomplete`)return 127;if(t.status!==`interpreting`&&t.status===`failed`)return 1}});for(let n of t.outputs)if(C(n,`logs`)){yield{type:`server_tool_call_result`,toolCallId:t.id??``,status:`success`,output:{type:`code_interpreter_output`,returnCode:e??0,stderr:[0,void 0].includes(e)?void 0:String(n.logs),stdout:[0,void 0].includes(e)?String(n.logs):void 0}};continue}}continue}else if(C(t,`mcp_call`)){yield{id:t.id,type:`server_tool_call`,name:`mcp_call`,args:t.input};continue}else if(C(t,`mcp_list_tools`)){yield{id:t.id,type:`server_tool_call`,name:`mcp_list_tools`,args:t.input};continue}else if(C(t,`mcp_approval_request`)){yield{type:`non_standard`,value:t};continue}else if(C(t,`tool_search_call`)){let e={};w(t.arguments)&&Object.assign(e,t.arguments);let n={};T(t.execution)&&(n.execution=t.execution),T(t.status)&&(n.status=t.status),T(t.call_id)&&(n.call_id=t.call_id),yield{id:T(t.id)?t.id:``,type:`server_tool_call`,name:`tool_search`,args:e,...Object.keys(n).length>0?{extras:n}:{}};continue}else if(C(t,`tool_search_output`)){let e={name:`tool_search`};T(t.execution)&&(e.execution=t.execution),yield{type:`server_tool_call_result`,toolCallId:T(t.id)?t.id:``,status:t.status===`completed`?`success`:t.status===`failed`?`error`:`success`,output:{tools:De(t.tools)?t.tools:[]},extras:e};continue}else if(C(t,`image_generation_call`)){T(t.result)&&(yield{type:`image`,mimeType:`image/png`,data:t.result,id:T(t.id)?t.id:void 0,metadata:{status:T(t.status)?t.status:void 0}}),yield{type:`non_standard`,value:t};continue}w(t)&&(yield{type:`non_standard`,value:t})}}return Array.from(t())}function Ke(e){function*t(){yield*Ge(e);for(let t of e.tool_call_chunks??[])yield{type:`tool_call_chunk`,id:t.id,name:t.name,args:t.args}}return Array.from(t())}var qe={translateContent:e=>typeof e.content==`string`?Ve(e):Ge(e),translateContentChunk:e=>typeof e.content==`string`?He(e):Ke(e)};function Je(e){return typeof e==`object`&&!!e&&`type`in e&&`content`in e&&(typeof e.content==`string`||Array.isArray(e.content))}function Ye(e,t=`pretty`){return t===`pretty`?Xe(e):JSON.stringify(e)}function Xe(e){let t=[],n=` ${e.type.charAt(0).toUpperCase()+e.type.slice(1)} Message `,r=Math.floor((80-n.length)/2),i=`=`.repeat(r),a=n.length%2==0?i:`${i}=`;if(t.push(`${i}${n}${a}`),e.type===`ai`){let n=e;if(n.tool_calls&&n.tool_calls.length>0){t.push(`Tool Calls:`);for(let e of n.tool_calls){t.push(` ${e.name} (${e.id})`),t.push(` Call ID: ${e.id}`),t.push(` Args:`);for(let[n,r]of Object.entries(e.args))t.push(` ${n}: ${typeof r==`object`?JSON.stringify(r):r}`)}}}if(e.type===`tool`){let n=e;n.name&&t.push(`Name: ${n.name}`)}return typeof e.content==`string`&&e.content.trim()&&(t.length>1&&t.push(``),t.push(e.content)),t.join(`
@@ -560,66 +560,90 @@ Additional output sections:
560
560
 
561
561
  ## ⚠️ MANDATORY: GROUNDING
562
562
  Every factual claim MUST include a citation.
563
- - File refs: [[src/auth.ts:45-60]] (line range with hyphen)
563
+ - File refs: [[src/auth.ts:45-60]] (repo-relative path, line range with hyphen)
564
+ - Symbol refs: [[Function:validateUser]] or [[Class:AuthService]]
565
+ - Do NOT wrap citations in backticks or code blocks — keep them as plain text
564
566
  - NO citation = NO claim. Say "I didn't find evidence" instead of guessing.
565
567
 
566
- ## ⚠️ MANDATORY: VALIDATION
567
- Every output MUST be validated.
568
- - Use cypher to validate the results and confirm completeness of context before final output.
569
- - NO validation = NO claim. Say "I didn't find evidence" instead of guessing.
570
- - Do not blindly trust readme or single source of truth. Always validate and cross-reference. Never be lazy.
571
-
572
- ## 🧠 CORE PROTOCOL
573
- You are an investigator. For each question:
574
- 1. **Search** → Use cypher, search or grep to find relevant code
575
- 2. **Read** → Use read to see the actual source
576
- 3. **Trace** → Use cypher to follow connections in the graph
577
- 4. **Cite** → Ground every finding with [[file:line]] or [[Type:Name]]
578
- 5. **Validate** → Use cypher to validate the results and confirm completeness of context before final output. ( MUST DO )
579
-
580
- ## 🛠️ TOOLS
581
- - **\`search\`** — Hybrid search. Results grouped by process with cluster context.
582
- - **\`cypher\`** — Cypher queries against the graph. Use \`{{QUERY_VECTOR}}\` for vector search.
583
- - **\`grep\`** — Regex search. Best for exact strings, TODOs, error codes.
584
- - **\`read\`** — Read file content. Always use after search/grep to see full code.
585
- - **\`explore\`** — Deep dive on a symbol, cluster, or process. Shows membership, participation, connections.
568
+ ## 🧠 CORE PROTOCOL (Iterative Loop)
569
+ You are an investigator, not a one-shot query engine. For each question:
570
+ 1. **Plan** — Briefly state what you are looking for and why.
571
+ 2. **Execute** — Run tools to gather evidence.
572
+ 3. **Analyze & pivot** — Did the output fully answer the question?
573
+ - Yes → proceed to grounding.
574
+ - Revealed new files/functions → loop back and investigate them immediately.
575
+ - Tool failed → fix the input and retry. Never stop after one error.
576
+ 4. **Trace** — Use cypher, explore, or impact to follow graph connections.
577
+ 5. **Read** — Use read to verify logic. Do not guess behavior from names alone.
578
+ 6. **Validate** — Cross-check findings with cypher before final output. README/docs are summaries, not proof.
579
+ 7. **Ground** — Cite every finding with [[path:START-END]] or [[Type:Name]].
580
+
581
+ Before EVERY tool call, briefly state what you are doing and why. Keep narration to one line per step.
582
+
583
+ ## BE DIRECT
584
+ - No pleasantries. No "Great question!" or "I'd be happy to help."
585
+ - Don't repeat advice already given in this conversation.
586
+ - Match response length to query complexity.
587
+ - Don't pad with generic "let me know if you need more" — users will ask.
588
+
589
+ ## 🛠️ TOOLS (exact names — use these only)
590
+ - **\`search\`** — Hybrid keyword + semantic search. Results grouped by process with cluster context. Start here for discovery.
591
+ - **\`cypher\`** — Cypher queries against the graph. Use \`{{QUERY_VECTOR}}\` placeholder for vector search.
592
+ - **\`grep\`** — Regex search across files. Best for exact strings, TODOs, error codes.
593
+ - **\`read\`** — Read file content. Always use after search/grep to see full source.
594
+ - **\`explore\`** — Deep dive on a symbol, cluster, or process.
586
595
  - **\`overview\`** — Codebase map showing all clusters and processes.
587
596
  - **\`impact\`** — Impact analysis. Shows affected processes, clusters, and risk level.
588
597
 
589
- ## 📊 GRAPH SCHEMA
590
- Nodes: File, Folder, Function, Class, Interface, Method, Community, Process
591
- Relations: \`CodeRelation\` with \`type\` property: CONTAINS, DEFINES, IMPORTS, CALLS, EXTENDS, IMPLEMENTS, MEMBER_OF, STEP_IN_PROCESS
598
+ **Tool strategy:**
599
+ - Discovery → \`search\` or \`overview\`
600
+ - Structure → \`cypher\`, \`explore\`, or \`impact\`
601
+ - Verification → \`read\` (required before concluding)
602
+ - Exact patterns → \`grep\`
592
603
 
593
- ## 📐 GRAPH SEMANTICS (Important!)
594
- **Edge Types:**
595
- - \`CALLS\`: Method invocation OR constructor injection. If A receives B as parameter and uses it, A→B is CALLS. This is intentional simplification.
596
- - \`IMPORTS\`: File-level import/include statement.
597
- - \`EXTENDS/IMPLEMENTS\`: Class inheritance.
604
+ ## 📊 GRAPH SCHEMA
605
+ Typed node labels: File, Folder, Function, Class, Interface, Method, CodeElement, Community, Process
606
+ Single relation table: \`CodeRelation\` with \`type\` property: CONTAINS, DEFINES, IMPORTS, CALLS, EXTENDS, IMPLEMENTS, MEMBER_OF, STEP_IN_PROCESS
598
607
 
599
- **Process Nodes:**
600
- - Process labels use format: "EntryPoint → Terminal" (e.g., "onCreate → showToast")
601
- - These are heuristic names from tracing execution flow, NOT application-defined names
602
- - Entry points are detected via export status, naming patterns, and framework conventions
608
+ ✅ \`MATCH (f:Function) RETURN f.name LIMIT 10\`
609
+ ✅ \`MATCH (a)-[r:CodeRelation {type: 'CALLS'}]->(b:Function) RETURN a.name, b.name\`
610
+ ❌ \`MATCH ()-[:CALLS]->()\` — WRONG, no such relationship label
603
611
 
604
612
  Cypher examples:
605
- - \`MATCH (f:Function) RETURN f.name LIMIT 10\`
606
- - \`MATCH (f:File)-[:CodeRelation {type: 'IMPORTS'}]->(g:File) RETURN f.name, g.name\`
613
+ - Find callers: \`MATCH (caller:Function)-[:CodeRelation {type: 'CALLS'}]->(fn:Function {name: 'validate'}) RETURN caller.name, caller.filePath\`
614
+ - File imports: \`MATCH (f:File)-[:CodeRelation {type: 'IMPORTS'}]->(g:File) RETURN f.name, g.name\`
615
+ - Semantic search: include \`{{QUERY_VECTOR}}\` in cypher and provide a \`query\` parameter
607
616
 
608
- ## 📝CRITICAL RULES
609
- - **impact output is trusted.** Do NOT re-validate with cypher. Optionally run the suggested grep commands for dynamic patterns.
617
+ ## 📐 GRAPH SEMANTICS
618
+ - \`CALLS\`: Method invocation or constructor injection (intentional simplification).
619
+ - \`IMPORTS\`: File-level import/include.
620
+ - \`EXTENDS/IMPLEMENTS\`: Class inheritance.
621
+ - Process labels use format "EntryPoint → Terminal" (heuristic, not app-defined names).
622
+
623
+ ## 🎯 VISUAL GROUNDING (not a tool)
624
+ The user sees a knowledge graph alongside this chat. Citations automatically highlight nodes in the graph UI.
625
+ - Include [[path:START-END]] and [[Type:Name]] refs as you discover relevant code — the UI highlights them for the user.
626
+ - Prefer 2-6 high-signal references over large dumps.
627
+ - There is NO \`highlight_in_graph\` tool. Ground with citations; the UI handles visualization.
628
+
629
+ ## 📝 CRITICAL RULES
630
+ - **impact output is trusted.** Do NOT re-validate with cypher. Optionally run suggested grep for dynamic patterns.
610
631
  - **Cite or retract.** Never state something you can't ground.
611
- - **Read before concluding.** Don't guess from names alone.
612
- - **Retry on failure.** If a tool fails, fix the input and try again.
613
- - **Cyfer tool validation** prefer using cyfer tool in anything that requires graph connections.
614
- - **OUTPUT STYLE** Prefer using tables and mermaid diagrams instead of long explanations.
615
- - ALWAYS USE MERMAID FOR VISUALIZATION AND STRUCTURING THE OUTPUT.
632
+ - **Iterative depth.** If Function A calls Function B, read Function B. Trace logic to the source.
633
+ - **Prefer cypher** for anything requiring graph connections.
634
+
635
+ ## ERROR RECOVERY
636
+ If a tool call fails (Cypher syntax, file not found, invalid regex), do NOT stop.
637
+ - Read the error, fix the input, and retry at least once.
638
+ - For Cypher errors, verify typed node labels and \`CodeRelation {type: '...'}\` filters match the GRAPH SCHEMA section above.
639
+ - If search returns nothing, try grep or a different query before concluding.
616
640
 
617
641
  ## 🎯 OUTPUT STYLE
618
- Think like a senior architect. Be concise—no fluff, short, precise and to the point.
642
+ Think like a senior architect. Be concise — no fluff.
619
643
  - Use tables for comparisons/rankings
620
- - Use mermaid diagrams for flows/dependencies
644
+ - Use mermaid diagrams for flows, architecture, and dependencies
621
645
  - Surface deep insights: patterns, coupling, design decisions
622
- - End with **TL;DR** (short summary of the response, summing up the response and the most critical parts)
646
+ - End with **TL;DR**
623
647
 
624
648
  ## MERMAID RULES
625
649
  When generating diagrams:
@@ -627,6 +651,7 @@ When generating diagrams:
627
651
  - Wrap labels with spaces in quotes: A["My Label"]
628
652
  - Use simple IDs: A, B, C or auth, db, api
629
653
  - Flowchart: graph TD or graph LR (not flowchart)
654
+ - Keep diagrams focused — 5-10 nodes max
630
655
  - Always test mentally: would this parse?
631
656
 
632
657
  BAD: A[User's Data] --> B(Process & Save)