@vohongtho.infotech/code-intel 0.8.0 → 0.9.0

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/index.js CHANGED
@@ -11,7 +11,8 @@ import { SEMRESATTRS_DEPLOYMENT_ENVIRONMENT, SEMRESATTRS_SERVICE_NAME } from '@o
11
11
  import { trace, context, SpanStatusCode } from '@opentelemetry/api';
12
12
  import winston from 'winston';
13
13
  import DailyRotateFile from 'winston-daily-rotate-file';
14
- import os12 from 'os';
14
+ import os13 from 'os';
15
+ import { execSync } from 'child_process';
15
16
  import Database3 from 'better-sqlite3';
16
17
  import bcrypt from 'bcrypt';
17
18
  import crypto5 from 'crypto';
@@ -24,7 +25,6 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
24
25
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
25
26
  import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
26
27
  import { Database, Connection } from '@ladybugdb/core';
27
- import { execSync } from 'child_process';
28
28
  import express from 'express';
29
29
  import compression from 'compression';
30
30
  import cors from 'cors';
@@ -1162,7 +1162,7 @@ var init_logger = __esm({
1162
1162
  };
1163
1163
  }
1164
1164
  /** Global log directory: ~/.code-intel/logs */
1165
- static LOG_DIR = path31.join(os12.homedir(), ".code-intel", "logs");
1165
+ static LOG_DIR = path31.join(os13.homedir(), ".code-intel", "logs");
1166
1166
  static getLogger() {
1167
1167
  if (!_Logger.instance) {
1168
1168
  const isProduction = process.env.NODE_ENV === "production";
@@ -2674,7 +2674,7 @@ function loadSyncResult(groupName) {
2674
2674
  var GROUPS_DIR;
2675
2675
  var init_group_registry = __esm({
2676
2676
  "src/multi-repo/group-registry.ts"() {
2677
- GROUPS_DIR = path31.join(os12.homedir(), ".code-intel", "groups");
2677
+ GROUPS_DIR = path31.join(os13.homedir(), ".code-intel", "groups");
2678
2678
  }
2679
2679
  });
2680
2680
 
@@ -4245,12 +4245,11 @@ var init_vulnerability_detector = __esm({
4245
4245
  };
4246
4246
  }
4247
4247
  });
4248
-
4249
- // src/errors/codes.ts
4250
4248
  var ErrorCodes, AppError;
4251
4249
  var init_codes = __esm({
4252
4250
  "src/errors/codes.ts"() {
4253
4251
  ErrorCodes = {
4252
+ // Auth (CI-1xxx)
4254
4253
  UNAUTHORIZED: "CI-1000",
4255
4254
  FORBIDDEN: "CI-1001",
4256
4255
  NOT_FOUND: "CI-1002",
@@ -4260,6 +4259,16 @@ var init_codes = __esm({
4260
4259
  RATE_LIMIT_EXCEEDED: "CI-1100",
4261
4260
  PAYLOAD_TOO_LARGE: "CI-1101",
4262
4261
  INVALID_REQUEST: "CI-1200",
4262
+ // Config (CI-2xxx)
4263
+ CONFIG_INVALID: "CI-2000",
4264
+ CONFIG_NOT_FOUND: "CI-2001",
4265
+ // Analysis (CI-3xxx)
4266
+ ANALYSIS_FAILED: "CI-3000",
4267
+ // DB (CI-4xxx)
4268
+ DB_ERROR: "CI-4000",
4269
+ // Network (CI-5xxx)
4270
+ NETWORK_ERROR: "CI-5001",
4271
+ // Internal (CI-9xxx)
4263
4272
  INTERNAL_ERROR: "CI-5000"
4264
4273
  };
4265
4274
  AppError = class extends Error {
@@ -4314,7 +4323,7 @@ var init_fs_secure = __esm({
4314
4323
  }
4315
4324
  });
4316
4325
  function getUsersDBPath() {
4317
- return process.env["CODE_INTEL_USERS_DB_PATH"] ?? path31.join(os12.homedir(), ".code-intel", "users.db");
4326
+ return process.env["CODE_INTEL_USERS_DB_PATH"] ?? path31.join(os13.homedir(), ".code-intel", "users.db");
4318
4327
  }
4319
4328
  function getOrCreateUsersDB() {
4320
4329
  if (!_usersDB) {
@@ -4607,17 +4616,17 @@ function getScryptN() {
4607
4616
  return Number.isInteger(v) && v >= 1024 ? v : 1 << 14;
4608
4617
  }
4609
4618
  function getSecretsPath() {
4610
- return process.env["CODE_INTEL_SECRETS_PATH"] ?? path31.join(os12.homedir(), ".code-intel", ".secrets");
4619
+ return process.env["CODE_INTEL_SECRETS_PATH"] ?? path31.join(os13.homedir(), ".code-intel", ".secrets");
4611
4620
  }
4612
4621
  function getMasterPassword() {
4613
4622
  const fromEnv = process.env["CODE_INTEL_SECRET_KEY"];
4614
4623
  if (fromEnv && fromEnv.length >= 16) return fromEnv;
4615
4624
  let username = "unknown";
4616
4625
  try {
4617
- username = os12.userInfo().username;
4626
+ username = os13.userInfo().username;
4618
4627
  } catch {
4619
4628
  }
4620
- return `code-intel-machine:${os12.hostname()}:${username}:${os12.platform()}`;
4629
+ return `code-intel-machine:${os13.hostname()}:${username}:${os13.platform()}`;
4621
4630
  }
4622
4631
  function deriveKey(password, salt) {
4623
4632
  return crypto5.scryptSync(password, salt, KEY_LEN, { N: getScryptN(), r: 8, p: 1 });
@@ -6355,7 +6364,7 @@ var LLMGovernanceLogger = class {
6355
6364
  }
6356
6365
  /** Path to the JSONL log file. */
6357
6366
  getLogPath() {
6358
- return process.env["CODE_INTEL_GOVERNANCE_LOG_PATH"] ?? path31.join(os12.homedir(), ".code-intel", "llm-governance.jsonl");
6367
+ return process.env["CODE_INTEL_GOVERNANCE_LOG_PATH"] ?? path31.join(os13.homedir(), ".code-intel", "llm-governance.jsonl");
6359
6368
  }
6360
6369
  /**
6361
6370
  * Append an entry to the governance log.
@@ -7004,7 +7013,7 @@ async function loadGraphToDB(graph, dbManager) {
7004
7013
  } catch {
7005
7014
  }
7006
7015
  }
7007
- const tmpDir = fs24.mkdtempSync(path31.join(os12.tmpdir(), "code-intel-csv-"));
7016
+ const tmpDir = fs24.mkdtempSync(path31.join(os13.tmpdir(), "code-intel-csv-"));
7008
7017
  try {
7009
7018
  const nodeTableFiles = writeNodeCSVs(graph, tmpDir);
7010
7019
  const edgeGroups = writeEdgeCSV(graph, tmpDir);
@@ -7104,7 +7113,7 @@ function buildNodeProps(node) {
7104
7113
  function escCypher(s) {
7105
7114
  return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "");
7106
7115
  }
7107
- var GLOBAL_DIR = path31.join(os12.homedir(), ".code-intel");
7116
+ var GLOBAL_DIR = path31.join(os13.homedir(), ".code-intel");
7108
7117
  var REPOS_FILE = path31.join(GLOBAL_DIR, "repos.json");
7109
7118
  function loadRegistry() {
7110
7119
  try {
@@ -9669,7 +9678,7 @@ var JobsDB = class {
9669
9678
  }
9670
9679
  };
9671
9680
  function getJobsDBPath() {
9672
- return path31.join(os12.homedir(), ".code-intel", "jobs.db");
9681
+ return path31.join(os13.homedir(), ".code-intel", "jobs.db");
9673
9682
  }
9674
9683
  var _jobsDB = null;
9675
9684
  function getOrCreateJobsDB() {
@@ -9761,14 +9770,14 @@ var BACKUP_VERSION = "1.0";
9761
9770
  var ALGORITHM = "aes-256-gcm";
9762
9771
  var IV_LENGTH = 16;
9763
9772
  function getBackupDir() {
9764
- return path31.join(os12.homedir(), ".code-intel", "backups");
9773
+ return path31.join(os13.homedir(), ".code-intel", "backups");
9765
9774
  }
9766
9775
  function getBackupKey() {
9767
9776
  const keyHex = process.env["CODE_INTEL_BACKUP_KEY"];
9768
9777
  if (keyHex && keyHex.length >= 64) {
9769
9778
  return Buffer.from(keyHex.slice(0, 64), "hex");
9770
9779
  }
9771
- const seed = `code-intel-backup-${os12.hostname()}-${os12.homedir()}`;
9780
+ const seed = `code-intel-backup-${os13.hostname()}-${os13.homedir()}`;
9772
9781
  return crypto5.createHash("sha256").update(seed).digest();
9773
9782
  }
9774
9783
  function encryptBuffer(data, key) {
@@ -9810,11 +9819,11 @@ var BackupService = class {
9810
9819
  filesToBackup.push({ name: f, localPath: fp });
9811
9820
  }
9812
9821
  }
9813
- const registryPath = path31.join(os12.homedir(), ".code-intel", "registry.json");
9822
+ const registryPath = path31.join(os13.homedir(), ".code-intel", "registry.json");
9814
9823
  if (fs24.existsSync(registryPath)) {
9815
9824
  filesToBackup.push({ name: "registry.json", localPath: registryPath });
9816
9825
  }
9817
- const usersDbPath = path31.join(os12.homedir(), ".code-intel", "users.db");
9826
+ const usersDbPath = path31.join(os13.homedir(), ".code-intel", "users.db");
9818
9827
  if (fs24.existsSync(usersDbPath)) {
9819
9828
  filesToBackup.push({ name: "users.db", localPath: usersDbPath });
9820
9829
  }
@@ -9980,7 +9989,7 @@ var BackupService = class {
9980
9989
  }
9981
9990
  let destPath;
9982
9991
  if (name === "registry.json" || name === "users.db") {
9983
- destPath = path31.join(os12.homedir(), ".code-intel", name);
9992
+ destPath = path31.join(os13.homedir(), ".code-intel", name);
9984
9993
  } else {
9985
9994
  destPath = path31.join(codeIntelDir, name);
9986
9995
  }