@polka-codes/cli-shared 0.10.1 → 0.10.5

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 (70) hide show
  1. package/dist/config.d.ts +13 -0
  2. package/dist/config.js +202 -0
  3. package/dist/config.js.map +1 -0
  4. package/dist/config.parameters.test.d.ts +1 -0
  5. package/dist/config.parameters.test.js +240 -0
  6. package/dist/config.parameters.test.js.map +1 -0
  7. package/dist/config.rules.test.d.ts +1 -0
  8. package/dist/config.rules.test.js +92 -0
  9. package/dist/config.rules.test.js.map +1 -0
  10. package/dist/config.test.d.ts +1 -0
  11. package/dist/config.test.js +311 -0
  12. package/dist/config.test.js.map +1 -0
  13. package/dist/index.d.ts +6 -0
  14. package/dist/index.js +694 -70817
  15. package/dist/index.js.map +1 -0
  16. package/dist/memory-manager.d.ts +52 -0
  17. package/dist/memory-manager.js +76 -0
  18. package/dist/memory-manager.js.map +1 -0
  19. package/dist/project-scope.d.ts +10 -0
  20. package/dist/project-scope.js +67 -0
  21. package/dist/project-scope.js.map +1 -0
  22. package/dist/provider.d.ts +32 -0
  23. package/dist/provider.js +366 -0
  24. package/dist/provider.js.map +1 -0
  25. package/dist/provider.test.d.ts +1 -0
  26. package/dist/provider.test.js +21 -0
  27. package/dist/provider.test.js.map +1 -0
  28. package/dist/sqlite-memory-store.d.ts +112 -0
  29. package/dist/sqlite-memory-store.js +919 -0
  30. package/dist/sqlite-memory-store.js.map +1 -0
  31. package/dist/sqlite-memory-store.test.d.ts +1 -0
  32. package/dist/sqlite-memory-store.test.js +661 -0
  33. package/dist/sqlite-memory-store.test.js.map +1 -0
  34. package/dist/utils/__tests__/parameterSimplifier.test.d.ts +1 -0
  35. package/dist/utils/__tests__/parameterSimplifier.test.js +137 -0
  36. package/dist/utils/__tests__/parameterSimplifier.test.js.map +1 -0
  37. package/dist/utils/checkRipgrep.d.ts +5 -0
  38. package/dist/utils/checkRipgrep.js +22 -0
  39. package/dist/utils/checkRipgrep.js.map +1 -0
  40. package/dist/utils/eventHandler.d.ts +11 -0
  41. package/dist/utils/eventHandler.js +196 -0
  42. package/dist/utils/eventHandler.js.map +1 -0
  43. package/dist/utils/eventHandler.test.d.ts +1 -0
  44. package/dist/utils/eventHandler.test.js +31 -0
  45. package/dist/utils/eventHandler.test.js.map +1 -0
  46. package/dist/utils/index.d.ts +6 -0
  47. package/dist/utils/index.js +7 -0
  48. package/dist/utils/index.js.map +1 -0
  49. package/dist/utils/listFiles.d.ts +12 -0
  50. package/dist/utils/listFiles.js +136 -0
  51. package/dist/utils/listFiles.js.map +1 -0
  52. package/dist/utils/listFiles.test.d.ts +1 -0
  53. package/dist/utils/listFiles.test.js +64 -0
  54. package/dist/utils/listFiles.test.js.map +1 -0
  55. package/dist/utils/parameterSimplifier.d.ts +1 -0
  56. package/dist/utils/parameterSimplifier.js +65 -0
  57. package/dist/utils/parameterSimplifier.js.map +1 -0
  58. package/dist/utils/readMultiline.d.ts +1 -0
  59. package/dist/utils/readMultiline.js +19 -0
  60. package/dist/utils/readMultiline.js.map +1 -0
  61. package/dist/utils/search.constants.d.ts +7 -0
  62. package/dist/utils/search.constants.js +8 -0
  63. package/dist/utils/search.constants.js.map +1 -0
  64. package/dist/utils/searchFiles.d.ts +12 -0
  65. package/dist/utils/searchFiles.js +72 -0
  66. package/dist/utils/searchFiles.js.map +1 -0
  67. package/dist/utils/searchFiles.test.d.ts +1 -0
  68. package/dist/utils/searchFiles.test.js +140 -0
  69. package/dist/utils/searchFiles.test.js.map +1 -0
  70. package/package.json +2 -2
