Skip to content

Conversation

@sisyphus-dev-ai
Copy link
Collaborator

@sisyphus-dev-ai sisyphus-dev-ai commented Jan 7, 2026

Summary

Fixes #501 - CLI -v flag now reports the correct version matching package.json

Problem

  • bunx oh-my-opencode -v reported outdated version (e.g., 2.13.2)
  • bunx oh-my-opencode get-local-version showed correct version (e.g., 2.14.0) from package.json
  • Root cause: Publish workflow built CLI before bumping version in package.json, so the old version was embedded in dist/cli/index.js

Solution

  1. Created script/bump-version.ts - Standalone script to bump version in package.json
  2. Modified publish workflow - Added "Bump Version" step BEFORE "Build" step
  3. Modified script/publish.ts - Skip version bump if package.json already updated

Workflow Changes

Before:

  1. Build (embeds OLD version)
  2. Publish script (bumps package.json to NEW version)
  3. Publish to npm (NEW package.json + OLD dist/cli/index.js) ❌

After:

  1. Bump Version (updates package.json to NEW version)
  2. Build (embeds NEW version into dist/cli/index.js) ✅
  3. Publish script (skips version bump, publishes to npm)

Testing

  • ✅ Local build test confirms version correctly embedded in bundle
  • ✅ Workflow guarantees version sync between package.json and CLI
  • ✅ Next publish will have matching versions across all files

Files Changed

  • script/bump-version.ts (new) - Version bumping logic
  • .github/workflows/publish.yml - Added bump step before build
  • script/publish.ts - Added logic to skip version bump if already done

Summary by cubic

Syncs the CLI -v output with package.json by bumping the version before build in the publish workflow and skipping redundant bumps. Fixes #501.

  • Bug Fixes
    • Added script/bump-version.ts to bump the version (supports BUMP and VERSION env vars).
    • Updated publish.yml to run the bump step before Build.
    • Updated publish.ts to detect a pre-bumped version and avoid bumping again, ensuring the built CLI embeds the correct version.

Written for commit d3a3ef8. Summary will update on new commits.

Resolves #501

**Problem:**
- CLI  flag reported outdated version (e.g., 2.13.2)
- package.json and get-local-version showed correct version (e.g., 2.14.0)
- Root cause: publish workflow built CLI before bumping version in package.json

**Solution:**
1. Created script/bump-version.ts to bump version before build
2. Modified publish workflow to run bump-version.ts before Build step
3. Modified publish.ts to skip version bump if already done

**Workflow now:**
1. Bump Version (updates package.json)
2. Build (embeds NEW version into dist/cli/index.js)
3. Publish (uses correct version)

**Testing:**
- Local build test confirms version correctly embedded in bundle
- Workflow now guarantees version sync between package.json and CLI
@greptile-apps
Copy link

greptile-apps bot commented Jan 7, 2026

Greptile Summary

Fixed CLI version mismatch by reordering workflow steps to bump package.json version before building, ensuring the correct version is embedded in dist/cli/index.js.

Key Changes:

  • Created script/bump-version.ts to handle version bumping as a separate step
  • Added "Bump Version" step in publish.yml workflow before "Build" step
  • Modified script/publish.ts to detect and skip redundant version bumps when already updated

Root Cause:
The CLI reads version from package.json at build time (src/cli/index.ts:12-13), which gets embedded into the built bundle. Previously, the build happened before version bump, causing the old version to be hardcoded in dist/cli/index.js.

Solution:
By bumping the version first, the build process now embeds the correct version into the CLI bundle, resolving the mismatch between oh-my-opencode -v and package.json.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix correctly addresses the root cause by reordering workflow steps. The implementation is clean with proper idempotency checks, duplicate detection, and graceful exit conditions. All changes are additive with backward compatibility preserved.
  • No files require special attention

Important Files Changed

