@ncukondo/reference-manager 0.15.3 → 0.16.0

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.
Files changed (62) hide show
  1. package/dist/chunks/alternate-screen-DcxkOKfW.js +19 -0
  2. package/dist/chunks/alternate-screen-DcxkOKfW.js.map +1 -0
  3. package/dist/chunks/format-C6FA-7hE.js +397 -0
  4. package/dist/chunks/format-C6FA-7hE.js.map +1 -0
  5. package/dist/chunks/{index-TKhWlXl1.js → index-4SVOiraD.js} +104 -76
  6. package/dist/chunks/index-4SVOiraD.js.map +1 -0
  7. package/dist/chunks/{index-DVFYLuQx.js → index-Bzl4_3Ki.js} +2 -2
  8. package/dist/chunks/index-Bzl4_3Ki.js.map +1 -0
  9. package/dist/chunks/index-CEYp8OSj.js +531 -0
  10. package/dist/chunks/index-CEYp8OSj.js.map +1 -0
  11. package/dist/chunks/jsx-runtime-Q5cUjSur.js +322 -0
  12. package/dist/chunks/jsx-runtime-Q5cUjSur.js.map +1 -0
  13. package/dist/chunks/reference-select-CgM-RBIa.js +214 -0
  14. package/dist/chunks/reference-select-CgM-RBIa.js.map +1 -0
  15. package/dist/chunks/{style-select-BNQHC79W.js → style-select-tmKOHx_B.js} +6 -31
  16. package/dist/chunks/style-select-tmKOHx_B.js.map +1 -0
  17. package/dist/cli/commands/attach.d.ts.map +1 -1
  18. package/dist/cli/commands/cite.d.ts.map +1 -1
  19. package/dist/cli/commands/edit.d.ts.map +1 -1
  20. package/dist/cli/commands/fulltext.d.ts.map +1 -1
  21. package/dist/cli/commands/remove.d.ts.map +1 -1
  22. package/dist/cli/commands/search.d.ts +1 -1
  23. package/dist/cli/commands/search.d.ts.map +1 -1
  24. package/dist/cli/commands/update.d.ts.map +1 -1
  25. package/dist/cli/helpers.d.ts.map +1 -1
  26. package/dist/cli/index.d.ts.map +1 -1
  27. package/dist/cli.js +1 -1
  28. package/dist/features/interactive/action-menu.d.ts +10 -12
  29. package/dist/features/interactive/action-menu.d.ts.map +1 -1
  30. package/dist/features/interactive/alternate-screen.d.ts +42 -0
  31. package/dist/features/interactive/alternate-screen.d.ts.map +1 -0
  32. package/dist/features/interactive/apps/CiteFlowApp.d.ts +52 -0
  33. package/dist/features/interactive/apps/CiteFlowApp.d.ts.map +1 -0
  34. package/dist/features/interactive/apps/SearchFlowApp.d.ts +34 -0
  35. package/dist/features/interactive/apps/SearchFlowApp.d.ts.map +1 -0
  36. package/dist/features/interactive/apps/index.d.ts +11 -0
  37. package/dist/features/interactive/apps/index.d.ts.map +1 -0
  38. package/dist/features/interactive/apps/runCiteFlow.d.ts +42 -0
  39. package/dist/features/interactive/apps/runCiteFlow.d.ts.map +1 -0
  40. package/dist/features/interactive/apps/runSearchFlow.d.ts +28 -0
  41. package/dist/features/interactive/apps/runSearchFlow.d.ts.map +1 -0
  42. package/dist/features/interactive/components/SearchableMultiSelect.d.ts +49 -0
  43. package/dist/features/interactive/components/SearchableMultiSelect.d.ts.map +1 -0
  44. package/dist/features/interactive/components/Select.d.ts +26 -0
  45. package/dist/features/interactive/components/Select.d.ts.map +1 -0
  46. package/dist/features/interactive/components/index.d.ts +8 -0
  47. package/dist/features/interactive/components/index.d.ts.map +1 -0
  48. package/dist/features/interactive/search-prompt.d.ts +15 -12
  49. package/dist/features/interactive/search-prompt.d.ts.map +1 -1
  50. package/dist/features/interactive/style-select.d.ts +3 -11
  51. package/dist/features/interactive/style-select.d.ts.map +1 -1
  52. package/package.json +7 -4
  53. package/dist/chunks/action-menu-yzuB0WT3.js +0 -119
  54. package/dist/chunks/action-menu-yzuB0WT3.js.map +0 -1
  55. package/dist/chunks/index-DVFYLuQx.js.map +0 -1
  56. package/dist/chunks/index-TKhWlXl1.js.map +0 -1
  57. package/dist/chunks/reference-select-B9w9CLa1.js +0 -52
  58. package/dist/chunks/reference-select-B9w9CLa1.js.map +0 -1
  59. package/dist/chunks/search-prompt-BrWpOcij.js +0 -265
  60. package/dist/chunks/search-prompt-BrWpOcij.js.map +0 -1
  61. package/dist/chunks/style-select-BNQHC79W.js.map +0 -1
  62. /package/bin/{reference-manager.js → cli.js} +0 -0
