@sudocode-ai/local-server 0.1.7 → 0.1.9
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/README.md +6 -0
- package/dist/errors/agent-errors.d.ts +43 -0
- package/dist/errors/agent-errors.d.ts.map +1 -0
- package/dist/errors/agent-errors.js +69 -0
- package/dist/errors/agent-errors.js.map +1 -0
- package/dist/execution/adapters/claude-adapter.d.ts +63 -0
- package/dist/execution/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/claude-adapter.js +82 -0
- package/dist/execution/adapters/claude-adapter.js.map +1 -0
- package/dist/execution/adapters/codex-adapter.d.ts +67 -0
- package/dist/execution/adapters/codex-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/codex-adapter.js +183 -0
- package/dist/execution/adapters/codex-adapter.js.map +1 -0
- package/dist/execution/adapters/codex-config-builder.d.ts +30 -0
- package/dist/execution/adapters/codex-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/codex-config-builder.js +110 -0
- package/dist/execution/adapters/codex-config-builder.js.map +1 -0
- package/dist/execution/adapters/copilot-adapter.d.ts +94 -0
- package/dist/execution/adapters/copilot-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/copilot-adapter.js +163 -0
- package/dist/execution/adapters/copilot-adapter.js.map +1 -0
- package/dist/execution/adapters/copilot-config-builder.d.ts +48 -0
- package/dist/execution/adapters/copilot-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/copilot-config-builder.js +125 -0
- package/dist/execution/adapters/copilot-config-builder.js.map +1 -0
- package/dist/execution/adapters/cursor-adapter.d.ts +66 -0
- package/dist/execution/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/cursor-adapter.js +121 -0
- package/dist/execution/adapters/cursor-adapter.js.map +1 -0
- package/dist/execution/adapters/cursor-config-builder.d.ts +29 -0
- package/dist/execution/adapters/cursor-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/cursor-config-builder.js +49 -0
- package/dist/execution/adapters/cursor-config-builder.js.map +1 -0
- package/dist/execution/adapters/shared/config-presets.d.ts +102 -0
- package/dist/execution/adapters/shared/config-presets.d.ts.map +1 -0
- package/dist/execution/adapters/shared/config-presets.js +205 -0
- package/dist/execution/adapters/shared/config-presets.js.map +1 -0
- package/dist/execution/adapters/shared/config-utils.d.ts +95 -0
- package/dist/execution/adapters/shared/config-utils.d.ts.map +1 -0
- package/dist/execution/adapters/shared/config-utils.js +163 -0
- package/dist/execution/adapters/shared/config-utils.js.map +1 -0
- package/dist/execution/adapters/shared/index.d.ts +8 -0
- package/dist/execution/adapters/shared/index.d.ts.map +1 -0
- package/dist/execution/adapters/shared/index.js +8 -0
- package/dist/execution/adapters/shared/index.js.map +1 -0
- package/dist/execution/executors/agent-executor-wrapper.d.ts +153 -0
- package/dist/execution/executors/agent-executor-wrapper.d.ts.map +1 -0
- package/dist/execution/executors/agent-executor-wrapper.js +652 -0
- package/dist/execution/executors/agent-executor-wrapper.js.map +1 -0
- package/dist/execution/executors/executor-factory.d.ts +95 -0
- package/dist/execution/executors/executor-factory.d.ts.map +1 -0
- package/dist/execution/executors/executor-factory.js +120 -0
- package/dist/execution/executors/executor-factory.js.map +1 -0
- package/dist/execution/output/ag-ui-adapter.d.ts +0 -2
- package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -1
- package/dist/execution/output/ag-ui-adapter.js +0 -2
- package/dist/execution/output/ag-ui-adapter.js.map +1 -1
- package/dist/execution/output/index.d.ts +0 -3
- package/dist/execution/output/index.d.ts.map +1 -1
- package/dist/execution/output/index.js +0 -2
- package/dist/execution/output/index.js.map +1 -1
- package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts +108 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts.map +1 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.js +321 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.js.map +1 -0
- package/dist/execution/process/builders/claude.d.ts +24 -57
- package/dist/execution/process/builders/claude.d.ts.map +1 -1
- package/dist/execution/process/builders/claude.js +153 -19
- package/dist/execution/process/builders/claude.js.map +1 -1
- package/dist/execution/transport/ipc-transport-manager.d.ts +74 -0
- package/dist/execution/transport/ipc-transport-manager.d.ts.map +1 -0
- package/dist/execution/transport/ipc-transport-manager.js +104 -0
- package/dist/execution/transport/ipc-transport-manager.js.map +1 -0
- package/dist/execution/transport/transport-manager.d.ts.map +1 -1
- package/dist/execution/transport/transport-manager.js +3 -0
- package/dist/execution/transport/transport-manager.js.map +1 -1
- package/dist/execution/worktree/conflict-detector.d.ts +85 -0
- package/dist/execution/worktree/conflict-detector.d.ts.map +1 -0
- package/dist/execution/worktree/conflict-detector.js +129 -0
- package/dist/execution/worktree/conflict-detector.js.map +1 -0
- package/dist/execution/worktree/git-cli.d.ts +9 -0
- package/dist/execution/worktree/git-cli.d.ts.map +1 -1
- package/dist/execution/worktree/git-cli.js +10 -0
- package/dist/execution/worktree/git-cli.js.map +1 -1
- package/dist/execution/worktree/git-sync-cli.d.ts +198 -0
- package/dist/execution/worktree/git-sync-cli.d.ts.map +1 -0
- package/dist/execution/worktree/git-sync-cli.js +401 -0
- package/dist/execution/worktree/git-sync-cli.js.map +1 -0
- package/dist/execution/worktree/manager.d.ts +18 -0
- package/dist/execution/worktree/manager.d.ts.map +1 -1
- package/dist/execution/worktree/manager.js +9 -3
- package/dist/execution/worktree/manager.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +124 -229
- package/dist/index.js.map +1 -1
- package/dist/middleware/project-context.d.ts +37 -0
- package/dist/middleware/project-context.d.ts.map +1 -0
- package/dist/middleware/project-context.js +91 -0
- package/dist/middleware/project-context.js.map +1 -0
- package/dist/public/assets/index-DV9Tbujb.css +1 -0
- package/dist/public/assets/index-DcDX9-Ad.js +740 -0
- package/dist/public/assets/index-DcDX9-Ad.js.map +1 -0
- package/dist/public/assets/{react-vendor-ByUx1V_q.js → react-vendor-DiL5hC7l.js} +2 -2
- package/dist/public/assets/{react-vendor-ByUx1V_q.js.map → react-vendor-DiL5hC7l.js.map} +1 -1
- package/dist/public/assets/ui-vendor-B4WMPEfa.js +54 -0
- package/dist/public/assets/ui-vendor-B4WMPEfa.js.map +1 -0
- package/dist/public/index.html +4 -4
- package/dist/routes/agents.d.ts +3 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +62 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/config.d.ts +3 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +25 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/editors.d.ts +15 -0
- package/dist/routes/editors.d.ts.map +1 -0
- package/dist/routes/editors.js +98 -0
- package/dist/routes/editors.js.map +1 -0
- package/dist/routes/executions-stream.d.ts +8 -5
- package/dist/routes/executions-stream.d.ts.map +1 -1
- package/dist/routes/executions-stream.js +10 -6
- package/dist/routes/executions-stream.js.map +1 -1
- package/dist/routes/executions.d.ts +6 -10
- package/dist/routes/executions.d.ts.map +1 -1
- package/dist/routes/executions.js +792 -37
- package/dist/routes/executions.js.map +1 -1
- package/dist/routes/feedback.d.ts +3 -2
- package/dist/routes/feedback.d.ts.map +1 -1
- package/dist/routes/feedback.js +12 -10
- package/dist/routes/feedback.js.map +1 -1
- package/dist/routes/files.d.ts +18 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +89 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/issues.d.ts +3 -2
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +19 -18
- package/dist/routes/issues.js.map +1 -1
- package/dist/routes/projects.d.ts +11 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +447 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/relationships.d.ts +3 -2
- package/dist/routes/relationships.d.ts.map +1 -1
- package/dist/routes/relationships.js +12 -10
- package/dist/routes/relationships.js.map +1 -1
- package/dist/routes/repo-info.d.ts +3 -0
- package/dist/routes/repo-info.d.ts.map +1 -0
- package/dist/routes/repo-info.js +203 -0
- package/dist/routes/repo-info.js.map +1 -0
- package/dist/routes/specs.d.ts +3 -2
- package/dist/routes/specs.d.ts.map +1 -1
- package/dist/routes/specs.js +19 -18
- package/dist/routes/specs.js.map +1 -1
- package/dist/routes/version.d.ts +3 -0
- package/dist/routes/version.d.ts.map +1 -0
- package/dist/routes/version.js +25 -0
- package/dist/routes/version.js.map +1 -0
- package/dist/services/agent-registry.d.ts +140 -0
- package/dist/services/agent-registry.d.ts.map +1 -0
- package/dist/services/agent-registry.js +272 -0
- package/dist/services/agent-registry.js.map +1 -0
- package/dist/services/editor-service.d.ts +57 -0
- package/dist/services/editor-service.d.ts.map +1 -0
- package/dist/services/editor-service.js +204 -0
- package/dist/services/editor-service.js.map +1 -0
- package/dist/services/execution-changes-service.d.ts +110 -0
- package/dist/services/execution-changes-service.d.ts.map +1 -0
- package/dist/services/execution-changes-service.js +700 -0
- package/dist/services/execution-changes-service.js.map +1 -0
- package/dist/services/execution-lifecycle.d.ts +1 -0
- package/dist/services/execution-lifecycle.d.ts.map +1 -1
- package/dist/services/execution-lifecycle.js +37 -7
- package/dist/services/execution-lifecycle.js.map +1 -1
- package/dist/services/execution-logs-store.d.ts +75 -0
- package/dist/services/execution-logs-store.d.ts.map +1 -1
- package/dist/services/execution-logs-store.js +142 -2
- package/dist/services/execution-logs-store.js.map +1 -1
- package/dist/services/execution-service.d.ts +82 -59
- package/dist/services/execution-service.d.ts.map +1 -1
- package/dist/services/execution-service.js +514 -469
- package/dist/services/execution-service.js.map +1 -1
- package/dist/services/execution-worker-pool.d.ts +116 -0
- package/dist/services/execution-worker-pool.d.ts.map +1 -0
- package/dist/services/execution-worker-pool.js +326 -0
- package/dist/services/execution-worker-pool.js.map +1 -0
- package/dist/services/executions.d.ts +3 -0
- package/dist/services/executions.d.ts.map +1 -1
- package/dist/services/executions.js +11 -17
- package/dist/services/executions.js.map +1 -1
- package/dist/services/export.d.ts +8 -2
- package/dist/services/export.d.ts.map +1 -1
- package/dist/services/export.js +29 -23
- package/dist/services/export.js.map +1 -1
- package/dist/services/file-search/git-ls-files-strategy.d.ts +72 -0
- package/dist/services/file-search/git-ls-files-strategy.d.ts.map +1 -0
- package/dist/services/file-search/git-ls-files-strategy.js +176 -0
- package/dist/services/file-search/git-ls-files-strategy.js.map +1 -0
- package/dist/services/file-search/index.d.ts +9 -0
- package/dist/services/file-search/index.d.ts.map +1 -0
- package/dist/services/file-search/index.js +10 -0
- package/dist/services/file-search/index.js.map +1 -0
- package/dist/services/file-search/registry.d.ts +97 -0
- package/dist/services/file-search/registry.d.ts.map +1 -0
- package/dist/services/file-search/registry.js +140 -0
- package/dist/services/file-search/registry.js.map +1 -0
- package/dist/services/file-search/strategy.d.ts +58 -0
- package/dist/services/file-search/strategy.d.ts.map +1 -0
- package/dist/services/file-search/strategy.js +8 -0
- package/dist/services/file-search/strategy.js.map +1 -0
- package/dist/services/project-context.d.ts +69 -0
- package/dist/services/project-context.d.ts.map +1 -0
- package/dist/services/project-context.js +113 -0
- package/dist/services/project-context.js.map +1 -0
- package/dist/services/project-manager.d.ts +95 -0
- package/dist/services/project-manager.d.ts.map +1 -0
- package/dist/services/project-manager.js +388 -0
- package/dist/services/project-manager.js.map +1 -0
- package/dist/services/project-registry.d.ts +98 -0
- package/dist/services/project-registry.d.ts.map +1 -0
- package/dist/services/project-registry.js +289 -0
- package/dist/services/project-registry.js.map +1 -0
- package/dist/services/prompt-resolver.d.ts +97 -0
- package/dist/services/prompt-resolver.d.ts.map +1 -0
- package/dist/services/prompt-resolver.js +377 -0
- package/dist/services/prompt-resolver.js.map +1 -0
- package/dist/services/repo-info.d.ts +12 -0
- package/dist/services/repo-info.d.ts.map +1 -1
- package/dist/services/repo-info.js +46 -0
- package/dist/services/repo-info.js.map +1 -1
- package/dist/services/version-service.d.ts +14 -0
- package/dist/services/version-service.d.ts.map +1 -0
- package/dist/services/version-service.js +57 -0
- package/dist/services/version-service.js.map +1 -0
- package/dist/services/watcher.d.ts +3 -4
- package/dist/services/watcher.d.ts.map +1 -1
- package/dist/services/watcher.js +18 -35
- package/dist/services/watcher.js.map +1 -1
- package/dist/services/websocket.d.ts +30 -16
- package/dist/services/websocket.d.ts.map +1 -1
- package/dist/services/websocket.js +102 -37
- package/dist/services/websocket.js.map +1 -1
- package/dist/services/worktree-sync-service.d.ts +326 -0
- package/dist/services/worktree-sync-service.d.ts.map +1 -0
- package/dist/services/worktree-sync-service.js +1091 -0
- package/dist/services/worktree-sync-service.js.map +1 -0
- package/dist/types/editor.d.ts +49 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/editor.js +50 -0
- package/dist/types/editor.js.map +1 -0
- package/dist/types/project.d.ts +58 -0
- package/dist/types/project.d.ts.map +1 -0
- package/dist/types/project.js +10 -0
- package/dist/types/project.js.map +1 -0
- package/dist/utils/executable-check.d.ts +36 -0
- package/dist/utils/executable-check.d.ts.map +1 -0
- package/dist/utils/executable-check.js +79 -0
- package/dist/utils/executable-check.js.map +1 -0
- package/dist/workers/execution-worker.d.ts +18 -0
- package/dist/workers/execution-worker.d.ts.map +1 -0
- package/dist/workers/execution-worker.js +340 -0
- package/dist/workers/execution-worker.js.map +1 -0
- package/dist/workers/worker-ipc.d.ts +84 -0
- package/dist/workers/worker-ipc.d.ts.map +1 -0
- package/dist/workers/worker-ipc.js +29 -0
- package/dist/workers/worker-ipc.js.map +1 -0
- package/package.json +6 -5
- package/dist/execution/output/ag-ui-integration.d.ts +0 -96
- package/dist/execution/output/ag-ui-integration.d.ts.map +0 -1
- package/dist/execution/output/ag-ui-integration.js +0 -96
- package/dist/execution/output/ag-ui-integration.js.map +0 -1
- package/dist/execution/output/claude-code-output-processor.d.ts +0 -321
- package/dist/execution/output/claude-code-output-processor.d.ts.map +0 -1
- package/dist/execution/output/claude-code-output-processor.js +0 -769
- package/dist/execution/output/claude-code-output-processor.js.map +0 -1
- package/dist/public/assets/index-B3SEMufD.js +0 -580
- package/dist/public/assets/index-B3SEMufD.js.map +0 -1
- package/dist/public/assets/index-D2YGL3gX.css +0 -1
- package/dist/public/assets/ui-vendor-CotR6bx9.js +0 -54
- package/dist/public/assets/ui-vendor-CotR6bx9.js.map +0 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Executions service - database operations for agent executions
|
|
3
3
|
*/
|
|
4
4
|
import { randomUUID } from "crypto";
|
|
5
|
-
import { broadcastExecutionUpdate } from "./websocket.js";
|
|
6
5
|
/**
|
|
7
6
|
* Create a new execution
|
|
8
7
|
*/
|
|
@@ -34,17 +33,16 @@ export function createExecution(db, input) {
|
|
|
34
33
|
target_branch,
|
|
35
34
|
branch_name,
|
|
36
35
|
worktree_path,
|
|
36
|
+
parent_execution_id,
|
|
37
37
|
created_at,
|
|
38
38
|
updated_at
|
|
39
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
39
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
40
40
|
`);
|
|
41
|
-
stmt.run(id, input.issue_id, issue_uuid, input.agent_type, input.mode || null, input.prompt || null, input.config || null, "running", now, input.before_commit || null, input.target_branch, input.branch_name, input.worktree_path || null, now, now);
|
|
41
|
+
stmt.run(id, input.issue_id, issue_uuid, input.agent_type, input.mode || null, input.prompt || null, input.config || null, "running", now, input.before_commit || null, input.target_branch, input.branch_name, input.worktree_path || null, input.parent_execution_id || null, now, now);
|
|
42
42
|
const execution = getExecution(db, id);
|
|
43
43
|
if (!execution) {
|
|
44
44
|
throw new Error(`Failed to create execution with id ${id}`);
|
|
45
45
|
}
|
|
46
|
-
// Broadcast to execution subscribers AND issue subscribers (dual broadcast)
|
|
47
|
-
broadcastExecutionUpdate(execution.id, "created", execution, execution.issue_id || undefined);
|
|
48
46
|
return execution;
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
@@ -94,6 +92,10 @@ export function updateExecution(db, id, input) {
|
|
|
94
92
|
updates.push("error_message = ?");
|
|
95
93
|
values.push(input.error_message);
|
|
96
94
|
}
|
|
95
|
+
if (input.before_commit !== undefined) {
|
|
96
|
+
updates.push("before_commit = ?");
|
|
97
|
+
values.push(input.before_commit);
|
|
98
|
+
}
|
|
97
99
|
if (input.after_commit !== undefined) {
|
|
98
100
|
updates.push("after_commit = ?");
|
|
99
101
|
values.push(input.after_commit);
|
|
@@ -114,6 +116,10 @@ export function updateExecution(db, id, input) {
|
|
|
114
116
|
updates.push("summary = ?");
|
|
115
117
|
values.push(input.summary);
|
|
116
118
|
}
|
|
119
|
+
if (input.files_changed !== undefined) {
|
|
120
|
+
updates.push("files_changed = ?");
|
|
121
|
+
values.push(input.files_changed);
|
|
122
|
+
}
|
|
117
123
|
// Always update updated_at
|
|
118
124
|
updates.push("updated_at = ?");
|
|
119
125
|
values.push(new Date().toISOString());
|
|
@@ -132,28 +138,16 @@ export function updateExecution(db, id, input) {
|
|
|
132
138
|
if (!updated) {
|
|
133
139
|
throw new Error(`Failed to update execution ${id}`);
|
|
134
140
|
}
|
|
135
|
-
// Determine action type based on what changed
|
|
136
|
-
const statusChanged = input.status !== undefined &&
|
|
137
|
-
execution.status !== input.status;
|
|
138
|
-
const action = statusChanged ? "status_changed" : "updated";
|
|
139
|
-
// Broadcast to both execution and issue subscribers
|
|
140
|
-
broadcastExecutionUpdate(updated.id, action, updated, updated.issue_id || undefined);
|
|
141
141
|
return updated;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Delete an execution
|
|
145
145
|
*/
|
|
146
146
|
export function deleteExecution(db, id) {
|
|
147
|
-
// Get execution before deletion to access issue_id for broadcast
|
|
148
|
-
const execution = getExecution(db, id);
|
|
149
147
|
const stmt = db.prepare(`
|
|
150
148
|
DELETE FROM executions WHERE id = ?
|
|
151
149
|
`);
|
|
152
150
|
const result = stmt.run(id);
|
|
153
|
-
// Broadcast deletion if execution existed
|
|
154
|
-
if (result.changes > 0 && execution) {
|
|
155
|
-
broadcastExecutionUpdate(id, "deleted", { id }, execution.issue_id || undefined);
|
|
156
|
-
}
|
|
157
151
|
return result.changes > 0;
|
|
158
152
|
}
|
|
159
153
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executions.js","sourceRoot":"","sources":["../../src/services/executions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"executions.js","sourceRoot":"","sources":["../../src/services/executions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAoCpC;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,EAAqB,EACrB,KAA2B;IAE3B,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE,CAAC;IACpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAErC,yCAAyC;IACzC,IAAI,UAAU,GAAkB,IAAI,CAAC;IACrC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,EAAE;aACb,OAAO,CAAC,sCAAsC,CAAC;aAC/C,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAiC,CAAC;QACvD,IAAI,KAAK,EAAE,CAAC;YACV,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;GAmBvB,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CACN,EAAE,EACF,KAAK,CAAC,QAAQ,EACd,UAAU,EACV,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,IAAI,IAAI,IAAI,EAClB,KAAK,CAAC,MAAM,IAAI,IAAI,EACpB,KAAK,CAAC,MAA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,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAAqB,EAAE,EAAU;IAC/D,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;GAEvB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAE5B,OAAO,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,EAAqB,EACrB,MAAwB;IAExB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;;KAIvB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAgB,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;KAGvB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,GAAG,EAAiB,CAAC;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -5,12 +5,15 @@ import type Database from "better-sqlite3";
|
|
|
5
5
|
/**
|
|
6
6
|
* Sync a single entity to its markdown file
|
|
7
7
|
*/
|
|
8
|
-
export declare function syncEntityToMarkdown(db: Database.Database, entityId: string, entityType: "spec" | "issue"): Promise<void>;
|
|
8
|
+
export declare function syncEntityToMarkdown(db: Database.Database, entityId: string, entityType: "spec" | "issue", outputDir?: string): Promise<void>;
|
|
9
9
|
/**
|
|
10
10
|
* Trigger an export to JSONL and Markdown files (debounced)
|
|
11
11
|
* This should be called after any database modifications
|
|
12
|
+
*
|
|
13
|
+
* @param db - Database instance
|
|
14
|
+
* @param outputDir - Optional output directory (defaults to getSudocodeDir())
|
|
12
15
|
*/
|
|
13
|
-
export declare function triggerExport(db: Database.Database): void;
|
|
16
|
+
export declare function triggerExport(db: Database.Database, outputDir?: string): void;
|
|
14
17
|
/**
|
|
15
18
|
* Execute export immediately (bypass debouncing)
|
|
16
19
|
* Exports to both JSONL and Markdown files
|
|
@@ -19,6 +22,9 @@ export declare function executeExportNow(db: Database.Database): Promise<void>;
|
|
|
19
22
|
/**
|
|
20
23
|
* Cleanup the export debouncer (cancel pending exports and reset)
|
|
21
24
|
* Should be called when closing the database or during test cleanup
|
|
25
|
+
*
|
|
26
|
+
* Note: With WeakMap-based debouncers, this is now a no-op since
|
|
27
|
+
* debouncers are automatically garbage collected when the database is closed
|
|
22
28
|
*/
|
|
23
29
|
export declare function cleanupExport(): void;
|
|
24
30
|
//# sourceMappingURL=export.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAkD3C;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GAAG,OAAO,EAC5B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAsB7E;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
package/dist/services/export.js
CHANGED
|
@@ -5,20 +5,21 @@ import { exportToJSONL } from "@sudocode-ai/cli/dist/export.js";
|
|
|
5
5
|
import { syncJSONLToMarkdown } from "@sudocode-ai/cli/dist/sync.js";
|
|
6
6
|
import { getSudocodeDir } from "../utils/sudocode-dir.js";
|
|
7
7
|
import * as path from "path";
|
|
8
|
-
// Global debouncer state
|
|
9
|
-
|
|
8
|
+
// Global debouncer state (keyed by database instance)
|
|
9
|
+
const exportDebouncers = new WeakMap();
|
|
10
10
|
/**
|
|
11
|
-
* Initialize or get the export debouncer
|
|
11
|
+
* Initialize or get the export debouncer for a specific database
|
|
12
12
|
*/
|
|
13
13
|
function getExportDebouncer(db) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
let debouncer = exportDebouncers.get(db);
|
|
15
|
+
if (!debouncer) {
|
|
16
|
+
debouncer = {
|
|
17
17
|
timeoutId: null,
|
|
18
18
|
pending: false,
|
|
19
19
|
};
|
|
20
|
+
exportDebouncers.set(db, debouncer);
|
|
20
21
|
}
|
|
21
|
-
return
|
|
22
|
+
return debouncer;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Execute the full export (JSONL only)
|
|
@@ -26,10 +27,10 @@ function getExportDebouncer(db) {
|
|
|
26
27
|
* Markdown updates should happen through the watcher's reverse sync if enabled,
|
|
27
28
|
* or through explicit sync commands.
|
|
28
29
|
*/
|
|
29
|
-
async function executeFullExport(db) {
|
|
30
|
-
const
|
|
30
|
+
async function executeFullExport(db, outputDir) {
|
|
31
|
+
const dir = outputDir || getSudocodeDir();
|
|
31
32
|
// Export to JSONL only
|
|
32
|
-
await exportToJSONL(db, { outputDir });
|
|
33
|
+
await exportToJSONL(db, { outputDir: dir });
|
|
33
34
|
// Note: We don't sync to markdown here because:
|
|
34
35
|
// 1. It would update ALL markdown files on every change (inefficient)
|
|
35
36
|
// 2. The watcher can handle reverse sync if enabled (JSONL → Markdown)
|
|
@@ -39,13 +40,13 @@ async function executeFullExport(db) {
|
|
|
39
40
|
/**
|
|
40
41
|
* Sync a single entity to its markdown file
|
|
41
42
|
*/
|
|
42
|
-
export async function syncEntityToMarkdown(db, entityId, entityType) {
|
|
43
|
-
const
|
|
43
|
+
export async function syncEntityToMarkdown(db, entityId, entityType, outputDir) {
|
|
44
|
+
const dir = outputDir || getSudocodeDir();
|
|
44
45
|
if (entityType === "issue") {
|
|
45
46
|
const { getIssueById } = await import("./issues.js");
|
|
46
47
|
const issue = getIssueById(db, entityId);
|
|
47
48
|
if (issue) {
|
|
48
|
-
const mdPath = path.join(
|
|
49
|
+
const mdPath = path.join(dir, "issues", `${issue.id}.md`);
|
|
49
50
|
await syncJSONLToMarkdown(db, issue.id, "issue", mdPath);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -54,8 +55,8 @@ export async function syncEntityToMarkdown(db, entityId, entityType) {
|
|
|
54
55
|
const spec = getSpecById(db, entityId);
|
|
55
56
|
if (spec) {
|
|
56
57
|
const mdPath = spec.file_path
|
|
57
|
-
? path.join(
|
|
58
|
-
: path.join(
|
|
58
|
+
? path.join(dir, spec.file_path)
|
|
59
|
+
: path.join(dir, "specs", `${spec.id}.md`);
|
|
59
60
|
await syncJSONLToMarkdown(db, spec.id, "spec", mdPath);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -63,16 +64,22 @@ export async function syncEntityToMarkdown(db, entityId, entityType) {
|
|
|
63
64
|
/**
|
|
64
65
|
* Trigger an export to JSONL and Markdown files (debounced)
|
|
65
66
|
* This should be called after any database modifications
|
|
67
|
+
*
|
|
68
|
+
* @param db - Database instance
|
|
69
|
+
* @param outputDir - Optional output directory (defaults to getSudocodeDir())
|
|
66
70
|
*/
|
|
67
|
-
export function triggerExport(db) {
|
|
71
|
+
export function triggerExport(db, outputDir) {
|
|
68
72
|
const debouncer = getExportDebouncer(db);
|
|
69
73
|
debouncer.pending = true;
|
|
74
|
+
if (outputDir) {
|
|
75
|
+
debouncer.outputDir = outputDir;
|
|
76
|
+
}
|
|
70
77
|
if (debouncer.timeoutId) {
|
|
71
78
|
clearTimeout(debouncer.timeoutId);
|
|
72
79
|
}
|
|
73
80
|
debouncer.timeoutId = setTimeout(async () => {
|
|
74
81
|
try {
|
|
75
|
-
await executeFullExport(db);
|
|
82
|
+
await executeFullExport(db, debouncer.outputDir);
|
|
76
83
|
}
|
|
77
84
|
catch (error) {
|
|
78
85
|
console.error("Export failed:", error);
|
|
@@ -94,13 +101,12 @@ export async function executeExportNow(db) {
|
|
|
94
101
|
/**
|
|
95
102
|
* Cleanup the export debouncer (cancel pending exports and reset)
|
|
96
103
|
* Should be called when closing the database or during test cleanup
|
|
104
|
+
*
|
|
105
|
+
* Note: With WeakMap-based debouncers, this is now a no-op since
|
|
106
|
+
* debouncers are automatically garbage collected when the database is closed
|
|
97
107
|
*/
|
|
98
108
|
export function cleanupExport() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
clearTimeout(exportDebouncer.timeoutId);
|
|
102
|
-
}
|
|
103
|
-
exportDebouncer = null;
|
|
104
|
-
}
|
|
109
|
+
// No-op: debouncers are now per-database and will be GC'd automatically
|
|
110
|
+
// Kept for backward compatibility
|
|
105
111
|
}
|
|
106
112
|
//# sourceMappingURL=export.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OA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H,MAAM,iBAAiB,CAAC,EAAE,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;gBAAS,CAAC;YACT,+CAA+C;YAC/C,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;YAC1B,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,oBAAoB;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EAAqB;IAC1D,MAAM,iBAAiB,CAAC,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,wEAAwE;IACxE,kCAAkC;AACpC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git ls-files search strategy
|
|
3
|
+
*
|
|
4
|
+
* Uses `git ls-files` command to search for files in a git repository.
|
|
5
|
+
* This strategy respects .gitignore and is fast for git repositories.
|
|
6
|
+
*/
|
|
7
|
+
import type { FileSearchStrategy, FileSearchOptions, FileSearchResult } from "./strategy.js";
|
|
8
|
+
/**
|
|
9
|
+
* Git ls-files strategy implementation
|
|
10
|
+
*
|
|
11
|
+
* Uses git ls-files to list all tracked files in a repository,
|
|
12
|
+
* then filters and ranks them based on the search query.
|
|
13
|
+
*
|
|
14
|
+
* Features:
|
|
15
|
+
* - Respects .gitignore automatically
|
|
16
|
+
* - Fast for git repositories
|
|
17
|
+
* - 5 second cache to reduce repeated git calls
|
|
18
|
+
* - Graceful fallback for non-git directories
|
|
19
|
+
*/
|
|
20
|
+
export declare class GitLsFilesStrategy implements FileSearchStrategy {
|
|
21
|
+
private cache;
|
|
22
|
+
private readonly cacheTTL;
|
|
23
|
+
getName(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Search for files matching the query
|
|
26
|
+
*
|
|
27
|
+
* @param workspacePath - Absolute path to workspace root
|
|
28
|
+
* @param options - Search options
|
|
29
|
+
* @returns Matching files sorted by relevance
|
|
30
|
+
*/
|
|
31
|
+
search(workspacePath: string, options: FileSearchOptions): Promise<FileSearchResult[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Get files from git ls-files with caching
|
|
34
|
+
*
|
|
35
|
+
* @param workspacePath - Absolute path to workspace
|
|
36
|
+
* @returns Array of file paths relative to workspace root
|
|
37
|
+
*/
|
|
38
|
+
private getCachedFiles;
|
|
39
|
+
/**
|
|
40
|
+
* Match a file path against the query
|
|
41
|
+
*
|
|
42
|
+
* @param path - File path relative to workspace root
|
|
43
|
+
* @param query - Search query (case-insensitive)
|
|
44
|
+
* @returns Match result with type, or null if no match
|
|
45
|
+
*/
|
|
46
|
+
private matchFile;
|
|
47
|
+
/**
|
|
48
|
+
* Compare two match results for sorting
|
|
49
|
+
*
|
|
50
|
+
* Priority:
|
|
51
|
+
* 1. Match type (exact > prefix > contains)
|
|
52
|
+
* 2. Path length (shorter first)
|
|
53
|
+
* 3. Alphabetical
|
|
54
|
+
*
|
|
55
|
+
* @param a - First result
|
|
56
|
+
* @param b - Second result
|
|
57
|
+
* @returns Negative if a < b, positive if a > b, 0 if equal
|
|
58
|
+
*/
|
|
59
|
+
private compareMatchQuality;
|
|
60
|
+
/**
|
|
61
|
+
* Clear the cache (useful for testing or manual invalidation)
|
|
62
|
+
*/
|
|
63
|
+
clearCache(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Get cache statistics (useful for debugging/monitoring)
|
|
66
|
+
*/
|
|
67
|
+
getCacheStats(): {
|
|
68
|
+
entries: number;
|
|
69
|
+
workspaces: string[];
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=git-ls-files-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-ls-files-strategy.d.ts","sourceRoot":"","sources":["../../../src/services/file-search/git-ls-files-strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAA;AAYtB;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,YAAW,kBAAkB;IAC3D,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAO;IAEhC,OAAO,IAAI,MAAM;IAIjB;;;;;;OAMG;IACG,MAAM,CACV,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAsC9B;;;;;OAKG;YACW,cAAc;IAqC5B;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IA8BjB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,aAAa,IAAI;QACf,OAAO,EAAE,MAAM,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;KACrB;CAMF"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git ls-files search strategy
|
|
3
|
+
*
|
|
4
|
+
* Uses `git ls-files` command to search for files in a git repository.
|
|
5
|
+
* This strategy respects .gitignore and is fast for git repositories.
|
|
6
|
+
*/
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
/**
|
|
9
|
+
* Git ls-files strategy implementation
|
|
10
|
+
*
|
|
11
|
+
* Uses git ls-files to list all tracked files in a repository,
|
|
12
|
+
* then filters and ranks them based on the search query.
|
|
13
|
+
*
|
|
14
|
+
* Features:
|
|
15
|
+
* - Respects .gitignore automatically
|
|
16
|
+
* - Fast for git repositories
|
|
17
|
+
* - 5 second cache to reduce repeated git calls
|
|
18
|
+
* - Graceful fallback for non-git directories
|
|
19
|
+
*/
|
|
20
|
+
export class GitLsFilesStrategy {
|
|
21
|
+
cache = new Map();
|
|
22
|
+
cacheTTL = 5000; // 5 seconds in milliseconds
|
|
23
|
+
getName() {
|
|
24
|
+
return "git-ls-files";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Search for files matching the query
|
|
28
|
+
*
|
|
29
|
+
* @param workspacePath - Absolute path to workspace root
|
|
30
|
+
* @param options - Search options
|
|
31
|
+
* @returns Matching files sorted by relevance
|
|
32
|
+
*/
|
|
33
|
+
async search(workspacePath, options) {
|
|
34
|
+
const { query, limit, includeDirectories } = options;
|
|
35
|
+
// Empty query returns empty results
|
|
36
|
+
if (!query || query.trim().length === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
// Get all files from git (cached)
|
|
41
|
+
const allFiles = await this.getCachedFiles(workspacePath);
|
|
42
|
+
// Filter directories if requested
|
|
43
|
+
let filesToSearch = allFiles;
|
|
44
|
+
if (!includeDirectories) {
|
|
45
|
+
// git ls-files only returns files by default, so no filtering needed
|
|
46
|
+
// but we keep this for consistency with other strategies
|
|
47
|
+
filesToSearch = allFiles.filter((path) => !path.endsWith("/"));
|
|
48
|
+
}
|
|
49
|
+
// Match and rank files
|
|
50
|
+
const matches = filesToSearch
|
|
51
|
+
.map((path) => this.matchFile(path, query))
|
|
52
|
+
.filter((result) => result !== null)
|
|
53
|
+
.sort((a, b) => this.compareMatchQuality(a, b))
|
|
54
|
+
.slice(0, limit);
|
|
55
|
+
return matches;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
// Log error but don't throw - gracefully return empty results
|
|
59
|
+
console.warn(`[GitLsFilesStrategy] Failed to search files in ${workspacePath}:`, error instanceof Error ? error.message : String(error));
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get files from git ls-files with caching
|
|
65
|
+
*
|
|
66
|
+
* @param workspacePath - Absolute path to workspace
|
|
67
|
+
* @returns Array of file paths relative to workspace root
|
|
68
|
+
*/
|
|
69
|
+
async getCachedFiles(workspacePath) {
|
|
70
|
+
const now = Date.now();
|
|
71
|
+
const cached = this.cache.get(workspacePath);
|
|
72
|
+
// Return cached files if still valid
|
|
73
|
+
if (cached && now - cached.timestamp < this.cacheTTL) {
|
|
74
|
+
return cached.files;
|
|
75
|
+
}
|
|
76
|
+
// Execute git ls-files
|
|
77
|
+
try {
|
|
78
|
+
const output = execSync("git ls-files", {
|
|
79
|
+
cwd: workspacePath,
|
|
80
|
+
encoding: "utf-8",
|
|
81
|
+
stdio: ["ignore", "pipe", "pipe"], // Ignore stdin, capture stdout, capture stderr
|
|
82
|
+
});
|
|
83
|
+
const files = output
|
|
84
|
+
.split("\n")
|
|
85
|
+
.map((line) => line.trim())
|
|
86
|
+
.filter((line) => line.length > 0);
|
|
87
|
+
// Cache the results
|
|
88
|
+
this.cache.set(workspacePath, {
|
|
89
|
+
files,
|
|
90
|
+
timestamp: now,
|
|
91
|
+
});
|
|
92
|
+
return files;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
// Git command failed (not a git repo, or other error)
|
|
96
|
+
// Clear cache and return empty array
|
|
97
|
+
this.cache.delete(workspacePath);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Match a file path against the query
|
|
103
|
+
*
|
|
104
|
+
* @param path - File path relative to workspace root
|
|
105
|
+
* @param query - Search query (case-insensitive)
|
|
106
|
+
* @returns Match result with type, or null if no match
|
|
107
|
+
*/
|
|
108
|
+
matchFile(path, query) {
|
|
109
|
+
const name = path.split("/").pop();
|
|
110
|
+
const lowerQuery = query.toLowerCase();
|
|
111
|
+
const lowerPath = path.toLowerCase();
|
|
112
|
+
const lowerName = name.toLowerCase();
|
|
113
|
+
// Exact match on filename
|
|
114
|
+
if (lowerName === lowerQuery) {
|
|
115
|
+
return { path, name, isFile: true, matchType: "exact" };
|
|
116
|
+
}
|
|
117
|
+
// Prefix match on filename
|
|
118
|
+
if (lowerName.startsWith(lowerQuery)) {
|
|
119
|
+
return { path, name, isFile: true, matchType: "prefix" };
|
|
120
|
+
}
|
|
121
|
+
// Prefix match on path
|
|
122
|
+
if (lowerPath.startsWith(lowerQuery)) {
|
|
123
|
+
return { path, name, isFile: true, matchType: "prefix" };
|
|
124
|
+
}
|
|
125
|
+
// Contains match anywhere in path
|
|
126
|
+
if (lowerPath.includes(lowerQuery)) {
|
|
127
|
+
return { path, name, isFile: true, matchType: "contains" };
|
|
128
|
+
}
|
|
129
|
+
// No match
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Compare two match results for sorting
|
|
134
|
+
*
|
|
135
|
+
* Priority:
|
|
136
|
+
* 1. Match type (exact > prefix > contains)
|
|
137
|
+
* 2. Path length (shorter first)
|
|
138
|
+
* 3. Alphabetical
|
|
139
|
+
*
|
|
140
|
+
* @param a - First result
|
|
141
|
+
* @param b - Second result
|
|
142
|
+
* @returns Negative if a < b, positive if a > b, 0 if equal
|
|
143
|
+
*/
|
|
144
|
+
compareMatchQuality(a, b) {
|
|
145
|
+
// Define match type ordering
|
|
146
|
+
const matchOrder = { exact: 0, prefix: 1, contains: 2 };
|
|
147
|
+
const aOrder = matchOrder[a.matchType || "contains"];
|
|
148
|
+
const bOrder = matchOrder[b.matchType || "contains"];
|
|
149
|
+
// Compare by match type first
|
|
150
|
+
if (aOrder !== bOrder) {
|
|
151
|
+
return aOrder - bOrder;
|
|
152
|
+
}
|
|
153
|
+
// Same match type - shorter paths first
|
|
154
|
+
if (a.path.length !== b.path.length) {
|
|
155
|
+
return a.path.length - b.path.length;
|
|
156
|
+
}
|
|
157
|
+
// Same length - alphabetical
|
|
158
|
+
return a.path.localeCompare(b.path);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Clear the cache (useful for testing or manual invalidation)
|
|
162
|
+
*/
|
|
163
|
+
clearCache() {
|
|
164
|
+
this.cache.clear();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get cache statistics (useful for debugging/monitoring)
|
|
168
|
+
*/
|
|
169
|
+
getCacheStats() {
|
|
170
|
+
return {
|
|
171
|
+
entries: this.cache.size,
|
|
172
|
+
workspaces: Array.from(this.cache.keys()),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=git-ls-files-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-ls-files-strategy.js","sourceRoot":"","sources":["../../../src/services/file-search/git-ls-files-strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAiBxC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,kBAAkB;IACrB,KAAK,GAA4B,IAAI,GAAG,EAAE,CAAA;IACjC,QAAQ,GAAG,IAAI,CAAA,CAAC,4BAA4B;IAE7D,OAAO;QACL,OAAO,cAAc,CAAA;IACvB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CACV,aAAqB,EACrB,OAA0B;QAE1B,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAA;QAEpD,oCAAoC;QACpC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxC,OAAO,EAAE,CAAA;QACX,CAAC;QAED,IAAI,CAAC;YACH,kCAAkC;YAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;YAEzD,kCAAkC;YAClC,IAAI,aAAa,GAAG,QAAQ,CAAA;YAC5B,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACxB,qEAAqE;gBACrE,yDAAyD;gBACzD,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAA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CAAA;IACrC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED;;OAEG;IACH,aAAa;QAIX,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACxB,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC1C,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File search service exports
|
|
3
|
+
*
|
|
4
|
+
* Provides file search capabilities with pluggable strategies.
|
|
5
|
+
*/
|
|
6
|
+
export type { FileSearchStrategy, FileSearchOptions, FileSearchResult, } from "./strategy.js";
|
|
7
|
+
export { FileSearchStrategyRegistry, fileSearchRegistry, type StrategyType, } from "./registry.js";
|
|
8
|
+
export { GitLsFilesStrategy } from "./git-ls-files-strategy.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/file-search/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAA;AAGtB,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File search service exports
|
|
3
|
+
*
|
|
4
|
+
* Provides file search capabilities with pluggable strategies.
|
|
5
|
+
*/
|
|
6
|
+
// Registry for managing strategies
|
|
7
|
+
export { FileSearchStrategyRegistry, fileSearchRegistry, } from "./registry.js";
|
|
8
|
+
// Strategies
|
|
9
|
+
export { GitLsFilesStrategy } from "./git-ls-files-strategy.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/file-search/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,mCAAmC;AACnC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAEnB,MAAM,eAAe,CAAA;AAEtB,aAAa;AACb,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File search strategy registry
|
|
3
|
+
*
|
|
4
|
+
* Manages registration and retrieval of file search strategies.
|
|
5
|
+
* Allows switching between different search implementations.
|
|
6
|
+
*/
|
|
7
|
+
import type { FileSearchStrategy } from "./strategy.js";
|
|
8
|
+
/**
|
|
9
|
+
* Type name for registered strategies
|
|
10
|
+
*/
|
|
11
|
+
export type StrategyType = "git-ls-files" | "fast-glob" | "indexed";
|
|
12
|
+
/**
|
|
13
|
+
* Registry for file search strategies
|
|
14
|
+
*
|
|
15
|
+
* Manages multiple search strategy implementations and provides
|
|
16
|
+
* a way to select which one to use (globally or per-project).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Register a strategy
|
|
21
|
+
* fileSearchRegistry.register('git-ls-files', new GitLsFilesStrategy())
|
|
22
|
+
*
|
|
23
|
+
* // Set as default
|
|
24
|
+
* fileSearchRegistry.setDefault('git-ls-files')
|
|
25
|
+
*
|
|
26
|
+
* // Get strategy (uses default if not specified)
|
|
27
|
+
* const strategy = fileSearchRegistry.get()
|
|
28
|
+
* const results = await strategy.search(workspacePath, options)
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class FileSearchStrategyRegistry {
|
|
32
|
+
private strategies;
|
|
33
|
+
private defaultStrategy;
|
|
34
|
+
/**
|
|
35
|
+
* Register a new search strategy
|
|
36
|
+
*
|
|
37
|
+
* @param type - Unique identifier for this strategy
|
|
38
|
+
* @param strategy - Strategy implementation
|
|
39
|
+
* @throws Error if strategy with this type already registered
|
|
40
|
+
*/
|
|
41
|
+
register(type: StrategyType, strategy: FileSearchStrategy): void;
|
|
42
|
+
/**
|
|
43
|
+
* Unregister a search strategy
|
|
44
|
+
*
|
|
45
|
+
* @param type - Strategy type to remove
|
|
46
|
+
* @returns True if strategy was found and removed, false otherwise
|
|
47
|
+
*/
|
|
48
|
+
unregister(type: StrategyType): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get a specific strategy by type, or the default strategy
|
|
51
|
+
*
|
|
52
|
+
* @param type - Optional strategy type. If not provided, returns default.
|
|
53
|
+
* @returns The requested strategy
|
|
54
|
+
* @throws Error if no strategy found for the given type
|
|
55
|
+
* @throws Error if no default strategy set and type not provided
|
|
56
|
+
*/
|
|
57
|
+
get(type?: StrategyType): FileSearchStrategy;
|
|
58
|
+
/**
|
|
59
|
+
* Set the default strategy to use
|
|
60
|
+
*
|
|
61
|
+
* @param type - Strategy type to set as default
|
|
62
|
+
* @throws Error if strategy type not registered
|
|
63
|
+
*/
|
|
64
|
+
setDefault(type: StrategyType): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the current default strategy type
|
|
67
|
+
*
|
|
68
|
+
* @returns Default strategy type, or null if no default set
|
|
69
|
+
*/
|
|
70
|
+
getDefaultType(): StrategyType | null;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a strategy is registered
|
|
73
|
+
*
|
|
74
|
+
* @param type - Strategy type to check
|
|
75
|
+
* @returns True if registered, false otherwise
|
|
76
|
+
*/
|
|
77
|
+
has(type: StrategyType): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Get all registered strategy types
|
|
80
|
+
*
|
|
81
|
+
* @returns Array of registered strategy type names
|
|
82
|
+
*/
|
|
83
|
+
listTypes(): StrategyType[];
|
|
84
|
+
/**
|
|
85
|
+
* Clear all registered strategies and reset default
|
|
86
|
+
*
|
|
87
|
+
* Useful for testing or complete reconfiguration
|
|
88
|
+
*/
|
|
89
|
+
clear(): void;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Global file search strategy registry instance
|
|
93
|
+
*
|
|
94
|
+
* Use this singleton for application-wide strategy management.
|
|
95
|
+
*/
|
|
96
|
+
export declare const fileSearchRegistry: FileSearchStrategyRegistry;
|
|
97
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/services/file-search/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,WAAW,GAAG,SAAS,CAAA;AAEnE;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,0BAA0B;IACrC,OAAO,CAAC,UAAU,CAAmD;IACrE,OAAO,CAAC,eAAe,CAA4B;IAEnD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAgBhE;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAavC;;;;;;;OAOG;IACH,GAAG,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,kBAAkB;IAuB5C;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAYpC;;;;OAIG;IACH,cAAc,IAAI,YAAY,GAAG,IAAI;IAIrC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO;IAIhC;;;;OAIG;IACH,SAAS,IAAI,YAAY,EAAE;IAI3B;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAId;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,4BAAmC,CAAA"}
|