@ncukondo/reference-manager 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +267 -109
  2. package/dist/chunks/file-watcher-B-SiUw5f.js +1557 -0
  3. package/dist/chunks/file-watcher-B-SiUw5f.js.map +1 -0
  4. package/dist/chunks/{search-Be9vzUIH.js → index-DLIGxQaB.js} +399 -89
  5. package/dist/chunks/index-DLIGxQaB.js.map +1 -0
  6. package/dist/chunks/loader-DuzyKV70.js +394 -0
  7. package/dist/chunks/loader-DuzyKV70.js.map +1 -0
  8. package/dist/cli/commands/add.d.ts +3 -3
  9. package/dist/cli/commands/add.d.ts.map +1 -1
  10. package/dist/cli/commands/cite.d.ts +3 -3
  11. package/dist/cli/commands/cite.d.ts.map +1 -1
  12. package/dist/cli/commands/fulltext.d.ts +5 -34
  13. package/dist/cli/commands/fulltext.d.ts.map +1 -1
  14. package/dist/cli/commands/list.d.ts +3 -3
  15. package/dist/cli/commands/list.d.ts.map +1 -1
  16. package/dist/cli/commands/mcp.d.ts +16 -0
  17. package/dist/cli/commands/mcp.d.ts.map +1 -0
  18. package/dist/cli/commands/remove.d.ts +3 -3
  19. package/dist/cli/commands/remove.d.ts.map +1 -1
  20. package/dist/cli/commands/search.d.ts +3 -3
  21. package/dist/cli/commands/search.d.ts.map +1 -1
  22. package/dist/cli/commands/server.d.ts +2 -0
  23. package/dist/cli/commands/server.d.ts.map +1 -1
  24. package/dist/cli/commands/update.d.ts +3 -3
  25. package/dist/cli/commands/update.d.ts.map +1 -1
  26. package/dist/cli/execution-context.d.ts +23 -36
  27. package/dist/cli/execution-context.d.ts.map +1 -1
  28. package/dist/cli/index.d.ts.map +1 -1
  29. package/dist/cli/server-client.d.ts +24 -40
  30. package/dist/cli/server-client.d.ts.map +1 -1
  31. package/dist/cli/server-detection.d.ts +1 -0
  32. package/dist/cli/server-detection.d.ts.map +1 -1
  33. package/dist/cli.js +21060 -317
  34. package/dist/cli.js.map +1 -1
  35. package/dist/config/defaults.d.ts.map +1 -1
  36. package/dist/config/loader.d.ts.map +1 -1
  37. package/dist/config/schema.d.ts +2 -3
  38. package/dist/config/schema.d.ts.map +1 -1
  39. package/dist/core/csl-json/types.d.ts +3 -0
  40. package/dist/core/csl-json/types.d.ts.map +1 -1
  41. package/dist/core/library-interface.d.ts +100 -0
  42. package/dist/core/library-interface.d.ts.map +1 -0
  43. package/dist/core/library.d.ts +29 -46
  44. package/dist/core/library.d.ts.map +1 -1
  45. package/dist/features/operations/add.d.ts +2 -2
  46. package/dist/features/operations/add.d.ts.map +1 -1
  47. package/dist/features/operations/cite.d.ts +2 -2
  48. package/dist/features/operations/cite.d.ts.map +1 -1
  49. package/dist/features/operations/fulltext/attach.d.ts +47 -0
  50. package/dist/features/operations/fulltext/attach.d.ts.map +1 -0
  51. package/dist/features/operations/fulltext/detach.d.ts +38 -0
  52. package/dist/features/operations/fulltext/detach.d.ts.map +1 -0
  53. package/dist/features/operations/fulltext/get.d.ts +41 -0
  54. package/dist/features/operations/fulltext/get.d.ts.map +1 -0
  55. package/dist/features/operations/fulltext/index.d.ts +9 -0
  56. package/dist/features/operations/fulltext/index.d.ts.map +1 -0
  57. package/dist/features/operations/index.d.ts +15 -0
  58. package/dist/features/operations/index.d.ts.map +1 -0
  59. package/dist/features/operations/library-operations.d.ts +64 -0
  60. package/dist/features/operations/library-operations.d.ts.map +1 -0
  61. package/dist/features/operations/list.d.ts +2 -2
  62. package/dist/features/operations/list.d.ts.map +1 -1
  63. package/dist/features/operations/operations-library.d.ts +36 -0
  64. package/dist/features/operations/operations-library.d.ts.map +1 -0
  65. package/dist/features/operations/remove.d.ts +4 -4
  66. package/dist/features/operations/remove.d.ts.map +1 -1
  67. package/dist/features/operations/search.d.ts +2 -2
  68. package/dist/features/operations/search.d.ts.map +1 -1
  69. package/dist/features/operations/update.d.ts +2 -2
  70. package/dist/features/operations/update.d.ts.map +1 -1
  71. package/dist/features/search/matcher.d.ts.map +1 -1
  72. package/dist/features/search/normalizer.d.ts +12 -0
  73. package/dist/features/search/normalizer.d.ts.map +1 -1
  74. package/dist/features/search/tokenizer.d.ts.map +1 -1
  75. package/dist/features/search/types.d.ts +1 -1
  76. package/dist/features/search/types.d.ts.map +1 -1
  77. package/dist/features/search/uppercase.d.ts +41 -0
  78. package/dist/features/search/uppercase.d.ts.map +1 -0
  79. package/dist/index.js +24 -192
  80. package/dist/index.js.map +1 -1
  81. package/dist/mcp/context.d.ts +19 -0
  82. package/dist/mcp/context.d.ts.map +1 -0
  83. package/dist/mcp/index.d.ts +20 -0
  84. package/dist/mcp/index.d.ts.map +1 -0
  85. package/dist/mcp/resources/index.d.ts +10 -0
  86. package/dist/mcp/resources/index.d.ts.map +1 -0
  87. package/dist/mcp/resources/library.d.ts +26 -0
  88. package/dist/mcp/resources/library.d.ts.map +1 -0
  89. package/dist/mcp/tools/add.d.ts +17 -0
  90. package/dist/mcp/tools/add.d.ts.map +1 -0
  91. package/dist/mcp/tools/cite.d.ts +15 -0
  92. package/dist/mcp/tools/cite.d.ts.map +1 -0
  93. package/dist/mcp/tools/fulltext.d.ts +51 -0
  94. package/dist/mcp/tools/fulltext.d.ts.map +1 -0
  95. package/dist/mcp/tools/index.d.ts +12 -0
  96. package/dist/mcp/tools/index.d.ts.map +1 -0
  97. package/dist/mcp/tools/list.d.ts +13 -0
  98. package/dist/mcp/tools/list.d.ts.map +1 -0
  99. package/dist/mcp/tools/remove.d.ts +19 -0
  100. package/dist/mcp/tools/remove.d.ts.map +1 -0
  101. package/dist/mcp/tools/search.d.ts +13 -0
  102. package/dist/mcp/tools/search.d.ts.map +1 -0
  103. package/dist/server/index.d.ts +23 -1
  104. package/dist/server/index.d.ts.map +1 -1
  105. package/dist/server/routes/references.d.ts.map +1 -1
  106. package/dist/server.js +5 -271
  107. package/dist/server.js.map +1 -1
  108. package/package.json +2 -1
  109. package/dist/chunks/detector-DHztTaFY.js +0 -619
  110. package/dist/chunks/detector-DHztTaFY.js.map +0 -1
  111. package/dist/chunks/loader-mQ25o6cV.js +0 -1054
  112. package/dist/chunks/loader-mQ25o6cV.js.map +0 -1
  113. package/dist/chunks/search-Be9vzUIH.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import type { CslItem } from "../../core/csl-json/types.js";
