@cortex-context/cli 0.0.6 → 0.0.8

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
@@ -18210,6 +18210,16 @@ var import_child_process = require("child_process");
18210
18210
  var import_fs5 = require("fs");
18211
18211
  var import_path5 = require("path");
18212
18212
  var import_os3 = require("os");
18213
+ function tryFixLxcSysctl() {
18214
+ try {
18215
+ (0, import_child_process.execSync)("sysctl -w net.ipv4.ip_unprivileged_port_start=0", {
18216
+ stdio: "ignore"
18217
+ });
18218
+ return { applied: true };
18219
+ } catch {
18220
+ return { applied: false };
18221
+ }
18222
+ }
18213
18223
  async function deployLocalStack(workspacePath) {
18214
18224
  const templatePath = (0, import_path5.join)(
18215
18225
  __dirname,
@@ -18225,15 +18235,21 @@ async function deployLocalStack(workspacePath) {
18225
18235
  (0, import_fs5.cpSync)(templatePath, destPath);
18226
18236
  }
18227
18237
  try {
18228
- (0, import_child_process.execSync)(`docker compose -f "${destPath}" up -d`, {
18229
- cwd: workspacePath,
18230
- stdio: "inherit"
18231
- });
18238
+ (0, import_child_process.execSync)(
18239
+ `docker compose --project-name cortex-local -f "${destPath}" up -d`,
18240
+ {
18241
+ cwd: workspacePath,
18242
+ stdio: "inherit"
18243
+ }
18244
+ );
18232
18245
  return { started: true };
18233
18246
  } catch (err) {
18247
+ const msg = err instanceof Error ? err.message : String(err);
18248
+ const isLxcSysctlError = msg.includes("ip_unprivileged_port_start") || msg.includes("sysctl");
18234
18249
  return {
18235
18250
  started: false,
18236
- error: `docker compose failed: ${err instanceof Error ? err.message : String(err)}`
18251
+ isLxcSysctlError,
18252
+ error: `docker compose failed: ${msg}`
18237
18253
  };
18238
18254
  }
18239
18255
  }
@@ -28027,6 +28043,8 @@ async function serveCommand() {
28027
28043
 
28028
28044
  // src/commands/server.ts
28029
28045
  var import_os4 = require("os");
28046
+ var import_fs12 = require("fs");
28047
+ var import_path13 = require("path");
28030
28048
  var import_prompts3 = __toESM(require_prompts3());
28031
28049
  var CORTEX_URL2 = "http://localhost:8082";
28032
28050
  var NEO4J_URL = "http://localhost:7474";
@@ -28039,7 +28057,9 @@ async function serverCommand(options) {
28039
28057
  )
28040
28058
  );
28041
28059
  console.log("");
28042
- const workDir = options.dir ?? process.cwd();
28060
+ const defaultDir = (0, import_path13.join)((0, import_os4.homedir)(), ".cortex-context");
28061
+ const workDir = options.dir ?? defaultDir;
28062
+ (0, import_fs12.mkdirSync)(workDir, { recursive: true });
28043
28063
  console.log(source_default.bold(" Step 1: Docker"));
28044
28064
  const dockerReady = isDockerAvailable();
28045
28065
  if (dockerReady) {
@@ -28139,12 +28159,33 @@ async function serverCommand(options) {
28139
28159
  }
28140
28160
  console.log("");
28141
28161
  console.log(source_default.bold(" Step 3: Starting Cortex stack"));
28162
+ const sysctlFix = tryFixLxcSysctl();
28163
+ if (sysctlFix.applied) {
28164
+ console.log(source_default.dim(" (applied net.ipv4.ip_unprivileged_port_start=0 for LXC compatibility)"));
28165
+ }
28142
28166
  const startSpinner = ora(" Running docker compose up -d...").start();
28143
28167
  const startResult = await deployLocalStack(workDir);
28144
28168
  if (!startResult.started) {
28145
- startSpinner.fail(
28146
- source_default.red(` \u2717 Docker Compose failed: ${startResult.error}`)
28147
- );
28169
+ startSpinner.fail(source_default.red(" \u2717 Docker Compose failed"));
28170
+ if (startResult.isLxcSysctlError) {
28171
+ console.log("");
28172
+ console.log(source_default.bold.yellow(" \u26A0 Proxmox LXC sysctl restriction detected"));
28173
+ console.log("");
28174
+ console.log(source_default.dim(" runc >= 1.1 tries to configure net.ipv4.ip_unprivileged_port_start"));
28175
+ console.log(source_default.dim(" inside each container's network namespace. Proxmox LXC containers"));
28176
+ console.log(source_default.dim(" block this unless the sysctl is explicitly allowed in the LXC config."));
28177
+ console.log("");
28178
+ console.log(source_default.bold(" Fix (run on the Proxmox host):"));
28179
+ console.log("");
28180
+ console.log(source_default.cyan(" CTID=<your-container-id>"));
28181
+ console.log(source_default.cyan(' echo "lxc.sysctl.net.ipv4.ip_unprivileged_port_start = 0" \\'));
28182
+ console.log(source_default.cyan(" >> /etc/pve/lxc/${CTID}.conf"));
28183
+ console.log(source_default.cyan(" pct restart ${CTID}"));
28184
+ console.log("");
28185
+ console.log(source_default.dim(" Then run cortex-context server again inside the LXC."));
28186
+ } else {
28187
+ console.log(source_default.dim(` ${startResult.error}`));
28188
+ }
28148
28189
  process.exit(1);
28149
28190
  }
28150
28191
  startSpinner.succeed(source_default.green(" \u2713 Containers started"));
@@ -28187,8 +28228,8 @@ async function serverCommand(options) {
28187
28228
  }
28188
28229
 
28189
28230
  // src/commands/uninstall.ts
28190
- var import_path13 = require("path");
28191
- var import_fs12 = require("fs");
28231
+ var import_path14 = require("path");
28232
+ var import_fs13 = require("fs");
28192
28233
  var import_prompts4 = __toESM(require_prompts3());
28193
28234
  var CORTEX_SKILLS = [
28194
28235
  "cortex-research",
@@ -28201,20 +28242,20 @@ async function uninstallCommand(options) {
28201
28242
  console.log(source_default.bold.cyan(" \u25C6 Cortex Context \u2014 Uninstall"));
28202
28243
  console.log(source_default.dim(" Removes Cortex Context from your workspace."));
28203
28244
  console.log("");
28204
- const workspacePath = (0, import_path13.resolve)(options.workspace ?? process.cwd());
28245
+ const workspacePath = (0, import_path14.resolve)(options.workspace ?? process.cwd());
28205
28246
  console.log(source_default.dim(` Workspace: ${workspacePath}`));
28206
28247
  console.log("");
28207
- const skillsPath = (0, import_path13.join)(workspacePath, ".github", "skills");
28248
+ const skillsPath = (0, import_path14.join)(workspacePath, ".github", "skills");
28208
28249
  const skillsToRemove = CORTEX_SKILLS.filter(
28209
- (s) => (0, import_fs12.existsSync)((0, import_path13.join)(skillsPath, s))
28250
+ (s) => (0, import_fs13.existsSync)((0, import_path14.join)(skillsPath, s))
28210
28251
  );
28211
- const hasMcp = (0, import_fs12.existsSync)((0, import_path13.join)(workspacePath, ".vscode", "mcp.json"));
28212
- const hasCursorMcp = (0, import_fs12.existsSync)((0, import_path13.join)(workspacePath, ".cursor", "mcp.json"));
28213
- const hasHook = (0, import_fs12.existsSync)(
28214
- (0, import_path13.join)(workspacePath, ".git", "hooks", "post-commit")
28252
+ const hasMcp = (0, import_fs13.existsSync)((0, import_path14.join)(workspacePath, ".vscode", "mcp.json"));
28253
+ const hasCursorMcp = (0, import_fs13.existsSync)((0, import_path14.join)(workspacePath, ".cursor", "mcp.json"));
28254
+ const hasHook = (0, import_fs13.existsSync)(
28255
+ (0, import_path14.join)(workspacePath, ".git", "hooks", "post-commit")
28215
28256
  );
28216
- const hasConfig = (0, import_fs12.existsSync)(
28217
- (0, import_path13.join)(process.env["HOME"] ?? "~", ".cortex-context", "config.json")
28257
+ const hasConfig = (0, import_fs13.existsSync)(
28258
+ (0, import_path14.join)(process.env["HOME"] ?? "~", ".cortex-context", "config.json")
28218
28259
  );
28219
28260
  console.log(source_default.bold(" Will remove:"));
28220
28261
  if (hasMcp) {
@@ -28313,9 +28354,9 @@ async function uninstallCommand(options) {
28313
28354
  }
28314
28355
  if (!options.keepSkills) {
28315
28356
  for (const skill of skillsToRemove) {
28316
- const skillDir = (0, import_path13.join)(skillsPath, skill);
28357
+ const skillDir = (0, import_path14.join)(skillsPath, skill);
28317
28358
  try {
28318
- (0, import_fs12.rmSync)(skillDir, { recursive: true, force: true });
28359
+ (0, import_fs13.rmSync)(skillDir, { recursive: true, force: true });
28319
28360
  console.log(source_default.green(` \u2713 .github/skills/${skill}/ \u2014 removed`));
28320
28361
  removed++;
28321
28362
  } catch (err) {
@@ -28329,12 +28370,12 @@ async function uninstallCommand(options) {
28329
28370
  }
28330
28371
  }
28331
28372
  if (!options.keepHook && hasHook) {
28332
- const hookPath = (0, import_path13.join)(workspacePath, ".git", "hooks", "post-commit");
28373
+ const hookPath = (0, import_path14.join)(workspacePath, ".git", "hooks", "post-commit");
28333
28374
  try {
28334
28375
  const { readFileSync: readFileSync7 } = await import("fs");
28335
28376
  const hookContent = readFileSync7(hookPath, "utf-8");
28336
28377
  if (hookContent.includes("cortex-context")) {
28337
- (0, import_fs12.unlinkSync)(hookPath);
28378
+ (0, import_fs13.unlinkSync)(hookPath);
28338
28379
  console.log(source_default.green(" \u2713 .git/hooks/post-commit \u2014 removed"));
28339
28380
  removed++;
28340
28381
  } else {
@@ -28383,10 +28424,10 @@ async function uninstallCommand(options) {
28383
28424
  }
28384
28425
 
28385
28426
  // src/cli.ts
28386
- var import_fs13 = require("fs");
28387
- var import_path14 = require("path");
28427
+ var import_fs14 = require("fs");
28428
+ var import_path15 = require("path");
28388
28429
  var pkg = JSON.parse(
28389
- (0, import_fs13.readFileSync)((0, import_path14.join)(__dirname, "..", "package.json"), "utf-8")
28430
+ (0, import_fs14.readFileSync)((0, import_path15.join)(__dirname, "..", "package.json"), "utf-8")
28390
28431
  );
28391
28432
  function createCli() {
28392
28433
  const program3 = new Command();