Repository navigation
fix(plugins): filter .d.mts and .d.cts declaration files in extension discovery - #107994
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 12:36 AM ET / 04:36 UTC. ClawSweeper reviewWhat this changesThe PR expands plugin-file filtering so TypeScript declaration files ending in Merge readinessThis remains a useful, narrowly scoped bug fix: current Priority: P2 Review scores
Verification
How this fits togetherPlugin discovery scans bundled, global, workspace, and configured roots for candidate entry files, then passes candidates into manifest validation and plugin loading. This change tightens the shared file gate before invalid declaration files can become discovery candidates. flowchart LR
A[Plugin roots] --> B[Directory scan]
B --> C[Extension file gate]
C -->|Runnable source| D[Plugin candidate]
C -->|Declaration file| E[Ignored]
D --> F[Manifest registry]
F --> G[Plugin loader]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +24. Total +24 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Land this small owner-boundary fix after the exact PR-head checks complete, retaining the one shared declaration-file filter and the focused regression test. Do we have a high-confidence way to reproduce the issue? Yes—high confidence from current source: a Is this the best way to solve the issue? Yes. Updating the single shared file gate is the narrowest maintainable solution because every scanned file reaches it before candidate creation; filtering downstream would leave duplicate paths and inconsistent behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 121a86210555. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
… discovery
isExtensionFile only checked for .d.ts but not .d.mts or .d.cts.
path.extname('.d.mts') returns '.mts' so these declaration files
passed through all checks and were treated as valid plugin entries.
Replaced the single .d.ts check with a regex covering all TS
declaration file variants.
Co-Authored-By: Claude <[email protected]>
f06da20 to
96cc216
Compare
|
@clawsweeper re-review Updated PR body with real OpenClaw runtime invocation evidence (not standalone simulation). Please re-review. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
96cc216 to
c6c1b8a
Compare
|
Land-ready verification for original contributor head c6c1b8a: current main misclassifies .d.mts and .d.cts TypeScript declarations as executable plugin candidates at the shared discovery owner. I corrected the original regression so it actually scans an explicit plugin directory and includes valid executable .mts/.cts controls; restoring the current-main guard makes the real filesystem-boundary test fail with the unexpected bravo.d candidate, while the contributor fix makes it pass and preserves both valid formats. Focused proof: OPENCLAW_VITEST_MAX_WORKERS=1 node /Users/steipete/Projects/openclaw/scripts/run-vitest.mjs src/plugins/discovery.test.ts -t 'ignores TypeScript declaration files'. Targeted formatting and git diff checks passed; fresh complete-branch Codex xhigh autoreview passed (0.99). Exact-head full hosted CI run 30684105948 is green, including plugin tests, lint, types, security, all four QA Smoke profiles, and openclaw/ci-gate; authored-body proof run 30684400787 is green. Original contributor authorship is preserved. |
|
Merged via squash.
|
… discovery (openclaw#107994) * fix(plugins): filter .d.mts and .d.cts declaration files in extension discovery isExtensionFile only checked for .d.ts but not .d.mts or .d.cts. path.extname('.d.mts') returns '.mts' so these declaration files passed through all checks and were treated as valid plugin entries. Replaced the single .d.ts check with a regex covering all TS declaration file variants. Co-Authored-By: Claude <[email protected]> * fix: update d.mts test to use distinct filenames so it fails on old code --------- Co-authored-by: Claude <[email protected]>
What Problem This Solves
isExtensionFileinsrc/plugins/discovery.ts:299only filters.d.tsfiles but not.d.mtsor.d.ctsdeclaration files.path.extname(".d.mts")returns.mts, so these declaration files pass all extension checks and are treated as valid plugin entries.Why This Change Was Made
The fix belongs in
isExtensionFilebecause it is the single gate for extension file filtering. The oldendsWith(".d.ts")check was too narrow for the TS declaration file family. Using a regex/\\.d\\.[cm]?ts$/covers all three variants without changing the function signature or callers.User Impact
.d.mtsand.d.ctsfiles in plugin directories are mistakenly treated as valid plugin entriesReal behavior proof
Behavior addressed: .d.mts and .d.cts declaration files not filtered in extension discovery
Real environment tested: Linux x86_64, Node 24, commit
96cc216econ branchfix/d-cts-d-mts-extension-filter(rebased on upstream/main94e1cc9a4)Exact steps or command run after this patch:
node --import tsx /tmp/verify-real-discovery-runtime.mjs— real OpenClawdiscoverOpenClawPluginsruntime invocation: creates a temp state dir, placesalpha.d.ts,bravo.d.mts,charlie.d.ctsfiles in an extensions root, then calls the actual production discovery function and inspects the returned candidates listEvidence after fix: Terminal capture of
noderuntime verification (copied live output):Observed result after fix: Real
discoverOpenClawPluginsinvocation correctly excludes all three declaration file variants. None ofalpha.d.ts,bravo.d.mts,charlie.d.ctsappear in any candidate source path. 147 real plugin candidates still discovered correctly.What was not tested: End-to-end CLI plugin loading (CI will cover)
Tests and validation
New test
ignores TypeScript declaration files (.d.ts, .d.mts, .d.cts) in extension rootsuses distinct filenames (alpha/bravo/charlie) soderiveIdHintproduces predictable idHints. Test would fail on unpatched code:bravo.d.mtsandcharlie.d.ctswould be incorrectly accepted as candidates with idHintsbravo.dandcharlie.d.Risk checklist
discoverOpenClawPluginsruntime verifiedCloses: N/A (no existing issue)
Evidence