@@ -11,13 +11,14 @@ import { g as getExtension, i as isValidFulltextFiles, a as isReservedRole, F as
11
11
  import { o as openWithSystemApp, l as loadConfig, e as getDefaultCurrentDirConfigFilename, h as getDefaultUserConfigPath } from "./loader-DuhmXjiI.js";
12
12
  import { spawn, spawnSync } from "node:child_process";
13
13
  import process$1, { stdin, stdout } from "node:process";
14
+ import * as readline from "node:readline";
14
15
  import { parse as parse$2, stringify as stringify$2 } from "@iarna/toml";
15
16
  import "@citation-js/core";
16
17
  import "@citation-js/plugin-csl";
17
18
  import { ZodOptional as ZodOptional$2, z } from "zod";
18
19
  import { serve } from "@hono/node-server";
19
20
  const name = "@ncukondo/reference-manager";
20
- const version$1 = "0.15.3";
21
+ const version$1 = "0.16.0";
21
22
  const description$1 = "A local reference management tool using CSL-JSON as the single source of truth";
22
23
  const packageJson = {
23
24
  name,
@@ -903,27 +904,27 @@ class OperationsLibrary {
903
904
  }
904
905
  // Attachment operations
905
906
  async attachAdd(options) {
906
- const { addAttachment: addAttachment2 } = await import("./index-DVFYLuQx.js");
907
+ const { addAttachment: addAttachment2 } = await import("./index-Bzl4_3Ki.js");
907
908
  return addAttachment2(this.library, options);
908
909
  }
909
910
  async attachList(options) {
910
- const { listAttachments: listAttachments2 } = await import("./index-DVFYLuQx.js");
911
+ const { listAttachments: listAttachments2 } = await import("./index-Bzl4_3Ki.js");
911
912
  return listAttachments2(this.library, options);
912
913
  }
913
914
  async attachGet(options) {
914
- const { getAttachment: getAttachment2 } = await import("./index-DVFYLuQx.js");
915
+ const { getAttachment: getAttachment2 } = await import("./index-Bzl4_3Ki.js");
915
916
  return getAttachment2(this.library, options);
916
917
  }
917
918
  async attachDetach(options) {
918
- const { detachAttachment: detachAttachment2 } = await import("./index-DVFYLuQx.js");
919
+ const { detachAttachment: detachAttachment2 } = await import("./index-Bzl4_3Ki.js");
919
920
  return detachAttachment2(this.library, options);
920
921
  }
921
922
  async attachSync(options) {
922
- const { syncAttachments: syncAttachments2 } = await import("./index-DVFYLuQx.js");
923
+ const { syncAttachments: syncAttachments2 } = await import("./index-Bzl4_3Ki.js");
923
924
  return syncAttachments2(this.library, options);
924
925
  }
925
926
  async attachOpen(options) {
926
- const { openAttachment: openAttachment2 } = await import("./index-DVFYLuQx.js");
927
+ const { openAttachment: openAttachment2 } = await import("./index-Bzl4_3Ki.js");
927
928
  return openAttachment2(this.library, options);
928
929
  }
929
930
  }
@@ -1348,18 +1349,32 @@ async function readConfirmation(prompt) {
1348
1349
  if (!isTTY()) {
1349
1350
  return true;
1350
1351
  }
1351
- const enquirer = await import("enquirer");
1352
- const Confirm = enquirer.default.Confirm;
1353
- const confirmPrompt = new Confirm({
1354
- name: "confirm",
1355
- message: prompt,
1356
- initial: false
1357
- });
1358
- try {
1359
- return await confirmPrompt.run();
1360
- } catch {
1361
- return false;
1352
+ if (process.stdin.isTTY && process.stdin.isRaw) {
1353
+ process.stdin.setRawMode(false);
1362
1354
  }
1355
+ process.stdin.resume();
1356
+ process.stdin.ref();
1357
+ const rl = readline.createInterface({
1358
+ input: process.stdin,
1359
+ output: process.stderr
1360
+ });
1361
+ return new Promise((resolve2) => {
1362
+ let resolved = false;
1363
+ rl.question(`${prompt} (y/N) `, (answer) => {
1364
+ if (!resolved) {
1365
+ resolved = true;
1366
+ rl.close();
1367
+ const normalized = answer.trim().toLowerCase();
1368
+ resolve2(normalized === "y" || normalized === "yes");
1369
+ }
1370
+ });
1371
+ rl.on("close", () => {
1372
+ if (!resolved) {
1373
+ resolved = true;
1374
+ resolve2(false);
1375
+ }
1376
+ });
1377
+ });
1363
1378
  }
1364
1379
  async function readStdinContent() {
1365
1380
  const chunks = [];
@@ -1590,12 +1605,11 @@ function getAttachExitCode(result) {
1590
1605
  return result.success ? 0 : 1;
1591
1606
  }
1592
1607
  async function executeInteractiveSelect$1(context, config2) {
1593
- const { selectReferencesOrExit } = await import("./reference-select-B9w9CLa1.js");
1608
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
1609
+ const { selectReferencesOrExit } = await import("./reference-select-CgM-RBIa.js");
1594
1610
  const allReferences = await context.library.getAll();
1595
- const identifiers = await selectReferencesOrExit(
1596
- allReferences,
1597
- { multiSelect: false },
1598
- config2.cli.tui
1611
+ const identifiers = await withAlternateScreen(
1612
+ () => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
1599
1613
  );
1600
1614
  return identifiers[0];
1601
1615
  }
@@ -1964,27 +1978,44 @@ function getCiteExitCode(result) {
1964
1978
  return 0;
1965
1979
  }
1966
1980
  async function executeInteractiveCite(options, context, config2) {
1967
- const { selectReferencesOrExit } = await import("./reference-select-B9w9CLa1.js");
1968
- const { runStyleSelect } = await import("./style-select-BNQHC79W.js");
1981
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
1982
+ const { runCiteFlow } = await import("./index-CEYp8OSj.js");
1983
+ const { buildStyleChoices, listCustomStyles } = await import("./style-select-tmKOHx_B.js");
1984
+ const { search } = await import("./file-watcher-B_WpVHSV.js").then((n) => n.y);
1985
+ const { tokenize } = await import("./file-watcher-B_WpVHSV.js").then((n) => n.x);
1986
+ const { checkTTY } = await import("./tty-BMyaEOhX.js");
1987
+ checkTTY();
1969
1988
  const allReferences = await context.library.getAll();
1970
- const identifiers = await selectReferencesOrExit(
1971
- allReferences,
1972
- { multiSelect: true },
1973
- config2.cli.tui
1989
+ if (allReferences.length === 0) {
1990
+ process.stderr.write("No references in library.\n");
1991
+ setExitCode(ExitCode.SUCCESS);
1992
+ return { results: [] };
1993
+ }
1994
+ const searchFn = (query) => {
1995
+ const { tokens } = tokenize(query);
1996
+ return search(allReferences, tokens);
1997
+ };
1998
+ const showStyleSelect = !options.style && !options.cslFile;
1999
+ const customStyles = listCustomStyles(config2.citation.cslDirectory);
2000
+ const styleOptions = buildStyleChoices(customStyles, config2.citation.defaultStyle);
2001
+ const result = await withAlternateScreen(
2002
+ () => runCiteFlow({
2003
+ allReferences,
2004
+ searchFn,
2005
+ config: { limit: config2.cli.tui.limit },
2006
+ styleOptions,
2007
+ showStyleSelect
2008
+ })
1974
2009
  );
1975
- let style = options.style;
1976
- if (!style && !options.cslFile) {
1977
- const styleResult = await runStyleSelect({
1978
- cslDirectory: config2.citation.cslDirectory,
1979
- defaultStyle: config2.citation.defaultStyle
1980
- });
1981
- if (styleResult.cancelled) {
1982
- setExitCode(ExitCode.SUCCESS);
1983
- return { results: [] };
1984
- }
1985
- style = styleResult.style;
2010
+ if (result.cancelled || result.identifiers.length === 0) {
2011
+ setExitCode(ExitCode.SUCCESS);
2012
+ return { results: [] };
1986
2013
  }
1987
- return executeCite({ ...options, ...style && { style }, identifiers }, context);
2014
+ const style = result.style ?? options.style;
2015
+ return executeCite(
2016
+ { ...options, ...style && { style }, identifiers: result.identifiers },
2017
+ context
2018
+ );
1988
2019
  }
1989
2020
  async function handleCiteAction(identifiers, options, globalOpts) {
1990
2021
  try {
@@ -5802,12 +5833,11 @@ function formatEditOutput(result) {
5802
5833
  return lines.join("\n");
5803
5834
  }
5804
5835
  async function executeInteractiveEdit(options, context, config2) {
5805
- const { selectReferencesOrExit } = await import("./reference-select-B9w9CLa1.js");
5836
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
5837
+ const { selectReferencesOrExit } = await import("./reference-select-CgM-RBIa.js");
5806
5838
  const allReferences = await context.library.getAll();
5807
- const identifiers = await selectReferencesOrExit(
5808
- allReferences,
5809
- { multiSelect: true },
5810
- config2.cli.tui
5839
+ const identifiers = await withAlternateScreen(
5840
+ () => selectReferencesOrExit(allReferences, { multiSelect: true }, config2.cli.tui)
5811
5841
  );
5812
5842
  const format2 = options.format ?? config2.cli.edit.defaultFormat;
5813
5843
  return executeEditCommand(
@@ -9451,12 +9481,11 @@ function getFulltextExitCode(result) {
9451
9481
  return result.success ? 0 : 1;
9452
9482
  }
9453
9483
  async function executeInteractiveSelect(context, config2) {
9454
- const { selectReferencesOrExit } = await import("./reference-select-B9w9CLa1.js");
9484
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
9485
+ const { selectReferencesOrExit } = await import("./reference-select-CgM-RBIa.js");
9455
9486
  const allReferences = await context.library.getAll();
9456
- const identifiers = await selectReferencesOrExit(
9457
- allReferences,
9458
- { multiSelect: false },
9459
- config2.cli.tui
9487
+ const identifiers = await withAlternateScreen(
9488
+ () => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
9460
9489
  );
9461
9490
  return identifiers[0];
9462
9491
  }
@@ -30514,12 +30543,11 @@ Continue?`;
30514
30543
  return readConfirmation(confirmMsg);
30515
30544
  }
30516
30545
  async function executeInteractiveRemove(context, config2) {
30517
- const { selectReferenceItemsOrExit } = await import("./reference-select-B9w9CLa1.js");
30546
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
30547
+ const { selectReferenceItemsOrExit } = await import("./reference-select-CgM-RBIa.js");
30518
30548
  const allReferences = await context.library.getAll();
30519
- const selectedItems = await selectReferenceItemsOrExit(
30520
- allReferences,
30521
- { multiSelect: false },
30522
- config2.cli.tui
30549
+ const selectedItems = await withAlternateScreen(
30550
+ () => selectReferenceItemsOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
30523
30551
  );
30524
30552
  const selectedItem = selectedItems[0];
30525
30553
  return { identifier: selectedItem.id, item: selectedItem };
@@ -30719,8 +30747,8 @@ function validateInteractiveOptions(options) {
30719
30747
  async function executeInteractiveSearch(options, context, config2) {
30720
30748
  validateInteractiveOptions(options);
30721
30749
  const { checkTTY } = await import("./tty-BMyaEOhX.js");
30722
- const { runSearchPrompt } = await import("./search-prompt-BrWpOcij.js");
30723
- const { runActionMenu } = await import("./action-menu-yzuB0WT3.js");
30750
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
30751
+ const { runSearchFlow } = await import("./index-CEYp8OSj.js");
30724
30752
  const { search } = await import("./file-watcher-B_WpVHSV.js").then((n) => n.y);
30725
30753
  const { tokenize } = await import("./file-watcher-B_WpVHSV.js").then((n) => n.x);
30726
30754
  checkTTY();
@@ -30730,22 +30758,15 @@ async function executeInteractiveSearch(options, context, config2) {
30730
30758
  return search(allReferences, tokens);
30731
30759
  };
30732
30760
  const tuiConfig = config2.cli.tui;
30733
- const searchResult = await runSearchPrompt(
30734
- allReferences,
30735
- searchFn,
30736
- {
30761
+ const result = await withAlternateScreen(
30762
+ () => runSearchFlow(allReferences, searchFn, {
30737
30763
  limit: tuiConfig.limit,
30738
30764
  debounceMs: tuiConfig.debounceMs
30739
- },
30740
- options.query || ""
30765
+ })
30741
30766
  );
30742
- if (searchResult.cancelled || searchResult.selected.length === 0) {
30743
- return { output: "", cancelled: true };
30744
- }
30745
- const actionResult = await runActionMenu(searchResult.selected);
30746
30767
  return {
30747
- output: actionResult.output,
30748
- cancelled: actionResult.cancelled
30768
+ output: result.output,
30769
+ cancelled: result.cancelled
30749
30770
  };
30750
30771
  }
30751
30772
  async function serverStart(options) {
@@ -31028,12 +31049,11 @@ function formatUpdateOutput(result, identifier) {
31028
31049
  return parts.join("\n");
31029
31050
  }
31030
31051
  async function executeInteractiveUpdate(context, config2) {
31031
- const { selectReferencesOrExit } = await import("./reference-select-B9w9CLa1.js");
31052
+ const { withAlternateScreen } = await import("./alternate-screen-DcxkOKfW.js");
31053
+ const { selectReferencesOrExit } = await import("./reference-select-CgM-RBIa.js");
31032
31054
  const allReferences = await context.library.getAll();
31033
- const identifiers = await selectReferencesOrExit(
31034
- allReferences,
31035
- { multiSelect: false },
31036
- config2.cli.tui
31055
+ const identifiers = await withAlternateScreen(
31056
+ () => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
31037
31057
  );
31038
31058
  return identifiers[0];
31039
31059
  }
@@ -31042,6 +31062,13 @@ async function resolveUpdateIdentifier(identifierArg, hasSetOptions, context, co
31042
31062
  return identifierArg;
31043
31063
  }
31044
31064
  if (isTTY()) {
31065
+ if (!hasSetOptions) {
31066
+ process.stderr.write(
31067
+ "Error: The update command requires --set options or a file argument.\nFor interactive editing, use: ref edit [id]\n"
31068
+ );
31069
+ setExitCode(ExitCode.ERROR);
31070
+ return "";
31071
+ }
31045
31072
  return executeInteractiveUpdate(context, config2);
31046
31073
  }
31047
31074
  if (hasSetOptions) {
@@ -31503,6 +31530,7 @@ async function handleSearchAction(query, options, program) {
31503
31530
  `);
31504
31531
  }
31505
31532
  setExitCode(ExitCode.SUCCESS);
31533
+ return;
31506
31534
  }
31507
31535
  const result = await executeSearch({ ...options, query }, context);
31508
31536
  const output = formatSearchOutput(result, { ...options, query });
@@ -31796,4 +31824,4 @@ export {
31796
31824
  openAttachment as o,
31797
31825
  syncAttachments as s
31798
31826
  };
31799
- //# sourceMappingURL=index-TKhWlXl1.js.map
31827
+ //# sourceMappingURL=index-4SVOiraD.js.map