opencodekit 0.12.5 → 0.12.7
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/dist/index.js +2 -2
- package/dist/template/.opencode/agent/build.md +54 -29
- package/dist/template/.opencode/agent/explore.md +27 -16
- package/dist/template/.opencode/agent/planner.md +103 -63
- package/dist/template/.opencode/agent/review.md +31 -23
- package/dist/template/.opencode/agent/rush.md +33 -23
- package/dist/template/.opencode/agent/scout.md +27 -19
- package/dist/template/.opencode/agent/vision.md +29 -19
- package/dist/template/.opencode/command/accessibility-check.md +1 -0
- package/dist/template/.opencode/command/analyze-mockup.md +1 -0
- package/dist/template/.opencode/command/analyze-project.md +2 -1
- package/dist/template/.opencode/command/brainstorm.md +2 -1
- package/dist/template/.opencode/command/design-audit.md +1 -0
- package/dist/template/.opencode/command/finish.md +39 -4
- package/dist/template/.opencode/command/implement.md +26 -6
- package/dist/template/.opencode/command/init.md +1 -0
- package/dist/template/.opencode/command/pr.md +28 -1
- package/dist/template/.opencode/command/research-ui.md +1 -0
- package/dist/template/.opencode/command/research.md +1 -0
- package/dist/template/.opencode/command/review-codebase.md +1 -0
- package/dist/template/.opencode/command/status.md +3 -2
- package/dist/template/.opencode/command/summarize.md +2 -1
- package/dist/template/.opencode/command/ui-review.md +1 -0
- package/dist/template/.opencode/memory/project/architecture.md +59 -6
- package/dist/template/.opencode/memory/project/commands.md +20 -164
- package/dist/template/.opencode/memory/user.md +24 -7
- package/dist/template/.opencode/opencode.json +496 -542
- package/dist/template/.opencode/package.json +1 -1
- package/dist/template/.opencode/skill/condition-based-waiting/example.ts +71 -65
- package/dist/template/.opencode/tool/memory-read.ts +57 -57
- package/dist/template/.opencode/tool/memory-update.ts +53 -53
- package/dist/template/.opencode/tsconfig.json +19 -19
- package/package.json +1 -1
- package/dist/template/.opencode/command.backup/analyze-project.md +0 -465
- package/dist/template/.opencode/command.backup/finish.md +0 -167
- package/dist/template/.opencode/command.backup/implement.md +0 -143
- package/dist/template/.opencode/command.backup/pr.md +0 -252
- package/dist/template/.opencode/command.backup/status.md +0 -376
- package/dist/template/.opencode/lib/lsp/client.ts +0 -614
- package/dist/template/.opencode/lib/lsp/config.ts +0 -199
- package/dist/template/.opencode/lib/lsp/constants.ts +0 -339
- package/dist/template/.opencode/lib/lsp/types.ts +0 -138
- package/dist/template/.opencode/lib/lsp/utils.ts +0 -190
- package/dist/template/.opencode/memory/project/SHELL_OUTPUT_MIGRATION_PLAN.md +0 -551
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
existsSync,
|
|
3
|
-
mkdirSync,
|
|
4
|
-
readFileSync,
|
|
5
|
-
renameSync,
|
|
6
|
-
rmSync,
|
|
7
|
-
writeFileSync,
|
|
8
|
-
} from "node:fs";
|
|
9
|
-
import { dirname } from "node:path";
|
|
10
|
-
import { fileURLToPath } from "node:url";
|
|
11
|
-
import type {
|
|
12
|
-
CreateFile,
|
|
13
|
-
DeleteFile,
|
|
14
|
-
RenameFile,
|
|
15
|
-
TextDocumentEdit,
|
|
16
|
-
TextEdit,
|
|
17
|
-
WorkspaceEdit,
|
|
18
|
-
} from "./types";
|
|
19
|
-
|
|
20
|
-
export interface ApplyEditResult {
|
|
21
|
-
success: boolean;
|
|
22
|
-
filesModified: string[];
|
|
23
|
-
error?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isTextDocumentEdit(
|
|
27
|
-
change: TextDocumentEdit | CreateFile | RenameFile | DeleteFile,
|
|
28
|
-
): change is TextDocumentEdit {
|
|
29
|
-
return "textDocument" in change && "edits" in change;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function isCreateFile(
|
|
33
|
-
change: TextDocumentEdit | CreateFile | RenameFile | DeleteFile,
|
|
34
|
-
): change is CreateFile {
|
|
35
|
-
return "kind" in change && change.kind === "create";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isRenameFile(
|
|
39
|
-
change: TextDocumentEdit | CreateFile | RenameFile | DeleteFile,
|
|
40
|
-
): change is RenameFile {
|
|
41
|
-
return "kind" in change && change.kind === "rename";
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isDeleteFile(
|
|
45
|
-
change: TextDocumentEdit | CreateFile | RenameFile | DeleteFile,
|
|
46
|
-
): change is DeleteFile {
|
|
47
|
-
return "kind" in change && change.kind === "delete";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function applyTextEdits(filePath: string, edits: TextEdit[]): void {
|
|
51
|
-
const content = readFileSync(filePath, "utf-8");
|
|
52
|
-
const lines = content.split("\n");
|
|
53
|
-
|
|
54
|
-
// Sort edits in reverse order to apply from bottom to top
|
|
55
|
-
const sortedEdits = [...edits].sort((a, b) => {
|
|
56
|
-
if (b.range.start.line !== a.range.start.line) {
|
|
57
|
-
return b.range.start.line - a.range.start.line;
|
|
58
|
-
}
|
|
59
|
-
return b.range.start.character - a.range.start.character;
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
for (const edit of sortedEdits) {
|
|
63
|
-
const { start, end } = edit.range;
|
|
64
|
-
|
|
65
|
-
// Get the text before and after the edit range
|
|
66
|
-
const startLine = lines[start.line] ?? "";
|
|
67
|
-
const endLine = lines[end.line] ?? "";
|
|
68
|
-
|
|
69
|
-
const beforeEdit = startLine.slice(0, start.character);
|
|
70
|
-
const afterEdit = endLine.slice(end.character);
|
|
71
|
-
|
|
72
|
-
// Create new content for the affected lines
|
|
73
|
-
const newLines = edit.newText.split("\n");
|
|
74
|
-
|
|
75
|
-
if (newLines.length === 1) {
|
|
76
|
-
// Single line replacement
|
|
77
|
-
lines[start.line] = beforeEdit + newLines[0] + afterEdit;
|
|
78
|
-
// Remove any lines between start and end
|
|
79
|
-
if (end.line > start.line) {
|
|
80
|
-
lines.splice(start.line + 1, end.line - start.line);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
// Multi-line replacement
|
|
84
|
-
newLines[0] = beforeEdit + newLines[0];
|
|
85
|
-
newLines[newLines.length - 1] = newLines[newLines.length - 1] + afterEdit;
|
|
86
|
-
|
|
87
|
-
// Replace the affected lines
|
|
88
|
-
lines.splice(start.line, end.line - start.line + 1, ...newLines);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
writeFileSync(filePath, lines.join("\n"));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function applyWorkspaceEdit(edit: WorkspaceEdit): ApplyEditResult {
|
|
96
|
-
const filesModified: string[] = [];
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
// Handle documentChanges (newer format)
|
|
100
|
-
if (edit.documentChanges) {
|
|
101
|
-
for (const change of edit.documentChanges) {
|
|
102
|
-
if (isTextDocumentEdit(change)) {
|
|
103
|
-
const filePath = fileURLToPath(change.textDocument.uri);
|
|
104
|
-
applyTextEdits(filePath, change.edits);
|
|
105
|
-
if (!filesModified.includes(filePath)) {
|
|
106
|
-
filesModified.push(filePath);
|
|
107
|
-
}
|
|
108
|
-
} else if (isCreateFile(change)) {
|
|
109
|
-
const filePath = fileURLToPath(change.uri);
|
|
110
|
-
const dir = dirname(filePath);
|
|
111
|
-
if (!existsSync(dir)) {
|
|
112
|
-
mkdirSync(dir, { recursive: true });
|
|
113
|
-
}
|
|
114
|
-
if (!existsSync(filePath) || change.options?.overwrite) {
|
|
115
|
-
writeFileSync(filePath, "");
|
|
116
|
-
filesModified.push(filePath);
|
|
117
|
-
}
|
|
118
|
-
} else if (isRenameFile(change)) {
|
|
119
|
-
const oldPath = fileURLToPath(change.oldUri);
|
|
120
|
-
const newPath = fileURLToPath(change.newUri);
|
|
121
|
-
const newDir = dirname(newPath);
|
|
122
|
-
if (!existsSync(newDir)) {
|
|
123
|
-
mkdirSync(newDir, { recursive: true });
|
|
124
|
-
}
|
|
125
|
-
if (existsSync(oldPath)) {
|
|
126
|
-
if (!existsSync(newPath) || change.options?.overwrite) {
|
|
127
|
-
renameSync(oldPath, newPath);
|
|
128
|
-
filesModified.push(oldPath, newPath);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
} else if (isDeleteFile(change)) {
|
|
132
|
-
const filePath = fileURLToPath(change.uri);
|
|
133
|
-
if (existsSync(filePath)) {
|
|
134
|
-
rmSync(filePath, { recursive: change.options?.recursive });
|
|
135
|
-
filesModified.push(filePath);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Handle changes (older format)
|
|
142
|
-
if (edit.changes) {
|
|
143
|
-
for (const [uri, edits] of Object.entries(edit.changes)) {
|
|
144
|
-
const filePath = fileURLToPath(uri);
|
|
145
|
-
applyTextEdits(filePath, edits);
|
|
146
|
-
if (!filesModified.includes(filePath)) {
|
|
147
|
-
filesModified.push(filePath);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return { success: true, filesModified };
|
|
153
|
-
} catch (error) {
|
|
154
|
-
return {
|
|
155
|
-
success: false,
|
|
156
|
-
filesModified,
|
|
157
|
-
error: error instanceof Error ? error.message : String(error),
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export function formatWorkspaceEditPreview(edit: WorkspaceEdit): string {
|
|
163
|
-
const changes: string[] = [];
|
|
164
|
-
|
|
165
|
-
if (edit.documentChanges) {
|
|
166
|
-
for (const change of edit.documentChanges) {
|
|
167
|
-
if (isTextDocumentEdit(change)) {
|
|
168
|
-
const filePath = fileURLToPath(change.textDocument.uri);
|
|
169
|
-
changes.push(`Modify: ${filePath} (${change.edits.length} edit(s))`);
|
|
170
|
-
} else if (isCreateFile(change)) {
|
|
171
|
-
changes.push(`Create: ${fileURLToPath(change.uri)}`);
|
|
172
|
-
} else if (isRenameFile(change)) {
|
|
173
|
-
changes.push(
|
|
174
|
-
`Rename: ${fileURLToPath(change.oldUri)} → ${fileURLToPath(change.newUri)}`,
|
|
175
|
-
);
|
|
176
|
-
} else if (isDeleteFile(change)) {
|
|
177
|
-
changes.push(`Delete: ${fileURLToPath(change.uri)}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (edit.changes) {
|
|
183
|
-
for (const [uri, edits] of Object.entries(edit.changes)) {
|
|
184
|
-
const filePath = fileURLToPath(uri);
|
|
185
|
-
changes.push(`Modify: ${filePath} (${edits.length} edit(s))`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return changes.join("\n");
|
|
190
|
-
}
|