opencodekit 0.12.6 → 0.13.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.
Files changed (65) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +2756 -523
  3. package/dist/template/.opencode/AGENTS.md +35 -128
  4. package/dist/template/.opencode/README.md +4 -3
  5. package/dist/template/.opencode/agent/build.md +32 -21
  6. package/dist/template/.opencode/agent/explore.md +27 -16
  7. package/dist/template/.opencode/agent/planner.md +103 -63
  8. package/dist/template/.opencode/agent/review.md +31 -23
  9. package/dist/template/.opencode/agent/rush.md +27 -19
  10. package/dist/template/.opencode/agent/scout.md +27 -19
  11. package/dist/template/.opencode/agent/vision.md +29 -19
  12. package/dist/template/.opencode/command/accessibility-check.md +1 -0
  13. package/dist/template/.opencode/command/analyze-mockup.md +1 -0
  14. package/dist/template/.opencode/command/analyze-project.md +2 -1
  15. package/dist/template/.opencode/command/brainstorm.md +2 -1
  16. package/dist/template/.opencode/command/design-audit.md +1 -0
  17. package/dist/template/.opencode/command/design.md +1 -0
  18. package/dist/template/.opencode/command/finish.md +39 -4
  19. package/dist/template/.opencode/command/fix.md +28 -1
  20. package/dist/template/.opencode/command/implement.md +26 -6
  21. package/dist/template/.opencode/command/init.md +1 -0
  22. package/dist/template/.opencode/command/pr.md +28 -1
  23. package/dist/template/.opencode/command/research-ui.md +1 -0
  24. package/dist/template/.opencode/command/research.md +1 -4
  25. package/dist/template/.opencode/command/review-codebase.md +1 -0
  26. package/dist/template/.opencode/command/start.md +106 -0
  27. package/dist/template/.opencode/command/status.md +3 -2
  28. package/dist/template/.opencode/command/summarize.md +2 -1
  29. package/dist/template/.opencode/command/triage.md +66 -12
  30. package/dist/template/.opencode/command/ui-review.md +1 -0
  31. package/dist/template/.opencode/memory/project/architecture.md +59 -6
  32. package/dist/template/.opencode/memory/project/beads-workflow.md +278 -0
  33. package/dist/template/.opencode/memory/project/commands.md +20 -164
  34. package/dist/template/.opencode/memory/session-context.md +40 -0
  35. package/dist/template/.opencode/memory/user.md +24 -7
  36. package/dist/template/.opencode/opencode.json +77 -16
  37. package/dist/template/.opencode/package.json +1 -1
  38. package/dist/template/.opencode/plugin/compaction.ts +62 -18
  39. package/dist/template/.opencode/plugin/lib/notify.ts +2 -3
  40. package/dist/template/.opencode/plugin/sessions.ts +1 -1
  41. package/dist/template/.opencode/plugin/skill-mcp.ts +11 -12
  42. package/dist/template/.opencode/skill/beads/SKILL.md +44 -0
  43. package/dist/template/.opencode/skill/condition-based-waiting/example.ts +71 -65
  44. package/dist/template/.opencode/tool/ast-grep.ts +3 -3
  45. package/dist/template/.opencode/tool/bd-inbox.ts +7 -6
  46. package/dist/template/.opencode/tool/bd-msg.ts +3 -3
  47. package/dist/template/.opencode/tool/bd-release.ts +2 -2
  48. package/dist/template/.opencode/tool/bd-reserve.ts +5 -4
  49. package/dist/template/.opencode/tool/memory-read.ts +58 -58
  50. package/dist/template/.opencode/tool/memory-search.ts +2 -2
  51. package/dist/template/.opencode/tool/memory-update.ts +53 -54
  52. package/dist/template/.opencode/tool/observation.ts +6 -6
  53. package/dist/template/.opencode/tsconfig.json +19 -19
  54. package/package.json +8 -17
  55. package/dist/template/.opencode/command.backup/analyze-project.md +0 -465
  56. package/dist/template/.opencode/command.backup/finish.md +0 -167
  57. package/dist/template/.opencode/command.backup/implement.md +0 -143
  58. package/dist/template/.opencode/command.backup/pr.md +0 -252
  59. package/dist/template/.opencode/command.backup/status.md +0 -376
  60. package/dist/template/.opencode/lib/lsp/client.ts +0 -614
  61. package/dist/template/.opencode/lib/lsp/config.ts +0 -199
  62. package/dist/template/.opencode/lib/lsp/constants.ts +0 -339
  63. package/dist/template/.opencode/lib/lsp/types.ts +0 -138
  64. package/dist/template/.opencode/lib/lsp/utils.ts +0 -190
  65. 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
- }