@overcrow/mcp 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +91 -1
- package/dist/audit/index.js +103 -0
- package/dist/audit/lexer.js +417 -0
- package/dist/audit/project.js +200 -0
- package/dist/audit/rules.js +661 -0
- package/dist/bootstrap/download.js +229 -0
- package/dist/bootstrap/install.js +280 -0
- package/dist/bootstrap/pin.js +85 -0
- package/dist/bootstrap/pin.json +119 -0
- package/dist/bootstrap/zip.js +258 -0
- package/dist/cli.js +200 -0
- package/dist/confine.js +244 -0
- package/dist/content/docs/en/cli.md +768 -0
- package/dist/content/docs/en/creator-space.md +78 -0
- package/dist/content/docs/en/dev-channel.md +130 -0
- package/dist/content/docs/en/elements.md +469 -0
- package/dist/content/docs/en/forms.md +328 -0
- package/dist/content/docs/en/guide.md +252 -0
- package/dist/content/docs/en/index.md +85 -0
- package/dist/content/docs/en/limits.md +241 -0
- package/dist/content/docs/en/logic.md +446 -0
- package/dist/content/docs/en/manifest.md +388 -0
- package/dist/content/docs/en/mcp.md +165 -0
- package/dist/content/docs/en/package.md +131 -0
- package/dist/content/docs/en/publish-a-widget.md +94 -0
- package/dist/content/docs/en/publish-keys.md +95 -0
- package/dist/content/docs/en/publishing.md +167 -0
- package/dist/content/docs/en/reference.md +55 -0
- package/dist/content/docs/en/result-shapes.md +332 -0
- package/dist/content/docs/en/sdk.md +295 -0
- package/dist/content/docs/en/security.md +115 -0
- package/dist/content/docs/en/service-reference.md +344 -0
- package/dist/content/docs/en/services.md +517 -0
- package/dist/content/docs/en/style-properties.md +270 -0
- package/dist/content/docs/en/style.md +266 -0
- package/dist/content/docs/en/testing.md +400 -0
- package/dist/content/docs/en/verified-domain.md +46 -0
- package/dist/content/docs/en/view.md +338 -0
- package/dist/content/docs/en/widget-listing.md +65 -0
- package/dist/content/docs/en/widget-review.md +57 -0
- package/dist/content/docs/en/widget-statistics.md +134 -0
- package/dist/content/docs/en/widgets.md +76 -0
- package/dist/content/docs/fr/cli.md +802 -0
- package/dist/content/docs/fr/creator-space.md +83 -0
- package/dist/content/docs/fr/dev-channel.md +140 -0
- package/dist/content/docs/fr/elements.md +475 -0
- package/dist/content/docs/fr/forms.md +341 -0
- package/dist/content/docs/fr/guide.md +263 -0
- package/dist/content/docs/fr/index.md +90 -0
- package/dist/content/docs/fr/limits.md +244 -0
- package/dist/content/docs/fr/logic.md +461 -0
- package/dist/content/docs/fr/manifest.md +401 -0
- package/dist/content/docs/fr/mcp.md +173 -0
- package/dist/content/docs/fr/package.md +139 -0
- package/dist/content/docs/fr/publish-a-widget.md +101 -0
- package/dist/content/docs/fr/publish-keys.md +97 -0
- package/dist/content/docs/fr/publishing.md +177 -0
- package/dist/content/docs/fr/reference.md +59 -0
- package/dist/content/docs/fr/result-shapes.md +333 -0
- package/dist/content/docs/fr/sdk.md +301 -0
- package/dist/content/docs/fr/security.md +129 -0
- package/dist/content/docs/fr/service-reference.md +346 -0
- package/dist/content/docs/fr/services.md +540 -0
- package/dist/content/docs/fr/style-properties.md +272 -0
- package/dist/content/docs/fr/style.md +281 -0
- package/dist/content/docs/fr/testing.md +417 -0
- package/dist/content/docs/fr/verified-domain.md +49 -0
- package/dist/content/docs/fr/view.md +352 -0
- package/dist/content/docs/fr/widget-listing.md +69 -0
- package/dist/content/docs/fr/widget-review.md +59 -0
- package/dist/content/docs/fr/widget-statistics.md +141 -0
- package/dist/content/docs/fr/widgets.md +81 -0
- package/dist/content/examples/clock/LICENSE +21 -0
- package/dist/content/examples/clock/README.md +75 -0
- package/dist/content/examples/clock/listing.json +19 -0
- package/dist/content/examples/clock/locales/en.json +4 -0
- package/dist/content/examples/clock/locales/fr.json +4 -0
- package/dist/content/examples/clock/logic.ts +85 -0
- package/dist/content/examples/clock/manifest.json +44 -0
- package/dist/content/examples/clock/package.json +16 -0
- package/dist/content/examples/clock/style.ocss +26 -0
- package/dist/content/examples/clock/tests/hidden.scenario.json +68 -0
- package/dist/content/examples/clock/tests/load-logic.mjs +22 -0
- package/dist/content/examples/clock/tests/logic.test.mjs +89 -0
- package/dist/content/examples/clock/tests/options.scenario.json +108 -0
- package/dist/content/examples/clock/tests/preview.scenario.json +25 -0
- package/dist/content/examples/clock/tests/render.scenario.json +94 -0
- package/dist/content/examples/clock/tests/summer-time.scenario.json +74 -0
- package/dist/content/examples/clock/tests/ticks.scenario.json +120 -0
- package/dist/content/examples/clock/tsconfig.json +16 -0
- package/dist/content/examples/clock/view.ocml +8 -0
- package/dist/content/examples/countdown/LICENSE +20 -0
- package/dist/content/examples/countdown/listing.json +10 -0
- package/dist/content/examples/countdown/locales/en.json +15 -0
- package/dist/content/examples/countdown/locales/fr.json +15 -0
- package/dist/content/examples/countdown/logic.ts +179 -0
- package/dist/content/examples/countdown/manifest.json +34 -0
- package/dist/content/examples/countdown/package.json +15 -0
- package/dist/content/examples/countdown/style.ocss +94 -0
- package/dist/content/examples/countdown/tsconfig.json +16 -0
- package/dist/content/examples/countdown/view.ocml +42 -0
- package/dist/content/examples/fps/LICENSE +21 -0
- package/dist/content/examples/fps/README.md +64 -0
- package/dist/content/examples/fps/listing.json +19 -0
- package/dist/content/examples/fps/locales/en.json +11 -0
- package/dist/content/examples/fps/locales/fr.json +11 -0
- package/dist/content/examples/fps/logic.ts +64 -0
- package/dist/content/examples/fps/manifest.json +30 -0
- package/dist/content/examples/fps/package.json +16 -0
- package/dist/content/examples/fps/style.ocss +31 -0
- package/dist/content/examples/fps/submission.json +8 -0
- package/dist/content/examples/fps/tests/label.scenario.json +63 -0
- package/dist/content/examples/fps/tests/load-logic.mjs +22 -0
- package/dist/content/examples/fps/tests/logic.test.mjs +60 -0
- package/dist/content/examples/fps/tests/preview.scenario.json +29 -0
- package/dist/content/examples/fps/tests/refused.scenario.json +20 -0
- package/dist/content/examples/fps/tests/render.scenario.json +96 -0
- package/dist/content/examples/fps/tests/stale.scenario.json +91 -0
- package/dist/content/examples/fps/tests/unavailable.scenario.json +111 -0
- package/dist/content/examples/fps/tsconfig.json +16 -0
- package/dist/content/examples/fps/view.ocml +11 -0
- package/dist/content/examples/media/LICENSE +21 -0
- package/dist/content/examples/media/README.md +147 -0
- package/dist/content/examples/media/listing.json +19 -0
- package/dist/content/examples/media/locales/en.json +11 -0
- package/dist/content/examples/media/locales/fr.json +11 -0
- package/dist/content/examples/media/logic.ts +191 -0
- package/dist/content/examples/media/manifest.json +35 -0
- package/dist/content/examples/media/package.json +16 -0
- package/dist/content/examples/media/style.ocss +148 -0
- package/dist/content/examples/media/submission.json +12 -0
- package/dist/content/examples/media/tests/covers.scenario.json +144 -0
- package/dist/content/examples/media/tests/gesture.scenario.json +173 -0
- package/dist/content/examples/media/tests/load-logic.mjs +22 -0
- package/dist/content/examples/media/tests/logic.test.mjs +176 -0
- package/dist/content/examples/media/tests/marquee.scenario.json +127 -0
- package/dist/content/examples/media/tests/preview.scenario.json +52 -0
- package/dist/content/examples/media/tests/read-only.scenario.json +53 -0
- package/dist/content/examples/media/tests/refused.scenario.json +22 -0
- package/dist/content/examples/media/tests/refused.test.mjs +31 -0
- package/dist/content/examples/media/tests/render.scenario.json +136 -0
- package/dist/content/examples/media/tests/states.scenario.json +257 -0
- package/dist/content/examples/media/tests/unavailable.scenario.json +120 -0
- package/dist/content/examples/media/tsconfig.json +16 -0
- package/dist/content/examples/media/view.ocml +41 -0
- package/dist/content/examples/notes/LICENSE +21 -0
- package/dist/content/examples/notes/README.md +219 -0
- package/dist/content/examples/notes/listing.json +19 -0
- package/dist/content/examples/notes/locales/en.json +25 -0
- package/dist/content/examples/notes/locales/fr.json +25 -0
- package/dist/content/examples/notes/logic.ts +799 -0
- package/dist/content/examples/notes/manifest.json +40 -0
- package/dist/content/examples/notes/package.json +16 -0
- package/dist/content/examples/notes/style.ocss +469 -0
- package/dist/content/examples/notes/submission.json +12 -0
- package/dist/content/examples/notes/tests/checks.scenario.json +237 -0
- package/dist/content/examples/notes/tests/create.scenario.json +260 -0
- package/dist/content/examples/notes/tests/delete.scenario.json +342 -0
- package/dist/content/examples/notes/tests/drafts.scenario.json +714 -0
- package/dist/content/examples/notes/tests/editor.scenario.json +232 -0
- package/dist/content/examples/notes/tests/frame.scenario.json +93 -0
- package/dist/content/examples/notes/tests/interactive.scenario.json +344 -0
- package/dist/content/examples/notes/tests/limits.scenario.json +1351 -0
- package/dist/content/examples/notes/tests/load-logic.mjs +22 -0
- package/dist/content/examples/notes/tests/logic.test.mjs +514 -0
- package/dist/content/examples/notes/tests/preview.scenario.json +99 -0
- package/dist/content/examples/notes/tests/read-only.scenario.json +105 -0
- package/dist/content/examples/notes/tests/refused.scenario.json +33 -0
- package/dist/content/examples/notes/tests/save.scenario.json +378 -0
- package/dist/content/examples/notes/tests/states.scenario.json +640 -0
- package/dist/content/examples/notes/tests/typing.scenario.json +562 -0
- package/dist/content/examples/notes/tests/unavailable.scenario.json +246 -0
- package/dist/content/examples/notes/tsconfig.json +16 -0
- package/dist/content/examples/notes/view.ocml +154 -0
- package/dist/content/examples/performance/LICENSE +21 -0
- package/dist/content/examples/performance/README.md +134 -0
- package/dist/content/examples/performance/listing.json +19 -0
- package/dist/content/examples/performance/locales/en.json +20 -0
- package/dist/content/examples/performance/locales/fr.json +20 -0
- package/dist/content/examples/performance/logic.ts +210 -0
- package/dist/content/examples/performance/manifest.json +83 -0
- package/dist/content/examples/performance/package.json +16 -0
- package/dist/content/examples/performance/style.ocss +75 -0
- package/dist/content/examples/performance/submission.json +12 -0
- package/dist/content/examples/performance/tests/fahrenheit.scenario.json +110 -0
- package/dist/content/examples/performance/tests/horizontal.scenario.json +96 -0
- package/dist/content/examples/performance/tests/load-logic.mjs +22 -0
- package/dist/content/examples/performance/tests/logic.test.mjs +226 -0
- package/dist/content/examples/performance/tests/menu.scenario.json +170 -0
- package/dist/content/examples/performance/tests/no-fps-source.scenario.json +47 -0
- package/dist/content/examples/performance/tests/preview.scenario.json +45 -0
- package/dist/content/examples/performance/tests/refused.scenario.json +20 -0
- package/dist/content/examples/performance/tests/refused.test.mjs +19 -0
- package/dist/content/examples/performance/tests/region.scenario.json +89 -0
- package/dist/content/examples/performance/tests/render.scenario.json +112 -0
- package/dist/content/examples/performance/tests/sources.scenario.json +151 -0
- package/dist/content/examples/performance/tests/stale.scenario.json +111 -0
- package/dist/content/examples/performance/tests/telemetry-only.scenario.json +44 -0
- package/dist/content/examples/performance/tests/thresholds.scenario.json +147 -0
- package/dist/content/examples/performance/tests/waiting.scenario.json +105 -0
- package/dist/content/examples/performance/tsconfig.json +16 -0
- package/dist/content/examples/performance/view.ocml +18 -0
- package/dist/content/examples/playervox-journal/LICENSE +21 -0
- package/dist/content/examples/playervox-journal/README.md +150 -0
- package/dist/content/examples/playervox-journal/listing.json +19 -0
- package/dist/content/examples/playervox-journal/locales/en.json +25 -0
- package/dist/content/examples/playervox-journal/locales/fr.json +25 -0
- package/dist/content/examples/playervox-journal/logic.ts +556 -0
- package/dist/content/examples/playervox-journal/manifest.json +19 -0
- package/dist/content/examples/playervox-journal/package.json +16 -0
- package/dist/content/examples/playervox-journal/style.ocss +142 -0
- package/dist/content/examples/playervox-journal/submission.json +12 -0
- package/dist/content/examples/playervox-journal/tests/changes.scenario.json +482 -0
- package/dist/content/examples/playervox-journal/tests/delete.scenario.json +432 -0
- package/dist/content/examples/playervox-journal/tests/frame.scenario.json +169 -0
- package/dist/content/examples/playervox-journal/tests/load-logic.mjs +22 -0
- package/dist/content/examples/playervox-journal/tests/logic.test.mjs +349 -0
- package/dist/content/examples/playervox-journal/tests/paging.scenario.json +428 -0
- package/dist/content/examples/playervox-journal/tests/preview.scenario.json +184 -0
- package/dist/content/examples/playervox-journal/tests/read-only.scenario.json +157 -0
- package/dist/content/examples/playervox-journal/tests/refused.scenario.json +39 -0
- package/dist/content/examples/playervox-journal/tests/scale.scenario.json +286 -0
- package/dist/content/examples/playervox-journal/tests/signed-out.scenario.json +134 -0
- package/dist/content/examples/playervox-journal/tests/states.scenario.json +741 -0
- package/dist/content/examples/playervox-journal/tests/unavailable.scenario.json +183 -0
- package/dist/content/examples/playervox-journal/tsconfig.json +16 -0
- package/dist/content/examples/playervox-journal/view.ocml +52 -0
- package/dist/content/examples/playervox-rating/LICENSE +21 -0
- package/dist/content/examples/playervox-rating/README.md +166 -0
- package/dist/content/examples/playervox-rating/listing.json +19 -0
- package/dist/content/examples/playervox-rating/locales/en.json +35 -0
- package/dist/content/examples/playervox-rating/locales/fr.json +35 -0
- package/dist/content/examples/playervox-rating/logic.ts +581 -0
- package/dist/content/examples/playervox-rating/manifest.json +19 -0
- package/dist/content/examples/playervox-rating/package.json +16 -0
- package/dist/content/examples/playervox-rating/style.ocss +333 -0
- package/dist/content/examples/playervox-rating/submission.json +12 -0
- package/dist/content/examples/playervox-rating/tests/account.scenario.json +125 -0
- package/dist/content/examples/playervox-rating/tests/bounds.scenario.json +73 -0
- package/dist/content/examples/playervox-rating/tests/draft.scenario.json +199 -0
- package/dist/content/examples/playervox-rating/tests/form.scenario.json +142 -0
- package/dist/content/examples/playervox-rating/tests/load-logic.mjs +22 -0
- package/dist/content/examples/playervox-rating/tests/logic.test.mjs +346 -0
- package/dist/content/examples/playervox-rating/tests/offline.scenario.json +142 -0
- package/dist/content/examples/playervox-rating/tests/preview.scenario.json +44 -0
- package/dist/content/examples/playervox-rating/tests/publish-keyboard.scenario.json +221 -0
- package/dist/content/examples/playervox-rating/tests/publish-pointer.scenario.json +314 -0
- package/dist/content/examples/playervox-rating/tests/read-only.scenario.json +70 -0
- package/dist/content/examples/playervox-rating/tests/refused.scenario.json +45 -0
- package/dist/content/examples/playervox-rating/tests/states.scenario.json +362 -0
- package/dist/content/examples/playervox-rating/tsconfig.json +16 -0
- package/dist/content/examples/playervox-rating/view.ocml +62 -0
- package/dist/content/examples/playervox-reviews/LICENSE +21 -0
- package/dist/content/examples/playervox-reviews/README.md +194 -0
- package/dist/content/examples/playervox-reviews/listing.json +19 -0
- package/dist/content/examples/playervox-reviews/locales/en.json +32 -0
- package/dist/content/examples/playervox-reviews/locales/fr.json +32 -0
- package/dist/content/examples/playervox-reviews/logic.ts +822 -0
- package/dist/content/examples/playervox-reviews/manifest.json +30 -0
- package/dist/content/examples/playervox-reviews/package.json +16 -0
- package/dist/content/examples/playervox-reviews/style.ocss +260 -0
- package/dist/content/examples/playervox-reviews/submission.json +8 -0
- package/dist/content/examples/playervox-reviews/tests/account.scenario.json +249 -0
- package/dist/content/examples/playervox-reviews/tests/bounds.scenario.json +336 -0
- package/dist/content/examples/playervox-reviews/tests/changes.scenario.json +515 -0
- package/dist/content/examples/playervox-reviews/tests/filter.scenario.json +400 -0
- package/dist/content/examples/playervox-reviews/tests/frame.scenario.json +185 -0
- package/dist/content/examples/playervox-reviews/tests/keyboard.scenario.json +188 -0
- package/dist/content/examples/playervox-reviews/tests/load-logic.mjs +22 -0
- package/dist/content/examples/playervox-reviews/tests/logic.test.mjs +559 -0
- package/dist/content/examples/playervox-reviews/tests/offline-start.scenario.json +152 -0
- package/dist/content/examples/playervox-reviews/tests/offline.scenario.json +311 -0
- package/dist/content/examples/playervox-reviews/tests/paging.scenario.json +497 -0
- package/dist/content/examples/playervox-reviews/tests/preview.scenario.json +286 -0
- package/dist/content/examples/playervox-reviews/tests/reading.scenario.json +591 -0
- package/dist/content/examples/playervox-reviews/tests/refused.scenario.json +54 -0
- package/dist/content/examples/playervox-reviews/tests/scale.scenario.json +303 -0
- package/dist/content/examples/playervox-reviews/tests/states.scenario.json +700 -0
- package/dist/content/examples/playervox-reviews/tests/unavailable.scenario.json +192 -0
- package/dist/content/examples/playervox-reviews/tsconfig.json +16 -0
- package/dist/content/examples/playervox-reviews/view.ocml +110 -0
- package/dist/content/examples/playervox-score/LICENSE +21 -0
- package/dist/content/examples/playervox-score/README.md +131 -0
- package/dist/content/examples/playervox-score/listing.json +19 -0
- package/dist/content/examples/playervox-score/locales/en.json +23 -0
- package/dist/content/examples/playervox-score/locales/fr.json +23 -0
- package/dist/content/examples/playervox-score/logic.ts +430 -0
- package/dist/content/examples/playervox-score/manifest.json +47 -0
- package/dist/content/examples/playervox-score/package.json +16 -0
- package/dist/content/examples/playervox-score/style.ocss +247 -0
- package/dist/content/examples/playervox-score/submission.json +8 -0
- package/dist/content/examples/playervox-score/tests/grades.scenario.json +279 -0
- package/dist/content/examples/playervox-score/tests/load-logic.mjs +22 -0
- package/dist/content/examples/playervox-score/tests/logic.test.mjs +229 -0
- package/dist/content/examples/playervox-score/tests/options.scenario.json +302 -0
- package/dist/content/examples/playervox-score/tests/preview.scenario.json +68 -0
- package/dist/content/examples/playervox-score/tests/pulse.scenario.json +157 -0
- package/dist/content/examples/playervox-score/tests/refused.scenario.json +21 -0
- package/dist/content/examples/playervox-score/tests/signed-out.scenario.json +46 -0
- package/dist/content/examples/playervox-score/tests/states.scenario.json +450 -0
- package/dist/content/examples/playervox-score/tests/unavailable.scenario.json +84 -0
- package/dist/content/examples/playervox-score/tsconfig.json +16 -0
- package/dist/content/examples/playervox-score/view.ocml +51 -0
- package/dist/content/examples/session/LICENSE +21 -0
- package/dist/content/examples/session/README.md +57 -0
- package/dist/content/examples/session/listing.json +19 -0
- package/dist/content/examples/session/locales/en.json +3 -0
- package/dist/content/examples/session/locales/fr.json +3 -0
- package/dist/content/examples/session/logic.ts +26 -0
- package/dist/content/examples/session/manifest.json +19 -0
- package/dist/content/examples/session/package.json +16 -0
- package/dist/content/examples/session/style.ocss +16 -0
- package/dist/content/examples/session/submission.json +8 -0
- package/dist/content/examples/session/tests/hidden.scenario.json +45 -0
- package/dist/content/examples/session/tests/load-logic.mjs +22 -0
- package/dist/content/examples/session/tests/logic.test.mjs +37 -0
- package/dist/content/examples/session/tests/preview.scenario.json +28 -0
- package/dist/content/examples/session/tests/refused.scenario.json +20 -0
- package/dist/content/examples/session/tests/refused.test.mjs +16 -0
- package/dist/content/examples/session/tests/render.scenario.json +95 -0
- package/dist/content/examples/session/tests/ticks.scenario.json +139 -0
- package/dist/content/examples/session/tests/unknown.scenario.json +37 -0
- package/dist/content/examples/session/tsconfig.json +16 -0
- package/dist/content/examples/session/view.ocml +11 -0
- package/dist/content/examples/stopwatch/LICENSE +21 -0
- package/dist/content/examples/stopwatch/README.md +99 -0
- package/dist/content/examples/stopwatch/listing.json +19 -0
- package/dist/content/examples/stopwatch/locales/en.json +8 -0
- package/dist/content/examples/stopwatch/locales/fr.json +8 -0
- package/dist/content/examples/stopwatch/logic.ts +93 -0
- package/dist/content/examples/stopwatch/manifest.json +19 -0
- package/dist/content/examples/stopwatch/package.json +16 -0
- package/dist/content/examples/stopwatch/style.ocss +54 -0
- package/dist/content/examples/stopwatch/submission.json +12 -0
- package/dist/content/examples/stopwatch/tests/errors.scenario.json +121 -0
- package/dist/content/examples/stopwatch/tests/gesture.scenario.json +154 -0
- package/dist/content/examples/stopwatch/tests/hidden.scenario.json +57 -0
- package/dist/content/examples/stopwatch/tests/hundredths.scenario.json +173 -0
- package/dist/content/examples/stopwatch/tests/load-logic.mjs +22 -0
- package/dist/content/examples/stopwatch/tests/logic.test.mjs +99 -0
- package/dist/content/examples/stopwatch/tests/preview.scenario.json +36 -0
- package/dist/content/examples/stopwatch/tests/read-only.scenario.json +42 -0
- package/dist/content/examples/stopwatch/tests/read-only.test.mjs +18 -0
- package/dist/content/examples/stopwatch/tests/refused.scenario.json +22 -0
- package/dist/content/examples/stopwatch/tests/refused.test.mjs +18 -0
- package/dist/content/examples/stopwatch/tests/render.scenario.json +105 -0
- package/dist/content/examples/stopwatch/tests/states.scenario.json +246 -0
- package/dist/content/examples/stopwatch/tests/unknown.scenario.json +40 -0
- package/dist/content/examples/stopwatch/tsconfig.json +16 -0
- package/dist/content/examples/stopwatch/view.ocml +29 -0
- package/dist/content/examples/twitch-chat/LICENSE +21 -0
- package/dist/content/examples/twitch-chat/README.md +283 -0
- package/dist/content/examples/twitch-chat/listing.json +19 -0
- package/dist/content/examples/twitch-chat/locales/en.json +52 -0
- package/dist/content/examples/twitch-chat/locales/fr.json +52 -0
- package/dist/content/examples/twitch-chat/logic.ts +887 -0
- package/dist/content/examples/twitch-chat/manifest.json +33 -0
- package/dist/content/examples/twitch-chat/package.json +16 -0
- package/dist/content/examples/twitch-chat/style.ocss +544 -0
- package/dist/content/examples/twitch-chat/submission.json +12 -0
- package/dist/content/examples/twitch-chat/tests/account.scenario.json +325 -0
- package/dist/content/examples/twitch-chat/tests/burst.scenario.json +1866 -0
- package/dist/content/examples/twitch-chat/tests/channel-refused.scenario.json +372 -0
- package/dist/content/examples/twitch-chat/tests/channel.scenario.json +480 -0
- package/dist/content/examples/twitch-chat/tests/draft.scenario.json +279 -0
- package/dist/content/examples/twitch-chat/tests/fade.scenario.json +269 -0
- package/dist/content/examples/twitch-chat/tests/failures.scenario.json +420 -0
- package/dist/content/examples/twitch-chat/tests/favorites.scenario.json +376 -0
- package/dist/content/examples/twitch-chat/tests/frame.scenario.json +152 -0
- package/dist/content/examples/twitch-chat/tests/lifetime.scenario.json +186 -0
- package/dist/content/examples/twitch-chat/tests/load-logic.mjs +22 -0
- package/dist/content/examples/twitch-chat/tests/logic.test.mjs +1053 -0
- package/dist/content/examples/twitch-chat/tests/passive.scenario.json +536 -0
- package/dist/content/examples/twitch-chat/tests/preview.scenario.json +147 -0
- package/dist/content/examples/twitch-chat/tests/read-only.scenario.json +202 -0
- package/dist/content/examples/twitch-chat/tests/read-only.test.mjs +63 -0
- package/dist/content/examples/twitch-chat/tests/refused.scenario.json +65 -0
- package/dist/content/examples/twitch-chat/tests/refused.test.mjs +43 -0
- package/dist/content/examples/twitch-chat/tests/render.scenario.json +347 -0
- package/dist/content/examples/twitch-chat/tests/reply.scenario.json +384 -0
- package/dist/content/examples/twitch-chat/tests/send-refused.scenario.json +383 -0
- package/dist/content/examples/twitch-chat/tests/send.scenario.json +300 -0
- package/dist/content/examples/twitch-chat/tests/states.scenario.json +455 -0
- package/dist/content/examples/twitch-chat/tests/unavailable.scenario.json +256 -0
- package/dist/content/examples/twitch-chat/tests/unread.scenario.json +997 -0
- package/dist/content/examples/twitch-chat/tsconfig.json +16 -0
- package/dist/content/examples/twitch-chat/view.ocml +141 -0
- package/dist/content/examples/warframe-market/LICENSE +21 -0
- package/dist/content/examples/warframe-market/README.md +176 -0
- package/dist/content/examples/warframe-market/listing.json +19 -0
- package/dist/content/examples/warframe-market/locales/en.json +44 -0
- package/dist/content/examples/warframe-market/locales/fr.json +44 -0
- package/dist/content/examples/warframe-market/logic.ts +1265 -0
- package/dist/content/examples/warframe-market/manifest.json +92 -0
- package/dist/content/examples/warframe-market/package.json +16 -0
- package/dist/content/examples/warframe-market/style.ocss +422 -0
- package/dist/content/examples/warframe-market/submission.json +24 -0
- package/dist/content/examples/warframe-market/tests/bounds.scenario.json +60 -0
- package/dist/content/examples/warframe-market/tests/cached.scenario.json +70 -0
- package/dist/content/examples/warframe-market/tests/detail.scenario.json +251 -0
- package/dist/content/examples/warframe-market/tests/errors.scenario.json +105 -0
- package/dist/content/examples/warframe-market/tests/fixtures.json +295 -0
- package/dist/content/examples/warframe-market/tests/load-logic.mjs +22 -0
- package/dist/content/examples/warframe-market/tests/logic.test.mjs +505 -0
- package/dist/content/examples/warframe-market/tests/no-clipboard.scenario.json +104 -0
- package/dist/content/examples/warframe-market/tests/passive.scenario.json +87 -0
- package/dist/content/examples/warframe-market/tests/preview.scenario.json +146 -0
- package/dist/content/examples/warframe-market/tests/refresh.scenario.json +56 -0
- package/dist/content/examples/warframe-market/tests/refused.scenario.json +74 -0
- package/dist/content/examples/warframe-market/tests/render.scenario.json +210 -0
- package/dist/content/examples/warframe-market/tests/search.scenario.json +189 -0
- package/dist/content/examples/warframe-market/tests/unavailable.scenario.json +54 -0
- package/dist/content/examples/warframe-market/tsconfig.json +16 -0
- package/dist/content/examples/warframe-market/view.ocml +116 -0
- package/dist/content/examples/weather/LICENSE +20 -0
- package/dist/content/examples/weather/listing.json +10 -0
- package/dist/content/examples/weather/locales/en.json +9 -0
- package/dist/content/examples/weather/locales/fr.json +9 -0
- package/dist/content/examples/weather/logic.ts +62 -0
- package/dist/content/examples/weather/manifest.json +51 -0
- package/dist/content/examples/weather/package.json +15 -0
- package/dist/content/examples/weather/style.ocss +29 -0
- package/dist/content/examples/weather/submission.json +17 -0
- package/dist/content/examples/weather/tsconfig.json +16 -0
- package/dist/content/examples/weather/view.ocml +12 -0
- package/dist/content/index.json +3705 -0
- package/dist/content/reference/errors.json +1924 -0
- package/dist/content/reference/limits.json +1154 -0
- package/dist/content/reference/manifest.md +223 -0
- package/dist/content/reference/permissions.json +413 -0
- package/dist/content/templates/blank/locales/en.json +3 -0
- package/dist/content/templates/blank/locales/fr.json +3 -0
- package/dist/content/templates/blank/logic.ts +7 -0
- package/dist/content/templates/blank/manifest.json +16 -0
- package/dist/content/templates/blank/style.ocss +10 -0
- package/dist/content/templates/blank/tests/example.scenario.json +10 -0
- package/dist/content/templates/blank/view.ocml +6 -0
- package/dist/content/templates/chart/locales/en.json +3 -0
- package/dist/content/templates/chart/locales/fr.json +3 -0
- package/dist/content/templates/chart/logic.ts +27 -0
- package/dist/content/templates/chart/manifest.json +16 -0
- package/dist/content/templates/chart/style.ocss +27 -0
- package/dist/content/templates/chart/tests/example.scenario.json +10 -0
- package/dist/content/templates/chart/view.ocml +10 -0
- package/dist/content/templates/counter/locales/en.json +4 -0
- package/dist/content/templates/counter/locales/fr.json +4 -0
- package/dist/content/templates/counter/logic.ts +20 -0
- package/dist/content/templates/counter/manifest.json +16 -0
- package/dist/content/templates/counter/style.ocss +26 -0
- package/dist/content/templates/counter/tests/example.scenario.json +11 -0
- package/dist/content/templates/counter/view.ocml +13 -0
- package/dist/content/templates/list/locales/en.json +8 -0
- package/dist/content/templates/list/locales/fr.json +8 -0
- package/dist/content/templates/list/logic.ts +35 -0
- package/dist/content/templates/list/manifest.json +16 -0
- package/dist/content/templates/list/style.ocss +42 -0
- package/dist/content/templates/list/tests/example.scenario.json +10 -0
- package/dist/content/templates/list/view.ocml +17 -0
- package/dist/content/templates/shared/LICENSE +20 -0
- package/dist/content/templates/shared/package.json +14 -0
- package/dist/content/templates/shared/tsconfig.json +16 -0
- package/dist/content.js +68 -0
- package/dist/env.js +156 -0
- package/dist/fingerprint.js +32 -0
- package/dist/hidden.js +47 -0
- package/dist/ids.js +27 -0
- package/dist/index.js +82 -0
- package/dist/knowledge.js +222 -0
- package/dist/npm.js +149 -0
- package/dist/prompts.js +47 -0
- package/dist/resources.js +82 -0
- package/dist/run.js +120 -0
- package/dist/server.js +43 -0
- package/dist/session.js +205 -0
- package/dist/sources.js +218 -0
- package/dist/text.js +80 -0
- package/dist/texts.js +44 -0
- package/dist/tools/audit.js +105 -0
- package/dist/tools/build.js +453 -0
- package/dist/tools/common.js +122 -0
- package/dist/tools/docs.js +196 -0
- package/dist/tools/preview.js +87 -0
- package/dist/tools/project.js +183 -0
- package/dist/tools/setup.js +146 -0
- package/dist/tools/submission.js +369 -0
- package/dist/version.js +3 -0
- package/npm-shrinkwrap.json +402 -0
- package/package.json +50 -4
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
// check, test, update_reference_images, package and inspect: the CLI's
|
|
2
|
+
// commands, their results read from its JSON output, as data.
|
|
3
|
+
import { lstat, readFile } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { authoritySummary } from "../audit/index.js";
|
|
7
|
+
import { Cli } from "../cli.js";
|
|
8
|
+
import { sourcesFingerprint } from "../fingerprint.js";
|
|
9
|
+
import { explainError } from "../knowledge.js";
|
|
10
|
+
import { boundList, clean, cleanLine } from "../text.js";
|
|
11
|
+
import { DESCRIPTIONS } from "../texts.js";
|
|
12
|
+
import { registerPreviewTool } from "./preview.js";
|
|
13
|
+
import { fail, ok, READ_ONLY, TOOLS_MISSING, widgetDirectory, withRoots, } from "./common.js";
|
|
14
|
+
const DIRECTORY = z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.max(1024)
|
|
18
|
+
.describe("The widget folder (it holds manifest.json), relative to the project folder.");
|
|
19
|
+
const SCENARIO = z
|
|
20
|
+
.string()
|
|
21
|
+
.regex(/^[a-z0-9][a-z0-9-]{0,63}$/)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("One scenario name (the file tests/<name>.scenario.json); all scenarios when absent.");
|
|
24
|
+
const NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
25
|
+
const MAX_DIAGNOSTICS = 200;
|
|
26
|
+
const MAX_IMAGE_BYTES = 1 << 20;
|
|
27
|
+
const MAX_IMAGES_BYTES = 4 << 20;
|
|
28
|
+
const MAX_IMAGE_SETS = 3;
|
|
29
|
+
/**
|
|
30
|
+
* Folders the CLI writes into: a link there could lead the write out of the
|
|
31
|
+
* project, so each must resolve inside it (or not exist yet).
|
|
32
|
+
*/
|
|
33
|
+
async function checkOutputs(confinement, target, folders) {
|
|
34
|
+
for (const folder of folders)
|
|
35
|
+
await confinement.resolve(join(target, folder), "new-directory");
|
|
36
|
+
}
|
|
37
|
+
const diagnosticSchema = z.object({
|
|
38
|
+
severity: z.enum(["error", "warning"]),
|
|
39
|
+
code: z.string(),
|
|
40
|
+
file: z.string().nullable(),
|
|
41
|
+
line: z.number().nullable(),
|
|
42
|
+
column: z.number().nullable(),
|
|
43
|
+
message: z.string(),
|
|
44
|
+
help: z.string().nullable(),
|
|
45
|
+
docs: z.string().nullable(),
|
|
46
|
+
});
|
|
47
|
+
function shapeDiagnostics(diagnostics) {
|
|
48
|
+
const { items, omitted } = boundList(diagnostics, MAX_DIAGNOSTICS);
|
|
49
|
+
return {
|
|
50
|
+
diagnostics: items.map((diagnostic) => ({
|
|
51
|
+
severity: diagnostic.severity,
|
|
52
|
+
code: cleanLine(diagnostic.code, 64),
|
|
53
|
+
file: diagnostic.file === null ? null : cleanLine(diagnostic.file, 256),
|
|
54
|
+
line: diagnostic.line,
|
|
55
|
+
column: diagnostic.column,
|
|
56
|
+
message: cleanLine(diagnostic.message, 600),
|
|
57
|
+
help: diagnostic.help === null ? null : cleanLine(diagnostic.help, 600),
|
|
58
|
+
docs: explainError(diagnostic.code, "en")?.url ?? null,
|
|
59
|
+
})),
|
|
60
|
+
omitted,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function counts(diagnostics) {
|
|
64
|
+
return {
|
|
65
|
+
errors: diagnostics.filter((d) => d.severity === "error").length,
|
|
66
|
+
warnings: diagnostics.filter((d) => d.severity === "warning").length,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function cliOf(env) {
|
|
70
|
+
const tools = await env.session.installedTools();
|
|
71
|
+
return tools ? new Cli(tools) : undefined;
|
|
72
|
+
}
|
|
73
|
+
/** Reads a PNG of the project for an image result, within the bounds. */
|
|
74
|
+
async function pngContent(confinement, wanted, budget) {
|
|
75
|
+
// Through the confinement: a link in tests/ cannot show a file from elsewhere.
|
|
76
|
+
const path = await confinement.resolve(wanted, "file").catch(() => undefined);
|
|
77
|
+
if (!path)
|
|
78
|
+
return undefined;
|
|
79
|
+
const info = await lstat(path).catch(() => undefined);
|
|
80
|
+
if (!info?.isFile() || info.size > MAX_IMAGE_BYTES || info.size > budget.left)
|
|
81
|
+
return undefined;
|
|
82
|
+
const data = await readFile(path);
|
|
83
|
+
if (data.readUInt32BE(0) !== 0x89504e47)
|
|
84
|
+
return undefined;
|
|
85
|
+
budget.left -= info.size;
|
|
86
|
+
return { type: "image", data: data.toString("base64"), mimeType: "image/png" };
|
|
87
|
+
}
|
|
88
|
+
function shapeScenario(line) {
|
|
89
|
+
const passed = line.passed === true;
|
|
90
|
+
const list = (value) => (Array.isArray(value) ? value : []);
|
|
91
|
+
const outcomes = (value) => list(value)
|
|
92
|
+
.filter((outcome) => outcome.ok !== true)
|
|
93
|
+
.slice(0, 20)
|
|
94
|
+
.map((outcome) => ({
|
|
95
|
+
step: typeof outcome.step === "number" ? outcome.step : null,
|
|
96
|
+
kind: cleanLine(String(outcome.kind ?? ""), 32),
|
|
97
|
+
detail: typeof outcome.detail === "string" ? clean(outcome.detail, 1500) : null,
|
|
98
|
+
}));
|
|
99
|
+
const name = String(line.name ?? "");
|
|
100
|
+
return {
|
|
101
|
+
name: NAME.test(name) ? name : cleanLine(name, 64),
|
|
102
|
+
passed,
|
|
103
|
+
failure: typeof line.failure === "string" ? clean(line.failure, 2000) : null,
|
|
104
|
+
failedExpectations: outcomes(line.expectations),
|
|
105
|
+
scenarioErrors: outcomes(line.errors),
|
|
106
|
+
faults: list(line.faults)
|
|
107
|
+
.slice(0, 20)
|
|
108
|
+
.map((fault) => cleanLine(String(fault), 64)),
|
|
109
|
+
images: list(line.images)
|
|
110
|
+
.slice(0, 64)
|
|
111
|
+
.map((image) => {
|
|
112
|
+
const imageName = String(image.name ?? "");
|
|
113
|
+
const safe = NAME.test(imageName) && NAME.test(name);
|
|
114
|
+
const status = cleanLine(String(image.status ?? ""), 16);
|
|
115
|
+
return {
|
|
116
|
+
name: cleanLine(imageName, 64),
|
|
117
|
+
status,
|
|
118
|
+
ppm: typeof image.ppm === "number" ? image.ppm : null,
|
|
119
|
+
maxDelta: typeof image.maxDelta === "number" ? image.maxDelta : null,
|
|
120
|
+
reference: safe ? `tests/reference/${name}/${imageName}.png` : null,
|
|
121
|
+
actual: safe && ["different", "size", "missing"].includes(status)
|
|
122
|
+
? `tests/output/${name}/${imageName}.actual.png`
|
|
123
|
+
: null,
|
|
124
|
+
diff: safe && status === "different" ? `tests/output/${name}/${imageName}.diff.png` : null,
|
|
125
|
+
};
|
|
126
|
+
}),
|
|
127
|
+
logs: passed
|
|
128
|
+
? []
|
|
129
|
+
: list(line.logs)
|
|
130
|
+
.slice(0, 20)
|
|
131
|
+
.map((log) => ({
|
|
132
|
+
level: cleanLine(String(log.level ?? ""), 8),
|
|
133
|
+
text: clean(String(log.text ?? ""), 500),
|
|
134
|
+
})),
|
|
135
|
+
staleReferences: list(line.staleReferences)
|
|
136
|
+
.slice(0, 20)
|
|
137
|
+
.map((path) => cleanLine(String(path), 256)),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const scenarioSchema = z.object({
|
|
141
|
+
name: z.string(),
|
|
142
|
+
passed: z.boolean(),
|
|
143
|
+
failure: z.string().nullable(),
|
|
144
|
+
failedExpectations: z.array(z.object({ step: z.number().nullable(), kind: z.string(), detail: z.string().nullable() })),
|
|
145
|
+
scenarioErrors: z.array(z.object({ step: z.number().nullable(), kind: z.string(), detail: z.string().nullable() })),
|
|
146
|
+
faults: z.array(z.string()),
|
|
147
|
+
images: z.array(z.object({
|
|
148
|
+
name: z.string(),
|
|
149
|
+
status: z.string(),
|
|
150
|
+
ppm: z.number().nullable(),
|
|
151
|
+
maxDelta: z.number().nullable(),
|
|
152
|
+
reference: z.string().nullable(),
|
|
153
|
+
actual: z.string().nullable(),
|
|
154
|
+
diff: z.string().nullable(),
|
|
155
|
+
})),
|
|
156
|
+
logs: z.array(z.object({ level: z.string(), text: z.string() })),
|
|
157
|
+
staleReferences: z.array(z.string()),
|
|
158
|
+
});
|
|
159
|
+
const testOutput = z.object({
|
|
160
|
+
directory: z.string(),
|
|
161
|
+
ran: z.boolean(),
|
|
162
|
+
passed: z.number().nullable(),
|
|
163
|
+
failed: z.number().nullable(),
|
|
164
|
+
scenarios: z.array(scenarioSchema),
|
|
165
|
+
diagnostics: z.array(diagnosticSchema),
|
|
166
|
+
problem: z.string().nullable(),
|
|
167
|
+
imagesShown: z.array(z.string()),
|
|
168
|
+
next: z.string(),
|
|
169
|
+
});
|
|
170
|
+
async function runTests(env, confinement, directory, scenario, update, signal) {
|
|
171
|
+
const cli = await cliOf(env);
|
|
172
|
+
if (!cli)
|
|
173
|
+
return { failure: fail(TOOLS_MISSING) };
|
|
174
|
+
const target = await widgetDirectory(confinement, directory);
|
|
175
|
+
await checkOutputs(confinement, target, update ? ["tests/output", "tests/reference"] : ["tests/output"]);
|
|
176
|
+
const result = await cli.test(target, { scenario, update }, signal);
|
|
177
|
+
const { diagnostics } = shapeDiagnostics(result.diagnostics);
|
|
178
|
+
if (!result.ran) {
|
|
179
|
+
return {
|
|
180
|
+
target,
|
|
181
|
+
structured: {
|
|
182
|
+
directory: confinement.display(target),
|
|
183
|
+
ran: false,
|
|
184
|
+
passed: null,
|
|
185
|
+
failed: null,
|
|
186
|
+
scenarios: [],
|
|
187
|
+
diagnostics,
|
|
188
|
+
problem: clean(result.problem, 2000) || "No scenario ran.",
|
|
189
|
+
imagesShown: [],
|
|
190
|
+
next: diagnostics.length > 0
|
|
191
|
+
? "Fix the diagnostics (run check), then test again."
|
|
192
|
+
: "Read the problem, fix it, and test again.",
|
|
193
|
+
},
|
|
194
|
+
images: [],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const scenarios = result.scenarios.slice(0, 256).map(shapeScenario);
|
|
198
|
+
// Images of the first failures: reference, new image, difference.
|
|
199
|
+
const images = [];
|
|
200
|
+
const shown = [];
|
|
201
|
+
const budget = { left: MAX_IMAGES_BYTES };
|
|
202
|
+
if (!update) {
|
|
203
|
+
let sets = 0;
|
|
204
|
+
for (const entry of scenarios) {
|
|
205
|
+
for (const image of entry.images) {
|
|
206
|
+
if (sets >= MAX_IMAGE_SETS || !image.actual)
|
|
207
|
+
continue;
|
|
208
|
+
sets += 1;
|
|
209
|
+
for (const [label, path] of [
|
|
210
|
+
["reference", image.reference],
|
|
211
|
+
["new", image.actual],
|
|
212
|
+
["difference", image.diff],
|
|
213
|
+
]) {
|
|
214
|
+
if (!path)
|
|
215
|
+
continue;
|
|
216
|
+
const block = await pngContent(confinement, join(target, path), budget);
|
|
217
|
+
if (block) {
|
|
218
|
+
images.push({ type: "text", text: `${entry.name} / ${image.name}: ${label} image (${path})` }, block);
|
|
219
|
+
shown.push(path);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const failed = scenarios.filter((entry) => !entry.passed).length;
|
|
226
|
+
// Only a plain run counts for the submission: not an update of the references.
|
|
227
|
+
if (!update) {
|
|
228
|
+
env.session.lastTests.set(target, {
|
|
229
|
+
fingerprint: await sourcesFingerprint(target),
|
|
230
|
+
passed: scenarios.length - failed,
|
|
231
|
+
failed,
|
|
232
|
+
complete: scenario === undefined,
|
|
233
|
+
at: new Date(),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
target,
|
|
238
|
+
structured: {
|
|
239
|
+
directory: confinement.display(target),
|
|
240
|
+
ran: true,
|
|
241
|
+
passed: result.passed ?? scenarios.length - failed,
|
|
242
|
+
failed: result.failed ?? failed,
|
|
243
|
+
scenarios,
|
|
244
|
+
diagnostics,
|
|
245
|
+
problem: result.problem ? clean(result.problem, 2000) : null,
|
|
246
|
+
imagesShown: shown,
|
|
247
|
+
next: failed === 0
|
|
248
|
+
? update
|
|
249
|
+
? "Reference images updated. Look at them, then run test again."
|
|
250
|
+
: "All scenarios pass. Run audit next."
|
|
251
|
+
: "Fix the widget, or, if the new images are right, ask the user before update_reference_images.",
|
|
252
|
+
},
|
|
253
|
+
images,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
export function registerBuildTools(env) {
|
|
257
|
+
const { server } = env;
|
|
258
|
+
server.registerTool("check", {
|
|
259
|
+
title: "Check a widget",
|
|
260
|
+
description: DESCRIPTIONS.check,
|
|
261
|
+
inputSchema: z.strictObject({ directory: DIRECTORY }),
|
|
262
|
+
outputSchema: z.object({
|
|
263
|
+
directory: z.string(),
|
|
264
|
+
ok: z.boolean(),
|
|
265
|
+
errors: z.number(),
|
|
266
|
+
warnings: z.number(),
|
|
267
|
+
diagnostics: z.array(diagnosticSchema),
|
|
268
|
+
omitted: z.number(),
|
|
269
|
+
next: z.string(),
|
|
270
|
+
}),
|
|
271
|
+
annotations: { title: "Check a widget", ...READ_ONLY },
|
|
272
|
+
}, async ({ directory }, ctx) => withRoots(env, ctx, async (confinement, redactor) => {
|
|
273
|
+
const cli = await cliOf(env);
|
|
274
|
+
if (!cli)
|
|
275
|
+
return fail(TOOLS_MISSING);
|
|
276
|
+
const target = await widgetDirectory(confinement, directory);
|
|
277
|
+
const result = await cli.check(target, ctx.mcpReq.signal);
|
|
278
|
+
const { errors, warnings } = counts(result.diagnostics);
|
|
279
|
+
const shaped = shapeDiagnostics(result.diagnostics);
|
|
280
|
+
const next = errors > 0
|
|
281
|
+
? "Fix the errors (explain_error explains a code), then check again."
|
|
282
|
+
: warnings > 0
|
|
283
|
+
? "Fix the warnings: a submission must have none."
|
|
284
|
+
: "No problem. Run test next.";
|
|
285
|
+
return ok({
|
|
286
|
+
directory: confinement.display(target),
|
|
287
|
+
ok: result.ok && warnings === 0,
|
|
288
|
+
errors,
|
|
289
|
+
warnings,
|
|
290
|
+
...shaped,
|
|
291
|
+
next,
|
|
292
|
+
}, errors + warnings === 0
|
|
293
|
+
? "check: no problem."
|
|
294
|
+
: `check: ${errors} error(s), ${warnings} warning(s).`, { data: true, redactor });
|
|
295
|
+
}));
|
|
296
|
+
server.registerTool("test", {
|
|
297
|
+
title: "Test a widget",
|
|
298
|
+
description: DESCRIPTIONS.test,
|
|
299
|
+
inputSchema: z.strictObject({ directory: DIRECTORY, scenario: SCENARIO }),
|
|
300
|
+
outputSchema: testOutput,
|
|
301
|
+
annotations: {
|
|
302
|
+
title: "Test a widget",
|
|
303
|
+
readOnlyHint: false,
|
|
304
|
+
destructiveHint: false,
|
|
305
|
+
idempotentHint: true,
|
|
306
|
+
openWorldHint: false,
|
|
307
|
+
},
|
|
308
|
+
}, async ({ directory, scenario }, ctx) => withRoots(env, ctx, async (confinement, redactor) => {
|
|
309
|
+
const run = await runTests(env, confinement, directory, scenario, false, ctx.mcpReq.signal);
|
|
310
|
+
if ("failure" in run)
|
|
311
|
+
return run.failure;
|
|
312
|
+
const s = run.structured;
|
|
313
|
+
const summary = s.ran
|
|
314
|
+
? `test: ${s.passed} passed, ${s.failed} failed.`
|
|
315
|
+
: `test: no scenario ran. ${s.problem}`;
|
|
316
|
+
return ok(s, summary, { data: true, redactor, extra: run.images });
|
|
317
|
+
}));
|
|
318
|
+
server.registerTool("update_reference_images", {
|
|
319
|
+
title: "Update reference images",
|
|
320
|
+
description: DESCRIPTIONS.update_reference_images,
|
|
321
|
+
inputSchema: z.strictObject({
|
|
322
|
+
directory: DIRECTORY,
|
|
323
|
+
scenario: SCENARIO,
|
|
324
|
+
confirm: z
|
|
325
|
+
.literal(true)
|
|
326
|
+
.describe("Must be true: the user agreed to replace the reference images."),
|
|
327
|
+
}),
|
|
328
|
+
outputSchema: testOutput,
|
|
329
|
+
annotations: {
|
|
330
|
+
title: "Update reference images",
|
|
331
|
+
readOnlyHint: false,
|
|
332
|
+
destructiveHint: true,
|
|
333
|
+
idempotentHint: true,
|
|
334
|
+
openWorldHint: false,
|
|
335
|
+
},
|
|
336
|
+
}, async ({ directory, scenario }, ctx) => withRoots(env, ctx, async (confinement, redactor) => {
|
|
337
|
+
const run = await runTests(env, confinement, directory, scenario, true, ctx.mcpReq.signal);
|
|
338
|
+
if ("failure" in run)
|
|
339
|
+
return run.failure;
|
|
340
|
+
const updated = run.structured.scenarios.flatMap((entry) => entry.images
|
|
341
|
+
.filter((image) => image.status === "updated")
|
|
342
|
+
.map((image) => image.reference ?? image.name));
|
|
343
|
+
return ok(run.structured, `Updated ${updated.length} reference image(s)${updated.length ? `: ${updated.slice(0, 10).join(", ")}` : ""}.`, {
|
|
344
|
+
data: true,
|
|
345
|
+
redactor,
|
|
346
|
+
});
|
|
347
|
+
}));
|
|
348
|
+
registerPreviewTool(env);
|
|
349
|
+
server.registerTool("package", {
|
|
350
|
+
title: "Package a widget",
|
|
351
|
+
description: DESCRIPTIONS.package,
|
|
352
|
+
inputSchema: z.strictObject({ directory: DIRECTORY }),
|
|
353
|
+
outputSchema: z.object({
|
|
354
|
+
directory: z.string(),
|
|
355
|
+
ok: z.boolean(),
|
|
356
|
+
package: z.string().nullable(),
|
|
357
|
+
bytes: z.number().nullable(),
|
|
358
|
+
logicBytes: z.number().nullable(),
|
|
359
|
+
sha256: z.string().nullable(),
|
|
360
|
+
diagnostics: z.array(diagnosticSchema),
|
|
361
|
+
next: z.string(),
|
|
362
|
+
}),
|
|
363
|
+
annotations: {
|
|
364
|
+
title: "Package a widget",
|
|
365
|
+
readOnlyHint: false,
|
|
366
|
+
destructiveHint: false,
|
|
367
|
+
idempotentHint: true,
|
|
368
|
+
openWorldHint: false,
|
|
369
|
+
},
|
|
370
|
+
}, async ({ directory }, ctx) => withRoots(env, ctx, async (confinement, redactor) => {
|
|
371
|
+
const cli = await cliOf(env);
|
|
372
|
+
if (!cli)
|
|
373
|
+
return fail(TOOLS_MISSING);
|
|
374
|
+
const target = await widgetDirectory(confinement, directory);
|
|
375
|
+
const manifest = JSON.parse(await readFile(join(target, "manifest.json"), "utf8"));
|
|
376
|
+
const id = String(manifest.id ?? "");
|
|
377
|
+
const version = String(manifest.version ?? "");
|
|
378
|
+
if (!/^[a-z0-9.-]{3,128}$/.test(id) || !/^\d+\.\d+\.\d+$/.test(version)) {
|
|
379
|
+
return fail("manifest.json has no valid id and version: run check first.");
|
|
380
|
+
}
|
|
381
|
+
await checkOutputs(confinement, target, ["dist"]);
|
|
382
|
+
const out = join(target, "dist", `${id}-${version}.ocpkg`);
|
|
383
|
+
const result = await cli.package(target, out, ctx.mcpReq.signal);
|
|
384
|
+
const shaped = shapeDiagnostics(result.diagnostics);
|
|
385
|
+
return ok({
|
|
386
|
+
directory: confinement.display(target),
|
|
387
|
+
ok: result.ok,
|
|
388
|
+
package: result.ok ? confinement.display(out) : null,
|
|
389
|
+
bytes: result.bytes,
|
|
390
|
+
logicBytes: result.logicBytes,
|
|
391
|
+
sha256: result.sha256,
|
|
392
|
+
diagnostics: shaped.diagnostics,
|
|
393
|
+
next: result.ok
|
|
394
|
+
? "Run inspect on the package to see what it may do, then prepare_submission."
|
|
395
|
+
: "Fix the diagnostics, then package again.",
|
|
396
|
+
}, result.ok
|
|
397
|
+
? `Packaged ${confinement.display(out)} (${result.bytes} bytes, logic.js ${result.logicBytes} bytes).`
|
|
398
|
+
: "The package could not be built.", { data: true, redactor });
|
|
399
|
+
}));
|
|
400
|
+
server.registerTool("inspect", {
|
|
401
|
+
title: "Inspect a package",
|
|
402
|
+
description: DESCRIPTIONS.inspect,
|
|
403
|
+
inputSchema: z.strictObject({
|
|
404
|
+
file: z.string().min(1).max(1024).describe("A .ocpkg file inside the project."),
|
|
405
|
+
}),
|
|
406
|
+
outputSchema: z.object({
|
|
407
|
+
file: z.string(),
|
|
408
|
+
ok: z.boolean(),
|
|
409
|
+
id: z.string().nullable(),
|
|
410
|
+
version: z.string().nullable(),
|
|
411
|
+
bytes: z.number().nullable(),
|
|
412
|
+
sha256: z.string().nullable(),
|
|
413
|
+
heapMiB: z.number().nullable(),
|
|
414
|
+
sdk: z.string().nullable(),
|
|
415
|
+
files: z.array(z.object({ path: z.string(), bytes: z.number() })),
|
|
416
|
+
mayDo: z.array(z.string()),
|
|
417
|
+
diagnostics: z.array(diagnosticSchema),
|
|
418
|
+
}),
|
|
419
|
+
annotations: { title: "Inspect a package", ...READ_ONLY },
|
|
420
|
+
}, async ({ file }, ctx) => withRoots(env, ctx, async (confinement, redactor) => {
|
|
421
|
+
const cli = await cliOf(env);
|
|
422
|
+
if (!cli)
|
|
423
|
+
return fail(TOOLS_MISSING);
|
|
424
|
+
if (!file.endsWith(".ocpkg"))
|
|
425
|
+
return fail("inspect reads .ocpkg files.");
|
|
426
|
+
const path = await confinement.resolve(file, "file");
|
|
427
|
+
const result = await cli.inspect(path, confinement.roots[0]?.path ?? path, ctx.mcpReq.signal);
|
|
428
|
+
const report = result.report ?? {};
|
|
429
|
+
const archive = (report.archive ?? {});
|
|
430
|
+
const files = Array.isArray(report.files)
|
|
431
|
+
? report.files
|
|
432
|
+
: [];
|
|
433
|
+
const manifest = (report.manifest ?? null);
|
|
434
|
+
return ok({
|
|
435
|
+
file: confinement.display(path),
|
|
436
|
+
ok: result.ok,
|
|
437
|
+
id: typeof report.id === "string" ? report.id : null,
|
|
438
|
+
version: typeof report.version === "string" ? report.version : null,
|
|
439
|
+
bytes: typeof archive.bytes === "number" ? archive.bytes : null,
|
|
440
|
+
sha256: typeof archive.sha256 === "string" ? archive.sha256 : null,
|
|
441
|
+
heapMiB: typeof report.heapBytes === "number" ? report.heapBytes / 1048576 : null,
|
|
442
|
+
sdk: typeof report.sdk === "string" ? report.sdk : null,
|
|
443
|
+
files: files.slice(0, 256).map((entry) => ({
|
|
444
|
+
path: cleanLine(String(entry.path ?? ""), 256),
|
|
445
|
+
bytes: Number(entry.bytes ?? 0),
|
|
446
|
+
})),
|
|
447
|
+
mayDo: manifest ? authoritySummary(manifest) : [],
|
|
448
|
+
diagnostics: shapeDiagnostics(result.diagnostics).diagnostics,
|
|
449
|
+
}, result.ok
|
|
450
|
+
? `${String(report.id)} ${String(report.version)}: ${files.length} files, ${String(archive.bytes)} bytes.`
|
|
451
|
+
: "The package is refused.", { data: true, redactor });
|
|
452
|
+
}));
|
|
453
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Helpers shared by the tools: results with structured content and a text
|
|
2
|
+
// copy, errors the model can act on, the confinement of each request, and
|
|
3
|
+
// project data marked as data.
|
|
4
|
+
import { CliError } from "../cli.js";
|
|
5
|
+
import { lstat } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { ConfinementError } from "../confine.js";
|
|
8
|
+
import { NpmError } from "../npm.js";
|
|
9
|
+
import { RunError } from "../run.js";
|
|
10
|
+
import { SetupError } from "../session.js";
|
|
11
|
+
import { bound, DATA_NOTICE } from "../text.js";
|
|
12
|
+
/** Most characters a text result carries; Claude Code moves larger results to a file. */
|
|
13
|
+
export const MAX_RESULT_CHARS = 40_000;
|
|
14
|
+
/**
|
|
15
|
+
* A successful result: a one-line summary for people, then the structured
|
|
16
|
+
* content as JSON (clients that ignore `structuredContent` still get it).
|
|
17
|
+
* Results that carry project content are marked as data.
|
|
18
|
+
*/
|
|
19
|
+
export function ok(structured, summary, options = {}) {
|
|
20
|
+
const redact = (text) => (options.redactor ? options.redactor.text(text) : text);
|
|
21
|
+
const structuredContent = options.redactor
|
|
22
|
+
? redactDeep(structured, options.redactor)
|
|
23
|
+
: structured;
|
|
24
|
+
const json = JSON.stringify(structuredContent);
|
|
25
|
+
const body = options.data
|
|
26
|
+
? `${DATA_NOTICE}\n<data>\n${json.replaceAll("</data>", "<\\/data>")}\n</data>`
|
|
27
|
+
: json;
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{ type: "text", text: bound(`${redact(summary)}\n\n${body}`, MAX_RESULT_CHARS) },
|
|
31
|
+
...(options.extra ?? []),
|
|
32
|
+
],
|
|
33
|
+
structuredContent,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Replaces the user's paths in every string of a JSON value. */
|
|
37
|
+
function redactDeep(value, redactor) {
|
|
38
|
+
if (typeof value === "string")
|
|
39
|
+
return redactor.text(value);
|
|
40
|
+
if (Array.isArray(value))
|
|
41
|
+
return value.map((item) => redactDeep(item, redactor));
|
|
42
|
+
if (typeof value === "object" && value !== null) {
|
|
43
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactDeep(item, redactor)]));
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
/** A failure the model can correct: what went wrong and what to do. */
|
|
48
|
+
export function fail(message, redactor) {
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: bound(redactor ? redactor.text(message) : message, 4000) }],
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Turns the expected errors into tool failures; anything else is rethrown. */
|
|
55
|
+
export function failure(error, redactor) {
|
|
56
|
+
if (error instanceof ConfinementError ||
|
|
57
|
+
error instanceof SetupError ||
|
|
58
|
+
error instanceof NpmError ||
|
|
59
|
+
error instanceof RunError) {
|
|
60
|
+
return fail(error.message, redactor);
|
|
61
|
+
}
|
|
62
|
+
if (error instanceof CliError) {
|
|
63
|
+
const detail = error.stderr
|
|
64
|
+
.split("\n")
|
|
65
|
+
.filter((line) => line.trim() !== "")
|
|
66
|
+
.slice(0, 8)
|
|
67
|
+
.join("\n");
|
|
68
|
+
return fail(`${error.message}${detail ? `\n${DATA_NOTICE}\n${detail}` : ""}`, redactor);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
export const TOOLS_MISSING = "The creator tools (the widget CLI and its test runtime) are not installed on this computer yet: run the setup tool first. It downloads them once (about 15 MB) and checks them.";
|
|
73
|
+
/**
|
|
74
|
+
* Runs `handler` with the project folders of this request. When the
|
|
75
|
+
* client's roots are needed and not known yet, returns the input request
|
|
76
|
+
* that asks for them; the client then retries the call.
|
|
77
|
+
*/
|
|
78
|
+
export async function withRoots(env, ctx, handler) {
|
|
79
|
+
const answer = await env.session.roots(ctx, env.server);
|
|
80
|
+
if ("input" in answer)
|
|
81
|
+
return answer.input;
|
|
82
|
+
if ("error" in answer)
|
|
83
|
+
return fail(answer.error);
|
|
84
|
+
const redactor = env.session.redactor(answer.confinement);
|
|
85
|
+
try {
|
|
86
|
+
return await handler(answer.confinement, redactor);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return failure(error, redactor);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Sends a progress notification when the client asked for them. */
|
|
93
|
+
export function progress(ctx) {
|
|
94
|
+
const token = ctx.mcpReq._meta
|
|
95
|
+
?.progressToken;
|
|
96
|
+
if (token === undefined)
|
|
97
|
+
return undefined;
|
|
98
|
+
return (done, total, message) => {
|
|
99
|
+
ctx.mcpReq
|
|
100
|
+
.notify({
|
|
101
|
+
method: "notifications/progress",
|
|
102
|
+
params: { progressToken: token, progress: done, total, ...(message ? { message } : {}) },
|
|
103
|
+
})
|
|
104
|
+
.catch(() => undefined);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** Annotations, spelled out for every tool (no default is relied on). */
|
|
108
|
+
export const READ_ONLY = {
|
|
109
|
+
readOnlyHint: true,
|
|
110
|
+
destructiveHint: false,
|
|
111
|
+
idempotentHint: true,
|
|
112
|
+
openWorldHint: false,
|
|
113
|
+
};
|
|
114
|
+
/** A widget folder inside the project: it must hold a manifest.json. */
|
|
115
|
+
export async function widgetDirectory(confinement, directory) {
|
|
116
|
+
const target = await confinement.resolve(directory, "directory");
|
|
117
|
+
const manifest = await lstat(join(target, "manifest.json")).catch(() => undefined);
|
|
118
|
+
if (!manifest?.isFile()) {
|
|
119
|
+
throw new ConfinementError(`${directory} is not a widget folder: it has no manifest.json.`);
|
|
120
|
+
}
|
|
121
|
+
return target;
|
|
122
|
+
}
|