codesession-cli 1.0.0 → 1.2.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/src/watcher.ts DELETED
@@ -1,52 +0,0 @@
1
- import chokidar from 'chokidar';
2
- import { relative } from 'path';
3
- import { addFileChange } from './db';
4
-
5
- let watcher: chokidar.FSWatcher | null = null;
6
- const changedFiles = new Set<string>();
7
-
8
- export function startWatcher(sessionId: number, cwd: string): void {
9
- if (watcher) return;
10
-
11
- watcher = chokidar.watch(cwd, {
12
- ignored: /(^|[\/\\])\..|(node_modules|dist|build|\.git)/,
13
- persistent: true,
14
- ignoreInitial: true,
15
- });
16
-
17
- watcher
18
- .on('add', (path) => handleChange(sessionId, path, cwd, 'created'))
19
- .on('change', (path) => handleChange(sessionId, path, cwd, 'modified'))
20
- .on('unlink', (path) => handleChange(sessionId, path, cwd, 'deleted'));
21
- }
22
-
23
- export function stopWatcher(): void {
24
- if (watcher) {
25
- watcher.close();
26
- watcher = null;
27
- changedFiles.clear();
28
- }
29
- }
30
-
31
- function handleChange(
32
- sessionId: number,
33
- path: string,
34
- cwd: string,
35
- changeType: 'created' | 'modified' | 'deleted'
36
- ): void {
37
- const relativePath = relative(cwd, path);
38
-
39
- // Deduplicate rapid changes to same file
40
- const key = `${relativePath}-${changeType}`;
41
- if (changedFiles.has(key)) return;
42
-
43
- changedFiles.add(key);
44
- setTimeout(() => changedFiles.delete(key), 1000);
45
-
46
- addFileChange({
47
- sessionId,
48
- filePath: relativePath,
49
- changeType,
50
- timestamp: new Date().toISOString(),
51
- });
52
- }
package/test.ts DELETED
@@ -1,4 +0,0 @@
1
- // Test file to trigger file watcher
2
- export function hello() {
3
- return 'Hello from test!';
4
- }
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "sourceMap": true,
16
- "moduleResolution": "node"
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist"]
20
- }