diff --git a/STATS.md b/STATS.md index b92604813..15f6f99ab 100644 --- a/STATS.md +++ b/STATS.md @@ -93,3 +93,5 @@ | 2025-09-26 | 404,334 (+5,455) | 306,713 (+5,050) | 711,047 (+10,505) | | 2025-09-27 | 411,618 (+7,284) | 317,763 (+11,050) | 729,381 (+18,334) | | 2025-09-28 | 414,910 (+3,292) | 322,522 (+4,759) | 737,432 (+8,051) | +| 2025-09-29 | 419,919 (+5,009) | 328,033 (+5,511) | 747,952 (+10,520) | +| 2025-09-30 | 427,991 (+8,072) | 336,472 (+8,439) | 764,463 (+16,511) | diff --git a/bun.lock b/bun.lock index ca8303a35..b647af823 100644 --- a/bun.lock +++ b/bun.lock @@ -12,7 +12,7 @@ }, "packages/app": { "name": "@opencode/app", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@kobalte/core": "0.13.11", "@opencode-ai/sdk": "workspace:*", @@ -60,7 +60,7 @@ }, "packages/console/core": { "name": "@opencode/console-core", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@aws-sdk/client-sts": "3.782.0", "@opencode/console-resource": "workspace:*", @@ -77,7 +77,7 @@ }, "packages/console/function": { "name": "@opencode/console-function", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@ai-sdk/anthropic": "2.0.0", "@ai-sdk/openai": "2.0.2", @@ -103,7 +103,7 @@ }, "packages/console/scripts": { "name": "@opencode/console-scripts", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@opencode/console-core": "workspace:*", "tsx": "4.20.5", @@ -115,7 +115,7 @@ }, "packages/function": { "name": "@opencode/function", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@octokit/auth-app": "8.0.1", "@octokit/rest": "22.0.0", @@ -130,7 +130,7 @@ }, "packages/opencode": { "name": "opencode", - "version": "0.13.2", + "version": "0.13.5", "bin": { "opencode": "./bin/opencode", }, @@ -190,7 +190,7 @@ }, "packages/plugin": { "name": "@opencode-ai/plugin", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@opencode-ai/sdk": "workspace:*", "zod": "catalog:", @@ -202,7 +202,7 @@ }, "packages/sdk/js": { "name": "@opencode-ai/sdk", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@hey-api/openapi-ts": "0.82.5", }, @@ -213,7 +213,7 @@ }, "packages/web": { "name": "@opencode/web", - "version": "0.13.2", + "version": "0.13.5", "dependencies": { "@astrojs/cloudflare": "12.6.3", "@astrojs/markdown-remark": "6.3.1", diff --git a/github/sst-env.d.ts b/github/sst-env.d.ts index 6b69016e7..f742a1200 100644 --- a/github/sst-env.d.ts +++ b/github/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/infra/app.ts b/infra/app.ts index 465ed9052..151879208 100644 --- a/infra/app.ts +++ b/infra/app.ts @@ -2,6 +2,7 @@ import { domain } from "./stage" const GITHUB_APP_ID = new sst.Secret("GITHUB_APP_ID") const GITHUB_APP_PRIVATE_KEY = new sst.Secret("GITHUB_APP_PRIVATE_KEY") +export const EMAILOCTOPUS_API_KEY = new sst.Secret("EMAILOCTOPUS_API_KEY") const bucket = new sst.cloudflare.Bucket("Bucket") export const api = new sst.cloudflare.Worker("Api", { diff --git a/infra/console.ts b/infra/console.ts index b898995d9..bab661975 100644 --- a/infra/console.ts +++ b/infra/console.ts @@ -1,4 +1,5 @@ import { domain } from "./stage" +import { EMAILOCTOPUS_API_KEY } from "./app" //////////////// // DATABASE @@ -121,7 +122,7 @@ if ($app.stage === "production" || $app.stage === "frank") { new sst.cloudflare.x.SolidStart("Console", { domain, path: "packages/console/app", - link: [database, AUTH_API_URL, STRIPE_WEBHOOK_SECRET, STRIPE_SECRET_KEY, ZEN_MODELS], + link: [database, AUTH_API_URL, STRIPE_WEBHOOK_SECRET, STRIPE_SECRET_KEY, ZEN_MODELS, EMAILOCTOPUS_API_KEY], environment: { //VITE_DOCS_URL: web.url.apply((url) => url!), //VITE_API_URL: gateway.url.apply((url) => url!), diff --git a/packages/app/package.json b/packages/app/package.json index ededee45d..75ebe811d 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/app", - "version": "0.13.2", + "version": "0.13.5", "description": "", "type": "module", "scripts": { diff --git a/packages/app/src/sst-env.d.ts b/packages/app/src/sst-env.d.ts index 1b1683a1e..47a8fbec7 100644 --- a/packages/app/src/sst-env.d.ts +++ b/packages/app/src/sst-env.d.ts @@ -2,7 +2,9 @@ /* tslint:disable */ /* eslint-disable */ /// -interface ImportMetaEnv {} +interface ImportMetaEnv { + +} interface ImportMeta { readonly env: ImportMetaEnv -} +} \ No newline at end of file diff --git a/packages/app/sst-env.d.ts b/packages/app/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/app/sst-env.d.ts +++ b/packages/app/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/console/app/package.json b/packages/console/app/package.json index fd9d579e0..d4816175f 100644 --- a/packages/console/app/package.json +++ b/packages/console/app/package.json @@ -7,7 +7,7 @@ "dev:remote": "VITE_AUTH_URL=https://auth.dev.opencode.ai bun sst shell --stage=dev bun dev", "build": "vinxi build && ../../opencode/script/schema.ts ./.output/public/config.json", "start": "vinxi start", - "version": "0.13.2" + "version": "0.13.5" }, "dependencies": { "@ibm/plex": "6.4.1", diff --git a/packages/console/app/src/routes/workspace/member-section.tsx b/packages/console/app/src/routes/workspace/member-section.tsx index 602c29efc..d0afd7eb9 100644 --- a/packages/console/app/src/routes/workspace/member-section.tsx +++ b/packages/console/app/src/routes/workspace/member-section.tsx @@ -5,7 +5,7 @@ import { createStore } from "solid-js/store" import { formatDateUTC, formatDateForTable } from "./common" import styles from "./member-section.module.css" import { and, Database, eq, sql } from "@opencode/console-core/drizzle/index.js" -import { UserTable } from "@opencode/console-core/schema/user.sql.js" +import { UserTable, UserRole } from "@opencode/console-core/schema/user.sql.js" import { Identifier } from "@opencode/console-core/identifier.js" const removeMember = action(async (form: FormData) => { @@ -31,10 +31,12 @@ const removeMember = action(async (form: FormData) => { const inviteMember = action(async (form: FormData) => { "use server" - const name = form.get("name")?.toString().trim() - if (!name) return { error: "Name is required" } + const email = form.get("email")?.toString().trim() + if (!email) return { error: "Email is required" } const workspaceID = form.get("workspaceID")?.toString() if (!workspaceID) return { error: "Workspace ID is required" } + const role = form.get("role")?.toString() as (typeof UserRole)[number] + if (!role) return { error: "Role is required" } return json( await withActor( () => @@ -44,12 +46,10 @@ const inviteMember = action(async (form: FormData) => { .values({ id: Identifier.create("user"), name: "", - email: name, + email, workspaceID, - role: "member", - timeJoined: sql`now()`, + role, }) - .onDuplicateKeyUpdate({ set: { timeJoined: sql`now()` } }) .then((data) => ({ error: undefined, data })) .catch((e) => ({ error: e.message as string })), ), @@ -109,7 +109,23 @@ export function MemberCreateForm() { >
- (input = r)} data-component="input" name="name" type="text" placeholder="Enter email" /> + (input = r)} data-component="input" name="email" type="text" placeholder="Enter email" /> +
+ + +
{(err) =>
{err()}
}
@@ -160,15 +176,15 @@ export function MemberSection() { {(member) => { - const [copied, setCopied] = createSignal(false) - // const submission = useSubmission(removeKey, ([fd]) => fd.get("id")?.toString() === key.id) return ( {member.email} {member.role} - - {formatDateForTable(member.timeJoined!)} - + invited}> + + {formatDateForTable(member.timeSeen!)} + + diff --git a/packages/console/app/sst-env.d.ts b/packages/console/app/sst-env.d.ts index bd5588217..9b9de7327 100644 --- a/packages/console/app/sst-env.d.ts +++ b/packages/console/app/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/console/core/migrations/0020_supreme_jack_power.sql b/packages/console/core/migrations/0020_supreme_jack_power.sql new file mode 100644 index 000000000..93e34e142 --- /dev/null +++ b/packages/console/core/migrations/0020_supreme_jack_power.sql @@ -0,0 +1 @@ +ALTER TABLE `user` DROP COLUMN `time_joined`; \ No newline at end of file diff --git a/packages/console/core/migrations/meta/0020_snapshot.json b/packages/console/core/migrations/meta/0020_snapshot.json new file mode 100644 index 000000000..662093f55 --- /dev/null +++ b/packages/console/core/migrations/meta/0020_snapshot.json @@ -0,0 +1,695 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "908437f9-54ed-4c83-b555-614926e326f8", + "prevId": "a2bb7222-561c-45f0-8939-8ef9b8e57bb3", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "email": { + "name": "email", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "billing": { + "name": "billing", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_id": { + "name": "payment_method_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_method_last4": { + "name": "payment_method_last4", + "type": "varchar(4)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "balance": { + "name": "balance", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "monthly_limit": { + "name": "monthly_limit", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "monthly_usage": { + "name": "monthly_usage", + "type": "bigint", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_monthly_usage_updated": { + "name": "time_monthly_usage_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reload": { + "name": "reload", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reload_error": { + "name": "reload_error", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_error": { + "name": "time_reload_error", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_reload_locked_till": { + "name": "time_reload_locked_till", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_customer_id": { + "name": "global_customer_id", + "columns": [ + "customer_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "billing_workspace_id_id_pk": { + "name": "billing_workspace_id_id_pk", + "columns": [ + "workspace_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "payment": { + "name": "payment", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "customer_id": { + "name": "customer_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "invoice_id": { + "name": "invoice_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payment_id": { + "name": "payment_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "amount": { + "name": "amount", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_refunded": { + "name": "time_refunded", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "payment_workspace_id_id_pk": { + "name": "payment_workspace_id_id_pk", + "columns": [ + "workspace_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "usage": { + "name": "usage", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "output_tokens": { + "name": "output_tokens", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_5m_tokens": { + "name": "cache_write_5m_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cache_write_1h_tokens": { + "name": "cache_write_1h_tokens", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost": { + "name": "cost", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "usage_workspace_id_id_pk": { + "name": "usage_workspace_id_id_pk", + "columns": [ + "workspace_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "key": { + "name": "key", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "json", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "old_name": { + "name": "old_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_used": { + "name": "time_used", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "global_key": { + "name": "global_key", + "columns": [ + "key" + ], + "isUnique": true + }, + "name": { + "name": "name", + "columns": [ + "workspace_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "key_workspace_id_id_pk": { + "name": "key_workspace_id_id_pk", + "columns": [ + "workspace_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "time_seen": { + "name": "time_seen", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "int", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "enum('admin','member')", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "user_email": { + "name": "user_email", + "columns": [ + "workspace_id", + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_workspace_id_id_pk": { + "name": "user_workspace_id_id_pk", + "columns": [ + "workspace_id", + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "workspace": { + "name": "workspace", + "columns": { + "id": { + "name": "id", + "type": "varchar(30)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "time_created": { + "name": "time_created", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(now())" + }, + "time_updated": { + "name": "time_updated", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)" + }, + "time_deleted": { + "name": "time_deleted", + "type": "timestamp(3)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "slug": { + "name": "slug", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_id": { + "name": "workspace_id", + "columns": [ + "id" + ] + } + }, + "uniqueConstraints": {}, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/console/core/migrations/meta/_journal.json b/packages/console/core/migrations/meta/_journal.json index d19c9a11a..5b45082fd 100644 --- a/packages/console/core/migrations/meta/_journal.json +++ b/packages/console/core/migrations/meta/_journal.json @@ -141,6 +141,13 @@ "when": 1759103696975, "tag": "0019_dazzling_cable", "breakpoints": true + }, + { + "idx": 20, + "version": "5", + "when": 1759169697658, + "tag": "0020_supreme_jack_power", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/console/core/package.json b/packages/console/core/package.json index a87c74bd2..fb46a9bcc 100644 --- a/packages/console/core/package.json +++ b/packages/console/core/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@opencode/console-core", - "version": "0.13.2", + "version": "0.13.5", "private": true, "type": "module", "dependencies": { diff --git a/packages/console/core/src/actor.ts b/packages/console/core/src/actor.ts index 9f2216f9c..f9db01293 100644 --- a/packages/console/core/src/actor.ts +++ b/packages/console/core/src/actor.ts @@ -21,7 +21,7 @@ export namespace Actor { properties: { userID: string workspaceID: string - role: UserRole + role: (typeof UserRole)[number] } } diff --git a/packages/console/core/src/schema/user.sql.ts b/packages/console/core/src/schema/user.sql.ts index 0c2bba947..34939474e 100644 --- a/packages/console/core/src/schema/user.sql.ts +++ b/packages/console/core/src/schema/user.sql.ts @@ -2,8 +2,7 @@ import { mysqlTable, uniqueIndex, varchar, int, mysqlEnum } from "drizzle-orm/my import { timestamps, utc, workspaceColumns } from "../drizzle/types" import { workspaceIndexes } from "./workspace.sql" -const UserRole = ["admin", "member"] as const -export type UserRole = (typeof UserRole)[number] +export const UserRole = ["admin", "member"] as const export const UserTable = mysqlTable( "user", @@ -13,9 +12,8 @@ export const UserTable = mysqlTable( email: varchar("email", { length: 255 }).notNull(), name: varchar("name", { length: 255 }).notNull(), timeSeen: utc("time_seen"), - timeJoined: utc("time_joined"), color: int("color"), - role: mysqlEnum("role", ["admin", "member"]).notNull(), + role: mysqlEnum("role", UserRole).notNull(), }, (table) => [...workspaceIndexes(table), uniqueIndex("user_email").on(table.workspaceID, table.email)], ) diff --git a/packages/console/core/src/workspace.ts b/packages/console/core/src/workspace.ts index 5067803ee..0ff3a1532 100644 --- a/packages/console/core/src/workspace.ts +++ b/packages/console/core/src/workspace.ts @@ -21,8 +21,8 @@ export namespace Workspace { id: Identifier.create("user"), email: account.properties.email, name: "", + timeSeen: sql`now()`, role: "admin", - timeJoined: sql`now()`, }) await tx.insert(BillingTable).values({ workspaceID, diff --git a/packages/console/core/sst-env.d.ts b/packages/console/core/sst-env.d.ts index bd5588217..9b9de7327 100644 --- a/packages/console/core/sst-env.d.ts +++ b/packages/console/core/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/console/function/package.json b/packages/console/function/package.json index 6fa31a936..2461ac880 100644 --- a/packages/console/function/package.json +++ b/packages/console/function/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/console-function", - "version": "0.13.2", + "version": "0.13.5", "$schema": "https://json.schemastore.org/package.json", "private": true, "type": "module", diff --git a/packages/console/function/sst-env.d.ts b/packages/console/function/sst-env.d.ts index c14ff4acc..0cd862dff 100644 --- a/packages/console/function/sst-env.d.ts +++ b/packages/console/function/sst-env.d.ts @@ -6,75 +6,83 @@ import "sst" declare module "sst" { export interface Resource { - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string } - Console: { - type: "sst.cloudflare.SolidStart" - url: string + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string + "Desktop": { + "type": "sst.cloudflare.StaticSite" + "url": string } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string + "EMAILOCTOPUS_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - Web: { - type: "sst.cloudflare.Astro" - url: string + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string } - ZEN_MODELS: { - type: "sst.sst.Secret" - value: string + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "ZEN_MODELS": { + "type": "sst.sst.Secret" + "value": string } } } -// cloudflare -import * as cloudflare from "@cloudflare/workers-types" +// cloudflare +import * as cloudflare from "@cloudflare/workers-types"; declare module "sst" { export interface Resource { - Api: cloudflare.Service - AuthApi: cloudflare.Service - AuthStorage: cloudflare.KVNamespace - Bucket: cloudflare.R2Bucket - LogProcessor: cloudflare.Service + "Api": cloudflare.Service + "AuthApi": cloudflare.Service + "AuthStorage": cloudflare.KVNamespace + "Bucket": cloudflare.R2Bucket + "LogProcessor": cloudflare.Service } } import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/console/resource/sst-env.d.ts b/packages/console/resource/sst-env.d.ts index c14ff4acc..0cd862dff 100644 --- a/packages/console/resource/sst-env.d.ts +++ b/packages/console/resource/sst-env.d.ts @@ -6,75 +6,83 @@ import "sst" declare module "sst" { export interface Resource { - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string } - Console: { - type: "sst.cloudflare.SolidStart" - url: string + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string + "Desktop": { + "type": "sst.cloudflare.StaticSite" + "url": string } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string + "EMAILOCTOPUS_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - Web: { - type: "sst.cloudflare.Astro" - url: string + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string } - ZEN_MODELS: { - type: "sst.sst.Secret" - value: string + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "ZEN_MODELS": { + "type": "sst.sst.Secret" + "value": string } } } -// cloudflare -import * as cloudflare from "@cloudflare/workers-types" +// cloudflare +import * as cloudflare from "@cloudflare/workers-types"; declare module "sst" { export interface Resource { - Api: cloudflare.Service - AuthApi: cloudflare.Service - AuthStorage: cloudflare.KVNamespace - Bucket: cloudflare.R2Bucket - LogProcessor: cloudflare.Service + "Api": cloudflare.Service + "AuthApi": cloudflare.Service + "AuthStorage": cloudflare.KVNamespace + "Bucket": cloudflare.R2Bucket + "LogProcessor": cloudflare.Service } } import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/console/scripts/package.json b/packages/console/scripts/package.json index e02ed041f..11beb8fe0 100644 --- a/packages/console/scripts/package.json +++ b/packages/console/scripts/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/console-scripts", - "version": "0.13.2", + "version": "0.13.5", "$schema": "https://json.schemastore.org/package.json", "private": true, "type": "module", diff --git a/packages/console/scripts/sst-env.d.ts b/packages/console/scripts/sst-env.d.ts index bd5588217..9b9de7327 100644 --- a/packages/console/scripts/sst-env.d.ts +++ b/packages/console/scripts/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/function/package.json b/packages/function/package.json index 4f09e6be3..a96b4118c 100644 --- a/packages/function/package.json +++ b/packages/function/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/function", - "version": "0.13.2", + "version": "0.13.5", "$schema": "https://json.schemastore.org/package.json", "private": true, "type": "module", diff --git a/packages/function/sst-env.d.ts b/packages/function/sst-env.d.ts index c14ff4acc..0cd862dff 100644 --- a/packages/function/sst-env.d.ts +++ b/packages/function/sst-env.d.ts @@ -6,75 +6,83 @@ import "sst" declare module "sst" { export interface Resource { - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string } - Console: { - type: "sst.cloudflare.SolidStart" - url: string + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string + "Desktop": { + "type": "sst.cloudflare.StaticSite" + "url": string } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string + "EMAILOCTOPUS_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - Web: { - type: "sst.cloudflare.Astro" - url: string + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string } - ZEN_MODELS: { - type: "sst.sst.Secret" - value: string + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "ZEN_MODELS": { + "type": "sst.sst.Secret" + "value": string } } } -// cloudflare -import * as cloudflare from "@cloudflare/workers-types" +// cloudflare +import * as cloudflare from "@cloudflare/workers-types"; declare module "sst" { export interface Resource { - Api: cloudflare.Service - AuthApi: cloudflare.Service - AuthStorage: cloudflare.KVNamespace - Bucket: cloudflare.R2Bucket - LogProcessor: cloudflare.Service + "Api": cloudflare.Service + "AuthApi": cloudflare.Service + "AuthStorage": cloudflare.KVNamespace + "Bucket": cloudflare.R2Bucket + "LogProcessor": cloudflare.Service } } import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/opencode/package.json b/packages/opencode/package.json index 986fbf144..9afcb87d6 100644 --- a/packages/opencode/package.json +++ b/packages/opencode/package.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/package.json", - "version": "0.13.2", + "version": "0.13.5", "name": "opencode", "type": "module", "private": true, diff --git a/packages/opencode/src/cli/cmd/debug/file.ts b/packages/opencode/src/cli/cmd/debug/file.ts index 898b7d390..7be304737 100644 --- a/packages/opencode/src/cli/cmd/debug/file.ts +++ b/packages/opencode/src/cli/cmd/debug/file.ts @@ -2,6 +2,22 @@ import { File } from "../../../file" import { bootstrap } from "../../bootstrap" import { cmd } from "../cmd" +const FileSearchCommand = cmd({ + command: "search ", + builder: (yargs) => + yargs.positional("query", { + type: "string", + demandOption: true, + description: "Search query", + }), + async handler(args) { + await bootstrap(process.cwd(), async () => { + const results = await File.search({ query: args.query }) + console.log(results.join("\n")) + }) + }, +}) + const FileReadCommand = cmd({ command: "read ", builder: (yargs) => @@ -48,6 +64,11 @@ const FileListCommand = cmd({ export const FileCommand = cmd({ command: "file", builder: (yargs) => - yargs.command(FileReadCommand).command(FileStatusCommand).command(FileListCommand).demandCommand(), + yargs + .command(FileReadCommand) + .command(FileStatusCommand) + .command(FileListCommand) + .command(FileSearchCommand) + .demandCommand(), async handler() {}, }) diff --git a/packages/opencode/src/cli/cmd/debug/ripgrep.ts b/packages/opencode/src/cli/cmd/debug/ripgrep.ts index ec3f9cb83..884b291b5 100644 --- a/packages/opencode/src/cli/cmd/debug/ripgrep.ts +++ b/packages/opencode/src/cli/cmd/debug/ripgrep.ts @@ -40,12 +40,14 @@ const FilesCommand = cmd({ }), async handler(args) { await bootstrap(process.cwd(), async () => { - const files = await Ripgrep.files({ + const files: string[] = [] + for await (const file of Ripgrep.files({ cwd: Instance.directory, - query: args.query, glob: args.glob ? [args.glob] : undefined, - limit: args.limit, - }) + })) { + files.push(file) + if (args.limit && files.length >= args.limit) break + } console.log(files.join("\n")) }) }, diff --git a/packages/opencode/src/config/markdown.ts b/packages/opencode/src/config/markdown.ts index e0e5afe42..a4dcbf5d4 100644 --- a/packages/opencode/src/config/markdown.ts +++ b/packages/opencode/src/config/markdown.ts @@ -1,6 +1,6 @@ export namespace ConfigMarkdown { export const FILE_REGEX = /(? { + type Entry = { files: string[]; dirs: string[] } + let cache: Entry = { files: [], dirs: [] } + let fetching = false + const fn = async (result: Entry) => { + fetching = true + const set = new Set() + for await (const file of Ripgrep.files({ cwd: Instance.directory })) { + result.files.push(file) + let current = file + while (true) { + const dir = path.dirname(current) + if (dir === current) break + current = dir + if (set.has(dir)) continue + set.add(dir) + result.dirs.push(dir + "/") + } + } + cache = result + fetching = false + } + fn(cache) + + return { + async files() { + if (!fetching) { + fn({ + files: [], + dirs: [], + }) + } + return cache + }, + } + }) + export async function status() { const project = Instance.project if (project.vcs !== "git") return [] @@ -203,4 +242,12 @@ export namespace File { return a.name.localeCompare(b.name) }) } + + export async function search(input: { query: string; limit?: number }) { + const limit = input.limit ?? 100 + const result = await state().then((x) => x.files()) + const items = input.query ? [...result.files, ...result.dirs] : [...result.dirs] + const sorted = fuzzysort.go(input.query, items, { limit: limit }).map((r) => r.target) + return sorted + } } diff --git a/packages/opencode/src/file/ripgrep.ts b/packages/opencode/src/file/ripgrep.ts index 1cbf6b8a8..d023f47c3 100644 --- a/packages/opencode/src/file/ripgrep.ts +++ b/packages/opencode/src/file/ripgrep.ts @@ -6,7 +6,7 @@ import z from "zod/v4" import { NamedError } from "../util/error" import { lazy } from "../util/lazy" import { $ } from "bun" -import { Fzf } from "./fzf" + import { ZipReader, BlobReader, BlobWriter } from "@zip.js/zip.js" export namespace Ripgrep { @@ -203,24 +203,48 @@ export namespace Ripgrep { return filepath } - export async function files(input: { cwd: string; query?: string; glob?: string[]; limit?: number }) { - const commands = [`${$.escape(await filepath())} --files --follow --hidden --glob='!.git/*'`] - + export async function* files(input: { cwd: string; glob?: string[] }) { + const args = [await filepath(), "--files", "--follow", "--hidden", "--glob=!.git/*"] if (input.glob) { for (const g of input.glob) { - commands[0] += ` --glob='${g}'` + args.push(`--glob=${g}`) } } - if (input.query) commands.push(`${await Fzf.filepath()} --filter=${input.query}`) - if (input.limit) commands.push(`head -n ${input.limit}`) - const joined = commands.join(" | ") - const result = await $`${{ raw: joined }}`.cwd(input.cwd).nothrow().text() - return result.split("\n").filter(Boolean) + const proc = Bun.spawn(args, { + cwd: input.cwd, + stdout: "pipe", + stderr: "ignore", + maxBuffer: 1024 * 1024 * 20, + }) + + const reader = proc.stdout.getReader() + const decoder = new TextDecoder() + let buffer = "" + + try { + while (true) { + const { done, value } = await reader.read() + if (done) break + + buffer += decoder.decode(value, { stream: true }) + const lines = buffer.split("\n") + buffer = lines.pop() || "" + + for (const line of lines) { + if (line) yield line + } + } + + if (buffer) yield buffer + } finally { + reader.releaseLock() + await proc.exited + } } export async function tree(input: { cwd: string; limit?: number }) { - const files = await Ripgrep.files({ cwd: input.cwd }) + const files = await Array.fromAsync(Ripgrep.files({ cwd: input.cwd })) interface Node { path: string[] children: Node[] diff --git a/packages/opencode/src/project/project.ts b/packages/opencode/src/project/project.ts index 37a03cc2b..88134483e 100644 --- a/packages/opencode/src/project/project.ts +++ b/packages/opencode/src/project/project.ts @@ -62,14 +62,12 @@ export namespace Project { await Storage.write(["project", "global"], project) return project } - worktree = path.dirname( - await $`git rev-parse --path-format=absolute --git-common-dir` - .quiet() - .nothrow() - .cwd(worktree) - .text() - .then((x) => x.trim()), - ) + worktree = await $`git rev-parse --path-format=absolute --show-toplevel` + .quiet() + .nothrow() + .cwd(worktree) + .text() + .then((x) => x.trim()) const project: Info = { id, worktree, diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts index 9f74cbfa3..a8103538f 100644 --- a/packages/opencode/src/server/server.ts +++ b/packages/opencode/src/server/server.ts @@ -985,12 +985,11 @@ export namespace Server { ), async (c) => { const query = c.req.valid("query").query - const result = await Ripgrep.files({ - cwd: Instance.directory, + const results = await File.search({ query, limit: 10, }) - return c.json(result) + return c.json(results) }, ) .get( diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index 200b831b6..8c6d5358e 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -581,9 +581,15 @@ export namespace SessionPrompt { } break case "file:": + log.info("file", { mime: part.mime }) // have to normalize, symbol search returns absolute paths // Decode the pathname since URL constructor doesn't automatically decode it - const filePath = decodeURIComponent(url.pathname) + const filepath = decodeURIComponent(url.pathname) + const stat = await Bun.file(filepath).stat() + + if (stat.isDirectory()) { + part.mime = "application/x-directory" + } if (part.mime === "text/plain") { let offset: number | undefined = undefined @@ -620,7 +626,7 @@ export namespace SessionPrompt { limit = end - offset } } - const args = { filePath, offset, limit } + const args = { filePath: filepath, offset, limit } const result = await ReadTool.init().then((t) => t.execute(args, { sessionID: input.sessionID, @@ -658,7 +664,7 @@ export namespace SessionPrompt { } if (part.mime === "application/x-directory") { - const args = { path: filePath } + const args = { path: filepath } const result = await ListTool.init().then((t) => t.execute(args, { sessionID: input.sessionID, @@ -695,15 +701,15 @@ export namespace SessionPrompt { ] } - const file = Bun.file(filePath) - FileTime.read(input.sessionID, filePath) + const file = Bun.file(filepath) + FileTime.read(input.sessionID, filepath) return [ { id: Identifier.ascending("part"), messageID: info.id, sessionID: input.sessionID, type: "text", - text: `Called the Read tool with the following input: {\"filePath\":\"${filePath}\"}`, + text: `Called the Read tool with the following input: {\"filePath\":\"${filepath}\"}`, synthetic: true, }, { diff --git a/packages/opencode/src/session/prompt/anthropic-20250930.txt b/packages/opencode/src/session/prompt/anthropic-20250930.txt new file mode 100644 index 000000000..7a4faea63 --- /dev/null +++ b/packages/opencode/src/session/prompt/anthropic-20250930.txt @@ -0,0 +1,166 @@ +You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user. + +IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Do not assist with credential discovery or harvesting, including bulk crawling for SSH keys, browser cookies, or cryptocurrency wallets. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation. +IMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files. + +If the user asks for help or wants to give feedback inform them of the following: +- /help: Get help with using Claude Code +- To give feedback, users should report the issue at https://github.com/anthropics/claude-code/issues + +When the user directly asks about Claude Code (eg. "can Claude Code do...", "does Claude Code have..."), or asks in second person (eg. "are you able...", "can you do..."), or asks how to use a specific Claude Code feature (eg. implement a hook, or write a slash command), use the WebFetch tool to gather information to answer the question from Claude Code docs. The list of available docs is available at https://docs.claude.com/en/docs/claude-code/claude_code_docs_map.md. + +# Tone and style +You should be concise, direct, and to the point, while providing complete information and matching the level of detail you provide in your response with the level of complexity of the user's query or the work you have completed. +A concise response is generally less than 4 lines, not including tool calls or code generated. You should provide more detail when the task is complex or when the user asks you to. +IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do. +IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to. +Do not add additional code explanation summary unless requested by the user. After working on a file, briefly confirm that you have completed the task, rather than providing an explanation of what you did. +Answer the user's question directly, avoiding any elaboration, explanation, introduction, conclusion, or excessive details. Brief answers are best, but be sure to provide complete information. You MUST avoid extra preamble before/after your response, such as "The answer is .", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". + +Here are some examples to demonstrate appropriate verbosity: + +user: 2 + 2 +assistant: 4 + + + +user: what is 2+2? +assistant: 4 + + + +user: is 11 a prime number? +assistant: Yes + + + +user: what command should I run to list files in the current directory? +assistant: ls + + + +user: what command should I run to watch files in the current directory? +assistant: [runs ls to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files] +npm run dev + + + +user: How many golf balls fit inside a jetta? +assistant: 150000 + + + +user: what files are in the directory src/? +assistant: [runs ls and sees foo.c, bar.c, baz.c] +user: which file contains the implementation of foo? +assistant: src/foo.c + +When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system). +Remember that your output will be displayed on a command line interface. Your responses can use Github-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification. +Output text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session. +If you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences. +Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked. +IMPORTANT: Keep your responses short, since they will be displayed on a command line interface. + +# Proactiveness +You are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between: +- Doing the right thing when asked, including taking actions and follow-up actions +- Not surprising the user with actions you take without asking +For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions. + +# Professional objectivity +Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if Claude honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs. + +# Task Management +You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress. +These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable. + +It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed. + +Examples: + + +user: Run the build and fix any type errors +assistant: I'm going to use the TodoWrite tool to write the following items to the todo list: +- Run the build +- Fix any type errors + +I'm now going to run the build using Bash. + +Looks like I found 10 type errors. I'm going to use the TodoWrite tool to write 10 items to the todo list. + +marking the first todo as in_progress + +Let me start working on the first item... + +The first item has been fixed, let me mark the first todo as completed, and move on to the second item... +.. +.. + +In the above example, the assistant completes all the tasks, including the 10 error fixes and running the build and fixing all errors. + + +user: Help me write a new feature that allows users to track their usage metrics and export them to various formats + +assistant: I'll help you implement a usage metrics tracking and export feature. Let me first use the TodoWrite tool to plan this task. +Adding the following todos to the todo list: +1. Research existing metrics tracking in the codebase +2. Design the metrics collection system +3. Implement core metrics tracking functionality +4. Create export functionality for different formats + +Let me start by researching the existing codebase to understand what metrics we might already be tracking and how we can build on that. + +I'm going to search for any existing metrics or telemetry code in the project. + +I've found some existing telemetry code. Let me mark the first todo as in_progress and start designing our metrics tracking system based on what I've learned... + +[Assistant continues implementing the feature step by step, marking todos as in_progress and completed as they go] + + + +Users may configure 'hooks', shell commands that execute in response to events like tool calls, in settings. Treat feedback from hooks, including , as coming from the user. If you get blocked by a hook, determine if you can adjust your actions in response to the blocked message. If not, ask the user to check their hooks configuration. + +# Doing tasks +The user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended: +- Use the TodoWrite tool to plan the task if required + +- Tool results and user messages may include tags. tags contain useful information and reminders. They are automatically added by the system, and bear no direct relation to the specific tool results or user messages in which they appear. + + +# Tool usage policy +- When doing file search, prefer to use the Task tool in order to reduce context usage. +- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description. + +- When WebFetch returns a message about a redirect to a different host, you should immediately make a new WebFetch request with the redirect URL provided in the response. +- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel. +- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks. For example, if you need to launch multiple agents in parallel, send a single message with multiple Task tool calls. +- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit for editing instead of sed/awk, and Write for creating files instead of cat with heredoc or echo redirection. Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead. + + +Here is useful information about the environment you are running in: + +Working directory: /home/thdxr/dev/projects/sst/opencode/packages/opencode +Is directory a git repo: Yes +Platform: linux +OS Version: Linux 6.12.4-arch1-1 +Today's date: 2025-09-30 + +You are powered by the model named Sonnet 4.5. The exact model ID is claude-sonnet-4-5-20250929. + +Assistant knowledge cutoff is January 2025. + + +IMPORTANT: Assist with defensive security tasks only. Refuse to create, modify, or improve code that may be used maliciously. Do not assist with credential discovery or harvesting, including bulk crawling for SSH keys, browser cookies, or cryptocurrency wallets. Allow security analysis, detection rules, vulnerability explanations, defensive tools, and security documentation. + + +IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation. + +# Code References + +When referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location. + + +user: Where are errors from the client handled? +assistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712. + diff --git a/packages/opencode/src/session/prompt/anthropic.txt b/packages/opencode/src/session/prompt/anthropic.txt index a2e5c07b6..6e623fdad 100644 --- a/packages/opencode/src/session/prompt/anthropic.txt +++ b/packages/opencode/src/session/prompt/anthropic.txt @@ -8,7 +8,7 @@ If the user asks for help or wants to give feedback inform them of the following # Tone and style You should be concise, direct, and to the point. -You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. +You should be concise, direct, and to the point, while providing complete information and matching the level of detail you provide in your response with the level of complexity of the user's query or the work you have completed. IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do. IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did. @@ -63,6 +63,9 @@ You are allowed to be proactive, but only when the user asks you to do something - Not surprising the user with actions you take without asking For example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions. +# Professional objectivity +Prioritize technical accuracy and truthfulness over validating the user's beliefs. Focus on facts and problem-solving, providing direct, objective technical info without any unnecessary superlatives, praise, or emotional validation. It is best for the user if Claude honestly applies the same rigorous standards to all ideas and disagrees when necessary, even if it may not be what the user wants to hear. Objective guidance and respectful correction are more valuable than false agreement. Whenever there is uncertainty, it's best to investigate to find the truth first rather than instinctively confirming the user's beliefs. + # Following conventions When making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns. - NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language). diff --git a/packages/opencode/src/tool/glob.ts b/packages/opencode/src/tool/glob.ts index dbbe88680..7553a5aa5 100644 --- a/packages/opencode/src/tool/glob.ts +++ b/packages/opencode/src/tool/glob.ts @@ -23,7 +23,7 @@ export const GlobTool = Tool.define("glob", { const limit = 100 const files = [] let truncated = false - for (const file of await Ripgrep.files({ + for await (const file of Ripgrep.files({ cwd: search, glob: [params.pattern], })) { diff --git a/packages/opencode/src/tool/ls.ts b/packages/opencode/src/tool/ls.ts index fbac41c9b..b80f668a5 100644 --- a/packages/opencode/src/tool/ls.ts +++ b/packages/opencode/src/tool/ls.ts @@ -44,11 +44,11 @@ export const ListTool = Tool.define("list", { const searchPath = path.resolve(Instance.directory, params.path || ".") const ignoreGlobs = IGNORE_PATTERNS.map((p) => `!${p}*`).concat(params.ignore?.map((p) => `!${p}`) || []) - const files = await Ripgrep.files({ - cwd: searchPath, - glob: ignoreGlobs, - limit: LIMIT, - }) + const files = [] + for await (const file of Ripgrep.files({ cwd: searchPath, glob: ignoreGlobs })) { + files.push(file) + if (files.length >= LIMIT) break + } // Build directory structure const dirs = new Set() diff --git a/packages/opencode/sst-env.d.ts b/packages/opencode/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/opencode/sst-env.d.ts +++ b/packages/opencode/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 1774ae882..b89a0c78a 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@opencode-ai/plugin", - "version": "0.13.2", + "version": "0.13.5", "type": "module", "scripts": { "typecheck": "tsc --noEmit", diff --git a/packages/plugin/sst-env.d.ts b/packages/plugin/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/plugin/sst-env.d.ts +++ b/packages/plugin/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json index bf4a7b38f..b5ed8b2a3 100644 --- a/packages/sdk/js/package.json +++ b/packages/sdk/js/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@opencode-ai/sdk", - "version": "0.13.2", + "version": "0.13.5", "type": "module", "scripts": { "typecheck": "tsc --noEmit", diff --git a/packages/sdk/js/sst-env.d.ts b/packages/sdk/js/sst-env.d.ts index bd5588217..9b9de7327 100644 --- a/packages/sdk/js/sst-env.d.ts +++ b/packages/sdk/js/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go index 6352dbc74..a09e809f0 100644 --- a/packages/tui/internal/components/chat/messages.go +++ b/packages/tui/internal/components/chat/messages.go @@ -664,7 +664,7 @@ func (m *messagesComponent) renderView() tea.Cmd { error = err.Data.Message } - if !hasContent && error == "" && !reverted { + if !hasContent && error == "" && !reverted && casted.Time.Completed == 0 { content = renderText( m.app, message.Info, diff --git a/packages/tui/internal/components/dialog/models.go b/packages/tui/internal/components/dialog/models.go index 110151147..e30a1068e 100644 --- a/packages/tui/internal/components/dialog/models.go +++ b/packages/tui/internal/components/dialog/models.go @@ -303,7 +303,8 @@ func (m *modelDialog) buildSearchResults(query string) []list.Item { for _, match := range matches { model := modelMap[match.Target] // Create a unique key to avoid duplicates - key := fmt.Sprintf("%s:%s", model.Provider.ID, model.Model.ID) + // Include name to handle custom models with same ID but different names + key := fmt.Sprintf("%s:%s:%s", model.Provider.ID, model.Model.ID, model.Model.Name) if seenModels[key] { continue } diff --git a/packages/web/package.json b/packages/web/package.json index 1608bff2f..baee8f20d 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,7 +1,7 @@ { "name": "@opencode/web", "type": "module", - "version": "0.13.2", + "version": "0.13.5", "scripts": { "dev": "astro dev", "dev:remote": "VITE_API_URL=https://api.opencode.ai astro dev", diff --git a/packages/web/src/content/docs/models.mdx b/packages/web/src/content/docs/models.mdx index efebc5cb4..b3fc4c28f 100644 --- a/packages/web/src/content/docs/models.mdx +++ b/packages/web/src/content/docs/models.mdx @@ -100,10 +100,41 @@ You can globally configure a model's options through the config. } ``` -Here we're configuring global settings for two models: `gpt-5` when accessed via the `openai` provider, and `claude-sonnet-4-20250514` when accessed via the `anthropic` provider. +Here we're configuring global settings for two built-in models: `gpt-5` when accessed via the `openai` provider, and `claude-sonnet-4-20250514` when accessed via the `anthropic` provider. +The built-in provider and model names can be found on [Models.dev](https://models.dev). You can also configure these options for any agents that you are using. The agent config overrides any global options here. [Learn more](/docs/agents/#additional). +You can also define custom models that extend built-in ones and can optionally use specific options by referring to their id: + +```jsonc title="opencode.jsonc" {6-20} +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "opencode": { + "models": { + "gpt-5-high": { + "id": "gpt-5", + "options": { + "reasoningEffort": "high", + "textVerbosity": "low", + "reasoningSummary": "auto" + } + }, + "gpt-5-low": { + "id": "gpt-5", + "options": { + "reasoningEffort": "low", + "textVerbosity": "low", + "reasoningSummary": "auto" + } + } + } + } + } +} +``` + --- ## Loading models diff --git a/packages/web/sst-env.d.ts b/packages/web/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/packages/web/sst-env.d.ts +++ b/packages/web/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/sdks/vscode/package.json b/sdks/vscode/package.json index 4835d9f52..c419cf4c8 100644 --- a/sdks/vscode/package.json +++ b/sdks/vscode/package.json @@ -2,7 +2,7 @@ "name": "opencode", "displayName": "opencode", "description": "opencode for VS Code", - "version": "0.13.2", + "version": "0.13.5", "publisher": "sst-dev", "repository": { "type": "git", diff --git a/sdks/vscode/sst-env.d.ts b/sdks/vscode/sst-env.d.ts index 0397645b5..b6a7e9066 100644 --- a/sdks/vscode/sst-env.d.ts +++ b/sdks/vscode/sst-env.d.ts @@ -6,4 +6,4 @@ /// import "sst" -export {} +export {} \ No newline at end of file diff --git a/sst-env.d.ts b/sst-env.d.ts index a8370105d..f6fdecb7b 100644 --- a/sst-env.d.ts +++ b/sst-env.d.ts @@ -5,83 +5,91 @@ declare module "sst" { export interface Resource { - AUTH_API_URL: { - type: "sst.sst.Linkable" - value: string + "AUTH_API_URL": { + "type": "sst.sst.Linkable" + "value": string } - Api: { - type: "sst.cloudflare.Worker" - url: string + "Api": { + "type": "sst.cloudflare.Worker" + "url": string } - AuthApi: { - type: "sst.cloudflare.Worker" - url: string + "AuthApi": { + "type": "sst.cloudflare.Worker" + "url": string } - AuthStorage: { - type: "sst.cloudflare.Kv" + "AuthStorage": { + "type": "sst.cloudflare.Kv" } - Bucket: { - name: string - type: "sst.cloudflare.Bucket" + "Bucket": { + "name": string + "type": "sst.cloudflare.Bucket" } - Console: { - type: "sst.cloudflare.SolidStart" - url: string + "Console": { + "type": "sst.cloudflare.SolidStart" + "url": string } - Database: { - database: string - host: string - password: string - port: number - type: "sst.sst.Linkable" - username: string + "Database": { + "database": string + "host": string + "password": string + "port": number + "type": "sst.sst.Linkable" + "username": string } - GITHUB_APP_ID: { - type: "sst.sst.Secret" - value: string + "Desktop": { + "type": "sst.cloudflare.StaticSite" + "url": string } - GITHUB_APP_PRIVATE_KEY: { - type: "sst.sst.Secret" - value: string + "EMAILOCTOPUS_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_ID_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_ID": { + "type": "sst.sst.Secret" + "value": string } - GITHUB_CLIENT_SECRET_CONSOLE: { - type: "sst.sst.Secret" - value: string + "GITHUB_APP_PRIVATE_KEY": { + "type": "sst.sst.Secret" + "value": string } - GOOGLE_CLIENT_ID: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_ID_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - HONEYCOMB_API_KEY: { - type: "sst.sst.Secret" - value: string + "GITHUB_CLIENT_SECRET_CONSOLE": { + "type": "sst.sst.Secret" + "value": string } - LogProcessor: { - type: "sst.cloudflare.Worker" + "GOOGLE_CLIENT_ID": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_SECRET_KEY: { - type: "sst.sst.Secret" - value: string + "HONEYCOMB_API_KEY": { + "type": "sst.sst.Secret" + "value": string } - STRIPE_WEBHOOK_SECRET: { - type: "sst.sst.Linkable" - value: string + "LogProcessor": { + "type": "sst.cloudflare.Worker" } - Web: { - type: "sst.cloudflare.Astro" - url: string + "STRIPE_SECRET_KEY": { + "type": "sst.sst.Secret" + "value": string } - ZEN_MODELS: { - type: "sst.sst.Secret" - value: string + "STRIPE_WEBHOOK_SECRET": { + "type": "sst.sst.Linkable" + "value": string + } + "Web": { + "type": "sst.cloudflare.Astro" + "url": string + } + "ZEN_MODELS": { + "type": "sst.sst.Secret" + "value": string } } } /// import "sst" -export {} +export {} \ No newline at end of file