rebrand: 将 opencode 改造为 zmo CLI 并隐藏非 CLI 命令

为打造自有纯 CLI 产品 zmo(类 Claude Code),在保留上游同步能力的前提下做套壳改造:
- 入口隐藏 9 个非 CLI 命令(console/web/github/pr/stats/export/import/db/debug)
- 全面 rebrand:scriptName、Logo、配置目录(~/.config/zmo)、bin 名、构建产物、可见文案
- env 双读兼容(ZMO_* 优先,回退 OPENCODE_*),配置文件名新增 zmo.json
- 刻意保留 @opencode-ai/* 内部包名与 opencode provider,避免破坏功能与上游同步

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 04:33:26 +08:00
parent cc9b73b0bd
commit b345dfcc50
16 changed files with 68 additions and 64 deletions

View File

@@ -121,7 +121,7 @@ async function toolError(part: ToolPart) {
export const RunCommand = effectCmd({
command: "run [message..]",
describe: "run opencode with a message",
describe: "run zmo with a message",
// --attach connects to a remote server (no local instance needed); the
// default path runs an in-process server and needs the project instance.
instance: (args) => !args.attach,
@@ -185,7 +185,7 @@ export const RunCommand = effectCmd({
})
.option("attach", {
type: "string",
describe: "attach to a running opencode server (e.g., http://localhost:4096)",
describe: "attach to a running zmo server (e.g., http://localhost:4096)",
})
.option("password", {
alias: ["p"],

View File

@@ -6,7 +6,7 @@ import { Flag } from "@opencode-ai/core/flag/flag"
export const ServeCommand = effectCmd({
command: "serve",
builder: (yargs) => withNetworkOptions(yargs),
describe: "starts a headless opencode server",
describe: "starts a headless zmo server",
// Server loads instances per-request via x-opencode-directory header — no
// need for an ambient project InstanceContext at startup.
instance: false,
@@ -17,7 +17,7 @@ export const ServeCommand = effectCmd({
}
const opts = yield* resolveNetworkOptions(args)
const server = yield* Effect.promise(() => Server.listen(opts))
console.log(`opencode server listening on http://${server.hostname}:${server.port}`)
console.log(`zmo server listening on http://${server.hostname}:${server.port}`)
yield* Effect.never
}),

View File

@@ -7,7 +7,7 @@ import { ServerAuth } from "@/server/auth"
export const AttachCommand = cmd({
command: "attach <url>",
describe: "attach to a running opencode server",
describe: "attach to a running zmo server",
builder: (yargs) =>
yargs
.positional("url", {

View File

@@ -77,12 +77,12 @@ export function resolveThreadDirectory(project?: string, envPWD = process.env.PW
export const TuiThreadCommand = cmd({
command: "$0 [project]",
describe: "start opencode tui",
describe: "start zmo tui",
builder: (yargs) =>
withNetworkOptions(yargs)
.positional("project", {
type: "string",
describe: "path to start opencode in",
describe: "path to start zmo in",
})
.option("model", {
type: "string",

View File

@@ -24,7 +24,7 @@ interface RemovalTargets {
export const UninstallCommand = {
command: "uninstall",
describe: "uninstall opencode and remove all related files",
describe: "uninstall zmo and remove all related files",
builder: (yargs: Argv) =>
yargs
.option("keep-config", {

View File

@@ -6,7 +6,7 @@ import { InstallationVersion } from "@opencode-ai/core/installation/version"
export const UpgradeCommand = {
command: "upgrade [target]",
describe: "upgrade opencode to the latest or a specific version",
describe: "upgrade zmo to the latest or a specific version",
builder: (yargs: Argv) => {
return yargs
.positional("target", {

View File

@@ -47,7 +47,7 @@ export function FormatError(input: unknown): string | undefined {
// MCPFailed: { name: string }
if (NamedError.hasName(input, "MCPFailed")) {
const data = isRecord(input) && isRecord(input.data) ? stringField(input.data, "name") : undefined
return `MCP server "${data}" failed. Note, opencode does not support MCP authentication yet.`
return `MCP server "${data}" failed. Note, zmo does not support MCP authentication yet.`
}
// AccountServiceError, AccountTransportError: TaggedErrorClass
@@ -64,8 +64,8 @@ export function FormatError(input: unknown): string | undefined {
return [
`Model not found: ${stringField(providerModelNotFound, "providerID")}/${stringField(providerModelNotFound, "modelID")}`,
...(suggestions.length ? ["Did you mean: " + suggestions.join(", ")] : []),
`Try: \`opencode models\` to list available models`,
`Or check your config (opencode.json) provider/model names`,
`Try: \`zmo models\` to list available models`,
`Or check your config (zmo.json) provider/model names`,
].join("\n")
}

View File

@@ -1,6 +1,6 @@
export const logo = {
left: [" ", "█▀▀█ █▀▀█ █▀▀█ █▀▀▄", "█__█ █__█ █^^^ █__█", "▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀~~▀"],
right: ["", "█▀▀▀ █▀▀█ █▀▀█ █▀▀█", "█___ █__█ █__█ █^^^", "▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀"],
left: ["▀▀▀▀", " ▄▀", "▄▀ ", "▄▄▄▄"],
right: ["█▄ ▄█ ▄▀▀▄", "█ ▀ █ █ █", "█ █ █ █", "█ █ ▀▄▄▀"],
}
export const go = {

View File

@@ -3,10 +3,10 @@ import { Schema } from "effect"
import { logo as glyphs } from "./logo"
const wordmark = [
``,
`█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀`,
`█ █ █ █ █▀▀▀ █ █ █ █ █ █ █ █▀▀▀`,
`▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀`,
`▀▀▀▀ █▄ ▄█ ▄▀▀▄`,
` ▄▀ █ ▀ █ █ `,
`▄▀ █ █ █ █`,
`▄▄▄▄ █ █ ▀▄▄`,
]
export class CancelledError extends Schema.TaggedErrorClass<CancelledError>()("UICancelledError", {}) {}