2
2
  import type { FulltextType } from "../../features/fulltext/index.js";
3
- import { type RemoveResult } from "../../features/operations/remove.js";
3
+ import type { RemoveResult } from "../../features/operations/remove.js";
4
4
  import type { ExecutionContext } from "../execution-context.js";
5
5
  /**
6
6
  * Options for the remove command.
@@ -15,10 +15,10 @@ export interface RemoveCommandOptions {
15
15
  export type RemoveCommandResult = RemoveResult;
16
16
  /**
17
17
  * Execute remove command.
18
- * Routes to server API or direct library operation based on execution context.
18
+ * Uses context.library.remove() which works for both local and server modes.
19
19
  *
20
20
  * @param options - Remove command options
21
- * @param context - Execution context (server or local)
21
+ * @param context - Execution context
22
22
  * @returns Remove result
23
23
  */
24
24
  export declare function executeRemove(options: RemoveCommandOptions, context: ExecutionContext): Promise<RemoveCommandResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/remove.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,qCAAqC,CAAC;AACzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,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AC,IAAI,EAAE,OAAO,GAAG,YAAY,EAAE,CAYxE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAInE;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBjG"}
@@ -1,4 +1,4 @@
1
- import { type SearchResult } from "../../features/operations/search.js";
1
+ import type { SearchResult } from "../../features/operations/search.js";
2
2
  import type { ExecutionContext } from "../execution-context.js";
3
3
  /**
4
4
  * Options for the search command.
@@ -16,10 +16,10 @@ export interface SearchCommandOptions {
16
16
  export type SearchCommandResult = SearchResult;
17
17
  /**
18
18
  * Execute search command.
19
- * Routes to server API or direct library operation based on execution context.
19
+ * Uses context.library.search() which works for both local and server modes.
20
20
  *
21
21
  * @param options - Search command options
22
- * @param context - Execution context (server or local)
22
+ * @param context - Execution context
23
23
  * @returns Search result containing formatted items
24
24
  */
25
25
  export declare function executeSearch(options: SearchCommandOptions, context: ExecutionContext): Promise<SearchCommandResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC;AA4B/C;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAW9B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAKtE"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC;AA4B/C;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAK9B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAKtE"}
@@ -1,8 +1,10 @@
1
+ import type { Config } from "../../config/schema.js";
1
2
  export interface ServerStartOptions {
2
3
  port?: number;
3
4
  daemon?: boolean;
4
5
  library: string;
5
6
  portfilePath: string;
7
+ config: Config;
6
8
  }
7
9
  export interface ServerInfo {
8
10
  port: number;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/server.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO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AY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA0BnF"}
@@ -1,5 +1,5 @@
1
1
  import type { CslItem } from "../../core/csl-json/types.js";
2
- import { type UpdateOperationResult } from "../../features/operations/update.js";
2
+ import type { UpdateOperationResult } from "../../features/operations/update.js";
3
3
  import type { ExecutionContext } from "../execution-context.js";
4
4
  /**
5
5
  * Options for the update command.
@@ -15,10 +15,10 @@ export interface UpdateCommandOptions {
15
15
  export type UpdateCommandResult = UpdateOperationResult;
16
16
  /**
17
17
  * Execute update command.
18
- * Routes to server API or direct library operation based on execution context.
18
+ * Uses context.library.update() which works for both local and server modes.
19
19
  *
20
20
  * @param options - Update command options
21
- * @param context - Execution context (server or local)
21
+ * @param context - Execution context
22
22
  * @returns Update result
23
23
  */
24
24
  export declare function executeUpdate(options: UpdateCommandOptions, context: ExecutionContext): Promise<UpdateCommandResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,KAAK,qBAAqB,EAAmB,MAAM,qCAAqC,CAAC;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAU9B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAsB1F"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAExD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAI9B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAsB1F"}
@@ -1,60 +1,47 @@
1
1
  /**
2
2
  * Execution Context for CLI Commands
3
3
  *
4
- * Provides a discriminated union type to distinguish between server and local execution modes.
5
- * This enables CLI commands to avoid redundant library loading when a server is available.
4
+ * Provides a unified interface for CLI commands to interact with the library,
5
+ * regardless of whether running in local or server mode.
6
+ *
7
+ * See: spec/decisions/ADR-009-ilibrary-operations-pattern.md
6
8
  */
7
9
  import type { Config } from "../config/schema.js";
8
10
  import type { Library } from "../core/library.js";
9
- import { ServerClient } from "./server-client.js";
10
- /**
11
- * Server execution context - uses ServerClient for operations
12
- */
13
- export interface ServerExecutionContext {
14
- type: "server";
15
- client: ServerClient;
16
- }
11
+ import type { ILibraryOperations } from "../features/operations/library-operations.js";
17
12
  /**
18
- * Local execution context - uses Library directly
13
+ * Execution mode indicating whether CLI is using local file access or server API.
19
14
  */
20
- export interface LocalExecutionContext {
21
- type: "local";
22
- library: Library;
23
- }
15
+ export type ExecutionMode = "local" | "server";
24
16
  /**
25
- * Discriminated union type for execution context.
26
- * Commands can use this to determine whether to use server or local operations.
17
+ * Unified execution context for CLI commands.
18
+ *
19
+ * Commands use `context.library` for all operations without needing to branch
20
+ * based on execution mode. The `mode` field is available for diagnostics and logging.
27
21
  *
28
22
  * @example
29
23
  * ```typescript
30
- * if (context.type === "server") {
31
- * // Use context.client for server operations
32
- * const result = await context.client.list(options);
33
- * } else {
34
- * // Use context.library for local operations
35
- * const items = context.library.getAll();
36
- * }
24
+ * // No branching needed - same code works for both modes
25
+ * const results = await context.library.search({ query });
26
+ * console.log(`Mode: ${context.mode}`);
37
27
  * ```
38
28
  */
