@ncukondo/reference-manager 0.15.2 → 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.
- package/dist/chunks/alternate-screen-DcxkOKfW.js +19 -0
- package/dist/chunks/alternate-screen-DcxkOKfW.js.map +1 -0
- package/dist/chunks/format-C6FA-7hE.js +397 -0
- package/dist/chunks/format-C6FA-7hE.js.map +1 -0
- package/dist/chunks/{index-BIFsFHVj.js → index-4SVOiraD.js} +120 -81
- package/dist/chunks/index-4SVOiraD.js.map +1 -0
- package/dist/chunks/{index-C30Ouuee.js → index-Bzl4_3Ki.js} +2 -2
- package/dist/chunks/index-Bzl4_3Ki.js.map +1 -0
- package/dist/chunks/index-CEYp8OSj.js +531 -0
- package/dist/chunks/index-CEYp8OSj.js.map +1 -0
- package/dist/chunks/jsx-runtime-Q5cUjSur.js +322 -0
- package/dist/chunks/jsx-runtime-Q5cUjSur.js.map +1 -0
- package/dist/chunks/{loader-DStZe-OB.js → loader-DuhmXjiI.js} +8 -1
- package/dist/chunks/loader-DuhmXjiI.js.map +1 -0
- package/dist/chunks/reference-select-CgM-RBIa.js +214 -0
- package/dist/chunks/reference-select-CgM-RBIa.js.map +1 -0
- package/dist/chunks/{style-select-BNQHC79W.js → style-select-tmKOHx_B.js} +6 -31
- package/dist/chunks/style-select-tmKOHx_B.js.map +1 -0
- package/dist/cli/commands/attach.d.ts +1 -1
- package/dist/cli/commands/attach.d.ts.map +1 -1
- package/dist/cli/commands/cite.d.ts.map +1 -1
- package/dist/cli/commands/edit.d.ts.map +1 -1
- package/dist/cli/commands/fulltext.d.ts.map +1 -1
- package/dist/cli/commands/remove.d.ts.map +1 -1
- package/dist/cli/commands/search.d.ts +1 -1
- package/dist/cli/commands/search.d.ts.map +1 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/helpers.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/features/interactive/action-menu.d.ts +10 -12
- package/dist/features/interactive/action-menu.d.ts.map +1 -1
- package/dist/features/interactive/alternate-screen.d.ts +42 -0
- package/dist/features/interactive/alternate-screen.d.ts.map +1 -0
- package/dist/features/interactive/apps/CiteFlowApp.d.ts +52 -0
- package/dist/features/interactive/apps/CiteFlowApp.d.ts.map +1 -0
- package/dist/features/interactive/apps/SearchFlowApp.d.ts +34 -0
- package/dist/features/interactive/apps/SearchFlowApp.d.ts.map +1 -0
- package/dist/features/interactive/apps/index.d.ts +11 -0
- package/dist/features/interactive/apps/index.d.ts.map +1 -0
- package/dist/features/interactive/apps/runCiteFlow.d.ts +42 -0
- package/dist/features/interactive/apps/runCiteFlow.d.ts.map +1 -0
- package/dist/features/interactive/apps/runSearchFlow.d.ts +28 -0
- package/dist/features/interactive/apps/runSearchFlow.d.ts.map +1 -0
- package/dist/features/interactive/components/SearchableMultiSelect.d.ts +49 -0
- package/dist/features/interactive/components/SearchableMultiSelect.d.ts.map +1 -0
- package/dist/features/interactive/components/Select.d.ts +26 -0
- package/dist/features/interactive/components/Select.d.ts.map +1 -0
- package/dist/features/interactive/components/index.d.ts +8 -0
- package/dist/features/interactive/components/index.d.ts.map +1 -0
- package/dist/features/interactive/search-prompt.d.ts +15 -12
- package/dist/features/interactive/search-prompt.d.ts.map +1 -1
- package/dist/features/interactive/style-select.d.ts +3 -11
- package/dist/features/interactive/style-select.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/opener.d.ts.map +1 -1
- package/package.json +7 -4
- package/dist/chunks/action-menu-CLBXtpmg.js +0 -119
- package/dist/chunks/action-menu-CLBXtpmg.js.map +0 -1
- package/dist/chunks/index-BIFsFHVj.js.map +0 -1
- package/dist/chunks/index-C30Ouuee.js.map +0 -1
- package/dist/chunks/loader-DStZe-OB.js.map +0 -1
- package/dist/chunks/reference-select-B9w9CLa1.js +0 -52
- package/dist/chunks/reference-select-B9w9CLa1.js.map +0 -1
- package/dist/chunks/search-prompt-BrWpOcij.js +0 -265
- package/dist/chunks/search-prompt-BrWpOcij.js.map +0 -1
- package/dist/chunks/style-select-BNQHC79W.js.map +0 -1
- /package/bin/{reference-manager.js → cli.js} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchFlowApp - Single App for search -t flow
|
|
3
|
+
*
|
|
4
|
+
* Manages state transitions: search → action → (style if needed)
|
|
5
|
+
* Following React Ink Single App Pattern (ADR-015)
|
|
6
|
+
*/
|
|
7
|
+
import type React from "react";
|
|
8
|
+
import type { CslItem } from "../../../core/csl-json/types.js";
|
|
9
|
+
import { type ActionMenuResult } from "../action-menu.js";
|
|
10
|
+
import { type Choice, type SortOption } from "../components/index.js";
|
|
11
|
+
/**
|
|
12
|
+
* Props for SearchFlowApp
|
|
13
|
+
*/
|
|
14
|
+
export interface SearchFlowAppProps {
|
|
15
|
+
/** Choices for the search prompt */
|
|
16
|
+
choices: Choice<CslItem>[];
|
|
17
|
+
/** Filter function for search */
|
|
18
|
+
filterFn: (query: string, choices: Choice<CslItem>[]) => Choice<CslItem>[];
|
|
19
|
+
/** Number of visible items */
|
|
20
|
+
visibleCount: number;
|
|
21
|
+
/** Default sort option */
|
|
22
|
+
defaultSort: SortOption;
|
|
23
|
+
/** Callback when flow completes */
|
|
24
|
+
onComplete: (result: ActionMenuResult) => void;
|
|
25
|
+
/** Callback when flow is cancelled */
|
|
26
|
+
onCancel: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* SearchFlowApp component
|
|
30
|
+
*
|
|
31
|
+
* Single App that manages search → action → style flow
|
|
32
|
+
*/
|
|
33
|
+
export declare function SearchFlowApp({ choices, filterFn, visibleCount, defaultSort, onComplete, onCancel, }: SearchFlowAppProps): React.ReactElement;
|
|
34
|
+
//# sourceMappingURL=SearchFlowApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchFlowApp.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/apps/SearchFlowApp.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAEL,KAAK,gBAAgB,EAItB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,MAAM,EAGX,KAAK,UAAU,EAChB,MAAM,wBAAwB,CAAC;AAOhC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3E,8BAA8B;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,WAAW,EAAE,UAAU,CAAC;IACxB,mCAAmC;IACnC,UAAU,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,sCAAsC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,GACT,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CA8GzC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow-specific App components for React Ink
|
|
3
|
+
*
|
|
4
|
+
* Each App manages a complete interactive flow with state transitions.
|
|
5
|
+
* Following React Ink Single App Pattern (ADR-015)
|
|
6
|
+
*/
|
|
7
|
+
export { SearchFlowApp, type SearchFlowAppProps } from "./SearchFlowApp.js";
|
|
8
|
+
export { runSearchFlow, type SearchFlowConfig, type SearchFunction } from "./runSearchFlow.js";
|
|
9
|
+
export { CiteFlowApp, type CiteFlowAppProps, type CiteFlowResult } from "./CiteFlowApp.js";
|
|
10
|
+
export { runCiteFlow, type CiteFlowConfig, type RunCiteFlowOptions } from "./runCiteFlow.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/apps/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runner for CiteFlowApp
|
|
3
|
+
*
|
|
4
|
+
* Provides the public API for running the cite flow.
|
|
5
|
+
*/
|
|
6
|
+
import type { CslItem } from "../../../core/csl-json/types.js";
|
|
7
|
+
import type { SearchResult } from "../../search/types.js";
|
|
8
|
+
import type { SelectOption } from "../components/index.js";
|
|
9
|
+
import { type CiteFlowResult } from "./CiteFlowApp.js";
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for the cite flow
|
|
12
|
+
*/
|
|
13
|
+
export interface CiteFlowConfig {
|
|
14
|
+
/** Maximum number of results to display */
|
|
15
|
+
limit: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Search function type for filtering references
|
|
19
|
+
*/
|
|
20
|
+
export type SearchFunction = (query: string) => SearchResult[];
|
|
21
|
+
/**
|
|
22
|
+
* Options for running the cite flow
|
|
23
|
+
*/
|
|
24
|
+
export interface RunCiteFlowOptions {
|
|
25
|
+
/** All references available for selection */
|
|
26
|
+
allReferences: CslItem[];
|
|
27
|
+
/** Search function for filtering */
|
|
28
|
+
searchFn: SearchFunction;
|
|
29
|
+
/** Flow configuration */
|
|
30
|
+
config: CiteFlowConfig;
|
|
31
|
+
/** Style options for style selection */
|
|
32
|
+
styleOptions: SelectOption<string>[];
|
|
33
|
+
/** Whether to show style selection */
|
|
34
|
+
showStyleSelect: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run the cite flow (reference selection → style selection if needed)
|
|
38
|
+
*
|
|
39
|
+
* This is the main entry point for interactive cite command.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runCiteFlow(options: RunCiteFlowOptions): Promise<CiteFlowResult>;
|
|
42
|
+
//# sourceMappingURL=runCiteFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCiteFlow.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/apps/runCiteFlow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EAAU,YAAY,EAAc,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,EAAE,CAAC;AA+H/D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,oCAAoC;IACpC,QAAQ,EAAE,cAAc,CAAC;IACzB,yBAAyB;IACzB,MAAM,EAAE,cAAc,CAAC;IACvB,wCAAwC;IACxC,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IACrC,sCAAsC;IACtC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAkEtF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runner for SearchFlowApp
|
|
3
|
+
*
|
|
4
|
+
* Provides the public API for running the search flow.
|
|
5
|
+
*/
|
|
6
|
+
import type { CslItem } from "../../../core/csl-json/types.js";
|
|
7
|
+
import type { SearchResult } from "../../search/types.js";
|
|
8
|
+
import type { ActionMenuResult } from "../action-menu.js";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for the search flow
|
|
11
|
+
*/
|
|
12
|
+
export interface SearchFlowConfig {
|
|
13
|
+
/** Maximum number of results to display */
|
|
14
|
+
limit: number;
|
|
15
|
+
/** Debounce delay in milliseconds (not used, kept for API compatibility) */
|
|
16
|
+
debounceMs: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Search function type for filtering references
|
|
20
|
+
*/
|
|
21
|
+
export type SearchFunction = (query: string) => SearchResult[];
|
|
22
|
+
/**
|
|
23
|
+
* Run the search flow (search → action → style if needed)
|
|
24
|
+
*
|
|
25
|
+
* This is the main entry point for the `search -t` command.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runSearchFlow(allReferences: CslItem[], searchFn: SearchFunction, config: SearchFlowConfig): Promise<ActionMenuResult>;
|
|
28
|
+
//# sourceMappingURL=runSearchFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runSearchFlow.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/apps/runSearchFlow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAM1D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,EAAE,CAAC;AA+H/D;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,OAAO,EAAE,EACxB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAiE3B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchableMultiSelect - A searchable multi-select component for React Ink
|
|
3
|
+
*
|
|
4
|
+
* This component combines text input for filtering with multi-select functionality,
|
|
5
|
+
* which is not available in ink-ui out of the box.
|
|
6
|
+
*/
|
|
7
|
+
import type React from "react";
|
|
8
|
+
export interface Choice<T = unknown> {
|
|
9
|
+
/** Unique identifier for the choice */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Primary text (title) - displayed in cyan when focused */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Secondary text (e.g., authors) */
|
|
14
|
+
subtitle?: string;
|
|
15
|
+
/** Tertiary text (e.g., year, type, identifiers) */
|
|
16
|
+
meta?: string;
|
|
17
|
+
/** Associated value */
|
|
18
|
+
value: T;
|
|
19
|
+
/** Date when the item was last updated (custom.timestamp) */
|
|
20
|
+
updatedDate?: Date;
|
|
21
|
+
/** Date when the item was created (custom.created_at) */
|
|
22
|
+
createdDate?: Date;
|
|
23
|
+
/** Date when the item was published (for sorting) */
|
|
24
|
+
publishedDate?: Date;
|
|
25
|
+
}
|
|
26
|
+
/** Sort option identifier */
|
|
27
|
+
export type SortOption = "updated-desc" | "updated-asc" | "created-desc" | "created-asc" | "published-desc" | "published-asc" | "relevance";
|
|
28
|
+
export interface SearchableMultiSelectProps<T> {
|
|
29
|
+
/** Available choices */
|
|
30
|
+
choices: Choice<T>[];
|
|
31
|
+
/** Filter function for search */
|
|
32
|
+
filterFn?: (query: string, choices: Choice<T>[]) => Choice<T>[];
|
|
33
|
+
/** Maximum visible items */
|
|
34
|
+
visibleCount?: number;
|
|
35
|
+
/** Callback when selection is confirmed */
|
|
36
|
+
onSubmit: (selected: Choice<T>[]) => void;
|
|
37
|
+
/** Callback when cancelled */
|
|
38
|
+
onCancel: () => void;
|
|
39
|
+
/** Placeholder text for search input */
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
/** Header text */
|
|
42
|
+
header?: string;
|
|
43
|
+
/** Footer text */
|
|
44
|
+
footer?: string;
|
|
45
|
+
/** Default sort option */
|
|
46
|
+
defaultSort?: SortOption;
|
|
47
|
+
}
|
|
48
|
+
export declare function SearchableMultiSelect<T>({ choices, filterFn, visibleCount: visibleCountProp, onSubmit, onCancel, placeholder, header, footer, defaultSort, }: SearchableMultiSelectProps<T>): React.ReactElement;
|
|
49
|
+
//# sourceMappingURL=SearchableMultiSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchableMultiSelect.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/components/SearchableMultiSelect.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,OAAO;IACjC,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAA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,CAAC,YAAY,CAsNpD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select - A simple single-select component for React Ink
|
|
3
|
+
*/
|
|
4
|
+
import type React from "react";
|
|
5
|
+
export interface SelectOption<T = string> {
|
|
6
|
+
/** Display label */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Associated value */
|
|
9
|
+
value: T;
|
|
10
|
+
/** Optional hint text */
|
|
11
|
+
hint?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SelectProps<T = string> {
|
|
14
|
+
/** Available options */
|
|
15
|
+
options: SelectOption<T>[];
|
|
16
|
+
/** Prompt message */
|
|
17
|
+
message: string;
|
|
18
|
+
/** Callback when selection is confirmed */
|
|
19
|
+
onSelect: (value: T) => void;
|
|
20
|
+
/** Callback when cancelled */
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
/** Initial selection index */
|
|
23
|
+
initialIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function Select<T = string>({ options, message, onSelect, onCancel, initialIndex, }: SelectProps<T>): React.ReactElement;
|
|
26
|
+
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/components/Select.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,MAAM;IACtC,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,EAAE,CAAC,CAAC;IACT,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,MAAM;IACrC,wBAAwB;IACxB,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,8BAA8B;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,EACjC,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAgB,GACjB,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,CA6ErC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Ink components for interactive TUI
|
|
3
|
+
*/
|
|
4
|
+
export { SearchableMultiSelect } from "./SearchableMultiSelect.js";
|
|
5
|
+
export type { Choice, SearchableMultiSelectProps, SortOption, } from "./SearchableMultiSelect.js";
|
|
6
|
+
export { Select } from "./Select.js";
|
|
7
|
+
export type { SelectOption, SelectProps } from "./Select.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/interactive/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EACV,MAAM,EACN,0BAA0B,EAC1B,UAAU,GACX,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Interactive search prompt using
|
|
2
|
+
* Interactive search prompt using React Ink
|
|
3
3
|
*
|
|
4
4
|
* Provides real-time incremental search with multiple selection support.
|
|
5
5
|
*/
|
|
6
6
|
import type { CslItem } from "../../core/csl-json/types.js";
|
|
7
7
|
import type { SearchResult } from "../search/types.js";
|
|
8
|
-
import type { AutoCompleteChoice } from "./enquirer.js";
|
|
9
8
|
/**
|
|
10
9
|
* Configuration for the search prompt
|
|
11
10
|
*/
|
|
12
11
|
export interface SearchPromptConfig {
|
|
13
12
|
/** Maximum number of results to display */
|
|
14
13
|
limit: number;
|
|
15
|
-
/** Debounce delay in milliseconds */
|
|
14
|
+
/** Debounce delay in milliseconds (not used in Ink version, kept for API compatibility) */
|
|
16
15
|
debounceMs: number;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
@@ -28,14 +27,6 @@ export interface SearchPromptResult {
|
|
|
28
27
|
/** Whether the prompt was cancelled */
|
|
29
28
|
cancelled: boolean;
|
|
30
29
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates choices from search results
|
|
33
|
-
*/
|
|
34
|
-
export declare function createChoices(results: SearchResult[], terminalWidth: number): AutoCompleteChoice[];
|
|
35
|
-
/**
|
|
36
|
-
* Parses selected values back to CslItems
|
|
37
|
-
*/
|
|
38
|
-
export declare function parseSelectedValues(values: string | string[]): CslItem[];
|
|
39
30
|
/**
|
|
40
31
|
* Gets terminal width, falling back to 80 if not available
|
|
41
32
|
*/
|
|
@@ -54,5 +45,17 @@ export declare function calculateEffectiveLimit(configLimit: number): number;
|
|
|
54
45
|
/**
|
|
55
46
|
* Creates and runs an interactive search prompt
|
|
56
47
|
*/
|
|
57
|
-
export declare function runSearchPrompt(allReferences: CslItem[], searchFn: SearchFunction, config: SearchPromptConfig,
|
|
48
|
+
export declare function runSearchPrompt(allReferences: CslItem[], searchFn: SearchFunction, config: SearchPromptConfig, _initialQuery?: string): Promise<SearchPromptResult>;
|
|
49
|
+
export interface AutoCompleteChoice {
|
|
50
|
+
name: string;
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates choices from search results (legacy, for test compatibility)
|
|
55
|
+
*/
|
|
56
|
+
export declare function createChoices(results: SearchResult[], _terminalWidth: number): AutoCompleteChoice[];
|
|
57
|
+
/**
|
|
58
|
+
* Parses selected values back to CslItems (legacy, for test compatibility)
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseSelectedValues(values: string | string[]): CslItem[];
|
|
58
61
|
//# sourceMappingURL=search-prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-prompt.d.ts","sourceRoot":"","sources":["../../../src/features/interactive/search-prompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"search-prompt.d.ts","sourceRoot":"","sources":["../../../src/features/interactive/search-prompt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,EAAE,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQnE;AA0JD;;GAEG;AACH,wBAAsB,eAAe,CACnC,aAAa,EAAE,OAAO,EAAE,EACxB,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,kBAAkB,EAC1B,aAAa,SAAK,GACjB,OAAO,CAAC,kBAAkB,CAAC,CA6D7B;AAID,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,YAAY,EAAE,EACvB,cAAc,EAAE,MAAM,GACrB,kBAAkB,EAAE,CAKtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,EAAE,CAexE"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Lists built-in styles and custom styles from csl_directory,
|
|
5
5
|
* with the default style shown first.
|
|
6
6
|
*/
|
|
7
|
+
import { type SelectOption } from "./components/index.js";
|
|
7
8
|
/**
|
|
8
9
|
* Options for style selection
|
|
9
10
|
*/
|
|
@@ -22,14 +23,6 @@ export interface StyleSelectResult {
|
|
|
22
23
|
/** Whether the selection was cancelled */
|
|
23
24
|
cancelled: boolean;
|
|
24
25
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Choice definition for Enquirer Select prompt
|
|
27
|
-
*/
|
|
28
|
-
interface StyleChoice {
|
|
29
|
-
name: string;
|
|
30
|
-
message: string;
|
|
31
|
-
value: string;
|
|
32
|
-
}
|
|
33
26
|
/**
|
|
34
27
|
* List custom CSL style names from the specified directory/directories.
|
|
35
28
|
*
|
|
@@ -42,9 +35,9 @@ export declare function listCustomStyles(cslDirectory: string | string[] | undef
|
|
|
42
35
|
*
|
|
43
36
|
* @param customStyles - Custom style names from csl_directory
|
|
44
37
|
* @param defaultStyle - Default style to show first
|
|
45
|
-
* @returns Array of
|
|
38
|
+
* @returns Array of SelectOption for Ink Select prompt
|
|
46
39
|
*/
|
|
47
|
-
export declare function buildStyleChoices(customStyles: string[], defaultStyle?: string):
|
|
40
|
+
export declare function buildStyleChoices(customStyles: string[], defaultStyle?: string): SelectOption<string>[];
|
|
48
41
|
/**
|
|
49
42
|
* Run the style selection prompt.
|
|
50
43
|
*
|
|
@@ -52,5 +45,4 @@ export declare function buildStyleChoices(customStyles: string[], defaultStyle?:
|
|
|
52
45
|
* @returns Selection result with style name
|
|
53
46
|
*/
|
|
54
47
|
export declare function runStyleSelect(options: StyleSelectOptions): Promise<StyleSelectResult>;
|
|
55
|
-
export {};
|
|
56
48
|
//# sourceMappingURL=style-select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-select.d.ts","sourceRoot":"","sources":["../../../src/features/interactive/style-select.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"style-select.d.ts","sourceRoot":"","sources":["../../../src/features/interactive/style-select.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;CACpB;AAaD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CA4BtF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EAAE,EACtB,YAAY,SAAQ,GACnB,YAAY,CAAC,MAAM,CAAC,EAAE,CA6BxB;AAmCD;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgD5F"}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import writeFileAtomicLib from "write-file-atomic";
|
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { g as getOpenerCommand, o as openWithSystemApp, b as backupConfigSchema, c as configSchema, d as defaultConfig, a as getDefaultBackupDirectory, e as getDefaultCurrentDirConfigFilename, f as getDefaultLibraryPath, h as getDefaultUserConfigPath, l as loadConfig, i as logLevelSchema, n as normalizePartialConfig, p as partialConfigSchema, w as watchConfigSchema } from "./chunks/loader-
|
|
9
|
+
import { g as getOpenerCommand, o as openWithSystemApp, b as backupConfigSchema, c as configSchema, d as defaultConfig, a as getDefaultBackupDirectory, e as getDefaultCurrentDirConfigFilename, f as getDefaultLibraryPath, h as getDefaultUserConfigPath, l as loadConfig, i as logLevelSchema, n as normalizePartialConfig, p as partialConfigSchema, w as watchConfigSchema } from "./chunks/loader-DuhmXjiI.js";
|
|
10
10
|
function validateCslJson(data) {
|
|
11
11
|
const parseResult = CslLibrarySchema.safeParse(data);
|
|
12
12
|
if (!parseResult.success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opener.d.ts","sourceRoot":"","sources":["../../src/utils/opener.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAY/B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,OAAiB,GAAG,MAAM,EAAE,CAcnF;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAyB,GAClC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"opener.d.ts","sourceRoot":"","sources":["../../src/utils/opener.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAY/B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,OAAiB,GAAG,MAAM,EAAE,CAcnF;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAyB,GAClC,OAAO,CAAC,IAAI,CAAC,CAqDf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ncukondo/reference-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A local reference management tool using CSL-JSON as the single source of truth",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"node": ">=22"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
|
-
"ref": "./bin/
|
|
14
|
-
"reference-manager": "./bin/
|
|
13
|
+
"ref": "./bin/cli.js",
|
|
14
|
+
"reference-manager": "./bin/cli.js"
|
|
15
15
|
},
|
|
16
16
|
"main": "./dist/index.js",
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
@@ -56,10 +56,12 @@
|
|
|
56
56
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
57
57
|
"chokidar": "^5.0.0",
|
|
58
58
|
"commander": "^12.1.0",
|
|
59
|
-
"enquirer": "^2.4.1",
|
|
60
59
|
"env-paths": "^3.0.0",
|
|
61
60
|
"hono": "^4.11.1",
|
|
61
|
+
"ink": "^6.6.0",
|
|
62
|
+
"ink-ui": "^0.4.0",
|
|
62
63
|
"js-yaml": "^4.1.1",
|
|
64
|
+
"react": "^19.2.3",
|
|
63
65
|
"tabtab": "^3.0.2",
|
|
64
66
|
"write-file-atomic": "^7.0.0",
|
|
65
67
|
"yaml": "^2.8.2",
|
|
@@ -71,6 +73,7 @@
|
|
|
71
73
|
"@types/chokidar": "^1.7.5",
|
|
72
74
|
"@types/js-yaml": "^4.0.9",
|
|
73
75
|
"@types/node": "^22.19.2",
|
|
76
|
+
"@types/react": "^19.2.9",
|
|
74
77
|
"@types/tabtab": "^3.0.4",
|
|
75
78
|
"@types/write-file-atomic": "^4.0.3",
|
|
76
79
|
"@vitest/coverage-v8": "^2.1.9",
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { f as formatBibtex } from "./index-BIFsFHVj.js";
|
|
2
|
-
import { f as formatBibliographyCSL } from "./index-DHgeuWGP.js";
|
|
3
|
-
const ACTION_CHOICES = [
|
|
4
|
-
{ name: "output-ids", message: "Output IDs (citation keys)", value: "output-ids" },
|
|
5
|
-
{ name: "output-csl-json", message: "Output as CSL-JSON", value: "output-csl-json" },
|
|
6
|
-
{ name: "output-bibtex", message: "Output as BibTeX", value: "output-bibtex" },
|
|
7
|
-
{ name: "cite-apa", message: "Generate citation (APA)", value: "cite-apa" },
|
|
8
|
-
{ name: "cite-choose", message: "Generate citation (choose style)", value: "cite-choose" },
|
|
9
|
-
{ name: "cancel", message: "Cancel", value: "cancel" }
|
|
10
|
-
];
|
|
11
|
-
const STYLE_CHOICES = [
|
|
12
|
-
{ name: "apa", message: "APA", value: "apa" },
|
|
13
|
-
{ name: "vancouver", message: "Vancouver", value: "vancouver" },
|
|
14
|
-
{ name: "harvard", message: "Harvard", value: "harvard" }
|
|
15
|
-
];
|
|
16
|
-
function generateOutput(action, items, style = "apa") {
|
|
17
|
-
switch (action) {
|
|
18
|
-
case "output-ids":
|
|
19
|
-
return items.map((item) => item.id).join("\n");
|
|
20
|
-
case "output-csl-json":
|
|
21
|
-
return JSON.stringify(items, null, 2);
|
|
22
|
-
case "output-bibtex":
|
|
23
|
-
return formatBibtex(items);
|
|
24
|
-
case "cite-apa":
|
|
25
|
-
return formatBibliographyCSL(items, { style: "apa" });
|
|
26
|
-
case "cite-choose":
|
|
27
|
-
return formatBibliographyCSL(items, { style });
|
|
28
|
-
case "cancel":
|
|
29
|
-
return "";
|
|
30
|
-
default:
|
|
31
|
-
return "";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function processAction(action, items) {
|
|
35
|
-
if (action === "cite-choose") {
|
|
36
|
-
const styleResult = await runStyleSelectPrompt();
|
|
37
|
-
if (styleResult.cancelled) {
|
|
38
|
-
return {
|
|
39
|
-
action: "cancel",
|
|
40
|
-
output: "",
|
|
41
|
-
cancelled: true
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
action,
|
|
46
|
-
output: generateOutput(action, items, styleResult.style),
|
|
47
|
-
cancelled: false
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (action === "cancel") {
|
|
51
|
-
return {
|
|
52
|
-
action,
|
|
53
|
-
output: "",
|
|
54
|
-
cancelled: true
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
action,
|
|
59
|
-
output: generateOutput(action, items),
|
|
60
|
-
cancelled: false
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async function runStyleSelectPrompt() {
|
|
64
|
-
const enquirer = await import("enquirer");
|
|
65
|
-
const Select = enquirer.default.Select;
|
|
66
|
-
const promptOptions = {
|
|
67
|
-
name: "style",
|
|
68
|
-
message: "Select citation style:",
|
|
69
|
-
choices: STYLE_CHOICES
|
|
70
|
-
};
|
|
71
|
-
try {
|
|
72
|
-
const prompt = new Select(promptOptions);
|
|
73
|
-
const result = await prompt.run();
|
|
74
|
-
return {
|
|
75
|
-
style: result,
|
|
76
|
-
cancelled: false
|
|
77
|
-
};
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (error === "" || error instanceof Error && error.message === "") {
|
|
80
|
-
return {
|
|
81
|
-
cancelled: true
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async function runActionMenu(items) {
|
|
88
|
-
const enquirer = await import("enquirer");
|
|
89
|
-
const Select = enquirer.default.Select;
|
|
90
|
-
const count = items.length;
|
|
91
|
-
const refWord = count === 1 ? "reference" : "references";
|
|
92
|
-
const message = `Action for ${count} selected ${refWord}:`;
|
|
93
|
-
const promptOptions = {
|
|
94
|
-
name: "action",
|
|
95
|
-
message,
|
|
96
|
-
choices: ACTION_CHOICES
|
|
97
|
-
};
|
|
98
|
-
try {
|
|
99
|
-
const prompt = new Select(promptOptions);
|
|
100
|
-
const action = await prompt.run();
|
|
101
|
-
return processAction(action, items);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
if (error === "" || error instanceof Error && error.message === "") {
|
|
104
|
-
return {
|
|
105
|
-
action: "cancel",
|
|
106
|
-
output: "",
|
|
107
|
-
cancelled: true
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
export {
|
|
114
|
-
ACTION_CHOICES,
|
|
115
|
-
STYLE_CHOICES,
|
|
116
|
-
runActionMenu,
|
|
117
|
-
runStyleSelectPrompt
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=action-menu-CLBXtpmg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"action-menu-CLBXtpmg.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,EAA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