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.
Files changed (44) hide show
  1. package/dist/index.js +2 -2
  2. package/dist/template/.opencode/agent/build.md +54 -29
  3. package/dist/template/.opencode/agent/explore.md +27 -16
  4. package/dist/template/.opencode/agent/planner.md +103 -63
  5. package/dist/template/.opencode/agent/review.md +31 -23
  6. package/dist/template/.opencode/agent/rush.md +33 -23
  7. package/dist/template/.opencode/agent/scout.md +27 -19
  8. package/dist/template/.opencode/agent/vision.md +29 -19
  9. package/dist/template/.opencode/command/accessibility-check.md +1 -0
  10. package/dist/template/.opencode/command/analyze-mockup.md +1 -0
  11. package/dist/template/.opencode/command/analyze-project.md +2 -1
  12. package/dist/template/.opencode/command/brainstorm.md +2 -1
  13. package/dist/template/.opencode/command/design-audit.md +1 -0
  14. package/dist/template/.opencode/command/finish.md +39 -4
  15. package/dist/template/.opencode/command/implement.md +26 -6
  16. package/dist/template/.opencode/command/init.md +1 -0
  17. package/dist/template/.opencode/command/pr.md +28 -1
  18. package/dist/template/.opencode/command/research-ui.md +1 -0
  19. package/dist/template/.opencode/command/research.md +1 -0
  20. package/dist/template/.opencode/command/review-codebase.md +1 -0
  21. package/dist/template/.opencode/command/status.md +3 -2
  22. package/dist/template/.opencode/command/summarize.md +2 -1
  23. package/dist/template/.opencode/command/ui-review.md +1 -0
  24. package/dist/template/.opencode/memory/project/architecture.md +59 -6
  25. package/dist/template/.opencode/memory/project/commands.md +20 -164
  26. package/dist/template/.opencode/memory/user.md +24 -7
  27. package/dist/template/.opencode/opencode.json +496 -542
  28. package/dist/template/.opencode/package.json +1 -1
  29. package/dist/template/.opencode/skill/condition-based-waiting/example.ts +71 -65
  30. package/dist/template/.opencode/tool/memory-read.ts +57 -57
  31. package/dist/template/.opencode/tool/memory-update.ts +53 -53
  32. package/dist/template/.opencode/tsconfig.json +19 -19
  33. package/package.json +1 -1
  34. package/dist/template/.opencode/command.backup/analyze-project.md +0 -465
  35. package/dist/template/.opencode/command.backup/finish.md +0 -167
  36. package/dist/template/.opencode/command.backup/implement.md +0 -143
  37. package/dist/template/.opencode/command.backup/pr.md +0 -252
  38. package/dist/template/.opencode/command.backup/status.md +0 -376
  39. package/dist/template/.opencode/lib/lsp/client.ts +0 -614
  40. package/dist/template/.opencode/lib/lsp/config.ts +0 -199
  41. package/dist/template/.opencode/lib/lsp/constants.ts +0 -339
  42. package/dist/template/.opencode/lib/lsp/types.ts +0 -138
  43. package/dist/template/.opencode/lib/lsp/utils.ts +0 -190
  44. package/dist/template/.opencode/memory/project/SHELL_OUTPUT_MIGRATION_PLAN.md +0 -551