@@ -0,0 +1,21 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { getProvider } from './provider';
3
+ describe('getProvider', () => {
4
+ describe('askFollowupQuestion', () => {
5
+ it('should return first option when yes is true and options are provided', async () => {
6
+ const provider = getProvider({ yes: true });
7
+ if (!provider.askFollowupQuestion)
8
+ throw new Error('askFollowupQuestion not defined');
9
+ const result = await provider.askFollowupQuestion('Question?', ['Option 1', 'Option 2']);
10
+ expect(result).toBe('Option 1');
11
+ });
12
+ it('should return empty string when yes is true and no options are provided', async () => {
13
+ const provider = getProvider({ yes: true });
14
+ if (!provider.askFollowupQuestion)
15
+ throw new Error('askFollowupQuestion not defined');
16
+ const result = await provider.askFollowupQuestion('Question?', []);
17
+ expect(result).toBe('');
18
+ });
19
+ });
20
+ });
21
+ //# sourceMappingURL=provider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.test.js","sourceRoot":"","sources":["../src/provider.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;YACpF,MAAM,QAAQ,GAAG,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;YAC3C,IAAI,CAAC,QAAQ,CAAC,mBAAmB;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;YACrF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;YACxF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;YACvF,MAAM,QAAQ,GAAG,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;YAC3C,IAAI,CAAC,QAAQ,CAAC,mBAAmB;gBAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;YACrF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;YAClE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,112 @@
1
+ import type { DatabaseStats, IMemoryStore, MemoryConfig, MemoryEntry, MemoryOperation, MemoryQuery, QueryOptions } from '@polka-codes/core';
2
+ export type { MemoryEntry, MemoryQuery, QueryOptions, MemoryOperation };
3
+ export declare class SQLiteMemoryStore implements IMemoryStore {
4
+ private db;
5
+ private dbPromise;
6
+ private config;
7
+ private currentScope;
8
+ private inTransaction;
9
+ private transactionMutex;
10
+ private fileLock;
11
+ /**
12
+ * Reset the lock file cleanup throttle. For testing purposes only.
13
+ */
14
+ static resetCleanupThrottle(): void;
15
+ /**
16
+ * Get the configured database path, or default if not set
17
+ */
18
+ private getDbPath;
19
+ /**
20
+ * Get lockfile instance for database path
21
+ */
22
+ private getFileLock;
23
+ private static readonly SORT_COLUMNS;
24
+ private static readonly ALLOWED_SORT_ORDERS;
25
+ private static readonly ALLOWED_PRIORITIES;
26
+ constructor(config: MemoryConfig, scope: string);
27
+ /**
28
+ * Initialize database connection and schema
29
+ */
30
+ private initializeDatabase;
31
+ /**
32
+ * Persist database to disk using atomic write with file locking
33
+ */
34
+ private saveDatabase;
35
+ /**
36
+ * Configure database pragmas
37
+ */
38
+ private configurePragmas;
39
+ /**
40
+ * Check database integrity
41
+ */
42
+ private checkIntegrity;
43
+ /**
44
+ * Initialize database schema
45
+ */
46
+ private initializeSchema;
47
+ /**
48
+ * Get database instance
49
+ */
50
+ private getDatabase;
51
+ /**
52
+ * Resolve home directory in path using shared utility
53
+ */
54
+ private resolvePath;
55
+ /**
56
+ * Generate UUID v4
57
+ */
58
+ private generateUUID;
59
+ /**
60
+ * Get current timestamp in milliseconds
61
+ */
62
+ private now;
63
+ /**
64
+ * Execute transaction
65
+ * Uses Mutex to serialize concurrent transaction calls for safety
66
+ * Supports reentrancy (nested transactions from the same call chain)
67
+ */
68
+ transaction<T>(callback: () => Promise<T>): Promise<T>;
69
+ /**
70
+ * Read memory by topic
71
+ * Note: Does NOT update last_accessed timestamp to avoid expensive disk writes on every read.
72
+ * The timestamp is updated when memory is modified through updateMemory operations.
73
+ */
74
+ readMemory(topic: string): Promise<string | undefined>;
75
+ /**
76
+ * Internal update memory without transaction (used by batchUpdateMemory)
77
+ */
78
+ private updateMemoryInternal;
79
+ /**
80
+ * Update memory
81
+ */
82
+ updateMemory(operation: 'append' | 'replace' | 'remove', topic: string, content: string | undefined, metadata?: {
83
+ entry_type?: string;
84
+ status?: string;
85
+ priority?: string;
86
+ tags?: string;
87
+ created_at?: number;
88
+ updated_at?: number;
89
+ last_accessed?: number;
90
+ }): Promise<void>;
91
+ /**
92
+ * Query memory with filters
93
+ */
94
+ queryMemory(query?: MemoryQuery, options?: QueryOptions): Promise<MemoryEntry[] | number>;
95
+ /**
96
+ * Build SQL query safely with parameterized statements
97
+ */
98
+ private buildQuery;
99
+ /**
100
+ * Batch update memory
101
+ */
102
+ batchUpdateMemory(operations: MemoryOperation[]): Promise<void>;
103
+ /**
104
+ * Close database connection
105
+ * @param skipSave - If true, skip saving before close (useful when save already failed)
106
+ */
107
+ close(skipSave?: boolean): Promise<void>;
108
+ /**
109
+ * Get database statistics
110
+ */
111
+ getStats(): Promise<DatabaseStats>;
112
+ }