@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 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA"}
@@ -0,0 +1,52 @@
1
+ import type { DatabaseStats, IMemoryStore, MemoryEntry, MemoryOperation, MemoryQuery, QueryOptions } from '@polka-codes/core';
2
+ /**
3
+ * Memory Manager
4
+ *
5
+ * This class provides core memory management logic that is independent
6
+ * of the storage backend. It implements the IMemoryStore interface and
7
+ * delegates storage operations to the provided store implementation.
8
+ *
9
+ * This allows the same business logic to be used with different storage
10
+ * backends (SQLite, PostgreSQL, Redis, etc.)
11
+ */
12
+ export declare class MemoryManager implements IMemoryStore {
13
+ private store;
14
+ constructor(store: IMemoryStore);
15
+ /**
16
+ * Read memory by topic name
17
+ */
18
+ readMemory(topic: string): Promise<string | undefined>;
19
+ /**
20
+ * Update memory with operation
21
+ */
22
+ updateMemory(operation: 'append' | 'replace' | 'remove', topic: string, content: string | undefined, metadata?: {
23
+ entry_type?: string;
24
+ status?: string;
25
+ priority?: string;
26
+ tags?: string;
27
+ created_at?: number;
28
+ updated_at?: number;
29
+ last_accessed?: number;
30
+ }): Promise<void>;
31
+ /**
32
+ * Query memory with filters
33
+ */
34
+ queryMemory(query?: MemoryQuery, options?: QueryOptions): Promise<MemoryEntry[] | number>;
35
+ /**
36
+ * Batch update memory
37
+ */
38
+ batchUpdateMemory(operations: MemoryOperation[]): Promise<void>;
39
+ /**
40
+ * Get database statistics
41
+ */
42
+ getStats(): Promise<DatabaseStats>;
43
+ /**
44
+ * Close the memory store
45
+ */
46
+ close(): Promise<void>;
47
+ /**
48
+ * Execute a transaction
49
+ * Exposes the underlying store's transaction method if available
50
+ */
51
+ transaction<T>(callback: () => Promise<T>): Promise<T>;
52
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Memory Manager
3
+ *
4
+ * This class provides core memory management logic that is independent
5
+ * of the storage backend. It implements the IMemoryStore interface and
6
+ * delegates storage operations to the provided store implementation.
7
+ *
8
+ * This allows the same business logic to be used with different storage
9
+ * backends (SQLite, PostgreSQL, Redis, etc.)
10
+ */
11
+ export class MemoryManager {
12
+ store;
13
+ constructor(store) {
14
+ this.store = store;
15
+ }
16
+ /**
17
+ * Read memory by topic name
18
+ */
19
+ async readMemory(topic) {
20
+ return this.store.readMemory(topic);
21
+ }
22
+ /**
23
+ * Update memory with operation
24
+ */
25
+ async updateMemory(operation, topic, content, metadata) {
26
+ return this.store.updateMemory(operation, topic, content, metadata);
27
+ }
28
+ /**
29
+ * Query memory with filters
30
+ */
31
+ async queryMemory(query = {}, options) {
32
+ // Apply default safety limit if not specified
33
+ const finalQuery = {
34
+ ...query,
35
+ };
36
+ // Only apply default limit for select operations, and if no explicit limit is set
37
+ // Skip for count, delete operations or when limit is explicitly set
38
+ const operation = options?.operation;
39
+ if ((operation === 'select' || !operation) && !finalQuery.limit) {
40
+ finalQuery.limit = 1000;
41
+ }
42
+ return this.store.queryMemory(finalQuery, options);
43
+ }
44
+ /**
45
+ * Batch update memory
46
+ */
47
+ async batchUpdateMemory(operations) {
48
+ return this.store.batchUpdateMemory(operations);
49
+ }
50
+ /**
51
+ * Get database statistics
52
+ */
53
+ async getStats() {
54
+ return this.store.getStats();
55
+ }
56
+ /**
57
+ * Close the memory store
58
+ */
59
+ async close() {
60
+ await this.store.close();
61
+ }
62
+ /**
63
+ * Execute a transaction
64
+ * Exposes the underlying store's transaction method if available
65
+ */
66
+ async transaction(callback) {
67
+ // Check if the underlying store supports transactions
68
+ const storeWithTransaction = this.store;
69
+ if (typeof storeWithTransaction.transaction === 'function') {
70
+ return storeWithTransaction.transaction(callback);
71
+ }
72
+ // If no transaction support, run the callback directly
73
+ return callback();
74
+ }
75
+ }
76
+ //# sourceMappingURL=memory-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-manager.js","sourceRoot":"","sources":["../src/memory-manager.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAChB,KAAK,CAAc;IAE3B,YAAY,KAAmB;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,K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,WAAW,KAAK,UAAU,EAAE,CAAC;YAC3D,OAAO,oBAAoB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACnD,CAAC;QACD,uDAAuD;QACvD,OAAO,QAAQ,EAAE,CAAA;IACnB,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Detect project scope from current working directory
3
+ *
4
+ * This function determines whether we're in a project directory or global scope.
5
+ * It looks for common project markers (.git, package.json, etc.) to identify the project root.
6
+ *
7
+ * @param cwd - Current working directory
8
+ * @returns A scope string ('global' or 'project:/absolute/path')
9
+ */
10
+ export declare function detectProjectScope(cwd: string): string;
@@ -0,0 +1,67 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, normalize, resolve, sep } from 'node:path';
3
+ /**
4
+ * Detect project scope from current working directory
5
+ *
6
+ * This function determines whether we're in a project directory or global scope.
7
+ * It looks for common project markers (.git, package.json, etc.) to identify the project root.
8
+ *
9
+ * @param cwd - Current working directory
10
+ * @returns A scope string ('global' or 'project:/absolute/path')
11
+ */
12
+ export function detectProjectScope(cwd) {
13
+ const projectPath = findProjectRoot(cwd);
14
+ if (!projectPath) {
15
+ return 'global';
16
+ }
17
+ const normalizedPath = normalizePath(projectPath);
18
+ return `project:${normalizedPath}`;
19
+ }
20
+ /**
21
+ * Find the project root directory by looking for common project markers
22
+ */
23
+ function findProjectRoot(dir) {
24
+ // Check if we're still in a valid directory
25
+ if (!existsSync(dir)) {
26
+ return null;
27
+ }
28
+ // Common project markers in priority order
29
+ const primaryMarkers = ['.git', 'package.json'];
30
+ const secondaryMarkers = [
31
+ 'Cargo.toml', // Rust
32
+ 'go.mod', // Go
33
+ 'pyproject.toml', // Python
34
+ 'requirements.txt', // Python
35
+ 'setup.py', // Python
36
+ 'Gemfile', // Ruby
37
+ 'pom.xml', // Java Maven
38
+ 'build.gradle', // Java Gradle
39
+ ];
40
+ // Check primary markers first
41
+ for (const marker of primaryMarkers) {
42
+ if (existsSync(resolve(dir, marker))) {
43
+ return dir;
44
+ }
45
+ }
46
+ // Check secondary markers
47
+ for (const marker of secondaryMarkers) {
48
+ if (existsSync(resolve(dir, marker))) {
49
+ return dir;
50
+ }
51
+ }
52
+ // Check if we've reached the filesystem root
53
+ const parent = dirname(dir);
54
+ if (parent === dir) {
55
+ return null;
56
+ }
57
+ // Recurse up the directory tree
58
+ return findProjectRoot(parent);
59
+ }
60
+ /**
61
+ * Normalize path to use forward slashes for consistency across platforms
62
+ */
63
+ function normalizePath(path) {
64
+ // Normalize path separators to forward slashes for consistency
65
+ return normalize(path).split(sep).join('/');
66
+ }
67
+ //# sourceMappingURL=project-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-scope.js","sourceRoot":"","sources":["../src/project-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE5D;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;IAExC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;IACjD,OAAO,WAAW,cAAc,EAAE,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,GAAW;IAClC,4CAA4C;IAC5C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,2CAA2C;IAC3C,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC/C,MAAM,gBAAgB,GAAG;QACvB,YAAY,EAAE,OAAO;QACrB,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,SAAS;QAC3B,kBAAkB,EAAE,SAAS;QAC7B,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,OAAO;QAClB,SAAS,EAAE,aAAa;QACxB,cAAc,EAAE,cAAc;KAC/B,CAAA;IAED,8BAA8B;IAC9B,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACrC,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACrC,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;IAED,6CAA6C;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IAC3B,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,gCAAgC;IAChC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,+DAA+D;IAC/D,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7C,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { LanguageModelV3 } from '@ai-sdk/provider';
2
+ import type { IMemoryStore, TodoItem, ToolProvider } from '@polka-codes/core';
3
+ export interface ProviderDataStore<T> {
4
+ read(): Promise<T | undefined>;
5
+ write(data: T): Promise<void>;
6
+ }
7
+ export interface TodoItemStore {
8
+ read(): Promise<TodoItem[]>;
9
+ write(data: TodoItem[]): Promise<void>;
10
+ }
11
+ export declare class InMemoryStore<T> implements ProviderDataStore<T> {
12
+ #private;
13
+ read(): Promise<T | undefined>;
14
+ write(data: T): Promise<void>;
15
+ }
16
+ export type ProviderOptions = {
17
+ command?: {
18
+ onStarted(command: string): void;
19
+ onStdout(data: string): void;
20
+ onStderr(data: string): void;
21
+ onExit(code: number): void;
22
+ onError(error: unknown): void;
23
+ };
24
+ excludeFiles?: string[];
25
+ summarizeOutput?: (stdout: string, stderr: string) => Promise<string | undefined>;
26
+ summaryThreshold?: number;
27
+ memoryStore?: ProviderDataStore<Record<string, string>> | IMemoryStore;
28
+ todoItemStore?: ProviderDataStore<TodoItem[]>;
29
+ getModel?: (command: string) => LanguageModelV3 | undefined;
30
+ yes?: boolean;
31
+ };
32
+ export declare const getProvider: (options?: ProviderOptions) => ToolProvider;
@@ -0,0 +1,366 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { mkdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
3
+ import { dirname, normalize, resolve } from 'node:path';
4
+ import { vertex } from '@ai-sdk/google-vertex';
5
+ import { input, select } from '@inquirer/prompts';
6
+ import { generateText, stepCountIs } from 'ai';
7
+ import ignore from 'ignore';
8
+ import { lookup } from 'mime-types';
9
+ import { checkRipgrep } from './utils/checkRipgrep';
10
+ import { listFiles } from './utils/listFiles';
11
+ import { searchFiles } from './utils/searchFiles';
12
+ export class InMemoryStore {
13
+ #data;
14
+ async read() {
15
+ return this.#data;
16
+ }
17
+ async write(data) {
18
+ this.#data = data;
19
+ }
20
+ }
21
+ /**
22
+ * Helper function to detect if memoryStore is an IMemoryStore
23
+ */
24
+ function isIMemoryStore(store) {
25
+ return 'readMemory' in store && 'updateMemory' in store;
26
+ }
27
+ export const getProvider = (options = {}) => {
28
+ const ig = ignore().add(options.excludeFiles ?? []);
29
+ const memoryStore = options.memoryStore ?? new InMemoryStore();
30
+ const todoItemStore = options.todoItemStore ?? new InMemoryStore();
31
+ const defaultMemoryTopic = ':default:';
32
+ const searchModel = options.getModel?.('search');
33
+ // Helper functions for memory operations that work with both store types
34
+ const readMemoryKV = async (topic) => {
35
+ if (!isIMemoryStore(memoryStore)) {
36
+ const data = (await memoryStore.read()) ?? {};
37
+ return data[topic];
38
+ }
39
+ // For IMemoryStore, topic is the "name" parameter
40
+ return memoryStore.readMemory(topic);
41
+ };
42
+ const updateMemoryKV = async (operation, topic, content) => {
43
+ if (!isIMemoryStore(memoryStore)) {
44
+ const data = (await memoryStore.read()) ?? {};
45
+ switch (operation) {
46
+ case 'append':
47
+ if (content === undefined) {
48
+ throw new Error('Content is required for append operation.');
49
+ }
50
+ data[topic] = `${data[topic] || ''}\n${content}`;
51
+ break;
52
+ case 'replace':
53
+ if (content === undefined) {
54
+ throw new Error('Content is required for replace operation.');
55
+ }
56
+ data[topic] = content;
57
+ break;
58
+ case 'remove':
59
+ delete data[topic];
60
+ break;
61
+ }
62
+ await memoryStore.write(data);
63
+ return;
64
+ }
65
+ // Use IMemoryStore API
66
+ await memoryStore.updateMemory(operation, topic, content);
67
+ };
68
+ const listMemoryTopicsKV = async () => {
69
+ if (!isIMemoryStore(memoryStore)) {
70
+ const data = (await memoryStore.read()) ?? {};
71
+ return Object.keys(data);
72
+ }
73
+ // For IMemoryStore, we need to query for all names in the current scope
74
+ const entries = await memoryStore.queryMemory({});
75
+ if (Array.isArray(entries)) {
76
+ return entries.map((e) => e.name);
77
+ }
78
+ return [];
79
+ };
80
+ const provider = {
81
+ listTodoItems: async (id, status) => {
82
+ const todoItems = (await todoItemStore.read()) ?? [];
83
+ let items;
84
+ if (!id) {
85
+ items = todoItems.filter((i) => !i.id.includes('.'));
86
+ }
87
+ else {
88
+ const parent = todoItems.find((i) => i.id === id);
89
+ if (!parent) {
90
+ throw new Error(`To-do item with id ${id} not found`);
91
+ }
92
+ items = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split('.').length === id.split('.').length + 1);
93
+ }
94
+ if (status) {
95
+ items = items.filter((item) => item.status === status);
96
+ }
97
+ items.sort((a, b) => {
98
+ const aParts = a.id.split('.');
99
+ const bParts = b.id.split('.');
100
+ const len = Math.min(aParts.length, bParts.length);
101
+ for (let i = 0; i < len; i++) {
102
+ const comparison = aParts[i].localeCompare(bParts[i], undefined, { numeric: true });
103
+ if (comparison !== 0) {
104
+ return comparison;
105
+ }
106
+ }
107
+ return aParts.length - bParts.length;
108
+ });
109
+ return items;
110
+ },
111
+ getTodoItem: async (id) => {
112
+ const todoItems = (await todoItemStore.read()) ?? [];
113
+ const item = todoItems.find((i) => i.id === id);
114
+ if (!item) {
115
+ throw new Error(`To-do item with id ${id} not found`);
116
+ }
117
+ const subItems = todoItems
118
+ .filter((i) => i.id.startsWith(`${id}.`) && i.id.split('.').length === id.split('.').length + 1)
119
+ .map(({ id, title }) => ({ id, title }));
120
+ return { ...item, subItems };
121
+ },
122
+ updateTodoItem: async (input) => {
123
+ const todoItems = (await todoItemStore.read()) ?? [];
124
+ if (input.operation === 'add') {
125
+ const { parentId, title, description, status } = input;
126
+ if (!title) {
127
+ throw new Error('Title is required for add operation');
128
+ }
129
+ let newId;
130
+ if (parentId) {
131
+ const parent = todoItems.find((i) => i.id === parentId);
132
+ if (!parent) {
133
+ throw new Error(`Parent to-do item with id ${parentId} not found`);
134
+ }
135
+ const childItems = todoItems.filter((i) => i.id.startsWith(`${parentId}.`) && i.id.split('.').length === parentId.split('.').length + 1);
136
+ const maxId = childItems.reduce((max, item) => {
137
+ const parts = item.id.split('.');
138
+ const lastPart = parseInt(parts[parts.length - 1], 10);
139
+ return Math.max(max, lastPart);
140
+ }, 0);
141
+ newId = `${parentId}.${maxId + 1}`;
142
+ }
143
+ else {
144
+ const rootItems = todoItems.filter((i) => !i.id.includes('.'));
145
+ const maxId = rootItems.reduce((max, item) => {
146
+ const idNum = parseInt(item.id, 10);
147
+ return Math.max(max, idNum);
148
+ }, 0);
149
+ newId = `${maxId + 1}`;
150
+ }
151
+ const newItem = {
152
+ id: newId,
153
+ title,
154
+ description: description ?? '',
155
+ status: status ?? 'open',
156
+ };
157
+ await todoItemStore.write([...todoItems, newItem]);
158
+ return { id: newId };
159
+ }
160
+ else {
161
+ // update
162
+ const { id } = input;
163
+ if (!id) {
164
+ throw new Error('ID is required for update operation');
165
+ }
166
+ const item = todoItems.find((i) => i.id === id);
167
+ if (!item) {
168
+ throw new Error(`To-do item with id ${id} not found`);
169
+ }
170
+ if (input.title != null) {
171
+ item.title = input.title;
172
+ }
173
+ if (input.description != null) {
174
+ item.description = input.description ?? '';
175
+ }
176
+ if (input.status != null) {
177
+ item.status = input.status;
178
+ }
179
+ await todoItemStore.write(todoItems);
180
+ return { id };
181
+ }
182
+ },
183
+ listMemoryTopics: async () => {
184
+ return listMemoryTopicsKV();
185
+ },
186
+ readMemory: async (topic = defaultMemoryTopic) => {
187
+ return readMemoryKV(topic);
188
+ },
189
+ updateMemory: async (operation, topic, content) => {
190
+ const memoryTopic = topic ?? defaultMemoryTopic;
191
+ await updateMemoryKV(operation, memoryTopic, content);
192
+ },
193
+ readFile: async (path, includeIgnored) => {
194
+ if (!includeIgnored && ig.ignores(path)) {
195
+ throw new Error(`Not allow to access file ${path}`);
196
+ }
197
+ try {
198
+ return await readFile(path, 'utf8');
199
+ }
200
+ catch (_e) {
201
+ return undefined;
202
+ }
203
+ },
204
+ writeFile: async (path, content) => {
205
+ if (ig.ignores(path)) {
206
+ throw new Error(`Not allow to access file ${path}`);
207
+ }
208
+ // generate parent directories if they don't exist
209
+ await mkdir(dirname(path), { recursive: true });
210
+ return await writeFile(path, content, 'utf8');
211
+ },
212
+ removeFile: async (path) => {
213
+ if (ig.ignores(path)) {
214
+ throw new Error(`Not allow to access file ${path}`);
215
+ }
216
+ return await unlink(path);
217
+ },
218
+ renameFile: async (sourcePath, targetPath) => {
219
+ if (ig.ignores(sourcePath) || ig.ignores(targetPath)) {
220
+ throw new Error(`Not allow to access file ${sourcePath} or ${targetPath}`);
221
+ }
222
+ return await rename(sourcePath, targetPath);
223
+ },
224
+ listFiles: async (path, recursive, maxCount, includeIgnored) => {
225
+ return await listFiles(path, recursive, maxCount, process.cwd(), options.excludeFiles, includeIgnored);
226
+ },
227
+ readBinaryFile: async (url) => {
228
+ if (url.startsWith('file://')) {
229
+ const filePath = decodeURIComponent(url.substring('file://'.length));
230
+ const resolvedPath = normalize(resolve(process.cwd(), filePath));
231
+ if (!resolvedPath.startsWith(process.cwd())) {
232
+ throw new Error(`Access to file path "${filePath}" is restricted.`);
233
+ }
234
+ const data = await readFile(resolvedPath);
235
+ const mediaType = lookup(resolvedPath) || 'application/octet-stream';
236
+ return {
237
+ base64Data: data.toString('base64'),
238
+ mediaType,
239
+ };
240
+ }
241
+ const response = await fetch(url);
242
+ if (!response.ok) {
243
+ throw new Error(`HTTP error! status: ${response.status}`);
244
+ }
245
+ const data = await response.arrayBuffer();
246
+ const mediaType = lookup(url) || 'application/octet-stream';
247
+ return {
248
+ base64Data: Buffer.from(data).toString('base64'),
249
+ mediaType,
250
+ };
251
+ },
252
+ executeCommand: (command, _needApprove) => {
253
+ // TODO: add timeout
254
+ return new Promise((resolve, reject) => {
255
+ // spawn a shell to execute the command
256
+ options.command?.onStarted(command);
257
+ const child = spawn(command, [], {
258
+ shell: true,
259
+ stdio: 'pipe',
260
+ });
261
+ let stdoutText = '';
262
+ let stderrText = '';
263
+ child.stdout.on('data', (data) => {
264
+ const dataStr = data.toString();
265
+ options.command?.onStdout(dataStr);
266
+ stdoutText += dataStr;
267
+ });
268
+ child.stderr.on('data', (data) => {
269
+ const dataStr = data.toString();
270
+ options.command?.onStderr(dataStr);
271
+ stderrText += dataStr;
272
+ });
273
+ child.on('close', async (code) => {
274
+ options.command?.onExit(code ?? 0);
275
+ const totalLength = stdoutText.length + stderrText.length;
276
+ if (totalLength > (options.summaryThreshold ?? 5000) && options.summarizeOutput) {
277
+ try {
278
+ const summary = await options.summarizeOutput(stdoutText, stderrText);
279
+ if (summary) {
280
+ resolve({
281
+ summary,
282
+ stdout: stdoutText,
283
+ stderr: stderrText,
284
+ exitCode: code ?? 0,
285
+ });
286
+ return;
287
+ }
288
+ }
289
+ catch (_e) {
290
+ console.error('Summarization failed:', _e);
291
+ }
292
+ }
293
+ resolve({
294
+ stdout: stdoutText,
295
+ stderr: stderrText,
296
+ exitCode: code ?? 0,
297
+ });
298
+ });
299
+ child.on('error', (err) => {
300
+ options.command?.onError(err);
301
+ reject(err);
302
+ });
303
+ });
304
+ },
305
+ askFollowupQuestion: async (question, answerOptions) => {
306
+ if (options.yes) {
307
+ if (answerOptions.length > 0) {
308
+ return answerOptions[0];
309
+ }
310
+ return '';
311
+ }
312
+ if (answerOptions.length === 0) {
313
+ return await input({ message: question });
314
+ }
315
+ const otherMessage = 'Other (enter text)';
316
+ answerOptions.push(otherMessage);
317
+ const answer = await select({
318
+ message: question,
319
+ choices: answerOptions.map((option) => ({ name: option, value: option })),
320
+ });
321
+ if (answer === otherMessage) {
322
+ return await input({ message: 'Enter your answer:' });
323
+ }
324
+ return answer;
325
+ },
326
+ fetchUrl: async (url) => {
327
+ const isRaw = url.startsWith('https://raw.githubusercontent.com/');
328
+ const urlToFetch = isRaw ? url : `https://r.jina.ai/${url}`;
329
+ try {
330
+ const response = await fetch(urlToFetch);
331
+ if (!response.ok) {
332
+ throw new Error(`HTTP error! status: ${response.status}`);
333
+ }
334
+ return await response.text();
335
+ }
336
+ catch (error) {
337
+ console.error('Error fetching URL:', error);
338
+ throw error;
339
+ }
340
+ },
341
+ search: searchModel &&
342
+ (async (query) => {
343
+ const googleSearchTool = vertex.tools.googleSearch({});
344
+ const resp = await generateText({
345
+ model: searchModel,
346
+ system: 'You are a web search assistant. When searching for information, provide comprehensive and detailed results. Include relevant facts, statistics, dates, and key details from the search results. Synthesize information from multiple sources when available. Structure your response clearly with the most relevant information first. Reference or cite sources when presenting specific claims or data.',
347
+ tools: {
348
+ google_search: googleSearchTool,
349
+ },
350
+ prompt: query,
351
+ stopWhen: stepCountIs(5),
352
+ });
353
+ return resp.text;
354
+ }),
355
+ };
356
+ if (checkRipgrep()) {
357
+ provider.searchFiles = async (path, regex, filePattern) => {
358
+ return await searchFiles(path, regex, filePattern, process.cwd(), options.excludeFiles);
359
+ };
360
+ }
361
+ else {
362
+ console.error('Error: ripgrep (rg) is not installed. Search file tool is disabled. Please install it from https://github.com/BurntSushi/ripgrep#installation');
363
+ }
364
+ return provider;
365
+ };
366
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAA;AAC9C,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAYjD,MAAM,OAAO,aAAa;IACxB,KAAK,CAAe;IAEpB,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAO;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;CACF;AAkBD;;GAEG;AACH,SAAS,cAAc,CAAC,KAA+D;IACrF,OAAO,YAAY,IAAI,KAAK,IAAI,cAAc,IAAI,KAAK,CAAA;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,W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