Skip to content

Conversation

@TabishB
Copy link
Contributor

@TabishB TabishB commented Jan 30, 2026

Summary

  • Update Codex adapter to return absolute paths (~/.codex/prompts/) via os.homedir(), respecting CODEX_HOME env var
  • Handle absolute paths in init.ts and update.ts file writers with path.isAbsolute() guard
  • Update docs (supported-tools.md), spec (spec.md), and design (design.md) to reflect global-path support and fix stale "deferred" rationale
  • Add tests for absolute path behavior and CODEX_HOME override

Test plan

  • npm run build passes with no type errors
  • npm test — all 1236 tests pass, including new Codex adapter tests for absolute paths and CODEX_HOME
  • Verify supported-tools.md footnote renders correctly on GitHub

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Codex prompts now resolve to the global home directory (~/.codex/prompts/); command paths correctly preserve absolute paths when present.
  • Documentation

    • Updated docs and API descriptions to note global Codex prompt locations and that command paths may be absolute; added a footnote about CODEX_HOME support.
  • Tests

    • Expanded tests to verify absolute path resolution and environment-driven Codex home behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

Codex custom prompts live in ~/.codex/prompts/ (global, not per-project).
Update the Codex adapter to return absolute paths via os.homedir(), handle
absolute paths in init/update writers, and update docs and specs to reflect
the change.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Updates Codex prompt handling to use a global home directory ($CODEX_HOME/prompts/ or ~/.codex/prompts/) rather than a project-relative .codex/prompts/. Adds getCodexHome() in the Codex adapter, preserves absolute command paths in init/update flows, and updates docs and tests accordingly.

Changes

Cohort / File(s) Summary
Documentation
docs/supported-tools.md, openspec/changes/multi-provider-skill-generation/design.md, openspec/changes/multi-provider-skill-generation/specs/command-generation/spec.md, src/core/command-generation/types.ts
Clarified that Codex prompts live in a global home (~/.codex/prompts/ or $CODEX_HOME/prompts/), added skillsDir?: string to design notes, and updated docs/comments to state getFilePath() / GeneratedCommand.path may return absolute paths.
Codex Adapter
src/core/command-generation/adapters/codex.ts
Added getCodexHome() (honors CODEX_HOME or defaults to ~/.codex) and changed Ops prompts path construction to use the resolved Codex home, producing absolute paths for Codex prompts.
Core Path Resolution
src/core/init.ts, src/core/update.ts
Changed logic to preserve absolute cmd.path values (use as-is) and only join relative paths with project base directories.
Tests
test/core/command-generation/adapters.test.ts
Expanded tests to assert absolute path returns, verify default home-directory resolution via os.homedir(), and honor CODEX_HOME env var.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Init/Update
  participant CodexAdapter
  participant FS
  participant Env as Environment

  CLI->>Init/Update: generate/update commands (cmd.path)
  Init/Update->>CodexAdapter: ToolCommandAdapter.getFilePath(commandId)
  CodexAdapter->>Env: read CODEX_HOME
  Env-->>CodexAdapter: CODEX_HOME or undefined
  CodexAdapter->>CodexAdapter: getCodexHome() -> resolve path (CODEX_HOME or os.homedir()+/.codex)
  CodexAdapter-->>Init/Update: return absolute file path for Codex command
  Init/Update->>Init/Update: if path is absolute use as-is else join with project path
  Init/Update->>FS: write command file to resolved path
  FS-->>Init/Update: write result
  Init/Update-->>CLI: completion
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Israel-Laguan

Poem

🐇 I dug a tunnel to the global home,

CODEX whispers where it loves to roam,
Prompts now live where the rabbit knows,
From $CODEX_HOME the wisdom grows,
Hopping paths that lead back home.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: support global paths for Codex command generation' accurately summarizes the main change: enabling Codex to use absolute paths in global directories (~/.codex/prompts/) instead of project-relative paths.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/codex-global-paths

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

@greptile-apps
Copy link

greptile-apps bot commented Jan 30, 2026

Greptile Overview

Greptile Summary

This PR adds support for global path installation in the Codex adapter, allowing commands to be installed to ~/.codex/prompts/ (or $CODEX_HOME/prompts/) instead of the project directory. This aligns with Codex's design where custom prompts are global rather than project-scoped.

Key changes:

  • Codex adapter now returns absolute paths via os.homedir() with CODEX_HOME env var support
  • init.ts and update.ts handle absolute paths with path.isAbsolute() guards before joining with project path
  • Type definitions and specs updated to reflect that adapters can return absolute paths
  • Comprehensive test coverage for absolute path behavior and environment variable override
  • Documentation updated to clearly indicate Codex's global installation pattern with footnote

