repo
stringlengths
7
64
file_url
stringlengths
81
338
file_path
stringlengths
5
257
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:25:31
2026-01-05 01:50:38
truncated
bool
2 classes
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/retry.ts
packages/util/src/retry.ts
export interface RetryOptions { attempts?: number delay?: number factor?: number maxDelay?: number retryIf?: (error: unknown) => boolean } const TRANSIENT_MESSAGES = [ "load failed", "network connection was lost", "network request failed", "failed to fetch", "econnreset", "econnrefused", "etime...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/lazy.ts
packages/util/src/lazy.ts
export function lazy<T>(fn: () => T) { let value: T | undefined let loaded = false return (): T => { if (loaded) return value as T loaded = true value = fn() return value as T } }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/iife.ts
packages/util/src/iife.ts
export function iife<T>(fn: () => T) { return fn() }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/identifier.ts
packages/util/src/identifier.ts
import { randomBytes } from "crypto" export namespace Identifier { const LENGTH = 26 // State for monotonic ID generation let lastTimestamp = 0 let counter = 0 export function ascending() { return create(false) } export function descending() { return create(true) } function randomBase62(l...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/encode.ts
packages/util/src/encode.ts
export function base64Encode(value: string) { const bytes = new TextEncoder().encode(value) const binary = Array.from(bytes, (b) => String.fromCharCode(b)).join("") return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "") } export function base64Decode(value: string) { const binary = atob(...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/binary.ts
packages/util/src/binary.ts
export namespace Binary { export function search<T>(array: T[], id: string, compare: (item: T) => string): { found: boolean; index: number } { let left = 0 let right = array.length - 1 while (left <= right) { const mid = Math.floor((left + right) / 2) const midId = compare(array[mid]) ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/util/src/error.ts
packages/util/src/error.ts
import z from "zod" export abstract class NamedError extends Error { abstract schema(): z.core.$ZodType abstract toObject(): { name: string; data: any } static create<Name extends string, Data extends z.core.$ZodType>(name: Name, data: Data) { const schema = z .object({ name: z.literal(name), ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/plugin/sst-env.d.ts
packages/plugin/sst-env.d.ts
/* This file is auto-generated by SST. Do not edit. */ /* tslint:disable */ /* eslint-disable */ /* deno-fmt-ignore-file */ /// <reference path="../../sst-env.d.ts" /> import "sst" export {}
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/plugin/src/example.ts
packages/plugin/src/example.ts
import { Plugin } from "./index" import { tool } from "./tool" export const ExamplePlugin: Plugin = async (ctx) => { return { tool: { mytool: tool({ description: "This is a custom tool", args: { foo: tool.schema.string().describe("foo"), }, async execute(args) { ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/plugin/src/shell.ts
packages/plugin/src/shell.ts
export type ShellFunction = (input: Uint8Array) => Uint8Array export type ShellExpression = | { toString(): string } | Array<ShellExpression> | string | { raw: string } | ReadableStream export interface BunShell { (strings: TemplateStringsArray, ...expressions: ShellExpression[]): BunShellPromise /** ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/plugin/src/tool.ts
packages/plugin/src/tool.ts
import { z } from "zod" export type ToolContext = { sessionID: string messageID: string agent: string abort: AbortSignal } export function tool<Args extends z.ZodRawShape>(input: { description: string args: Args execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string> }) { retu...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/plugin/src/index.ts
packages/plugin/src/index.ts
import type { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage, Message, Part, Auth, Config, } from "@opencode-ai/sdk" import type { BunShell } from "./shell" import { type ToolDefinition } from "./tool" export * from "./tool" export type ProviderContext = { sour...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/plugin/script/publish.ts
packages/plugin/script/publish.ts
#!/usr/bin/env bun import { Script } from "@opencode-ai/script" import { $ } from "bun" const dir = new URL("..", import.meta.url).pathname process.chdir(dir) await $`bun tsc` const pkg = await import("../package.json").then((m) => m.default) const original = JSON.parse(JSON.stringify(pkg)) for (const [key, value] of...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/sst-env.d.ts
packages/app/sst-env.d.ts
/* This file is auto-generated by SST. Do not edit. */ /* tslint:disable */ /* eslint-disable */ /* deno-fmt-ignore-file */ /// <reference path="../../sst-env.d.ts" /> import "sst" export {}
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/happydom.ts
packages/app/happydom.ts
import { GlobalRegistrator } from "@happy-dom/global-registrator" GlobalRegistrator.register() const originalGetContext = HTMLCanvasElement.prototype.getContext // @ts-expect-error - we're overriding with a simplified mock HTMLCanvasElement.prototype.getContext = function (contextType: string, _options?: unknown) { ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/vite.config.ts
packages/app/vite.config.ts
import { defineConfig } from "vite" import desktopPlugin from "./vite" export default defineConfig({ plugins: [desktopPlugin] as any, server: { host: "0.0.0.0", allowedHosts: true, port: 3000, }, build: { target: "esnext", // sourcemap: true, }, })
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/custom-elements.d.ts
packages/app/src/custom-elements.d.ts
import { DIFFS_TAG_NAME } from "@pierre/diffs" /** * TypeScript declaration for the <diffs-container> custom element. * This tells TypeScript that <diffs-container> is a valid JSX element in SolidJS. * Required for using the @pierre/diffs web component in .tsx files. */ declare module "solid-js" { namespace JSX...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/sst-env.d.ts
packages/app/src/sst-env.d.ts
/* This file is auto-generated by SST. Do not edit. */ /* tslint:disable */ /* eslint-disable */ /// <reference types="vite/client" /> interface ImportMetaEnv { } interface ImportMeta { readonly env: ImportMetaEnv }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/app.tsx
packages/app/src/app.tsx
import "@/index.css" import { ErrorBoundary, Show, type ParentProps } from "solid-js" import { Router, Route, Navigate } from "@solidjs/router" import { MetaProvider } from "@solidjs/meta" import { Font } from "@opencode-ai/ui/font" import { MarkedProvider } from "@opencode-ai/ui/context/marked" import { DiffComponentP...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/env.d.ts
packages/app/src/env.d.ts
interface ImportMetaEnv { readonly VITE_OPENCODE_SERVER_HOST: string readonly VITE_OPENCODE_SERVER_PORT: string } interface ImportMeta { readonly env: ImportMetaEnv }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/index.ts
packages/app/src/index.ts
export { PlatformProvider, type Platform } from "./context/platform" export { App } from "./app"
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/entry.tsx
packages/app/src/entry.tsx
// @refresh reload import { render } from "solid-js/web" import { App } from "@/app" import { Platform, PlatformProvider } from "@/context/platform" import pkg from "../package.json" const root = document.getElementById("root") if (import.meta.env.DEV && !(root instanceof HTMLElement)) { throw new Error( "Root e...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/addons/serialize.ts
packages/app/src/addons/serialize.ts
/** * SerializeAddon - Serialize terminal buffer contents * * Port of xterm.js addon-serialize for ghostty-web. * Enables serialization of terminal contents to a string that can * be written back to restore terminal state. * * Usage: * ```typescript * const serializeAddon = new SerializeAddon(); * term.loadAd...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/addons/serialize.test.ts
packages/app/src/addons/serialize.test.ts
import { describe, test, expect, beforeAll, afterEach } from "bun:test" import { Terminal, Ghostty } from "ghostty-web" import { SerializeAddon } from "./serialize" let ghostty: Ghostty beforeAll(async () => { ghostty = await Ghostty.load() }) const terminals: Terminal[] = [] afterEach(() => { for (const term of...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/hooks/use-providers.ts
packages/app/src/hooks/use-providers.ts
import { useGlobalSync } from "@/context/global-sync" import { base64Decode } from "@opencode-ai/util/encode" import { useParams } from "@solidjs/router" import { createMemo } from "solid-js" export const popularProviders = ["opencode", "anthropic", "github-copilot", "openai", "google", "openrouter", "vercel"] export...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/pages/directory-layout.tsx
packages/app/src/pages/directory-layout.tsx
import { createMemo, Show, type ParentProps } from "solid-js" import { useParams } from "@solidjs/router" import { SDKProvider, useSDK } from "@/context/sdk" import { SyncProvider, useSync } from "@/context/sync" import { LocalProvider } from "@/context/local" import { base64Decode } from "@opencode-ai/util/encode" im...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/pages/layout.tsx
packages/app/src/pages/layout.tsx
import { createEffect, createMemo, createSignal, For, Match, onCleanup, onMount, ParentProps, Show, Switch, untrack, type JSX, } from "solid-js" import { DateTime } from "luxon" import { A, useNavigate, useParams } from "@solidjs/router" import { useLayout, getAvatarColors, LocalProject } from "...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
true
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/pages/error.tsx
packages/app/src/pages/error.tsx
import { TextField } from "@opencode-ai/ui/text-field" import { Logo } from "@opencode-ai/ui/logo" import { Button } from "@opencode-ai/ui/button" import { Component, Show } from "solid-js" import { createStore } from "solid-js/store" import { usePlatform } from "@/context/platform" import { Icon } from "@opencode-ai/u...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/pages/session.tsx
packages/app/src/pages/session.tsx
import { For, onCleanup, Show, Match, Switch, createMemo, createEffect, on, batch } from "solid-js" import { createMediaQuery } from "@solid-primitives/media" import { Dynamic } from "solid-js/web" import { useLocal } from "@/context/local" import { selectionFromLines, useFile, type SelectedLineRange } from "@/context/...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
true
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/pages/home.tsx
packages/app/src/pages/home.tsx
import { useGlobalSync } from "@/context/global-sync" import { createMemo, For, Match, Show, Switch } from "solid-js" import { Button } from "@opencode-ai/ui/button" import { Logo } from "@opencode-ai/ui/logo" import { useLayout } from "@/context/layout" import { useNavigate } from "@solidjs/router" import { base64Enco...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/prompt-input.tsx
packages/app/src/components/prompt-input.tsx
import { useFilteredList } from "@opencode-ai/ui/hooks" import { createEffect, on, Component, Show, For, onMount, onCleanup, Switch, Match, createMemo } from "solid-js" import { createStore, produce } from "solid-js/store" import { createFocusSignal } from "@solid-primitives/active-element" import { useLocal } from "@/...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
true
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-connect-provider.tsx
packages/app/src/components/dialog-connect-provider.tsx
import type { ProviderAuthAuthorization } from "@opencode-ai/sdk/v2/client" import { Button } from "@opencode-ai/ui/button" import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import { Icon } from "@opencode-ai/ui/icon" import { IconButton } from "@opencode-ai/ui/i...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-provider.tsx
packages/app/src/components/dialog-select-provider.tsx
import { Component, Show } from "solid-js" import { useDialog } from "@opencode-ai/ui/context/dialog" import { popularProviders, useProviders } from "@/hooks/use-providers" import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" import { Tag } from "@opencode-ai/ui/tag" import { Prov...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session-lsp-indicator.tsx
packages/app/src/components/session-lsp-indicator.tsx
import { createMemo, Show } from "solid-js" import { useSync } from "@/context/sync" import { Tooltip } from "@opencode-ai/ui/tooltip" export function SessionLspIndicator() { const sync = useSync() const lspStats = createMemo(() => { const lsp = sync.data.lsp ?? [] const connected = lsp.filter((s) => s.st...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-server.tsx
packages/app/src/components/dialog-select-server.tsx
import { createEffect, createMemo, onCleanup } from "solid-js" import { createStore, reconcile } from "solid-js/store" import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" import { TextField } from "@opencode-ai/ui/text-fi...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-model-unpaid.tsx
packages/app/src/components/dialog-select-model-unpaid.tsx
import { Button } from "@opencode-ai/ui/button" import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import type { IconName } from "@opencode-ai/ui/icons/provider" import { List, type ListRef } from "@opencode-ai/ui/list" import { ProviderIcon } from "@opencode-ai/u...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session-mcp-indicator.tsx
packages/app/src/components/session-mcp-indicator.tsx
import { createMemo, Show } from "solid-js" import { Button } from "@opencode-ai/ui/button" import { useDialog } from "@opencode-ai/ui/context/dialog" import { useSync } from "@/context/sync" import { DialogSelectMcp } from "@/components/dialog-select-mcp" export function SessionMcpIndicator() { const sync = useSync...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/terminal.tsx
packages/app/src/components/terminal.tsx
import { Ghostty, Terminal as Term, FitAddon } from "ghostty-web" import { ComponentProps, createEffect, createSignal, onCleanup, onMount, splitProps } from "solid-js" import { useSDK } from "@/context/sdk" import { SerializeAddon } from "@/addons/serialize" import { LocalPTY } from "@/context/terminal" import { resolv...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session-context-usage.tsx
packages/app/src/components/session-context-usage.tsx
import { Match, Show, Switch, createMemo } from "solid-js" import { Tooltip } from "@opencode-ai/ui/tooltip" import { ProgressCircle } from "@opencode-ai/ui/progress-circle" import { Button } from "@opencode-ai/ui/button" import { useParams } from "@solidjs/router" import { AssistantMessage } from "@opencode-ai/sdk/v2/...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-model.tsx
packages/app/src/components/dialog-select-model.tsx
import { Popover as Kobalte } from "@kobalte/core/popover" import { Component, createMemo, createSignal, JSX, Show } from "solid-js" import { useLocal } from "@/context/local" import { useDialog } from "@opencode-ai/ui/context/dialog" import { popularProviders } from "@/hooks/use-providers" import { Button } from "@ope...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/file-tree.tsx
packages/app/src/components/file-tree.tsx
import { useLocal, type LocalFile } from "@/context/local" import { Collapsible } from "@opencode-ai/ui/collapsible" import { FileIcon } from "@opencode-ai/ui/file-icon" import { Tooltip } from "@opencode-ai/ui/tooltip" import { For, Match, Switch, type ComponentProps, type ParentProps } from "solid-js" import { Dynami...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-directory.tsx
packages/app/src/components/dialog-select-directory.tsx
import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import { FileIcon } from "@opencode-ai/ui/file-icon" import { List } from "@opencode-ai/ui/list" import { getDirectory, getFilename } from "@opencode-ai/util/path" import { createMemo } from "solid-js" import { us...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-manage-models.tsx
packages/app/src/components/dialog-manage-models.tsx
import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" import { Switch } from "@opencode-ai/ui/switch" import type { Component } from "solid-js" import { useLocal } from "@/context/local" import { popularProviders } from "@/hooks/use-providers" export const DialogManageModels: Comp...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/link.tsx
packages/app/src/components/link.tsx
import { ComponentProps, splitProps } from "solid-js" import { usePlatform } from "@/context/platform" export interface LinkProps extends ComponentProps<"button"> { href: string } export function Link(props: LinkProps) { const platform = usePlatform() const [local, rest] = splitProps(props, ["href", "children"]...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-mcp.tsx
packages/app/src/components/dialog-select-mcp.tsx
import { Component, createMemo, createSignal, Show } from "solid-js" import { useSync } from "@/context/sync" import { useSDK } from "@/context/sdk" import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" import { Switch } from "@opencode-ai/ui/switch" export const DialogSelectMcp: ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-edit-project.tsx
packages/app/src/components/dialog-edit-project.tsx
import { Button } from "@opencode-ai/ui/button" import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import { TextField } from "@opencode-ai/ui/text-field" import { Icon } from "@opencode-ai/ui/icon" import { createMemo, createSignal, For, Show } from "solid-js" imp...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/dialog-select-file.tsx
packages/app/src/components/dialog-select-file.tsx
import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import { FileIcon } from "@opencode-ai/ui/file-icon" import { List } from "@opencode-ai/ui/list" import { getDirectory, getFilename } from "@opencode-ai/util/path" import { useParams } from "@solidjs/router" impor...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session/session-new-view.tsx
packages/app/src/components/session/session-new-view.tsx
import { Show, createMemo } from "solid-js" import { DateTime } from "luxon" import { useSync } from "@/context/sync" import { Icon } from "@opencode-ai/ui/icon" import { getDirectory, getFilename } from "@opencode-ai/util/path" import { Select } from "@opencode-ai/ui/select" const MAIN_WORKTREE = "main" const CREATE_...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session/session-sortable-tab.tsx
packages/app/src/components/session/session-sortable-tab.tsx
import { createMemo, Show } from "solid-js" import type { JSX } from "solid-js" import { createSortable } from "@thisbeyond/solid-dnd" import { FileIcon } from "@opencode-ai/ui/file-icon" import { IconButton } from "@opencode-ai/ui/icon-button" import { Tooltip } from "@opencode-ai/ui/tooltip" import { Tabs } from "@op...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session/session-context-tab.tsx
packages/app/src/components/session/session-context-tab.tsx
import { createMemo, createEffect, on, onCleanup, For, Show } from "solid-js" import type { JSX } from "solid-js" import { useParams } from "@solidjs/router" import { DateTime } from "luxon" import { useSync } from "@/context/sync" import { useLayout } from "@/context/layout" import { checksum } from "@opencode-ai/util...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session/index.ts
packages/app/src/components/session/index.ts
export { SessionHeader } from "./session-header" export { SessionContextTab } from "./session-context-tab" export { SortableTab, FileVisual } from "./session-sortable-tab" export { SortableTerminalTab } from "./session-sortable-terminal-tab" export { NewSessionView } from "./session-new-view"
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session/session-sortable-terminal-tab.tsx
packages/app/src/components/session/session-sortable-terminal-tab.tsx
import type { JSX } from "solid-js" import { createSortable } from "@thisbeyond/solid-dnd" import { IconButton } from "@opencode-ai/ui/icon-button" import { Tabs } from "@opencode-ai/ui/tabs" import { useTerminal, type LocalPTY } from "@/context/terminal" export function SortableTerminalTab(props: { terminal: LocalPTY...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/components/session/session-header.tsx
packages/app/src/components/session/session-header.tsx
import { createEffect, createMemo, createResource, Show } from "solid-js" import { A, useNavigate, useParams } from "@solidjs/router" import { useLayout } from "@/context/layout" import { useCommand } from "@/context/command" import { useServer } from "@/context/server" import { useDialog } from "@opencode-ai/ui/contex...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/persist.ts
packages/app/src/utils/persist.ts
import { usePlatform } from "@/context/platform" import { makePersisted } from "@solid-primitives/storage" import { createResource, type Accessor } from "solid-js" import type { SetStoreFunction, Store } from "solid-js/store" type InitType = Promise<string> | string | null type PersistedWithReady<T> = [Store<T>, SetSt...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/id.ts
packages/app/src/utils/id.ts
import z from "zod" const prefixes = { session: "ses", message: "msg", permission: "per", user: "usr", part: "prt", pty: "pty", } as const const LENGTH = 26 let lastTimestamp = 0 let counter = 0 type Prefix = keyof typeof prefixes export namespace Identifier { export function schema(prefix: Prefix) { ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/dom.ts
packages/app/src/utils/dom.ts
export function getCharacterOffsetInLine(lineElement: Element, targetNode: Node, offset: number): number { const r = document.createRange() r.selectNodeContents(lineElement) r.setEnd(targetNode, offset) return r.toString().length } export function getNodeOffsetInLine(lineElement: Element, charIndex: number): {...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/speech.ts
packages/app/src/utils/speech.ts
import { createSignal, onCleanup } from "solid-js" // Minimal types to avoid relying on non-standard DOM typings type RecognitionResult = { 0: { transcript: string } isFinal: boolean } type RecognitionEvent = { results: RecognitionResult[] resultIndex: number } interface Recognition { continuous: boolean ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/solid-dnd.tsx
packages/app/src/utils/solid-dnd.tsx
import { useDragDropContext } from "@thisbeyond/solid-dnd" import { JSXElement } from "solid-js" import type { Transformer } from "@thisbeyond/solid-dnd" export const getDraggableId = (event: unknown): string | undefined => { if (typeof event !== "object" || event === null) return undefined if (!("draggable" in ev...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/index.ts
packages/app/src/utils/index.ts
export * from "./dom"
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/utils/prompt.ts
packages/app/src/utils/prompt.ts
import type { Part, TextPart, FilePart } from "@opencode-ai/sdk/v2" import type { Prompt, FileAttachmentPart } from "@/context/prompt" /** * Extract prompt content from message parts for restoring into the prompt input. * This is used by undo to restore the original user prompt. */ export function extractPromptFrom...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/sdk.tsx
packages/app/src/context/sdk.tsx
import { createOpencodeClient, type Event } from "@opencode-ai/sdk/v2/client" import { createSimpleContext } from "@opencode-ai/ui/context" import { createGlobalEmitter } from "@solid-primitives/event-bus" import { useGlobalSDK } from "./global-sdk" import { usePlatform } from "./platform" export const { use: useSDK, ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/prompt.tsx
packages/app/src/context/prompt.tsx
import { createStore } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import { batch, createMemo } from "solid-js" import { useParams } from "@solidjs/router" import type { FileSelection } from "@/context/file" import { persisted } from "@/utils/persist" interface PartBase { cont...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/sync.tsx
packages/app/src/context/sync.tsx
import { batch, createMemo } from "solid-js" import { produce, reconcile } from "solid-js/store" import { Binary } from "@opencode-ai/util/binary" import { retry } from "@opencode-ai/util/retry" import { createSimpleContext } from "@opencode-ai/ui/context" import { useGlobalSync } from "./global-sync" import { useSDK }...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/layout.tsx
packages/app/src/context/layout.tsx
import { createStore, produce } from "solid-js/store" import { batch, createMemo, onMount } from "solid-js" import { createSimpleContext } from "@opencode-ai/ui/context" import { useGlobalSync } from "./global-sync" import { useGlobalSDK } from "./global-sdk" import { useServer } from "./server" import { Project } from...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/terminal.tsx
packages/app/src/context/terminal.tsx
import { createStore, produce } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import { batch, createMemo } from "solid-js" import { useParams } from "@solidjs/router" import { useSDK } from "./sdk" import { persisted } from "@/utils/persist" export type LocalPTY = { id: string ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/local.tsx
packages/app/src/context/local.tsx
import { createStore, produce, reconcile } from "solid-js/store" import { batch, createMemo } from "solid-js" import { filter, firstBy, flat, groupBy, mapValues, pipe, uniqueBy, values } from "remeda" import type { FileContent, FileNode, Model, Provider, File as FileStatus } from "@opencode-ai/sdk/v2" import { createSi...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/permission.tsx
packages/app/src/context/permission.tsx
import { createMemo, onCleanup } from "solid-js" import { createStore } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import type { PermissionRequest } from "@opencode-ai/sdk/v2/client" import { persisted } from "@/utils/persist" import { useGlobalSDK } from "@/context/global-sdk" ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/global-sync.tsx
packages/app/src/context/global-sync.tsx
import { type Message, type Agent, type Session, type Part, type Config, type Path, type Project, type FileDiff, type Todo, type SessionStatus, type ProviderListResponse, type ProviderAuthResponse, type Command, type McpStatus, type LspStatus, type VcsInfo, type PermissionRequest, cr...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/notification.tsx
packages/app/src/context/notification.tsx
import { createStore } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import { useGlobalSDK } from "./global-sdk" import { useGlobalSync } from "./global-sync" import { usePlatform } from "@/context/platform" import { Binary } from "@opencode-ai/util/binary" import { base64Encode } ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/server.tsx
packages/app/src/context/server.tsx
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client" import { createSimpleContext } from "@opencode-ai/ui/context" import { batch, createEffect, createMemo, createResource, createSignal, onCleanup } from "solid-js" import { createStore } from "solid-js/store" import { usePlatform } from "@/context/platform...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/file.tsx
packages/app/src/context/file.tsx
import { createMemo, onCleanup } from "solid-js" import { createStore, produce } from "solid-js/store" import { createSimpleContext } from "@opencode-ai/ui/context" import type { FileContent } from "@opencode-ai/sdk/v2" import { showToast } from "@opencode-ai/ui/toast" import { useParams } from "@solidjs/router" import...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/global-sdk.tsx
packages/app/src/context/global-sdk.tsx
import { createOpencodeClient, type Event } from "@opencode-ai/sdk/v2/client" import { createSimpleContext } from "@opencode-ai/ui/context" import { createGlobalEmitter } from "@solid-primitives/event-bus" import { onCleanup } from "solid-js" import { usePlatform } from "./platform" import { useServer } from "./server"...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/command.tsx
packages/app/src/context/command.tsx
import { createMemo, createSignal, onCleanup, onMount, Show, type Accessor } from "solid-js" import { createSimpleContext } from "@opencode-ai/ui/context" import { useDialog } from "@opencode-ai/ui/context/dialog" import { Dialog } from "@opencode-ai/ui/dialog" import { List } from "@opencode-ai/ui/list" const IS_MAC ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/app/src/context/platform.tsx
packages/app/src/context/platform.tsx
import { createSimpleContext } from "@opencode-ai/ui/context" import { AsyncStorage, SyncStorage } from "@solid-primitives/storage" export type Platform = { /** Platform discriminator */ platform: "web" | "desktop" /** App version */ version?: string /** Open a URL in the default browser */ openLink(url:...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/sst-env.d.ts
packages/opencode/sst-env.d.ts
/* This file is auto-generated by SST. Do not edit. */ /* tslint:disable */ /* eslint-disable */ /* deno-fmt-ignore-file */ /// <reference path="../../sst-env.d.ts" /> import "sst" export {}
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/parsers-config.ts
packages/opencode/parsers-config.ts
export default { // NOTE: FOR markdown, javascript and typescript, we use the opentui built-in parsers // Warn: when taking queries from the nvim-treesitter repo, make sure to include the query dependencies as well // marked with for example `; inherits: ecma` at the top of the file. Just put the dependenci...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/index.ts
packages/opencode/src/index.ts
import yargs from "yargs" import { hideBin } from "yargs/helpers" import { RunCommand } from "./cli/cmd/run" import { GenerateCommand } from "./cli/cmd/generate" import { Log } from "./util/log" import { AuthCommand } from "./cli/cmd/auth" import { AgentCommand } from "./cli/cmd/agent" import { UpgradeCommand } from "....
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/storage/storage.ts
packages/opencode/src/storage/storage.ts
import { Log } from "../util/log" import path from "path" import fs from "fs/promises" import { Global } from "../global" import { lazy } from "../util/lazy" import { Lock } from "../util/lock" import { $ } from "bun" import { NamedError } from "@opencode-ai/util/error" import z from "zod" export namespace Storage { ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/locale.ts
packages/opencode/src/util/locale.ts
export namespace Locale { export function titlecase(str: string) { return str.replace(/\b\w/g, (c) => c.toUpperCase()) } export function time(input: number): string { const date = new Date(input) return date.toLocaleTimeString(undefined, { timeStyle: "short" }) } export function datetime(input: ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/filesystem.ts
packages/opencode/src/util/filesystem.ts
import { realpathSync } from "fs" import { exists } from "fs/promises" import { dirname, join, relative } from "path" export namespace Filesystem { /** * On Windows, normalize a path to its canonical casing using the filesystem. * This is needed because Windows paths are case-insensitive but LSP servers * m...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/timeout.ts
packages/opencode/src/util/timeout.ts
export function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> { let timeout: NodeJS.Timeout return Promise.race([ promise.then((result) => { clearTimeout(timeout) return result }), new Promise<never>((_, reject) => { timeout = setTimeout(() => { reject(new Error(`...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/color.ts
packages/opencode/src/util/color.ts
export namespace Color { export function isValidHex(hex?: string): hex is string { if (!hex) return false return /^#[0-9a-fA-F]{6}$/.test(hex) } export function hexToRgb(hex: string): { r: number; g: number; b: number } { const r = parseInt(hex.slice(1, 3), 16) const g = parseInt(hex.slice(3, 5),...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/signal.ts
packages/opencode/src/util/signal.ts
export function signal() { let resolve: any const promise = new Promise((r) => (resolve = r)) return { trigger() { return resolve() }, wait() { return promise }, } }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/keybind.ts
packages/opencode/src/util/keybind.ts
import { isDeepEqual } from "remeda" import type { ParsedKey } from "@opentui/core" export namespace Keybind { /** * Keybind info derived from OpenTUI's ParsedKey with our custom `leader` field. * This ensures type compatibility and catches missing fields at compile time. */ export type Info = Pick<Parsed...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/rpc.ts
packages/opencode/src/util/rpc.ts
export namespace Rpc { type Definition = { [method: string]: (input: any) => any } export function listen(rpc: Definition) { onmessage = async (evt) => { const parsed = JSON.parse(evt.data) if (parsed.type === "rpc.request") { const result = await rpc[parsed.method](parsed.input) ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/eventloop.ts
packages/opencode/src/util/eventloop.ts
import { Log } from "./log" export namespace EventLoop { export async function wait() { return new Promise<void>((resolve) => { const check = () => { const active = [...(process as any)._getActiveHandles(), ...(process as any)._getActiveRequests()] Log.Default.info("eventloop", { ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/lock.ts
packages/opencode/src/util/lock.ts
export namespace Lock { const locks = new Map< string, { readers: number writer: boolean waitingReaders: (() => void)[] waitingWriters: (() => void)[] } >() function get(key: string) { if (!locks.has(key)) { locks.set(key, { readers: 0, writer: false,...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/queue.ts
packages/opencode/src/util/queue.ts
export class AsyncQueue<T> implements AsyncIterable<T> { private queue: T[] = [] private resolvers: ((value: T) => void)[] = [] push(item: T) { const resolve = this.resolvers.shift() if (resolve) resolve(item) else this.queue.push(item) } async next(): Promise<T> { if (this.queue.length > 0)...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/scrap.ts
packages/opencode/src/util/scrap.ts
export const foo: string = "42" export const bar: number = 123 export function dummyFunction(): void { console.log("This is a dummy function") } export function randomHelper(): boolean { return Math.random() > 0.5 }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/fn.ts
packages/opencode/src/util/fn.ts
import { z } from "zod" export function fn<T extends z.ZodType, Result>(schema: T, cb: (input: z.infer<T>) => Result) { const result = (input: z.infer<T>) => { const parsed = schema.parse(input) return cb(parsed) } result.force = (input: z.infer<T>) => cb(input) result.schema = schema return result }...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/lazy.ts
packages/opencode/src/util/lazy.ts
export function lazy<T>(fn: () => T) { let value: T | undefined let loaded = false const result = (): T => { if (loaded) return value as T loaded = true value = fn() return value as T } result.reset = () => { loaded = false value = undefined } return result }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/token.ts
packages/opencode/src/util/token.ts
export namespace Token { const CHARS_PER_TOKEN = 4 export function estimate(input: string) { return Math.max(0, Math.round((input || "").length / CHARS_PER_TOKEN)) } }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/defer.ts
packages/opencode/src/util/defer.ts
export function defer<T extends () => void | Promise<void>>( fn: T, ): T extends () => Promise<void> ? { [Symbol.asyncDispose]: () => Promise<void> } : { [Symbol.dispose]: () => void } { return { [Symbol.dispose]() { fn() }, [Symbol.asyncDispose]() { return Promise.resolve(fn()) }, } a...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/iife.ts
packages/opencode/src/util/iife.ts
export function iife<T>(fn: () => T) { return fn() }
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/log.ts
packages/opencode/src/util/log.ts
import path from "path" import fs from "fs/promises" import { Global } from "../global" import z from "zod" export namespace Log { export const Level = z.enum(["DEBUG", "INFO", "WARN", "ERROR"]).meta({ ref: "LogLevel", description: "Log level" }) export type Level = z.infer<typeof Level> const levelPriority: Re...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/context.ts
packages/opencode/src/util/context.ts
import { AsyncLocalStorage } from "async_hooks" export namespace Context { export class NotFound extends Error { constructor(public override readonly name: string) { super(`No context found for ${name}`) } } export function create<T>(name: string) { const storage = new AsyncLocalStorage<T>() ...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/wildcard.ts
packages/opencode/src/util/wildcard.ts
import { sortBy, pipe } from "remeda" export namespace Wildcard { export function match(str: string, pattern: string) { const regex = new RegExp( "^" + pattern .replace(/[.+^${}()|[\]\\]/g, "\\$&") // escape special regex chars .replace(/\*/g, ".*") // * becomes .* .re...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/util/archive.ts
packages/opencode/src/util/archive.ts
import { $ } from "bun" import path from "path" export namespace Archive { export async function extractZip(zipPath: string, destDir: string) { if (process.platform === "win32") { const winZipPath = path.resolve(zipPath) const winDestDir = path.resolve(destDir) // $global:ProgressPreference sup...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/auth/index.ts
packages/opencode/src/auth/index.ts
import path from "path" import { Global } from "../global" import fs from "fs/promises" import z from "zod" export namespace Auth { export const Oauth = z .object({ type: z.literal("oauth"), refresh: z.string(), access: z.string(), expires: z.number(), enterpriseUrl: z.string().opti...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false
anomalyco/opencode
https://github.com/anomalyco/opencode/blob/0f9130b649f65a8f5d08492e764f47b38f441dca/packages/opencode/src/plugin/index.ts
packages/opencode/src/plugin/index.ts
import type { Hooks, PluginInput, Plugin as PluginInstance } from "@opencode-ai/plugin" import { Config } from "../config/config" import { Bus } from "../bus" import { Log } from "../util/log" import { createOpencodeClient } from "@opencode-ai/sdk" import { Server } from "../server/server" import { BunProc } from "../b...
typescript
MIT
0f9130b649f65a8f5d08492e764f47b38f441dca
2026-01-04T15:39:55.906013Z
false