Filename Overview
.github/workflows/publish.yml Added "Bump Version" step before "Build" to ensure package.json is updated before building CLI
script/bump-version.ts New standalone script to bump version in package.json before build, preventing version mismatch
script/publish.ts Added logic to detect if version already bumped and skip redundant package.json update

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Workflow
    participant BV as bump-version.ts
    participant NPM as npm Registry
    participant PKG as package.json
    participant Build as Build Process
    participant Pub as publish.ts

    Note over GH: Workflow Triggered (bump=patch/minor/major)
    
    GH->>BV: Execute bump-version.ts
    BV->>NPM: Fetch previous version
    NPM-->>BV: Return version (e.g., 2.13.2)
    BV->>BV: Calculate new version (e.g., 2.14.0)
    BV->>NPM: Check if version exists
    NPM-->>BV: Not found
    BV->>PKG: Update version field to 2.14.0
    PKG-->>BV: Success
    
    Note over GH,Build: Build Phase - NEW version now in package.json
    
    GH->>Build: Execute build script
    Build->>PKG: Import package.json
    PKG-->>Build: { version: "2.14.0" }
    Build->>Build: Embed version in dist/cli/index.js
    Note over Build: VERSION = "2.14.0" now hardcoded in bundle
    
    GH->>Pub: Execute publish.ts
    Pub->>NPM: Fetch previous version
    NPM-->>Pub: Return 2.13.2
    Pub->>PKG: Read current package.json version
    PKG-->>Pub: Return 2.14.0
    Pub->>Pub: Detect version already bumped (2.14.0 != 2.13.2)
    Pub->>Pub: Skip package.json update
    Pub->>NPM: Publish package with matching versions
    Note over NPM: package.json = 2.14.0, CLI = 2.14.0 ✅
Loading

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 3 files

Confidence score: 3/5

  • script/bump-version.ts treats process.env.BUMP as valid without runtime validation, so an unexpected value causes bumpVersion() to return undefined, likely breaking release scripts—worth tightening before merge.
  • main() is invoked without catching its promise, so failures in the bump script could result in silent unhandled rejections instead of a clean non-zero exit.
  • Pay close attention to script/bump-version.ts – ensure env validation and promise rejection handling are in place.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="script/bump-version.ts">

<violation number="1" location="script/bump-version.ts:6">
P1: Type assertion on `BUMP` env var doesn't validate the value at runtime. If an invalid value like `"invalid"` is passed, `bumpVersion()` will return `undefined` since the switch has no `default` case. Consider validating the value or adding a default case.</violation>

<violation number="2" location="script/bump-version.ts:69">
P2: The `main()` call doesn't handle the returned promise. Unhandled rejections may not exit with proper error code. Add `.catch()` to handle errors and exit with non-zero code.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

import { $ } from "bun"

const PACKAGE_NAME = "oh-my-opencode"
const bump = process.env.BUMP as "major" | "minor" | "patch" | undefined
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 7, 2026

Choose a reason for hiding this comment

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

P1: Type assertion on BUMP env var doesn't validate the value at runtime. If an invalid value like "invalid" is passed, bumpVersion() will return undefined since the switch has no default case. Consider validating the value or adding a default case.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At script/bump-version.ts, line 6:

<comment>Type assertion on `BUMP` env var doesn't validate the value at runtime. If an invalid value like `"invalid"` is passed, `bumpVersion()` will return `undefined` since the switch has no `default` case. Consider validating the value or adding a default case.</comment>

<file context>
@@ -0,0 +1,69 @@
+import { $ } from "bun"
+
+const PACKAGE_NAME = "oh-my-opencode"
+const bump = process.env.BUMP as "major" | "minor" | "patch" | undefined
+const versionOverride = process.env.VERSION
+
</file context>
Fix with Cubic

console.log(`New version will be embedded in the next build.`)
}

main()
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 7, 2026

Choose a reason for hiding this comment

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

P2: The main() call doesn't handle the returned promise. Unhandled rejections may not exit with proper error code. Add .catch() to handle errors and exit with non-zero code.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At script/bump-version.ts, line 69:

<comment>The `main()` call doesn't handle the returned promise. Unhandled rejections may not exit with proper error code. Add `.catch()` to handle errors and exit with non-zero code.</comment>

<file context>
@@ -0,0 +1,69 @@
+  console.log(`New version will be embedded in the next build.`)
+}
+
+main()
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI -v / --version reports 2.12.3 while package version is 2.12.4 (hardcoded version in dist)

2 participants