Skip to content

chore: sync upstream v1.3.15#67

Merged
terisuke merged 17 commits intodevfrom
chore/upstream-sync-20260405
Apr 5, 2026
Merged

chore: sync upstream v1.3.15#67
terisuke merged 17 commits intodevfrom
chore/upstream-sync-20260405

Conversation

@terisuke
Copy link
Copy Markdown

@terisuke terisuke commented Apr 5, 2026

What

Sync upstream anomalyco/opencode changes into fork (v1.3.13 → post-v1.3.15).

Why

Fork's dev build (0.0.0-dev) can't auto-update because Installation.method() returns "unknown".
The only way to stay current is via git merge from upstream.

Closes #66

Changes

Upstream commits merged (workflows excluded):

Test plan

  • bun test passes with no regressions
  • Fork-specific features (memory system, GLM fix, notifications) work
  • Typecheck passes
  • Build produces working binary

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 5, 2026 08:54
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Syncs the fork with upstream opencode through v1.3.15, updating package versions and integrating upstream changes such as Console org switching APIs/UI and the Effect-based read tool refactor.

Changes:

  • Bump workspace/package versions to 1.3.15 (incl. extensions + lockfile).
  • Add experimental Console endpoints + SDK bindings, and wire Console org/provider state into the TUI (including org switching dialog).
  • Migrate tool.read implementation/tests to the Effect service graph and update ToolRegistry dependencies.

Reviewed changes

Copilot reviewed 46 out of 47 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
sdks/vscode/package.json VS Code extension version bump to 1.3.15.
packages/web/src/content/docs/zen.mdx Removes MiMo free model references from docs/pricing tables.
packages/web/package.json Web package version bump to 1.3.15.
packages/util/package.json Util package version bump to 1.3.15.
packages/ui/package.json UI package version bump to 1.3.15.
packages/slack/package.json Slack package version bump to 1.3.15.
packages/sdk/openapi.json Adds experimental Console endpoints to OpenAPI spec.
packages/sdk/js/src/v2/gen/types.gen.ts Adds generated types for new Console endpoints.
packages/sdk/js/src/v2/gen/sdk.gen.ts Adds generated client methods for Console endpoints and repositions Tool client.
packages/sdk/js/package.json SDK JS package version bump to 1.3.15.
packages/plugin/package.json Plugin package version bump to 1.3.15.
packages/opencode/test/tool/read.test.ts Refactors read tool tests to Effect-based harness/layers.
packages/opencode/test/session/compaction.test.ts Expands tests for reasoning token separation and cost calculation.
packages/opencode/test/config/config.test.ts Updates mocks to include new Account.activeOrg() behavior.
packages/opencode/src/tool/registry.ts Adds required layers/services for effectified tools (ReadTool deps).
packages/opencode/src/tool/read.ts Migrates ReadTool to Tool.defineEffect, using AppFileSystem/LSP/Instruction services.
packages/opencode/src/tool/external-directory.ts Adds Effect wrapper + switches normalization helpers to AppFileSystem.
packages/opencode/src/session/prompt/kimi.txt Removes “Skills” section content from Kimi prompt template.
packages/opencode/src/session/index.ts Adjusts usage accounting to separate reasoning vs output tokens.
packages/opencode/src/server/routes/experimental.ts Adds /experimental/console endpoints (get/list orgs/switch org).
packages/opencode/src/npm/index.ts Sets Arborist ignoreScripts: true (safer installs).
packages/opencode/src/filesystem/index.ts Improves Windows path normalization + adds normalizePathPattern.
packages/opencode/src/config/console-state.ts Introduces ConsoleState schema + empty default.
packages/opencode/src/config/config.ts Tracks console-managed providers + active org name in Config state; adds getter.
packages/opencode/src/cli/cmd/tui/util/provider-origin.ts Adds labeling/helpers for Console-managed providers.
packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx Adds categoryView rendering for richer category headers.
packages/opencode/src/cli/cmd/tui/context/sync.tsx Fetches Console state via SDK and stores it in sync context.
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Displays Console org + managed-provider indicator in prompt header; triggers org switch command.
packages/opencode/src/cli/cmd/tui/component/dialog-provider.tsx Shows Console-managed providers in connect dialog with icon/footer; blocks selection.
packages/opencode/src/cli/cmd/tui/component/dialog-model.tsx Labels providers with Console-managed indicator in model dialog.
packages/opencode/src/cli/cmd/tui/component/dialog-console-org.tsx Adds org-switching dialog calling new experimental endpoints.
packages/opencode/src/cli/cmd/tui/app.tsx Adds “Switch org” command when multiple orgs are available.
packages/opencode/src/account/index.ts Adds activeOrg() + changes org listing behavior to be more fault-tolerant.
packages/opencode/specs/effect-migration.md Documents the transitional defineEffect pattern; marks read.ts migrated.
packages/opencode/script/build.ts Marks node-gyp as external for build.
packages/opencode/package.json Core opencode package version bump to 1.3.15.
packages/function/package.json Function package version bump to 1.3.15.
packages/extensions/zed/extension.toml Zed extension version + release asset URLs updated to v1.3.15.
packages/enterprise/package.json Enterprise package version bump to 1.3.15.
packages/desktop/package.json Desktop package version bump to 1.3.15.
packages/desktop-electron/package.json Desktop Electron package version bump to 1.3.15.
packages/console/mail/package.json Console mail package version bump to 1.3.15.
packages/console/function/package.json Console function package version bump to 1.3.15.
packages/console/core/package.json Console core package version bump to 1.3.15.
packages/console/app/package.json Console app package version bump to 1.3.15.
packages/app/package.json App package version bump to 1.3.15.
bun.lock Lockfile updated for version bumps across workspace packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1273 to +1277
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.get({\n ...\n})"
}
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x-codeSamples JS snippet is syntactically invalid: the import string is missing the closing quote after @opencode-ai/sdk (and the newline is inside the string). This will break generated docs/examples. Update the sample to a valid import (e.g. from "@opencode-ai/sdk") and keep newlines outside the string.