39
- export type ExecutionContext = ServerExecutionContext | LocalExecutionContext;
29
+ export interface ExecutionContext {
30
+ /** Execution mode for diagnostics and logging */
31
+ mode: ExecutionMode;
32
+ /** Unified operations interface - works for both local and server modes */
33
+ library: ILibraryOperations;
34
+ }
40
35
  /**
41
36
  * Creates an execution context based on the current configuration.
42
37
  *
43
38
  * This function checks for an available server connection first.
44
- * If a server is available, it returns a server context to avoid loading the library.
45
- * Otherwise, it loads the library and returns a local context.
39
+ * If a server is available, it returns a context with ServerClient.
40
+ * Otherwise, it loads the library and returns a context with OperationsLibrary.
46
41
  *
47
42
  * @param config - The application configuration
48
43
  * @param loadLibrary - Function to load the library (injected for testability)
49
- * @returns Promise resolving to either a server or local execution context
44
+ * @returns Promise resolving to an ExecutionContext
50
45
  */
51
46
  export declare function createExecutionContext(config: Config, loadLibrary: (path: string) => Promise<Library>): Promise<ExecutionContext>;
52
- /**
53
- * Type guard to check if context is a server context
54
- */
55
- export declare function isServerContext(context: ExecutionContext): context is ServerExecutionContext;
56
- /**
57
- * Type guard to check if context is a local context
58
- */
59
- export declare function isLocalContext(context: ExecutionContext): context is LocalExecutionContext;
60
47
  //# sourceMappingURL=execution-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../../src/cli/execution-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG,qBAAqB,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAC9C,OAAO,CAAC,gBAAgB,CAAC,CAkB3B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,IAAI,sBAAsB,CAE5F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,IAAI,qBAAqB,CAE1F"}
