@ncukondo/reference-manager 0.12.2 → 0.12.3
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/chunks/{action-menu-DVnckcXj.js → action-menu-wjKl5_b6.js} +3 -3
- package/dist/chunks/{action-menu-DVnckcXj.js.map → action-menu-wjKl5_b6.js.map} +1 -1
- package/dist/chunks/{index-ESdsVVfP.js → index-uiCqx7-V.js} +12 -16
- package/dist/chunks/index-uiCqx7-V.js.map +1 -0
- package/dist/chunks/{index-Az8CHxm3.js → index-vL26PhAf.js} +2 -1
- package/dist/chunks/{index-Az8CHxm3.js.map → index-vL26PhAf.js.map} +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/features/operations/add.d.ts +1 -0
- package/dist/features/operations/add.d.ts.map +1 -1
- package/dist/features/operations/json-output.d.ts +0 -2
- package/dist/features/operations/json-output.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/index-ESdsVVfP.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as formatBibtex } from "./index-
|
|
2
|
-
import { f as formatBibliographyCSL } from "./index-
|
|
1
|
+
import { f as formatBibtex } from "./index-uiCqx7-V.js";
|
|
2
|
+
import { f as formatBibliographyCSL } from "./index-vL26PhAf.js";
|
|
3
3
|
const ACTION_CHOICES = [
|
|
4
4
|
{ name: "output-ids", message: "Output IDs (citation keys)", value: "output-ids" },
|
|
5
5
|
{ name: "output-csl-json", message: "Output as CSL-JSON", value: "output-csl-json" },
|
|
@@ -116,4 +116,4 @@ export {
|
|
|
116
116
|
runActionMenu,
|
|
117
117
|
runStyleSelectPrompt
|
|
118
118
|
};
|
|
119
|
-
//# sourceMappingURL=action-menu-
|
|
119
|
+
//# sourceMappingURL=action-menu-wjKl5_b6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-menu-
|
|
1
|
+
{"version":3,"file":"action-menu-wjKl5_b6.js","sources":["../../src/features/interactive/action-menu.ts"],"sourcesContent":["/**\n * Action menu for interactive search mode.\n * Allows users to perform actions on selected references.\n */\n\nimport type { CslItem } from \"../../core/csl-json/types.js\";\nimport { formatBibliographyCSL, formatBibtex } from \"../format/index.js\";\n\n/**\n * Action types available in the action menu.\n */\nexport type ActionType =\n | \"output-ids\"\n | \"output-csl-json\"\n | \"output-bibtex\"\n | \"cite-apa\"\n | \"cite-choose\"\n | \"cancel\";\n\n/**\n * Result from action menu selection.\n */\nexport interface ActionMenuResult {\n /** Selected action type */\n action: ActionType;\n /** Generated output (empty for cancel) */\n output: string;\n /** Whether the prompt was cancelled */\n cancelled: boolean;\n}\n\n/**\n * Result from style selection prompt.\n */\nexport interface StyleSelectResult {\n /** Selected style (undefined if cancelled) */\n style?: string;\n /** Whether the prompt was cancelled */\n cancelled: boolean;\n}\n\n/**\n * Choice definition for Enquirer Select prompt.\n */\ninterface SelectChoice {\n name: string;\n message: string;\n value: ActionType | string;\n}\n\n/**\n * Available action choices for the action menu.\n */\nexport const ACTION_CHOICES: SelectChoice[] = [\n { name: \"output-ids\", message: \"Output IDs (citation keys)\", value: \"output-ids\" },\n { name: \"output-csl-json\", message: \"Output as CSL-JSON\", value: \"output-csl-json\" },\n { name: \"output-bibtex\", message: \"Output as BibTeX\", value: \"output-bibtex\" },\n { name: \"cite-apa\", message: \"Generate citation (APA)\", value: \"cite-apa\" },\n { name: \"cite-choose\", message: \"Generate citation (choose style)\", value: \"cite-choose\" },\n { name: \"cancel\", message: \"Cancel\", value: \"cancel\" },\n];\n\n/**\n * Available style choices for citation style selection.\n * Uses BUILTIN_STYLES from config/csl-styles.ts\n */\nexport const STYLE_CHOICES: SelectChoice[] = [\n { name: \"apa\", message: \"APA\", value: \"apa\" },\n { name: \"vancouver\", message: \"Vancouver\", value: \"vancouver\" },\n { name: \"harvard\", message: \"Harvard\", value: \"harvard\" },\n];\n\n/**\n * Run the style selection prompt.\n */\n\n/**\n * Generate output for the given action and items.\n */\nfunction generateOutput(action: ActionType, items: CslItem[], style = \"apa\"): string {\n switch (action) {\n case \"output-ids\":\n return items.map((item) => item.id).join(\"\\n\");\n\n case \"output-csl-json\":\n return JSON.stringify(items, null, 2);\n\n case \"output-bibtex\":\n return formatBibtex(items);\n\n case \"cite-apa\":\n return formatBibliographyCSL(items, { style: \"apa\" });\n\n case \"cite-choose\":\n return formatBibliographyCSL(items, { style });\n\n case \"cancel\":\n return \"\";\n\n default:\n return \"\";\n }\n}\n\n/**\n * Process the selected action and generate result.\n */\nasync function processAction(action: ActionType, items: CslItem[]): Promise<ActionMenuResult> {\n // Handle cite-choose: prompt for style first\n if (action === \"cite-choose\") {\n const styleResult = await runStyleSelectPrompt();\n if (styleResult.cancelled) {\n return {\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n };\n }\n return {\n action,\n output: generateOutput(action, items, styleResult.style),\n cancelled: false,\n };\n }\n\n // Handle cancel\n if (action === \"cancel\") {\n return {\n action,\n output: \"\",\n cancelled: true,\n };\n }\n\n // Handle other actions\n return {\n action,\n output: generateOutput(action, items),\n cancelled: false,\n };\n}\n\nexport async function runStyleSelectPrompt(): Promise<StyleSelectResult> {\n // Dynamic import to allow mocking in tests\n // enquirer is a CommonJS module, so we must use default import\n const enquirer = await import(\"enquirer\");\n const Select = (enquirer.default as unknown as Record<string, unknown>).Select as new (\n options: Record<string, unknown>\n ) => { run(): Promise<string> };\n\n const promptOptions = {\n name: \"style\",\n message: \"Select citation style:\",\n choices: STYLE_CHOICES,\n };\n\n try {\n const prompt = new Select(promptOptions);\n const result = (await prompt.run()) as string;\n\n return {\n style: result,\n cancelled: false,\n };\n } catch (error) {\n // Enquirer throws an empty string when cancelled\n if (error === \"\" || (error instanceof Error && error.message === \"\")) {\n return {\n cancelled: true,\n };\n }\n throw error;\n }\n}\n\n/**\n * Run the action menu for selected references.\n *\n * @param items - Selected references\n * @returns Action result with output\n */\nexport async function runActionMenu(items: CslItem[]): Promise<ActionMenuResult> {\n // Dynamic import to allow mocking in tests\n // enquirer is a CommonJS module, so we must use default import\n const enquirer = await import(\"enquirer\");\n const Select = (enquirer.default as unknown as Record<string, unknown>).Select as new (\n options: Record<string, unknown>\n ) => { run(): Promise<string> };\n\n const count = items.length;\n const refWord = count === 1 ? \"reference\" : \"references\";\n const message = `Action for ${count} selected ${refWord}:`;\n\n const promptOptions = {\n name: \"action\",\n message,\n choices: ACTION_CHOICES,\n };\n\n try {\n const prompt = new Select(promptOptions);\n const action = (await prompt.run()) as ActionType;\n\n return processAction(action, items);\n } catch (error) {\n // Enquirer throws an empty string when cancelled\n if (error === \"\" || (error instanceof Error && error.message === \"\")) {\n return {\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n };\n }\n throw error;\n }\n}\n"],"names":[],"mappings":";;AAqDO,MAAM,iBAAiC;AAAA,EAC5C,EAAE,MAAM,cAAc,SAAS,8BAA8B,OAAO,aAAA;AAAA,EACpE,EAAE,MAAM,mBAAmB,SAAS,sBAAsB,OAAO,kBAAA;AAAA,EACjE,EAAE,MAAM,iBAAiB,SAAS,oBAAoB,OAAO,gBAAA;AAAA,EAC7D,EAAE,MAAM,YAAY,SAAS,2BAA2B,OAAO,WAAA;AAAA,EAC/D,EAAE,MAAM,eAAe,SAAS,oCAAoC,OAAO,cAAA;AAAA,EAC3E,EAAE,MAAM,UAAU,SAAS,UAAU,OAAO,SAAA;AAC9C;AAMO,MAAM,gBAAgC;AAAA,EAC3C,EAAE,MAAM,OAAO,SAAS,OAAO,OAAO,MAAA;AAAA,EACtC,EAAE,MAAM,aAAa,SAAS,aAAa,OAAO,YAAA;AAAA,EAClD,EAAE,MAAM,WAAW,SAAS,WAAW,OAAO,UAAA;AAChD;AASA,SAAS,eAAe,QAAoB,OAAkB,QAAQ,OAAe;AACnF,UAAQ,QAAA;AAAA,IACN,KAAK;AACH,aAAO,MAAM,IAAI,CAAC,SAAS,KAAK,EAAE,EAAE,KAAK,IAAI;AAAA,IAE/C,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AAA;AAAA,IAEf;AACA,UAAM;AAAA,EACR;AACF;AAQA,eAAsB,cAAc,OAA6C;AAG/E,QAAM,WAAW,MAAM,OAAO,UAAU;AACxC,QAAM,SAAU,SAAS,QAA+C;AAIxE,QAAM,QAAQ,MAAM;AACpB,QAAM,UAAU,UAAU,IAAI,cAAc;AAC5C,QAAM,UAAU,cAAc,KAAK,aAAa,OAAO;AAEvD,QAAM,gBAAgB;AAAA,IACpB,MAAM;AAAA,IACN;AAAA,IACA,SAAS;AAAA,EAAA;AAGX,MAAI;AACF,UAAM,SAAS,IAAI,OAAO,aAAa;AACvC,UAAM,SAAU,MAAM,OAAO,IAAA;AAE7B,WAAO,cAAc,QAAQ,KAAK;AAAA,EACpC,SAAS,OAAO;AAEd,QAAI,UAAU,MAAO,iBAAiB,SAAS,MAAM,YAAY,IAAK;AACpE,aAAO;AAAA,QACL,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,WAAW;AAAA,MAAA;AAAA,IAEf;AACA,UAAM;AAAA,EACR;AACF;"}
|
|
@@ -9,14 +9,14 @@ import * as path from "node:path";
|
|
|
9
9
|
import { join, extname } from "node:path";
|
|
10
10
|
import { spawnSync, spawn } from "node:child_process";
|
|
11
11
|
import { mkdir, unlink, rename, copyFile, rm, readFile } from "node:fs/promises";
|
|
12
|
-
import { u as updateReference, B as BUILTIN_STYLES, s as startServerWithFileWatcher, g as getFulltextAttachmentTypes } from "./index-
|
|
12
|
+
import { u as updateReference, B as BUILTIN_STYLES, s as startServerWithFileWatcher, g as getFulltextAttachmentTypes } from "./index-vL26PhAf.js";
|
|
13
13
|
import { o as openWithSystemApp, l as loadConfig } from "./loader-DVmjpU4U.js";
|
|
14
14
|
import "@citation-js/core";
|
|
15
15
|
import "@citation-js/plugin-csl";
|
|
16
16
|
import process$1, { stdin, stdout } from "node:process";
|
|
17
17
|
import { serve } from "@hono/node-server";
|
|
18
18
|
const name = "@ncukondo/reference-manager";
|
|
19
|
-
const version$1 = "0.12.
|
|
19
|
+
const version$1 = "0.12.3";
|
|
20
20
|
const description$1 = "A local reference management tool using CSL-JSON as the single source of truth";
|
|
21
21
|
const packageJson = {
|
|
22
22
|
name,
|
|
@@ -24,10 +24,10 @@ const packageJson = {
|
|
|
24
24
|
description: description$1
|
|
25
25
|
};
|
|
26
26
|
function formatAddJsonOutput(result, options) {
|
|
27
|
-
const { full = false,
|
|
27
|
+
const { full = false, items: items2 = /* @__PURE__ */ new Map() } = options;
|
|
28
28
|
const added = result.added.map((item) => {
|
|
29
29
|
const output = {
|
|
30
|
-
source:
|
|
30
|
+
source: item.source,
|
|
31
31
|
id: item.id,
|
|
32
32
|
uuid: item.uuid,
|
|
33
33
|
title: item.title
|
|
@@ -27343,19 +27343,19 @@ class OperationsLibrary {
|
|
|
27343
27343
|
}
|
|
27344
27344
|
// High-level operations
|
|
27345
27345
|
async search(options) {
|
|
27346
|
-
const { searchReferences } = await import("./index-
|
|
27346
|
+
const { searchReferences } = await import("./index-vL26PhAf.js").then((n) => n.d);
|
|
27347
27347
|
return searchReferences(this.library, options);
|
|
27348
27348
|
}
|
|
27349
27349
|
async list(options) {
|
|
27350
|
-
const { listReferences } = await import("./index-
|
|
27350
|
+
const { listReferences } = await import("./index-vL26PhAf.js").then((n) => n.l);
|
|
27351
27351
|
return listReferences(this.library, options ?? {});
|
|
27352
27352
|
}
|
|
27353
27353
|
async cite(options) {
|
|
27354
|
-
const { citeReferences } = await import("./index-
|
|
27354
|
+
const { citeReferences } = await import("./index-vL26PhAf.js").then((n) => n.b);
|
|
27355
27355
|
return citeReferences(this.library, options);
|
|
27356
27356
|
}
|
|
27357
27357
|
async import(inputs, options) {
|
|
27358
|
-
const { addReferences } = await import("./index-
|
|
27358
|
+
const { addReferences } = await import("./index-vL26PhAf.js").then((n) => n.a);
|
|
27359
27359
|
return addReferences(inputs, this.library, options ?? {});
|
|
27360
27360
|
}
|
|
27361
27361
|
}
|
|
@@ -27867,7 +27867,7 @@ async function mcpStart(options) {
|
|
|
27867
27867
|
async function executeRemove(options, context) {
|
|
27868
27868
|
const { identifier, idType = "id", fulltextDirectory, deleteFulltext = false } = options;
|
|
27869
27869
|
if (context.mode === "local" && deleteFulltext && fulltextDirectory) {
|
|
27870
|
-
const { removeReference } = await import("./index-
|
|
27870
|
+
const { removeReference } = await import("./index-vL26PhAf.js").then((n) => n.r);
|
|
27871
27871
|
return removeReference(context.library, {
|
|
27872
27872
|
identifier,
|
|
27873
27873
|
idType,
|
|
@@ -27996,7 +27996,7 @@ async function executeInteractiveSearch(options, context, config2) {
|
|
|
27996
27996
|
validateInteractiveOptions(options);
|
|
27997
27997
|
const { checkTTY } = await import("./tty-CDBIQraQ.js");
|
|
27998
27998
|
const { runSearchPrompt } = await import("./search-prompt-RtHDJFgL.js");
|
|
27999
|
-
const { runActionMenu } = await import("./action-menu-
|
|
27999
|
+
const { runActionMenu } = await import("./action-menu-wjKl5_b6.js");
|
|
28000
28000
|
const { search } = await import("./file-watcher-BhIAeC21.js").then((n) => n.y);
|
|
28001
28001
|
const { tokenize } = await import("./file-watcher-BhIAeC21.js").then((n) => n.x);
|
|
28002
28002
|
checkTTY();
|
|
@@ -28958,10 +28958,6 @@ function buildAddOptions(inputs, options, config2, stdinContent) {
|
|
|
28958
28958
|
return addOptions;
|
|
28959
28959
|
}
|
|
28960
28960
|
async function outputAddResultJson(result, context, full) {
|
|
28961
|
-
const sources = /* @__PURE__ */ new Map();
|
|
28962
|
-
for (const item of result.added) {
|
|
28963
|
-
sources.set(item.id, "");
|
|
28964
|
-
}
|
|
28965
28961
|
const items2 = /* @__PURE__ */ new Map();
|
|
28966
28962
|
if (full) {
|
|
28967
28963
|
for (const added of result.added) {
|
|
@@ -28971,7 +28967,7 @@ async function outputAddResultJson(result, context, full) {
|
|
|
28971
28967
|
}
|
|
28972
28968
|
}
|
|
28973
28969
|
}
|
|
28974
|
-
const options = { full,
|
|
28970
|
+
const options = { full, items: items2 };
|
|
28975
28971
|
const jsonOutput = formatAddJsonOutput(result, options);
|
|
28976
28972
|
process.stdout.write(`${JSON.stringify(jsonOutput)}
|
|
28977
28973
|
`);
|
|
@@ -29532,4 +29528,4 @@ export {
|
|
|
29532
29528
|
formatBibtex as f,
|
|
29533
29529
|
main as m
|
|
29534
29530
|
};
|
|
29535
|
-
//# sourceMappingURL=index-
|
|
29531
|
+
//# sourceMappingURL=index-uiCqx7-V.js.map
|