@ncukondo/reference-manager 0.5.1 → 0.5.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/README.md +6 -1
- package/dist/chunks/{file-watcher-Dqkw6R7-.js → file-watcher-CBAbblss.js} +120 -19
- package/dist/chunks/file-watcher-CBAbblss.js.map +1 -0
- package/dist/chunks/index-Bl_mOQRe.js +1657 -0
- package/dist/chunks/index-Bl_mOQRe.js.map +1 -0
- package/dist/cli/commands/fulltext.d.ts +4 -3
- package/dist/cli/commands/fulltext.d.ts.map +1 -1
- package/dist/cli/commands/remove.d.ts +2 -1
- package/dist/cli/commands/remove.d.ts.map +1 -1
- package/dist/cli/commands/update.d.ts +2 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/server-client.d.ts +5 -4
- package/dist/cli/server-client.d.ts.map +1 -1
- package/dist/cli.js +49 -42
- package/dist/cli.js.map +1 -1
- package/dist/core/library-interface.d.ts +22 -4
- package/dist/core/library-interface.d.ts.map +1 -1
- package/dist/core/library.d.ts +2 -10
- package/dist/core/library.d.ts.map +1 -1
- package/dist/core/reference.d.ts +1 -0
- package/dist/core/reference.d.ts.map +1 -1
- package/dist/features/duplicate/detector.d.ts.map +1 -1
- package/dist/features/duplicate/types.d.ts +2 -1
- package/dist/features/duplicate/types.d.ts.map +1 -1
- package/dist/features/import/cache.d.ts +8 -0
- package/dist/features/import/cache.d.ts.map +1 -1
- package/dist/features/import/detector.d.ts +11 -3
- package/dist/features/import/detector.d.ts.map +1 -1
- package/dist/features/import/fetcher.d.ts +8 -0
- package/dist/features/import/fetcher.d.ts.map +1 -1
- package/dist/features/import/importer.d.ts.map +1 -1
- package/dist/features/import/normalizer.d.ts +26 -0
- package/dist/features/import/normalizer.d.ts.map +1 -1
- package/dist/features/import/rate-limiter.d.ts +1 -1
- package/dist/features/import/rate-limiter.d.ts.map +1 -1
- package/dist/features/operations/cite.d.ts +3 -3
- package/dist/features/operations/cite.d.ts.map +1 -1
- package/dist/features/operations/fulltext/attach.d.ts +3 -3
- package/dist/features/operations/fulltext/attach.d.ts.map +1 -1
- package/dist/features/operations/fulltext/detach.d.ts +3 -3
- package/dist/features/operations/fulltext/detach.d.ts.map +1 -1
- package/dist/features/operations/fulltext/get.d.ts +3 -3
- package/dist/features/operations/fulltext/get.d.ts.map +1 -1
- package/dist/features/operations/remove.d.ts +3 -3
- package/dist/features/operations/remove.d.ts.map +1 -1
- package/dist/features/operations/update.d.ts +3 -3
- package/dist/features/operations/update.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/server/routes/references.d.ts.map +1 -1
- package/dist/server.js +2 -2
- package/package.json +2 -1
- package/dist/chunks/file-watcher-Dqkw6R7-.js.map +0 -1
- package/dist/chunks/index-9dyK2f9_.js +0 -29851
- package/dist/chunks/index-9dyK2f9_.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { ZodOptional as ZodOptional$2, z } from "zod";
|
|
3
|
-
import { L as Library, F as FileWatcher } from "./chunks/file-watcher-
|
|
3
|
+
import { L as Library, F as FileWatcher } from "./chunks/file-watcher-CBAbblss.js";
|
|
4
4
|
import { promises, existsSync, mkdtempSync, writeFileSync, readFileSync } from "node:fs";
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { join, extname } from "node:path";
|
|
9
9
|
import { mkdir, unlink, rename, copyFile, rm, readFile } from "node:fs/promises";
|
|
10
|
-
import { u as updateReference,
|
|
10
|
+
import { u as updateReference, B as BUILTIN_STYLES, a as addReferences, c as citeReferences, l as listReferences, r as removeReference, s as searchReferences, b as startServerWithFileWatcher } from "./chunks/index-Bl_mOQRe.js";
|
|
11
11
|
import process$1, { stdin, stdout } from "node:process";
|
|
12
12
|
import { l as loadConfig } from "./chunks/loader-DuzyKV70.js";
|
|
13
13
|
import { spawn } from "node:child_process";
|
|
14
14
|
import { serve } from "@hono/node-server";
|
|
15
15
|
const name = "@ncukondo/reference-manager";
|
|
16
|
-
const version$1 = "0.5.
|
|
16
|
+
const version$1 = "0.5.3";
|
|
17
17
|
const description$1 = "A local reference management tool using CSL-JSON as the single source of truth";
|
|
18
18
|
const packageJson = {
|
|
19
19
|
name,
|
|
@@ -163,7 +163,7 @@ async function validateOptions$2(options) {
|
|
|
163
163
|
function buildCiteOptions(options) {
|
|
164
164
|
return {
|
|
165
165
|
identifiers: options.identifiers,
|
|
166
|
-
...options.uuid
|
|
166
|
+
...options.uuid && { idType: "uuid" },
|
|
167
167
|
...options.style !== void 0 && { style: options.style },
|
|
168
168
|
...options.cslFile !== void 0 && { cslFile: options.cslFile },
|
|
169
169
|
...options.locale !== void 0 && { locale: options.locale },
|
|
@@ -451,11 +451,11 @@ async function fulltextAttach(library, options) {
|
|
|
451
451
|
type: explicitType,
|
|
452
452
|
move,
|
|
453
453
|
force,
|
|
454
|
-
|
|
454
|
+
idType = "id",
|
|
455
455
|
fulltextDirectory,
|
|
456
456
|
stdinContent
|
|
457
457
|
} = options;
|
|
458
|
-
const item = await library.find(identifier, {
|
|
458
|
+
const item = await library.find(identifier, { idType });
|
|
459
459
|
if (!item) {
|
|
460
460
|
return { success: false, error: `Reference '${identifier}' not found` };
|
|
461
461
|
}
|
|
@@ -482,7 +482,7 @@ async function fulltextAttach(library, options) {
|
|
|
482
482
|
updates: {
|
|
483
483
|
custom: { fulltext: newFulltext }
|
|
484
484
|
},
|
|
485
|
-
|
|
485
|
+
idType
|
|
486
486
|
});
|
|
487
487
|
await cleanupTempDir(tempDir);
|
|
488
488
|
return {
|
|
@@ -528,8 +528,8 @@ function getFilePaths(manager, item, types2, identifier) {
|
|
|
528
528
|
return { success: true, paths };
|
|
529
529
|
}
|
|
530
530
|
async function fulltextGet(library, options) {
|
|
531
|
-
const { identifier, type: type2, stdout: stdout2,
|
|
532
|
-
const item = await library.find(identifier, {
|
|
531
|
+
const { identifier, type: type2, stdout: stdout2, idType = "id", fulltextDirectory } = options;
|
|
532
|
+
const item = await library.find(identifier, { idType });
|
|
533
533
|
if (!item) {
|
|
534
534
|
return { success: false, error: `Reference '${identifier}' not found` };
|
|
535
535
|
}
|
|
@@ -573,8 +573,8 @@ function handleDetachError(error) {
|
|
|
573
573
|
throw error;
|
|
574
574
|
}
|
|
575
575
|
async function fulltextDetach(library, options) {
|
|
576
|
-
const { identifier, type: type2, delete: deleteFile,
|
|
577
|
-
const item = await library.find(identifier, {
|
|
576
|
+
const { identifier, type: type2, delete: deleteFile, idType = "id", fulltextDirectory } = options;
|
|
577
|
+
const item = await library.find(identifier, { idType });
|
|
578
578
|
if (!item) {
|
|
579
579
|
return { success: false, error: `Reference '${identifier}' not found` };
|
|
580
580
|
}
|
|
@@ -596,7 +596,7 @@ async function fulltextDetach(library, options) {
|
|
|
596
596
|
updates: {
|
|
597
597
|
custom: { fulltext: updatedFulltext }
|
|
598
598
|
},
|
|
599
|
-
|
|
599
|
+
idType
|
|
600
600
|
});
|
|
601
601
|
const resultData = { success: true, detached };
|
|
602
602
|
if (deleted.length > 0) {
|
|
@@ -614,7 +614,7 @@ async function executeFulltextAttach(options, context) {
|
|
|
614
614
|
type: options.type,
|
|
615
615
|
move: options.move,
|
|
616
616
|
force: options.force,
|
|
617
|
-
|
|
617
|
+
idType: options.idType,
|
|
618
618
|
fulltextDirectory: options.fulltextDirectory,
|
|
619
619
|
stdinContent: options.stdinContent
|
|
620
620
|
};
|
|
@@ -625,7 +625,7 @@ async function executeFulltextGet(options, context) {
|
|
|
625
625
|
identifier: options.identifier,
|
|
626
626
|
type: options.type,
|
|
627
627
|
stdout: options.stdout,
|
|
628
|
-
|
|
628
|
+
idType: options.idType,
|
|
629
629
|
fulltextDirectory: options.fulltextDirectory
|
|
630
630
|
};
|
|
631
631
|
return fulltextGet(context.library, operationOptions);
|
|
@@ -635,7 +635,7 @@ async function executeFulltextDetach(options, context) {
|
|
|
635
635
|
identifier: options.identifier,
|
|
636
636
|
type: options.type,
|
|
637
637
|
delete: options.delete,
|
|
638
|
-
|
|
638
|
+
idType: options.idType,
|
|
639
639
|
fulltextDirectory: options.fulltextDirectory
|
|
640
640
|
};
|
|
641
641
|
return fulltextDetach(context.library, operationOptions);
|
|
@@ -12494,6 +12494,9 @@ function mergeCapabilities(base, additional) {
|
|
|
12494
12494
|
}
|
|
12495
12495
|
return result;
|
|
12496
12496
|
}
|
|
12497
|
+
function getDefaultExportFromCjs(x) {
|
|
12498
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
12499
|
+
}
|
|
12497
12500
|
var ajv = { exports: {} };
|
|
12498
12501
|
var core$1 = {};
|
|
12499
12502
|
var validate = {};
|
|
@@ -21330,8 +21333,8 @@ async function mcpStart(options) {
|
|
|
21330
21333
|
return result;
|
|
21331
21334
|
}
|
|
21332
21335
|
async function executeRemove(options, context) {
|
|
21333
|
-
const { identifier,
|
|
21334
|
-
return context.library.remove(identifier, {
|
|
21336
|
+
const { identifier, idType = "id" } = options;
|
|
21337
|
+
return context.library.remove(identifier, { idType });
|
|
21335
21338
|
}
|
|
21336
21339
|
function formatRemoveOutput(result, identifier) {
|
|
21337
21340
|
if (!result.removed) {
|
|
@@ -21491,8 +21494,8 @@ async function serverStatus(portfilePath) {
|
|
|
21491
21494
|
return result;
|
|
21492
21495
|
}
|
|
21493
21496
|
async function executeUpdate(options, context) {
|
|
21494
|
-
const { identifier, updates,
|
|
21495
|
-
return context.library.update(identifier, updates, {
|
|
21497
|
+
const { identifier, updates, idType = "id" } = options;
|
|
21498
|
+
return context.library.update(identifier, updates, { idType });
|
|
21496
21499
|
}
|
|
21497
21500
|
function formatUpdateOutput(result, identifier) {
|
|
21498
21501
|
if (!result.updated) {
|
|
@@ -21538,19 +21541,19 @@ class OperationsLibrary {
|
|
|
21538
21541
|
}
|
|
21539
21542
|
// High-level operations
|
|
21540
21543
|
async search(options) {
|
|
21541
|
-
const { searchReferences: searchReferences2 } = await import("./chunks/index-
|
|
21544
|
+
const { searchReferences: searchReferences2 } = await import("./chunks/index-Bl_mOQRe.js").then((n) => n.h);
|
|
21542
21545
|
return searchReferences2(this.library, options);
|
|
21543
21546
|
}
|
|
21544
21547
|
async list(options) {
|
|
21545
|
-
const { listReferences: listReferences2 } = await import("./chunks/index-
|
|
21548
|
+
const { listReferences: listReferences2 } = await import("./chunks/index-Bl_mOQRe.js").then((n) => n.g);
|
|
21546
21549
|
return listReferences2(this.library, options ?? {});
|
|
21547
21550
|
}
|
|
21548
21551
|
async cite(options) {
|
|
21549
|
-
const { citeReferences: citeReferences2 } = await import("./chunks/index-
|
|
21552
|
+
const { citeReferences: citeReferences2 } = await import("./chunks/index-Bl_mOQRe.js").then((n) => n.f);
|
|
21550
21553
|
return citeReferences2(this.library, options);
|
|
21551
21554
|
}
|
|
21552
21555
|
async import(inputs, options) {
|
|
21553
|
-
const { addReferences: addReferences2 } = await import("./chunks/index-
|
|
21556
|
+
const { addReferences: addReferences2 } = await import("./chunks/index-Bl_mOQRe.js").then((n) => n.e);
|
|
21554
21557
|
return addReferences2(inputs, this.library, options ?? {});
|
|
21555
21558
|
}
|
|
21556
21559
|
}
|
|
@@ -21576,12 +21579,12 @@ class ServerClient {
|
|
|
21576
21579
|
/**
|
|
21577
21580
|
* Find reference by citation ID or UUID.
|
|
21578
21581
|
* @param identifier - Citation ID or UUID
|
|
21579
|
-
* @param options - Find options (
|
|
21582
|
+
* @param options - Find options (idType to specify identifier type)
|
|
21580
21583
|
* @returns CSL item or undefined if not found
|
|
21581
21584
|
*/
|
|
21582
21585
|
async find(identifier, options = {}) {
|
|
21583
|
-
const {
|
|
21584
|
-
const url =
|
|
21586
|
+
const { idType = "id" } = options;
|
|
21587
|
+
const url = idType === "uuid" ? `${this.baseUrl}/api/references/uuid/${encodeURIComponent(identifier)}` : `${this.baseUrl}/api/references/id/${encodeURIComponent(identifier)}`;
|
|
21585
21588
|
const response = await fetch(url);
|
|
21586
21589
|
if (response.status === 404) {
|
|
21587
21590
|
return void 0;
|
|
@@ -21615,12 +21618,12 @@ class ServerClient {
|
|
|
21615
21618
|
* Update reference by citation ID or UUID.
|
|
21616
21619
|
* @param identifier - Citation ID or UUID
|
|
21617
21620
|
* @param updates - Partial CSL item with fields to update
|
|
21618
|
-
* @param options - Update options (
|
|
21621
|
+
* @param options - Update options (idType to specify identifier type, onIdCollision for collision handling)
|
|
21619
21622
|
* @returns Update result with updated item, success status, and any ID changes
|
|
21620
21623
|
*/
|
|
21621
21624
|
async update(identifier, updates, options) {
|
|
21622
|
-
const {
|
|
21623
|
-
const url =
|
|
21625
|
+
const { idType = "id", onIdCollision } = options ?? {};
|
|
21626
|
+
const url = idType === "uuid" ? `${this.baseUrl}/api/references/uuid/${encodeURIComponent(identifier)}` : `${this.baseUrl}/api/references/id/${encodeURIComponent(identifier)}`;
|
|
21624
21627
|
const response = await fetch(url, {
|
|
21625
21628
|
method: "PUT",
|
|
21626
21629
|
headers: { "Content-Type": "application/json" },
|
|
@@ -21640,12 +21643,12 @@ class ServerClient {
|
|
|
21640
21643
|
/**
|
|
21641
21644
|
* Remove a reference by citation ID or UUID.
|
|
21642
21645
|
* @param identifier - The citation ID or UUID of the reference to remove
|
|
21643
|
-
* @param options - Remove options (
|
|
21646
|
+
* @param options - Remove options (idType to specify identifier type)
|
|
21644
21647
|
* @returns Remove result with removed status and removedItem
|
|
21645
21648
|
*/
|
|
21646
21649
|
async remove(identifier, options = {}) {
|
|
21647
|
-
const {
|
|
21648
|
-
const url =
|
|
21650
|
+
const { idType = "id" } = options;
|
|
21651
|
+
const url = idType === "uuid" ? `${this.baseUrl}/api/references/uuid/${encodeURIComponent(identifier)}` : `${this.baseUrl}/api/references/id/${encodeURIComponent(identifier)}`;
|
|
21649
21652
|
const response = await fetch(url, {
|
|
21650
21653
|
method: "DELETE"
|
|
21651
21654
|
});
|
|
@@ -21987,12 +21990,16 @@ async function handleAddAction(inputs, options, program) {
|
|
|
21987
21990
|
}
|
|
21988
21991
|
}
|
|
21989
21992
|
function registerAddCommand(program) {
|
|
21990
|
-
program.command("add").description("Add new reference(s) to the library").argument("[input...]", "File paths or identifiers (PMID/DOI), or use stdin").option("-f, --force", "Skip duplicate detection").option(
|
|
21993
|
+
program.command("add").description("Add new reference(s) to the library").argument("[input...]", "File paths or identifiers (PMID/DOI/ISBN), or use stdin").option("-f, --force", "Skip duplicate detection").option(
|
|
21994
|
+
"--format <format>",
|
|
21995
|
+
"Explicit input format: json|bibtex|ris|pmid|doi|isbn|auto",
|
|
21996
|
+
"auto"
|
|
21997
|
+
).option("--verbose", "Show detailed error information").action(async (inputs, options) => {
|
|
21991
21998
|
await handleAddAction(inputs, options, program);
|
|
21992
21999
|
});
|
|
21993
22000
|
}
|
|
21994
|
-
async function findReferenceToRemove(identifier,
|
|
21995
|
-
return context.library.find(identifier, {
|
|
22001
|
+
async function findReferenceToRemove(identifier, useUuid, context) {
|
|
22002
|
+
return context.library.find(identifier, { idType: useUuid ? "uuid" : "id" });
|
|
21996
22003
|
}
|
|
21997
22004
|
async function confirmRemoval(refToRemove, force, fulltextWarning) {
|
|
21998
22005
|
if (force || !isTTY()) {
|
|
@@ -22060,8 +22067,8 @@ async function handleRemoveAction(identifier, options, program) {
|
|
|
22060
22067
|
const removeOptions = {
|
|
22061
22068
|
identifier
|
|
22062
22069
|
};
|
|
22063
|
-
if (options.uuid
|
|
22064
|
-
removeOptions.
|
|
22070
|
+
if (options.uuid) {
|
|
22071
|
+
removeOptions.idType = "uuid";
|
|
22065
22072
|
}
|
|
22066
22073
|
const result = await executeRemove(removeOptions, context);
|
|
22067
22074
|
const output = formatRemoveOutput(result, identifier);
|
|
@@ -22115,8 +22122,8 @@ async function handleUpdateAction(identifier, file, options, program) {
|
|
|
22115
22122
|
identifier,
|
|
22116
22123
|
updates: validatedUpdates
|
|
22117
22124
|
};
|
|
22118
|
-
if (options.uuid
|
|
22119
|
-
updateOptions.
|
|
22125
|
+
if (options.uuid) {
|
|
22126
|
+
updateOptions.idType = "uuid";
|
|
22120
22127
|
}
|
|
22121
22128
|
const result = await executeUpdate(updateOptions, context);
|
|
22122
22129
|
const output = formatUpdateOutput(result, identifier);
|
|
@@ -22296,7 +22303,7 @@ async function handleFulltextAttachAction(identifier, filePathArg, options, prog
|
|
|
22296
22303
|
...type2 && { type: type2 },
|
|
22297
22304
|
...options.move && { move: options.move },
|
|
22298
22305
|
...options.force && { force: options.force },
|
|
22299
|
-
...options.uuid && {
|
|
22306
|
+
...options.uuid && { idType: "uuid" },
|
|
22300
22307
|
...stdinContent && { stdinContent }
|
|
22301
22308
|
};
|
|
22302
22309
|
const result = await executeFulltextAttach(attachOptions, context);
|
|
@@ -22321,7 +22328,7 @@ async function handleFulltextGetAction(identifier, options, program) {
|
|
|
22321
22328
|
...options.pdf && { type: "pdf" },
|
|
22322
22329
|
...options.markdown && { type: "markdown" },
|
|
22323
22330
|
...options.stdout && { stdout: options.stdout },
|
|
22324
|
-
...options.uuid && {
|
|
22331
|
+
...options.uuid && { idType: "uuid" }
|
|
22325
22332
|
};
|
|
22326
22333
|
const result = await executeFulltextGet(getOptions, context);
|
|
22327
22334
|
if (result.success && result.content && options.stdout) {
|
|
@@ -22355,7 +22362,7 @@ async function handleFulltextDetachAction(identifier, options, program) {
|
|
|
22355
22362
|
...options.markdown && { type: "markdown" },
|
|
22356
22363
|
...options.delete && { delete: options.delete },
|
|
22357
22364
|
...options.force && { force: options.force },
|
|
22358
|
-
...options.uuid && {
|
|
22365
|
+
...options.uuid && { idType: "uuid" }
|
|
22359
22366
|
};
|
|
22360
22367
|
const result = await executeFulltextDetach(detachOptions, context);
|
|
22361
22368
|
const output = formatFulltextDetachOutput(result);
|