1
+ {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../../src/cli/execution-context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAKvF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,IAAI,EAAE,aAAa,CAAC;IACpB,2EAA2E;IAC3E,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAC9C,OAAO,CAAC,gBAAgB,CAAC,CAmB3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmDpC;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CA6BvC;AA8tBD;;GAEG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAaxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoDpC;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CA8BvC;AAkwBD;;GAEG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAaxD"}
@@ -1,17 +1,6 @@
1
1
  import type { CslItem } from "../core/csl-json/types.js";
2
- import type { AddReferencesResult } from "../features/operations/add.js";
3
- import type { CiteResult } from "../features/operations/cite.js";
4
- import type { ListOptions, ListResult } from "../features/operations/list.js";
5
- import type { RemoveResult } from "../features/operations/remove.js";
6
- import type { SearchOperationOptions, SearchResult } from "../features/operations/search.js";
7
- import type { UpdateOperationResult } from "../features/operations/update.js";
8
- /**
9
- * Options for addFromInputs method.
10
- */
11
- export interface AddFromInputsOptions {
12
- force?: boolean;
13
- format?: string;
14
- }
2
+ import type { FindOptions, RemoveResult as ILibraryRemoveResult, RemoveOptions, UpdateOptions, UpdateResult } from "../core/library-interface.js";
3
+ import type { AddReferencesResult, CiteResult, ILibraryOperations, ImportOptions, ListOptions, ListResult, SearchOperationOptions, SearchResult } from "../features/operations/index.js";
15
4
  /**
16
5
  * Options for cite method.
17
6
  */
@@ -27,7 +16,7 @@ export interface CiteOptions {
27
16
  /**
28
17
  * Client for communicating with the reference-manager HTTP server.
29
18
  */
30
- export declare class ServerClient {
19
+ export declare class ServerClient implements ILibraryOperations {
31
20
  private baseUrl;
32
21
  constructor(baseUrl: string);
33
22
  /**
@@ -36,49 +25,44 @@ export declare class ServerClient {
36
25
  */
37
26
  getAll(): Promise<CslItem[]>;
38
27
  /**
39
- * Find reference by identifier.
28
+ * Find reference by citation ID or UUID.
40
29
  * @param identifier - Citation ID or UUID
41
- * @param options - Options object
42
- * @param options.byUuid - If true, treat identifier as UUID; otherwise as citation ID
43
- * @returns CSL item or null if not found
30
+ * @param options - Find options (byUuid to use UUID lookup)
31
+ * @returns CSL item or undefined if not found
44
32
  */
45
- find(identifier: string, options?: {
46
- byUuid?: boolean;
47
- }): Promise<CslItem | null>;
33
+ find(identifier: string, options?: FindOptions): Promise<CslItem | undefined>;
48
34
  /**
49
35
  * Add new reference to the library.
50
36
  * @param item - CSL item to add
51
- * @returns Created CSL item with UUID
37
+ * @returns The added CSL item (with generated ID and UUID)
52
38
  */
53
39
  add(item: CslItem): Promise<CslItem>;
54
40
  /**
55
- * Update existing reference.
41
+ * Update reference by citation ID or UUID.
56
42
  * @param identifier - Citation ID or UUID
57
43
  * @param updates - Partial CSL item with fields to update
58
- * @param options - Options object
59
- * @param options.byUuid - If true, treat identifier as UUID; otherwise as citation ID
60
- * @returns Update operation result
44
+ * @param options - Update options (byUuid to use UUID lookup, onIdCollision for collision handling)
45
+ * @returns Update result with updated item, success status, and any ID changes
61
46
  */
62
- update(identifier: string, updates: Partial<CslItem>, options?: {
63
- byUuid?: boolean;
64
- }): Promise<UpdateOperationResult>;
47
+ update(identifier: string, updates: Partial<CslItem>, options?: UpdateOptions): Promise<UpdateResult>;
65
48
  /**
66
- * Remove reference by identifier.
67
- * @param identifier - Citation ID or UUID
68
- * @param options - Options object
69
- * @param options.byUuid - If true, treat identifier as UUID; otherwise as citation ID
70
- * @returns Remove operation result
49
+ * Remove a reference by citation ID or UUID.
50
+ * @param identifier - The citation ID or UUID of the reference to remove
51
+ * @param options - Remove options (byUuid to use UUID lookup)
52
+ * @returns Remove result with removed status and removedItem
53
+ */
54
+ remove(identifier: string, options?: RemoveOptions): Promise<ILibraryRemoveResult>;
55
+ /**
56
+ * Save is a no-op for ServerClient (HTTP requests are already persisted).
71
57
  */
72
- remove(identifier: string, options?: {
73
- byUuid?: boolean;
74
- }): Promise<RemoveResult>;
58
+ save(): Promise<void>;
75
59
  /**
76
- * Add references from various input formats.
60
+ * Import references from various input formats.
77
61
  * @param inputs - Array of inputs (file paths, PMIDs, DOIs)
78
- * @param options - Options for add operation
62
+ * @param options - Options for import operation
79
63
  * @returns Result containing added, failed, and skipped items
80
64
  */
81
- addFromInputs(inputs: string[], options?: AddFromInputsOptions): Promise<AddReferencesResult>;
65
+ import(inputs: string[], options?: ImportOptions): Promise<AddReferencesResult>;
82
66
  /**
83
67
  * Generate citations for references.
84
68
  * @param options - Cite options including identifiers and formatting
@@ -1 +1 @@
1
- {"version":3,"file":"server-client.d.ts","sourceRoot":"","sources":["../../src/cli/server-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC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MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,YAAa,YAAW,kBAAkB;IACzC,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,MAAM;IAMnC;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAWlC;;;;;OAKG;IACG,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAsBvF;;;;OAIG;IACG,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB1C;;;;;;OAMG;IACG,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EACzB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC;IA0BxB;;;;;OAKG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAyB5F;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAerF;;;;OAIG;IACG,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAerD;;;;OAIG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAetD;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC;CAcrE"}
@@ -15,6 +15,7 @@ export interface ServerConnection {
15
15
  export declare function getServerConnection(libraryPath: string, config: Config): Promise<ServerConnection | null>;
16
16
  /**
17
17
  * Start server in daemon mode.
18
+ * Spawns server process directly (without --daemon flag) in background.
18
19
  * @param libraryPath - Path to the library file
19
20
  * @param _config - Configuration (reserved for future use)
20
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"server-detection.d.ts","sourceRoot":"","sources":["../../src/cli/server-detection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AASlD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmClC;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe3F;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CActE"}
1
+ {"version":3,"file":"server-detection.d.ts","sourceRoot":"","sources":["../../src/cli/server-detection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AASlD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmClC;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3F;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CActE"}