Skip to content

refactor(scripts): migrate documentation and configuration tools to .mts - #6936

Merged
cv merged 3 commits into
mainfrom
refactor/6920-docs-config-tools-mts
Jul 15, 2026
Merged

refactor(scripts): migrate documentation and configuration tools to .mts#6936
cv merged 3 commits into
mainfrom
refactor/6920-docs-config-tools-mts

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Renames the seven ESM-shaped documentation and configuration tools under scripts/ from .ts to .mts so each tool's module contract is explicit, and updates every reference to the old paths. Documentation generation, route validation, config validation, and Fern preview behaviour are unchanged; the root package keeps its CommonJS contract.

Related Issue

Resolves #6920

Changes

  • Renamed to .mts: check-docs-published-routes, check-env-var-docs, fern-preview-config, generate-starter-prompt, sync-agent-variant-docs, validate-configs, watch-fern-preview.
  • Updated inter-script relative imports to explicit .mts (check-docs-published-routessync-agent-variant-docs; watch-fern-previewfern-preview-config).
  • Updated package.json script entries, .pre-commit-config.yaml hook entries and the check-env-var-docs files: filter, and the docs-preview-pr / docs-publish-staging workflow path filters.
  • Added explicit .mts extensions to the ten extensionless importers (docs/config test files plus scripts/checks/local-credential-helper-pin.ts); moduleResolution: bundler does not resolve extensionless specifiers to .mts.
  • Updated validate-configs.mts direct-invocation guard (process.argv[1] now ends .mts) and its usage strings.
  • Updated generated-file provenance in sync-agent-variant-docs.mts and generate-starter-prompt.mts to name the new source paths, and the path references in docs/CONTRIBUTING.md and .coderabbit.yaml.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification: rename-only, no behaviour change; the docs/config test suite was retargeted to the new .mts paths and passes (15 files, 285 tests)
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: no user-facing behaviour change; only internal CONTRIBUTING.md and provenance path references were updated to the new .mts filenames
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result: npm run typecheck:cli clean; npx vitest run --project integration on the 15 touched docs/config test files → 285 passed
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added automated audits to flag undocumented, stale, or invalid environment-variable documentation.
    • Improved Fern preview instance validation and argument building.
  • Bug Fixes

    • Updated documentation preview/publish workflows and config validation tooling to use the correct ESM entry points.
    • Corrected generated-file attribution and related validation messaging to match the active scripts.
  • Documentation

    • Refreshed contribution guidance and internal docs-route checking instructions.
  • Tests

    • Updated documentation, configuration, and preview tests to target the current module implementations.

@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: da597fd8-3966-4cef-a304-301c1998c67d

📥 Commits

Reviewing files that changed from the base of the PR and between 166e555 and f2edbc0.

📒 Files selected for processing (1)
  • scripts/validate-configs.mts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/validate-configs.mts

📝 Walkthrough

Walkthrough

Documentation and configuration tooling was migrated to explicit .mts entrypoints. A new environment-variable documentation audit and Fern preview configuration module were added, while commands, workflows, hooks, generated notices, imports, documentation, and tests were updated.

Changes

Documentation and configuration tooling migration

