docdex 0.2.9 → 0.2.10
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/CHANGELOG.md +1 -1
- package/lib/postinstall_setup.js +52 -18
- package/lib/uninstall.js +11 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
package/lib/postinstall_setup.js
CHANGED
|
@@ -40,6 +40,10 @@ function configUrlForPort(port) {
|
|
|
40
40
|
return `http://localhost:${port}/sse`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function configStreamableUrlForPort(port) {
|
|
44
|
+
return `http://localhost:${port}/v1/mcp`;
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
function isPortAvailable(port, host) {
|
|
44
48
|
return new Promise((resolve) => {
|
|
45
49
|
const server = net.createServer();
|
|
@@ -837,11 +841,21 @@ async function maybePromptOllamaModel({
|
|
|
837
841
|
}
|
|
838
842
|
|
|
839
843
|
const normalizedInstalled = installed.map(normalizeModelName);
|
|
844
|
+
const displayModels = normalizedInstalled.map((model) => {
|
|
845
|
+
const selectable = model.toLowerCase() !== DEFAULT_OLLAMA_MODEL.toLowerCase();
|
|
846
|
+
return {
|
|
847
|
+
model,
|
|
848
|
+
label: selectable ? model : `${model} (embedding only)`,
|
|
849
|
+
selectable
|
|
850
|
+
};
|
|
851
|
+
});
|
|
852
|
+
const selectableModels = displayModels.filter((item) => item.selectable).map((item) => item.model);
|
|
840
853
|
const installedLower = normalizedInstalled.map((model) => model.toLowerCase());
|
|
841
854
|
const hasPhi = installedLower.includes(phiModel.toLowerCase());
|
|
842
|
-
const
|
|
855
|
+
const defaultLower = defaultChoice ? defaultChoice.toLowerCase() : null;
|
|
856
|
+
const selectionDefault = defaultLower && selectableModels.some((model) => model.toLowerCase() === defaultLower)
|
|
843
857
|
? defaultChoice
|
|
844
|
-
:
|
|
858
|
+
: selectableModels[0];
|
|
845
859
|
|
|
846
860
|
if (decision.mode === "auto") {
|
|
847
861
|
if (selectionDefault) {
|
|
@@ -852,24 +866,28 @@ async function maybePromptOllamaModel({
|
|
|
852
866
|
}
|
|
853
867
|
|
|
854
868
|
stdout.write("[docdex] Ollama models detected:\n");
|
|
855
|
-
|
|
856
|
-
const marker = model === selectionDefault ? " (default)" : "";
|
|
857
|
-
stdout.write(` ${idx + 1}) ${
|
|
869
|
+
displayModels.forEach((item, idx) => {
|
|
870
|
+
const marker = item.model === selectionDefault ? " (default)" : "";
|
|
871
|
+
stdout.write(` ${idx + 1}) ${item.label}${marker}\n`);
|
|
858
872
|
});
|
|
859
873
|
if (!hasPhi) {
|
|
860
874
|
stdout.write(` I) Install ${phiModel} (~${sizeText}, free ${freeText})\n`);
|
|
861
875
|
}
|
|
862
876
|
stdout.write(" S) Skip\n");
|
|
863
877
|
|
|
878
|
+
const defaultHint = selectionDefault ? ` [${selectionDefault}]` : "";
|
|
864
879
|
const answer = await promptInput(
|
|
865
|
-
`[docdex] Select default model
|
|
880
|
+
`[docdex] Select default model${defaultHint}: `,
|
|
866
881
|
{ stdin, stdout }
|
|
867
882
|
);
|
|
868
883
|
const normalizedAnswer = normalizeModelName(answer);
|
|
869
884
|
const answerLower = normalizedAnswer.toLowerCase();
|
|
870
885
|
if (!answer) {
|
|
871
|
-
|
|
872
|
-
|
|
886
|
+
if (selectionDefault) {
|
|
887
|
+
updateDefaultModelConfig(configPath, selectionDefault, logger);
|
|
888
|
+
return { status: "selected", model: selectionDefault };
|
|
889
|
+
}
|
|
890
|
+
return { status: "skipped", reason: "no_models" };
|
|
873
891
|
}
|
|
874
892
|
if (answerLower === "s" || answerLower === "skip") {
|
|
875
893
|
return { status: "skipped", reason: "user_skip" };
|
|
@@ -881,16 +899,24 @@ async function maybePromptOllamaModel({
|
|
|
881
899
|
return { status: "installed", model: phiModel };
|
|
882
900
|
}
|
|
883
901
|
const numeric = Number.parseInt(answerLower, 10);
|
|
884
|
-
if (Number.isFinite(numeric) && numeric >= 1 && numeric <=
|
|
885
|
-
const selected =
|
|
886
|
-
|
|
887
|
-
|
|
902
|
+
if (Number.isFinite(numeric) && numeric >= 1 && numeric <= displayModels.length) {
|
|
903
|
+
const selected = displayModels[numeric - 1];
|
|
904
|
+
if (!selected.selectable) {
|
|
905
|
+
logger?.warn?.(`[docdex] ${selected.model} is an embedding-only model; choose a chat model.`);
|
|
906
|
+
return { status: "skipped", reason: "embedding_only" };
|
|
907
|
+
}
|
|
908
|
+
updateDefaultModelConfig(configPath, selected.model, logger);
|
|
909
|
+
return { status: "selected", model: selected.model };
|
|
888
910
|
}
|
|
889
911
|
const matchedIndex = installedLower.indexOf(answerLower);
|
|
890
912
|
if (matchedIndex !== -1) {
|
|
891
|
-
const selected =
|
|
892
|
-
|
|
893
|
-
|
|
913
|
+
const selected = displayModels[matchedIndex];
|
|
914
|
+
if (!selected.selectable) {
|
|
915
|
+
logger?.warn?.(`[docdex] ${selected.model} is an embedding-only model; choose a chat model.`);
|
|
916
|
+
return { status: "skipped", reason: "embedding_only" };
|
|
917
|
+
}
|
|
918
|
+
updateDefaultModelConfig(configPath, selected.model, logger);
|
|
919
|
+
return { status: "selected", model: selected.model };
|
|
894
920
|
}
|
|
895
921
|
logger?.warn?.("[docdex] Unrecognized selection; skipping model update.");
|
|
896
922
|
return { status: "skipped", reason: "invalid_selection" };
|
|
@@ -1072,8 +1098,14 @@ function commandExists(cmd, spawnSyncFn) {
|
|
|
1072
1098
|
function launchMacTerminal({ binaryPath, args, spawnSyncFn, logger }) {
|
|
1073
1099
|
const command = [binaryPath, ...args].join(" ");
|
|
1074
1100
|
const script = [
|
|
1075
|
-
'tell application "Terminal"
|
|
1076
|
-
|
|
1101
|
+
'tell application "Terminal"',
|
|
1102
|
+
'if not (exists window 1) then',
|
|
1103
|
+
`do script ${JSON.stringify(command)}`,
|
|
1104
|
+
"else",
|
|
1105
|
+
`do script ${JSON.stringify(command)} in window 1`,
|
|
1106
|
+
"end if",
|
|
1107
|
+
"activate",
|
|
1108
|
+
"end tell"
|
|
1077
1109
|
].join("\n");
|
|
1078
1110
|
const result = spawnSyncFn("osascript", ["-e", script]);
|
|
1079
1111
|
if (result.status === 0) return true;
|
|
@@ -1173,10 +1205,11 @@ async function runPostInstallSetup({ binaryPath, logger } = {}) {
|
|
|
1173
1205
|
}
|
|
1174
1206
|
|
|
1175
1207
|
const url = configUrlForPort(port);
|
|
1208
|
+
const codexUrl = configStreamableUrlForPort(port);
|
|
1176
1209
|
const paths = clientConfigPaths();
|
|
1177
1210
|
upsertMcpServerJson(paths.claude, url);
|
|
1178
1211
|
upsertMcpServerJson(paths.cursor, url);
|
|
1179
|
-
upsertCodexConfig(paths.codex,
|
|
1212
|
+
upsertCodexConfig(paths.codex, codexUrl);
|
|
1180
1213
|
|
|
1181
1214
|
const daemonRoot = ensureDaemonRoot();
|
|
1182
1215
|
const resolvedBinary = resolveBinaryPath({ binaryPath });
|
|
@@ -1208,6 +1241,7 @@ module.exports = {
|
|
|
1208
1241
|
upsertCodexConfig,
|
|
1209
1242
|
pickAvailablePort,
|
|
1210
1243
|
configUrlForPort,
|
|
1244
|
+
configStreamableUrlForPort,
|
|
1211
1245
|
parseEnvBool,
|
|
1212
1246
|
resolveOllamaInstallMode,
|
|
1213
1247
|
resolveOllamaModelPromptMode,
|
package/lib/uninstall.js
CHANGED
|
@@ -380,6 +380,16 @@ function stopDaemonByName() {
|
|
|
380
380
|
return true;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
function stopMcpByName() {
|
|
384
|
+
if (process.platform === "win32") {
|
|
385
|
+
spawnSync("taskkill", ["/IM", "docdex-mcp-server.exe", "/T", "/F"]);
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
spawnSync("pkill", ["-TERM", "-x", "docdex-mcp-server"]);
|
|
389
|
+
spawnSync("pkill", ["-TERM", "-f", "docdex-mcp-server"]);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
|
|
383
393
|
function unregisterStartup() {
|
|
384
394
|
if (process.platform === "darwin") {
|
|
385
395
|
const plistPath = path.join(os.homedir(), "Library", "LaunchAgents", "com.docdex.daemon.plist");
|
|
@@ -458,6 +468,7 @@ async function main() {
|
|
|
458
468
|
if (!stopped) {
|
|
459
469
|
stopDaemonByName();
|
|
460
470
|
}
|
|
471
|
+
stopMcpByName();
|
|
461
472
|
unregisterStartup();
|
|
462
473
|
removeClientConfigs();
|
|
463
474
|
clearStartupFailure();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docdex",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"mcpName": "io.github.bekirdag/docdex",
|
|
5
5
|
"description": "Docdex CLI as an npm-installable binary wrapper.",
|
|
6
6
|
"bin": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"postinstall": "node ./lib/install.js",
|
|
19
|
+
"preuninstall": "node ./lib/uninstall.js",
|
|
19
20
|
"postuninstall": "node ./lib/uninstall.js",
|
|
20
21
|
"test": "node --test",
|
|
21
22
|
"pack:verify": "node --test test/packaging_guardrails.test.js"
|