@ncukondo/reference-manager 0.22.2 → 0.23.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/{action-menu-R-QKMCZJ.js → action-menu-C0-X1ndf.js} +3 -3
- package/dist/chunks/{action-menu-R-QKMCZJ.js.map → action-menu-C0-X1ndf.js.map} +1 -1
- package/dist/chunks/{format-uBMjeVAZ.js → format-CBbnqK3-.js} +2 -2
- package/dist/chunks/{format-uBMjeVAZ.js.map → format-CBbnqK3-.js.map} +1 -1
- package/dist/chunks/{index-B7NyGOm6.js → index-BSWbcT3c.js} +4 -4
- package/dist/chunks/{index-B7NyGOm6.js.map → index-BSWbcT3c.js.map} +1 -1
- package/dist/chunks/{index-CXZ_Trjb.js → index-BVDVqLTl.js} +3 -3
- package/dist/chunks/index-BVDVqLTl.js.map +1 -0
- package/dist/chunks/{index-DxjW_BKA.js → index-BrETQT0g.js} +78 -45
- package/dist/chunks/index-BrETQT0g.js.map +1 -0
- package/dist/chunks/index-eZatWPDi.js +12525 -0
- package/dist/chunks/index-eZatWPDi.js.map +1 -0
- package/dist/chunks/{loader-BZgpKsTG.js → loader-CzviN_sy.js} +60 -18
- package/dist/chunks/loader-CzviN_sy.js.map +1 -0
- package/dist/chunks/{reference-select-Cpq_Q4f6.js → reference-select-CogjIATu.js} +3 -3
- package/dist/chunks/{reference-select-Cpq_Q4f6.js.map → reference-select-CogjIATu.js.map} +1 -1
- package/dist/chunks/{style-select-CQIqnmWS.js → style-select-CJzZczSq.js} +3 -3
- package/dist/chunks/{style-select-CQIqnmWS.js.map → style-select-CJzZczSq.js.map} +1 -1
- package/dist/cli/commands/fulltext.d.ts +4 -0
- package/dist/cli/commands/fulltext.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/env-override.d.ts.map +1 -1
- package/dist/config/key-parser.d.ts.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/schema.d.ts +30 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/features/operations/fulltext/discover.d.ts +5 -0
- package/dist/features/operations/fulltext/discover.d.ts.map +1 -1
- package/dist/features/operations/fulltext/fetch.d.ts.map +1 -1
- package/dist/features/operations/fulltext/get.d.ts +2 -0
- package/dist/features/operations/fulltext/get.d.ts.map +1 -1
- package/dist/features/operations/fulltext/open.d.ts +2 -0
- package/dist/features/operations/fulltext/open.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/tools/fulltext.d.ts.map +1 -1
- package/dist/server.js +3 -3
- package/package.json +2 -2
- package/dist/chunks/index-CXZ_Trjb.js.map +0 -1
- package/dist/chunks/index-DFhoO9RA.js +0 -5929
- package/dist/chunks/index-DFhoO9RA.js.map +0 -1
- package/dist/chunks/index-DxjW_BKA.js.map +0 -1
- package/dist/chunks/loader-BZgpKsTG.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-B7NyGOm6.js","sources":["../../src/features/interactive/apps/SearchFlowApp.tsx","../../src/features/interactive/apps/runSearchFlow.ts","../../src/features/interactive/apps/CiteFlowApp.tsx","../../src/features/interactive/apps/runCiteFlow.ts"],"sourcesContent":["/**\n * SearchFlowApp - Single App for search -t flow\n *\n * Manages state transitions: search → action → (style/output-format if needed)\n * Following React Ink Single App Pattern (ADR-015)\n */\n\nimport { Box, useApp } from \"ink\";\nimport type React from \"react\";\nimport { createElement, useEffect, useState } from \"react\";\nimport type { CitationKeyFormat } from \"../../../config/schema.js\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport {\n type ActionMenuResult,\n type ActionType,\n OUTPUT_FORMAT_CHOICES,\n type OutputFormatType,\n STYLE_CHOICES,\n generateOutput,\n getActionChoices,\n isSideEffectAction,\n} from \"../action-menu.js\";\nimport {\n type Choice,\n SearchableMultiSelect,\n Select,\n type SortOption,\n} from \"../components/index.js\";\n\n/**\n * Flow states for the search flow\n */\ntype FlowState = \"search\" | \"action\" | \"style\" | \"output-format\" | \"exiting\";\n\n/**\n * Props for SearchFlowApp\n */\nexport interface SearchFlowAppProps {\n /** Choices for the search prompt */\n choices: Choice<CslItem>[];\n /** Filter function for search */\n filterFn: (query: string, choices: Choice<CslItem>[]) => Choice<CslItem>[];\n /** Number of visible items */\n visibleCount: number;\n /** Default sort option */\n defaultSort: SortOption;\n /** Default citation key format */\n defaultKeyFormat: CitationKeyFormat;\n /** Default citation style */\n defaultStyle: string;\n /** Debounce delay in milliseconds for search filtering */\n debounceMs?: number;\n /** Callback when flow completes */\n onComplete: (result: ActionMenuResult) => void;\n /** Callback when flow is cancelled */\n onCancel: () => void;\n}\n\n/**\n * SearchFlowApp component\n *\n * Single App that manages search → action → style/output-format flow\n */\nexport function SearchFlowApp({\n choices,\n filterFn,\n visibleCount,\n defaultSort,\n defaultKeyFormat,\n defaultStyle,\n debounceMs,\n onComplete,\n onCancel,\n}: SearchFlowAppProps): React.ReactElement {\n const { exit } = useApp();\n const [state, setState] = useState<FlowState>(\"search\");\n const [selectedItems, setSelectedItems] = useState<CslItem[]>([]);\n const [pendingResult, setPendingResult] = useState<ActionMenuResult | null>(null);\n\n // Exit when entering \"exiting\" state (after rendering empty component)\n useEffect(() => {\n if (state === \"exiting\" && pendingResult) {\n exit();\n if (pendingResult.cancelled) {\n onCancel();\n } else {\n onComplete(pendingResult);\n }\n }\n }, [state, pendingResult, exit, onCancel, onComplete]);\n\n // Transition to exiting state with result\n const exitWith = (result: ActionMenuResult) => {\n setPendingResult(result);\n setState(\"exiting\");\n };\n\n // Handle search submission\n const handleSearchSubmit = (selected: Choice<CslItem>[]) => {\n if (selected.length === 0) {\n exitWith({ action: \"cancel\", output: \"\", cancelled: true });\n return;\n }\n setSelectedItems(selected.map((c) => c.value));\n setState(\"action\");\n };\n\n // Handle search cancel\n const handleSearchCancel = () => {\n exitWith({ action: \"cancel\", output: \"\", cancelled: true });\n };\n\n // Handle action selection\n const handleActionSelect = (action: ActionType) => {\n if (action === \"cancel\") {\n exitWith({ action: \"cancel\", output: \"\", cancelled: true });\n return;\n }\n\n // If cite-choose, go to style selection\n if (action === \"cite-choose\") {\n setState(\"style\");\n return;\n }\n\n // If output-format, go to output format submenu\n if (action === \"output-format\") {\n setState(\"output-format\");\n return;\n }\n\n // Handle side-effect actions\n if (isSideEffectAction(action)) {\n exitWith({ action, output: \"\", cancelled: false, selectedItems });\n return;\n }\n\n // Generate output and complete\n const output = generateOutput(action, selectedItems, {\n defaultKeyFormat,\n defaultStyle,\n });\n exitWith({ action, output, cancelled: false });\n };\n\n // Handle action cancel (go back to search)\n const handleActionCancel = () => {\n setState(\"search\");\n };\n\n // Handle style selection\n const handleStyleSelect = (style: string) => {\n const output = generateOutput(\"cite-choose\", selectedItems, {\n defaultKeyFormat,\n defaultStyle: style,\n });\n exitWith({ action: \"cite-choose\", output, cancelled: false });\n };\n\n // Handle style cancel (go back to action)\n const handleStyleCancel = () => {\n setState(\"action\");\n };\n\n // Handle output format selection\n const handleOutputFormatSelect = (format: OutputFormatType) => {\n if (format === \"cancel\") {\n setState(\"action\");\n return;\n }\n\n const output = generateOutput(format, selectedItems, {\n defaultKeyFormat,\n defaultStyle,\n });\n exitWith({ action: \"output-format\", output, cancelled: false });\n };\n\n // Handle output format cancel (go back to action)\n const handleOutputFormatCancel = () => {\n setState(\"action\");\n };\n\n // Render based on current state\n if (state === \"exiting\") {\n // Empty component - Ink will clear the previous content\n return createElement(Box);\n }\n\n if (state === \"search\") {\n return createElement(SearchableMultiSelect<CslItem>, {\n choices,\n filterFn,\n visibleCount,\n onSubmit: handleSearchSubmit,\n onCancel: handleSearchCancel,\n header: \"Search references\",\n placeholder: \"Type to search...\",\n defaultSort,\n ...(debounceMs !== undefined && { debounceMs }),\n });\n }\n\n if (state === \"action\") {\n const count = selectedItems.length;\n const refWord = count === 1 ? \"reference\" : \"references\";\n return createElement(Select<ActionType>, {\n key: \"action\",\n options: getActionChoices(count, { defaultKeyFormat }),\n message: `Action for ${count} selected ${refWord}:`,\n onSelect: handleActionSelect,\n onCancel: handleActionCancel,\n });\n }\n\n if (state === \"output-format\") {\n return createElement(Select<OutputFormatType>, {\n key: \"output-format\",\n options: OUTPUT_FORMAT_CHOICES,\n message: \"Select output format:\",\n onSelect: handleOutputFormatSelect,\n onCancel: handleOutputFormatCancel,\n });\n }\n\n // state === \"style\"\n return createElement(Select<string>, {\n key: \"style\",\n options: STYLE_CHOICES,\n message: \"Select citation style:\",\n onSelect: handleStyleSelect,\n onCancel: handleStyleCancel,\n });\n}\n","/**\n * Runner for SearchFlowApp\n *\n * Provides the public API for running the search flow.\n */\n\nimport { render } from \"ink\";\nimport { createElement } from \"react\";\nimport type { CitationKeyFormat } from \"../../../config/schema.js\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport { buildResourceIndicators } from \"../../format/resource-indicators.js\";\nimport type { SearchResult } from \"../../search/types.js\";\nimport type { ActionMenuResult } from \"../action-menu.js\";\nimport { restoreStdinAfterInk } from \"../alternate-screen.js\";\nimport { type Choice, type SortOption, calculateEffectiveLimit } from \"../components/index.js\";\nimport { formatAuthors } from \"../format.js\";\nimport { SearchFlowApp } from \"./SearchFlowApp.js\";\n\n/**\n * Configuration for the search flow\n */\nexport interface SearchFlowConfig {\n /** Maximum number of results to display */\n limit: number;\n /** Debounce delay in milliseconds for search filtering */\n debounceMs: number;\n /** Default citation key format */\n defaultKeyFormat?: CitationKeyFormat;\n /** Default citation style */\n defaultStyle?: string;\n}\n\n/**\n * Search function type for filtering references\n */\nexport type SearchFunction = (query: string) => SearchResult[];\n\n/**\n * Extract year from CSL item\n */\nfunction extractYear(item: CslItem): number | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n return firstDatePart[0];\n}\n\n/**\n * Extract published date from CSL item\n */\nfunction extractPublishedDate(item: CslItem): Date | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n const [year, month = 1, day = 1] = firstDatePart;\n if (year === undefined) return undefined;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Extract updated date from CSL item (from custom.timestamp)\n */\nfunction extractUpdatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.timestamp;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Extract created date from CSL item (from custom.created_at)\n */\nfunction extractCreatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.created_at;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Format identifiers for meta line\n */\nfunction formatIdentifiers(item: CslItem): string {\n const parts: string[] = [];\n if (item.DOI) parts.push(`DOI: ${item.DOI}`);\n if (item.PMID) parts.push(`PMID: ${item.PMID}`);\n if (item.PMCID) parts.push(`PMCID: ${item.PMCID}`);\n if (item.ISBN) parts.push(`ISBN: ${item.ISBN}`);\n return parts.join(\" · \");\n}\n\n/**\n * Format item type for display\n */\nfunction formatType(type: string): string {\n const typeMap: Record<string, string> = {\n \"article-journal\": \"Journal article\",\n \"article-magazine\": \"Magazine article\",\n \"article-newspaper\": \"Newspaper article\",\n book: \"Book\",\n chapter: \"Book chapter\",\n \"paper-conference\": \"Conference paper\",\n thesis: \"Thesis\",\n report: \"Report\",\n webpage: \"Web page\",\n };\n return typeMap[type] ?? type;\n}\n\n/**\n * Convert CslItem to Choice for SearchableMultiSelect\n */\nexport function toChoice(item: CslItem): Choice<CslItem> {\n const authors = formatAuthors(item.author);\n const year = extractYear(item);\n const identifiers = formatIdentifiers(item);\n const itemType = formatType(item.type);\n\n // Build meta line: Year · Type · Identifiers\n const metaParts: string[] = [];\n if (year) metaParts.push(String(year));\n metaParts.push(itemType);\n if (identifiers) metaParts.push(identifiers);\n\n const updatedDate = extractUpdatedDate(item);\n const createdDate = extractCreatedDate(item);\n const publishedDate = extractPublishedDate(item);\n\n // Prepend resource indicators to meta if present\n const indicators = buildResourceIndicators(item);\n const metaStr = metaParts.join(\" · \");\n const meta = indicators ? `${indicators} ${metaStr}` : metaStr;\n\n return {\n id: item.id,\n title: item.title ?? \"(No title)\",\n subtitle: authors || \"(No authors)\",\n meta,\n value: item,\n ...(updatedDate && { updatedDate }),\n ...(createdDate && { createdDate }),\n ...(publishedDate && { publishedDate }),\n };\n}\n\n/**\n * Run the search flow (search → action → style if needed)\n *\n * This is the main entry point for the `search -t` command.\n */\nexport async function runSearchFlow(\n allReferences: CslItem[],\n searchFn: SearchFunction,\n config: SearchFlowConfig\n): Promise<ActionMenuResult> {\n // Convert references to choices and build lookup map\n const choices = allReferences.map(toChoice);\n const choiceMap = new Map(choices.map((c) => [c.id, c]));\n\n // Calculate effective visible count\n const effectiveLimit = calculateEffectiveLimit(config.limit);\n\n // Create filter function using the provided search function\n const filterFn = (query: string, choices: Choice<CslItem>[]): Choice<CslItem>[] => {\n if (!query.trim()) return choices;\n\n const results = searchFn(query);\n return results.flatMap((r) => {\n const choice = choiceMap.get(r.reference.id);\n return choice ? [choice] : [];\n });\n };\n\n // Default sort option\n const defaultSort: SortOption = \"updated-desc\";\n\n // Create a promise to capture the result\n return new Promise<ActionMenuResult>((resolve) => {\n let flowResult: ActionMenuResult = {\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n };\n\n const handleComplete = (result: ActionMenuResult): void => {\n flowResult = result;\n };\n\n const handleCancel = (): void => {\n flowResult = {\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n };\n };\n\n // Render the Ink app (single render for entire flow)\n const { waitUntilExit } = render(\n createElement(SearchFlowApp, {\n choices,\n filterFn,\n visibleCount: effectiveLimit,\n defaultSort,\n defaultKeyFormat: config.defaultKeyFormat ?? \"pandoc\",\n defaultStyle: config.defaultStyle ?? \"apa\",\n debounceMs: config.debounceMs,\n onComplete: handleComplete,\n onCancel: handleCancel,\n })\n );\n\n // Wait for the app to exit, then resolve\n waitUntilExit()\n .then(() => {\n restoreStdinAfterInk();\n resolve(flowResult);\n })\n .catch(() => {\n restoreStdinAfterInk();\n resolve({\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n });\n });\n });\n}\n","/**\n * CiteFlowApp - Single App for cite command flow\n *\n * Implements the Single App Pattern (ADR-015) for the cite command.\n * Manages state transitions: reference selection → style selection → exiting\n */\n\nimport { Box, useApp } from \"ink\";\nimport type React from \"react\";\nimport { createElement, useEffect, useState } from \"react\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport { SearchableMultiSelect } from \"../components/SearchableMultiSelect.js\";\nimport { Select, type SelectOption } from \"../components/Select.js\";\nimport type { Choice, SortOption } from \"../components/index.js\";\n\n// Flow states\ntype FlowState = \"search\" | \"style\" | \"exiting\";\n\n/**\n * Result from the cite flow\n */\nexport interface CiteFlowResult {\n /** Selected reference IDs */\n identifiers: string[];\n /** Selected style (if style selection was shown) */\n style?: string;\n /** Whether the flow was cancelled */\n cancelled: boolean;\n}\n\n/**\n * Props for CiteFlowApp\n */\nexport interface CiteFlowAppProps {\n /** All reference choices */\n choices: Choice<CslItem>[];\n /** Filter function for search */\n filterFn: (query: string, choices: Choice<CslItem>[]) => Choice<CslItem>[];\n /** Number of visible items */\n visibleCount: number;\n /** Default sort option */\n defaultSort: SortOption;\n /** Style options for style selection */\n styleOptions: SelectOption<string>[];\n /** Whether to show style selection (false if style already specified) */\n showStyleSelect: boolean;\n /** Callback when flow completes */\n onComplete: (result: CiteFlowResult) => void;\n /** Callback when flow is cancelled */\n onCancel: () => void;\n}\n\n/**\n * CiteFlowApp component\n *\n * Single Ink app that handles the entire cite flow:\n * 1. Reference selection (SearchableMultiSelect)\n * 2. Style selection (Select) - optional\n * 3. Exit\n */\nexport function CiteFlowApp({\n choices,\n filterFn,\n visibleCount,\n defaultSort,\n styleOptions,\n showStyleSelect,\n onComplete,\n onCancel,\n}: CiteFlowAppProps): React.ReactElement {\n const { exit } = useApp();\n const [state, setState] = useState<FlowState>(\"search\");\n const [selectedItems, setSelectedItems] = useState<CslItem[]>([]);\n const [pendingResult, setPendingResult] = useState<CiteFlowResult | null>(null);\n\n // Exit when entering \"exiting\" state\n useEffect(() => {\n if (state === \"exiting\" && pendingResult) {\n exit();\n if (pendingResult.cancelled) {\n onCancel();\n } else {\n onComplete(pendingResult);\n }\n }\n }, [state, pendingResult, exit, onCancel, onComplete]);\n\n // Transition to exiting state with result\n const exitWith = (result: CiteFlowResult) => {\n setPendingResult(result);\n setState(\"exiting\");\n };\n\n // Handle search submission\n const handleSearchSubmit = (selected: Choice<CslItem>[]) => {\n if (selected.length === 0) {\n exitWith({ identifiers: [], cancelled: true });\n return;\n }\n const items = selected.map((c) => c.value);\n setSelectedItems(items);\n\n if (showStyleSelect) {\n setState(\"style\");\n } else {\n // No style selection needed, complete immediately\n exitWith({\n identifiers: items.map((item) => item.id),\n cancelled: false,\n });\n }\n };\n\n // Handle search cancel\n const handleSearchCancel = () => {\n exitWith({ identifiers: [], cancelled: true });\n };\n\n // Handle style selection\n const handleStyleSelect = (style: string) => {\n exitWith({\n identifiers: selectedItems.map((item) => item.id),\n style,\n cancelled: false,\n });\n };\n\n // Handle style cancel (go back to search)\n const handleStyleCancel = () => {\n setState(\"search\");\n };\n\n // Render based on current state\n if (state === \"exiting\") {\n return createElement(Box);\n }\n\n if (state === \"search\") {\n return createElement(SearchableMultiSelect<CslItem>, {\n choices,\n filterFn,\n visibleCount,\n onSubmit: handleSearchSubmit,\n onCancel: handleSearchCancel,\n header: \"Select references to cite\",\n placeholder: \"Type to search...\",\n defaultSort,\n });\n }\n\n // state === \"style\"\n const count = selectedItems.length;\n const refWord = count === 1 ? \"reference\" : \"references\";\n return createElement(Select<string>, {\n options: styleOptions,\n message: `Select citation style for ${count} ${refWord}:`,\n onSelect: handleStyleSelect,\n onCancel: handleStyleCancel,\n });\n}\n","/**\n * Runner for CiteFlowApp\n *\n * Provides the public API for running the cite flow.\n */\n\nimport { render } from \"ink\";\nimport { createElement } from \"react\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport type { SearchResult } from \"../../search/types.js\";\nimport { restoreStdinAfterInk } from \"../alternate-screen.js\";\nimport {\n type Choice,\n type SelectOption,\n type SortOption,\n calculateEffectiveLimit,\n} from \"../components/index.js\";\nimport { formatAuthors } from \"../format.js\";\nimport { CiteFlowApp, type CiteFlowResult } from \"./CiteFlowApp.js\";\n\n/**\n * Configuration for the cite flow\n */\nexport interface CiteFlowConfig {\n /** Maximum number of results to display */\n limit: number;\n}\n\n/**\n * Search function type for filtering references\n */\nexport type SearchFunction = (query: string) => SearchResult[];\n\n/**\n * Extract year from CSL item\n */\nfunction extractYear(item: CslItem): number | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n return firstDatePart[0];\n}\n\n/**\n * Extract published date from CSL item\n */\nfunction extractPublishedDate(item: CslItem): Date | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n const [year, month = 1, day = 1] = firstDatePart;\n if (year === undefined) return undefined;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Extract updated date from CSL item (from custom.timestamp)\n */\nfunction extractUpdatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.timestamp;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Extract created date from CSL item (from custom.created_at)\n */\nfunction extractCreatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.created_at;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Format identifiers for meta line\n */\nfunction formatIdentifiers(item: CslItem): string {\n const parts: string[] = [];\n if (item.DOI) parts.push(`DOI: ${item.DOI}`);\n if (item.PMID) parts.push(`PMID: ${item.PMID}`);\n if (item.PMCID) parts.push(`PMCID: ${item.PMCID}`);\n if (item.ISBN) parts.push(`ISBN: ${item.ISBN}`);\n return parts.join(\" · \");\n}\n\n/**\n * Format item type for display\n */\nfunction formatType(type: string): string {\n const typeMap: Record<string, string> = {\n \"article-journal\": \"Journal article\",\n \"article-magazine\": \"Magazine article\",\n \"article-newspaper\": \"Newspaper article\",\n book: \"Book\",\n chapter: \"Book chapter\",\n \"paper-conference\": \"Conference paper\",\n thesis: \"Thesis\",\n report: \"Report\",\n webpage: \"Web page\",\n };\n return typeMap[type] ?? type;\n}\n\n/**\n * Convert CslItem to Choice for SearchableMultiSelect\n */\nfunction toChoice(item: CslItem): Choice<CslItem> {\n const authors = formatAuthors(item.author);\n const year = extractYear(item);\n const identifiers = formatIdentifiers(item);\n const itemType = formatType(item.type);\n\n // Build meta line: Year · Type · Identifiers\n const metaParts: string[] = [];\n if (year) metaParts.push(String(year));\n metaParts.push(itemType);\n if (identifiers) metaParts.push(identifiers);\n\n const updatedDate = extractUpdatedDate(item);\n const createdDate = extractCreatedDate(item);\n const publishedDate = extractPublishedDate(item);\n\n return {\n id: item.id,\n title: item.title ?? \"(No title)\",\n subtitle: authors || \"(No authors)\",\n meta: metaParts.join(\" · \"),\n value: item,\n ...(updatedDate && { updatedDate }),\n ...(createdDate && { createdDate }),\n ...(publishedDate && { publishedDate }),\n };\n}\n\n/**\n * Options for running the cite flow\n */\nexport interface RunCiteFlowOptions {\n /** All references available for selection */\n allReferences: CslItem[];\n /** Search function for filtering */\n searchFn: SearchFunction;\n /** Flow configuration */\n config: CiteFlowConfig;\n /** Style options for style selection */\n styleOptions: SelectOption<string>[];\n /** Whether to show style selection */\n showStyleSelect: boolean;\n}\n\n/**\n * Run the cite flow (reference selection → style selection if needed)\n *\n * This is the main entry point for interactive cite command.\n */\nexport async function runCiteFlow(options: RunCiteFlowOptions): Promise<CiteFlowResult> {\n const { allReferences, searchFn, config, styleOptions, showStyleSelect } = options;\n\n // Convert references to choices\n const choices = allReferences.map(toChoice);\n\n // Calculate effective visible count\n const effectiveLimit = calculateEffectiveLimit(config.limit);\n\n // Create filter function using the provided search function\n const filterFn = (query: string, choices: Choice<CslItem>[]): Choice<CslItem>[] => {\n if (!query.trim()) return choices;\n\n const results = searchFn(query);\n return results.map((r) => toChoice(r.reference));\n };\n\n // Default sort option\n const defaultSort: SortOption = \"updated-desc\";\n\n // Create a promise to capture the result\n return new Promise<CiteFlowResult>((resolve) => {\n let flowResult: CiteFlowResult = {\n identifiers: [],\n cancelled: true,\n };\n\n const handleComplete = (result: CiteFlowResult): void => {\n flowResult = result;\n };\n\n const handleCancel = (): void => {\n flowResult = {\n identifiers: [],\n cancelled: true,\n };\n };\n\n // Render the Ink app (single render for entire flow)\n const { waitUntilExit } = render(\n createElement(CiteFlowApp, {\n choices,\n filterFn,\n visibleCount: effectiveLimit,\n defaultSort,\n styleOptions,\n showStyleSelect,\n onComplete: handleComplete,\n onCancel: handleCancel,\n })\n );\n\n // Wait for the app to exit, then resolve\n waitUntilExit()\n .then(() => {\n restoreStdinAfterInk();\n resolve(flowResult);\n })\n .catch(() => {\n restoreStdinAfterInk();\n resolve({\n identifiers: [],\n cancelled: true,\n });\n });\n });\n}\n"],"names":["extractYear","extractPublishedDate","extractUpdatedDate","extractCreatedDate","formatIdentifiers","formatType","toChoice","choices"],"mappings":";;;;;AA+DO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA2C;AACzC,QAAM,EAAE,KAAA,IAAS,OAAA;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AkB;AAAA,MACxB,cAAc,aAAa;AAAA,QACzB;AAAA,QACA;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,QACZ,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAIH,kBAAA,EACG,KAAK,MAAM;AACV,2BAAA;AACA,cAAQ,UAAU;AAAA,IACpB,CAAC,EACA,MAAM,MAAM;AACX,2BAAA;AACA,cAAQ;AAAA,QACN,aAAa,CAAA;AAAA,QACb,WAAW;AAAA,MAAA,CACZ;AAAA,IACH,CAAC;AAAA,EACL,CAAC;AACH;"}
|
|
1
|
+
{"version":3,"file":"index-BSWbcT3c.js","sources":["../../src/features/interactive/apps/SearchFlowApp.tsx","../../src/features/interactive/apps/runSearchFlow.ts","../../src/features/interactive/apps/CiteFlowApp.tsx","../../src/features/interactive/apps/runCiteFlow.ts"],"sourcesContent":["/**\n * SearchFlowApp - Single App for search -t flow\n *\n * Manages state transitions: search → action → (style/output-format if needed)\n * Following React Ink Single App Pattern (ADR-015)\n */\n\nimport { Box, useApp } from \"ink\";\nimport type React from \"react\";\nimport { createElement, useEffect, useState } from \"react\";\nimport type { CitationKeyFormat } from \"../../../config/schema.js\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport {\n type ActionMenuResult,\n type ActionType,\n OUTPUT_FORMAT_CHOICES,\n type OutputFormatType,\n STYLE_CHOICES,\n generateOutput,\n getActionChoices,\n isSideEffectAction,\n} from \"../action-menu.js\";\nimport {\n type Choice,\n SearchableMultiSelect,\n Select,\n type SortOption,\n} from \"../components/index.js\";\n\n/**\n * Flow states for the search flow\n */\ntype FlowState = \"search\" | \"action\" | \"style\" | \"output-format\" | \"exiting\";\n\n/**\n * Props for SearchFlowApp\n */\nexport interface SearchFlowAppProps {\n /** Choices for the search prompt */\n choices: Choice<CslItem>[];\n /** Filter function for search */\n filterFn: (query: string, choices: Choice<CslItem>[]) => Choice<CslItem>[];\n /** Number of visible items */\n visibleCount: number;\n /** Default sort option */\n defaultSort: SortOption;\n /** Default citation key format */\n defaultKeyFormat: CitationKeyFormat;\n /** Default citation style */\n defaultStyle: string;\n /** Debounce delay in milliseconds for search filtering */\n debounceMs?: number;\n /** Callback when flow completes */\n onComplete: (result: ActionMenuResult) => void;\n /** Callback when flow is cancelled */\n onCancel: () => void;\n}\n\n/**\n * SearchFlowApp component\n *\n * Single App that manages search → action → style/output-format flow\n */\nexport function SearchFlowApp({\n choices,\n filterFn,\n visibleCount,\n defaultSort,\n defaultKeyFormat,\n defaultStyle,\n debounceMs,\n onComplete,\n onCancel,\n}: SearchFlowAppProps): React.ReactElement {\n const { exit } = useApp();\n const [state, setState] = useState<FlowState>(\"search\");\n const [selectedItems, setSelectedItems] = useState<CslItem[]>([]);\n const [pendingResult, setPendingResult] = useState<ActionMenuResult | null>(null);\n\n // Exit when entering \"exiting\" state (after rendering empty component)\n useEffect(() => {\n if (state === \"exiting\" && pendingResult) {\n exit();\n if (pendingResult.cancelled) {\n onCancel();\n } else {\n onComplete(pendingResult);\n }\n }\n }, [state, pendingResult, exit, onCancel, onComplete]);\n\n // Transition to exiting state with result\n const exitWith = (result: ActionMenuResult) => {\n setPendingResult(result);\n setState(\"exiting\");\n };\n\n // Handle search submission\n const handleSearchSubmit = (selected: Choice<CslItem>[]) => {\n if (selected.length === 0) {\n exitWith({ action: \"cancel\", output: \"\", cancelled: true });\n return;\n }\n setSelectedItems(selected.map((c) => c.value));\n setState(\"action\");\n };\n\n // Handle search cancel\n const handleSearchCancel = () => {\n exitWith({ action: \"cancel\", output: \"\", cancelled: true });\n };\n\n // Handle action selection\n const handleActionSelect = (action: ActionType) => {\n if (action === \"cancel\") {\n exitWith({ action: \"cancel\", output: \"\", cancelled: true });\n return;\n }\n\n // If cite-choose, go to style selection\n if (action === \"cite-choose\") {\n setState(\"style\");\n return;\n }\n\n // If output-format, go to output format submenu\n if (action === \"output-format\") {\n setState(\"output-format\");\n return;\n }\n\n // Handle side-effect actions\n if (isSideEffectAction(action)) {\n exitWith({ action, output: \"\", cancelled: false, selectedItems });\n return;\n }\n\n // Generate output and complete\n const output = generateOutput(action, selectedItems, {\n defaultKeyFormat,\n defaultStyle,\n });\n exitWith({ action, output, cancelled: false });\n };\n\n // Handle action cancel (go back to search)\n const handleActionCancel = () => {\n setState(\"search\");\n };\n\n // Handle style selection\n const handleStyleSelect = (style: string) => {\n const output = generateOutput(\"cite-choose\", selectedItems, {\n defaultKeyFormat,\n defaultStyle: style,\n });\n exitWith({ action: \"cite-choose\", output, cancelled: false });\n };\n\n // Handle style cancel (go back to action)\n const handleStyleCancel = () => {\n setState(\"action\");\n };\n\n // Handle output format selection\n const handleOutputFormatSelect = (format: OutputFormatType) => {\n if (format === \"cancel\") {\n setState(\"action\");\n return;\n }\n\n const output = generateOutput(format, selectedItems, {\n defaultKeyFormat,\n defaultStyle,\n });\n exitWith({ action: \"output-format\", output, cancelled: false });\n };\n\n // Handle output format cancel (go back to action)\n const handleOutputFormatCancel = () => {\n setState(\"action\");\n };\n\n // Render based on current state\n if (state === \"exiting\") {\n // Empty component - Ink will clear the previous content\n return createElement(Box);\n }\n\n if (state === \"search\") {\n return createElement(SearchableMultiSelect<CslItem>, {\n choices,\n filterFn,\n visibleCount,\n onSubmit: handleSearchSubmit,\n onCancel: handleSearchCancel,\n header: \"Search references\",\n placeholder: \"Type to search...\",\n defaultSort,\n ...(debounceMs !== undefined && { debounceMs }),\n });\n }\n\n if (state === \"action\") {\n const count = selectedItems.length;\n const refWord = count === 1 ? \"reference\" : \"references\";\n return createElement(Select<ActionType>, {\n key: \"action\",\n options: getActionChoices(count, { defaultKeyFormat }),\n message: `Action for ${count} selected ${refWord}:`,\n onSelect: handleActionSelect,\n onCancel: handleActionCancel,\n });\n }\n\n if (state === \"output-format\") {\n return createElement(Select<OutputFormatType>, {\n key: \"output-format\",\n options: OUTPUT_FORMAT_CHOICES,\n message: \"Select output format:\",\n onSelect: handleOutputFormatSelect,\n onCancel: handleOutputFormatCancel,\n });\n }\n\n // state === \"style\"\n return createElement(Select<string>, {\n key: \"style\",\n options: STYLE_CHOICES,\n message: \"Select citation style:\",\n onSelect: handleStyleSelect,\n onCancel: handleStyleCancel,\n });\n}\n","/**\n * Runner for SearchFlowApp\n *\n * Provides the public API for running the search flow.\n */\n\nimport { render } from \"ink\";\nimport { createElement } from \"react\";\nimport type { CitationKeyFormat } from \"../../../config/schema.js\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport { buildResourceIndicators } from \"../../format/resource-indicators.js\";\nimport type { SearchResult } from \"../../search/types.js\";\nimport type { ActionMenuResult } from \"../action-menu.js\";\nimport { restoreStdinAfterInk } from \"../alternate-screen.js\";\nimport { type Choice, type SortOption, calculateEffectiveLimit } from \"../components/index.js\";\nimport { formatAuthors } from \"../format.js\";\nimport { SearchFlowApp } from \"./SearchFlowApp.js\";\n\n/**\n * Configuration for the search flow\n */\nexport interface SearchFlowConfig {\n /** Maximum number of results to display */\n limit: number;\n /** Debounce delay in milliseconds for search filtering */\n debounceMs: number;\n /** Default citation key format */\n defaultKeyFormat?: CitationKeyFormat;\n /** Default citation style */\n defaultStyle?: string;\n}\n\n/**\n * Search function type for filtering references\n */\nexport type SearchFunction = (query: string) => SearchResult[];\n\n/**\n * Extract year from CSL item\n */\nfunction extractYear(item: CslItem): number | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n return firstDatePart[0];\n}\n\n/**\n * Extract published date from CSL item\n */\nfunction extractPublishedDate(item: CslItem): Date | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n const [year, month = 1, day = 1] = firstDatePart;\n if (year === undefined) return undefined;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Extract updated date from CSL item (from custom.timestamp)\n */\nfunction extractUpdatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.timestamp;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Extract created date from CSL item (from custom.created_at)\n */\nfunction extractCreatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.created_at;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Format identifiers for meta line\n */\nfunction formatIdentifiers(item: CslItem): string {\n const parts: string[] = [];\n if (item.DOI) parts.push(`DOI: ${item.DOI}`);\n if (item.PMID) parts.push(`PMID: ${item.PMID}`);\n if (item.PMCID) parts.push(`PMCID: ${item.PMCID}`);\n if (item.ISBN) parts.push(`ISBN: ${item.ISBN}`);\n return parts.join(\" · \");\n}\n\n/**\n * Format item type for display\n */\nfunction formatType(type: string): string {\n const typeMap: Record<string, string> = {\n \"article-journal\": \"Journal article\",\n \"article-magazine\": \"Magazine article\",\n \"article-newspaper\": \"Newspaper article\",\n book: \"Book\",\n chapter: \"Book chapter\",\n \"paper-conference\": \"Conference paper\",\n thesis: \"Thesis\",\n report: \"Report\",\n webpage: \"Web page\",\n };\n return typeMap[type] ?? type;\n}\n\n/**\n * Convert CslItem to Choice for SearchableMultiSelect\n */\nexport function toChoice(item: CslItem): Choice<CslItem> {\n const authors = formatAuthors(item.author);\n const year = extractYear(item);\n const identifiers = formatIdentifiers(item);\n const itemType = formatType(item.type);\n\n // Build meta line: Year · Type · Identifiers\n const metaParts: string[] = [];\n if (year) metaParts.push(String(year));\n metaParts.push(itemType);\n if (identifiers) metaParts.push(identifiers);\n\n const updatedDate = extractUpdatedDate(item);\n const createdDate = extractCreatedDate(item);\n const publishedDate = extractPublishedDate(item);\n\n // Prepend resource indicators to meta if present\n const indicators = buildResourceIndicators(item);\n const metaStr = metaParts.join(\" · \");\n const meta = indicators ? `${indicators} ${metaStr}` : metaStr;\n\n return {\n id: item.id,\n title: item.title ?? \"(No title)\",\n subtitle: authors || \"(No authors)\",\n meta,\n value: item,\n ...(updatedDate && { updatedDate }),\n ...(createdDate && { createdDate }),\n ...(publishedDate && { publishedDate }),\n };\n}\n\n/**\n * Run the search flow (search → action → style if needed)\n *\n * This is the main entry point for the `search -t` command.\n */\nexport async function runSearchFlow(\n allReferences: CslItem[],\n searchFn: SearchFunction,\n config: SearchFlowConfig\n): Promise<ActionMenuResult> {\n // Convert references to choices and build lookup map\n const choices = allReferences.map(toChoice);\n const choiceMap = new Map(choices.map((c) => [c.id, c]));\n\n // Calculate effective visible count\n const effectiveLimit = calculateEffectiveLimit(config.limit);\n\n // Create filter function using the provided search function\n const filterFn = (query: string, choices: Choice<CslItem>[]): Choice<CslItem>[] => {\n if (!query.trim()) return choices;\n\n const results = searchFn(query);\n return results.flatMap((r) => {\n const choice = choiceMap.get(r.reference.id);\n return choice ? [choice] : [];\n });\n };\n\n // Default sort option\n const defaultSort: SortOption = \"updated-desc\";\n\n // Create a promise to capture the result\n return new Promise<ActionMenuResult>((resolve) => {\n let flowResult: ActionMenuResult = {\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n };\n\n const handleComplete = (result: ActionMenuResult): void => {\n flowResult = result;\n };\n\n const handleCancel = (): void => {\n flowResult = {\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n };\n };\n\n // Render the Ink app (single render for entire flow)\n const { waitUntilExit } = render(\n createElement(SearchFlowApp, {\n choices,\n filterFn,\n visibleCount: effectiveLimit,\n defaultSort,\n defaultKeyFormat: config.defaultKeyFormat ?? \"pandoc\",\n defaultStyle: config.defaultStyle ?? \"apa\",\n debounceMs: config.debounceMs,\n onComplete: handleComplete,\n onCancel: handleCancel,\n })\n );\n\n // Wait for the app to exit, then resolve\n waitUntilExit()\n .then(() => {\n restoreStdinAfterInk();\n resolve(flowResult);\n })\n .catch(() => {\n restoreStdinAfterInk();\n resolve({\n action: \"cancel\",\n output: \"\",\n cancelled: true,\n });\n });\n });\n}\n","/**\n * CiteFlowApp - Single App for cite command flow\n *\n * Implements the Single App Pattern (ADR-015) for the cite command.\n * Manages state transitions: reference selection → style selection → exiting\n */\n\nimport { Box, useApp } from \"ink\";\nimport type React from \"react\";\nimport { createElement, useEffect, useState } from \"react\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport { SearchableMultiSelect } from \"../components/SearchableMultiSelect.js\";\nimport { Select, type SelectOption } from \"../components/Select.js\";\nimport type { Choice, SortOption } from \"../components/index.js\";\n\n// Flow states\ntype FlowState = \"search\" | \"style\" | \"exiting\";\n\n/**\n * Result from the cite flow\n */\nexport interface CiteFlowResult {\n /** Selected reference IDs */\n identifiers: string[];\n /** Selected style (if style selection was shown) */\n style?: string;\n /** Whether the flow was cancelled */\n cancelled: boolean;\n}\n\n/**\n * Props for CiteFlowApp\n */\nexport interface CiteFlowAppProps {\n /** All reference choices */\n choices: Choice<CslItem>[];\n /** Filter function for search */\n filterFn: (query: string, choices: Choice<CslItem>[]) => Choice<CslItem>[];\n /** Number of visible items */\n visibleCount: number;\n /** Default sort option */\n defaultSort: SortOption;\n /** Style options for style selection */\n styleOptions: SelectOption<string>[];\n /** Whether to show style selection (false if style already specified) */\n showStyleSelect: boolean;\n /** Callback when flow completes */\n onComplete: (result: CiteFlowResult) => void;\n /** Callback when flow is cancelled */\n onCancel: () => void;\n}\n\n/**\n * CiteFlowApp component\n *\n * Single Ink app that handles the entire cite flow:\n * 1. Reference selection (SearchableMultiSelect)\n * 2. Style selection (Select) - optional\n * 3. Exit\n */\nexport function CiteFlowApp({\n choices,\n filterFn,\n visibleCount,\n defaultSort,\n styleOptions,\n showStyleSelect,\n onComplete,\n onCancel,\n}: CiteFlowAppProps): React.ReactElement {\n const { exit } = useApp();\n const [state, setState] = useState<FlowState>(\"search\");\n const [selectedItems, setSelectedItems] = useState<CslItem[]>([]);\n const [pendingResult, setPendingResult] = useState<CiteFlowResult | null>(null);\n\n // Exit when entering \"exiting\" state\n useEffect(() => {\n if (state === \"exiting\" && pendingResult) {\n exit();\n if (pendingResult.cancelled) {\n onCancel();\n } else {\n onComplete(pendingResult);\n }\n }\n }, [state, pendingResult, exit, onCancel, onComplete]);\n\n // Transition to exiting state with result\n const exitWith = (result: CiteFlowResult) => {\n setPendingResult(result);\n setState(\"exiting\");\n };\n\n // Handle search submission\n const handleSearchSubmit = (selected: Choice<CslItem>[]) => {\n if (selected.length === 0) {\n exitWith({ identifiers: [], cancelled: true });\n return;\n }\n const items = selected.map((c) => c.value);\n setSelectedItems(items);\n\n if (showStyleSelect) {\n setState(\"style\");\n } else {\n // No style selection needed, complete immediately\n exitWith({\n identifiers: items.map((item) => item.id),\n cancelled: false,\n });\n }\n };\n\n // Handle search cancel\n const handleSearchCancel = () => {\n exitWith({ identifiers: [], cancelled: true });\n };\n\n // Handle style selection\n const handleStyleSelect = (style: string) => {\n exitWith({\n identifiers: selectedItems.map((item) => item.id),\n style,\n cancelled: false,\n });\n };\n\n // Handle style cancel (go back to search)\n const handleStyleCancel = () => {\n setState(\"search\");\n };\n\n // Render based on current state\n if (state === \"exiting\") {\n return createElement(Box);\n }\n\n if (state === \"search\") {\n return createElement(SearchableMultiSelect<CslItem>, {\n choices,\n filterFn,\n visibleCount,\n onSubmit: handleSearchSubmit,\n onCancel: handleSearchCancel,\n header: \"Select references to cite\",\n placeholder: \"Type to search...\",\n defaultSort,\n });\n }\n\n // state === \"style\"\n const count = selectedItems.length;\n const refWord = count === 1 ? \"reference\" : \"references\";\n return createElement(Select<string>, {\n options: styleOptions,\n message: `Select citation style for ${count} ${refWord}:`,\n onSelect: handleStyleSelect,\n onCancel: handleStyleCancel,\n });\n}\n","/**\n * Runner for CiteFlowApp\n *\n * Provides the public API for running the cite flow.\n */\n\nimport { render } from \"ink\";\nimport { createElement } from \"react\";\nimport type { CslItem } from \"../../../core/csl-json/types.js\";\nimport type { SearchResult } from \"../../search/types.js\";\nimport { restoreStdinAfterInk } from \"../alternate-screen.js\";\nimport {\n type Choice,\n type SelectOption,\n type SortOption,\n calculateEffectiveLimit,\n} from \"../components/index.js\";\nimport { formatAuthors } from \"../format.js\";\nimport { CiteFlowApp, type CiteFlowResult } from \"./CiteFlowApp.js\";\n\n/**\n * Configuration for the cite flow\n */\nexport interface CiteFlowConfig {\n /** Maximum number of results to display */\n limit: number;\n}\n\n/**\n * Search function type for filtering references\n */\nexport type SearchFunction = (query: string) => SearchResult[];\n\n/**\n * Extract year from CSL item\n */\nfunction extractYear(item: CslItem): number | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n return firstDatePart[0];\n}\n\n/**\n * Extract published date from CSL item\n */\nfunction extractPublishedDate(item: CslItem): Date | undefined {\n const dateParts = item.issued?.[\"date-parts\"];\n if (!dateParts || dateParts.length === 0) return undefined;\n const firstDatePart = dateParts[0];\n if (!firstDatePart || firstDatePart.length === 0) return undefined;\n const [year, month = 1, day = 1] = firstDatePart;\n if (year === undefined) return undefined;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Extract updated date from CSL item (from custom.timestamp)\n */\nfunction extractUpdatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.timestamp;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Extract created date from CSL item (from custom.created_at)\n */\nfunction extractCreatedDate(item: CslItem): Date | undefined {\n const dateStr = item.custom?.created_at;\n if (!dateStr || typeof dateStr !== \"string\") return undefined;\n const date = new Date(dateStr);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\n/**\n * Format identifiers for meta line\n */\nfunction formatIdentifiers(item: CslItem): string {\n const parts: string[] = [];\n if (item.DOI) parts.push(`DOI: ${item.DOI}`);\n if (item.PMID) parts.push(`PMID: ${item.PMID}`);\n if (item.PMCID) parts.push(`PMCID: ${item.PMCID}`);\n if (item.ISBN) parts.push(`ISBN: ${item.ISBN}`);\n return parts.join(\" · \");\n}\n\n/**\n * Format item type for display\n */\nfunction formatType(type: string): string {\n const typeMap: Record<string, string> = {\n \"article-journal\": \"Journal article\",\n \"article-magazine\": \"Magazine article\",\n \"article-newspaper\": \"Newspaper article\",\n book: \"Book\",\n chapter: \"Book chapter\",\n \"paper-conference\": \"Conference paper\",\n thesis: \"Thesis\",\n report: \"Report\",\n webpage: \"Web page\",\n };\n return typeMap[type] ?? type;\n}\n\n/**\n * Convert CslItem to Choice for SearchableMultiSelect\n */\nfunction toChoice(item: CslItem): Choice<CslItem> {\n const authors = formatAuthors(item.author);\n const year = extractYear(item);\n const identifiers = formatIdentifiers(item);\n const itemType = formatType(item.type);\n\n // Build meta line: Year · Type · Identifiers\n const metaParts: string[] = [];\n if (year) metaParts.push(String(year));\n metaParts.push(itemType);\n if (identifiers) metaParts.push(identifiers);\n\n const updatedDate = extractUpdatedDate(item);\n const createdDate = extractCreatedDate(item);\n const publishedDate = extractPublishedDate(item);\n\n return {\n id: item.id,\n title: item.title ?? \"(No title)\",\n subtitle: authors || \"(No authors)\",\n meta: metaParts.join(\" · \"),\n value: item,\n ...(updatedDate && { updatedDate }),\n ...(createdDate && { createdDate }),\n ...(publishedDate && { publishedDate }),\n };\n}\n\n/**\n * Options for running the cite flow\n */\nexport interface RunCiteFlowOptions {\n /** All references available for selection */\n allReferences: CslItem[];\n /** Search function for filtering */\n searchFn: SearchFunction;\n /** Flow configuration */\n config: CiteFlowConfig;\n /** Style options for style selection */\n styleOptions: SelectOption<string>[];\n /** Whether to show style selection */\n showStyleSelect: boolean;\n}\n\n/**\n * Run the cite flow (reference selection → style selection if needed)\n *\n * This is the main entry point for interactive cite command.\n */\nexport async function runCiteFlow(options: RunCiteFlowOptions): Promise<CiteFlowResult> {\n const { allReferences, searchFn, config, styleOptions, showStyleSelect } = options;\n\n // Convert references to choices\n const choices = allReferences.map(toChoice);\n\n // Calculate effective visible count\n const effectiveLimit = calculateEffectiveLimit(config.limit);\n\n // Create filter function using the provided search function\n const filterFn = (query: string, choices: Choice<CslItem>[]): Choice<CslItem>[] => {\n if (!query.trim()) return choices;\n\n const results = searchFn(query);\n return results.map((r) => toChoice(r.reference));\n };\n\n // Default sort option\n const defaultSort: SortOption = \"updated-desc\";\n\n // Create a promise to capture the result\n return new Promise<CiteFlowResult>((resolve) => {\n let flowResult: CiteFlowResult = {\n identifiers: [],\n cancelled: true,\n };\n\n const handleComplete = (result: CiteFlowResult): void => {\n flowResult = result;\n };\n\n const handleCancel = (): void => {\n flowResult = {\n identifiers: [],\n cancelled: true,\n };\n };\n\n // Render the Ink app (single render for entire flow)\n const { waitUntilExit } = render(\n createElement(CiteFlowApp, {\n choices,\n filterFn,\n visibleCount: effectiveLimit,\n defaultSort,\n styleOptions,\n showStyleSelect,\n onComplete: handleComplete,\n onCancel: handleCancel,\n })\n );\n\n // Wait for the app to exit, then resolve\n waitUntilExit()\n .then(() => {\n restoreStdinAfterInk();\n resolve(flowResult);\n })\n .catch(() => {\n restoreStdinAfterInk();\n resolve({\n identifiers: [],\n cancelled: true,\n });\n });\n });\n}\n"],"names":["extractYear","extractPublishedDate","extractUpdatedDate","extractCreatedDate","formatIdentifiers","formatType","toChoice","choices"],"mappings":";;;;;AA+DO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA2C;AACzC,QAAM,EAAE,KAAA,IAAS,OAAA;AACjB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAoB,QAAQ;AACtD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAoB,CAAA,CAAE;AAChE,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAkC,IAAI;AAGhF,YAAU,MAAM;AACd,QAAI,UAAU,aAAa,eAAe;AACxC,WAAA;AACA,UAAI,cA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B,CAAC,EACA,MAAM,MAAM;AACX,2BAAA;AACA,cAAQ;AAAA,QACN,aAAa,CAAA;AAAA,QACb,WAAW;AAAA,MAAA,CACZ;AAAA,IACH,CAAC;AAAA,EACL,CAAC;AACH;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a } from "./index-
|
|
2
|
-
import { d, g, l, o, s } from "./index-
|
|
1
|
+
import { a } from "./index-eZatWPDi.js";
|
|
2
|
+
import { d, g, l, o, s } from "./index-BrETQT0g.js";
|
|
3
3
|
export {
|
|
4
4
|
a as addAttachment,
|
|
5
5
|
d as detachAttachment,
|
|
@@ -8,4 +8,4 @@ export {
|
|
|
8
8
|
o as openAttachment,
|
|
9
9
|
s as syncAttachments
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=index-
|
|
11
|
+
//# sourceMappingURL=index-BVDVqLTl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BVDVqLTl.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import { i as isEqual, M as MANAGED_CUSTOM_FIELDS, w as writeFileAtomic, L as Library, h as CslItemSchema, p as pickDefined, a as sortOrderSchema, z as paginationOptionsSchema, F as FileWatcher, b as sortFieldSchema, y as searchSortFieldSchema } from "./file-watcher-Dyns9dxx.js";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { promises, readFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
import path__default, { join, basename, dirname } from "node:path";
|
|
8
|
-
import { n as normalizePathForOutput, d as deleteDirectoryIfEmpty, p as parseFilename, i as isReservedRole, e as ensureDirectory, a as addAttachment, R as RESERVED_ROLES, g as generateFilename, b as findFulltextFiles, c as findFulltextFile, h as extensionToFormat, j as fulltextAttach, k as fulltextGet, l as fulltextDiscover, m as fulltextFetch, o as fulltextConvert, q as getExtension, B as BUILTIN_STYLES,
|
|
8
|
+
import { n as normalizePathForOutput, d as deleteDirectoryIfEmpty, p as parseFilename, i as isReservedRole, e as ensureDirectory, a as addAttachment, R as RESERVED_ROLES, g as generateFilename, b as findFulltextFiles, c as findFulltextFile, h as extensionToFormat, j as fulltextAttach, k as fulltextGet, l as fulltextDiscover, m as fulltextFetch, o as fulltextConvert, q as getExtension, r as getDefaultExportFromCjs, B as BUILTIN_STYLES, s as getFulltextAttachmentTypes, t as startServerWithFileWatcher } from "./index-eZatWPDi.js";
|
|
9
9
|
import { readFile, unlink, stat, readdir, rename } from "node:fs/promises";
|
|
10
|
-
import { o as openWithSystemApp, l as loadConfig, e as getDefaultCurrentDirConfigFilename, h as getDefaultUserConfigPath } from "./loader-
|
|
10
|
+
import { o as openWithSystemApp, l as loadConfig, e as getDefaultCurrentDirConfigFilename, h as getDefaultUserConfigPath } from "./loader-CzviN_sy.js";
|
|
11
11
|
import { spawn, spawnSync } from "node:child_process";
|
|
12
12
|
import process$1, { stdin, stdout } from "node:process";
|
|
13
13
|
import * as readline from "node:readline";
|
|
@@ -19,7 +19,7 @@ import "@citation-js/plugin-csl";
|
|
|
19
19
|
import { ZodOptional as ZodOptional$2, z } from "zod";
|
|
20
20
|
import { serve } from "@hono/node-server";
|
|
21
21
|
const name = "@ncukondo/reference-manager";
|
|
22
|
-
const version$1 = "0.
|
|
22
|
+
const version$1 = "0.23.0";
|
|
23
23
|
const description$1 = "A local reference management tool using CSL-JSON as the single source of truth";
|
|
24
24
|
const packageJson = {
|
|
25
25
|
name,
|
|
@@ -902,15 +902,15 @@ class OperationsLibrary {
|
|
|
902
902
|
}
|
|
903
903
|
// High-level operations
|
|
904
904
|
async search(options) {
|
|
905
|
-
const { searchReferences } = await import("./index-
|
|
905
|
+
const { searchReferences } = await import("./index-eZatWPDi.js").then((n) => n.A);
|
|
906
906
|
return searchReferences(this.library, options);
|
|
907
907
|
}
|
|
908
908
|
async list(options) {
|
|
909
|
-
const { listReferences } = await import("./index-
|
|
909
|
+
const { listReferences } = await import("./index-eZatWPDi.js").then((n) => n.z);
|
|
910
910
|
return listReferences(this.library, options ?? {});
|
|
911
911
|
}
|
|
912
912
|
async cite(options) {
|
|
913
|
-
const { citeReferences } = await import("./index-
|
|
913
|
+
const { citeReferences } = await import("./index-eZatWPDi.js").then((n) => n.y);
|
|
914
914
|
const defaultStyle = options.defaultStyle ?? this.citationConfig?.defaultStyle;
|
|
915
915
|
const cslDirectory = options.cslDirectory ?? this.citationConfig?.cslDirectory;
|
|
916
916
|
const mergedOptions = {
|
|
@@ -921,32 +921,32 @@ class OperationsLibrary {
|
|
|
921
921
|
return citeReferences(this.library, mergedOptions);
|
|
922
922
|
}
|
|
923
923
|
async import(inputs, options) {
|
|
924
|
-
const { addReferences } = await import("./index-
|
|
924
|
+
const { addReferences } = await import("./index-eZatWPDi.js").then((n) => n.x);
|
|
925
925
|
return addReferences(inputs, this.library, options ?? {});
|
|
926
926
|
}
|
|
927
927
|
// Attachment operations
|
|
928
928
|
async attachAdd(options) {
|
|
929
|
-
const { addAttachment: addAttachment2 } = await import("./index-
|
|
929
|
+
const { addAttachment: addAttachment2 } = await import("./index-BVDVqLTl.js");
|
|
930
930
|
return addAttachment2(this.library, options);
|
|
931
931
|
}
|
|
932
932
|
async attachList(options) {
|
|
933
|
-
const { listAttachments: listAttachments2 } = await import("./index-
|
|
933
|
+
const { listAttachments: listAttachments2 } = await import("./index-BVDVqLTl.js");
|
|
934
934
|
return listAttachments2(this.library, options);
|
|
935
935
|
}
|
|
936
936
|
async attachGet(options) {
|
|
937
|
-
const { getAttachment: getAttachment2 } = await import("./index-
|
|
937
|
+
const { getAttachment: getAttachment2 } = await import("./index-BVDVqLTl.js");
|
|
938
938
|
return getAttachment2(this.library, options);
|
|
939
939
|
}
|
|
940
940
|
async attachDetach(options) {
|
|
941
|
-
const { detachAttachment: detachAttachment2 } = await import("./index-
|
|
941
|
+
const { detachAttachment: detachAttachment2 } = await import("./index-BVDVqLTl.js");
|
|
942
942
|
return detachAttachment2(this.library, options);
|
|
943
943
|
}
|
|
944
944
|
async attachSync(options) {
|
|
945
|
-
const { syncAttachments: syncAttachments2 } = await import("./index-
|
|
945
|
+
const { syncAttachments: syncAttachments2 } = await import("./index-BVDVqLTl.js");
|
|
946
946
|
return syncAttachments2(this.library, options);
|
|
947
947
|
}
|
|
948
948
|
async attachOpen(options) {
|
|
949
|
-
const { openAttachment: openAttachment2 } = await import("./index-
|
|
949
|
+
const { openAttachment: openAttachment2 } = await import("./index-BVDVqLTl.js");
|
|
950
950
|
return openAttachment2(this.library, options);
|
|
951
951
|
}
|
|
952
952
|
}
|
|
@@ -1790,7 +1790,7 @@ function getAttachExitCode(result) {
|
|
|
1790
1790
|
}
|
|
1791
1791
|
async function executeInteractiveSelect$2(context, config2) {
|
|
1792
1792
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
1793
|
-
const { selectReferencesOrExit } = await import("./reference-select-
|
|
1793
|
+
const { selectReferencesOrExit } = await import("./reference-select-CogjIATu.js");
|
|
1794
1794
|
const allReferences = await context.library.getAll();
|
|
1795
1795
|
const identifiers = await withAlternateScreen2(
|
|
1796
1796
|
() => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
|
|
@@ -2338,8 +2338,8 @@ function getCiteExitCode(result) {
|
|
|
2338
2338
|
}
|
|
2339
2339
|
async function executeInteractiveCite(options, context, config2) {
|
|
2340
2340
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
2341
|
-
const { runCiteFlow } = await import("./index-
|
|
2342
|
-
const { buildStyleChoices, listCustomStyles } = await import("./style-select-
|
|
2341
|
+
const { runCiteFlow } = await import("./index-BSWbcT3c.js");
|
|
2342
|
+
const { buildStyleChoices, listCustomStyles } = await import("./style-select-CJzZczSq.js");
|
|
2343
2343
|
const { search } = await import("./file-watcher-Dyns9dxx.js").then((n) => n.B);
|
|
2344
2344
|
const { tokenize } = await import("./file-watcher-Dyns9dxx.js").then((n) => n.A);
|
|
2345
2345
|
const { checkTTY } = await import("./tty-BMyaEOhX.js");
|
|
@@ -2423,10 +2423,13 @@ const ENV_OVERRIDE_MAP = {
|
|
|
2423
2423
|
REFERENCE_MANAGER_CLI_DEFAULT_LIMIT: "cli.default_limit",
|
|
2424
2424
|
REFERENCE_MANAGER_MCP_DEFAULT_LIMIT: "mcp.default_limit",
|
|
2425
2425
|
REFERENCE_MANAGER_CLIPBOARD_AUTO_COPY: "cli.tui.clipboard_auto_copy",
|
|
2426
|
+
REFERENCE_MANAGER_FULLTEXT_PREFERRED_TYPE: "fulltext.preferred_type",
|
|
2426
2427
|
PUBMED_EMAIL: "pubmed.email",
|
|
2427
2428
|
PUBMED_API_KEY: "pubmed.api_key",
|
|
2428
2429
|
UNPAYWALL_EMAIL: "fulltext.sources.unpaywall_email",
|
|
2429
|
-
CORE_API_KEY: "fulltext.sources.core_api_key"
|
|
2430
|
+
CORE_API_KEY: "fulltext.sources.core_api_key",
|
|
2431
|
+
NCBI_EMAIL: "fulltext.sources.ncbi_email",
|
|
2432
|
+
NCBI_TOOL: "fulltext.sources.ncbi_tool"
|
|
2430
2433
|
};
|
|
2431
2434
|
const KEY_TO_ENV_MAP = Object.fromEntries(
|
|
2432
2435
|
Object.entries(ENV_OVERRIDE_MAP).map(([envVar, configKey]) => [configKey, envVar])
|
|
@@ -2496,6 +2499,13 @@ const CONFIG_KEY_REGISTRY = [
|
|
|
2496
2499
|
type: "string[]",
|
|
2497
2500
|
description: "Fulltext source priority order"
|
|
2498
2501
|
},
|
|
2502
|
+
{
|
|
2503
|
+
key: "fulltext.preferred_type",
|
|
2504
|
+
type: "enum",
|
|
2505
|
+
description: "Preferred fulltext type for open/get",
|
|
2506
|
+
enumValues: ["pdf", "markdown"],
|
|
2507
|
+
optional: true
|
|
2508
|
+
},
|
|
2499
2509
|
{
|
|
2500
2510
|
key: "fulltext.auto_fetch_on_add",
|
|
2501
2511
|
type: "boolean",
|
|
@@ -2513,6 +2523,18 @@ const CONFIG_KEY_REGISTRY = [
|
|
|
2513
2523
|
description: "API key for CORE",
|
|
2514
2524
|
optional: true
|
|
2515
2525
|
},
|
|
2526
|
+
{
|
|
2527
|
+
key: "fulltext.sources.ncbi_email",
|
|
2528
|
+
type: "string",
|
|
2529
|
+
description: "Email for NCBI E-utilities",
|
|
2530
|
+
optional: true
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
key: "fulltext.sources.ncbi_tool",
|
|
2534
|
+
type: "string",
|
|
2535
|
+
description: "Tool name for NCBI E-utilities",
|
|
2536
|
+
optional: true
|
|
2537
|
+
},
|
|
2516
2538
|
// attachments section
|
|
2517
2539
|
{ key: "attachments.directory", type: "string", description: "Attachments storage directory" },
|
|
2518
2540
|
// cli section
|
|
@@ -3468,9 +3490,6 @@ const alternateScreen = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.def
|
|
|
3468
3490
|
restoreStdinAfterInk,
|
|
3469
3491
|
withAlternateScreen
|
|
3470
3492
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3471
|
-
function getDefaultExportFromCjs(x) {
|
|
3472
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3473
|
-
}
|
|
3474
3493
|
var jsxRuntime = { exports: {} };
|
|
3475
3494
|
var reactJsxRuntime_production = {};
|
|
3476
3495
|
/**
|
|
@@ -6919,7 +6938,7 @@ function formatEditOutput(result) {
|
|
|
6919
6938
|
}
|
|
6920
6939
|
async function executeInteractiveEdit(options, context, config2) {
|
|
6921
6940
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
6922
|
-
const { selectReferencesOrExit } = await import("./reference-select-
|
|
6941
|
+
const { selectReferencesOrExit } = await import("./reference-select-CogjIATu.js");
|
|
6923
6942
|
const allReferences = await context.library.getAll();
|
|
6924
6943
|
const identifiers = await withAlternateScreen2(
|
|
6925
6944
|
() => selectReferencesOrExit(allReferences, { multiSelect: true }, config2.cli.tui)
|
|
@@ -10247,23 +10266,25 @@ async function fulltextDetach(library, options) {
|
|
|
10247
10266
|
function buildFilePath(attachmentsDirectory, directory, filename) {
|
|
10248
10267
|
return join(attachmentsDirectory, directory, filename);
|
|
10249
10268
|
}
|
|
10250
|
-
function determineTypeToOpen(attachments) {
|
|
10269
|
+
function determineTypeToOpen(attachments, preferredType) {
|
|
10251
10270
|
const files = findFulltextFiles(attachments);
|
|
10252
10271
|
if (files.length === 0) return void 0;
|
|
10253
|
-
const
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
if (
|
|
10272
|
+
const hasPdf = files.some((f) => f.filename.endsWith(".pdf"));
|
|
10273
|
+
const hasMd = files.some((f) => f.filename.endsWith(".md"));
|
|
10274
|
+
if (preferredType === "markdown" && hasMd) return "markdown";
|
|
10275
|
+
if (preferredType === "pdf" && hasPdf) return "pdf";
|
|
10276
|
+
if (hasPdf) return "pdf";
|
|
10277
|
+
if (hasMd) return "markdown";
|
|
10257
10278
|
return void 0;
|
|
10258
10279
|
}
|
|
10259
10280
|
async function fulltextOpen(library, options) {
|
|
10260
|
-
const { identifier, type: type2, idType = "id", fulltextDirectory } = options;
|
|
10281
|
+
const { identifier, type: type2, preferredType, idType = "id", fulltextDirectory } = options;
|
|
10261
10282
|
const item = await library.find(identifier, { idType });
|
|
10262
10283
|
if (!item) {
|
|
10263
10284
|
return { success: false, error: `Reference not found: ${identifier}` };
|
|
10264
10285
|
}
|
|
10265
10286
|
const attachments = item.custom?.attachments;
|
|
10266
|
-
const typeToOpen = type2 ?? determineTypeToOpen(attachments);
|
|
10287
|
+
const typeToOpen = type2 ?? determineTypeToOpen(attachments, preferredType);
|
|
10267
10288
|
if (!typeToOpen) {
|
|
10268
10289
|
return { success: false, error: `No fulltext attached to reference: ${identifier}` };
|
|
10269
10290
|
}
|
|
@@ -10309,6 +10330,7 @@ async function executeFulltextGet(options, context) {
|
|
|
10309
10330
|
const operationOptions = {
|
|
10310
10331
|
identifier: options.identifier,
|
|
10311
10332
|
type: options.type,
|
|
10333
|
+
preferredType: options.preferredType,
|
|
10312
10334
|
stdout: options.stdout,
|
|
10313
10335
|
idType: options.idType,
|
|
10314
10336
|
fulltextDirectory: options.fulltextDirectory
|
|
@@ -10329,6 +10351,7 @@ async function executeFulltextOpen(options, context) {
|
|
|
10329
10351
|
const operationOptions = {
|
|
10330
10352
|
identifier: options.identifier,
|
|
10331
10353
|
type: options.type,
|
|
10354
|
+
preferredType: options.preferredType,
|
|
10332
10355
|
idType: options.idType,
|
|
10333
10356
|
fulltextDirectory: options.fulltextDirectory
|
|
10334
10357
|
};
|
|
@@ -10456,7 +10479,7 @@ function getFulltextExitCode(result) {
|
|
|
10456
10479
|
}
|
|
10457
10480
|
async function executeInteractiveSelect$1(context, config2) {
|
|
10458
10481
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
10459
|
-
const { selectReferencesOrExit } = await import("./reference-select-
|
|
10482
|
+
const { selectReferencesOrExit } = await import("./reference-select-CogjIATu.js");
|
|
10460
10483
|
const allReferences = await context.library.getAll();
|
|
10461
10484
|
const identifiers = await withAlternateScreen2(
|
|
10462
10485
|
() => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
|
|
@@ -10552,13 +10575,15 @@ async function handleFulltextGetAction(identifierArg, options, globalOpts) {
|
|
|
10552
10575
|
}
|
|
10553
10576
|
identifier = stdinId;
|
|
10554
10577
|
}
|
|
10578
|
+
const preferValue = options.prefer ?? config2.fulltext.preferredType;
|
|
10555
10579
|
const getOptions = {
|
|
10556
10580
|
identifier,
|
|
10557
10581
|
fulltextDirectory: config2.attachments.directory,
|
|
10558
10582
|
...options.pdf && { type: "pdf" },
|
|
10559
10583
|
...options.markdown && { type: "markdown" },
|
|
10560
10584
|
...options.stdout && { stdout: options.stdout },
|
|
10561
|
-
...options.uuid && { idType: "uuid" }
|
|
10585
|
+
...options.uuid && { idType: "uuid" },
|
|
10586
|
+
...preferValue && { preferredType: preferValue }
|
|
10562
10587
|
};
|
|
10563
10588
|
const result = await executeFulltextGet(getOptions, context);
|
|
10564
10589
|
outputFulltextGetResult(result, Boolean(options.stdout));
|
|
@@ -10629,12 +10654,14 @@ async function handleFulltextOpenAction(identifierArg, options, globalOpts) {
|
|
|
10629
10654
|
}
|
|
10630
10655
|
identifier = stdinId;
|
|
10631
10656
|
}
|
|
10657
|
+
const preferValue = options.prefer ?? config2.fulltext.preferredType;
|
|
10632
10658
|
const openOptions = {
|
|
10633
10659
|
identifier,
|
|
10634
10660
|
fulltextDirectory: config2.attachments.directory,
|
|
10635
10661
|
...options.pdf && { type: "pdf" },
|
|
10636
10662
|
...options.markdown && { type: "markdown" },
|
|
10637
|
-
...options.uuid && { idType: "uuid" }
|
|
10663
|
+
...options.uuid && { idType: "uuid" },
|
|
10664
|
+
...preferValue && { preferredType: preferValue }
|
|
10638
10665
|
};
|
|
10639
10666
|
const result = await executeFulltextOpen(openOptions, context);
|
|
10640
10667
|
const output = formatFulltextOpenOutput(result);
|
|
@@ -31377,9 +31404,11 @@ function registerFulltextGetTool(server, getLibraryOperations, getConfig) {
|
|
|
31377
31404
|
async (args) => {
|
|
31378
31405
|
const libraryOps = getLibraryOperations();
|
|
31379
31406
|
const config2 = getConfig();
|
|
31407
|
+
const preferredType = config2.fulltext?.preferredType;
|
|
31380
31408
|
const pathResult = await fulltextGet(libraryOps, {
|
|
31381
31409
|
identifier: args.id,
|
|
31382
|
-
fulltextDirectory: config2.attachments.directory
|
|
31410
|
+
fulltextDirectory: config2.attachments.directory,
|
|
31411
|
+
...preferredType && { preferredType }
|
|
31383
31412
|
});
|
|
31384
31413
|
if (!pathResult.success) {
|
|
31385
31414
|
return {
|
|
@@ -31493,7 +31522,7 @@ function registerFulltextFetchTool(server, getLibraryOperations, getConfig) {
|
|
|
31493
31522
|
server.registerTool(
|
|
31494
31523
|
"fulltext_fetch",
|
|
31495
31524
|
{
|
|
31496
|
-
description: "Download and attach Open Access full-text for a reference. Automatically discovers OA sources, downloads PDF/XML, converts PMC XML to Markdown, and attaches files.",
|
|
31525
|
+
description: "Download and attach Open Access full-text for a reference. Automatically discovers OA sources, downloads PDF/XML/HTML, converts PMC XML and arXiv HTML to Markdown, and attaches files.",
|
|
31497
31526
|
inputSchema: {
|
|
31498
31527
|
id: z.string().describe("Reference ID"),
|
|
31499
31528
|
source: z.enum(["pmc", "arxiv", "unpaywall", "core"]).optional().describe("Preferred source (optional)"),
|
|
@@ -31750,7 +31779,7 @@ async function mcpStart(options) {
|
|
|
31750
31779
|
async function executeRemove(options, context) {
|
|
31751
31780
|
const { identifier, idType = "id", fulltextDirectory, deleteFulltext = false } = options;
|
|
31752
31781
|
if (context.mode === "local" && deleteFulltext && fulltextDirectory) {
|
|
31753
|
-
const { removeReference } = await import("./index-
|
|
31782
|
+
const { removeReference } = await import("./index-eZatWPDi.js").then((n) => n.w);
|
|
31754
31783
|
return removeReference(context.library, {
|
|
31755
31784
|
identifier,
|
|
31756
31785
|
idType,
|
|
@@ -31805,7 +31834,7 @@ Continue?`;
|
|
|
31805
31834
|
}
|
|
31806
31835
|
async function executeInteractiveRemove(context, config2) {
|
|
31807
31836
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
31808
|
-
const { selectReferenceItemsOrExit } = await import("./reference-select-
|
|
31837
|
+
const { selectReferenceItemsOrExit } = await import("./reference-select-CogjIATu.js");
|
|
31809
31838
|
const allReferences = await context.library.getAll();
|
|
31810
31839
|
const selectedItems = await withAlternateScreen2(
|
|
31811
31840
|
() => selectReferenceItemsOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
|
|
@@ -32030,7 +32059,7 @@ async function executeInteractiveSearch(options, context, config2) {
|
|
|
32030
32059
|
validateInteractiveOptions(options);
|
|
32031
32060
|
const { checkTTY } = await import("./tty-BMyaEOhX.js");
|
|
32032
32061
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
32033
|
-
const { runSearchFlow } = await import("./index-
|
|
32062
|
+
const { runSearchFlow } = await import("./index-BSWbcT3c.js");
|
|
32034
32063
|
const { search } = await import("./file-watcher-Dyns9dxx.js").then((n) => n.B);
|
|
32035
32064
|
const { tokenize } = await import("./file-watcher-Dyns9dxx.js").then((n) => n.A);
|
|
32036
32065
|
checkTTY();
|
|
@@ -32049,7 +32078,7 @@ async function executeInteractiveSearch(options, context, config2) {
|
|
|
32049
32078
|
})
|
|
32050
32079
|
);
|
|
32051
32080
|
if (result.selectedItems && !result.cancelled) {
|
|
32052
|
-
const { isSideEffectAction } = await import("./action-menu-
|
|
32081
|
+
const { isSideEffectAction } = await import("./action-menu-C0-X1ndf.js");
|
|
32053
32082
|
if (isSideEffectAction(result.action)) {
|
|
32054
32083
|
await executeSideEffectAction(result.action, result.selectedItems, context, config2);
|
|
32055
32084
|
return { output: "", cancelled: false, action: result.action };
|
|
@@ -32065,7 +32094,7 @@ async function executeSideEffectAction(action, items2, context, config2) {
|
|
|
32065
32094
|
switch (action) {
|
|
32066
32095
|
case "open-url": {
|
|
32067
32096
|
const { resolveDefaultUrl: resolveDefaultUrl2 } = await Promise.resolve().then(() => url);
|
|
32068
|
-
const { openWithSystemApp: openWithSystemApp2 } = await import("./loader-
|
|
32097
|
+
const { openWithSystemApp: openWithSystemApp2 } = await import("./loader-CzviN_sy.js").then((n) => n.j);
|
|
32069
32098
|
const item = items2[0];
|
|
32070
32099
|
if (!item) return;
|
|
32071
32100
|
const url$1 = resolveDefaultUrl2(item);
|
|
@@ -32452,7 +32481,7 @@ function formatUpdateOutput(result, identifier) {
|
|
|
32452
32481
|
}
|
|
32453
32482
|
async function executeInteractiveUpdate(context, config2) {
|
|
32454
32483
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
32455
|
-
const { selectReferencesOrExit } = await import("./reference-select-
|
|
32484
|
+
const { selectReferencesOrExit } = await import("./reference-select-CogjIATu.js");
|
|
32456
32485
|
const allReferences = await context.library.getAll();
|
|
32457
32486
|
const identifiers = await withAlternateScreen2(
|
|
32458
32487
|
() => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
|
|
@@ -32747,7 +32776,7 @@ function getUrlExitCode(result) {
|
|
|
32747
32776
|
}
|
|
32748
32777
|
async function executeInteractiveSelect(context, config2) {
|
|
32749
32778
|
const { withAlternateScreen: withAlternateScreen2 } = await Promise.resolve().then(() => alternateScreen);
|
|
32750
|
-
const { selectReferencesOrExit } = await import("./reference-select-
|
|
32779
|
+
const { selectReferencesOrExit } = await import("./reference-select-CogjIATu.js");
|
|
32751
32780
|
const allReferences = await context.library.getAll();
|
|
32752
32781
|
const identifiers = await withAlternateScreen2(
|
|
32753
32782
|
() => selectReferencesOrExit(allReferences, { multiSelect: false }, config2.cli.tui)
|
|
@@ -33250,7 +33279,7 @@ function shouldAutoFetch(cliFlag, configEnabled) {
|
|
|
33250
33279
|
return configEnabled;
|
|
33251
33280
|
}
|
|
33252
33281
|
async function performAutoFetch(addedItems, context, config2) {
|
|
33253
|
-
const { fulltextFetch: fulltextFetch2 } = await import("./index-
|
|
33282
|
+
const { fulltextFetch: fulltextFetch2 } = await import("./index-eZatWPDi.js").then((n) => n.v);
|
|
33254
33283
|
const fetchResults = await autoFetchFulltext(addedItems, context, {
|
|
33255
33284
|
fulltextConfig: config2.fulltext,
|
|
33256
33285
|
fulltextDirectory: config2.attachments.directory,
|
|
@@ -33471,13 +33500,17 @@ function registerFulltextCommand(program) {
|
|
|
33471
33500
|
fulltextCmd.command("attach").description("Attach a full-text file to a reference").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").argument("[file-path]", "Path to the file to attach").option("--pdf [path]", "Attach as PDF (path optional if provided as argument)").option("--markdown [path]", "Attach as Markdown (path optional if provided as argument)").option("--move", "Move file instead of copy").option("-f, --force", "Overwrite existing attachment").option("--uuid", "Interpret identifier as UUID").action(async (identifier, filePath, options) => {
|
|
33472
33501
|
await handleFulltextAttachAction(identifier, filePath, options, program.opts());
|
|
33473
33502
|
});
|
|
33474
|
-
fulltextCmd.command("get").description("Get full-text file path or content").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--pdf", "Get PDF file only").option("--markdown", "Get Markdown file only").
|
|
33503
|
+
fulltextCmd.command("get").description("Get full-text file path or content").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--pdf", "Get PDF file only").option("--markdown", "Get Markdown file only").addOption(
|
|
33504
|
+
new Option("--prefer <type>", "Preferred fulltext type").choices(["pdf", "markdown"])
|
|
33505
|
+
).option("--stdout", "Output file content to stdout").option("--uuid", "Interpret identifier as UUID").action(async (identifier, options) => {
|
|
33475
33506
|
await handleFulltextGetAction(identifier, options, program.opts());
|
|
33476
33507
|
});
|
|
33477
33508
|
fulltextCmd.command("detach").description("Detach full-text file from a reference").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--pdf", "Detach PDF only").option("--markdown", "Detach Markdown only").option("--remove-files", "Also delete the file from disk").option("-f, --force", "Skip confirmation for file removal").option("--uuid", "Interpret identifier as UUID").action(async (identifier, options) => {
|
|
33478
33509
|
await handleFulltextDetachAction(identifier, options, program.opts());
|
|
33479
33510
|
});
|
|
33480
|
-
fulltextCmd.command("open").description("Open full-text file with system default application").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--pdf", "Open PDF file").option("--markdown", "Open Markdown file").
|
|
33511
|
+
fulltextCmd.command("open").description("Open full-text file with system default application").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--pdf", "Open PDF file").option("--markdown", "Open Markdown file").addOption(
|
|
33512
|
+
new Option("--prefer <type>", "Preferred fulltext type").choices(["pdf", "markdown"])
|
|
33513
|
+
).option("--uuid", "Interpret identifier as UUID").action(async (identifier, options) => {
|
|
33481
33514
|
await handleFulltextOpenAction(identifier, options, program.opts());
|
|
33482
33515
|
});
|
|
33483
33516
|
fulltextCmd.command("discover").description("Check OA (Open Access) availability for a reference").argument("[identifier]", "Citation key or UUID (interactive selection if omitted)").option("--uuid", "Interpret identifier as UUID").action(async (identifier, options) => {
|
|
@@ -33525,4 +33558,4 @@ export {
|
|
|
33525
33558
|
restoreStdinAfterInk as r,
|
|
33526
33559
|
syncAttachments as s
|
|
33527
33560
|
};
|
|
33528
|
-
//# sourceMappingURL=index-
|
|
33561
|
+
//# sourceMappingURL=index-BrETQT0g.js.map
|