diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a2e69410c8b..349b6942d75 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,10 +1,11 @@ name: deploy on: - push: - branches: - - dev - - production + # Disabled for forks - requires CLOUDFLARE_API_TOKEN secret + # push: + # branches: + # - dev + # - production workflow_dispatch: concurrency: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cf9c547df89..8ecbe3dd4d5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -67,6 +67,6 @@ jobs: run: | OPENCODE_VERSION=${{ inputs.version }} ./script/publish.ts env: - GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} AUR_KEY: ${{ secrets.AUR_KEY }} NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 1e16bde8cc5..9e2aa546c61 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,58 @@ --- +## 🚨 Fork Notice + +This is a fork of [sst/opencode](https://github.com/sst/opencode) with the following enhancement: + +### **✨ New Feature: Configurable Co-Authored Text** + +**Feature:** Add `include_co_authored_by` configuration option to control whether opencode adds co-authored text to git commit messages and PR descriptions. + +**Based on:** [sst/opencode PR #1369](https://github.com/sst/opencode/pull/1369) - "implement the includeCoAuthoredBy option" + +**Status:** Ready for upstream contribution + +### **How to Enable/Disable Co-Authored Text** + +#### **Disable Co-Authored Text (New Option)** +```bash +# Global configuration +mkdir -p ~/.config/opencode +cat > ~/.config/opencode/opencode.json << 'EOF' +{ + "$schema": "https://opencode.ai/config.json", + "include_co_authored_by": false +} +EOF + +# OR Project-level configuration +cat > opencode.json << 'EOF' +{ + "$schema": "https://opencode.ai/config.json", + "include_co_authored_by": false +} +EOF +``` + +#### **Behavior Changes** + +**With `include_co_authored_by: true` (default):** +```bash +git commit -m "Your commit message + +🤖 Generated with [opencode](https://opencode.ai) + +Co-Authored-By: opencode " +``` + +**With `include_co_authored_by: false`:** +```bash +git commit -m "Your commit message." +``` + +--- + ### Installation ```bash diff --git a/cloud/app/package.json b/cloud/app/package.json index 72163d18aa1..e75d3800fe0 100644 --- a/cloud/app/package.json +++ b/cloud/app/package.json @@ -5,7 +5,7 @@ "dev": "vinxi dev --host 0.0.0.0", "build": "vinxi build", "start": "vinxi start", - "version": "0.5.5" + "version": "0.5.5-fork" }, "dependencies": { "@ibm/plex": "6.4.1", diff --git a/cloud/core/package.json b/cloud/core/package.json index 1da17a1754e..e410002af57 100644 --- a/cloud/core/package.json +++ b/cloud/core/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@opencode/cloud-core", - "version": "0.5.5", + "version": "0.5.5-fork", "private": true, "type": "module", "dependencies": { diff --git a/cloud/function/package.json b/cloud/function/package.json index d2aa13ed0db..40c2bdb7df5 100644 --- a/cloud/function/package.json +++ b/cloud/function/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/cloud-function", - "version": "0.5.5", + "version": "0.5.5-fork", "$schema": "https://json.schemastore.org/package.json", "private": true, "type": "module", diff --git a/cloud/web/package.json b/cloud/web/package.json index 8246cefe0b6..30017405b16 100644 --- a/cloud/web/package.json +++ b/cloud/web/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/cloud-web", - "version": "0.5.5", + "version": "0.5.5-fork", "private": true, "description": "", "type": "module", diff --git a/packages/function/package.json b/packages/function/package.json index 211ebb5c9c8..60c71e70a21 100644 --- a/packages/function/package.json +++ b/packages/function/package.json @@ -1,6 +1,6 @@ { "name": "@opencode/function", - "version": "0.5.5", + "version": "0.5.5-fork", "$schema": "https://json.schemastore.org/package.json", "private": true, "type": "module", diff --git a/packages/opencode/package.json b/packages/opencode/package.json index 9b288567ec9..4a7506ebe0c 100644 --- a/packages/opencode/package.json +++ b/packages/opencode/package.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/package.json", - "version": "0.5.5", + "version": "0.5.5-fork", "name": "opencode", "type": "module", "private": true, diff --git a/packages/opencode/script/publish.ts b/packages/opencode/script/publish.ts index 74cd3dfa6b0..2e97701d0e5 100755 --- a/packages/opencode/script/publish.ts +++ b/packages/opencode/script/publish.ts @@ -5,7 +5,7 @@ import { $ } from "bun" import pkg from "../package.json" -const dry = process.env["OPENCODE_DRY"] === "true" +// const dry = process.env["OPENCODE_DRY"] === "true" // Commented out for fork const version = process.env["OPENCODE_VERSION"]! const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true" @@ -30,7 +30,7 @@ const targets = [ await $`rm -rf dist` const optionalDependencies: Record = {} -const npmTag = snapshot ? "snapshot" : "latest" +// const npmTag = snapshot ? "snapshot" : "latest" // Commented out for fork for (const [os, arch] of targets) { console.log(`building ${os}-${arch}`) const name = `${pkg.name}-${os}-${arch}` @@ -60,7 +60,10 @@ for (const [os, arch] of targets) { 2, ), ) - if (!dry) await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${npmTag}` + // Set permissions for binary files + await $`cd dist/${name} && chmod 777 -R .` + // Skip npm publishing for fork - requires NPM_CONFIG_TOKEN + // if (!dry) await $`cd dist/${name} && chmod 777 -R . && bun publish --access public --tag ${npmTag}` optionalDependencies[name] = version } @@ -84,18 +87,21 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write( 2, ), ) -if (!dry) await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}` +// Skip npm publishing for fork - requires NPM_CONFIG_TOKEN +// if (!dry) await $`cd ./dist/${pkg.name} && bun publish --access public --tag ${npmTag}` if (!snapshot) { for (const key of Object.keys(optionalDependencies)) { await $`cd dist/${key}/bin && zip -r ../../${key}.zip *` } - // Calculate SHA values + // Calculate SHA values - needed for AUR/Homebrew publishing (disabled for fork) + /* const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) const macX64Sha = await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) const macArm64Sha = await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim()) + */ /* AUR package - commented out as AUR is down const pkgbuild = [ @@ -138,6 +144,8 @@ if (!snapshot) { } */ + // Skip Homebrew publishing for fork - requires push access to sst/homebrew-tap + /* // Homebrew formula const homebrewFormula = [ "# typed: false", @@ -195,4 +203,5 @@ if (!snapshot) { await $`cd ./dist/homebrew-tap && git add opencode.rb` await $`cd ./dist/homebrew-tap && git commit -m "Update to v${version}"` if (!dry) await $`cd ./dist/homebrew-tap && git push` + */ } diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 752014c53b0..17b8cb3f4cb 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -318,6 +318,7 @@ export namespace Config { .optional() .describe("@deprecated Use 'share' field instead. Share newly created sessions automatically"), autoupdate: z.boolean().optional().describe("Automatically update to the latest version"), + include_co_authored_by: z.boolean().optional().describe("Include co-authored-by text in commit messages"), disabled_providers: z.array(z.string()).optional().describe("Disable providers that are loaded automatically"), model: z.string().describe("Model to use in the format of provider/model, eg anthropic/claude-2").optional(), small_model: z diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index da1559c5065..f0217f3e1cc 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -11,6 +11,7 @@ import { Log } from "../util/log" import { Wildcard } from "../util/wildcard" import { $ } from "bun" import { Agent } from "../agent/agent" +import { Config } from "../config/config" const MAX_OUTPUT_LENGTH = 30_000 const DEFAULT_TIMEOUT = 1 * 60 * 1000 @@ -18,6 +19,22 @@ const MAX_TIMEOUT = 10 * 60 * 1000 const log = Log.create({ service: "bash-tool" }) +function replaceCoAuthoredMessage(description: string, includeCoAuthoredBy?: boolean) { + if (includeCoAuthoredBy === false) { + return description.replace("${commitCoAuthored1}", ".") + .replace("${commitCoAuthored2}", "") + .replace("${prCoAuthored}", "") + } + + const generatedWith = "🤖 Generated with [opencode](https://opencode.ai)" + const coAuthoredBy = `${generatedWith}\nCo-Authored-By: opencode ` + + // Add co-authoring text when option is true + return description.replace("${commitCoAuthored1}", ` ending with:\n ${coAuthoredBy}`) + .replace("${commitCoAuthored2}", `\n\n ${coAuthoredBy}`) + .replace("${prCoAuthored}", `\n\n${generatedWith}`) +} + const parser = lazy(async () => { try { const { default: Parser } = await import("tree-sitter") @@ -43,18 +60,20 @@ const parser = lazy(async () => { } }) -export const BashTool = Tool.define("bash", { - description: DESCRIPTION, - parameters: z.object({ - command: z.string().describe("The command to execute"), - timeout: z.number().describe("Optional timeout in milliseconds").optional(), - description: z - .string() - .describe( - "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'", - ), - }), - async execute(params, ctx) { +export const BashTool = Tool.define("bash", async () => { + const cfg = await Config.get() + return { + description: replaceCoAuthoredMessage(DESCRIPTION, cfg.include_co_authored_by), + parameters: z.object({ + command: z.string().describe("The command to execute"), + timeout: z.number().describe("Optional timeout in milliseconds").optional(), + description: z + .string() + .describe( + "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'", + ), + }), + async execute(params, ctx) { const timeout = Math.min(params.timeout ?? DEFAULT_TIMEOUT, MAX_TIMEOUT) const app = App.info() const tree = await parser().then((p) => p.parse(params.command)) @@ -186,5 +205,6 @@ export const BashTool = Tool.define("bash", { }, output, } - }, + }, + } }) diff --git a/packages/plugin/package.json b/packages/plugin/package.json index f0dba802f94..c8c7dde6d95 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.5.5", + "version": "0.5.5-fork", "type": "module", "scripts": { "typecheck": "tsc --noEmit" diff --git a/packages/plugin/script/publish.ts b/packages/plugin/script/publish.ts index b984fd4f404..29ae50ffe48 100644 --- a/packages/plugin/script/publish.ts +++ b/packages/plugin/script/publish.ts @@ -9,6 +9,8 @@ const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true" await $`bun tsc` +// Skip npm publishing for fork - requires NPM_CONFIG_TOKEN +/* if (snapshot) { await $`bun publish --tag snapshot --access public` await $`git checkout package.json` @@ -16,3 +18,4 @@ if (snapshot) { if (!snapshot) { await $`bun publish --access public` } +*/ diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json index 02a486f28fe..02c76ecb39d 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.5.5", + "version": "0.5.5-fork", "type": "module", "scripts": { "typecheck": "tsc --noEmit" diff --git a/packages/sdk/js/script/publish.ts b/packages/sdk/js/script/publish.ts index 389a9376c66..10f1ab7f8b0 100644 --- a/packages/sdk/js/script/publish.ts +++ b/packages/sdk/js/script/publish.ts @@ -11,9 +11,12 @@ await $`bun tsc` const snapshot = process.env["OPENCODE_SNAPSHOT"] === "true" +// Skip npm publishing for fork - requires NPM_CONFIG_TOKEN +/* if (snapshot) { await $`bun publish --tag snapshot` } if (!snapshot) { await $`bun publish` } +*/ diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 79932b05e18..ab21762be40 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -599,6 +599,10 @@ export type Config = { * Automatically update to the latest version */ autoupdate?: boolean + /** + * Include co-authored-by text in commit messages + */ + include_co_authored_by?: boolean /** * Disable providers that are loaded automatically */ @@ -729,6 +733,9 @@ export type Config = { } webfetch?: "ask" | "allow" | "deny" } + tools?: { + [key: string]: boolean + } experimental?: { hook?: { file_edited?: { @@ -794,6 +801,10 @@ export type KeybindsConfig = { * List all sessions */ session_list: string + /** + * Show session timeline + */ + session_timeline: string /** * Share current session */ diff --git a/packages/web/package.json b/packages/web/package.json index 04d968995c3..c03efd473e0 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,7 +1,7 @@ { "name": "@opencode/web", "type": "module", - "version": "0.5.5", + "version": "0.5.5-fork", "scripts": { "dev": "astro dev", "dev:remote": "sst shell --stage=dev --target=Web astro dev", diff --git a/script/update-fork.sh b/script/update-fork.sh new file mode 100755 index 00000000000..22085f4b0c3 --- /dev/null +++ b/script/update-fork.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# OpenCode Fork Update Script +# Automates the process of updating the fork from upstream and creating a new -fork release + +set -e # Exit on any error + +echo "🔄 OpenCode Fork Update Script" +echo "==============================" + +# Check if we're in the right directory +if [ ! -f "packages/opencode/package.json" ]; then + echo "❌ Error: Please run this script from the root of the opencode repository" + exit 1 +fi + +# Check if upstream remote exists +if ! git remote | grep -q "upstream"; then + echo "❌ Error: No 'upstream' remote found. Please add it first:" + echo " git remote add upstream https://github.com/sst/opencode.git" + exit 1 +fi + +# Check if we're on dev branch +current_branch=$(git branch --show-current) +if [ "$current_branch" != "dev" ]; then + echo "❌ Error: Please switch to the 'dev' branch first" + echo " git checkout dev" + exit 1 +fi + +# Check for uncommitted changes +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "❌ Error: You have uncommitted changes. Please commit or stash them first." + exit 1 +fi + +echo "✅ Pre-flight checks passed" +echo + +# Step 1: Fetch upstream changes +echo "📡 Step 1: Fetching upstream changes..." +git fetch upstream +echo "✅ Upstream fetched" + +# Step 2: Get the latest upstream version +echo "🔍 Step 2: Checking latest upstream version..." +latest_upstream_tag=$(git tag --list --sort=-version:refname | grep -E "^v[0-9]" | head -1) +latest_upstream_version=${latest_upstream_tag#v} # Remove 'v' prefix +echo "📍 Latest upstream version: $latest_upstream_version" + +# Step 3: Merge upstream changes +echo "🔀 Step 3: Merging upstream/dev..." +if ! git merge upstream/dev; then + echo "❌ Merge conflicts detected! Please resolve them manually and run:" + echo " git add ." + echo " git commit -m 'Merge upstream/dev'" + echo " Then re-run this script" + exit 1 +fi +echo "✅ Merged upstream changes" + +# Step 4: Create fork version +fork_version="$latest_upstream_version-fork" +echo "🏷️ Step 4: Creating fork version: $fork_version" + +# Step 5: Push changes +echo "📤 Step 5: Pushing changes to origin..." +git push origin dev +echo "✅ Changes pushed" + +# Step 6: Trigger GitHub Actions release +echo "🚀 Step 6: Triggering GitHub Actions release for v$fork_version..." +gh workflow run publish.yml --repo dbirks/opencode --field version="$fork_version" +echo "✅ Release workflow triggered" + +# Step 7: Monitor workflow (optional) +echo "👁️ Step 7: Monitoring workflow..." +echo " You can monitor the release at:" +echo " https://github.com/dbirks/opencode/actions" +echo +echo " Or run this command to watch progress:" +echo " gh run list --repo dbirks/opencode --limit 1" + +echo +echo "🎉 Fork update process completed!" +echo " Fork version: $fork_version" +echo " The GitHub Actions workflow is now building your release." +echo +echo "📝 What was done:" +echo " ✅ Fetched latest upstream changes" +echo " ✅ Merged upstream/dev into your fork" +echo " ✅ Pushed changes to your fork" +echo " ✅ Triggered release workflow for v$fork_version" +echo +echo "🔮 Next steps:" +echo " • Wait for the GitHub Actions workflow to complete" +echo " • Your fork-specific features are preserved" +echo " • New release will be available with latest upstream features" \ No newline at end of file diff --git a/sdks/vscode/package.json b/sdks/vscode/package.json index c2af58a0e81..92308065bf4 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.5.5", + "version": "0.5.5-fork", "publisher": "sst-dev", "repository": { "type": "git",