The implementation is clean, well-tested, and backwards-compatible. The path.isAbsolute() check ensures other adapters that return relative paths continue to work correctly.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • Implementation is well-designed with proper absolute path handling, comprehensive test coverage including env var override scenarios, and updated documentation. The path.isAbsolute() guard ensures backwards compatibility with existing adapters.
  • No files require special attention

Important Files Changed

Filename Overview
src/core/command-generation/adapters/codex.ts Added getCodexHome() function with CODEX_HOME env var support and updated getFilePath() to return absolute paths
src/core/init.ts Added path.isAbsolute() check before joining command file path with project path
src/core/update.ts Added path.isAbsolute() checks in two locations before joining command file paths with project paths
test/core/command-generation/adapters.test.ts Added comprehensive tests for absolute paths, CODEX_HOME env var override, and default home directory behavior

Sequence Diagram

sequenceDiagram
    participant User
    participant InitCommand
    participant UpdateCommand
    participant CommandAdapterRegistry
    participant CodexAdapter
    participant FileSystemUtils
    participant OS

    User->>InitCommand: opsx init --tools codex
    InitCommand->>CommandAdapterRegistry: get('codex')
    CommandAdapterRegistry-->>InitCommand: codexAdapter
    InitCommand->>CodexAdapter: getFilePath('explore')
    CodexAdapter->>OS: process.env.CODEX_HOME?
    alt CODEX_HOME set
        OS-->>CodexAdapter: /custom/codex-home
        CodexAdapter->>CodexAdapter: path.resolve(CODEX_HOME)
    else CODEX_HOME not set
        CodexAdapter->>OS: os.homedir()
        OS-->>CodexAdapter: /home/user
        CodexAdapter->>CodexAdapter: path.join(homedir, '.codex')
    end
    CodexAdapter-->>InitCommand: /home/user/.codex/prompts/opsx-explore.md
    InitCommand->>InitCommand: path.isAbsolute(cmd.path)?
    alt path is absolute
        InitCommand->>FileSystemUtils: writeFile(absolutePath, content)
    else path is relative
        InitCommand->>FileSystemUtils: writeFile(projectPath + relativePath, content)
    end
    FileSystemUtils->>FileSystemUtils: createDirectory(dirname)
    FileSystemUtils->>OS: fs.writeFile()
    FileSystemUtils-->>InitCommand: Success
    InitCommand-->>User: Codex commands installed to ~/.codex/prompts/
Loading

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/core/command-generation/adapters/codex.ts`:
- Around line 14-20: getCodexHome currently treats an empty CODEX_HOME env var
as set and resolves to CWD; change getCodexHome to treat empty/whitespace-only
CODEX_HOME as unset by trimming and checking length (e.g. const homeEnv =
process.env.CODEX_HOME?.trim(); if (!homeEnv) use path.join(os.homedir(),
'.codex') ), then pass the chosen path to path.resolve so an empty value no
longer causes writes into the project directory; update the getCodexHome
function accordingly.

In `@test/core/command-generation/adapters.test.ts`:
- Around line 214-217: The test for codexAdapter.getFilePath('explore') is
brittle because it asserts the prefix ".codex" which fails when CODEX_HOME is
customized; change the assertion to only verify the suffix structure by either
checking filePath.endsWith(path.join('prompts', 'opsx-explore.md')) or using a
looser regex like /[\\/ ]?prompts[\\/]opsx-explore\.md$/ (or simply
/[\\/]prompts[\\/]opsx-explore\.md$/) so the test still validates the final path
segment without depending on a specific CODEX_HOME prefix; update the test case
in the 'should generate path ending with correct structure' spec that calls
codexAdapter.getFilePath('explore').
🧹 Nitpick comments (1)
openspec/changes/multi-provider-skill-generation/design.md (1)

20-45: Clarify the “non-goal but implemented” phrasing.
Consider rewording to indicate global paths are out of scope except Codex, to avoid contradictory wording.

✏️ Suggested wording
-- Global path installation — implemented for Codex (absolute path from adapter)
+- Global path installation for tools other than Codex (Codex uses absolute adapter paths today)

- Guard against empty CODEX_HOME resolving to CWD by trimming the env var
- Loosen test regex to not depend on .codex prefix (resilient to custom CODEX_HOME)
- Clarify non-goal wording in design.md to avoid contradictory phrasing
@TabishB TabishB merged commit f27e5e8 into main Jan 30, 2026
9 checks passed
@TabishB TabishB deleted the docs/codex-global-paths branch January 30, 2026 09:51
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.

2 participants