@@ -1,199 +0,0 @@
1
- import { existsSync, readdirSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { extname, join } from "node:path";
4
- import { BUILTIN_SERVERS, EXT_TO_LANG } from "./constants";
5
- import type { LSPServerConfig } from "./types";
6
-
7
- /**
8
- * Known paths where OpenCode installs bundled LSP servers
9
- * These are checked when the command isn't found in PATH
10
- */
11
- function getOpenCodeDataDir(): string {
12
- const home = homedir();
13
- switch (process.platform) {
14
- case "darwin":
15
- return join(home, ".local/share/opencode");
16
- case "win32":
17
- return join(
18
- process.env.APPDATA ?? join(home, "AppData/Roaming"),
19
- "opencode",
20
- );
21
- default: // linux
22
- return join(
23
- process.env.XDG_DATA_HOME ?? join(home, ".local/share"),
24
- "opencode",
25
- );
26
- }
27
- }
28
-
29
- import { mkdtempSync } from "node:fs";
30
- import { tmpdir } from "node:os";
31
-
32
- /**
33
- * Find OpenCode's bundled jdtls launcher jar and build the full command
34
- * @see https://github.com/eclipse-jdtls/eclipse.jdt.ls
35
- */
36
- function findOpenCodeJdtls(): string[] | null {
37
- const jdtlsDir = join(getOpenCodeDataDir(), "bin/jdtls");
38
- const pluginsDir = join(jdtlsDir, "plugins");
39
-
40
- if (!existsSync(pluginsDir)) return null;
41
-
42
- try {
43
- const files = readdirSync(pluginsDir);
44
- const launcherJar = files.find(
45
- (f) =>
46
- f.startsWith("org.eclipse.equinox.launcher_") && f.endsWith(".jar"),
47
- );
48
- if (!launcherJar) return null;
49
-
50
- const configDir = join(
51
- jdtlsDir,
52
- process.platform === "darwin"
53
- ? "config_mac"
54
- : process.platform === "win32"
55
- ? "config_win"
56
- : "config_linux",
57
- );
58
-
59
- if (!existsSync(configDir)) return null;
60
-
61
- // Create a unique data directory for this jdtls instance
62
- const dataDir = mkdtempSync(join(tmpdir(), "opencodekit-jdtls-data"));
63
-
64
- return [
65
- "java",
66
- // JVM arguments required by jdtls
67
- "-Declipse.application=org.eclipse.jdt.ls.core.id1",
68
- "-Dosgi.bundles.defaultStartLevel=4",
69
- "-Declipse.product=org.eclipse.jdt.ls.core.product",
70
- "-Dlog.level=ALL",
71
- "--add-modules=ALL-SYSTEM",
72
- "--add-opens",
73
- "java.base/java.util=ALL-UNNAMED",
74
- "--add-opens",
75
- "java.base/java.lang=ALL-UNNAMED",
76
- "-jar",
77
- join(pluginsDir, launcherJar),
78
- "-configuration",
79
- configDir,
80
- "-data",
81
- dataDir,
82
- ];
83
- } catch {
84
- return null;
85
- }
86
- }
87
-
88
- export interface ResolvedServer extends LSPServerConfig {
89
- id: string;
90
- }
91
-
92
- let configuredServers: LSPServerConfig[] = [];
93
-
94
- export function setServers(servers: LSPServerConfig[]): void {
95
- configuredServers = servers;
96
- }
97
-
98
- export function getLanguageId(ext: string): string {
99
- return EXT_TO_LANG[ext] ?? ext.slice(1);
100
- }
101
-
102
- function commandExists(cmd: string): boolean {
103
- const paths = (process.env.PATH ?? "").split(
104
- process.platform === "win32" ? ";" : ":",
105
- );
106
- const extensions =
107
- process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
108
-
109
- for (const dir of paths) {
110
- for (const ext of extensions) {
111
- const fullPath = `${dir}/${cmd}${ext}`;
112
- if (existsSync(fullPath)) return true;
113
- }
114
- }
115
- return false;
116
- }
117
-
118
- export function resolveServer(filePath: string): ResolvedServer | null {
119
- const ext = extname(filePath);
120
- if (!ext) return null;
121
-
122
- // Check user-configured servers first
123
- for (const server of configuredServers) {
124
- if (server.disabled) continue;
125
- if (server.extensions.includes(ext)) {
126
- const [cmd] = server.command;
127
- if (cmd && commandExists(cmd)) {
128
- return { ...server, id: server.id };
129
- }
130
- }
131
- }
132
-
133
- // Fall back to built-in servers
134
- for (const [id, config] of Object.entries(BUILTIN_SERVERS)) {
135
- if (config.extensions.includes(ext)) {
136
- const [cmd] = config.command;
137
- if (cmd && commandExists(cmd)) {
138
- return { ...config, id };
139
- }
140
- }
141
- }
142
-
143
- // Special case: Try OpenCode's bundled jdtls for Java files
144
- if (ext === ".java") {
145
- const jdtlsCommand = findOpenCodeJdtls();
146
- if (jdtlsCommand && commandExists("java")) {
147
- return {
148
- id: "jdtls",
149
- command: jdtlsCommand,
150
- extensions: [".java"],
151
- };
152
- }
153
- }
154
-
155
- return null;
156
- }
157
-
158
- export function listAvailableServers(): Array<{
159
- id: string;
160
- extensions: string[];
161
- available: boolean;
162
- }> {
163
- const results: Array<{
164
- id: string;
165
- extensions: string[];
166
- available: boolean;
167
- }> = [];
168
-
169
- // User-configured servers
170
- for (const server of configuredServers) {
171
- const [cmd] = server.command;
172
- results.push({
173
- id: server.id,
174
- extensions: server.extensions,
175
- available: !server.disabled && !!cmd && commandExists(cmd),
176
- });
177
- }
178
-
179
- // Built-in servers (skip if user already configured same id)
180
- const configuredIds = new Set(configuredServers.map((s) => s.id));
181
- for (const [id, config] of Object.entries(BUILTIN_SERVERS)) {
182
- if (configuredIds.has(id)) continue;
183
- const [cmd] = config.command;
184
-
185
- // Special case: jdtls can use OpenCode's bundled version
186
- let available = !!cmd && commandExists(cmd);
187
- if (!available && id === "jdtls") {
188
- available = !!(findOpenCodeJdtls() && commandExists("java"));
189
- }
190
-
191
- results.push({
192
- id,
193
- extensions: config.extensions,
194
- available,
195
- });
196
- }
197
-
198
- return results;
199
- }
@@ -1,339 +0,0 @@
1
- import type { LSPServerConfig } from "./types";
2
-
3
- export const SYMBOL_KIND_MAP: Record<number, string> = {
4
- 1: "File",
5
- 2: "Module",
6
- 3: "Namespace",
7
- 4: "Package",
8
- 5: "Class",
9
- 6: "Method",
10
- 7: "Property",
11
- 8: "Field",
12
- 9: "Constructor",
13
- 10: "Enum",
14
- 11: "Interface",
15
- 12: "Function",
16
- 13: "Variable",
17
- 14: "Constant",
18
- 15: "String",
19
- 16: "Number",
20
- 17: "Boolean",
21
- 18: "Array",
22
- 19: "Object",
23
- 20: "Key",
24
- 21: "Null",
25
- 22: "EnumMember",
26
- 23: "Struct",
27
- 24: "Event",
28
- 25: "Operator",
29
- 26: "TypeParameter",
30
- };
31
-
32
- export const SEVERITY_MAP: Record<number, string> = {
33
- 1: "error",
34
- 2: "warning",
35
- 3: "information",
36
- 4: "hint",
37
- };
38
-
39
- export const DEFAULT_MAX_REFERENCES = 200;
40
- export const DEFAULT_MAX_SYMBOLS = 200;
41
- export const DEFAULT_MAX_DIAGNOSTICS = 200;
42
-
43
- /**
44
- * Built-in LSP servers synced with OpenCode's LSP configuration
45
- * @see https://opencode.ai/docs/lsp/
46
- *
47
- * Servers are matched in order - first match wins.
48
- * Some servers (jdtls, pyright, etc.) may use OpenCode's bundled installation.
49
- */
50
- export const BUILTIN_SERVERS: Record<string, Omit<LSPServerConfig, "id">> = {
51
- // TypeScript/JavaScript
52
- typescript: {
53
- command: ["typescript-language-server", "--stdio"],
54
- extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"],
55
- },
56
- deno: {
57
- command: ["deno", "lsp"],
58
- extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs"],
59
- },
60
-
61
- // Frontend frameworks
62
- vue: {
63
- command: ["vue-language-server", "--stdio"],
64
- extensions: [".vue"],
65
- },
66
- svelte: {
67
- command: ["svelteserver", "--stdio"],
68
- extensions: [".svelte"],
69
- },
70
- astro: {
71
- command: ["astro-ls", "--stdio"],
72
- extensions: [".astro"],
73
- },
74
-
75
- // Go
76
- gopls: {
77
- command: ["gopls"],
78
- extensions: [".go"],
79
- },
80
-
81
- // Python
82
- basedpyright: {
83
- command: ["basedpyright-langserver", "--stdio"],
84
- extensions: [".py", ".pyi"],
85
- },
86
- pyright: {
87
- command: ["pyright-langserver", "--stdio"],
88
- extensions: [".py", ".pyi"],
89
- },
90
-
91
- // Rust
92
- rust: {
93
- command: ["rust-analyzer"],
94
- extensions: [".rs"],
95
- },
96
-
97
- // C/C++
98
- clangd: {
99
- command: ["clangd", "--background-index", "--clang-tidy"],
100
- extensions: [
101
- ".c",
102
- ".cpp",
103
- ".cc",
104
- ".cxx",
105
- ".c++",
106
- ".h",
107
- ".hpp",
108
- ".hh",
109
- ".hxx",
110
- ".h++",
111
- ],
112
- },
113
-
114
- // Java - OpenCode auto-installs jdtls, requires Java 21+
115
- jdtls: {
116
- command: ["jdtls"],
117
- extensions: [".java"],
118
- },
119
-
120
- // C#/F#
121
- csharp: {
122
- command: ["OmniSharp", "-lsp"],
123
- extensions: [".cs"],
124
- },
125
- fsharp: {
126
- command: ["fsautocomplete", "--adaptive-lsp-server-enabled"],
127
- extensions: [".fs", ".fsi", ".fsx", ".fsscript"],
128
- },
129
-
130
- // Ruby
131
- "ruby-lsp": {
132
- command: ["ruby-lsp"],
133
- extensions: [".rb", ".rake", ".gemspec", ".ru"],
134
- },
135
-
136
- // PHP
137
- intelephense: {
138
- command: ["intelephense", "--stdio"],
139
- extensions: [".php"],
140
- },
141
-
142
- // Lua
143
- "lua-ls": {
144
- command: ["lua-language-server"],
145
- extensions: [".lua"],
146
- },
147
-
148
- // Shell
149
- bash: {
150
- command: ["bash-language-server", "start"],
151
- extensions: [".sh", ".bash", ".zsh", ".ksh"],
152
- },
153
-
154
- // Swift/Objective-C
155
- "sourcekit-lsp": {
156
- command: ["sourcekit-lsp"],
157
- extensions: [".swift", ".objc", ".objcpp"],
158
- },
159
-
160
- // Dart
161
- dart: {
162
- command: ["dart", "language-server", "--protocol=lsp"],
163
- extensions: [".dart"],
164
- },
165
-
166
- // Elixir
167
- "elixir-ls": {
168
- command: ["elixir-ls"],
169
- extensions: [".ex", ".exs"],
170
- },
171
-
172
- // Gleam
173
- gleam: {
174
- command: ["gleam", "lsp"],
175
- extensions: [".gleam"],
176
- },
177
-
178
- // Clojure
179
- "clojure-lsp": {
180
- command: ["clojure-lsp"],
181
- extensions: [".clj", ".cljs", ".cljc", ".edn"],
182
- },
183
-
184
- // OCaml
185
- "ocaml-lsp": {
186
- command: ["ocamllsp"],
187
- extensions: [".ml", ".mli"],
188
- },
189
-
190
- // Zig
191
- zls: {
192
- command: ["zls"],
193
- extensions: [".zig", ".zon"],
194
- },
195
-
196
- // Nix
197
- nixd: {
198
- command: ["nixd"],
199
- extensions: [".nix"],
200
- },
201
-
202
- // Terraform
203
- terraform: {
204
- command: ["terraform-ls", "serve"],
205
- extensions: [".tf", ".tfvars"],
206
- },
207
-
208
- // Typst
209
- tinymist: {
210
- command: ["tinymist", "lsp"],
211
- extensions: [".typ", ".typc"],
212
- },
213
-
214
- // YAML
215
- "yaml-ls": {
216
- command: ["yaml-language-server", "--stdio"],
217
- extensions: [".yaml", ".yml"],
218
- },
219
- };
220
-
221
- // Extension to language ID mapping (used for LSP textDocument/didOpen)
222
- export const EXT_TO_LANG: Record<string, string> = {
223
- // TypeScript/JavaScript
224
- ".ts": "typescript",
225
- ".tsx": "typescriptreact",
226
- ".mts": "typescript",
227
- ".cts": "typescript",
228
- ".js": "javascript",
229
- ".jsx": "javascriptreact",
230
- ".mjs": "javascript",
231
- ".cjs": "javascript",
232
- ".json": "json",
233
- ".jsonc": "jsonc",
234
-
235
- // Python
236
- ".py": "python",
237
- ".pyi": "python",
238
-
239
- // Go
240
- ".go": "go",
241
-
242
- // Rust
243
- ".rs": "rust",
244
-
245
- // C/C++
246
- ".c": "c",
247
- ".cpp": "cpp",
248
- ".cc": "cpp",
249
- ".cxx": "cpp",
250
- ".c++": "cpp",
251
- ".h": "c",
252
- ".hpp": "cpp",
253
- ".hh": "cpp",
254
- ".hxx": "cpp",
255
- ".h++": "cpp",
256
-
257
- // Java
258
- ".java": "java",
259
-
260
- // C#/F#
261
- ".cs": "csharp",
262
- ".fs": "fsharp",
263
- ".fsi": "fsharp",
264
- ".fsx": "fsharp",
265
- ".fsscript": "fsharp",
266
-
267
- // Ruby
268
- ".rb": "ruby",
269
- ".rake": "ruby",
270
- ".gemspec": "ruby",
271
- ".ru": "ruby",
272
-
273
- // PHP
274
- ".php": "php",
275
-
276
- // Lua
277
- ".lua": "lua",
278
-
279
- // Shell
280
- ".sh": "shellscript",
281
- ".bash": "shellscript",
282
- ".zsh": "shellscript",
283
- ".ksh": "shellscript",
284
-
285
- // Swift/Objective-C
286
- ".swift": "swift",
287
- ".objc": "objective-c",
288
- ".objcpp": "objective-cpp",
289
-
290
- // Dart
291
- ".dart": "dart",
292
-
293
- // Elixir
294
- ".ex": "elixir",
295
- ".exs": "elixir",
296
-
297
- // Gleam
298
- ".gleam": "gleam",
299
-
300
- // Clojure
301
- ".clj": "clojure",
302
- ".cljs": "clojurescript",
303
- ".cljc": "clojure",
304
- ".edn": "edn",
305
-
306
- // OCaml
307
- ".ml": "ocaml",
308
- ".mli": "ocaml",
309
-
310
- // Zig
311
- ".zig": "zig",
312
- ".zon": "zig",
313
-
314
- // Nix
315
- ".nix": "nix",
316
-
317
- // Terraform
318
- ".tf": "terraform",
319
- ".tfvars": "terraform",
320
-
321
- // Typst
322
- ".typ": "typst",
323
- ".typc": "typst",
324
-
325
- // Frontend frameworks
326
- ".vue": "vue",
327
- ".svelte": "svelte",
328
- ".astro": "astro",
329
-
330
- // Web
331
- ".html": "html",
332
- ".css": "css",
333
- ".scss": "scss",
334
-
335
- // Config/Data
336
- ".yaml": "yaml",
337
- ".yml": "yaml",
338
- ".md": "markdown",
339
- };
@@ -1,138 +0,0 @@
1
- export interface LSPServerConfig {
2
- id: string;
3
- command: string[];
4
- extensions: string[];
5
- disabled?: boolean;
6
- env?: Record<string, string>;
7
- initialization?: Record<string, unknown>;
8
- }
9
-
10
- export interface Position {
11
- line: number;
12
- character: number;
13
- }
14
-
15
- export interface Range {
16
- start: Position;
17
- end: Position;
18
- }
19
-
20
- export interface Location {
21
- uri: string;
22
- range: Range;
23
- }
24
-
25
- export interface LocationLink {
26
- targetUri: string;
27
- targetRange: Range;
28
- targetSelectionRange: Range;
29
- originSelectionRange?: Range;
30
- }
31
-
32
- export interface SymbolInfo {
33
- name: string;
34
- kind: number;
35
- location: Location;
36
- containerName?: string;
37
- }
38
-
39
- export interface DocumentSymbol {
40
- name: string;
41
- kind: number;
42
- range: Range;
43
- selectionRange: Range;
44
- children?: DocumentSymbol[];
45
- }
46
-
47
- export interface Diagnostic {
48
- range: Range;
49
- severity?: number;
50
- code?: string | number;
51
- source?: string;
52
- message: string;
53
- }
54
-
55
- export interface HoverResult {
56
- contents:
57
- | { kind?: string; value: string }
58
- | string
59
- | Array<{ kind?: string; value: string } | string>;
60
- range?: Range;
61
- }
62
-
63
- export interface TextDocumentIdentifier {
64
- uri: string;
65
- }
66
-
67
- export interface VersionedTextDocumentIdentifier
68
- extends TextDocumentIdentifier {
69
- version: number | null;
70
- }
71
-
72
- export interface TextEdit {
73
- range: Range;
74
- newText: string;
75
- }
76
-
77
- export interface TextDocumentEdit {
78
- textDocument: VersionedTextDocumentIdentifier;
79
- edits: TextEdit[];
80
- }
81
-
82
- export interface CreateFile {
83
- kind: "create";
84
- uri: string;
85
- options?: { overwrite?: boolean; ignoreIfExists?: boolean };
86
- }
87
-
88
- export interface RenameFile {
89
- kind: "rename";
90
- oldUri: string;
91
- newUri: string;
92
- options?: { overwrite?: boolean; ignoreIfExists?: boolean };
93
- }
94
-
95
- export interface DeleteFile {
96
- kind: "delete";
97
- uri: string;
98
- options?: { recursive?: boolean; ignoreIfNotExists?: boolean };
99
- }
100
-
101
- export interface WorkspaceEdit {
102
- changes?: { [uri: string]: TextEdit[] };
103
- documentChanges?: (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[];
104
- }
105
-
106
- export interface PrepareRenameResult {
107
- range: Range;
108
- placeholder?: string;
109
- }
110
-
111
- export interface PrepareRenameDefaultBehavior {
112
- defaultBehavior: boolean;
113
- }
114
-
115
- export interface Command {
116
- title: string;
117
- command: string;
118
- arguments?: unknown[];
119
- }
120
-
121
- export interface CodeActionContext {
122
- diagnostics: Diagnostic[];
123
- only?: string[];
124
- triggerKind?: CodeActionTriggerKind;
125
- }
126
-
127
- export type CodeActionTriggerKind = 1 | 2;
128
-
129
- export interface CodeAction {
130
- title: string;
131
- kind?: string;
132
- diagnostics?: Diagnostic[];
133
- isPreferred?: boolean;
134
- disabled?: { reason: string };
135
- edit?: WorkspaceEdit;
136
- command?: Command;
137
- data?: unknown;
138
- }