@vohongtho.infotech/code-intel 0.3.0 → 0.3.1
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/cli/main.js +279 -1505
- package/dist/cli/main.js.map +1 -1
- package/dist/index.js +166 -1392
- package/dist/index.js.map +1 -1
- package/dist/wasm/tree-sitter-kotlin.wasm +0 -0
- package/dist/wasm/tree-sitter-swift.wasm +0 -0
- package/package.json +24 -22
package/dist/cli/main.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { SpanStatusCode, trace, context, diag, baggageEntryMetadataFromString } from '@opentelemetry/api';
|
|
3
|
-
import { inspect } from 'util';
|
|
4
|
-
import * as zlib from 'zlib';
|
|
5
|
-
import { Readable } from 'stream';
|
|
6
|
-
import * as fs25 from 'fs';
|
|
7
|
-
import fs25__default, { readFileSync, existsSync } from 'fs';
|
|
8
|
-
import * as path28 from 'path';
|
|
9
|
-
import path28__default, { dirname, join } from 'path';
|
|
10
2
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
11
3
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
4
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
12
5
|
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
13
6
|
import { SEMRESATTRS_DEPLOYMENT_ENVIRONMENT, SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
7
|
+
import { SpanStatusCode, trace, context } from '@opentelemetry/api';
|
|
14
8
|
import winston from 'winston';
|
|
15
9
|
import DailyRotateFile from 'winston-daily-rotate-file';
|
|
10
|
+
import fs24, { readFileSync, existsSync } from 'fs';
|
|
11
|
+
import path27, { dirname, join } from 'path';
|
|
16
12
|
import os12 from 'os';
|
|
17
13
|
import { createRequire } from 'module';
|
|
18
14
|
import { fileURLToPath } from 'url';
|
|
@@ -49,1227 +45,6 @@ var __export = (target, all) => {
|
|
|
49
45
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
50
46
|
};
|
|
51
47
|
|
|
52
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
|
|
53
|
-
var OTLPExporterBase;
|
|
54
|
-
var init_OTLPExporterBase = __esm({
|
|
55
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js"() {
|
|
56
|
-
OTLPExporterBase = class {
|
|
57
|
-
_delegate;
|
|
58
|
-
constructor(delegate) {
|
|
59
|
-
this._delegate = delegate;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Export items.
|
|
63
|
-
* @param items
|
|
64
|
-
* @param resultCallback
|
|
65
|
-
*/
|
|
66
|
-
export(items, resultCallback) {
|
|
67
|
-
this._delegate.export(items, resultCallback);
|
|
68
|
-
}
|
|
69
|
-
forceFlush() {
|
|
70
|
-
return this._delegate.forceFlush();
|
|
71
|
-
}
|
|
72
|
-
shutdown() {
|
|
73
|
-
return this._delegate.shutdown();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js
|
|
80
|
-
var OTLPExporterError;
|
|
81
|
-
var init_types = __esm({
|
|
82
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js"() {
|
|
83
|
-
OTLPExporterError = class extends Error {
|
|
84
|
-
code;
|
|
85
|
-
name = "OTLPExporterError";
|
|
86
|
-
data;
|
|
87
|
-
constructor(message, code, data) {
|
|
88
|
-
super(message);
|
|
89
|
-
this.data = data;
|
|
90
|
-
this.code = code;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js
|
|
97
|
-
function validateTimeoutMillis(timeoutMillis) {
|
|
98
|
-
if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {
|
|
99
|
-
return timeoutMillis;
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`);
|
|
102
|
-
}
|
|
103
|
-
function wrapStaticHeadersInFunction(headers) {
|
|
104
|
-
if (headers == null) {
|
|
105
|
-
return void 0;
|
|
106
|
-
}
|
|
107
|
-
return async () => headers;
|
|
108
|
-
}
|
|
109
|
-
function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
110
|
-
return {
|
|
111
|
-
timeoutMillis: validateTimeoutMillis(userProvidedConfiguration.timeoutMillis ?? fallbackConfiguration.timeoutMillis ?? defaultConfiguration.timeoutMillis),
|
|
112
|
-
concurrencyLimit: userProvidedConfiguration.concurrencyLimit ?? fallbackConfiguration.concurrencyLimit ?? defaultConfiguration.concurrencyLimit,
|
|
113
|
-
compression: userProvidedConfiguration.compression ?? fallbackConfiguration.compression ?? defaultConfiguration.compression
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function getSharedConfigurationDefaults() {
|
|
117
|
-
return {
|
|
118
|
-
timeoutMillis: 1e4,
|
|
119
|
-
concurrencyLimit: 30,
|
|
120
|
-
compression: "none"
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
var init_shared_configuration = __esm({
|
|
124
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js"() {
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js
|
|
129
|
-
function createBoundedQueueExportPromiseHandler(options) {
|
|
130
|
-
return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
|
|
131
|
-
}
|
|
132
|
-
var BoundedQueueExportPromiseHandler;
|
|
133
|
-
var init_bounded_queue_export_promise_handler = __esm({
|
|
134
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js"() {
|
|
135
|
-
BoundedQueueExportPromiseHandler = class {
|
|
136
|
-
_concurrencyLimit;
|
|
137
|
-
_sendingPromises = [];
|
|
138
|
-
/**
|
|
139
|
-
* @param concurrencyLimit maximum promises allowed in a queue at the same time.
|
|
140
|
-
*/
|
|
141
|
-
constructor(concurrencyLimit) {
|
|
142
|
-
this._concurrencyLimit = concurrencyLimit;
|
|
143
|
-
}
|
|
144
|
-
pushPromise(promise) {
|
|
145
|
-
if (this.hasReachedLimit()) {
|
|
146
|
-
throw new Error("Concurrency Limit reached");
|
|
147
|
-
}
|
|
148
|
-
this._sendingPromises.push(promise);
|
|
149
|
-
const popPromise = () => {
|
|
150
|
-
const index = this._sendingPromises.indexOf(promise);
|
|
151
|
-
void this._sendingPromises.splice(index, 1);
|
|
152
|
-
};
|
|
153
|
-
promise.then(popPromise, popPromise);
|
|
154
|
-
}
|
|
155
|
-
hasReachedLimit() {
|
|
156
|
-
return this._sendingPromises.length >= this._concurrencyLimit;
|
|
157
|
-
}
|
|
158
|
-
async awaitAll() {
|
|
159
|
-
await Promise.all(this._sendingPromises);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// ../../node_modules/@opentelemetry/core/build/esm/baggage/constants.js
|
|
166
|
-
var BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_ITEMS_SEPARATOR;
|
|
167
|
-
var init_constants = __esm({
|
|
168
|
-
"../../node_modules/@opentelemetry/core/build/esm/baggage/constants.js"() {
|
|
169
|
-
BAGGAGE_KEY_PAIR_SEPARATOR = "=";
|
|
170
|
-
BAGGAGE_PROPERTIES_SEPARATOR = ";";
|
|
171
|
-
BAGGAGE_ITEMS_SEPARATOR = ",";
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
function parsePairKeyValue(entry) {
|
|
175
|
-
if (!entry)
|
|
176
|
-
return;
|
|
177
|
-
const metadataSeparatorIndex = entry.indexOf(BAGGAGE_PROPERTIES_SEPARATOR);
|
|
178
|
-
const keyPairPart = metadataSeparatorIndex === -1 ? entry : entry.substring(0, metadataSeparatorIndex);
|
|
179
|
-
const separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
|
|
180
|
-
if (separatorIndex <= 0)
|
|
181
|
-
return;
|
|
182
|
-
const rawKey = keyPairPart.substring(0, separatorIndex).trim();
|
|
183
|
-
const rawValue = keyPairPart.substring(separatorIndex + 1).trim();
|
|
184
|
-
if (!rawKey || !rawValue)
|
|
185
|
-
return;
|
|
186
|
-
let key;
|
|
187
|
-
let value;
|
|
188
|
-
try {
|
|
189
|
-
key = decodeURIComponent(rawKey);
|
|
190
|
-
value = decodeURIComponent(rawValue);
|
|
191
|
-
} catch {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
let metadata;
|
|
195
|
-
if (metadataSeparatorIndex !== -1 && metadataSeparatorIndex < entry.length - 1) {
|
|
196
|
-
const metadataString = entry.substring(metadataSeparatorIndex + 1);
|
|
197
|
-
metadata = baggageEntryMetadataFromString(metadataString);
|
|
198
|
-
}
|
|
199
|
-
return { key, value, metadata };
|
|
200
|
-
}
|
|
201
|
-
function parseKeyPairsIntoRecord(value) {
|
|
202
|
-
const result = {};
|
|
203
|
-
if (typeof value === "string" && value.length > 0) {
|
|
204
|
-
value.split(BAGGAGE_ITEMS_SEPARATOR).forEach((entry) => {
|
|
205
|
-
const keyPair = parsePairKeyValue(entry);
|
|
206
|
-
if (keyPair !== void 0 && keyPair.value.length > 0) {
|
|
207
|
-
result[keyPair.key] = keyPair.value;
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
return result;
|
|
212
|
-
}
|
|
213
|
-
var init_utils = __esm({
|
|
214
|
-
"../../node_modules/@opentelemetry/core/build/esm/baggage/utils.js"() {
|
|
215
|
-
init_constants();
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
function getNumberFromEnv(key) {
|
|
219
|
-
const raw = process.env[key];
|
|
220
|
-
if (raw == null || raw.trim() === "") {
|
|
221
|
-
return void 0;
|
|
222
|
-
}
|
|
223
|
-
const value = Number(raw);
|
|
224
|
-
if (isNaN(value)) {
|
|
225
|
-
diag.warn(`Unknown value ${inspect(raw)} for ${key}, expected a number, using defaults`);
|
|
226
|
-
return void 0;
|
|
227
|
-
}
|
|
228
|
-
return value;
|
|
229
|
-
}
|
|
230
|
-
function getStringFromEnv(key) {
|
|
231
|
-
const raw = process.env[key];
|
|
232
|
-
if (raw == null || raw.trim() === "") {
|
|
233
|
-
return void 0;
|
|
234
|
-
}
|
|
235
|
-
return raw;
|
|
236
|
-
}
|
|
237
|
-
var init_environment = __esm({
|
|
238
|
-
"../../node_modules/@opentelemetry/core/build/esm/platform/node/environment.js"() {
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// ../../node_modules/@opentelemetry/core/build/esm/platform/node/index.js
|
|
243
|
-
var init_node = __esm({
|
|
244
|
-
"../../node_modules/@opentelemetry/core/build/esm/platform/node/index.js"() {
|
|
245
|
-
init_environment();
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// ../../node_modules/@opentelemetry/core/build/esm/platform/index.js
|
|
250
|
-
var init_platform = __esm({
|
|
251
|
-
"../../node_modules/@opentelemetry/core/build/esm/platform/index.js"() {
|
|
252
|
-
init_node();
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// ../../node_modules/@opentelemetry/core/build/esm/common/time.js
|
|
257
|
-
function hrTimeToNanoseconds(time) {
|
|
258
|
-
return time[0] * SECOND_TO_NANOSECONDS + time[1];
|
|
259
|
-
}
|
|
260
|
-
var NANOSECOND_DIGITS, SECOND_TO_NANOSECONDS;
|
|
261
|
-
var init_time = __esm({
|
|
262
|
-
"../../node_modules/@opentelemetry/core/build/esm/common/time.js"() {
|
|
263
|
-
NANOSECOND_DIGITS = 9;
|
|
264
|
-
SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
// ../../node_modules/@opentelemetry/core/build/esm/ExportResult.js
|
|
269
|
-
var ExportResultCode;
|
|
270
|
-
var init_ExportResult = __esm({
|
|
271
|
-
"../../node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
|
|
272
|
-
(function(ExportResultCode2) {
|
|
273
|
-
ExportResultCode2[ExportResultCode2["SUCCESS"] = 0] = "SUCCESS";
|
|
274
|
-
ExportResultCode2[ExportResultCode2["FAILED"] = 1] = "FAILED";
|
|
275
|
-
})(ExportResultCode || (ExportResultCode = {}));
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// ../../node_modules/@opentelemetry/core/build/esm/index.js
|
|
280
|
-
var init_esm = __esm({
|
|
281
|
-
"../../node_modules/@opentelemetry/core/build/esm/index.js"() {
|
|
282
|
-
init_time();
|
|
283
|
-
init_ExportResult();
|
|
284
|
-
init_utils();
|
|
285
|
-
init_platform();
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
function isPartialSuccessResponse(response) {
|
|
289
|
-
return Object.prototype.hasOwnProperty.call(response, "partialSuccess");
|
|
290
|
-
}
|
|
291
|
-
function createLoggingPartialSuccessResponseHandler() {
|
|
292
|
-
return {
|
|
293
|
-
handleResponse(response) {
|
|
294
|
-
if (response == null || !isPartialSuccessResponse(response) || response.partialSuccess == null || Object.keys(response.partialSuccess).length === 0) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
diag.warn("Received Partial Success response:", JSON.stringify(response.partialSuccess));
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
var init_logging_response_handler = __esm({
|
|
302
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js"() {
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
function createOtlpExportDelegate(components, settings) {
|
|
306
|
-
return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
|
|
307
|
-
}
|
|
308
|
-
var OTLPExportDelegate;
|
|
309
|
-
var init_otlp_export_delegate = __esm({
|
|
310
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js"() {
|
|
311
|
-
init_esm();
|
|
312
|
-
init_types();
|
|
313
|
-
init_logging_response_handler();
|
|
314
|
-
OTLPExportDelegate = class {
|
|
315
|
-
_diagLogger;
|
|
316
|
-
_transport;
|
|
317
|
-
_serializer;
|
|
318
|
-
_responseHandler;
|
|
319
|
-
_promiseQueue;
|
|
320
|
-
_timeout;
|
|
321
|
-
constructor(transport, serializer, responseHandler, promiseQueue, timeout) {
|
|
322
|
-
this._transport = transport;
|
|
323
|
-
this._serializer = serializer;
|
|
324
|
-
this._responseHandler = responseHandler;
|
|
325
|
-
this._promiseQueue = promiseQueue;
|
|
326
|
-
this._timeout = timeout;
|
|
327
|
-
this._diagLogger = diag.createComponentLogger({
|
|
328
|
-
namespace: "OTLPExportDelegate"
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
export(internalRepresentation, resultCallback) {
|
|
332
|
-
this._diagLogger.debug("items to be sent", internalRepresentation);
|
|
333
|
-
if (this._promiseQueue.hasReachedLimit()) {
|
|
334
|
-
resultCallback({
|
|
335
|
-
code: ExportResultCode.FAILED,
|
|
336
|
-
error: new Error("Concurrent export limit reached")
|
|
337
|
-
});
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
const serializedRequest = this._serializer.serializeRequest(internalRepresentation);
|
|
341
|
-
if (serializedRequest == null) {
|
|
342
|
-
resultCallback({
|
|
343
|
-
code: ExportResultCode.FAILED,
|
|
344
|
-
error: new Error("Nothing to send")
|
|
345
|
-
});
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
this._promiseQueue.pushPromise(this._transport.send(serializedRequest, this._timeout).then((response) => {
|
|
349
|
-
if (response.status === "success") {
|
|
350
|
-
if (response.data != null) {
|
|
351
|
-
try {
|
|
352
|
-
this._responseHandler.handleResponse(this._serializer.deserializeResponse(response.data));
|
|
353
|
-
} catch (e) {
|
|
354
|
-
this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?", e, response.data);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
resultCallback({
|
|
358
|
-
code: ExportResultCode.SUCCESS
|
|
359
|
-
});
|
|
360
|
-
return;
|
|
361
|
-
} else if (response.status === "failure" && response.error) {
|
|
362
|
-
resultCallback({
|
|
363
|
-
code: ExportResultCode.FAILED,
|
|
364
|
-
error: response.error
|
|
365
|
-
});
|
|
366
|
-
return;
|
|
367
|
-
} else if (response.status === "retryable") {
|
|
368
|
-
resultCallback({
|
|
369
|
-
code: ExportResultCode.FAILED,
|
|
370
|
-
error: response.error ?? new OTLPExporterError("Export failed with retryable status")
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
resultCallback({
|
|
374
|
-
code: ExportResultCode.FAILED,
|
|
375
|
-
error: new OTLPExporterError("Export failed with unknown error")
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
}, (reason) => resultCallback({
|
|
379
|
-
code: ExportResultCode.FAILED,
|
|
380
|
-
error: reason
|
|
381
|
-
})));
|
|
382
|
-
}
|
|
383
|
-
forceFlush() {
|
|
384
|
-
return this._promiseQueue.awaitAll();
|
|
385
|
-
}
|
|
386
|
-
async shutdown() {
|
|
387
|
-
this._diagLogger.debug("shutdown started");
|
|
388
|
-
await this.forceFlush();
|
|
389
|
-
this._transport.shutdown();
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
|
|
396
|
-
var init_esm2 = __esm({
|
|
397
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js"() {
|
|
398
|
-
init_OTLPExporterBase();
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
|
|
403
|
-
function createResource(resource, encoder) {
|
|
404
|
-
const result = {
|
|
405
|
-
attributes: toAttributes(resource.attributes, encoder),
|
|
406
|
-
droppedAttributesCount: 0
|
|
407
|
-
};
|
|
408
|
-
const schemaUrl = resource.schemaUrl;
|
|
409
|
-
if (schemaUrl && schemaUrl !== "")
|
|
410
|
-
result.schemaUrl = schemaUrl;
|
|
411
|
-
return result;
|
|
412
|
-
}
|
|
413
|
-
function createInstrumentationScope(scope) {
|
|
414
|
-
return {
|
|
415
|
-
name: scope.name,
|
|
416
|
-
version: scope.version
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function toAttributes(attributes, encoder) {
|
|
420
|
-
return Object.keys(attributes).map((key) => toKeyValue(key, attributes[key], encoder));
|
|
421
|
-
}
|
|
422
|
-
function toKeyValue(key, value, encoder) {
|
|
423
|
-
return {
|
|
424
|
-
key,
|
|
425
|
-
value: toAnyValue(value, encoder)
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
function toAnyValue(value, encoder) {
|
|
429
|
-
const t = typeof value;
|
|
430
|
-
if (t === "string")
|
|
431
|
-
return { stringValue: value };
|
|
432
|
-
if (t === "number") {
|
|
433
|
-
if (!Number.isInteger(value))
|
|
434
|
-
return { doubleValue: value };
|
|
435
|
-
return { intValue: value };
|
|
436
|
-
}
|
|
437
|
-
if (t === "boolean")
|
|
438
|
-
return { boolValue: value };
|
|
439
|
-
if (value instanceof Uint8Array)
|
|
440
|
-
return { bytesValue: encoder.encodeUint8Array(value) };
|
|
441
|
-
if (Array.isArray(value)) {
|
|
442
|
-
const values = new Array(value.length);
|
|
443
|
-
for (let i = 0; i < value.length; i++) {
|
|
444
|
-
values[i] = toAnyValue(value[i], encoder);
|
|
445
|
-
}
|
|
446
|
-
return { arrayValue: { values } };
|
|
447
|
-
}
|
|
448
|
-
if (t === "object" && value != null) {
|
|
449
|
-
const keys = Object.keys(value);
|
|
450
|
-
const values = new Array(keys.length);
|
|
451
|
-
for (let i = 0; i < keys.length; i++) {
|
|
452
|
-
values[i] = {
|
|
453
|
-
key: keys[i],
|
|
454
|
-
value: toAnyValue(value[keys[i]], encoder)
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
return { kvlistValue: { values } };
|
|
458
|
-
}
|
|
459
|
-
return {};
|
|
460
|
-
}
|
|
461
|
-
var init_internal = __esm({
|
|
462
|
-
"../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js"() {
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
|
|
467
|
-
function hrTimeToNanos(hrTime2) {
|
|
468
|
-
const NANOSECONDS = BigInt(1e9);
|
|
469
|
-
return BigInt(Math.trunc(hrTime2[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime2[1]));
|
|
470
|
-
}
|
|
471
|
-
function encodeAsString(hrTime2) {
|
|
472
|
-
const nanos = hrTimeToNanos(hrTime2);
|
|
473
|
-
return nanos.toString();
|
|
474
|
-
}
|
|
475
|
-
function identity(value) {
|
|
476
|
-
return value;
|
|
477
|
-
}
|
|
478
|
-
var encodeTimestamp, JSON_ENCODER;
|
|
479
|
-
var init_utils2 = __esm({
|
|
480
|
-
"../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js"() {
|
|
481
|
-
init_esm();
|
|
482
|
-
encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds;
|
|
483
|
-
JSON_ENCODER = {
|
|
484
|
-
encodeHrTime: encodeTimestamp,
|
|
485
|
-
encodeSpanContext: identity,
|
|
486
|
-
encodeOptionalSpanContext: identity,
|
|
487
|
-
encodeUint8Array: (bytes) => {
|
|
488
|
-
if (typeof Buffer !== "undefined") {
|
|
489
|
-
return Buffer.from(bytes).toString("base64");
|
|
490
|
-
}
|
|
491
|
-
const chars = new Array(bytes.length);
|
|
492
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
493
|
-
chars[i] = String.fromCharCode(bytes[i]);
|
|
494
|
-
}
|
|
495
|
-
return btoa(chars.join(""));
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
|
|
502
|
-
function buildSpanFlagsFrom(traceFlags, isRemote) {
|
|
503
|
-
let flags = traceFlags & 255 | SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK;
|
|
504
|
-
if (isRemote) {
|
|
505
|
-
flags |= SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK;
|
|
506
|
-
}
|
|
507
|
-
return flags;
|
|
508
|
-
}
|
|
509
|
-
function sdkSpanToOtlpSpan(span, encoder) {
|
|
510
|
-
const ctx = span.spanContext();
|
|
511
|
-
const status = span.status;
|
|
512
|
-
const parentSpanId = span.parentSpanContext?.spanId ? encoder.encodeSpanContext(span.parentSpanContext?.spanId) : void 0;
|
|
513
|
-
return {
|
|
514
|
-
traceId: encoder.encodeSpanContext(ctx.traceId),
|
|
515
|
-
spanId: encoder.encodeSpanContext(ctx.spanId),
|
|
516
|
-
parentSpanId,
|
|
517
|
-
traceState: ctx.traceState?.serialize(),
|
|
518
|
-
name: span.name,
|
|
519
|
-
// Span kind is offset by 1 because the API does not define a value for unset
|
|
520
|
-
kind: span.kind == null ? 0 : span.kind + 1,
|
|
521
|
-
startTimeUnixNano: encoder.encodeHrTime(span.startTime),
|
|
522
|
-
endTimeUnixNano: encoder.encodeHrTime(span.endTime),
|
|
523
|
-
attributes: toAttributes(span.attributes, encoder),
|
|
524
|
-
droppedAttributesCount: span.droppedAttributesCount,
|
|
525
|
-
events: span.events.map((event) => toOtlpSpanEvent(event, encoder)),
|
|
526
|
-
droppedEventsCount: span.droppedEventsCount,
|
|
527
|
-
status: {
|
|
528
|
-
// API and proto enums share the same values
|
|
529
|
-
code: status.code,
|
|
530
|
-
message: status.message
|
|
531
|
-
},
|
|
532
|
-
links: span.links.map((link) => toOtlpLink(link, encoder)),
|
|
533
|
-
droppedLinksCount: span.droppedLinksCount,
|
|
534
|
-
flags: buildSpanFlagsFrom(ctx.traceFlags, span.parentSpanContext?.isRemote)
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
function toOtlpLink(link, encoder) {
|
|
538
|
-
return {
|
|
539
|
-
attributes: link.attributes ? toAttributes(link.attributes, encoder) : [],
|
|
540
|
-
spanId: encoder.encodeSpanContext(link.context.spanId),
|
|
541
|
-
traceId: encoder.encodeSpanContext(link.context.traceId),
|
|
542
|
-
traceState: link.context.traceState?.serialize(),
|
|
543
|
-
droppedAttributesCount: link.droppedAttributesCount || 0,
|
|
544
|
-
flags: buildSpanFlagsFrom(link.context.traceFlags, link.context.isRemote)
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
function toOtlpSpanEvent(timedEvent, encoder) {
|
|
548
|
-
return {
|
|
549
|
-
attributes: timedEvent.attributes ? toAttributes(timedEvent.attributes, encoder) : [],
|
|
550
|
-
name: timedEvent.name,
|
|
551
|
-
timeUnixNano: encoder.encodeHrTime(timedEvent.time),
|
|
552
|
-
droppedAttributesCount: timedEvent.droppedAttributesCount || 0
|
|
553
|
-
};
|
|
554
|
-
}
|
|
555
|
-
function createExportTraceServiceRequest(spans, encoder) {
|
|
556
|
-
return {
|
|
557
|
-
resourceSpans: spanRecordsToResourceSpans(spans, encoder)
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
function createResourceMap(readableSpans) {
|
|
561
|
-
const resourceMap = /* @__PURE__ */ new Map();
|
|
562
|
-
for (const record of readableSpans) {
|
|
563
|
-
let ilsMap = resourceMap.get(record.resource);
|
|
564
|
-
if (!ilsMap) {
|
|
565
|
-
ilsMap = /* @__PURE__ */ new Map();
|
|
566
|
-
resourceMap.set(record.resource, ilsMap);
|
|
567
|
-
}
|
|
568
|
-
const instrumentationScopeKey = `${record.instrumentationScope.name}@${record.instrumentationScope.version || ""}:${record.instrumentationScope.schemaUrl || ""}`;
|
|
569
|
-
let records = ilsMap.get(instrumentationScopeKey);
|
|
570
|
-
if (!records) {
|
|
571
|
-
records = [];
|
|
572
|
-
ilsMap.set(instrumentationScopeKey, records);
|
|
573
|
-
}
|
|
574
|
-
records.push(record);
|
|
575
|
-
}
|
|
576
|
-
return resourceMap;
|
|
577
|
-
}
|
|
578
|
-
function spanRecordsToResourceSpans(readableSpans, encoder) {
|
|
579
|
-
const resourceMap = createResourceMap(readableSpans);
|
|
580
|
-
const out = [];
|
|
581
|
-
const entryIterator = resourceMap.entries();
|
|
582
|
-
let entry = entryIterator.next();
|
|
583
|
-
while (!entry.done) {
|
|
584
|
-
const [resource, ilmMap] = entry.value;
|
|
585
|
-
const scopeResourceSpans = [];
|
|
586
|
-
const ilmIterator = ilmMap.values();
|
|
587
|
-
let ilmEntry = ilmIterator.next();
|
|
588
|
-
while (!ilmEntry.done) {
|
|
589
|
-
const scopeSpans = ilmEntry.value;
|
|
590
|
-
if (scopeSpans.length > 0) {
|
|
591
|
-
const spans = scopeSpans.map((readableSpan) => sdkSpanToOtlpSpan(readableSpan, encoder));
|
|
592
|
-
scopeResourceSpans.push({
|
|
593
|
-
scope: createInstrumentationScope(scopeSpans[0].instrumentationScope),
|
|
594
|
-
spans,
|
|
595
|
-
schemaUrl: scopeSpans[0].instrumentationScope.schemaUrl
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
ilmEntry = ilmIterator.next();
|
|
599
|
-
}
|
|
600
|
-
const processedResource = createResource(resource, encoder);
|
|
601
|
-
const transformedSpans = {
|
|
602
|
-
resource: processedResource,
|
|
603
|
-
scopeSpans: scopeResourceSpans,
|
|
604
|
-
schemaUrl: processedResource.schemaUrl
|
|
605
|
-
};
|
|
606
|
-
out.push(transformedSpans);
|
|
607
|
-
entry = entryIterator.next();
|
|
608
|
-
}
|
|
609
|
-
return out;
|
|
610
|
-
}
|
|
611
|
-
var SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK, SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK;
|
|
612
|
-
var init_internal2 = __esm({
|
|
613
|
-
"../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js"() {
|
|
614
|
-
init_internal();
|
|
615
|
-
SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256;
|
|
616
|
-
SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512;
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
var JsonTraceSerializer;
|
|
620
|
-
var init_trace = __esm({
|
|
621
|
-
"../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js"() {
|
|
622
|
-
init_internal2();
|
|
623
|
-
init_utils2();
|
|
624
|
-
JsonTraceSerializer = {
|
|
625
|
-
serializeRequest: (arg) => {
|
|
626
|
-
const request = createExportTraceServiceRequest(arg, JSON_ENCODER);
|
|
627
|
-
const encoder = new TextEncoder();
|
|
628
|
-
return encoder.encode(JSON.stringify(request));
|
|
629
|
-
},
|
|
630
|
-
deserializeResponse: (arg) => {
|
|
631
|
-
if (arg.length === 0) {
|
|
632
|
-
return {};
|
|
633
|
-
}
|
|
634
|
-
const decoder = new TextDecoder();
|
|
635
|
-
try {
|
|
636
|
-
return JSON.parse(decoder.decode(arg));
|
|
637
|
-
} catch (err) {
|
|
638
|
-
diag.warn(`Failed to parse trace export response: ${err.message}. Returning empty response`);
|
|
639
|
-
return {};
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js
|
|
647
|
-
var init_json = __esm({
|
|
648
|
-
"../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js"() {
|
|
649
|
-
init_trace();
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
// ../../node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
|
|
654
|
-
var init_esm3 = __esm({
|
|
655
|
-
"../../node_modules/@opentelemetry/otlp-transformer/build/esm/index.js"() {
|
|
656
|
-
init_json();
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
|
-
function validateAndNormalizeHeaders(partialHeaders) {
|
|
660
|
-
const headers = {};
|
|
661
|
-
Object.entries(partialHeaders ?? {}).forEach(([key, value]) => {
|
|
662
|
-
if (typeof value !== "undefined") {
|
|
663
|
-
headers[key] = String(value);
|
|
664
|
-
} else {
|
|
665
|
-
diag.warn(`Header "${key}" has invalid value (${value}) and will be ignored`);
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
return headers;
|
|
669
|
-
}
|
|
670
|
-
var init_util = __esm({
|
|
671
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js"() {
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js
|
|
676
|
-
function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
|
|
677
|
-
return async () => {
|
|
678
|
-
const requiredHeaders = {
|
|
679
|
-
...await defaultHeaders()
|
|
680
|
-
};
|
|
681
|
-
const headers = {};
|
|
682
|
-
if (fallbackHeaders != null) {
|
|
683
|
-
Object.assign(headers, await fallbackHeaders());
|
|
684
|
-
}
|
|
685
|
-
if (userProvidedHeaders != null) {
|
|
686
|
-
Object.assign(headers, validateAndNormalizeHeaders(await userProvidedHeaders()));
|
|
687
|
-
}
|
|
688
|
-
return Object.assign(headers, requiredHeaders);
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
function validateUserProvidedUrl(url) {
|
|
692
|
-
if (url == null) {
|
|
693
|
-
return void 0;
|
|
694
|
-
}
|
|
695
|
-
try {
|
|
696
|
-
const base = globalThis.location?.href;
|
|
697
|
-
return new URL(url, base).href;
|
|
698
|
-
} catch {
|
|
699
|
-
throw new Error(`Configuration: Could not parse user-provided export URL: '${url}'`);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
703
|
-
return {
|
|
704
|
-
...mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
|
|
705
|
-
headers: mergeHeaders(userProvidedConfiguration.headers, fallbackConfiguration.headers, defaultConfiguration.headers),
|
|
706
|
-
url: validateUserProvidedUrl(userProvidedConfiguration.url) ?? fallbackConfiguration.url ?? defaultConfiguration.url
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
710
|
-
return {
|
|
711
|
-
...getSharedConfigurationDefaults(),
|
|
712
|
-
headers: async () => requiredHeaders,
|
|
713
|
-
url: "http://localhost:4318/" + signalResourcePath
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
var init_otlp_http_configuration = __esm({
|
|
717
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js"() {
|
|
718
|
-
init_shared_configuration();
|
|
719
|
-
init_util();
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-configuration.js
|
|
724
|
-
function httpAgentFactoryFromOptions(options) {
|
|
725
|
-
return async (protocol) => {
|
|
726
|
-
const isInsecure = protocol === "http:";
|
|
727
|
-
const module = isInsecure ? import('http') : import('https');
|
|
728
|
-
const { Agent } = await module;
|
|
729
|
-
if (isInsecure) {
|
|
730
|
-
const { ca, cert, key, ...insecureOptions } = options;
|
|
731
|
-
return new Agent(insecureOptions);
|
|
732
|
-
}
|
|
733
|
-
return new Agent(options);
|
|
734
|
-
};
|
|
735
|
-
}
|
|
736
|
-
function mergeOtlpNodeHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
737
|
-
return {
|
|
738
|
-
...mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
|
|
739
|
-
agentFactory: userProvidedConfiguration.agentFactory ?? fallbackConfiguration.agentFactory ?? defaultConfiguration.agentFactory,
|
|
740
|
-
userAgent: userProvidedConfiguration.userAgent
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
function getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
744
|
-
return {
|
|
745
|
-
...getHttpConfigurationDefaults(requiredHeaders, signalResourcePath),
|
|
746
|
-
agentFactory: httpAgentFactoryFromOptions({ keepAlive: true })
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
var init_otlp_node_http_configuration = __esm({
|
|
750
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-configuration.js"() {
|
|
751
|
-
init_otlp_http_configuration();
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
|
|
755
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js
|
|
756
|
-
function isExportHTTPErrorRetryable(statusCode) {
|
|
757
|
-
return statusCode === 429 || statusCode === 502 || statusCode === 503 || statusCode === 504;
|
|
758
|
-
}
|
|
759
|
-
function parseRetryAfterToMills(retryAfter) {
|
|
760
|
-
if (retryAfter == null) {
|
|
761
|
-
return void 0;
|
|
762
|
-
}
|
|
763
|
-
const seconds = Number.parseInt(retryAfter, 10);
|
|
764
|
-
if (Number.isInteger(seconds)) {
|
|
765
|
-
return seconds > 0 ? seconds * 1e3 : -1;
|
|
766
|
-
}
|
|
767
|
-
const delay = new Date(retryAfter).getTime() - Date.now();
|
|
768
|
-
if (delay >= 0) {
|
|
769
|
-
return delay;
|
|
770
|
-
}
|
|
771
|
-
return 0;
|
|
772
|
-
}
|
|
773
|
-
var init_is_export_retryable = __esm({
|
|
774
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js"() {
|
|
775
|
-
}
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js
|
|
779
|
-
var VERSION;
|
|
780
|
-
var init_version = __esm({
|
|
781
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js"() {
|
|
782
|
-
VERSION = "0.215.0";
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
function sendWithHttp(request, url, headers, compression, userAgent, agent, data, timeoutMillis) {
|
|
786
|
-
return new Promise((resolve2) => {
|
|
787
|
-
const parsedUrl = new URL(url);
|
|
788
|
-
if (userAgent) {
|
|
789
|
-
headers["User-Agent"] = `${userAgent} ${DEFAULT_USER_AGENT}`;
|
|
790
|
-
} else {
|
|
791
|
-
headers["User-Agent"] = DEFAULT_USER_AGENT;
|
|
792
|
-
}
|
|
793
|
-
const options = {
|
|
794
|
-
hostname: parsedUrl.hostname,
|
|
795
|
-
port: parsedUrl.port,
|
|
796
|
-
path: parsedUrl.pathname,
|
|
797
|
-
method: "POST",
|
|
798
|
-
headers,
|
|
799
|
-
agent
|
|
800
|
-
};
|
|
801
|
-
const req = request(options, (res) => {
|
|
802
|
-
const responseData = [];
|
|
803
|
-
let responseSize = 0;
|
|
804
|
-
res.on("data", (chunk) => {
|
|
805
|
-
responseSize += chunk.length;
|
|
806
|
-
if (responseSize > MAX_RESPONSE_BODY_SIZE) {
|
|
807
|
-
const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
|
|
808
|
-
resolve2({ status: "failure", error: sizeError });
|
|
809
|
-
res.destroy();
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
responseData.push(chunk);
|
|
813
|
-
});
|
|
814
|
-
res.on("end", () => {
|
|
815
|
-
if (res.statusCode && res.statusCode <= 299) {
|
|
816
|
-
resolve2({
|
|
817
|
-
status: "success",
|
|
818
|
-
data: Buffer.concat(responseData)
|
|
819
|
-
});
|
|
820
|
-
} else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
|
|
821
|
-
resolve2({
|
|
822
|
-
status: "retryable",
|
|
823
|
-
retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
|
|
824
|
-
});
|
|
825
|
-
} else {
|
|
826
|
-
const error = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
|
|
827
|
-
resolve2({
|
|
828
|
-
status: "failure",
|
|
829
|
-
error
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
res.on("error", (error) => {
|
|
834
|
-
if (res.statusCode && res.statusCode <= 299) {
|
|
835
|
-
resolve2({
|
|
836
|
-
status: "success"
|
|
837
|
-
});
|
|
838
|
-
} else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
|
|
839
|
-
resolve2({
|
|
840
|
-
status: "retryable",
|
|
841
|
-
error,
|
|
842
|
-
retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
|
|
843
|
-
});
|
|
844
|
-
} else {
|
|
845
|
-
resolve2({
|
|
846
|
-
status: "failure",
|
|
847
|
-
error
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
});
|
|
851
|
-
});
|
|
852
|
-
req.setTimeout(timeoutMillis, () => {
|
|
853
|
-
req.destroy();
|
|
854
|
-
resolve2({
|
|
855
|
-
status: "retryable",
|
|
856
|
-
error: new Error("Request timed out")
|
|
857
|
-
});
|
|
858
|
-
});
|
|
859
|
-
req.on("error", (error) => {
|
|
860
|
-
if (isHttpTransportNetworkErrorRetryable(error)) {
|
|
861
|
-
resolve2({
|
|
862
|
-
status: "retryable",
|
|
863
|
-
error
|
|
864
|
-
});
|
|
865
|
-
} else {
|
|
866
|
-
resolve2({
|
|
867
|
-
status: "failure",
|
|
868
|
-
error
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
compressAndSend(req, compression, data, (error) => {
|
|
873
|
-
resolve2({
|
|
874
|
-
status: "failure",
|
|
875
|
-
error
|
|
876
|
-
});
|
|
877
|
-
});
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
function compressAndSend(req, compression, data, onError) {
|
|
881
|
-
let dataStream = readableFromUint8Array(data);
|
|
882
|
-
if (compression === "gzip") {
|
|
883
|
-
req.setHeader("Content-Encoding", "gzip");
|
|
884
|
-
dataStream = dataStream.on("error", onError).pipe(zlib.createGzip()).on("error", onError);
|
|
885
|
-
}
|
|
886
|
-
dataStream.pipe(req).on("error", onError);
|
|
887
|
-
}
|
|
888
|
-
function readableFromUint8Array(buff) {
|
|
889
|
-
const readable = new Readable();
|
|
890
|
-
readable.push(buff);
|
|
891
|
-
readable.push(null);
|
|
892
|
-
return readable;
|
|
893
|
-
}
|
|
894
|
-
function isHttpTransportNetworkErrorRetryable(error) {
|
|
895
|
-
const RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
896
|
-
"ECONNRESET",
|
|
897
|
-
"ECONNREFUSED",
|
|
898
|
-
"EPIPE",
|
|
899
|
-
"ETIMEDOUT",
|
|
900
|
-
"EAI_AGAIN",
|
|
901
|
-
"ENOTFOUND",
|
|
902
|
-
"ENETUNREACH",
|
|
903
|
-
"EHOSTUNREACH"
|
|
904
|
-
]);
|
|
905
|
-
if ("code" in error && typeof error.code === "string") {
|
|
906
|
-
return RETRYABLE_NETWORK_ERROR_CODES.has(error.code);
|
|
907
|
-
}
|
|
908
|
-
return false;
|
|
909
|
-
}
|
|
910
|
-
var DEFAULT_USER_AGENT, MAX_RESPONSE_BODY_SIZE;
|
|
911
|
-
var init_http_transport_utils = __esm({
|
|
912
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js"() {
|
|
913
|
-
init_is_export_retryable();
|
|
914
|
-
init_types();
|
|
915
|
-
init_version();
|
|
916
|
-
DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION}`;
|
|
917
|
-
MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js
|
|
922
|
-
async function requestFunctionFactory(protocol) {
|
|
923
|
-
const module = protocol === "http:" ? import('http') : import('https');
|
|
924
|
-
const { request } = await module;
|
|
925
|
-
return request;
|
|
926
|
-
}
|
|
927
|
-
function createHttpExporterTransport(parameters) {
|
|
928
|
-
return new HttpExporterTransport(parameters);
|
|
929
|
-
}
|
|
930
|
-
var HttpExporterTransport;
|
|
931
|
-
var init_http_exporter_transport = __esm({
|
|
932
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js"() {
|
|
933
|
-
init_http_transport_utils();
|
|
934
|
-
HttpExporterTransport = class {
|
|
935
|
-
_utils = null;
|
|
936
|
-
_parameters;
|
|
937
|
-
constructor(parameters) {
|
|
938
|
-
this._parameters = parameters;
|
|
939
|
-
}
|
|
940
|
-
async send(data, timeoutMillis) {
|
|
941
|
-
const { agent, request } = await this._loadUtils();
|
|
942
|
-
const headers = await this._parameters.headers();
|
|
943
|
-
return sendWithHttp(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, timeoutMillis);
|
|
944
|
-
}
|
|
945
|
-
shutdown() {
|
|
946
|
-
}
|
|
947
|
-
async _loadUtils() {
|
|
948
|
-
let utils = this._utils;
|
|
949
|
-
if (utils === null) {
|
|
950
|
-
const protocol = new URL(this._parameters.url).protocol;
|
|
951
|
-
const [agent, request] = await Promise.all([
|
|
952
|
-
this._parameters.agentFactory(protocol),
|
|
953
|
-
requestFunctionFactory(protocol)
|
|
954
|
-
]);
|
|
955
|
-
utils = this._utils = { agent, request };
|
|
956
|
-
}
|
|
957
|
-
return utils;
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
function getJitter() {
|
|
963
|
-
return Math.random() * (2 * JITTER) - JITTER;
|
|
964
|
-
}
|
|
965
|
-
function createRetryingTransport(options) {
|
|
966
|
-
return new RetryingTransport(options.transport);
|
|
967
|
-
}
|
|
968
|
-
var MAX_ATTEMPTS, INITIAL_BACKOFF, MAX_BACKOFF, BACKOFF_MULTIPLIER, JITTER, RetryingTransport;
|
|
969
|
-
var init_retrying_transport = __esm({
|
|
970
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js"() {
|
|
971
|
-
MAX_ATTEMPTS = 5;
|
|
972
|
-
INITIAL_BACKOFF = 1e3;
|
|
973
|
-
MAX_BACKOFF = 5e3;
|
|
974
|
-
BACKOFF_MULTIPLIER = 1.5;
|
|
975
|
-
JITTER = 0.2;
|
|
976
|
-
RetryingTransport = class {
|
|
977
|
-
_transport;
|
|
978
|
-
constructor(transport) {
|
|
979
|
-
this._transport = transport;
|
|
980
|
-
}
|
|
981
|
-
retry(data, timeoutMillis, inMillis) {
|
|
982
|
-
return new Promise((resolve2, reject) => {
|
|
983
|
-
setTimeout(() => {
|
|
984
|
-
this._transport.send(data, timeoutMillis).then(resolve2, reject);
|
|
985
|
-
}, inMillis);
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
async send(data, timeoutMillis) {
|
|
989
|
-
let attempts = MAX_ATTEMPTS;
|
|
990
|
-
let nextBackoff = INITIAL_BACKOFF;
|
|
991
|
-
const deadline = Date.now() + timeoutMillis;
|
|
992
|
-
let result = await this._transport.send(data, timeoutMillis);
|
|
993
|
-
while (result.status === "retryable" && attempts > 0) {
|
|
994
|
-
attempts--;
|
|
995
|
-
const backoff = Math.max(Math.min(nextBackoff * (1 + getJitter()), MAX_BACKOFF), 0);
|
|
996
|
-
nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;
|
|
997
|
-
const retryInMillis = result.retryInMillis ?? backoff;
|
|
998
|
-
const remainingTimeoutMillis = deadline - Date.now();
|
|
999
|
-
if (retryInMillis > remainingTimeoutMillis) {
|
|
1000
|
-
diag.info(`Export retry time ${Math.round(retryInMillis)}ms exceeds remaining timeout ${Math.round(remainingTimeoutMillis)}ms, not retrying further.`);
|
|
1001
|
-
return result;
|
|
1002
|
-
}
|
|
1003
|
-
diag.verbose(`Scheduling export retry in ${Math.round(retryInMillis)}ms`);
|
|
1004
|
-
result = await this.retry(data, remainingTimeoutMillis, retryInMillis);
|
|
1005
|
-
}
|
|
1006
|
-
if (result.status === "success") {
|
|
1007
|
-
diag.verbose(`Export succeeded after ${MAX_ATTEMPTS - attempts} retry attempts.`);
|
|
1008
|
-
} else if (result.status === "retryable") {
|
|
1009
|
-
diag.info(`Export failed after maximum retry attempts (${MAX_ATTEMPTS}).`);
|
|
1010
|
-
} else {
|
|
1011
|
-
diag.info(`Export failed with non-retryable error: ${result.error}`);
|
|
1012
|
-
}
|
|
1013
|
-
return result;
|
|
1014
|
-
}
|
|
1015
|
-
shutdown() {
|
|
1016
|
-
return this._transport.shutdown();
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
|
|
1022
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js
|
|
1023
|
-
function createOtlpHttpExportDelegate(options, serializer) {
|
|
1024
|
-
return createOtlpExportDelegate({
|
|
1025
|
-
transport: createRetryingTransport({
|
|
1026
|
-
transport: createHttpExporterTransport(options)
|
|
1027
|
-
}),
|
|
1028
|
-
serializer,
|
|
1029
|
-
promiseHandler: createBoundedQueueExportPromiseHandler(options)
|
|
1030
|
-
}, { timeout: options.timeoutMillis });
|
|
1031
|
-
}
|
|
1032
|
-
var init_otlp_http_export_delegate = __esm({
|
|
1033
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js"() {
|
|
1034
|
-
init_otlp_export_delegate();
|
|
1035
|
-
init_http_exporter_transport();
|
|
1036
|
-
init_bounded_queue_export_promise_handler();
|
|
1037
|
-
init_retrying_transport();
|
|
1038
|
-
}
|
|
1039
|
-
});
|
|
1040
|
-
function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
|
|
1041
|
-
const envTimeout = getNumberFromEnv(timeoutEnvVar);
|
|
1042
|
-
if (envTimeout != null) {
|
|
1043
|
-
if (Number.isFinite(envTimeout) && envTimeout > 0) {
|
|
1044
|
-
return envTimeout;
|
|
1045
|
-
}
|
|
1046
|
-
diag.warn(`Configuration: ${timeoutEnvVar} is invalid, expected number greater than 0 (actual: ${envTimeout})`);
|
|
1047
|
-
}
|
|
1048
|
-
return void 0;
|
|
1049
|
-
}
|
|
1050
|
-
function getTimeoutFromEnv(signalIdentifier) {
|
|
1051
|
-
const specificTimeout = parseAndValidateTimeoutFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_TIMEOUT`);
|
|
1052
|
-
const nonSpecificTimeout = parseAndValidateTimeoutFromEnv("OTEL_EXPORTER_OTLP_TIMEOUT");
|
|
1053
|
-
return specificTimeout ?? nonSpecificTimeout;
|
|
1054
|
-
}
|
|
1055
|
-
function parseAndValidateCompressionFromEnv(compressionEnvVar) {
|
|
1056
|
-
const compression = getStringFromEnv(compressionEnvVar)?.trim();
|
|
1057
|
-
if (compression == null || compression === "none" || compression === "gzip") {
|
|
1058
|
-
return compression;
|
|
1059
|
-
}
|
|
1060
|
-
diag.warn(`Configuration: ${compressionEnvVar} is invalid, expected 'none' or 'gzip' (actual: '${compression}')`);
|
|
1061
|
-
return void 0;
|
|
1062
|
-
}
|
|
1063
|
-
function getCompressionFromEnv(signalIdentifier) {
|
|
1064
|
-
const specificCompression = parseAndValidateCompressionFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_COMPRESSION`);
|
|
1065
|
-
const nonSpecificCompression = parseAndValidateCompressionFromEnv("OTEL_EXPORTER_OTLP_COMPRESSION");
|
|
1066
|
-
return specificCompression ?? nonSpecificCompression;
|
|
1067
|
-
}
|
|
1068
|
-
function getSharedConfigurationFromEnvironment(signalIdentifier) {
|
|
1069
|
-
return {
|
|
1070
|
-
timeoutMillis: getTimeoutFromEnv(signalIdentifier),
|
|
1071
|
-
compression: getCompressionFromEnv(signalIdentifier)
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
var init_shared_env_configuration = __esm({
|
|
1075
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js"() {
|
|
1076
|
-
init_esm();
|
|
1077
|
-
}
|
|
1078
|
-
});
|
|
1079
|
-
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
1080
|
-
const signalSpecificRawHeaders = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`);
|
|
1081
|
-
const nonSignalSpecificRawHeaders = getStringFromEnv("OTEL_EXPORTER_OTLP_HEADERS");
|
|
1082
|
-
const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
|
|
1083
|
-
const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
|
|
1084
|
-
if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) {
|
|
1085
|
-
return void 0;
|
|
1086
|
-
}
|
|
1087
|
-
return Object.assign({}, parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), parseKeyPairsIntoRecord(signalSpecificRawHeaders));
|
|
1088
|
-
}
|
|
1089
|
-
function appendRootPathToUrlIfNeeded(url) {
|
|
1090
|
-
try {
|
|
1091
|
-
const parsedUrl = new URL(url);
|
|
1092
|
-
return parsedUrl.toString();
|
|
1093
|
-
} catch {
|
|
1094
|
-
diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
1095
|
-
return void 0;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
function appendResourcePathToUrl(url, path29) {
|
|
1099
|
-
try {
|
|
1100
|
-
new URL(url);
|
|
1101
|
-
} catch {
|
|
1102
|
-
diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
1103
|
-
return void 0;
|
|
1104
|
-
}
|
|
1105
|
-
if (!url.endsWith("/")) {
|
|
1106
|
-
url = url + "/";
|
|
1107
|
-
}
|
|
1108
|
-
url += path29;
|
|
1109
|
-
try {
|
|
1110
|
-
new URL(url);
|
|
1111
|
-
} catch {
|
|
1112
|
-
diag.warn(`Configuration: Provided URL appended with '${path29}' is not a valid URL, using 'undefined' instead of '${url}'`);
|
|
1113
|
-
return void 0;
|
|
1114
|
-
}
|
|
1115
|
-
return url;
|
|
1116
|
-
}
|
|
1117
|
-
function getNonSpecificUrlFromEnv(signalResourcePath) {
|
|
1118
|
-
const envUrl = getStringFromEnv("OTEL_EXPORTER_OTLP_ENDPOINT");
|
|
1119
|
-
if (envUrl === void 0) {
|
|
1120
|
-
return void 0;
|
|
1121
|
-
}
|
|
1122
|
-
return appendResourcePathToUrl(envUrl, signalResourcePath);
|
|
1123
|
-
}
|
|
1124
|
-
function getSpecificUrlFromEnv(signalIdentifier) {
|
|
1125
|
-
const envUrl = getStringFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`);
|
|
1126
|
-
if (envUrl === void 0) {
|
|
1127
|
-
return void 0;
|
|
1128
|
-
}
|
|
1129
|
-
return appendRootPathToUrlIfNeeded(envUrl);
|
|
1130
|
-
}
|
|
1131
|
-
function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
|
|
1132
|
-
const signalSpecificPath = getStringFromEnv(signalSpecificEnvVar);
|
|
1133
|
-
const nonSignalSpecificPath = getStringFromEnv(nonSignalSpecificEnvVar);
|
|
1134
|
-
const filePath = signalSpecificPath ?? nonSignalSpecificPath;
|
|
1135
|
-
if (filePath != null) {
|
|
1136
|
-
try {
|
|
1137
|
-
return fs25.readFileSync(path28.resolve(process.cwd(), filePath));
|
|
1138
|
-
} catch {
|
|
1139
|
-
diag.warn(warningMessage);
|
|
1140
|
-
return void 0;
|
|
1141
|
-
}
|
|
1142
|
-
} else {
|
|
1143
|
-
return void 0;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
function getClientCertificateFromEnv(signalIdentifier) {
|
|
1147
|
-
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE", "Failed to read client certificate chain file");
|
|
1148
|
-
}
|
|
1149
|
-
function getClientKeyFromEnv(signalIdentifier) {
|
|
1150
|
-
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, "OTEL_EXPORTER_OTLP_CLIENT_KEY", "Failed to read client certificate private key file");
|
|
1151
|
-
}
|
|
1152
|
-
function getRootCertificateFromEnv(signalIdentifier) {
|
|
1153
|
-
return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, "OTEL_EXPORTER_OTLP_CERTIFICATE", "Failed to read root certificate file");
|
|
1154
|
-
}
|
|
1155
|
-
function getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
|
|
1156
|
-
return {
|
|
1157
|
-
...getSharedConfigurationFromEnvironment(signalIdentifier),
|
|
1158
|
-
url: getSpecificUrlFromEnv(signalIdentifier) ?? getNonSpecificUrlFromEnv(signalResourcePath),
|
|
1159
|
-
headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier)),
|
|
1160
|
-
agentFactory: httpAgentFactoryFromOptions({
|
|
1161
|
-
keepAlive: true,
|
|
1162
|
-
ca: getRootCertificateFromEnv(signalIdentifier),
|
|
1163
|
-
cert: getClientCertificateFromEnv(signalIdentifier),
|
|
1164
|
-
key: getClientKeyFromEnv(signalIdentifier)
|
|
1165
|
-
})
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
var init_otlp_node_http_env_configuration = __esm({
|
|
1169
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-node-http-env-configuration.js"() {
|
|
1170
|
-
init_esm();
|
|
1171
|
-
init_shared_env_configuration();
|
|
1172
|
-
init_shared_configuration();
|
|
1173
|
-
init_otlp_node_http_configuration();
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
|
|
1177
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js
|
|
1178
|
-
function convertLegacyHeaders(config) {
|
|
1179
|
-
if (typeof config.headers === "function") {
|
|
1180
|
-
return config.headers;
|
|
1181
|
-
}
|
|
1182
|
-
return wrapStaticHeadersInFunction(config.headers);
|
|
1183
|
-
}
|
|
1184
|
-
var init_convert_legacy_http_options = __esm({
|
|
1185
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-http-options.js"() {
|
|
1186
|
-
init_shared_configuration();
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
function convertLegacyAgentOptions(config) {
|
|
1190
|
-
if (typeof config.httpAgentOptions === "function") {
|
|
1191
|
-
return config.httpAgentOptions;
|
|
1192
|
-
}
|
|
1193
|
-
let legacy = config.httpAgentOptions;
|
|
1194
|
-
if (config.keepAlive != null) {
|
|
1195
|
-
legacy = { keepAlive: config.keepAlive, ...legacy };
|
|
1196
|
-
}
|
|
1197
|
-
if (legacy != null) {
|
|
1198
|
-
return httpAgentFactoryFromOptions(legacy);
|
|
1199
|
-
} else {
|
|
1200
|
-
return void 0;
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath, requiredHeaders) {
|
|
1204
|
-
if (config.metadata) {
|
|
1205
|
-
diag.warn("Metadata cannot be set when using http");
|
|
1206
|
-
}
|
|
1207
|
-
return mergeOtlpNodeHttpConfigurationWithDefaults({
|
|
1208
|
-
url: config.url,
|
|
1209
|
-
headers: convertLegacyHeaders(config),
|
|
1210
|
-
concurrencyLimit: config.concurrencyLimit,
|
|
1211
|
-
timeoutMillis: config.timeoutMillis,
|
|
1212
|
-
compression: config.compression,
|
|
1213
|
-
agentFactory: convertLegacyAgentOptions(config),
|
|
1214
|
-
userAgent: config.userAgent
|
|
1215
|
-
}, getNodeHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getNodeHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
1216
|
-
}
|
|
1217
|
-
var init_convert_legacy_node_http_options = __esm({
|
|
1218
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js"() {
|
|
1219
|
-
init_otlp_node_http_configuration();
|
|
1220
|
-
init_index_node_http();
|
|
1221
|
-
init_otlp_node_http_env_configuration();
|
|
1222
|
-
init_convert_legacy_http_options();
|
|
1223
|
-
}
|
|
1224
|
-
});
|
|
1225
|
-
|
|
1226
|
-
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js
|
|
1227
|
-
var init_index_node_http = __esm({
|
|
1228
|
-
"../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js"() {
|
|
1229
|
-
init_otlp_node_http_configuration();
|
|
1230
|
-
init_otlp_http_export_delegate();
|
|
1231
|
-
init_convert_legacy_node_http_options();
|
|
1232
|
-
}
|
|
1233
|
-
});
|
|
1234
|
-
|
|
1235
|
-
// ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js
|
|
1236
|
-
var OTLPTraceExporter;
|
|
1237
|
-
var init_OTLPTraceExporter = __esm({
|
|
1238
|
-
"../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js"() {
|
|
1239
|
-
init_esm2();
|
|
1240
|
-
init_esm3();
|
|
1241
|
-
init_index_node_http();
|
|
1242
|
-
OTLPTraceExporter = class extends OTLPExporterBase {
|
|
1243
|
-
constructor(config = {}) {
|
|
1244
|
-
super(createOtlpHttpExportDelegate(convertLegacyHttpOptions(config, "TRACES", "v1/traces", {
|
|
1245
|
-
"Content-Type": "application/json"
|
|
1246
|
-
}), JsonTraceSerializer));
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
|
|
1252
|
-
// ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js
|
|
1253
|
-
var init_node2 = __esm({
|
|
1254
|
-
"../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js"() {
|
|
1255
|
-
init_OTLPTraceExporter();
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
|
|
1259
|
-
// ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js
|
|
1260
|
-
var init_platform2 = __esm({
|
|
1261
|
-
"../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js"() {
|
|
1262
|
-
init_node2();
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
|
-
|
|
1266
|
-
// ../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js
|
|
1267
|
-
var init_esm4 = __esm({
|
|
1268
|
-
"../../node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js"() {
|
|
1269
|
-
init_platform2();
|
|
1270
|
-
}
|
|
1271
|
-
});
|
|
1272
|
-
|
|
1273
48
|
// src/observability/tracing.ts
|
|
1274
49
|
var tracing_exports = {};
|
|
1275
50
|
__export(tracing_exports, {
|
|
@@ -1353,7 +128,6 @@ function getActiveTraceContext() {
|
|
|
1353
128
|
var _sdk, TRACER_NAME, BLOCKED_ATTR_KEYS;
|
|
1354
129
|
var init_tracing = __esm({
|
|
1355
130
|
"src/observability/tracing.ts"() {
|
|
1356
|
-
init_esm4();
|
|
1357
131
|
_sdk = null;
|
|
1358
132
|
TRACER_NAME = "code-intel";
|
|
1359
133
|
BLOCKED_ATTR_KEYS = /secret|password|token|key|auth|credential/i;
|
|
@@ -1538,7 +312,7 @@ var init_logger = __esm({
|
|
|
1538
312
|
};
|
|
1539
313
|
}
|
|
1540
314
|
/** Global log directory: ~/.code-intel/logs */
|
|
1541
|
-
static LOG_DIR =
|
|
315
|
+
static LOG_DIR = path27.join(os12.homedir(), ".code-intel", "logs");
|
|
1542
316
|
static getLogger() {
|
|
1543
317
|
if (!_Logger.instance) {
|
|
1544
318
|
const isProduction = process.env.NODE_ENV === "production";
|
|
@@ -1547,12 +321,12 @@ var init_logger = __esm({
|
|
|
1547
321
|
transports.push(new winston.transports.Console());
|
|
1548
322
|
if (!isProduction) {
|
|
1549
323
|
try {
|
|
1550
|
-
if (!
|
|
1551
|
-
|
|
324
|
+
if (!fs24.existsSync(_Logger.LOG_DIR)) {
|
|
325
|
+
fs24.mkdirSync(_Logger.LOG_DIR, { recursive: true });
|
|
1552
326
|
}
|
|
1553
327
|
transports.push(
|
|
1554
328
|
new DailyRotateFile({
|
|
1555
|
-
filename:
|
|
329
|
+
filename: path27.join(_Logger.LOG_DIR, "%DATE%-code-intel.log"),
|
|
1556
330
|
datePattern: "YYYY-MM-DD",
|
|
1557
331
|
maxSize: "20m",
|
|
1558
332
|
maxFiles: "14d"
|
|
@@ -1674,11 +448,11 @@ var init_id_generator = __esm({
|
|
|
1674
448
|
}
|
|
1675
449
|
});
|
|
1676
450
|
function findBundledWasmDir() {
|
|
1677
|
-
const fileDir =
|
|
451
|
+
const fileDir = path27.dirname(fileURLToPath(import.meta.url));
|
|
1678
452
|
const candidates = [
|
|
1679
|
-
|
|
453
|
+
path27.join(fileDir, "wasm"),
|
|
1680
454
|
// dist/index.js → dist/wasm/
|
|
1681
|
-
|
|
455
|
+
path27.join(fileDir, "../wasm")
|
|
1682
456
|
// dist/cli/main.js → dist/wasm/
|
|
1683
457
|
];
|
|
1684
458
|
for (const candidate of candidates) {
|
|
@@ -1719,7 +493,7 @@ function wasmPath(lang) {
|
|
|
1719
493
|
}
|
|
1720
494
|
const bundled = BUNDLED_WASM_MAP[lang];
|
|
1721
495
|
if (bundled) {
|
|
1722
|
-
const bundledPath =
|
|
496
|
+
const bundledPath = path27.join(_bundledWasmDir, bundled);
|
|
1723
497
|
if (existsSync(bundledPath)) return bundledPath;
|
|
1724
498
|
}
|
|
1725
499
|
return null;
|
|
@@ -1732,14 +506,14 @@ async function initParser() {
|
|
|
1732
506
|
}
|
|
1733
507
|
async function getLanguage(lang) {
|
|
1734
508
|
if (languageCache.has(lang)) return languageCache.get(lang);
|
|
1735
|
-
const
|
|
1736
|
-
if (!
|
|
509
|
+
const path28 = wasmPath(lang);
|
|
510
|
+
if (!path28) {
|
|
1737
511
|
languageCache.set(lang, null);
|
|
1738
512
|
return null;
|
|
1739
513
|
}
|
|
1740
514
|
try {
|
|
1741
515
|
await initParser();
|
|
1742
|
-
const language = await Language.load(
|
|
516
|
+
const language = await Language.load(path28);
|
|
1743
517
|
languageCache.set(lang, language);
|
|
1744
518
|
return language;
|
|
1745
519
|
} catch {
|
|
@@ -3164,7 +1938,7 @@ var init_parse_phase = __esm({
|
|
|
3164
1938
|
const batch = filePaths.slice(i, i + CONCURRENCY);
|
|
3165
1939
|
await Promise.all(batch.map(async (filePath) => {
|
|
3166
1940
|
try {
|
|
3167
|
-
const source = await
|
|
1941
|
+
const source = await fs24.promises.readFile(filePath, "utf-8");
|
|
3168
1942
|
context2.fileCache.set(filePath, source);
|
|
3169
1943
|
} catch {
|
|
3170
1944
|
}
|
|
@@ -3177,14 +1951,14 @@ var init_parse_phase = __esm({
|
|
|
3177
1951
|
const lang = detectLanguage(filePath);
|
|
3178
1952
|
if (!lang) {
|
|
3179
1953
|
if (context2.verbose) {
|
|
3180
|
-
const relativePath2 =
|
|
1954
|
+
const relativePath2 = path27.relative(context2.workspaceRoot, filePath);
|
|
3181
1955
|
logger_default.info(` [parse] skipped (no parser): ${relativePath2}`);
|
|
3182
1956
|
}
|
|
3183
1957
|
continue;
|
|
3184
1958
|
}
|
|
3185
1959
|
const source = context2.fileCache.get(filePath);
|
|
3186
1960
|
if (!source) continue;
|
|
3187
|
-
const relativePath =
|
|
1961
|
+
const relativePath = path27.relative(context2.workspaceRoot, filePath);
|
|
3188
1962
|
const fileNodeId = generateNodeId("file", relativePath, relativePath);
|
|
3189
1963
|
const fileNode = context2.graph.getNode(fileNodeId);
|
|
3190
1964
|
if (fileNode) {
|
|
@@ -3430,11 +2204,11 @@ var init_resolve_phase = __esm({
|
|
|
3430
2204
|
let heritageEdges = 0;
|
|
3431
2205
|
const fileIndex = /* @__PURE__ */ new Map();
|
|
3432
2206
|
for (const fp of filePaths) {
|
|
3433
|
-
const rel =
|
|
2207
|
+
const rel = path27.relative(workspaceRoot, fp);
|
|
3434
2208
|
fileIndex.set(rel, fp);
|
|
3435
2209
|
const noExt = rel.replace(/\.\w+$/, "");
|
|
3436
2210
|
if (!fileIndex.has(noExt)) fileIndex.set(noExt, fp);
|
|
3437
|
-
const base =
|
|
2211
|
+
const base = path27.basename(rel, path27.extname(rel));
|
|
3438
2212
|
if (!fileIndex.has(base)) fileIndex.set(base, fp);
|
|
3439
2213
|
}
|
|
3440
2214
|
const symbolIndex = /* @__PURE__ */ new Map();
|
|
@@ -3465,7 +2239,7 @@ var init_resolve_phase = __esm({
|
|
|
3465
2239
|
for (const filePath of filePaths) {
|
|
3466
2240
|
const lang = detectLanguage(filePath);
|
|
3467
2241
|
if (!lang) continue;
|
|
3468
|
-
const relativePath =
|
|
2242
|
+
const relativePath = path27.relative(workspaceRoot, filePath);
|
|
3469
2243
|
const fileNodeId = generateNodeId("file", relativePath, relativePath);
|
|
3470
2244
|
const source = fileCache.get(filePath);
|
|
3471
2245
|
if (!source) continue;
|
|
@@ -3478,13 +2252,13 @@ var init_resolve_phase = __esm({
|
|
|
3478
2252
|
let resolvedRelPath = null;
|
|
3479
2253
|
if (cleaned.startsWith(".")) {
|
|
3480
2254
|
const cleanedNoJs = cleaned.replace(/\.(js|jsx)$/, "");
|
|
3481
|
-
const fromDir =
|
|
2255
|
+
const fromDir = path27.dirname(relativePath);
|
|
3482
2256
|
for (const ext of ["", ".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".go", "/index.ts", "/index.js"]) {
|
|
3483
|
-
const candidate =
|
|
3484
|
-
const normalized =
|
|
2257
|
+
const candidate = path27.join(fromDir, cleanedNoJs + ext);
|
|
2258
|
+
const normalized = path27.normalize(candidate);
|
|
3485
2259
|
if (fileIndex.has(normalized)) {
|
|
3486
2260
|
const absPath = fileIndex.get(normalized);
|
|
3487
|
-
resolvedRelPath =
|
|
2261
|
+
resolvedRelPath = path27.relative(workspaceRoot, absPath);
|
|
3488
2262
|
break;
|
|
3489
2263
|
}
|
|
3490
2264
|
}
|
|
@@ -3612,7 +2386,7 @@ var init_db_manager = __esm({
|
|
|
3612
2386
|
this.dbPath = dbPath;
|
|
3613
2387
|
}
|
|
3614
2388
|
async init() {
|
|
3615
|
-
|
|
2389
|
+
fs24.mkdirSync(path27.dirname(this.dbPath), { recursive: true });
|
|
3616
2390
|
this.db = new Database(this.dbPath);
|
|
3617
2391
|
await this.db.init();
|
|
3618
2392
|
this.conn = new Connection(this.db);
|
|
@@ -3708,7 +2482,7 @@ var init_schema = __esm({
|
|
|
3708
2482
|
}
|
|
3709
2483
|
});
|
|
3710
2484
|
function writeNodeCSVs(graph, outputDir) {
|
|
3711
|
-
|
|
2485
|
+
fs24.mkdirSync(outputDir, { recursive: true });
|
|
3712
2486
|
const header = "id,name,file_path,start_line,end_line,exported,content,metadata\n";
|
|
3713
2487
|
const tableBuffers = /* @__PURE__ */ new Map();
|
|
3714
2488
|
const tableFilePaths = /* @__PURE__ */ new Map();
|
|
@@ -3716,7 +2490,7 @@ function writeNodeCSVs(graph, outputDir) {
|
|
|
3716
2490
|
const table = NODE_TABLE_MAP[node.kind];
|
|
3717
2491
|
if (!tableBuffers.has(table)) {
|
|
3718
2492
|
tableBuffers.set(table, [header]);
|
|
3719
|
-
tableFilePaths.set(table,
|
|
2493
|
+
tableFilePaths.set(table, path27.join(outputDir, `${table}.csv`));
|
|
3720
2494
|
}
|
|
3721
2495
|
tableBuffers.get(table).push(
|
|
3722
2496
|
csvRow([
|
|
@@ -3736,12 +2510,12 @@ function writeNodeCSVs(graph, outputDir) {
|
|
|
3736
2510
|
);
|
|
3737
2511
|
}
|
|
3738
2512
|
for (const [table, lines] of tableBuffers) {
|
|
3739
|
-
|
|
2513
|
+
fs24.writeFileSync(tableFilePaths.get(table), lines.join(""), "utf-8");
|
|
3740
2514
|
}
|
|
3741
2515
|
return tableFilePaths;
|
|
3742
2516
|
}
|
|
3743
2517
|
function writeEdgeCSV(graph, outputDir) {
|
|
3744
|
-
|
|
2518
|
+
fs24.mkdirSync(outputDir, { recursive: true });
|
|
3745
2519
|
const header = "from_id,to_id,kind,weight,label\n";
|
|
3746
2520
|
const groups = /* @__PURE__ */ new Map();
|
|
3747
2521
|
for (const edge of graph.allEdges()) {
|
|
@@ -3752,7 +2526,7 @@ function writeEdgeCSV(graph, outputDir) {
|
|
|
3752
2526
|
const toTable = NODE_TABLE_MAP[targetNode.kind];
|
|
3753
2527
|
const key = `${fromTable}->${toTable}`;
|
|
3754
2528
|
if (!groups.has(key)) {
|
|
3755
|
-
const filePath =
|
|
2529
|
+
const filePath = path27.join(outputDir, `edges_${fromTable}_${toTable}.csv`);
|
|
3756
2530
|
groups.set(key, { lines: [header], from: fromTable, to: toTable, filePath });
|
|
3757
2531
|
}
|
|
3758
2532
|
groups.get(key).lines.push(
|
|
@@ -3767,7 +2541,7 @@ function writeEdgeCSV(graph, outputDir) {
|
|
|
3767
2541
|
}
|
|
3768
2542
|
const result = [];
|
|
3769
2543
|
for (const group of groups.values()) {
|
|
3770
|
-
|
|
2544
|
+
fs24.writeFileSync(group.filePath, group.lines.join(""), "utf-8");
|
|
3771
2545
|
result.push({ fromTable: group.from, toTable: group.to, filePath: group.filePath });
|
|
3772
2546
|
}
|
|
3773
2547
|
return result;
|
|
@@ -3810,7 +2584,7 @@ async function loadGraphToDB(graph, dbManager) {
|
|
|
3810
2584
|
} catch {
|
|
3811
2585
|
}
|
|
3812
2586
|
}
|
|
3813
|
-
const tmpDir =
|
|
2587
|
+
const tmpDir = fs24.mkdtempSync(path27.join(os12.tmpdir(), "code-intel-csv-"));
|
|
3814
2588
|
try {
|
|
3815
2589
|
const nodeTableFiles = writeNodeCSVs(graph, tmpDir);
|
|
3816
2590
|
const edgeGroups = writeEdgeCSV(graph, tmpDir);
|
|
@@ -3829,8 +2603,8 @@ async function loadGraphToDB(graph, dbManager) {
|
|
|
3829
2603
|
}
|
|
3830
2604
|
let nodeCount = 0;
|
|
3831
2605
|
for (const [table, csvPath] of nodeTableFiles) {
|
|
3832
|
-
if (!
|
|
3833
|
-
const stat =
|
|
2606
|
+
if (!fs24.existsSync(csvPath)) continue;
|
|
2607
|
+
const stat = fs24.statSync(csvPath);
|
|
3834
2608
|
if (stat.size < 50) continue;
|
|
3835
2609
|
try {
|
|
3836
2610
|
await dbManager.execute(
|
|
@@ -3843,8 +2617,8 @@ async function loadGraphToDB(graph, dbManager) {
|
|
|
3843
2617
|
}
|
|
3844
2618
|
let edgeCount = 0;
|
|
3845
2619
|
for (const group of edgeGroups) {
|
|
3846
|
-
if (!
|
|
3847
|
-
const stat =
|
|
2620
|
+
if (!fs24.existsSync(group.filePath)) continue;
|
|
2621
|
+
const stat = fs24.statSync(group.filePath);
|
|
3848
2622
|
if (stat.size < 50) continue;
|
|
3849
2623
|
try {
|
|
3850
2624
|
await dbManager.execute(
|
|
@@ -3858,7 +2632,7 @@ async function loadGraphToDB(graph, dbManager) {
|
|
|
3858
2632
|
return { nodeCount, edgeCount };
|
|
3859
2633
|
} finally {
|
|
3860
2634
|
try {
|
|
3861
|
-
|
|
2635
|
+
fs24.rmSync(tmpDir, { recursive: true, force: true });
|
|
3862
2636
|
} catch {
|
|
3863
2637
|
}
|
|
3864
2638
|
}
|
|
@@ -3960,15 +2734,15 @@ var init_graph_loader = __esm({
|
|
|
3960
2734
|
});
|
|
3961
2735
|
function loadRegistry() {
|
|
3962
2736
|
try {
|
|
3963
|
-
const data =
|
|
2737
|
+
const data = fs24.readFileSync(REPOS_FILE, "utf-8");
|
|
3964
2738
|
return JSON.parse(data);
|
|
3965
2739
|
} catch {
|
|
3966
2740
|
return [];
|
|
3967
2741
|
}
|
|
3968
2742
|
}
|
|
3969
2743
|
function saveRegistry(entries) {
|
|
3970
|
-
|
|
3971
|
-
|
|
2744
|
+
fs24.mkdirSync(GLOBAL_DIR, { recursive: true });
|
|
2745
|
+
fs24.writeFileSync(REPOS_FILE, JSON.stringify(entries, null, 2));
|
|
3972
2746
|
}
|
|
3973
2747
|
function upsertRepo(entry) {
|
|
3974
2748
|
const entries = loadRegistry();
|
|
@@ -3987,28 +2761,28 @@ function removeRepo(repoPath) {
|
|
|
3987
2761
|
var GLOBAL_DIR, REPOS_FILE;
|
|
3988
2762
|
var init_repo_registry = __esm({
|
|
3989
2763
|
"src/storage/repo-registry.ts"() {
|
|
3990
|
-
GLOBAL_DIR =
|
|
3991
|
-
REPOS_FILE =
|
|
2764
|
+
GLOBAL_DIR = path27.join(os12.homedir(), ".code-intel");
|
|
2765
|
+
REPOS_FILE = path27.join(GLOBAL_DIR, "repos.json");
|
|
3992
2766
|
}
|
|
3993
2767
|
});
|
|
3994
2768
|
function saveMetadata(repoDir, metadata) {
|
|
3995
|
-
const metaDir =
|
|
3996
|
-
|
|
3997
|
-
|
|
2769
|
+
const metaDir = path27.join(repoDir, ".code-intel");
|
|
2770
|
+
fs24.mkdirSync(metaDir, { recursive: true });
|
|
2771
|
+
fs24.writeFileSync(path27.join(metaDir, "meta.json"), JSON.stringify(metadata, null, 2));
|
|
3998
2772
|
}
|
|
3999
2773
|
function loadMetadata(repoDir) {
|
|
4000
2774
|
try {
|
|
4001
|
-
const data =
|
|
2775
|
+
const data = fs24.readFileSync(path27.join(repoDir, ".code-intel", "meta.json"), "utf-8");
|
|
4002
2776
|
return JSON.parse(data);
|
|
4003
2777
|
} catch {
|
|
4004
2778
|
return null;
|
|
4005
2779
|
}
|
|
4006
2780
|
}
|
|
4007
2781
|
function getDbPath(repoDir) {
|
|
4008
|
-
return
|
|
2782
|
+
return path27.join(repoDir, ".code-intel", "graph.db");
|
|
4009
2783
|
}
|
|
4010
2784
|
function getVectorDbPath(repoDir) {
|
|
4011
|
-
return
|
|
2785
|
+
return path27.join(repoDir, ".code-intel", "vector.db");
|
|
4012
2786
|
}
|
|
4013
2787
|
var init_metadata = __esm({
|
|
4014
2788
|
"src/storage/metadata.ts"() {
|
|
@@ -4144,27 +2918,27 @@ __export(group_registry_exports, {
|
|
|
4144
2918
|
saveSyncResult: () => saveSyncResult
|
|
4145
2919
|
});
|
|
4146
2920
|
function groupFile(name) {
|
|
4147
|
-
return
|
|
2921
|
+
return path27.join(GROUPS_DIR, `${name}.json`);
|
|
4148
2922
|
}
|
|
4149
2923
|
function loadGroup(name) {
|
|
4150
2924
|
try {
|
|
4151
|
-
return JSON.parse(
|
|
2925
|
+
return JSON.parse(fs24.readFileSync(groupFile(name), "utf-8"));
|
|
4152
2926
|
} catch {
|
|
4153
2927
|
return null;
|
|
4154
2928
|
}
|
|
4155
2929
|
}
|
|
4156
2930
|
function saveGroup(group) {
|
|
4157
|
-
|
|
4158
|
-
|
|
2931
|
+
fs24.mkdirSync(GROUPS_DIR, { recursive: true });
|
|
2932
|
+
fs24.writeFileSync(groupFile(group.name), JSON.stringify(group, null, 2) + "\n");
|
|
4159
2933
|
}
|
|
4160
2934
|
function listGroups() {
|
|
4161
2935
|
const groups = [];
|
|
4162
2936
|
try {
|
|
4163
|
-
for (const file of
|
|
2937
|
+
for (const file of fs24.readdirSync(GROUPS_DIR)) {
|
|
4164
2938
|
if (!file.endsWith(".json") || file.endsWith(".sync.json")) continue;
|
|
4165
2939
|
try {
|
|
4166
2940
|
const g = JSON.parse(
|
|
4167
|
-
|
|
2941
|
+
fs24.readFileSync(path27.join(GROUPS_DIR, file), "utf-8")
|
|
4168
2942
|
);
|
|
4169
2943
|
groups.push(g);
|
|
4170
2944
|
} catch {
|
|
@@ -4176,16 +2950,16 @@ function listGroups() {
|
|
|
4176
2950
|
}
|
|
4177
2951
|
function deleteGroup(name) {
|
|
4178
2952
|
try {
|
|
4179
|
-
|
|
2953
|
+
fs24.unlinkSync(groupFile(name));
|
|
4180
2954
|
} catch {
|
|
4181
2955
|
}
|
|
4182
2956
|
try {
|
|
4183
|
-
|
|
2957
|
+
fs24.unlinkSync(path27.join(GROUPS_DIR, `${name}.sync.json`));
|
|
4184
2958
|
} catch {
|
|
4185
2959
|
}
|
|
4186
2960
|
}
|
|
4187
2961
|
function groupExists(name) {
|
|
4188
|
-
return
|
|
2962
|
+
return fs24.existsSync(groupFile(name));
|
|
4189
2963
|
}
|
|
4190
2964
|
function addMember(groupName, member) {
|
|
4191
2965
|
const group = loadGroup(groupName);
|
|
@@ -4211,16 +2985,16 @@ function removeMember(groupName, groupPath) {
|
|
|
4211
2985
|
return group;
|
|
4212
2986
|
}
|
|
4213
2987
|
function saveSyncResult(result) {
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
2988
|
+
fs24.mkdirSync(GROUPS_DIR, { recursive: true });
|
|
2989
|
+
fs24.writeFileSync(
|
|
2990
|
+
path27.join(GROUPS_DIR, `${result.groupName}.sync.json`),
|
|
4217
2991
|
JSON.stringify(result, null, 2) + "\n"
|
|
4218
2992
|
);
|
|
4219
2993
|
}
|
|
4220
2994
|
function loadSyncResult(groupName) {
|
|
4221
2995
|
try {
|
|
4222
2996
|
return JSON.parse(
|
|
4223
|
-
|
|
2997
|
+
fs24.readFileSync(path27.join(GROUPS_DIR, `${groupName}.sync.json`), "utf-8")
|
|
4224
2998
|
);
|
|
4225
2999
|
} catch {
|
|
4226
3000
|
return null;
|
|
@@ -4229,7 +3003,7 @@ function loadSyncResult(groupName) {
|
|
|
4229
3003
|
var GROUPS_DIR;
|
|
4230
3004
|
var init_group_registry = __esm({
|
|
4231
3005
|
"src/multi-repo/group-registry.ts"() {
|
|
4232
|
-
GROUPS_DIR =
|
|
3006
|
+
GROUPS_DIR = path27.join(os12.homedir(), ".code-intel", "groups");
|
|
4233
3007
|
}
|
|
4234
3008
|
});
|
|
4235
3009
|
|
|
@@ -4635,25 +3409,25 @@ function validateDAG(phases) {
|
|
|
4635
3409
|
const visiting = /* @__PURE__ */ new Set();
|
|
4636
3410
|
const visited = /* @__PURE__ */ new Set();
|
|
4637
3411
|
const phaseMap = new Map(phases.map((p) => [p.name, p]));
|
|
4638
|
-
function dfs(name,
|
|
3412
|
+
function dfs(name, path28) {
|
|
4639
3413
|
if (visiting.has(name)) {
|
|
4640
|
-
const cycleStart =
|
|
4641
|
-
const cycle =
|
|
3414
|
+
const cycleStart = path28.indexOf(name);
|
|
3415
|
+
const cycle = path28.slice(cycleStart).concat(name);
|
|
4642
3416
|
errors.push({ type: "cycle", message: `Cycle detected: ${cycle.join(" \u2192 ")}` });
|
|
4643
3417
|
return true;
|
|
4644
3418
|
}
|
|
4645
3419
|
if (visited.has(name)) return false;
|
|
4646
3420
|
visiting.add(name);
|
|
4647
|
-
|
|
3421
|
+
path28.push(name);
|
|
4648
3422
|
const phase = phaseMap.get(name);
|
|
4649
3423
|
if (phase) {
|
|
4650
3424
|
for (const dep of phase.dependencies) {
|
|
4651
|
-
if (dfs(dep,
|
|
3425
|
+
if (dfs(dep, path28)) return true;
|
|
4652
3426
|
}
|
|
4653
3427
|
}
|
|
4654
3428
|
visiting.delete(name);
|
|
4655
3429
|
visited.add(name);
|
|
4656
|
-
|
|
3430
|
+
path28.pop();
|
|
4657
3431
|
return false;
|
|
4658
3432
|
}
|
|
4659
3433
|
for (const phase of phases) {
|
|
@@ -4866,7 +3640,7 @@ var IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
|
4866
3640
|
]);
|
|
4867
3641
|
function loadIgnorePatterns(workspaceRoot) {
|
|
4868
3642
|
try {
|
|
4869
|
-
const raw =
|
|
3643
|
+
const raw = fs24.readFileSync(path27.join(workspaceRoot, ".codeintelignore"), "utf-8");
|
|
4870
3644
|
const extras = /* @__PURE__ */ new Set();
|
|
4871
3645
|
for (const line of raw.split("\n")) {
|
|
4872
3646
|
const trimmed = line.trim();
|
|
@@ -4890,7 +3664,7 @@ var scanPhase = {
|
|
|
4890
3664
|
function walk2(dir) {
|
|
4891
3665
|
let entries;
|
|
4892
3666
|
try {
|
|
4893
|
-
entries =
|
|
3667
|
+
entries = fs24.readdirSync(dir, { withFileTypes: true });
|
|
4894
3668
|
} catch {
|
|
4895
3669
|
return;
|
|
4896
3670
|
}
|
|
@@ -4899,15 +3673,15 @@ var scanPhase = {
|
|
|
4899
3673
|
if (entry.name.startsWith(".")) continue;
|
|
4900
3674
|
if (IGNORED_DIRS.has(entry.name)) continue;
|
|
4901
3675
|
if (extraIgnore.has(entry.name)) continue;
|
|
4902
|
-
walk2(
|
|
3676
|
+
walk2(path27.join(dir, entry.name));
|
|
4903
3677
|
} else if (entry.isFile()) {
|
|
4904
3678
|
const name = entry.name;
|
|
4905
3679
|
if (IGNORED_FILE_SUFFIXES.some((s) => name.endsWith(s))) continue;
|
|
4906
|
-
const ext =
|
|
3680
|
+
const ext = path27.extname(name);
|
|
4907
3681
|
if (!extensions.has(ext)) continue;
|
|
4908
|
-
const fullPath =
|
|
3682
|
+
const fullPath = path27.join(dir, name);
|
|
4909
3683
|
try {
|
|
4910
|
-
const stat =
|
|
3684
|
+
const stat = fs24.statSync(fullPath);
|
|
4911
3685
|
if (stat.size > MAX_FILE_SIZE_BYTES) continue;
|
|
4912
3686
|
} catch {
|
|
4913
3687
|
continue;
|
|
@@ -4934,20 +3708,20 @@ var structurePhase = {
|
|
|
4934
3708
|
const dirs = /* @__PURE__ */ new Set();
|
|
4935
3709
|
let structDone = 0;
|
|
4936
3710
|
for (const filePath of context2.filePaths) {
|
|
4937
|
-
const relativePath =
|
|
3711
|
+
const relativePath = path27.relative(context2.workspaceRoot, filePath);
|
|
4938
3712
|
const lang = detectLanguage(filePath);
|
|
4939
3713
|
context2.graph.addNode({
|
|
4940
3714
|
id: generateNodeId("file", relativePath, relativePath),
|
|
4941
3715
|
kind: "file",
|
|
4942
|
-
name:
|
|
3716
|
+
name: path27.basename(filePath),
|
|
4943
3717
|
filePath: relativePath,
|
|
4944
3718
|
metadata: lang ? { language: lang } : void 0
|
|
4945
3719
|
});
|
|
4946
|
-
let dir =
|
|
3720
|
+
let dir = path27.dirname(relativePath);
|
|
4947
3721
|
while (dir && dir !== "." && dir !== "") {
|
|
4948
3722
|
if (dirs.has(dir)) break;
|
|
4949
3723
|
dirs.add(dir);
|
|
4950
|
-
dir =
|
|
3724
|
+
dir = path27.dirname(dir);
|
|
4951
3725
|
}
|
|
4952
3726
|
structDone++;
|
|
4953
3727
|
context2.onPhaseProgress?.("structure", structDone, context2.filePaths.length);
|
|
@@ -4956,7 +3730,7 @@ var structurePhase = {
|
|
|
4956
3730
|
context2.graph.addNode({
|
|
4957
3731
|
id: generateNodeId("directory", dir, dir),
|
|
4958
3732
|
kind: "directory",
|
|
4959
|
-
name:
|
|
3733
|
+
name: path27.basename(dir),
|
|
4960
3734
|
filePath: dir
|
|
4961
3735
|
});
|
|
4962
3736
|
}
|
|
@@ -5067,22 +3841,22 @@ var flowPhase = {
|
|
|
5067
3841
|
const queue = [{ nodeId: ep.id, path: [ep.id] }];
|
|
5068
3842
|
const visited = /* @__PURE__ */ new Set();
|
|
5069
3843
|
while (queue.length > 0 && flowCount < maxFlows) {
|
|
5070
|
-
const { nodeId, path:
|
|
5071
|
-
if (
|
|
3844
|
+
const { nodeId, path: path28 } = queue.shift();
|
|
3845
|
+
if (path28.length > maxDepth) continue;
|
|
5072
3846
|
const callEdges = [...graph.findEdgesFrom(nodeId)].filter((e) => e.kind === "calls").slice(0, maxBranching);
|
|
5073
|
-
if (callEdges.length === 0 &&
|
|
3847
|
+
if (callEdges.length === 0 && path28.length >= 3) {
|
|
5074
3848
|
const flowId = generateNodeId("flow", ep.filePath, `flow-${flowCount}`);
|
|
5075
3849
|
graph.addNode({
|
|
5076
3850
|
id: flowId,
|
|
5077
3851
|
kind: "flow",
|
|
5078
3852
|
name: `${ep.name} flow ${flowCount}`,
|
|
5079
3853
|
filePath: ep.filePath,
|
|
5080
|
-
metadata: { steps:
|
|
3854
|
+
metadata: { steps: path28, entryPoint: ep.name }
|
|
5081
3855
|
});
|
|
5082
|
-
for (let i = 0; i <
|
|
3856
|
+
for (let i = 0; i < path28.length; i++) {
|
|
5083
3857
|
graph.addEdge({
|
|
5084
|
-
id: generateEdgeId(
|
|
5085
|
-
source:
|
|
3858
|
+
id: generateEdgeId(path28[i], flowId, `step_of_${i}`),
|
|
3859
|
+
source: path28[i],
|
|
5086
3860
|
target: flowId,
|
|
5087
3861
|
kind: "step_of",
|
|
5088
3862
|
weight: 1,
|
|
@@ -5095,7 +3869,7 @@ var flowPhase = {
|
|
|
5095
3869
|
for (const edge of callEdges) {
|
|
5096
3870
|
if (visited.has(edge.target)) continue;
|
|
5097
3871
|
visited.add(edge.target);
|
|
5098
|
-
queue.push({ nodeId: edge.target, path: [...
|
|
3872
|
+
queue.push({ nodeId: edge.target, path: [...path28, edge.target] });
|
|
5099
3873
|
}
|
|
5100
3874
|
}
|
|
5101
3875
|
}
|
|
@@ -5182,8 +3956,8 @@ var WorkerPool = class extends EventEmitter {
|
|
|
5182
3956
|
/** Submit a task. Resolves with the worker result or rejects on error. */
|
|
5183
3957
|
run(input) {
|
|
5184
3958
|
if (this.closed) return Promise.reject(new Error("WorkerPool is closed"));
|
|
5185
|
-
return new Promise((
|
|
5186
|
-
const task = { id: input.taskId, input, resolve
|
|
3959
|
+
return new Promise((resolve, reject) => {
|
|
3960
|
+
const task = { id: input.taskId, input, resolve, reject, retries: 0 };
|
|
5187
3961
|
this.queue.push(task);
|
|
5188
3962
|
if (this.queue.length > this.maxQueueSize) {
|
|
5189
3963
|
this.emit("backpressure", this.queue.length);
|
|
@@ -5236,7 +4010,7 @@ var LANG_QUERIES2 = {
|
|
|
5236
4010
|
};
|
|
5237
4011
|
function workerScriptPath() {
|
|
5238
4012
|
const thisFile = fileURLToPath(import.meta.url);
|
|
5239
|
-
return
|
|
4013
|
+
return path27.join(path27.dirname(thisFile), "parse-worker.js");
|
|
5240
4014
|
}
|
|
5241
4015
|
var parsePhaseParallel = {
|
|
5242
4016
|
name: "parse",
|
|
@@ -5252,14 +4026,14 @@ var parsePhaseParallel = {
|
|
|
5252
4026
|
const batch = filePaths.slice(i, i + CONCURRENCY);
|
|
5253
4027
|
await Promise.all(batch.map(async (filePath) => {
|
|
5254
4028
|
try {
|
|
5255
|
-
const source = await
|
|
4029
|
+
const source = await fs24.promises.readFile(filePath, "utf-8");
|
|
5256
4030
|
context2.fileCache.set(filePath, source);
|
|
5257
4031
|
} catch {
|
|
5258
4032
|
}
|
|
5259
4033
|
}));
|
|
5260
4034
|
}
|
|
5261
4035
|
const workerScript = workerScriptPath();
|
|
5262
|
-
const workerScriptExists =
|
|
4036
|
+
const workerScriptExists = fs24.existsSync(workerScript);
|
|
5263
4037
|
if (!workerScriptExists || workerCount === 1) {
|
|
5264
4038
|
logger_default.info(`[parse-parallel] falling back to sequential (workerCount=${workerCount}, scriptExists=${workerScriptExists})`);
|
|
5265
4039
|
const { parsePhase: parsePhase2 } = await Promise.resolve().then(() => (init_parse_phase(), parse_phase_exports));
|
|
@@ -5271,7 +4045,7 @@ var parsePhaseParallel = {
|
|
|
5271
4045
|
if (!lang) continue;
|
|
5272
4046
|
const source = context2.fileCache.get(filePath);
|
|
5273
4047
|
if (!source) continue;
|
|
5274
|
-
const relativePath =
|
|
4048
|
+
const relativePath = path27.relative(context2.workspaceRoot, filePath);
|
|
5275
4049
|
const fileNodeId = generateNodeId("file", relativePath, relativePath);
|
|
5276
4050
|
const fileNode = context2.graph.getNode(fileNodeId);
|
|
5277
4051
|
if (fileNode) fileNode.content = source.slice(0, 2e3);
|
|
@@ -5314,7 +4088,7 @@ var parsePhaseParallel = {
|
|
|
5314
4088
|
symbolCount += res.nodes.length;
|
|
5315
4089
|
if (res.usedTreeSitter) treeSitterCount++;
|
|
5316
4090
|
else regexCount++;
|
|
5317
|
-
const relativePath =
|
|
4091
|
+
const relativePath = path27.relative(context2.workspaceRoot, res.taskId);
|
|
5318
4092
|
const funcs = res.nodes.filter((n) => n.kind === "function" || n.kind === "method").map((n) => ({ id: n.id, startLine: n.startLine ?? 0, endLine: n.endLine })).sort((a, b) => a.startLine - b.startLine);
|
|
5319
4093
|
if (funcs.length > 0) context2.fileFunctionIndex.set(relativePath, funcs);
|
|
5320
4094
|
parseDone++;
|
|
@@ -5341,7 +4115,7 @@ init_id_generator();
|
|
|
5341
4115
|
init_logger();
|
|
5342
4116
|
function workerScriptPath2() {
|
|
5343
4117
|
const thisFile = fileURLToPath(import.meta.url);
|
|
5344
|
-
return
|
|
4118
|
+
return path27.join(path27.dirname(thisFile), "resolve-worker.js");
|
|
5345
4119
|
}
|
|
5346
4120
|
var resolvePhaseParallel = {
|
|
5347
4121
|
name: "resolve",
|
|
@@ -5353,11 +4127,11 @@ var resolvePhaseParallel = {
|
|
|
5353
4127
|
const fileFunctionIndex = context2.fileFunctionIndex ?? /* @__PURE__ */ new Map();
|
|
5354
4128
|
const fileIndex = {};
|
|
5355
4129
|
for (const fp of filePaths) {
|
|
5356
|
-
const rel =
|
|
4130
|
+
const rel = path27.relative(workspaceRoot, fp);
|
|
5357
4131
|
fileIndex[rel] = fp;
|
|
5358
4132
|
const noExt = rel.replace(/\.\w+$/, "");
|
|
5359
4133
|
if (!fileIndex[noExt]) fileIndex[noExt] = fp;
|
|
5360
|
-
const base =
|
|
4134
|
+
const base = path27.basename(rel, path27.extname(rel));
|
|
5361
4135
|
if (!fileIndex[base]) fileIndex[base] = fp;
|
|
5362
4136
|
}
|
|
5363
4137
|
const symbolIndex = {};
|
|
@@ -5371,7 +4145,7 @@ var resolvePhaseParallel = {
|
|
|
5371
4145
|
}
|
|
5372
4146
|
const snapshot = { symbolIndex, fileSymbolIndex, fileIndex, workspaceRoot };
|
|
5373
4147
|
const workerScript = workerScriptPath2();
|
|
5374
|
-
const workerScriptExists =
|
|
4148
|
+
const workerScriptExists = fs24.existsSync(workerScript);
|
|
5375
4149
|
const workerCount = parseInt(process.env["PARSE_WORKERS"] ?? "", 10) || Math.max(1, os12.cpus().length - 1);
|
|
5376
4150
|
if (!workerScriptExists || workerCount === 1) {
|
|
5377
4151
|
logger_default.info(`[resolve-parallel] falling back to sequential`);
|
|
@@ -5384,7 +4158,7 @@ var resolvePhaseParallel = {
|
|
|
5384
4158
|
if (!lang) continue;
|
|
5385
4159
|
const source = fileCache.get(filePath);
|
|
5386
4160
|
if (!source) continue;
|
|
5387
|
-
const relativePath =
|
|
4161
|
+
const relativePath = path27.relative(workspaceRoot, filePath);
|
|
5388
4162
|
const fileNodeId = generateNodeId("file", relativePath, relativePath);
|
|
5389
4163
|
const funcList = fileFunctionIndex.get(relativePath) ?? [];
|
|
5390
4164
|
tasks.push({ taskId: filePath, filePath, relativePath, fileNodeId, source, funcList });
|
|
@@ -5401,18 +4175,18 @@ var resolvePhaseParallel = {
|
|
|
5401
4175
|
const pendingResolvers = /* @__PURE__ */ new Map();
|
|
5402
4176
|
for (const { w } of workers) {
|
|
5403
4177
|
w.on("message", (result) => {
|
|
5404
|
-
const
|
|
5405
|
-
if (
|
|
4178
|
+
const resolve = pendingResolvers.get(result.taskId);
|
|
4179
|
+
if (resolve) {
|
|
5406
4180
|
pendingResolvers.delete(result.taskId);
|
|
5407
|
-
|
|
4181
|
+
resolve(result);
|
|
5408
4182
|
}
|
|
5409
4183
|
});
|
|
5410
4184
|
w.on("error", (err) => logger_default.warn(`[resolve-worker] error: ${err.message}`));
|
|
5411
4185
|
}
|
|
5412
4186
|
let workerIdx = 0;
|
|
5413
4187
|
function runTask(task) {
|
|
5414
|
-
return new Promise((
|
|
5415
|
-
pendingResolvers.set(task.taskId,
|
|
4188
|
+
return new Promise((resolve) => {
|
|
4189
|
+
pendingResolvers.set(task.taskId, resolve);
|
|
5416
4190
|
const { w } = workers[workerIdx % workers.length];
|
|
5417
4191
|
workerIdx++;
|
|
5418
4192
|
w.postMessage(task);
|
|
@@ -5707,8 +4481,8 @@ async function syncGroup(group) {
|
|
|
5707
4481
|
logger_default.warn(` \u26A0 Registry entry "${member.registryName}" not found \u2014 skipping ${member.groupPath}`);
|
|
5708
4482
|
continue;
|
|
5709
4483
|
}
|
|
5710
|
-
const dbPath =
|
|
5711
|
-
if (!
|
|
4484
|
+
const dbPath = path27.join(regEntry.path, ".code-intel", "graph.db");
|
|
4485
|
+
if (!fs24.existsSync(dbPath)) {
|
|
5712
4486
|
logger_default.warn(` \u26A0 No index at ${dbPath} \u2014 run \`code-intel analyze ${regEntry.path}\` first`);
|
|
5713
4487
|
continue;
|
|
5714
4488
|
}
|
|
@@ -5745,8 +4519,8 @@ async function queryGroup(group, query, limit = 20) {
|
|
|
5745
4519
|
for (const member of group.members) {
|
|
5746
4520
|
const regEntry = registry.find((r) => r.name === member.registryName);
|
|
5747
4521
|
if (!regEntry) continue;
|
|
5748
|
-
const dbPath =
|
|
5749
|
-
if (!
|
|
4522
|
+
const dbPath = path27.join(regEntry.path, ".code-intel", "graph.db");
|
|
4523
|
+
if (!fs24.existsSync(dbPath)) continue;
|
|
5750
4524
|
const graph = createKnowledgeGraph();
|
|
5751
4525
|
const db = new DbManager(dbPath);
|
|
5752
4526
|
try {
|
|
@@ -5805,10 +4579,10 @@ var AppError = class extends Error {
|
|
|
5805
4579
|
var SECURE_DIR_MODE = 448;
|
|
5806
4580
|
var SECURE_FILE_MODE = 384;
|
|
5807
4581
|
function secureMkdir(dir) {
|
|
5808
|
-
|
|
4582
|
+
fs24.mkdirSync(dir, { recursive: true, mode: SECURE_DIR_MODE });
|
|
5809
4583
|
if (process.platform !== "win32") {
|
|
5810
4584
|
try {
|
|
5811
|
-
|
|
4585
|
+
fs24.chmodSync(dir, SECURE_DIR_MODE);
|
|
5812
4586
|
} catch {
|
|
5813
4587
|
}
|
|
5814
4588
|
}
|
|
@@ -5816,22 +4590,22 @@ function secureMkdir(dir) {
|
|
|
5816
4590
|
function secureChmodFile(file) {
|
|
5817
4591
|
if (process.platform === "win32") return;
|
|
5818
4592
|
try {
|
|
5819
|
-
|
|
4593
|
+
fs24.chmodSync(file, SECURE_FILE_MODE);
|
|
5820
4594
|
} catch {
|
|
5821
4595
|
}
|
|
5822
4596
|
}
|
|
5823
4597
|
function secureWriteFile(file, data) {
|
|
5824
|
-
secureMkdir(
|
|
5825
|
-
|
|
4598
|
+
secureMkdir(path27.dirname(file));
|
|
4599
|
+
fs24.writeFileSync(file, data, { mode: SECURE_FILE_MODE });
|
|
5826
4600
|
secureChmodFile(file);
|
|
5827
4601
|
}
|
|
5828
4602
|
function tightenDbFiles(dir) {
|
|
5829
4603
|
if (process.platform === "win32") return;
|
|
5830
|
-
if (!
|
|
5831
|
-
for (const name of
|
|
4604
|
+
if (!fs24.existsSync(dir)) return;
|
|
4605
|
+
for (const name of fs24.readdirSync(dir)) {
|
|
5832
4606
|
if (name.endsWith(".db") || name.endsWith(".db-wal") || name.endsWith(".db-shm")) {
|
|
5833
4607
|
try {
|
|
5834
|
-
|
|
4608
|
+
fs24.chmodSync(path27.join(dir, name), SECURE_FILE_MODE);
|
|
5835
4609
|
} catch {
|
|
5836
4610
|
}
|
|
5837
4611
|
}
|
|
@@ -5843,7 +4617,7 @@ var BCRYPT_ROUNDS = 12;
|
|
|
5843
4617
|
var UsersDB = class {
|
|
5844
4618
|
db;
|
|
5845
4619
|
constructor(dbPath) {
|
|
5846
|
-
const dir =
|
|
4620
|
+
const dir = path27.dirname(dbPath);
|
|
5847
4621
|
secureMkdir(dir);
|
|
5848
4622
|
this.db = new Database2(dbPath);
|
|
5849
4623
|
this.db.pragma("journal_mode = WAL");
|
|
@@ -6113,7 +4887,7 @@ var UsersDB = class {
|
|
|
6113
4887
|
}
|
|
6114
4888
|
};
|
|
6115
4889
|
function getUsersDBPath() {
|
|
6116
|
-
return process.env["CODE_INTEL_USERS_DB_PATH"] ??
|
|
4890
|
+
return process.env["CODE_INTEL_USERS_DB_PATH"] ?? path27.join(os12.homedir(), ".code-intel", "users.db");
|
|
6117
4891
|
}
|
|
6118
4892
|
var _usersDB = null;
|
|
6119
4893
|
function getOrCreateUsersDB() {
|
|
@@ -6132,7 +4906,7 @@ function getScryptN() {
|
|
|
6132
4906
|
return Number.isInteger(v) && v >= 1024 ? v : 1 << 14;
|
|
6133
4907
|
}
|
|
6134
4908
|
function getSecretsPath() {
|
|
6135
|
-
return process.env["CODE_INTEL_SECRETS_PATH"] ??
|
|
4909
|
+
return process.env["CODE_INTEL_SECRETS_PATH"] ?? path27.join(os12.homedir(), ".code-intel", ".secrets");
|
|
6136
4910
|
}
|
|
6137
4911
|
function getMasterPassword() {
|
|
6138
4912
|
const fromEnv = process.env["CODE_INTEL_SECRET_KEY"];
|
|
@@ -6174,12 +4948,12 @@ function decryptSecrets(encrypted) {
|
|
|
6174
4948
|
return JSON.parse(plaintext.toString("utf8"));
|
|
6175
4949
|
}
|
|
6176
4950
|
function loadSecrets(secretsPath = getSecretsPath()) {
|
|
6177
|
-
if (!
|
|
6178
|
-
const blob =
|
|
4951
|
+
if (!fs24.existsSync(secretsPath)) return {};
|
|
4952
|
+
const blob = fs24.readFileSync(secretsPath);
|
|
6179
4953
|
return decryptSecrets(blob);
|
|
6180
4954
|
}
|
|
6181
4955
|
function saveSecrets(blob, secretsPath = getSecretsPath()) {
|
|
6182
|
-
secureMkdir(
|
|
4956
|
+
secureMkdir(path27.dirname(secretsPath));
|
|
6183
4957
|
const encrypted = encryptSecrets(blob);
|
|
6184
4958
|
secureWriteFile(secretsPath, encrypted);
|
|
6185
4959
|
secureChmodFile(secretsPath);
|
|
@@ -6430,12 +5204,12 @@ async function verifyPassword(plain, hash) {
|
|
|
6430
5204
|
return bcrypt.compare(plain, hash);
|
|
6431
5205
|
}
|
|
6432
5206
|
var RETRY_DELAYS_SECONDS = [5, 30, 120];
|
|
6433
|
-
var
|
|
5207
|
+
var MAX_ATTEMPTS = 3;
|
|
6434
5208
|
var STUCK_THRESHOLD_MINUTES = 30;
|
|
6435
5209
|
var JobsDB = class {
|
|
6436
5210
|
db;
|
|
6437
5211
|
constructor(dbPath) {
|
|
6438
|
-
|
|
5212
|
+
fs24.mkdirSync(path27.dirname(dbPath), { recursive: true });
|
|
6439
5213
|
this.db = new Database2(dbPath);
|
|
6440
5214
|
this.db.pragma("journal_mode = WAL");
|
|
6441
5215
|
this.db.pragma("foreign_keys = ON");
|
|
@@ -6451,7 +5225,7 @@ var JobsDB = class {
|
|
|
6451
5225
|
repoPath TEXT NOT NULL,
|
|
6452
5226
|
params TEXT NOT NULL DEFAULT '{}',
|
|
6453
5227
|
attempts INTEGER NOT NULL DEFAULT 0,
|
|
6454
|
-
maxAttempts INTEGER NOT NULL DEFAULT ${
|
|
5228
|
+
maxAttempts INTEGER NOT NULL DEFAULT ${MAX_ATTEMPTS},
|
|
6455
5229
|
createdAt TEXT NOT NULL,
|
|
6456
5230
|
startedAt TEXT NULL,
|
|
6457
5231
|
finishedAt TEXT NULL,
|
|
@@ -6477,7 +5251,7 @@ var JobsDB = class {
|
|
|
6477
5251
|
this.db.prepare(
|
|
6478
5252
|
`INSERT INTO jobs (id, kind, status, repoPath, params, attempts, maxAttempts, createdAt, idempotencyKey)
|
|
6479
5253
|
VALUES (?, ?, 'pending', ?, ?, 0, ?, ?, ?)`
|
|
6480
|
-
).run(id, kind, repoPath, JSON.stringify(params),
|
|
5254
|
+
).run(id, kind, repoPath, JSON.stringify(params), MAX_ATTEMPTS, createdAt, idempotencyKey ?? null);
|
|
6481
5255
|
return this.getJob(id);
|
|
6482
5256
|
}
|
|
6483
5257
|
getJob(id) {
|
|
@@ -6577,7 +5351,7 @@ var JobsDB = class {
|
|
|
6577
5351
|
}
|
|
6578
5352
|
};
|
|
6579
5353
|
function getJobsDBPath() {
|
|
6580
|
-
return
|
|
5354
|
+
return path27.join(os12.homedir(), ".code-intel", "jobs.db");
|
|
6581
5355
|
}
|
|
6582
5356
|
var _jobsDB = null;
|
|
6583
5357
|
function getOrCreateJobsDB() {
|
|
@@ -6591,7 +5365,7 @@ var LLMGovernanceLogger = class {
|
|
|
6591
5365
|
}
|
|
6592
5366
|
/** Path to the JSONL log file. */
|
|
6593
5367
|
getLogPath() {
|
|
6594
|
-
return process.env["CODE_INTEL_GOVERNANCE_LOG_PATH"] ??
|
|
5368
|
+
return process.env["CODE_INTEL_GOVERNANCE_LOG_PATH"] ?? path27.join(os12.homedir(), ".code-intel", "llm-governance.jsonl");
|
|
6595
5369
|
}
|
|
6596
5370
|
/**
|
|
6597
5371
|
* Append an entry to the governance log.
|
|
@@ -6607,8 +5381,8 @@ var LLMGovernanceLogger = class {
|
|
|
6607
5381
|
...entry
|
|
6608
5382
|
};
|
|
6609
5383
|
const logPath = this.getLogPath();
|
|
6610
|
-
|
|
6611
|
-
|
|
5384
|
+
fs24.mkdirSync(path27.dirname(logPath), { recursive: true });
|
|
5385
|
+
fs24.appendFileSync(logPath, JSON.stringify(full) + "\n", "utf-8");
|
|
6612
5386
|
} catch {
|
|
6613
5387
|
}
|
|
6614
5388
|
}
|
|
@@ -6618,7 +5392,7 @@ var LLMGovernanceLogger = class {
|
|
|
6618
5392
|
*/
|
|
6619
5393
|
readLog(limit = 100) {
|
|
6620
5394
|
try {
|
|
6621
|
-
const raw =
|
|
5395
|
+
const raw = fs24.readFileSync(this.getLogPath(), "utf-8");
|
|
6622
5396
|
const lines = raw.split("\n").filter((l) => l.trim().length > 0).slice(-limit);
|
|
6623
5397
|
return lines.map((l) => JSON.parse(l));
|
|
6624
5398
|
} catch {
|
|
@@ -6653,7 +5427,7 @@ function sigV4SigningKey(secret, date, region, service) {
|
|
|
6653
5427
|
return hmac(kService, "aws4_request");
|
|
6654
5428
|
}
|
|
6655
5429
|
function s3Request(opts) {
|
|
6656
|
-
return new Promise((
|
|
5430
|
+
return new Promise((resolve, reject) => {
|
|
6657
5431
|
const { method, cfg, key, body, query } = opts;
|
|
6658
5432
|
const host = `${cfg.bucket}.s3.${cfg.region}.amazonaws.com`;
|
|
6659
5433
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -6701,7 +5475,7 @@ x-amz-date:${amzDate}
|
|
|
6701
5475
|
const req = https.request(reqOptions, (res) => {
|
|
6702
5476
|
const chunks = [];
|
|
6703
5477
|
res.on("data", (c) => chunks.push(c));
|
|
6704
|
-
res.on("end", () =>
|
|
5478
|
+
res.on("end", () => resolve({ statusCode: res.statusCode ?? 0, body: Buffer.concat(chunks).toString("utf-8") }));
|
|
6705
5479
|
});
|
|
6706
5480
|
req.on("error", reject);
|
|
6707
5481
|
if (body) req.write(body);
|
|
@@ -6712,7 +5486,7 @@ var BACKUP_VERSION = "1.0";
|
|
|
6712
5486
|
var ALGORITHM = "aes-256-gcm";
|
|
6713
5487
|
var IV_LENGTH = 16;
|
|
6714
5488
|
function getBackupDir() {
|
|
6715
|
-
return
|
|
5489
|
+
return path27.join(os12.homedir(), ".code-intel", "backups");
|
|
6716
5490
|
}
|
|
6717
5491
|
function getBackupKey() {
|
|
6718
5492
|
const keyHex = process.env["CODE_INTEL_BACKUP_KEY"];
|
|
@@ -6743,30 +5517,30 @@ var BackupService = class {
|
|
|
6743
5517
|
constructor(backupDir) {
|
|
6744
5518
|
this.backupDir = backupDir ?? getBackupDir();
|
|
6745
5519
|
this.key = getBackupKey();
|
|
6746
|
-
|
|
5520
|
+
fs24.mkdirSync(this.backupDir, { recursive: true });
|
|
6747
5521
|
}
|
|
6748
5522
|
/**
|
|
6749
5523
|
* Create a backup for a repository.
|
|
6750
5524
|
* Returns the backup entry.
|
|
6751
5525
|
*/
|
|
6752
5526
|
createBackup(repoPath) {
|
|
6753
|
-
const codeIntelDir =
|
|
5527
|
+
const codeIntelDir = path27.join(repoPath, ".code-intel");
|
|
6754
5528
|
const id = v4();
|
|
6755
5529
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6756
5530
|
const filesToBackup = [];
|
|
6757
5531
|
const candidates = ["graph.db", "vector.db", "meta.json"];
|
|
6758
5532
|
for (const f of candidates) {
|
|
6759
|
-
const fp =
|
|
6760
|
-
if (
|
|
5533
|
+
const fp = path27.join(codeIntelDir, f);
|
|
5534
|
+
if (fs24.existsSync(fp)) {
|
|
6761
5535
|
filesToBackup.push({ name: f, localPath: fp });
|
|
6762
5536
|
}
|
|
6763
5537
|
}
|
|
6764
|
-
const registryPath =
|
|
6765
|
-
if (
|
|
5538
|
+
const registryPath = path27.join(os12.homedir(), ".code-intel", "registry.json");
|
|
5539
|
+
if (fs24.existsSync(registryPath)) {
|
|
6766
5540
|
filesToBackup.push({ name: "registry.json", localPath: registryPath });
|
|
6767
5541
|
}
|
|
6768
|
-
const usersDbPath =
|
|
6769
|
-
if (
|
|
5542
|
+
const usersDbPath = path27.join(os12.homedir(), ".code-intel", "users.db");
|
|
5543
|
+
if (fs24.existsSync(usersDbPath)) {
|
|
6770
5544
|
filesToBackup.push({ name: "users.db", localPath: usersDbPath });
|
|
6771
5545
|
}
|
|
6772
5546
|
if (filesToBackup.length === 0) {
|
|
@@ -6777,7 +5551,7 @@ var BackupService = class {
|
|
|
6777
5551
|
createdAt,
|
|
6778
5552
|
version: BACKUP_VERSION,
|
|
6779
5553
|
files: filesToBackup.map((f) => {
|
|
6780
|
-
const data =
|
|
5554
|
+
const data = fs24.readFileSync(f.localPath);
|
|
6781
5555
|
return {
|
|
6782
5556
|
name: f.name,
|
|
6783
5557
|
sha256: crypto4.createHash("sha256").update(data).digest("hex"),
|
|
@@ -6791,7 +5565,7 @@ var BackupService = class {
|
|
|
6791
5565
|
manifestLenBuf.writeUInt32BE(manifestBuf.length, 0);
|
|
6792
5566
|
parts.push(manifestLenBuf, manifestBuf);
|
|
6793
5567
|
for (const f of filesToBackup) {
|
|
6794
|
-
const data =
|
|
5568
|
+
const data = fs24.readFileSync(f.localPath);
|
|
6795
5569
|
const nameBuf = Buffer.from(f.name, "utf-8");
|
|
6796
5570
|
const nameLenBuf = Buffer.alloc(2);
|
|
6797
5571
|
nameLenBuf.writeUInt16BE(nameBuf.length, 0);
|
|
@@ -6802,8 +5576,8 @@ var BackupService = class {
|
|
|
6802
5576
|
const plaintext = Buffer.concat(parts);
|
|
6803
5577
|
const encrypted = encryptBuffer(plaintext, this.key);
|
|
6804
5578
|
const backupFileName = `backup-${id}.cib`;
|
|
6805
|
-
const backupPath =
|
|
6806
|
-
|
|
5579
|
+
const backupPath = path27.join(this.backupDir, backupFileName);
|
|
5580
|
+
fs24.writeFileSync(backupPath, encrypted);
|
|
6807
5581
|
const entry = {
|
|
6808
5582
|
id,
|
|
6809
5583
|
createdAt,
|
|
@@ -6830,9 +5604,9 @@ var BackupService = class {
|
|
|
6830
5604
|
async uploadToS3(entry) {
|
|
6831
5605
|
const cfg = getS3Config();
|
|
6832
5606
|
if (!cfg) throw new Error("S3 not configured. Set CODE_INTEL_BACKUP_S3_BUCKET, CODE_INTEL_BACKUP_S3_ACCESS_KEY_ID, CODE_INTEL_BACKUP_S3_SECRET_ACCESS_KEY.");
|
|
6833
|
-
const fileName =
|
|
5607
|
+
const fileName = path27.basename(entry.path);
|
|
6834
5608
|
const s3Key = `${cfg.prefix}${fileName}`;
|
|
6835
|
-
const body =
|
|
5609
|
+
const body = fs24.readFileSync(entry.path);
|
|
6836
5610
|
const result = await s3Request({ method: "PUT", cfg, key: s3Key, body });
|
|
6837
5611
|
if (result.statusCode < 200 || result.statusCode >= 300) {
|
|
6838
5612
|
throw new Error(`S3 upload failed (HTTP ${result.statusCode}): ${result.body.slice(0, 200)}`);
|
|
@@ -6849,8 +5623,8 @@ var BackupService = class {
|
|
|
6849
5623
|
if (result.statusCode < 200 || result.statusCode >= 300) {
|
|
6850
5624
|
throw new Error(`S3 download failed (HTTP ${result.statusCode}): ${result.body.slice(0, 200)}`);
|
|
6851
5625
|
}
|
|
6852
|
-
|
|
6853
|
-
|
|
5626
|
+
fs24.mkdirSync(path27.dirname(destPath), { recursive: true });
|
|
5627
|
+
fs24.writeFileSync(destPath, Buffer.from(result.body, "binary"));
|
|
6854
5628
|
}
|
|
6855
5629
|
/**
|
|
6856
5630
|
* List backup objects in S3 with the configured prefix.
|
|
@@ -6896,10 +5670,10 @@ var BackupService = class {
|
|
|
6896
5670
|
if (!entry) {
|
|
6897
5671
|
throw new Error(`Backup "${backupId}" not found.`);
|
|
6898
5672
|
}
|
|
6899
|
-
if (!
|
|
5673
|
+
if (!fs24.existsSync(entry.path)) {
|
|
6900
5674
|
throw new Error(`Backup file not found at: ${entry.path}`);
|
|
6901
5675
|
}
|
|
6902
|
-
const encrypted =
|
|
5676
|
+
const encrypted = fs24.readFileSync(entry.path);
|
|
6903
5677
|
let plaintext;
|
|
6904
5678
|
try {
|
|
6905
5679
|
plaintext = decryptBuffer(encrypted, this.key);
|
|
@@ -6913,8 +5687,8 @@ var BackupService = class {
|
|
|
6913
5687
|
offset += manifestLen;
|
|
6914
5688
|
const manifest = JSON.parse(manifestStr);
|
|
6915
5689
|
const restoreBase = targetRepoPath ?? entry.repoPath;
|
|
6916
|
-
const codeIntelDir =
|
|
6917
|
-
|
|
5690
|
+
const codeIntelDir = path27.join(restoreBase, ".code-intel");
|
|
5691
|
+
fs24.mkdirSync(codeIntelDir, { recursive: true });
|
|
6918
5692
|
for (const fileEntry of manifest.files) {
|
|
6919
5693
|
const nameLen = plaintext.readUInt16BE(offset);
|
|
6920
5694
|
offset += 2;
|
|
@@ -6931,18 +5705,18 @@ var BackupService = class {
|
|
|
6931
5705
|
}
|
|
6932
5706
|
let destPath;
|
|
6933
5707
|
if (name === "registry.json" || name === "users.db") {
|
|
6934
|
-
destPath =
|
|
5708
|
+
destPath = path27.join(os12.homedir(), ".code-intel", name);
|
|
6935
5709
|
} else {
|
|
6936
|
-
destPath =
|
|
5710
|
+
destPath = path27.join(codeIntelDir, name);
|
|
6937
5711
|
}
|
|
6938
|
-
|
|
5712
|
+
fs24.writeFileSync(destPath, data);
|
|
6939
5713
|
}
|
|
6940
5714
|
}
|
|
6941
5715
|
/**
|
|
6942
5716
|
* Apply retention policy: keep N daily, M weekly, L monthly backups.
|
|
6943
5717
|
*/
|
|
6944
5718
|
applyRetention(options = { daily: 7, weekly: 4, monthly: 12 }) {
|
|
6945
|
-
const entries = this._loadIndex().filter((e) =>
|
|
5719
|
+
const entries = this._loadIndex().filter((e) => fs24.existsSync(e.path)).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
6946
5720
|
const keep = /* @__PURE__ */ new Set();
|
|
6947
5721
|
const now = /* @__PURE__ */ new Date();
|
|
6948
5722
|
const dailyCutoff = new Date(now);
|
|
@@ -6972,7 +5746,7 @@ var BackupService = class {
|
|
|
6972
5746
|
for (const e of entries) {
|
|
6973
5747
|
if (!keep.has(e.id)) {
|
|
6974
5748
|
try {
|
|
6975
|
-
|
|
5749
|
+
fs24.unlinkSync(e.path);
|
|
6976
5750
|
deleted++;
|
|
6977
5751
|
} catch {
|
|
6978
5752
|
}
|
|
@@ -6984,17 +5758,17 @@ var BackupService = class {
|
|
|
6984
5758
|
}
|
|
6985
5759
|
// ── Index helpers ──────────────────────────────────────────────────────────
|
|
6986
5760
|
_indexPath() {
|
|
6987
|
-
return
|
|
5761
|
+
return path27.join(this.backupDir, "index.json");
|
|
6988
5762
|
}
|
|
6989
5763
|
_loadIndex() {
|
|
6990
5764
|
try {
|
|
6991
|
-
return JSON.parse(
|
|
5765
|
+
return JSON.parse(fs24.readFileSync(this._indexPath(), "utf-8"));
|
|
6992
5766
|
} catch {
|
|
6993
5767
|
return [];
|
|
6994
5768
|
}
|
|
6995
5769
|
}
|
|
6996
5770
|
_saveIndex(entries) {
|
|
6997
|
-
|
|
5771
|
+
fs24.writeFileSync(this._indexPath(), JSON.stringify(entries, null, 2));
|
|
6998
5772
|
}
|
|
6999
5773
|
_appendIndex(entry) {
|
|
7000
5774
|
const entries = this._loadIndex();
|
|
@@ -7450,11 +6224,11 @@ var openApiSpec = {
|
|
|
7450
6224
|
};
|
|
7451
6225
|
|
|
7452
6226
|
// src/http/app.ts
|
|
7453
|
-
var __dirname$1 =
|
|
6227
|
+
var __dirname$1 = path27.dirname(fileURLToPath(import.meta.url));
|
|
7454
6228
|
var WEB_DIST = (() => {
|
|
7455
|
-
const bundled =
|
|
7456
|
-
if (
|
|
7457
|
-
return
|
|
6229
|
+
const bundled = path27.resolve(__dirname$1, "..", "web");
|
|
6230
|
+
if (fs24.existsSync(bundled)) return bundled;
|
|
6231
|
+
return path27.resolve(__dirname$1, "..", "..", "..", "web", "dist");
|
|
7458
6232
|
})();
|
|
7459
6233
|
function getAllowedOrigins() {
|
|
7460
6234
|
const env = process.env["CODE_INTEL_CORS_ORIGINS"];
|
|
@@ -7623,7 +6397,7 @@ function createApp(graph, repoName, workspaceRoot) {
|
|
|
7623
6397
|
vectorIndexBuilding = false;
|
|
7624
6398
|
}
|
|
7625
6399
|
}
|
|
7626
|
-
if (workspaceRoot) {
|
|
6400
|
+
if (workspaceRoot && process.env["NODE_ENV"] !== "test") {
|
|
7627
6401
|
setImmediate(() => ensureVectorIndex().catch(() => {
|
|
7628
6402
|
}));
|
|
7629
6403
|
}
|
|
@@ -7984,8 +6758,8 @@ function createApp(graph, repoName, workspaceRoot) {
|
|
|
7984
6758
|
const registry = loadRegistry();
|
|
7985
6759
|
const entry = registry.find((r) => r.name === requestedRepo || r.path === requestedRepo);
|
|
7986
6760
|
if (!entry) return null;
|
|
7987
|
-
const dbPath =
|
|
7988
|
-
if (!
|
|
6761
|
+
const dbPath = path27.join(entry.path, ".code-intel", "graph.db");
|
|
6762
|
+
if (!fs24.existsSync(dbPath)) return null;
|
|
7989
6763
|
const repoGraph = createKnowledgeGraph();
|
|
7990
6764
|
const db = new DbManager(dbPath);
|
|
7991
6765
|
try {
|
|
@@ -8071,7 +6845,7 @@ function createApp(graph, repoName, workspaceRoot) {
|
|
|
8071
6845
|
return;
|
|
8072
6846
|
}
|
|
8073
6847
|
try {
|
|
8074
|
-
const content =
|
|
6848
|
+
const content = fs24.readFileSync(file_path, "utf-8");
|
|
8075
6849
|
res.json({ content });
|
|
8076
6850
|
} catch {
|
|
8077
6851
|
res.status(404).json({ error: { code: ErrorCodes.NOT_FOUND, message: "File not found" } });
|
|
@@ -8329,8 +7103,8 @@ function createApp(graph, repoName, workspaceRoot) {
|
|
|
8329
7103
|
for (const member of group.members) {
|
|
8330
7104
|
const regEntry = registry.find((r) => r.name === member.registryName);
|
|
8331
7105
|
if (!regEntry) continue;
|
|
8332
|
-
const dbPath =
|
|
8333
|
-
if (!
|
|
7106
|
+
const dbPath = path27.join(regEntry.path, ".code-intel", "graph.db");
|
|
7107
|
+
if (!fs24.existsSync(dbPath)) continue;
|
|
8334
7108
|
const db = new DbManager(dbPath);
|
|
8335
7109
|
try {
|
|
8336
7110
|
await db.init();
|
|
@@ -8342,10 +7116,10 @@ function createApp(graph, repoName, workspaceRoot) {
|
|
|
8342
7116
|
}
|
|
8343
7117
|
res.json({ nodes: [...mergedGraph.allNodes()], edges: [...mergedGraph.allEdges()] });
|
|
8344
7118
|
});
|
|
8345
|
-
if (
|
|
7119
|
+
if (fs24.existsSync(WEB_DIST)) {
|
|
8346
7120
|
app.use(express.static(WEB_DIST));
|
|
8347
7121
|
app.get("/{*path}", (_req, res) => {
|
|
8348
|
-
res.sendFile(
|
|
7122
|
+
res.sendFile(path27.join(WEB_DIST, "index.html"));
|
|
8349
7123
|
});
|
|
8350
7124
|
}
|
|
8351
7125
|
app.use("/admin", requireRole("admin"));
|
|
@@ -9036,7 +7810,7 @@ async function dispatchTool(name, a, graph, repoName, workspaceRoot) {
|
|
|
9036
7810
|
for (const { filePath: changedFile, changedLines } of changedFiles) {
|
|
9037
7811
|
for (const node of graph.allNodes()) {
|
|
9038
7812
|
if (!node.filePath) continue;
|
|
9039
|
-
const normNode = node.filePath.replace(repoRoot + "/", "").replace(repoRoot +
|
|
7813
|
+
const normNode = node.filePath.replace(repoRoot + "/", "").replace(repoRoot + path27.sep, "");
|
|
9040
7814
|
const normChanged = changedFile.replace(/^a\/|^b\//, "");
|
|
9041
7815
|
if (!normNode.endsWith(normChanged) && !normChanged.endsWith(normNode)) continue;
|
|
9042
7816
|
if (node.startLine !== void 0 && node.endLine !== void 0) {
|
|
@@ -9309,20 +8083,20 @@ function parseDiff(diffText) {
|
|
|
9309
8083
|
// src/cli/main.ts
|
|
9310
8084
|
init_metadata();
|
|
9311
8085
|
async function writeSkillFiles(graph, workspaceRoot, projectName) {
|
|
9312
|
-
const outputDir =
|
|
8086
|
+
const outputDir = path27.join(workspaceRoot, ".claude", "skills", "code-intel");
|
|
9313
8087
|
const areas = buildAreaMap(graph, workspaceRoot);
|
|
9314
8088
|
if (areas.length === 0) return { skills: [], outputDir };
|
|
9315
|
-
|
|
9316
|
-
|
|
8089
|
+
fs24.rmSync(outputDir, { recursive: true, force: true });
|
|
8090
|
+
fs24.mkdirSync(outputDir, { recursive: true });
|
|
9317
8091
|
const skills = [];
|
|
9318
8092
|
const usedNames = /* @__PURE__ */ new Set();
|
|
9319
8093
|
for (const area of areas) {
|
|
9320
8094
|
const kebab = uniqueKebab(area.label, usedNames);
|
|
9321
8095
|
usedNames.add(kebab);
|
|
9322
8096
|
const content = renderSkill(area, projectName, kebab);
|
|
9323
|
-
const dir =
|
|
9324
|
-
|
|
9325
|
-
|
|
8097
|
+
const dir = path27.join(outputDir, kebab);
|
|
8098
|
+
fs24.mkdirSync(dir, { recursive: true });
|
|
8099
|
+
fs24.writeFileSync(path27.join(dir, "SKILL.md"), content, "utf-8");
|
|
9326
8100
|
skills.push({ name: kebab, label: area.label, symbolCount: area.nodes.length, fileCount: area.files.size });
|
|
9327
8101
|
}
|
|
9328
8102
|
return { skills, outputDir };
|
|
@@ -9502,8 +8276,8 @@ var BLOCK_START = "<!-- code-intel:start -->";
|
|
|
9502
8276
|
var BLOCK_END = "<!-- code-intel:end -->";
|
|
9503
8277
|
function writeContextFiles(workspaceRoot, projectName, stats, skills) {
|
|
9504
8278
|
const block = buildBlock(projectName, stats, skills);
|
|
9505
|
-
upsertFile(
|
|
9506
|
-
upsertFile(
|
|
8279
|
+
upsertFile(path27.join(workspaceRoot, "AGENTS.md"), block, "AGENTS.md");
|
|
8280
|
+
upsertFile(path27.join(workspaceRoot, "CLAUDE.md"), block, "CLAUDE.md");
|
|
9507
8281
|
}
|
|
9508
8282
|
function buildBlock(projectName, stats, skills) {
|
|
9509
8283
|
const skillRows = skills.map(
|
|
@@ -9555,7 +8329,7 @@ ${skillTable}
|
|
|
9555
8329
|
${BLOCK_END}`;
|
|
9556
8330
|
}
|
|
9557
8331
|
function upsertFile(filePath, block, fileName) {
|
|
9558
|
-
if (!
|
|
8332
|
+
if (!fs24.existsSync(filePath)) {
|
|
9559
8333
|
const newContent = [
|
|
9560
8334
|
`# ${fileName}`,
|
|
9561
8335
|
"",
|
|
@@ -9566,17 +8340,17 @@ function upsertFile(filePath, block, fileName) {
|
|
|
9566
8340
|
"<!-- Add your own custom notes below this line. They will never be overwritten by code-intel. -->",
|
|
9567
8341
|
""
|
|
9568
8342
|
].join("\n");
|
|
9569
|
-
|
|
8343
|
+
fs24.writeFileSync(filePath, newContent, "utf-8");
|
|
9570
8344
|
return;
|
|
9571
8345
|
}
|
|
9572
|
-
const existing =
|
|
8346
|
+
const existing = fs24.readFileSync(filePath, "utf-8");
|
|
9573
8347
|
const startIdx = findLineMarker(existing, BLOCK_START);
|
|
9574
8348
|
const endIdx = findLineMarker(existing, BLOCK_END, startIdx === -1 ? 0 : startIdx);
|
|
9575
8349
|
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
9576
8350
|
const before = existing.slice(0, startIdx);
|
|
9577
8351
|
const after = existing.slice(endIdx + BLOCK_END.length);
|
|
9578
8352
|
const updated = (before + block + after).trimEnd() + "\n";
|
|
9579
|
-
|
|
8353
|
+
fs24.writeFileSync(filePath, updated, "utf-8");
|
|
9580
8354
|
return;
|
|
9581
8355
|
}
|
|
9582
8356
|
const appended = [
|
|
@@ -9589,7 +8363,7 @@ function upsertFile(filePath, block, fileName) {
|
|
|
9589
8363
|
block,
|
|
9590
8364
|
""
|
|
9591
8365
|
].join("\n");
|
|
9592
|
-
|
|
8366
|
+
fs24.writeFileSync(filePath, appended, "utf-8");
|
|
9593
8367
|
}
|
|
9594
8368
|
function findLineMarker(content, marker, startFrom = 0) {
|
|
9595
8369
|
let idx = content.indexOf(marker, startFrom);
|
|
@@ -9631,14 +8405,14 @@ function getChangedFilesSince(workspaceRoot, baseHash) {
|
|
|
9631
8405
|
function filterChangedByMtime(allFilePaths, workspaceRoot, storedMtimes) {
|
|
9632
8406
|
const changed = [];
|
|
9633
8407
|
for (const absPath of allFilePaths) {
|
|
9634
|
-
const rel =
|
|
8408
|
+
const rel = path27.relative(workspaceRoot, absPath);
|
|
9635
8409
|
const stored = storedMtimes[rel];
|
|
9636
8410
|
if (stored === void 0) {
|
|
9637
8411
|
changed.push(absPath);
|
|
9638
8412
|
continue;
|
|
9639
8413
|
}
|
|
9640
8414
|
try {
|
|
9641
|
-
const { mtimeMs } =
|
|
8415
|
+
const { mtimeMs } = fs24.statSync(absPath);
|
|
9642
8416
|
if (mtimeMs > stored) changed.push(absPath);
|
|
9643
8417
|
} catch {
|
|
9644
8418
|
changed.push(absPath);
|
|
@@ -9650,8 +8424,8 @@ function buildMtimeSnapshot(filePaths, workspaceRoot) {
|
|
|
9650
8424
|
const snap = {};
|
|
9651
8425
|
for (const absPath of filePaths) {
|
|
9652
8426
|
try {
|
|
9653
|
-
const { mtimeMs } =
|
|
9654
|
-
snap[
|
|
8427
|
+
const { mtimeMs } = fs24.statSync(absPath);
|
|
8428
|
+
snap[path27.relative(workspaceRoot, absPath)] = mtimeMs;
|
|
9655
8429
|
} catch {
|
|
9656
8430
|
}
|
|
9657
8431
|
}
|
|
@@ -9662,8 +8436,8 @@ function decideIncremental(workspaceRoot, allFilePaths, prevCommitHash, storedMt
|
|
|
9662
8436
|
if (prevCommitHash) {
|
|
9663
8437
|
const changed = getChangedFilesSince(workspaceRoot, prevCommitHash);
|
|
9664
8438
|
if (changed !== null) {
|
|
9665
|
-
const scanSet = new Set(allFilePaths.map((p) =>
|
|
9666
|
-
const changedInScan = changed.filter((rel) => scanSet.has(rel)).map((rel) =>
|
|
8439
|
+
const scanSet = new Set(allFilePaths.map((p) => path27.relative(workspaceRoot, p)));
|
|
8440
|
+
const changedInScan = changed.filter((rel) => scanSet.has(rel)).map((rel) => path27.join(workspaceRoot, rel));
|
|
9667
8441
|
if (total > 0 && changedInScan.length / total > 0.2) {
|
|
9668
8442
|
return { incremental: false, fallbackReason: `changed files (${changedInScan.length}) > 20% of total (${total})` };
|
|
9669
8443
|
}
|
|
@@ -9776,17 +8550,17 @@ var MigrationRunner = class {
|
|
|
9776
8550
|
autoBackupBeforeMigration() {
|
|
9777
8551
|
try {
|
|
9778
8552
|
const dbFile = this.db.name;
|
|
9779
|
-
if (!dbFile || !
|
|
9780
|
-
const backupDir =
|
|
9781
|
-
|
|
8553
|
+
if (!dbFile || !fs24.existsSync(dbFile)) return;
|
|
8554
|
+
const backupDir = path27.join(os12.homedir(), ".code-intel", "backups", "pre-migration");
|
|
8555
|
+
fs24.mkdirSync(backupDir, { recursive: true });
|
|
9782
8556
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
9783
|
-
const baseName =
|
|
9784
|
-
const backupPath =
|
|
8557
|
+
const baseName = path27.basename(dbFile, ".db");
|
|
8558
|
+
const backupPath = path27.join(backupDir, `${baseName}-pre-migration-${ts}.db`);
|
|
9785
8559
|
try {
|
|
9786
8560
|
this.db.pragma("wal_checkpoint(TRUNCATE)");
|
|
9787
8561
|
} catch {
|
|
9788
8562
|
}
|
|
9789
|
-
|
|
8563
|
+
fs24.copyFileSync(dbFile, backupPath);
|
|
9790
8564
|
} catch {
|
|
9791
8565
|
}
|
|
9792
8566
|
}
|
|
@@ -9997,7 +8771,7 @@ program.name("code-intel").description("Code Intelligence Platform \u2014 Static
|
|
|
9997
8771
|
Docs: https://github.com/vohongtho/code-intel-platform
|
|
9998
8772
|
`);
|
|
9999
8773
|
async function analyzeWorkspace(targetPath, options) {
|
|
10000
|
-
const workspaceRoot =
|
|
8774
|
+
const workspaceRoot = path27.resolve(targetPath);
|
|
10001
8775
|
if (!options?.silent) console.log(`Analyzing: ${workspaceRoot}`);
|
|
10002
8776
|
logger_default.info(`analyze started: ${workspaceRoot}`);
|
|
10003
8777
|
if (options?.force) {
|
|
@@ -10018,14 +8792,14 @@ async function analyzeWorkspace(targetPath, options) {
|
|
|
10018
8792
|
];
|
|
10019
8793
|
for (const f of wipeFiles) {
|
|
10020
8794
|
try {
|
|
10021
|
-
if (
|
|
8795
|
+
if (fs24.existsSync(f)) fs24.unlinkSync(f);
|
|
10022
8796
|
} catch {
|
|
10023
8797
|
}
|
|
10024
8798
|
}
|
|
10025
8799
|
}
|
|
10026
8800
|
if (!options?.skipGit) {
|
|
10027
|
-
const gitDir =
|
|
10028
|
-
if (!
|
|
8801
|
+
const gitDir = path27.join(workspaceRoot, ".git");
|
|
8802
|
+
if (!fs24.existsSync(gitDir)) {
|
|
10029
8803
|
logger_default.warn(`${workspaceRoot} is not a Git repository`);
|
|
10030
8804
|
}
|
|
10031
8805
|
}
|
|
@@ -10124,17 +8898,17 @@ async function analyzeWorkspace(targetPath, options) {
|
|
|
10124
8898
|
const result = await runPipeline(phases, context2);
|
|
10125
8899
|
if (isIncremental && incrementalChangedFiles && incrementalChangedFiles.length > 0) {
|
|
10126
8900
|
const dbPath = getDbPath(workspaceRoot);
|
|
10127
|
-
if (
|
|
8901
|
+
if (fs24.existsSync(dbPath)) {
|
|
10128
8902
|
try {
|
|
10129
8903
|
const db = new DbManager(dbPath);
|
|
10130
8904
|
await db.init();
|
|
10131
8905
|
for (const absPath of incrementalChangedFiles) {
|
|
10132
|
-
const rel =
|
|
8906
|
+
const rel = path27.relative(workspaceRoot, absPath);
|
|
10133
8907
|
await removeNodesForFile(rel, db);
|
|
10134
8908
|
}
|
|
10135
8909
|
const { upsertNodes: upsertNodesBatch } = await Promise.resolve().then(() => (init_graph_loader(), graph_loader_exports));
|
|
10136
8910
|
const changedRelPaths = new Set(
|
|
10137
|
-
incrementalChangedFiles.map((f) =>
|
|
8911
|
+
incrementalChangedFiles.map((f) => path27.relative(workspaceRoot, f))
|
|
10138
8912
|
);
|
|
10139
8913
|
const nodesToUpsert = [...graph.allNodes()].filter(
|
|
10140
8914
|
(n) => changedRelPaths.has(n.filePath)
|
|
@@ -10159,7 +8933,7 @@ async function analyzeWorkspace(targetPath, options) {
|
|
|
10159
8933
|
mergedMtimes = newMtimes;
|
|
10160
8934
|
}
|
|
10161
8935
|
const currentCommitHash = getCurrentCommitHash(workspaceRoot) ?? void 0;
|
|
10162
|
-
const repoName =
|
|
8936
|
+
const repoName = path27.basename(workspaceRoot);
|
|
10163
8937
|
const indexVersion = v4();
|
|
10164
8938
|
saveMetadata(workspaceRoot, {
|
|
10165
8939
|
indexedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -10197,7 +8971,7 @@ async function analyzeWorkspace(targetPath, options) {
|
|
|
10197
8971
|
];
|
|
10198
8972
|
for (const f of newStaleFiles) {
|
|
10199
8973
|
try {
|
|
10200
|
-
if (
|
|
8974
|
+
if (fs24.existsSync(f)) fs24.unlinkSync(f);
|
|
10201
8975
|
} catch {
|
|
10202
8976
|
}
|
|
10203
8977
|
}
|
|
@@ -10214,21 +8988,21 @@ async function analyzeWorkspace(targetPath, options) {
|
|
|
10214
8988
|
];
|
|
10215
8989
|
for (const f of staleFiles) {
|
|
10216
8990
|
try {
|
|
10217
|
-
if (
|
|
8991
|
+
if (fs24.existsSync(f)) fs24.unlinkSync(f);
|
|
10218
8992
|
} catch {
|
|
10219
8993
|
}
|
|
10220
8994
|
}
|
|
10221
8995
|
for (const f of newStaleFiles) {
|
|
10222
8996
|
if (f === dbPathNew) continue;
|
|
10223
|
-
if (
|
|
8997
|
+
if (fs24.existsSync(f)) {
|
|
10224
8998
|
const dest = f.replace(dbPathNew, dbPath);
|
|
10225
8999
|
try {
|
|
10226
|
-
|
|
9000
|
+
fs24.renameSync(f, dest);
|
|
10227
9001
|
} catch {
|
|
10228
9002
|
}
|
|
10229
9003
|
}
|
|
10230
9004
|
}
|
|
10231
|
-
|
|
9005
|
+
fs24.renameSync(dbPathNew, dbPath);
|
|
10232
9006
|
stopSpinner();
|
|
10233
9007
|
logger_default.info(`DB persisted: ${nodeCount} nodes, ${edgeCount} edges`);
|
|
10234
9008
|
if (!options?.silent) {
|
|
@@ -10249,7 +9023,7 @@ async function analyzeWorkspace(targetPath, options) {
|
|
|
10249
9023
|
const staleVdb = [vdbPath, `${vdbPath}-shm`, `${vdbPath}-wal`, `${vdbPath}.shm`, `${vdbPath}.wal`];
|
|
10250
9024
|
for (const f of staleVdb) {
|
|
10251
9025
|
try {
|
|
10252
|
-
if (
|
|
9026
|
+
if (fs24.existsSync(f)) fs24.unlinkSync(f);
|
|
10253
9027
|
} catch {
|
|
10254
9028
|
}
|
|
10255
9029
|
}
|
|
@@ -10349,8 +9123,8 @@ program.command("setup").description("Configure MCP server for your editors (one
|
|
|
10349
9123
|
const configFile = `${configDir}/claude_desktop_config.json`;
|
|
10350
9124
|
try {
|
|
10351
9125
|
let existing = {};
|
|
10352
|
-
if (
|
|
10353
|
-
existing = JSON.parse(
|
|
9126
|
+
if (fs24.existsSync(configFile)) {
|
|
9127
|
+
existing = JSON.parse(fs24.readFileSync(configFile, "utf-8"));
|
|
10354
9128
|
}
|
|
10355
9129
|
const merged = {
|
|
10356
9130
|
...existing,
|
|
@@ -10359,8 +9133,8 @@ program.command("setup").description("Configure MCP server for your editors (one
|
|
|
10359
9133
|
...mcpConfig.mcpServers
|
|
10360
9134
|
}
|
|
10361
9135
|
};
|
|
10362
|
-
|
|
10363
|
-
|
|
9136
|
+
fs24.mkdirSync(configDir, { recursive: true });
|
|
9137
|
+
fs24.writeFileSync(configFile, JSON.stringify(merged, null, 2) + "\n", "utf-8");
|
|
10364
9138
|
console.log(`
|
|
10365
9139
|
\u2705 Written to ${configFile}`);
|
|
10366
9140
|
} catch (err) {
|
|
@@ -10416,10 +9190,10 @@ program.command("mcp").description("Start MCP server over stdio \u2014 exposes a
|
|
|
10416
9190
|
$ code-intel mcp
|
|
10417
9191
|
$ code-intel mcp ./my-project
|
|
10418
9192
|
`).action(async (targetPath) => {
|
|
10419
|
-
const workspaceRoot =
|
|
10420
|
-
const repoName =
|
|
9193
|
+
const workspaceRoot = path27.resolve(targetPath);
|
|
9194
|
+
const repoName = path27.basename(workspaceRoot);
|
|
10421
9195
|
const dbPath = getDbPath(workspaceRoot);
|
|
10422
|
-
const existingIndex =
|
|
9196
|
+
const existingIndex = fs24.existsSync(dbPath) && loadMetadata(workspaceRoot) !== null;
|
|
10423
9197
|
if (existingIndex) {
|
|
10424
9198
|
const graph = createKnowledgeGraph();
|
|
10425
9199
|
const db = new DbManager(dbPath);
|
|
@@ -10450,10 +9224,10 @@ program.command("serve").description("Start the local HTTP server + web UI for g
|
|
|
10450
9224
|
$ code-intel serve --port 8080
|
|
10451
9225
|
$ code-intel serve --force
|
|
10452
9226
|
`).action(async (targetPath, options) => {
|
|
10453
|
-
const workspaceRoot =
|
|
10454
|
-
const repoName =
|
|
9227
|
+
const workspaceRoot = path27.resolve(targetPath);
|
|
9228
|
+
const repoName = path27.basename(workspaceRoot);
|
|
10455
9229
|
const dbPath = getDbPath(workspaceRoot);
|
|
10456
|
-
const existingIndex = !options.force &&
|
|
9230
|
+
const existingIndex = !options.force && fs24.existsSync(dbPath) && loadMetadata(workspaceRoot) !== null;
|
|
10457
9231
|
if (existingIndex) {
|
|
10458
9232
|
const meta = loadMetadata(workspaceRoot);
|
|
10459
9233
|
if (meta.parser === "regex" || meta.parser === void 0) {
|
|
@@ -10508,7 +9282,7 @@ program.command("status").description("Show index freshness and statistics for a
|
|
|
10508
9282
|
$ code-intel status
|
|
10509
9283
|
$ code-intel status ./my-project
|
|
10510
9284
|
`).action((targetPath) => {
|
|
10511
|
-
const workspaceRoot =
|
|
9285
|
+
const workspaceRoot = path27.resolve(targetPath);
|
|
10512
9286
|
const meta = loadMetadata(workspaceRoot);
|
|
10513
9287
|
if (!meta) {
|
|
10514
9288
|
console.log(`
|
|
@@ -10532,18 +9306,18 @@ function trashDirName(repoPath) {
|
|
|
10532
9306
|
return `.code-intel-trash-${date}`;
|
|
10533
9307
|
}
|
|
10534
9308
|
function softDeleteCodeIntel(repoPath) {
|
|
10535
|
-
const codeIntelDir =
|
|
10536
|
-
if (!
|
|
9309
|
+
const codeIntelDir = path27.join(repoPath, ".code-intel");
|
|
9310
|
+
if (!fs24.existsSync(codeIntelDir)) return;
|
|
10537
9311
|
const trashName = trashDirName();
|
|
10538
|
-
const trashDir =
|
|
9312
|
+
const trashDir = path27.join(repoPath, trashName);
|
|
10539
9313
|
let dest = trashDir;
|
|
10540
9314
|
let counter = 1;
|
|
10541
|
-
while (
|
|
9315
|
+
while (fs24.existsSync(dest)) {
|
|
10542
9316
|
dest = `${trashDir}-${counter++}`;
|
|
10543
9317
|
}
|
|
10544
|
-
|
|
10545
|
-
|
|
10546
|
-
|
|
9318
|
+
fs24.renameSync(codeIntelDir, dest);
|
|
9319
|
+
fs24.writeFileSync(
|
|
9320
|
+
path27.join(dest, "TRASH_META.json"),
|
|
10547
9321
|
JSON.stringify({ deletedAt: (/* @__PURE__ */ new Date()).toISOString(), repoPath, permanent: false }, null, 2)
|
|
10548
9322
|
);
|
|
10549
9323
|
console.log(` \u2713 Moved to trash: ${dest}`);
|
|
@@ -10552,15 +9326,15 @@ function softDeleteCodeIntel(repoPath) {
|
|
|
10552
9326
|
function purgeStaleTrashes(repoPath) {
|
|
10553
9327
|
const cutoff = Date.now() - TRASH_TTL_DAYS * 24 * 60 * 60 * 1e3;
|
|
10554
9328
|
try {
|
|
10555
|
-
for (const entry of
|
|
9329
|
+
for (const entry of fs24.readdirSync(repoPath)) {
|
|
10556
9330
|
if (!entry.startsWith(".code-intel-trash-")) continue;
|
|
10557
|
-
const fullPath =
|
|
10558
|
-
const metaPath =
|
|
10559
|
-
if (
|
|
9331
|
+
const fullPath = path27.join(repoPath, entry);
|
|
9332
|
+
const metaPath = path27.join(fullPath, "TRASH_META.json");
|
|
9333
|
+
if (fs24.existsSync(metaPath)) {
|
|
10560
9334
|
try {
|
|
10561
|
-
const meta = JSON.parse(
|
|
9335
|
+
const meta = JSON.parse(fs24.readFileSync(metaPath, "utf-8"));
|
|
10562
9336
|
if (new Date(meta.deletedAt).getTime() < cutoff) {
|
|
10563
|
-
|
|
9337
|
+
fs24.rmSync(fullPath, { recursive: true, force: true });
|
|
10564
9338
|
console.log(` \u2713 Auto-purged stale trash: ${fullPath}`);
|
|
10565
9339
|
}
|
|
10566
9340
|
} catch {
|
|
@@ -10587,18 +9361,18 @@ program.command("clean").description("Soft-delete the knowledge graph index for
|
|
|
10587
9361
|
if (opts.listTrash) {
|
|
10588
9362
|
const repos = loadRegistry();
|
|
10589
9363
|
const roots = repos.map((r) => r.path);
|
|
10590
|
-
if (roots.length === 0) roots.push(
|
|
9364
|
+
if (roots.length === 0) roots.push(path27.resolve("."));
|
|
10591
9365
|
let found = 0;
|
|
10592
9366
|
for (const root of roots) {
|
|
10593
9367
|
try {
|
|
10594
|
-
for (const entry of
|
|
9368
|
+
for (const entry of fs24.readdirSync(root)) {
|
|
10595
9369
|
if (!entry.startsWith(".code-intel-trash-")) continue;
|
|
10596
|
-
const fullPath =
|
|
10597
|
-
const metaPath =
|
|
9370
|
+
const fullPath = path27.join(root, entry);
|
|
9371
|
+
const metaPath = path27.join(fullPath, "TRASH_META.json");
|
|
10598
9372
|
let deletedAt = "unknown";
|
|
10599
|
-
if (
|
|
9373
|
+
if (fs24.existsSync(metaPath)) {
|
|
10600
9374
|
try {
|
|
10601
|
-
deletedAt = JSON.parse(
|
|
9375
|
+
deletedAt = JSON.parse(fs24.readFileSync(metaPath, "utf-8")).deletedAt;
|
|
10602
9376
|
} catch {
|
|
10603
9377
|
}
|
|
10604
9378
|
}
|
|
@@ -10626,9 +9400,9 @@ program.command("clean").description("Soft-delete the knowledge graph index for
|
|
|
10626
9400
|
}
|
|
10627
9401
|
for (const r of repos) {
|
|
10628
9402
|
if (opts.purge) {
|
|
10629
|
-
const codeIntelDir =
|
|
10630
|
-
if (
|
|
10631
|
-
|
|
9403
|
+
const codeIntelDir = path27.join(r.path, ".code-intel");
|
|
9404
|
+
if (fs24.existsSync(codeIntelDir)) {
|
|
9405
|
+
fs24.rmSync(codeIntelDir, { recursive: true, force: true });
|
|
10632
9406
|
console.log(` \u2713 Hard-deleted ${codeIntelDir}`);
|
|
10633
9407
|
}
|
|
10634
9408
|
} else {
|
|
@@ -10642,11 +9416,11 @@ program.command("clean").description("Soft-delete the knowledge graph index for
|
|
|
10642
9416
|
`);
|
|
10643
9417
|
return;
|
|
10644
9418
|
}
|
|
10645
|
-
const workspaceRoot =
|
|
9419
|
+
const workspaceRoot = path27.resolve(targetPath);
|
|
10646
9420
|
if (opts.purge) {
|
|
10647
|
-
const codeIntelDir =
|
|
10648
|
-
if (
|
|
10649
|
-
|
|
9421
|
+
const codeIntelDir = path27.join(workspaceRoot, ".code-intel");
|
|
9422
|
+
if (fs24.existsSync(codeIntelDir)) {
|
|
9423
|
+
fs24.rmSync(codeIntelDir, { recursive: true, force: true });
|
|
10650
9424
|
console.log(`
|
|
10651
9425
|
\u2713 Hard-deleted ${codeIntelDir}`);
|
|
10652
9426
|
}
|
|
@@ -10658,16 +9432,16 @@ program.command("clean").description("Soft-delete the knowledge graph index for
|
|
|
10658
9432
|
console.log(" Index cleaned.\n");
|
|
10659
9433
|
});
|
|
10660
9434
|
async function loadOrAnalyzeWorkspace(targetPath) {
|
|
10661
|
-
const workspaceRoot =
|
|
9435
|
+
const workspaceRoot = path27.resolve(targetPath);
|
|
10662
9436
|
const dbPath = getDbPath(workspaceRoot);
|
|
10663
|
-
const existingIndex =
|
|
9437
|
+
const existingIndex = fs24.existsSync(dbPath) && loadMetadata(workspaceRoot) !== null;
|
|
10664
9438
|
if (existingIndex) {
|
|
10665
9439
|
const graph = createKnowledgeGraph();
|
|
10666
9440
|
const db = new DbManager(dbPath);
|
|
10667
9441
|
await db.init();
|
|
10668
9442
|
await loadGraphFromDB(graph, db);
|
|
10669
9443
|
db.close();
|
|
10670
|
-
return { graph, workspaceRoot, repoName:
|
|
9444
|
+
return { graph, workspaceRoot, repoName: path27.basename(workspaceRoot) };
|
|
10671
9445
|
}
|
|
10672
9446
|
return analyzeWorkspace(targetPath, { silent: true });
|
|
10673
9447
|
}
|
|
@@ -11095,9 +9869,9 @@ groupCmd.command("status <name>").description("Check index freshness and sync st
|
|
|
11095
9869
|
console.log(` \u2717 ${m.groupPath.padEnd(35)} [${m.registryName}] \u2014 NOT IN REGISTRY`);
|
|
11096
9870
|
continue;
|
|
11097
9871
|
}
|
|
11098
|
-
const metaPath =
|
|
9872
|
+
const metaPath = path27.join(regEntry.path, ".code-intel", "meta.json");
|
|
11099
9873
|
try {
|
|
11100
|
-
const meta = JSON.parse(
|
|
9874
|
+
const meta = JSON.parse(fs24.readFileSync(metaPath, "utf-8"));
|
|
11101
9875
|
const indexedAt = meta.indexedAt;
|
|
11102
9876
|
const ageMin = Math.round((now - new Date(indexedAt).getTime()) / 6e4);
|
|
11103
9877
|
const stale = ageMin > 1440 ? " \u26A0 STALE (>24h)" : "";
|
|
@@ -11130,10 +9904,10 @@ userCmd.command("create <username>").description("Create a new local user accoun
|
|
|
11130
9904
|
if (!password) {
|
|
11131
9905
|
const readline = await import('readline');
|
|
11132
9906
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
11133
|
-
password = await new Promise((
|
|
9907
|
+
password = await new Promise((resolve) => {
|
|
11134
9908
|
rl.question(` Password for ${username}: `, (ans) => {
|
|
11135
9909
|
rl.close();
|
|
11136
|
-
|
|
9910
|
+
resolve(ans);
|
|
11137
9911
|
});
|
|
11138
9912
|
});
|
|
11139
9913
|
}
|
|
@@ -11196,10 +9970,10 @@ userCmd.command("reset-password <username>").description("Reset the password for
|
|
|
11196
9970
|
if (!password) {
|
|
11197
9971
|
const readline = await import('readline');
|
|
11198
9972
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
11199
|
-
password = await new Promise((
|
|
9973
|
+
password = await new Promise((resolve) => {
|
|
11200
9974
|
rl.question(` New password for ${username}: `, (ans) => {
|
|
11201
9975
|
rl.close();
|
|
11202
|
-
|
|
9976
|
+
resolve(ans);
|
|
11203
9977
|
});
|
|
11204
9978
|
});
|
|
11205
9979
|
}
|
|
@@ -11314,7 +10088,7 @@ backupCmd.command("create [path]").description("Create an encrypted backup of th
|
|
|
11314
10088
|
$ code-intel backup create
|
|
11315
10089
|
$ code-intel backup create ./my-project
|
|
11316
10090
|
`).action((targetPath = ".") => {
|
|
11317
|
-
const repoPath =
|
|
10091
|
+
const repoPath = path27.resolve(targetPath);
|
|
11318
10092
|
const svc = new BackupService();
|
|
11319
10093
|
try {
|
|
11320
10094
|
const entry = svc.createBackup(repoPath);
|
|
@@ -11343,7 +10117,7 @@ backupCmd.command("list").description("List all available backups").action(() =>
|
|
|
11343
10117
|
Backups (${entries.length}):
|
|
11344
10118
|
`);
|
|
11345
10119
|
for (const e of entries) {
|
|
11346
|
-
const exists =
|
|
10120
|
+
const exists = fs24.existsSync(e.path);
|
|
11347
10121
|
const status = exists ? "\u2713" : "\u2717 (missing)";
|
|
11348
10122
|
console.log(` ${status} ${e.id.slice(0, 8)} ${e.createdAt} ${(e.size / 1024).toFixed(1)} KB \u2192 ${e.repoPath}`);
|
|
11349
10123
|
}
|
|
@@ -11356,7 +10130,7 @@ backupCmd.command("restore <id>").description("Restore a backup by ID").option("
|
|
|
11356
10130
|
`).action((id, opts) => {
|
|
11357
10131
|
const svc = new BackupService();
|
|
11358
10132
|
try {
|
|
11359
|
-
const targetPath = opts.target ?
|
|
10133
|
+
const targetPath = opts.target ? path27.resolve(opts.target) : void 0;
|
|
11360
10134
|
svc.restoreBackup(id, targetPath);
|
|
11361
10135
|
console.log(`
|
|
11362
10136
|
\u2705 Backup "${id}" restored successfully.
|
|
@@ -11375,8 +10149,8 @@ program.command("migrate").description("Manage database schema migrations").opti
|
|
|
11375
10149
|
$ code-intel migrate
|
|
11376
10150
|
$ code-intel migrate --rollback
|
|
11377
10151
|
`).action((opts) => {
|
|
11378
|
-
const dbPath = opts.db ??
|
|
11379
|
-
if (!
|
|
10152
|
+
const dbPath = opts.db ?? path27.join(os12.homedir(), ".code-intel", "users.db");
|
|
10153
|
+
if (!fs24.existsSync(dbPath)) {
|
|
11380
10154
|
console.error(`
|
|
11381
10155
|
\u2717 Database not found: ${dbPath}
|
|
11382
10156
|
Run \`code-intel serve\` or \`code-intel user create\` first.
|
|
@@ -11491,15 +10265,15 @@ authCmd.command("login").description("Authenticate via OIDC device flow \u2014 o
|
|
|
11491
10265
|
}
|
|
11492
10266
|
try {
|
|
11493
10267
|
const tokens = await pollDeviceFlow3(config, deviceResponse);
|
|
11494
|
-
const tokenPath =
|
|
10268
|
+
const tokenPath = path27.join(os12.homedir(), ".code-intel", "oidc-token.json");
|
|
11495
10269
|
const tokenData = {
|
|
11496
10270
|
accessToken: tokens.accessToken,
|
|
11497
10271
|
refreshToken: tokens.refreshToken,
|
|
11498
10272
|
server: serverUrl,
|
|
11499
10273
|
storedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
11500
10274
|
};
|
|
11501
|
-
|
|
11502
|
-
|
|
10275
|
+
fs24.mkdirSync(path27.dirname(tokenPath), { recursive: true });
|
|
10276
|
+
fs24.writeFileSync(tokenPath, JSON.stringify(tokenData, null, 2), { mode: 384 });
|
|
11503
10277
|
console.log(` \u2705 Authenticated successfully!`);
|
|
11504
10278
|
console.log(` Token stored at: ${tokenPath}`);
|
|
11505
10279
|
console.log(` Use CODE_INTEL_TOKEN env var or --token flag to use it with CLI/MCP.
|
|
@@ -11512,13 +10286,13 @@ authCmd.command("login").description("Authenticate via OIDC device flow \u2014 o
|
|
|
11512
10286
|
}
|
|
11513
10287
|
});
|
|
11514
10288
|
authCmd.command("status").description("Show the current OIDC authentication status").action(() => {
|
|
11515
|
-
const tokenPath =
|
|
11516
|
-
if (!
|
|
10289
|
+
const tokenPath = path27.join(os12.homedir(), ".code-intel", "oidc-token.json");
|
|
10290
|
+
if (!fs24.existsSync(tokenPath)) {
|
|
11517
10291
|
console.log("\n Not authenticated via OIDC. Run: code-intel auth login\n");
|
|
11518
10292
|
return;
|
|
11519
10293
|
}
|
|
11520
10294
|
try {
|
|
11521
|
-
const data = JSON.parse(
|
|
10295
|
+
const data = JSON.parse(fs24.readFileSync(tokenPath, "utf-8"));
|
|
11522
10296
|
console.log(`
|
|
11523
10297
|
\u2705 OIDC token stored`);
|
|
11524
10298
|
console.log(` Server : ${data.server ?? "unknown"}`);
|
|
@@ -11530,9 +10304,9 @@ authCmd.command("status").description("Show the current OIDC authentication stat
|
|
|
11530
10304
|
}
|
|
11531
10305
|
});
|
|
11532
10306
|
authCmd.command("logout").description("Remove locally stored OIDC token").action(() => {
|
|
11533
|
-
const tokenPath =
|
|
11534
|
-
if (
|
|
11535
|
-
|
|
10307
|
+
const tokenPath = path27.join(os12.homedir(), ".code-intel", "oidc-token.json");
|
|
10308
|
+
if (fs24.existsSync(tokenPath)) {
|
|
10309
|
+
fs24.unlinkSync(tokenPath);
|
|
11536
10310
|
console.log("\n \u2705 OIDC token removed. You are now logged out.\n");
|
|
11537
10311
|
} else {
|
|
11538
10312
|
console.log("\n No stored token found.\n");
|
|
@@ -11656,8 +10430,8 @@ program.command("config-validate <file>").description("Validate a JSON config fi
|
|
|
11656
10430
|
$ code-intel config-validate ./config.json
|
|
11657
10431
|
$ code-intel config-validate ~/.code-intel/config.json
|
|
11658
10432
|
`).action((file) => {
|
|
11659
|
-
const filePath =
|
|
11660
|
-
if (!
|
|
10433
|
+
const filePath = path27.resolve(file);
|
|
10434
|
+
if (!fs24.existsSync(filePath)) {
|
|
11661
10435
|
console.error(`
|
|
11662
10436
|
\u2717 File not found: ${filePath}
|
|
11663
10437
|
`);
|
|
@@ -11665,7 +10439,7 @@ program.command("config-validate <file>").description("Validate a JSON config fi
|
|
|
11665
10439
|
}
|
|
11666
10440
|
let cfg;
|
|
11667
10441
|
try {
|
|
11668
|
-
cfg = JSON.parse(
|
|
10442
|
+
cfg = JSON.parse(fs24.readFileSync(filePath, "utf-8"));
|
|
11669
10443
|
} catch (err) {
|
|
11670
10444
|
console.error(`
|
|
11671
10445
|
\u2717 Could not parse JSON: ${err instanceof Error ? err.message : err}
|
|
@@ -11686,7 +10460,7 @@ ${err instanceof Error ? err.message : err}
|
|
|
11686
10460
|
});
|
|
11687
10461
|
(function ensurePermissions() {
|
|
11688
10462
|
try {
|
|
11689
|
-
const dir =
|
|
10463
|
+
const dir = path27.join(os12.homedir(), ".code-intel");
|
|
11690
10464
|
secureMkdir(dir);
|
|
11691
10465
|
tightenDbFiles(dir);
|
|
11692
10466
|
} catch {
|