@cortex-context/cli 0.0.10 → 0.0.12
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 +88 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5617,7 +5617,7 @@ var require_dist = __commonJS({
|
|
|
5617
5617
|
});
|
|
5618
5618
|
};
|
|
5619
5619
|
}
|
|
5620
|
-
var
|
|
5620
|
+
var prompts6 = require_prompts();
|
|
5621
5621
|
var passOn = ["suggest", "format", "onState", "validate", "onRender", "type"];
|
|
5622
5622
|
var noop = () => {
|
|
5623
5623
|
};
|
|
@@ -5668,7 +5668,7 @@ var require_dist = __commonJS({
|
|
|
5668
5668
|
var _question2 = question;
|
|
5669
5669
|
name = _question2.name;
|
|
5670
5670
|
type = _question2.type;
|
|
5671
|
-
if (
|
|
5671
|
+
if (prompts6[type] === void 0) {
|
|
5672
5672
|
throw new Error(`prompt type (${type}) is not defined`);
|
|
5673
5673
|
}
|
|
5674
5674
|
if (override2[question.name] !== void 0) {
|
|
@@ -5679,7 +5679,7 @@ var require_dist = __commonJS({
|
|
|
5679
5679
|
}
|
|
5680
5680
|
}
|
|
5681
5681
|
try {
|
|
5682
|
-
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield
|
|
5682
|
+
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield prompts6[type](question);
|
|
5683
5683
|
answers[name] = answer = yield getFormattedAnswer(question, answer, true);
|
|
5684
5684
|
quit = yield onSubmit(question, answer, answers);
|
|
5685
5685
|
} catch (err) {
|
|
@@ -5711,7 +5711,7 @@ var require_dist = __commonJS({
|
|
|
5711
5711
|
}
|
|
5712
5712
|
module2.exports = Object.assign(prompt, {
|
|
5713
5713
|
prompt,
|
|
5714
|
-
prompts:
|
|
5714
|
+
prompts: prompts6,
|
|
5715
5715
|
inject,
|
|
5716
5716
|
override
|
|
5717
5717
|
});
|
|
@@ -7798,7 +7798,7 @@ var require_prompts2 = __commonJS({
|
|
|
7798
7798
|
var require_lib = __commonJS({
|
|
7799
7799
|
"node_modules/prompts/lib/index.js"(exports2, module2) {
|
|
7800
7800
|
"use strict";
|
|
7801
|
-
var
|
|
7801
|
+
var prompts6 = require_prompts2();
|
|
7802
7802
|
var passOn = ["suggest", "format", "onState", "validate", "onRender", "type"];
|
|
7803
7803
|
var noop = () => {
|
|
7804
7804
|
};
|
|
@@ -7830,7 +7830,7 @@ var require_lib = __commonJS({
|
|
|
7830
7830
|
throw new Error("prompt message is required");
|
|
7831
7831
|
}
|
|
7832
7832
|
({ name, type } = question);
|
|
7833
|
-
if (
|
|
7833
|
+
if (prompts6[type] === void 0) {
|
|
7834
7834
|
throw new Error(`prompt type (${type}) is not defined`);
|
|
7835
7835
|
}
|
|
7836
7836
|
if (override2[question.name] !== void 0) {
|
|
@@ -7841,7 +7841,7 @@ var require_lib = __commonJS({
|
|
|
7841
7841
|
}
|
|
7842
7842
|
}
|
|
7843
7843
|
try {
|
|
7844
|
-
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await
|
|
7844
|
+
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts6[type](question);
|
|
7845
7845
|
answers[name] = answer = await getFormattedAnswer(question, answer, true);
|
|
7846
7846
|
quit = await onSubmit(question, answer, answers);
|
|
7847
7847
|
} catch (err) {
|
|
@@ -7864,7 +7864,7 @@ var require_lib = __commonJS({
|
|
|
7864
7864
|
function override(answers) {
|
|
7865
7865
|
prompt._override = Object.assign({}, answers);
|
|
7866
7866
|
}
|
|
7867
|
-
module2.exports = Object.assign(prompt, { prompt, prompts:
|
|
7867
|
+
module2.exports = Object.assign(prompt, { prompt, prompts: prompts6, inject, override });
|
|
7868
7868
|
}
|
|
7869
7869
|
});
|
|
7870
7870
|
|
|
@@ -28251,17 +28251,17 @@ async function serverCommand(options) {
|
|
|
28251
28251
|
)
|
|
28252
28252
|
);
|
|
28253
28253
|
} else if (crunSetup.error) {
|
|
28254
|
-
console.log(
|
|
28255
|
-
source_default.dim(` (crun setup skipped: ${crunSetup.error})`)
|
|
28256
|
-
);
|
|
28254
|
+
console.log(source_default.dim(` (crun setup skipped: ${crunSetup.error})`));
|
|
28257
28255
|
}
|
|
28258
28256
|
}
|
|
28259
|
-
|
|
28257
|
+
console.log(source_default.dim(" $ docker compose up -d"));
|
|
28258
|
+
console.log("");
|
|
28260
28259
|
const startResult = await deployLocalStack(workDir, {
|
|
28261
28260
|
embeddings: options.embeddings ?? false
|
|
28262
28261
|
});
|
|
28262
|
+
console.log("");
|
|
28263
28263
|
if (!startResult.started) {
|
|
28264
|
-
|
|
28264
|
+
console.log(source_default.red(" \u2717 Docker Compose failed"));
|
|
28265
28265
|
if (startResult.isLxcSysctlError) {
|
|
28266
28266
|
console.log("");
|
|
28267
28267
|
console.log(
|
|
@@ -28280,9 +28280,7 @@ async function serverCommand(options) {
|
|
|
28280
28280
|
);
|
|
28281
28281
|
console.log("");
|
|
28282
28282
|
console.log(
|
|
28283
|
-
source_default.dim(
|
|
28284
|
-
" Attempted automatic fix (crun) \u2014 but it was not enough."
|
|
28285
|
-
)
|
|
28283
|
+
source_default.dim(" Attempted automatic fix (crun) \u2014 but it was not enough.")
|
|
28286
28284
|
);
|
|
28287
28285
|
console.log(
|
|
28288
28286
|
source_default.dim(
|
|
@@ -28292,19 +28290,21 @@ async function serverCommand(options) {
|
|
|
28292
28290
|
console.log("");
|
|
28293
28291
|
console.log(source_default.cyan(" apt-get install -y crun"));
|
|
28294
28292
|
console.log(source_default.cyan(" cat > /etc/docker/daemon.json << 'EOF'"));
|
|
28295
|
-
console.log(
|
|
28293
|
+
console.log(
|
|
28294
|
+
source_default.cyan(
|
|
28295
|
+
' {"default-runtime":"crun","runtimes":{"crun":{"path":"/usr/bin/crun"}}}'
|
|
28296
|
+
)
|
|
28297
|
+
);
|
|
28296
28298
|
console.log(source_default.cyan(" EOF"));
|
|
28297
28299
|
console.log(source_default.cyan(" systemctl restart docker"));
|
|
28298
28300
|
console.log("");
|
|
28299
|
-
console.log(
|
|
28300
|
-
source_default.dim(" Then run cortex-context server again.")
|
|
28301
|
-
);
|
|
28301
|
+
console.log(source_default.dim(" Then run cortex-context server again."));
|
|
28302
28302
|
} else {
|
|
28303
28303
|
console.log(source_default.dim(` ${startResult.error}`));
|
|
28304
28304
|
}
|
|
28305
28305
|
process.exit(1);
|
|
28306
28306
|
}
|
|
28307
|
-
|
|
28307
|
+
console.log(source_default.green(" \u2713 Containers started"));
|
|
28308
28308
|
console.log("");
|
|
28309
28309
|
console.log(source_default.bold(" Step 4: Waiting for Cortex API..."));
|
|
28310
28310
|
const healthSpinner = ora(
|
|
@@ -28539,6 +28539,70 @@ async function uninstallCommand(options) {
|
|
|
28539
28539
|
console.log("");
|
|
28540
28540
|
}
|
|
28541
28541
|
|
|
28542
|
+
// src/commands/reset.ts
|
|
28543
|
+
var import_prompts5 = __toESM(require_prompts3());
|
|
28544
|
+
async function resetCommand(options) {
|
|
28545
|
+
const config2 = readConfig();
|
|
28546
|
+
const url = config2.url;
|
|
28547
|
+
const token = config2.token ?? "";
|
|
28548
|
+
if (!url) {
|
|
28549
|
+
console.error(
|
|
28550
|
+
source_default.red(
|
|
28551
|
+
" \u2717 Cortex URL not configured. Run `cortex-context init` first."
|
|
28552
|
+
)
|
|
28553
|
+
);
|
|
28554
|
+
process.exit(1);
|
|
28555
|
+
}
|
|
28556
|
+
console.log("");
|
|
28557
|
+
console.log(source_default.bold(" \u25C6 Cortex Context \u2014 Reset Graph"));
|
|
28558
|
+
console.log("");
|
|
28559
|
+
console.log(source_default.yellow(" \u26A0 This will delete ALL nodes and relationships from the graph."));
|
|
28560
|
+
console.log(source_default.dim(` Server: ${url}`));
|
|
28561
|
+
console.log("");
|
|
28562
|
+
const confirmed = options.yes || await (0, import_prompts5.default)({
|
|
28563
|
+
type: "confirm",
|
|
28564
|
+
name: "ok",
|
|
28565
|
+
message: "Are you sure you want to wipe the entire graph?",
|
|
28566
|
+
initial: false
|
|
28567
|
+
}).then((r) => r.ok);
|
|
28568
|
+
if (!confirmed) {
|
|
28569
|
+
console.log(source_default.dim(" Aborted."));
|
|
28570
|
+
return;
|
|
28571
|
+
}
|
|
28572
|
+
console.log("");
|
|
28573
|
+
process.stdout.write(source_default.dim(" Sending DELETE /api/v1/graph... "));
|
|
28574
|
+
const endpoint = `${url.replace(/\/$/, "")}/api/v1/graph`;
|
|
28575
|
+
let res;
|
|
28576
|
+
try {
|
|
28577
|
+
res = await fetch(endpoint, {
|
|
28578
|
+
method: "DELETE",
|
|
28579
|
+
headers: {
|
|
28580
|
+
Authorization: `Bearer ${token}`,
|
|
28581
|
+
"Content-Type": "application/json"
|
|
28582
|
+
}
|
|
28583
|
+
});
|
|
28584
|
+
} catch (err) {
|
|
28585
|
+
process.stdout.write("\n");
|
|
28586
|
+
console.error(
|
|
28587
|
+
source_default.red(` \u2717 Network error: ${err instanceof Error ? err.message : String(err)}`)
|
|
28588
|
+
);
|
|
28589
|
+
process.exit(1);
|
|
28590
|
+
}
|
|
28591
|
+
if (!res.ok) {
|
|
28592
|
+
process.stdout.write("\n");
|
|
28593
|
+
const body = await res.text().catch(() => "");
|
|
28594
|
+
console.error(
|
|
28595
|
+
source_default.red(` \u2717 Server returned ${res.status}: ${body || res.statusText}`)
|
|
28596
|
+
);
|
|
28597
|
+
process.exit(1);
|
|
28598
|
+
}
|
|
28599
|
+
const data = await res.json();
|
|
28600
|
+
process.stdout.write("\n");
|
|
28601
|
+
console.log(source_default.green(` \u2713 ${data.message}`));
|
|
28602
|
+
console.log("");
|
|
28603
|
+
console.log(source_default.dim(" Run `cortex-context sync` to re-ingest the graph."));
|
|
28604
|
+
}
|
|
28605
|
+
|
|
28542
28606
|
// src/cli.ts
|
|
28543
28607
|
var import_fs14 = require("fs");
|
|
28544
28608
|
var import_path15 = require("path");
|
|
@@ -28588,6 +28652,9 @@ function createCli() {
|
|
|
28588
28652
|
"--workspace <path>",
|
|
28589
28653
|
"Target workspace path (defaults to current directory)"
|
|
28590
28654
|
).option("-y, --yes", "Skip confirmation prompt").option("--keep-config", "Preserve ~/.cortex-context/config.json").option("--keep-skills", "Preserve .github/skills/cortex-* directories").option("--keep-hook", "Preserve .git/hooks/post-commit").action(uninstallCommand);
|
|
28655
|
+
program3.command("reset").description(
|
|
28656
|
+
"Wipe all nodes and relationships from the Cortex Knowledge Graph (irreversible)"
|
|
28657
|
+
).option("-y, --yes", "Skip confirmation prompt").action(resetCommand);
|
|
28591
28658
|
return program3;
|
|
28592
28659
|
}
|
|
28593
28660
|
|