Repository navigation
feat: add simple tool plugin authoring - #83006
Conversation
Dependency Changes DetectedThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: Do we have a high-confidence way to reproduce the issue? Not applicable as a current-main bug, but yes for the review blockers: the latest PR head shows the failing source paths, and the Windows path guard issue is reproduced with a read-only Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land a repaired version that keeps manifest-first discovery, hardens authoring path boundaries, validates exact generated package metadata, scaffolds publishable package names, and includes redacted real CLI authoring proof. Do we have a high-confidence way to reproduce the issue? Do we have a high-confidence way to reproduce the issue? Not applicable as a current-main bug, but yes for the review blockers: the latest PR head shows the failing source paths, and the Windows path guard issue is reproduced with a read-only Is this the best way to solve the issue? Is this the best way to solve the issue? No, not as currently written. The SDK/CLI direction is plausible, but the command should share the existing manifest parser contract, harden root-boundary checks, validate the single generated runtime entry, and generate publishable scaffold metadata. Full review comments:
Overall correctness: patch is incorrect Security concerns:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f29bcff4dad0. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6046730732
ℹ️ 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".
| if (relative === ".." || relative.startsWith("../")) { | ||
| throw new Error(`entry must stay inside plugin root: ${targetPath}`); | ||
| } | ||
| return relative.startsWith(".") ? relative : `./${relative}`; |
There was a problem hiding this comment.
Reject cross-drive entry paths outside plugin root
normalizeRelativePath only rejects entries when the relative string starts with ../, but on Windows path.relative() returns a drive-qualified path (for example D:\...) when --entry is on a different drive. After separator normalization this becomes D:/..., passes the guard, and gets rewritten as ./D:/..., so plugins build/validate can import and persist an entry outside the plugin root instead of failing with the intended boundary error.
Useful? React with 👍 / 👎.
| function readJsonFile(filePath: string): JsonObject { | ||
| return JSON.parse(fs.readFileSync(filePath, "utf8")) as JsonObject; |
There was a problem hiding this comment.
Parse plugin manifests with JSON5-compatible loader
readJsonFile uses JSON.parse, but this command path also operates on openclaw.plugin.json, which is accepted by loadPluginManifest via JSON5 fallback. A manifest containing valid JSON5 syntax (comments/trailing commas) will pass loadPluginManifest and then crash when re-read here, causing plugins validate and plugins build --check to fail on otherwise supported manifests.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56b0d4a212
ℹ️ 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".
| fs.mkdirSync(path.join(rootDir, "src"), { recursive: true }); | ||
|
|
||
| const packageManifest = { | ||
| name: `openclaw-plugin-${id}`, |
There was a problem hiding this comment.
Validate plugin id before deriving scaffold package name
plugins init interpolates the raw <id> into package.json.name, so a valid scoped plugin id like @acme/quotes produces openclaw-plugin-@acme/quotes, which npm rejects as an invalid package name at publish time. This makes the generated scaffold unusable for normal distribution unless users manually repair metadata, so the command should validate/normalize ids (or generate a publishable package name scheme) before writing package.json.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3eb47d1700
ℹ️ 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".
| } else if (!extensionResolution.entries.includes(params.entry)) { | ||
| errors.push(`package.json openclaw.extensions must include ${params.entry}`); |
There was a problem hiding this comment.
Require a single openclaw.extensions runtime entry
validateToolPluginProject only checks whether openclaw.extensions includes the selected entry, so validation passes when extra stale entries are still present (for example ['./dist/index.js', './dist/old.js']). In that state plugins build would rewrite package.json, but plugins validate incorrectly reports success, allowing projects to ship unintended additional runtime entrypoints that can be loaded by OpenClaw.
Useful? React with 👍 / 👎.
3eb47d1 to
8538a8d
Compare
2d2d550 to
9ec68e3
Compare
|
Landed via rebase merge. Proof:
|
Summary
defineToolPluginas a typed SDK helper for simple tool-only plugins, including optional tool metadata and context-backed factories.openclaw plugins init,build, andvalidateso generatedopenclaw.plugin.jsonandpackage.jsonextension entries stay in sync with the plugin entry.llm-taskplugin and document the npm/package authoring workflow indocs/plugins/tool-plugins.mdplus the CLI/plugin SDK reference pages.Verification
node scripts/run-vitest.mjs src/plugin-sdk/tool-plugin.test.ts src/cli/plugins-authoring-command.test.ts(16 tests passed; rerun by Codex review)node scripts/run-vitest.mjs src/plugin-sdk/tool-plugin.test.ts src/cli/plugins-authoring-command.test.ts extensions/llm-task/src/llm-task-tool.test.ts -- --reporter=verbose(31 tests passed before final source-loader fix)pnpm check:changed(Testboxtbx_01krtr5zy3aabxe6pejqha1bev, Actions run https://github.com/openclaw/openclaw/actions/runs/25988511278, passed)pnpm openclaw plugins build --root extensions/llm-task --check && pnpm openclaw plugins validate --root extensions/llm-task(Plugin metadata is up to date.andPlugin llm-task is valid.)pnpm check:docspnpm plugin-sdk:api:checknode scripts/check-plugin-sdk-subpath-exports.mjsgit diff --checkReal behavior proof
Behavior addressed: simple tool-only plugin authoring through
defineToolPlugin, generated plugin metadata, optional tool declarations, and source or dist entry validation.Real environment tested: local OpenClaw checkout using the OpenClaw CLI against the bundled
extensions/llm-taskplugin, plus Blacksmith Testbox changed gate for the full touched surface.Exact steps or command run after this patch:
pnpm openclaw plugins build --root extensions/llm-task --check && pnpm openclaw plugins validate --root extensions/llm-taskEvidence after fix: the command loaded the package source entry
./index.ts, resolvedopenclaw/plugin-sdk/tool-pluginthrough the plugin SDK alias loader, checked generated metadata, then validated the manifest/package/entry agreement.Observed result after fix:
Plugin metadata is up to date.followed byPlugin llm-task is valid.Testboxtbx_01krtr5zy3aabxe6pejqha1bevalso passedpnpm check:changedfor head9ec68e3eda390aaea9a4eeba7712ea97e2f7af6a.What was not tested: publishing a third-party npm package to the public registry; the scaffold and docs cover npm packaging, but no package was published from this PR.