Copilot uses AI. Check for mistakes.
Comment on lines +1344 to +1348
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.listOrgs({\n ...\n})"
}
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x-codeSamples JS snippet for experimental.console.listOrgs is syntactically invalid (missing closing quote in the import path, newline embedded in the string). Please fix the example string so it produces valid JS when rendered/copied.

Copilot uses AI. Check for mistakes.
Comment on lines +1385 to +1402
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"accountID": {
"type": "string"
},
"orgID": {
"type": "string"
}
},
"required": ["accountID", "orgID"]
}
}
}
},
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/experimental/console/switch validates a JSON body with required accountID and orgID, but the OpenAPI requestBody is not marked as required. This causes generated clients to treat the body as optional and can lead to runtime 400s. Mark the requestBody as required (or adjust the route/validator if the body is truly optional).

Copilot uses AI. Check for mistakes.
Comment on lines +1403 to +1407
"x-codeSamples": [
{
"lang": "js",
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.switchOrg({\n ...\n})"
}
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x-codeSamples JS snippet for experimental.console.switchOrg is syntactically invalid (missing closing quote in the import path, newline embedded in the string). Fixing this in the OpenAPI spec will keep generated docs/examples usable.

Copilot uses AI. Check for mistakes.
Comment on lines +1053 to +1059
public switchOrg<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
accountID?: string
orgID?: string
},
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.switchOrg() takes accountID/orgID as optional parameters, but the server route requires both fields (and the OpenAPI schema marks them required). The SDK method signature should require these fields so callers can’t accidentally invoke it with an invalid body.

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +104
const stat = yield* fs.stat(filepath).pipe(
Effect.catchIf(
(err) => "reason" in err && err.reason._tag === "NotFound",
() => Effect.succeed(undefined),
),
)
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Effect.catchIf predicate uses "reason" in err without first verifying err is a non-null object. If a non-object is ever thrown/rejected, this predicate will itself throw a TypeError and mask the original error. Use a safer guard (similar to packages/opencode/src/storage/storage.ts:71-77) before using the in operator / accessing err.reason.

