Skip to content

refactor(scripts): migrate the OpenClaw tool-catalog patch tool to .mts (#6929) - #6941

Merged
cv merged 2 commits into
NVIDIA:mainfrom
atulya-singh:refactor/6929-tool-catalog-mts
Jul 15, 2026
Merged

refactor(scripts): migrate the OpenClaw tool-catalog patch tool to .mts (#6929)#6941
cv merged 2 commits into
NVIDIA:mainfrom
atulya-singh:refactor/6929-tool-catalog-mts

Conversation

@atulya-singh

@atulya-singh atulya-singh commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates scripts/patch-openclaw-tool-catalog.js to scripts/patch-openclaw-tool-catalog.mts, following the scripts/patch-openclaw-mcp-npx.mts precedent already in the tree. This is a module-boundary migration only — no behavior, patch shape, or output contract changes.

Related Issue

Fixes #6929
Parent: #6918

Changes

  • scripts/patch-openclaw-tool-catalog.js.mts (git detects the rename at 89% similarity):
    • Shebang #!/usr/bin/env node#!/usr/bin/env -S node --experimental-strip-types, matching the mcp-npx precedent.
    • require("node:fs") / require("node:path") → ESM imports; dropped "use strict" (implicit in ESM).
    • module.exports → named exports (MARKER, patchOpenClawToolCatalog, patchSelectionText) — the same three the CommonJS export block exposed.
    • require.main === modulepath.resolve(process.argv[1]) === fileURLToPath(import.meta.url), the precedent's ESM main guard.
    • Added types at the existing seams. The two catch (err) blocks that interpolated err.message now narrow via err instanceof Error ? err.message : String(err), since err is unknown in TypeScript — the message text is unchanged for Error instances, which is what both paths (ENOENT from readFileSync/readdirSync) actually throw.
  • Dockerfile: COPY and chmod paths updated; the RUN invocation now passes --experimental-strip-types, matching how the adjacent .mts patch tools are already invoked (lines 204/221/772).
  • src/lib/sandbox/build-context.ts: staged build-context copy path updated.
  • test/openclaw-tool-catalog-patch.test.ts: replaced the createRequire(import.meta.url) bridge with a static ESM import (a .mts module cannot be require()d), and the direct-execution spawn now passes --experimental-strip-types. Mirrors test/openclaw-mcp-npx-patch.test.ts.
  • test/onboard.test.ts, test/sandbox-build-context.test.ts: build-context fixture/assertion paths updated.
  • nemoclaw-blueprint/scripts/nemotron-inference-fix.js: stale path in an explanatory comment.

No live reference to the old .js path remains (git grep patch-openclaw-tool-catalog.js → no matches).

Preserved contracts

Per the epic's scope rules — shebang, executable mode (755, carried through git mv), SPDX header, exit codes, and the stdout/stderr contract are unchanged. Verified by direct execution:

$ ./scripts/patch-openclaw-tool-catalog.mts
Usage: patch-openclaw-tool-catalog.mts <openclaw-dist-dir>       # exit 2

$ node --experimental-strip-types scripts/patch-openclaw-tool-catalog.mts /nonexistent
ERROR: Could not read OpenClaw package metadata at /package.json: ENOENT: ...   # exit 1

The usage string now names .mts — it is derived from the filename it prints for, so leaving it as .js would have misnamed the tool.

Testing

  • npx vitest run test/openclaw-tool-catalog-patch.test.ts test/sandbox-build-context.test.ts11 passed
  • npx vitest run test/onboard.test.ts33 passed
  • npm run typecheck:cli → clean
  • Direct execution verified for both the usage (exit 2) and error (exit 1) paths, and via the shebang standalone — covering both the "direct execution" and "import/module use" halves the epic's shared acceptance criteria ask for.

Docs

No change needed — this tool has no contributor-facing command examples in docs/; it is invoked only by the Dockerfile build.

Note for reviewers

The Docker image build is the one contract I could not exercise locally. The RUN line depends on --experimental-strip-types being available in the image's Node, which the three adjacent .mts/.ts patch tools already rely on at lines 204/221/747/762/772 of the same Dockerfile, so the capability is established. Worth a CI image build to confirm.

Checklist

  • Follows the repository code style and conventions
  • Tests updated for the changed module boundary
  • Docs reviewed (no change required — see above)
  • No secrets, API keys, or credentials committed

Signed-off-by: Atulya Singh atulyarajsingh@gmail.com

Summary by CodeRabbit

  • Refactor

    • Migrated the OpenClaw tool-catalog patch script from JavaScript to a TypeScript module.
    • Updated the Docker image build and sandbox staging to copy and run the new module format.
    • Improved robustness of patch-script error reporting.
  • Tests

    • Updated sandbox and tool-catalog patch tests to validate the TypeScript-based workflow.
    • Expanded the dependency-review contract test to ensure the Dockerfile uses the new module and no longer references the old JavaScript script.

…ts (NVIDIA#6929)

Signed-off-by: Atulya Singh <atulyarajsingh@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 76430179-05f9-423a-8fdc-981590ac773b

📥 Commits

Reviewing files that changed from the base of the PR and between fe2d8a0 and 7c37152.

📒 Files selected for processing (1)
  • test/openclaw-dependency-review.test.ts

📝 Walkthrough

Walkthrough

The OpenClaw tool-catalog patch script is migrated from CommonJS JavaScript to typed ESM TypeScript. Docker execution, sandbox staging, cross-references, and tests now use the .mts entrypoint with Node’s type-stripping flag.

Changes

OpenClaw tool-catalog .mts migration

Layer / File(s) Summary
Typed ESM patch implementation
scripts/patch-openclaw-tool-catalog.mts
The patch script now uses ESM imports, typed patch results and helper signatures, safer error formatting, named exports, and an ESM-compatible CLI guard.
Docker and sandbox wiring
Dockerfile, src/lib/sandbox/build-context.ts, nemoclaw-blueprint/scripts/nemotron-inference-fix.js
Docker and optimized sandbox staging copy and execute the .mts script with --experimental-strip-types; the related comment uses the new path.
Migration test coverage
test/openclaw-tool-catalog-patch.test.ts, test/sandbox-build-context.test.ts, test/onboard.test.ts, test/openclaw-dependency-review.test.ts
Test imports, spawned process arguments, fixtures, staging assertions, and Dockerfile contract checks now target the .mts script.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

  • NVIDIA/NemoClaw#6942 — Migrates another OpenClaw patch shim to .mts while updating shared staging and Docker execution plumbing.

Suggested labels: chore

Suggested reviewers: cv

🚥 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 clearly states the main change: migrating the OpenClaw tool-catalog patch tool to .mts.
Linked Issues check ✅ Passed The changes match the migration requirements and preserve the patch contract, execution modes, and updated Docker/test paths.
Out of Scope Changes check ✅ Passed The diff stays focused on the .mts migration, related path updates, and contract tests without unrelated feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings match; normalized E2E selections differ; severity counts match.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: cloud-onboard, inference-routing, network-policy

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@wscurran wscurran added integration: openclaw OpenClaw integration behavior refactor PR restructures code without intended behavior change labels Jul 15, 2026
@wscurran

Copy link
Copy Markdown
Contributor

✨ Thanks for the migration. The .mts conversion follows the existing precedent cleanly with no behavior changes. Ready for maintainer review.


Related open issues:

@cv cv added the v0.0.84 label Jul 15, 2026

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the accepted #6929 migration and the added Dockerfile contract coverage. The patch behavior is unchanged, stale .js invocation is explicitly rejected, and local verification passed: 7 focused dependency-contract tests, 18 related tests, and 33 onboard tests after building the CLI. Approving pending completion of required CI and E2E evidence.

@cv
cv merged commit 7d1cef9 into NVIDIA:main Jul 15, 2026
77 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration: openclaw OpenClaw integration behavior refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate the OpenClaw tool-catalog patch tool to .mts

4 participants