Layer / File(s) Summary
Environment-variable documentation audit
scripts/check-env-var-docs.mts, .pre-commit-config.yaml, test/check-env-var-docs.test.ts
Adds AST-based environment-variable detection, documentation extraction, allowlist validation, source walking, categorized audit results, and pre-commit integration.
Fern preview configuration module
scripts/fern-preview-config.mts, scripts/watch-fern-preview.mts, test/fern-preview-config.test.ts
Adds Fern instance validation, default resolution, ordered CLI argument construction, and .mts imports for the watcher and tests.
.mts entrypoint wiring and verification
package.json, .github/workflows/*, .coderabbit.yaml, .pre-commit-config.yaml, docs/CONTRIBUTING.md, scripts/*.mts, scripts/checks/*, test/*
Updates commands, workflow filters, hooks, review instructions, generated notices, usage strings, internal imports, documentation, and tests to reference .mts entrypoints.

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

Sequence Diagram(s)

sequenceDiagram
  participant SourceFiles
  participant checkEnvVarDocs
  participant CommandsMdx
  participant AllowlistJson
  SourceFiles->>checkEnvVarDocs: scan NEMOCLAW_* reads
  CommandsMdx->>checkEnvVarDocs: extract documented variables
  AllowlistJson->>checkEnvVarDocs: load allowlist entries
  checkEnvVarDocs->>checkEnvVarDocs: compute audit results
Loading

Possibly related issues

Possibly related PRs

  • NVIDIA/NemoClaw#6894 — Touches the starter-prompt documentation pipeline updated by this migration.

Suggested labels: refactor, area: docs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the PR’s main change: migrating scripts and related tooling to .mts.
Linked Issues check ✅ Passed The changes update the seven listed tools and their references while keeping behavior unchanged, matching #6920.
Out of Scope Changes check ✅ Passed I don't see unrelated code changes; the edits are limited to the .mts migration and required reference updates.
✨ 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 refactor/6920-docs-config-tools-mts

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

@github-actions

Copy link
Copy Markdown
Contributor

@github-code-quality

github-code-quality Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the refactor/6920-docs-c... branch remains at 79%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main 6ef2df9 refactor/6920-docs-c... 7e1e71a +/-
src/lib/agent/dashboard-ui.ts 91% 85% -6%
src/lib/state/config-io.ts 95% 92% -3%
src/lib/agent/m...fest-readers.ts 97% 95% -2%
src/lib/securit...ntial-filter.ts 98% 99% +1%
src/lib/adapter...tp/curl-args.ts 97% 98% +1%
src/lib/state/gateway.ts 91% 93% +2%
src/lib/messagi.../persistence.ts 86% 89% +3%
src/lib/messagi...n-validation.ts 96% 100% +4%
src/lib/adapter...shell/client.ts 83% 88% +5%
src/lib/core/pr...mpt-activity.ts 67% 92% +25%

Updated July 15, 2026 15:25 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@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, credential-sanitization, security-posture

1 optional E2E recommendation
  • docs-validation

Workflow run details

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@scripts/check-env-var-docs.mts`:
- Around line 221-249: The isAssignmentOperator helper currently treats compound
assignments as write-only, incorrectly skipping reads of environment variables.
Narrow isAssignmentOperator to return true only for ts.SyntaxKind.EqualsToken,
while isAssignmentOrDeleteTarget continues handling delete expressions
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4d632d12-c10d-459d-a188-10e6704ef8fa

📥 Commits

Reviewing files that changed from the base of the PR and between 55fdc3f and 166e555.

📒 Files selected for processing (29)
  • .coderabbit.yaml
  • .github/workflows/docs-preview-pr.yaml
  • .github/workflows/docs-publish-staging.yaml
  • .pre-commit-config.yaml
  • docs/CONTRIBUTING.md
  • package.json
  • scripts/check-docs-published-routes.mts
  • scripts/check-env-var-docs.mts
  • scripts/checks/local-credential-helper-pin.ts
  • scripts/fern-preview-config.mts
  • scripts/generate-starter-prompt.mts
  • scripts/sync-agent-variant-docs.mts
  • scripts/validate-configs.mts
  • scripts/watch-fern-preview.mts
  • test/agent-variant-docs.test.ts
  • test/changelog-docs.test.ts
  • test/check-docs-published-routes.test.ts
  • test/check-env-var-docs.test.ts
  • test/fern-preview-config.test.ts
  • test/generate-platform-docs.test.ts
  • test/internal-commands-docs.test.ts
  • test/network-policies-published-routes.test.ts
  • test/onboard-performance-config-schema.test.ts
  • test/repro-5445-docs-published-route.test.ts
  • test/starter-prompt-docs.test.ts
  • test/sync-agent-variant-docs.test.ts
  • test/validate-blueprint.test.ts
  • test/validate-config-schemas.test.ts
  • test/validate-configs-dangerous-hosts.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

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

Inline comments:
In `@scripts/check-env-var-docs.mts`:
- Around line 221-249: The isAssignmentOperator helper currently treats compound
assignments as write-only, incorrectly skipping reads of environment variables.
Narrow isAssignmentOperator to return true only for ts.SyntaxKind.EqualsToken,
while isAssignmentOrDeleteTarget continues handling delete expressions
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4d632d12-c10d-459d-a188-10e6704ef8fa

📥 Commits

Reviewing files that changed from the base of the PR and between 55fdc3f and 166e555.

📒 Files selected for processing (29)
  • .coderabbit.yaml
  • .github/workflows/docs-preview-pr.yaml
  • .github/workflows/docs-publish-staging.yaml
  • .pre-commit-config.yaml
  • docs/CONTRIBUTING.md
  • package.json
  • scripts/check-docs-published-routes.mts
  • scripts/check-env-var-docs.mts
  • scripts/checks/local-credential-helper-pin.ts
  • scripts/fern-preview-config.mts
  • scripts/generate-starter-prompt.mts
  • scripts/sync-agent-variant-docs.mts
  • scripts/validate-configs.mts
  • scripts/watch-fern-preview.mts
  • test/agent-variant-docs.test.ts
  • test/changelog-docs.test.ts
  • test/check-docs-published-routes.test.ts
  • test/check-env-var-docs.test.ts
  • test/fern-preview-config.test.ts
  • test/generate-platform-docs.test.ts
  • test/internal-commands-docs.test.ts
  • test/network-policies-published-routes.test.ts
  • test/onboard-performance-config-schema.test.ts
  • test/repro-5445-docs-published-route.test.ts
  • test/starter-prompt-docs.test.ts
  • test/sync-agent-variant-docs.test.ts
  • test/validate-blueprint.test.ts
  • test/validate-config-schemas.test.ts
  • test/validate-configs-dangerous-hosts.test.ts
🛑 Comments failed to post (1)
scripts/check-env-var-docs.mts (1)

221-249: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== File outline ==\n'
ast-grep outline scripts/check-env-var-docs.mts --view expanded || true

printf '\n== Relevant lines in scripts/check-env-var-docs.mts ==\n'
sed -n '210,265p' scripts/check-env-var-docs.mts

printf '\n== Test file outline ==\n'
ast-grep outline scripts/check-env-var-docs.test.ts --view expanded || true

printf '\n== Relevant lines in scripts/check-env-var-docs.test.ts ==\n'
sed -n '1,260p' scripts/check-env-var-docs.test.ts

Repository: NVIDIA/NemoClaw

Length of output: 3708


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== TS SyntaxKind assignment range probe ==\n'
node - <<'JS'
const ts = require('typescript');
const assignmentKinds = Object.entries(ts.SyntaxKind)
  .filter(([k, v]) => typeof v === 'number' && k.endsWith('EqualsToken'))
  .sort((a, b) => a[1] - b[1]);
console.log('FirstAssignment:', ts.SyntaxKind[ts.SyntaxKind.FirstAssignment], ts.SyntaxKind.FirstAssignment);
console.log('LastAssignment:', ts.SyntaxKind[ts.SyntaxKind.LastAssignment], ts.SyntaxKind.LastAssignment);
console.log('Assignment tokens around range:');
for (const [name, val] of assignmentKinds) {
  if (val >= ts.SyntaxKind.FirstAssignment && val <= ts.SyntaxKind.LastAssignment) {
    console.log(name);
  }
}
console.log('Current explicit checks in file:');
const fs = require('fs');
const text = fs.readFileSync('scripts/check-env-var-docs.mts', 'utf8');
const m = text.match(/function isAssignmentOperator[\s\S]*?return \(([\s\S]*?)\n\s*\);/);
console.log(m ? m[1].trim() : 'not found');
JS

Repository: NVIDIA/NemoClaw

Length of output: 851


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Search for uses of isAssignmentOperator ==\n'
rg -n "isAssignmentOperator|QuestionQuestionEqualsToken|AmpersandAmpersandEqualsToken|BarBarEqualsToken" scripts/check-env-var-docs.mts scripts/check-env-var-docs.test.ts || true

Repository: NVIDIA/NemoClaw

Length of output: 733


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Relevant source around wrapper helpers ==\n'
sed -n '150,250p' scripts/check-env-var-docs.mts

printf '\n== Relevant test cases around env var reads/writes ==\n'
sed -n '1,220p' scripts/check-env-var-docs.test.ts

Repository: NVIDIA/NemoClaw

Length of output: 3268


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' scripts/check-env-var-docs.mts

Repository: NVIDIA/NemoClaw

Length of output: 6565


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Full env-var read scanner ==\n'
sed -n '1,220p' scripts/check-env-var-docs.mts

printf '\n== Repo file names matching check-env-var-docs ==\n'
git ls-files | rg 'check-env-var-docs'

Repository: NVIDIA/NemoClaw

Length of output: 6712


Only skip plain =
Compound assignments also read the current value, so process.env.FOO += 1 / ??= should still count as reads. Narrow this check to ts.SyntaxKind.EqualsToken; the current list can hide undocumented env vars touched through compound assignment.

🤖 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/check-env-var-docs.mts` around lines 221 - 249, The
isAssignmentOperator helper currently treats compound assignments as write-only,
incorrectly skipping reads of environment variables. Narrow isAssignmentOperator
to return true only for ts.SyntaxKind.EqualsToken, while
isAssignmentOrDeleteTarget continues handling delete expressions unchanged.

@laitingsheng laitingsheng added the chore Build, CI, dependency, or tooling maintenance label Jul 15, 2026
…onfigs

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>

@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 documentation/configuration tool module migration, workflow path updates, configuration and credential-helper behavior, focused tests, and completed CI/E2E gates. Approved for v0.0.84.

@cv
cv merged commit af90d44 into main Jul 15, 2026
55 checks passed
@cv
cv deleted the refactor/6920-docs-config-tools-mts branch July 15, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate documentation and configuration tools to .mts

2 participants