Copilot uses AI. Check for mistakes.
Comment on lines 302 to 312
const orgsByAccount = Effect.fn("Account.orgsByAccount")(function* () {
const accounts = yield* repo.list()
const [errors, results] = yield* Effect.partition(
return yield* Effect.forEach(
accounts,
(account) => orgs(account.id).pipe(Effect.map((orgs) => ({ account, orgs }))),
(account) =>
orgs(account.id).pipe(
Effect.catch(() => Effect.succeed([] as readonly Org[])),
Effect.map((orgs) => ({ account, orgs })),
),
{ concurrency: 3 },
)
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orgsByAccount() now swallows all per-account errors and returns an empty org list with no logging. This makes auth/network/config issues indistinguishable from “no orgs” and will also skew switchableOrgCount. Consider at least logging a warning (and ideally preserving the previous behavior of surfacing/collecting errors) when an account’s org fetch fails.

Copilot uses AI. Check for mistakes.
total,
input: adjustedInputTokens,
output: outputTokens,
output: outputTokens - reasoningTokens,
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output is computed as outputTokens - reasoningTokens without clamping. If a provider reports reasoning tokens separately (i.e. not included in outputTokens) or ever reports reasoningTokens > outputTokens, this becomes negative and will undercount cost. Consider guarding with Math.max(0, outputTokens - reasoningTokens) (or enforce/validate the invariant before subtracting).

Suggested change
output: outputTokens - reasoningTokens,
output: Math.max(0, outputTokens - reasoningTokens),

Copilot uses AI. Check for mistakes.
Comment on lines +50 to +59
footer: consoleManaged ? sync.data.console_state.activeOrgName : undefined,
category: provider.id in PROVIDER_PRIORITY ? "Popular" : "Other",
gutter: consoleManaged ? (
<text fg={theme.textMuted}>{CONSOLE_MANAGED_ICON}</text>
) : connected ? (
<text fg={theme.success}>✓</text>
) : undefined,
async onSelect() {
if (consoleManaged) return

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selecting a Console-managed provider currently becomes a no-op (if (consoleManaged) return) while the option remains enabled. In the “Connect a provider” dialog this results in user-visible broken behavior (selection does nothing). Consider marking these options as disabled: true (with an explanatory description) or handling selection by showing a dialog explaining it’s managed via Console / taking the user to org switching.

Copilot uses AI. Check for mistakes.
terisuke and others added 2 commits April 5, 2026 18:02
…c workflow

- Change opencode dependency from fixed "1.3.13" to "workspace:*" so
  upstream version bumps don't break bun install
- Bump guardrails version to 1.3.15
- Fix upstream-sync workflow: detect merge conflicts properly, graceful
  fallback when PR creation lacks permissions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…endency

The guardrails package now uses workspace:* instead of a pinned version
to prevent bun install failures when upstream bumps the version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@terisuke
Copy link
Copy Markdown
Author

terisuke commented Apr 5, 2026

Codex CLI セカンドオピニオンレビュー結果 (2026-04-05)

ドリフトチェック

フォーク独自の変更はIssueに対応する内容のみ(memory system, GLM fix, notifications, CI fixes)。
ただし upstream merge 由来の out-of-scope 変更(console/org-switching, tooling refactors)が含まれる — これは upstream 側の変更であり意図的に取り込んでいる。

Codex 検出 → コード検証結果

Finding Codex判定 検証結果 対応
npm ignoreScripts 削除 HIGH FALSEignoreScripts: true は npm/index.ts:67,108 に存在 対応不要(誤検出)
non-macOS notification focus MEDIUM TRUE — notification/index.ts:48 Issue #68
parseFrontmatter 型バリデーション LOW TRUE — memory/file.ts:41 Issue #69
repetition test 重複 LOW TRUE — repetition.test.ts:8-23 Issue #69
Token double-counting MEDIUM RESOLVED — upstream anomalyco#21047/anomalyco#21053 がこの sync に含まれる 対応不要

PR #67 Copilot レビュー指摘 (9件)

全てupstreamコード(sdk/openapi.json, sdk.gen.ts, read.ts, dialog-provider.tsx, session/index.ts, account/index.ts)への指摘。
フォーク側で修正すべきものではなく、upstream に報告すべき内容。
CRITICAL/HIGH 指摘はゼロ。

@terisuke terisuke merged commit e04eef8 into dev Apr 5, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: upstream sync to v1.3.15 — fix auto-update incompatibility

7 participants