Skip to content

fix: sync packaged plugin manifest#30

Merged
100yenadmin merged 1 commit into
mainfrom
codex/company-brain-plugin-manifest-parity
May 8, 2026
Merged

fix: sync packaged plugin manifest#30
100yenadmin merged 1 commit into
mainfrom
codex/company-brain-plugin-manifest-parity

Conversation

@100yenadmin
Copy link
Copy Markdown
Member

@100yenadmin 100yenadmin commented May 8, 2026

Summary

  • generates dist/openclaw.plugin.json from the root plugin manifest during build while preserving main: index.js for the packaged artifact
  • adds a manifest parity test so Company Brain context config and the cortex_insights tool cannot disappear from dist/ again
  • includes the generated dist test outputs used by the repo

Verification

  • npm test
  • git diff --check

Notes

npm run company-brain:canary still requires a live Cortex endpoint and returned fetch failed locally with the default http://localhost:8000; the repo-level unit/build coverage and the Electric Sheep staged smoke are the useful local checks for this packaging fix.

Targets plugin #24 and #25.

Summary by CodeRabbit

  • Chores

    • Enhanced build process with automated manifest validation and synchronization during compilation
  • Tests

    • Added manifest verification tests to ensure built artifacts remain consistent with source configuration

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

A build script now generates a distribution plugin manifest from the source manifest with the main field set to "index.js", and a new test verifies that the built manifest maintains parity with the source for key fields while enforcing the expected main entry point.

Changes

Plugin Manifest Parity Verification

Layer / File(s) Summary
Build Integration
package.json
Build script extended to run scripts/sync-dist-manifest.mjs after TypeScript compilation; test script adds plugin-manifest-parity.test.js.
Manifest Sync Script
scripts/sync-dist-manifest.mjs
New script reads openclaw.plugin.json, overrides main to "index.js", and writes pretty-printed JSON to dist/openclaw.plugin.json.
Test Validation
src/__tests__/plugin-manifest-parity.test.ts
New test verifies source and dist manifests match for tools and configSchema; asserts dist main field is "index.js"; validates presence of companyBrainContext* properties and "cortex_insights" tool.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A manifest compiled, with care,
Sync'd fresh into the dist so fair,
Tests whisper: "parity holds true,"
The cortex plugin, shiny new!
And tools align from root to built. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: sync packaged plugin manifest' directly describes the main change: syncing the packaged plugin manifest by generating dist/openclaw.plugin.json during build.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/company-brain-plugin-manifest-parity

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

Copy link
Copy Markdown

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

🧹 Nitpick comments (2)
scripts/sync-dist-manifest.mjs (1)

5-8: ⚡ Quick win

Ensure dist/ exists before writing the generated manifest.

Line 6 assumes the directory already exists; creating it here makes this script independently reliable.

Suggested change
-import { readFileSync, writeFileSync } from "node:fs";
+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@
 const manifest = JSON.parse(readFileSync("openclaw.plugin.json", "utf8"));
 
+mkdirSync("dist", { recursive: true });
+
 writeFileSync(
   "dist/openclaw.plugin.json",
   `${JSON.stringify({ ...manifest, main: "index.js" }, null, 2)}\n`,
 );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/sync-dist-manifest.mjs` around lines 5 - 8, The script calls
writeFileSync to write "dist/openclaw.plugin.json" but doesn't ensure the dist
directory exists; before the writeFileSync call (in
scripts/sync-dist-manifest.mjs, near the writeFileSync line that uses manifest
and main:"index.js"), create the dist directory (e.g., use fs.mkdirSync or
fs.promises.mkdir with { recursive: true }) so the write won't fail when dist is
missing; perform the mkdir step immediately before writing the file.
src/__tests__/plugin-manifest-parity.test.ts (1)

19-22: ⚡ Quick win

Add explicit guards for configSchema.properties before per-key checks.

Line 20 can throw a TypeError if shape regresses; a dedicated assertion gives clearer failure output.

Suggested change
 assert.deepEqual(distManifest.tools, rootManifest.tools);
 assert.deepEqual(distManifest.configSchema, rootManifest.configSchema);
 assert.equal(distManifest.main, "index.js");
+assert.ok(distManifest.configSchema, "dist manifest is missing configSchema");
+assert.ok(
+  distManifest.configSchema.properties,
+  "dist manifest is missing configSchema.properties",
+);
 
 for (const property of [
@@
 ]) {
   assert.ok(
     distManifest.configSchema.properties[property],
     `dist manifest is missing ${property}`,
   );
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/__tests__/plugin-manifest-parity.test.ts` around lines 19 - 22, Add an
explicit guard assertion before the per-key check to avoid a TypeError if shape
regresses: assert that distManifest.configSchema exists and that
distManifest.configSchema.properties is defined (e.g. using assert.ok or
assert.strictEqual) with a clear failure message, then proceed to the existing
per-key assertion that references
distManifest.configSchema.properties[property]; reference the symbols
distManifest, configSchema, properties and the per-key check to locate where to
insert the guard.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/sync-dist-manifest.mjs`:
- Around line 5-8: The script calls writeFileSync to write
"dist/openclaw.plugin.json" but doesn't ensure the dist directory exists; before
the writeFileSync call (in scripts/sync-dist-manifest.mjs, near the
writeFileSync line that uses manifest and main:"index.js"), create the dist
directory (e.g., use fs.mkdirSync or fs.promises.mkdir with { recursive: true })
so the write won't fail when dist is missing; perform the mkdir step immediately
before writing the file.

In `@src/__tests__/plugin-manifest-parity.test.ts`:
- Around line 19-22: Add an explicit guard assertion before the per-key check to
avoid a TypeError if shape regresses: assert that distManifest.configSchema
exists and that distManifest.configSchema.properties is defined (e.g. using
assert.ok or assert.strictEqual) with a clear failure message, then proceed to
the existing per-key assertion that references
distManifest.configSchema.properties[property]; reference the symbols
distManifest, configSchema, properties and the per-key check to locate where to
insert the guard.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d0ef545-2738-4f70-a896-175654cfaf90

📥 Commits

Reviewing files that changed from the base of the PR and between 75f4c53 and 2618ca7.

⛔ Files ignored due to path filters (5)
  • dist/__tests__/plugin-manifest-parity.test.d.ts is excluded by !**/dist/**
  • dist/__tests__/plugin-manifest-parity.test.d.ts.map is excluded by !**/dist/**, !**/*.map
  • dist/__tests__/plugin-manifest-parity.test.js is excluded by !**/dist/**
  • dist/__tests__/plugin-manifest-parity.test.js.map is excluded by !**/dist/**, !**/*.map
  • dist/openclaw.plugin.json is excluded by !**/dist/**
📒 Files selected for processing (3)
  • package.json
  • scripts/sync-dist-manifest.mjs
  • src/__tests__/plugin-manifest-parity.test.ts

@100yenadmin 100yenadmin merged commit 77a59a0 into main May 8, 2026
3 checks passed
@100yenadmin 100yenadmin deleted the codex/company-brain-plugin-manifest-parity branch May 8, 2026 12:38
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.

1 participant