GeezerVison is showing github.com — ignore: run prettier · mmacia/opencode@51bf193
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: opencode.json +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | "experimental": { | 4 | 4 | "hook": { | 5 | 5 | "file_edited": { | 6 | | - ".json": [] | | 6 | + ".json": [ | | 7 | + { | | 8 | + "command": ["bun", "run", "prettier", "$FILE"] | | 9 | + } | | 10 | + ] | 7 | 11 | }, | 8 | 12 | "session_completed": [ | 9 | 13 | { | |
Collapse file Copy file name to clipboardExpand all lines: packages/function/sst-env.d.ts +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | import "sst" | 7 | 7 | declare module "sst" { | 8 | 8 | export interface Resource { | 9 | | - "Web": { | 10 | | - "type": "sst.cloudflare.Astro" | 11 | | - "url": string | | 9 | + Web: { | | 10 | + type: "sst.cloudflare.Astro" | | 11 | + url: string | 12 | 12 | } | 13 | 13 | } | 14 | 14 | } | 15 | | -// cloudflare | 16 | | -import * as cloudflare from "@cloudflare/workers-types"; | | 15 | +// cloudflare | | 16 | +import * as cloudflare from "@cloudflare/workers-types" | 17 | 17 | declare module "sst" { | 18 | 18 | export interface Resource { | 19 | | - "Api": cloudflare.Service | 20 | | - "Bucket": cloudflare.R2Bucket | | 19 | + Api: cloudflare.Service | | 20 | + Bucket: cloudflare.R2Bucket | 21 | 21 | } | 22 | 22 | } | 23 | 23 |
| 24 | 24 | import "sst" | 25 | | -export {} | | 25 | +export {} |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/config.schema.json +8-26Lines changed: 8 additions & 26 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 202 | 202 | "type": "number" | 203 | 203 | } | 204 | 204 | }, | 205 | | - "required": [ | 206 | | - "input", | 207 | | - "output" | 208 | | - ], | | 205 | + "required": ["input", "output"], | 209 | 206 | "additionalProperties": false | 210 | 207 | }, | 211 | 208 | "limit": { | | 218 | 215 | "type": "number" | 219 | 216 | } | 220 | 217 | }, | 221 | | - "required": [ | 222 | | - "context", | 223 | | - "output" | 224 | | - ], | | 218 | + "required": ["context", "output"], | 225 | 219 | "additionalProperties": false | 226 | 220 | }, | 227 | 221 | "id": { | | 240 | 234 | "additionalProperties": {} | 241 | 235 | } | 242 | 236 | }, | 243 | | - "required": [ | 244 | | - "models" | 245 | | - ], | | 237 | + "required": ["models"], | 246 | 238 | "additionalProperties": false | 247 | 239 | }, | 248 | 240 | "description": "Custom provider configurations and model overrides" | | 274 | 266 | "description": "Environment variables to set when running the MCP server" | 275 | 267 | } | 276 | 268 | }, | 277 | | - "required": [ | 278 | | - "type", | 279 | | - "command" | 280 | | - ], | | 269 | + "required": ["type", "command"], | 281 | 270 | "additionalProperties": false | 282 | 271 | }, | 283 | 272 | { | | 293 | 282 | "description": "URL of the remote MCP server" | 294 | 283 | } | 295 | 284 | }, | 296 | | - "required": [ | 297 | | - "type", | 298 | | - "url" | 299 | | - ], | | 285 | + "required": ["type", "url"], | 300 | 286 | "additionalProperties": false | 301 | 287 | } | 302 | 288 | ] | | 329 | 315 | } | 330 | 316 | } | 331 | 317 | }, | 332 | | - "required": [ | 333 | | - "command" | 334 | | - ], | | 318 | + "required": ["command"], | 335 | 319 | "additionalProperties": false | 336 | 320 | } | 337 | 321 | } | | 354 | 338 | } | 355 | 339 | } | 356 | 340 | }, | 357 | | - "required": [ | 358 | | - "command" | 359 | | - ], | | 341 | + "required": ["command"], | 360 | 342 | "additionalProperties": false | 361 | 343 | } | 362 | 344 | } | | 369 | 351 | }, | 370 | 352 | "additionalProperties": false, | 371 | 353 | "$schema": "http://json-schema.org/draft-07/schema#" | 372 | | -} | | 354 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/app/app.ts -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -142,4 +142,3 @@ export namespace App { | 142 | 142 | .replace(/[^A-Za-z0-9_]/g, "-") | 143 | 143 | } | 144 | 144 | } | 145 | | - |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/auth.ts +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,7 +31,7 @@ export const AuthListCommand = cmd({ | 31 | 31 | UI.empty() | 32 | 32 | const authPath = path.join(Global.Path.data, "auth.json") | 33 | 33 | const homedir = os.homedir() | 34 | | - const displayPath = authPath.startsWith(homedir) | | 34 | + const displayPath = authPath.startsWith(homedir) | 35 | 35 | ? authPath.replace(homedir, "~") | 36 | 36 | : authPath | 37 | 37 | prompts.intro(`Credentials ${UI.Style.TEXT_DIM}${displayPath}`) | @@ -46,14 +46,14 @@ export const AuthListCommand = cmd({ | 46 | 46 | prompts.outro(`${results.length} credentials`) | 47 | 47 |
| 48 | 48 | // Environment variables section | 49 | | - const activeEnvVars: Array<{ provider: string, envVar: string }> = [] | 50 | | - | | 49 | + const activeEnvVars: Array<{ provider: string; envVar: string }> = [] | | 50 | + | 51 | 51 | for (const [providerID, provider] of Object.entries(database)) { | 52 | 52 | for (const envVar of provider.env) { | 53 | 53 | if (process.env[envVar]) { | 54 | | - activeEnvVars.push({ | 55 | | - provider: provider.name || providerID, | 56 | | - envVar | | 54 | + activeEnvVars.push({ | | 55 | + provider: provider.name || providerID, | | 56 | + envVar, | 57 | 57 | }) | 58 | 58 | } | 59 | 59 | } | @@ -62,11 +62,11 @@ export const AuthListCommand = cmd({ | 62 | 62 | if (activeEnvVars.length > 0) { | 63 | 63 | UI.empty() | 64 | 64 | prompts.intro("Environment") | 65 | | - | | 65 | + | 66 | 66 | for (const { provider, envVar } of activeEnvVars) { | 67 | 67 | prompts.log.info(`${provider} ${UI.Style.TEXT_DIM}${envVar}`) | 68 | 68 | } | 69 | | - | | 69 | + | 70 | 70 | prompts.outro(`${activeEnvVars.length} environment variables`) | 71 | 71 | } | 72 | 72 | }, | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/models.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,12 +8,12 @@ export const ModelsCommand = cmd({ | 8 | 8 | handler: async () => { | 9 | 9 | await App.provide({ cwd: process.cwd() }, async () => { | 10 | 10 | const providers = await Provider.list() | 11 | | - | | 11 | + | 12 | 12 | for (const [providerID, provider] of Object.entries(providers)) { | 13 | 13 | for (const modelID of Object.keys(provider.info.models)) { | 14 | 14 | console.log(`${providerID}/${modelID}`) | 15 | 15 | } | 16 | 16 | } | 17 | 17 | }) | 18 | 18 | }, | 19 | | -}) | | 19 | +}) |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/scrap.ts +4-7Lines changed: 4 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,12 +7,9 @@ export const ScrapCommand = cmd({ | 7 | 7 | builder: (yargs) => | 8 | 8 | yargs.positional("file", { type: "string", demandOption: true }), | 9 | 9 | async handler(args) { | 10 | | - await App.provide( | 11 | | - { cwd: process.cwd() }, | 12 | | - async () => { | 13 | | - await LSP.touchFile(args.file, true) | 14 | | - console.log(await LSP.diagnostics()) | 15 | | - }, | 16 | | - ) | | 10 | + await App.provide({ cwd: process.cwd() }, async () => { | | 11 | + await LSP.touchFile(args.file, true) | | 12 | + console.log(await LSP.diagnostics()) | | 13 | + }) | 17 | 14 | }, | 18 | 15 | }) |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/format/index.ts +55-55Lines changed: 55 additions & 55 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { App } from '../app/app' | 2 | | -import { BunProc } from '../bun' | 3 | | -import { Config } from '../config/config' | 4 | | -import { Log } from '../util/log' | 5 | | -import path from 'path' | | 1 | +import { App } from "../app/app" | | 2 | +import { BunProc } from "../bun" | | 3 | +import { Config } from "../config/config" | | 4 | +import { Log } from "../util/log" | | 5 | +import path from "path" | 6 | 6 |
| 7 | 7 | export namespace Format { | 8 | | - const log = Log.create({ service: 'format' }) | | 8 | + const log = Log.create({ service: "format" }) | 9 | 9 |
| 10 | | - const state = App.state('format', async () => { | | 10 | + const state = App.state("format", async () => { | 11 | 11 | const hooks: Record<string, Hook[]> = {} | 12 | 12 | for (const item of FORMATTERS) { | 13 | 13 | if (await item.enabled()) { | @@ -42,22 +42,22 @@ export namespace Format { | 42 | 42 | }) | 43 | 43 |
| 44 | 44 | export async function run(file: string) { | 45 | | - log.info('formatting', { file }) | | 45 | + log.info("formatting", { file }) | 46 | 46 | const { hooks } = await state() | 47 | 47 | const ext = path.extname(file) | 48 | 48 | const match = hooks[ext] | 49 | 49 | if (!match) return | 50 | 50 |
| 51 | 51 | for (const item of match) { | 52 | | - log.info('running', { command: item.command }) | | 52 | + log.info("running", { command: item.command }) | 53 | 53 | const proc = Bun.spawn({ | 54 | | - cmd: item.command.map((x) => x.replace('$FILE', file)), | | 54 | + cmd: item.command.map((x) => x.replace("$FILE", file)), | 55 | 55 | cwd: App.info().path.cwd, | 56 | 56 | env: item.environment, | 57 | 57 | }) | 58 | 58 | const exit = await proc.exited | 59 | 59 | if (exit !== 0) | 60 | | - log.error('failed', { | | 60 | + log.error("failed", { | 61 | 61 | command: item.command, | 62 | 62 | ...item.environment, | 63 | 63 | }) | @@ -79,58 +79,58 @@ export namespace Format { | 79 | 79 |
| 80 | 80 | const FORMATTERS: Native[] = [ | 81 | 81 | { | 82 | | - name: 'prettier', | 83 | | - extensions: [ | 84 | | - '.js', | 85 | | - '.jsx', | 86 | | - '.mjs', | 87 | | - '.cjs', | 88 | | - '.ts', | 89 | | - '.tsx', | 90 | | - '.mts', | 91 | | - '.cts', | 92 | | - '.html', | 93 | | - '.htm', | 94 | | - '.css', | 95 | | - '.scss', | 96 | | - '.sass', | 97 | | - '.less', | 98 | | - '.vue', | 99 | | - '.svelte', | 100 | | - '.json', | 101 | | - '.jsonc', | 102 | | - '.yaml', | 103 | | - '.yml', | 104 | | - '.toml', | 105 | | - '.xml', | 106 | | - '.md', | 107 | | - '.mdx', | 108 | | - '.php', | 109 | | - '.rb', | 110 | | - '.java', | 111 | | - '.go', | 112 | | - '.rs', | 113 | | - '.swift', | 114 | | - '.kt', | 115 | | - '.kts', | 116 | | - '.sol', | 117 | | - '.graphql', | 118 | | - '.gql', | 119 | | - ], | 120 | | - command: [BunProc.which(), 'run', 'prettier', '--write', '$FILE'], | | 82 | + name: "prettier", | | 83 | + command: [BunProc.which(), "run", "prettier", "--write", "$FILE"], | 121 | 84 | environment: { | 122 | | - BUN_BE_BUN: '1', | | 85 | + BUN_BE_BUN: "1", | 123 | 86 | }, | | 87 | + extensions: [ | | 88 | + ".js", | | 89 | + ".jsx", | | 90 | + ".mjs", | | 91 | + ".cjs", | | 92 | + ".ts", | | 93 | + ".tsx", | | 94 | + ".mts", | | 95 | + ".cts", | | 96 | + ".html", | | 97 | + ".htm", | | 98 | + ".css", | | 99 | + ".scss", | | 100 | + ".sass", | | 101 | + ".less", | | 102 | + ".vue", | | 103 | + ".svelte", | | 104 | + ".json", | | 105 | + ".jsonc", | | 106 | + ".yaml", | | 107 | + ".yml", | | 108 | + ".toml", | | 109 | + ".xml", | | 110 | + ".md", | | 111 | + ".mdx", | | 112 | + ".php", | | 113 | + ".rb", | | 114 | + ".java", | | 115 | + ".go", | | 116 | + ".rs", | | 117 | + ".swift", | | 118 | + ".kt", | | 119 | + ".kts", | | 120 | + ".sol", | | 121 | + ".graphql", | | 122 | + ".gql", | | 123 | + ], | 124 | 124 | async enabled() { | 125 | 125 | try { | 126 | 126 | const proc = Bun.spawn({ | 127 | | - cmd: [BunProc.which(), 'run', 'prettier', '--version'], | | 127 | + cmd: [BunProc.which(), "run", "prettier", "--version"], | 128 | 128 | cwd: App.info().path.cwd, | 129 | 129 | env: { | 130 | | - BUN_BE_BUN: '1', | | 130 | + BUN_BE_BUN: "1", | 131 | 131 | }, | 132 | | - stdout: 'ignore', | 133 | | - stderr: 'ignore', | | 132 | + stdout: "ignore", | | 133 | + stderr: "ignore", | 134 | 134 | }) | 135 | 135 | const exit = await proc.exited | 136 | 136 | return exit === 0 | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/tool/edit.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,6 +80,7 @@ export const EditTool = Tool.define({ | 80 | 80 | ) | 81 | 81 | await file.write(contentNew) | 82 | 82 | await Format.run(filepath) | | 83 | + contentNew = await file.text() | 83 | 84 | })() | 84 | 85 |
| 85 | 86 | const diff = trimDiff( | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/util/lazy.ts -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,4 +8,3 @@ export function lazy<T>(fn: () => T) { | 8 | 8 | return value as T | 9 | 9 | } | 10 | 10 | } | 11 | | - |
|