Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 0

魏士杰/opencode

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
dev
Branches (1)
dev
dev
Branches (1)
dev
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
dev
Branches (1)
dev
opencode
/
script
/
sync-zed.ts
opencode
/
script
/
sync-zed.ts
sync-zed.ts 4.89 KB
Copy Edit Raw Blame History
Aiden Cline authored 2026年01月09日 04:19 +08:00 . ci: update fork_repo var
#!/usr/bin/env bun
import { $ } from "bun"
import { tmpdir } from "os"
import { join } from "path"
const FORK_REPO = "anomalyco/zed-extensions"
const UPSTREAM_REPO = "zed-industries/extensions"
const EXTENSION_NAME = "opencode"
async function main() {
const version = process.argv[2]
if (!version) throw new Error("Version argument required, ex: bun script/sync-zed.ts v1.0.52")
const token = process.env.ZED_EXTENSIONS_PAT
if (!token) throw new Error("ZED_EXTENSIONS_PAT environment variable required")
const prToken = process.env.ZED_PR_PAT
if (!prToken) throw new Error("ZED_PR_PAT environment variable required")
const cleanVersion = version.replace(/^v/, "")
console.log(`📦 Syncing Zed extension for version ${cleanVersion}`)
const commitSha = await $`git rev-parse ${version}`.text()
const sha = commitSha.trim()
console.log(`🔍 Found commit SHA: ${sha}`)
const extensionToml = await $`git show ${version}:packages/extensions/zed/extension.toml`.text()
const parsed = Bun.TOML.parse(extensionToml) as { version: string }
const extensionVersion = parsed.version
if (extensionVersion !== cleanVersion) {
throw new Error(`Version mismatch: extension.toml has ${extensionVersion} but tag is ${cleanVersion}`)
}
console.log(`✅ Version ${extensionVersion} matches tag`)
// Clone the fork to a temp directory
const workDir = join(tmpdir(), `zed-extensions-${Date.now()}`)
console.log(`📁 Working in ${workDir}`)
await $`git clone https://x-access-token:${token}@github.com/${FORK_REPO}.git ${workDir}`
process.chdir(workDir)
// Configure git identity
await $`git config user.name "Aiden Cline"`
await $`git config user.email "63023139+rekram1-node@users.noreply.github.com "`
// Sync fork with upstream (force reset to match exactly)
console.log(`🔄 Syncing fork with upstream...`)
await $`git remote add upstream https://github.com/${UPSTREAM_REPO}.git`
await $`git fetch upstream`
await $`git checkout main`
await $`git reset --hard upstream/main`
await $`git push origin main --force`
console.log(`✅ Fork synced (force reset to upstream)`)
// Create a new branch
const branchName = `update-${EXTENSION_NAME}-${cleanVersion}`
console.log(`🌿 Creating branch ${branchName}`)
await $`git checkout -b ${branchName}`
const submodulePath = `extensions/${EXTENSION_NAME}`
console.log(`📌 Updating submodule to commit ${sha}`)
await $`git submodule update --init ${submodulePath}`
process.chdir(submodulePath)
await $`git fetch`
await $`git checkout ${sha}`
process.chdir(workDir)
await $`git add ${submodulePath}`
console.log(`📝 Updating extensions.toml`)
const extensionsTomlPath = "extensions.toml"
const extensionsToml = await Bun.file(extensionsTomlPath).text()
const versionRegex = new RegExp(`(\\[${EXTENSION_NAME}\\][\\s\\S]*?)version = "[^"]+"`)
const updatedToml = extensionsToml.replace(versionRegex, `1ドルversion = "${cleanVersion}"`)
if (updatedToml === extensionsToml) {
throw new Error(`Failed to update version in extensions.toml - pattern not found`)
}
await Bun.write(extensionsTomlPath, updatedToml)
await $`git add extensions.toml`
const commitMessage = `Update ${EXTENSION_NAME} to v${cleanVersion}`
await $`git commit -m ${commitMessage}`
console.log(`✅ Changes committed`)
// Delete any existing branches for opencode updates
console.log(`🔍 Checking for existing branches...`)
const branches = await $`git ls-remote --heads https://x-access-token:${token}@github.com/${FORK_REPO}.git`.text()
const branchPattern = `refs/heads/update-${EXTENSION_NAME}-`
const oldBranches = branches
.split("\n")
.filter((line) => line.includes(branchPattern))
.map((line) => line.split("refs/heads/")[1])
.filter(Boolean)
if (oldBranches.length > 0) {
console.log(`🗑️ Found ${oldBranches.length} old branch(es), deleting...`)
for (const branch of oldBranches) {
await $`git push https://x-access-token:${token}@github.com/${FORK_REPO}.git --delete ${branch}`
console.log(`✅ Deleted branch ${branch}`)
}
}
console.log(`🚀 Pushing to fork...`)
await $`git push https://x-access-token:${token}@github.com/${FORK_REPO}.git ${branchName}`
console.log(`📬 Creating pull request...`)
const prResult =
await $`gh pr create --repo ${UPSTREAM_REPO} --base main --head ${FORK_REPO.split("/")[0]}:${branchName} --title "Update ${EXTENSION_NAME} to v${cleanVersion}" --body "Updating OpenCode extension to v${cleanVersion}"`
.env({ ...process.env, GH_TOKEN: prToken })
.nothrow()
if (prResult.exitCode !== 0) {
console.error("stderr:", prResult.stderr.toString())
throw new Error(`Failed with exit code ${prResult.exitCode}`)
}
const prUrl = prResult.stdout.toString().trim()
console.log(`✅ Pull request created: ${prUrl}`)
console.log(`🎉 Done!`)
}
main().catch((err) => {
console.error("❌ Error:", err.message)
process.exit(1)
})
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/flamealpha/opencode.git
git@gitee.com:flamealpha/opencode.git
flamealpha
opencode
opencode
dev
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /