Skip to content

fix: repair opencode config and project metadata#394

Merged
affaan-m merged 1 commit intomainfrom
codex/fix-opencode-project-meta
Mar 11, 2026
Merged

fix: repair opencode config and project metadata#394
affaan-m merged 1 commit intomainfrom
codex/fix-opencode-project-meta

Conversation

@affaan-m
Copy link
Copy Markdown
Owner

@affaan-m affaan-m commented Mar 11, 2026

Summary

  • fix .opencode/opencode.json local file references so OpenCode resolves prompts/plugins relative to .opencode/
  • add a regression test for config-relative OpenCode file references
  • write per-project project.json metadata alongside atomic projects.json updates in detect-project.sh
  • document the metadata mirror in the continuous-learning-v2 skill docs

Closes #390
Closes #391

Test Plan

  • npm test
  • node tests/opencode-config.test.js

Summary by cubic

Fixes OpenCode config paths so files resolve relative to .opencode/, and adds per‑project metadata (project.json) with atomic writes in the continuous-learning flow.

  • Bug Fixes

    • Made all file and plugin paths in .opencode/opencode.json config‑relative; updated examples in MIGRATION.md and README.md.
    • Added tests/opencode-config.test.js to assert {file:...} and plugin paths resolve from .opencode/.
  • New Features

    • skills/continuous-learning-v2/scripts/detect-project.sh now writes a per‑project project.json (id, name, root, remote, created_at, last_seen) and updates projects.json atomically.
    • Added a test in tests/hooks/hooks.test.js to verify both metadata files are created and correctly populated.

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

Summary by CodeRabbit

  • New Features

    • Added project metadata storage within individual project directories, capturing project identifiers, names, remotes, and timestamps for enhanced project tracking and management capabilities.
  • Chores

    • Reorganized configuration and resource paths from internal hidden locations to public, top-level directories, improving overall project accessibility and simplifying configuration management.

@affaan-m affaan-m merged commit da4db99 into main Mar 11, 2026
27 of 37 checks passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7cff4d2-4a92-493a-bda9-01d222e8c8a4

📥 Commits

Reviewing files that changed from the base of the PR and between dba4c46 and de1e074.

📒 Files selected for processing (7)
  • .opencode/MIGRATION.md
  • .opencode/README.md
  • .opencode/opencode.json
  • skills/continuous-learning-v2/SKILL.md
  • skills/continuous-learning-v2/scripts/detect-project.sh
  • tests/hooks/hooks.test.js
  • tests/opencode-config.test.js

📝 Walkthrough

Walkthrough

Restructures OpenCode configuration paths from hidden .opencode/ directories to public top-level locations (prompts/, commands/, plugins/, instructions/). Updates all configuration file references and adds atomic project metadata writing to the project registry system in detect-project.sh.

Changes

Cohort / File(s) Summary
Configuration Path Restructuring
.opencode/MIGRATION.md, .opencode/README.md, .opencode/opencode.json
Updated all file references from .opencode/prompts/*, .opencode/commands/*, .opencode/plugins, and .opencode/instructions/* to public paths (prompts/*, commands/*, plugins/, instructions/*). Changes affect 12 agent prompt paths and 26 command template paths in opencode.json.
Project Metadata & Registry
skills/continuous-learning-v2/scripts/detect-project.sh, skills/continuous-learning-v2/SKILL.md
Introduced atomic project metadata writing via project.json files. Added atomic_write_json helper for safe file operations. Script now captures project metadata (id, name, root, remote, created_at, last_seen) and writes to both project directory and registry with timestamp preservation.
Configuration Validation Tests
tests/opencode-config.test.js, tests/hooks/hooks.test.js
Added new test file validating local .opencode/opencode.json references are config-relative. Enhanced hooks test with integration test verifying project metadata is written to registry and project directory with correct field values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Paths now public, no more hidden treasures,
Config moves out where everyone measures,
Project metadata flows, atomic and true,
Registry writes in one clean rendezvous

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-opencode-project-meta

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.

Copy link
Copy Markdown
Contributor

@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 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/opencode-config.test.js">

<violation number="1" location="tests/opencode-config.test.js:36">
P2: This check can pass for absolute or out-of-directory plugin paths, so it does not fully enforce config-relative plugin references.</violation>

<violation number="2" location="tests/opencode-config.test.js:72">
P2: This existence check can also pass for absolute or escaped file refs, so the test does not strictly validate config-relative `{file:...}` references.</violation>
</file>

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


for (const ref of refs) {
assert.ok(!ref.startsWith('.opencode/'), `File ref should not duplicate .opencode/: ${ref}`);
assert.ok(fs.existsSync(path.resolve(opencodeDir, ref)), `File ref should resolve from .opencode/: ${ref}`);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 11, 2026

Choose a reason for hiding this comment

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

P2: This existence check can also pass for absolute or escaped file refs, so the test does not strictly validate config-relative {file:...} references.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/opencode-config.test.js, line 72:

<comment>This existence check can also pass for absolute or escaped file refs, so the test does not strictly validate config-relative `{file:...}` references.</comment>

<file context>
@@ -0,0 +1,81 @@
+
+    for (const ref of refs) {
+      assert.ok(!ref.startsWith('.opencode/'), `File ref should not duplicate .opencode/: ${ref}`);
+      assert.ok(fs.existsSync(path.resolve(opencodeDir, ref)), `File ref should resolve from .opencode/: ${ref}`);
+    }
+  })
</file context>
Fix with Cubic

const plugins = config.plugin || [];
for (const pluginPath of plugins) {
assert.ok(!pluginPath.includes('.opencode/'), `Plugin path should be config-relative, got: ${pluginPath}`);
assert.ok(fs.existsSync(path.resolve(opencodeDir, pluginPath)), `Plugin path should resolve from .opencode/: ${pluginPath}`);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Mar 11, 2026

Choose a reason for hiding this comment

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

P2: This check can pass for absolute or out-of-directory plugin paths, so it does not fully enforce config-relative plugin references.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/opencode-config.test.js, line 36:

<comment>This check can pass for absolute or out-of-directory plugin paths, so it does not fully enforce config-relative plugin references.</comment>

<file context>
@@ -0,0 +1,81 @@
+    const plugins = config.plugin || [];
+    for (const pluginPath of plugins) {
+      assert.ok(!pluginPath.includes('.opencode/'), `Plugin path should be config-relative, got: ${pluginPath}`);
+      assert.ok(fs.existsSync(path.resolve(opencodeDir, pluginPath)), `Plugin path should resolve from .opencode/: ${pluginPath}`);
+    }
+  })
</file context>
Fix with Cubic

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de1e074b33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .opencode/opencode.json
"AGENTS.md",
"CONTRIBUTING.md",
".opencode/instructions/INSTRUCTIONS.md",
"instructions/INSTRUCTIONS.md",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore root-relative path for INSTRUCTIONS.md

The instructions array now points to instructions/INSTRUCTIONS.md, but this repository has no top-level instructions/ directory (.opencode/instructions/INSTRUCTIONS.md is the existing file). Because the other entries in this same array are root-scoped paths like AGENTS.md and skills/..., this change makes the core ECC instruction file unresolved in the bundled config, which can cause OpenCode to skip critical baseline instructions or fail config loading depending on runtime behavior.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

1 participant