cli-jaw 0.1.0
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.ko.md +411 -0
- package/README.md +416 -0
- package/README.zh-CN.md +411 -0
- package/dist/bin/cli-jaw.js +108 -0
- package/dist/bin/cli-jaw.js.map +1 -0
- package/dist/bin/commands/browser.js +241 -0
- package/dist/bin/commands/browser.js.map +1 -0
- package/dist/bin/commands/chat.js +878 -0
- package/dist/bin/commands/chat.js.map +1 -0
- package/dist/bin/commands/doctor.js +152 -0
- package/dist/bin/commands/doctor.js.map +1 -0
- package/dist/bin/commands/employee.js +70 -0
- package/dist/bin/commands/employee.js.map +1 -0
- package/dist/bin/commands/init.js +110 -0
- package/dist/bin/commands/init.js.map +1 -0
- package/dist/bin/commands/mcp.js +219 -0
- package/dist/bin/commands/mcp.js.map +1 -0
- package/dist/bin/commands/memory.js +105 -0
- package/dist/bin/commands/memory.js.map +1 -0
- package/dist/bin/commands/reset.js +109 -0
- package/dist/bin/commands/reset.js.map +1 -0
- package/dist/bin/commands/serve.js +75 -0
- package/dist/bin/commands/serve.js.map +1 -0
- package/dist/bin/commands/skill.js +232 -0
- package/dist/bin/commands/skill.js.map +1 -0
- package/dist/bin/commands/status.js +51 -0
- package/dist/bin/commands/status.js.map +1 -0
- package/dist/bin/postinstall.js +218 -0
- package/dist/bin/postinstall.js.map +1 -0
- package/dist/lib/mcp-sync.js +639 -0
- package/dist/lib/mcp-sync.js.map +1 -0
- package/dist/lib/quota-copilot.js +62 -0
- package/dist/lib/quota-copilot.js.map +1 -0
- package/dist/lib/upload.js +72 -0
- package/dist/lib/upload.js.map +1 -0
- package/dist/server.js +832 -0
- package/dist/server.js.map +1 -0
- package/dist/src/agent/args.js +66 -0
- package/dist/src/agent/args.js.map +1 -0
- package/dist/src/agent/events.js +328 -0
- package/dist/src/agent/events.js.map +1 -0
- package/dist/src/agent/spawn.js +646 -0
- package/dist/src/agent/spawn.js.map +1 -0
- package/dist/src/browser/actions.js +168 -0
- package/dist/src/browser/actions.js.map +1 -0
- package/dist/src/browser/connection.js +79 -0
- package/dist/src/browser/connection.js.map +1 -0
- package/dist/src/browser/index.js +4 -0
- package/dist/src/browser/index.js.map +1 -0
- package/dist/src/browser/vision.js +128 -0
- package/dist/src/browser/vision.js.map +1 -0
- package/dist/src/cli/acp-client.js +298 -0
- package/dist/src/cli/acp-client.js.map +1 -0
- package/dist/src/cli/commands.js +267 -0
- package/dist/src/cli/commands.js.map +1 -0
- package/dist/src/cli/handlers.js +405 -0
- package/dist/src/cli/handlers.js.map +1 -0
- package/dist/src/cli/registry.js +87 -0
- package/dist/src/cli/registry.js.map +1 -0
- package/dist/src/command-contract/catalog.js +36 -0
- package/dist/src/command-contract/catalog.js.map +1 -0
- package/dist/src/command-contract/help-renderer.js +39 -0
- package/dist/src/command-contract/help-renderer.js.map +1 -0
- package/dist/src/command-contract/policy.js +34 -0
- package/dist/src/command-contract/policy.js.map +1 -0
- package/dist/src/core/bus.js +17 -0
- package/dist/src/core/bus.js.map +1 -0
- package/dist/src/core/config.js +198 -0
- package/dist/src/core/config.js.map +1 -0
- package/dist/src/core/db.js +97 -0
- package/dist/src/core/db.js.map +1 -0
- package/dist/src/core/i18n.js +86 -0
- package/dist/src/core/i18n.js.map +1 -0
- package/dist/src/core/logger.js +14 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/settings-merge.js +40 -0
- package/dist/src/core/settings-merge.js.map +1 -0
- package/dist/src/http/async-handler.js +6 -0
- package/dist/src/http/async-handler.js.map +1 -0
- package/dist/src/http/error-middleware.js +24 -0
- package/dist/src/http/error-middleware.js.map +1 -0
- package/dist/src/http/response.js +16 -0
- package/dist/src/http/response.js.map +1 -0
- package/dist/src/memory/heartbeat.js +106 -0
- package/dist/src/memory/heartbeat.js.map +1 -0
- package/dist/src/memory/memory.js +119 -0
- package/dist/src/memory/memory.js.map +1 -0
- package/dist/src/memory/worklog.js +154 -0
- package/dist/src/memory/worklog.js.map +1 -0
- package/dist/src/orchestrator/distribute.js +310 -0
- package/dist/src/orchestrator/distribute.js.map +1 -0
- package/dist/src/orchestrator/parser.js +118 -0
- package/dist/src/orchestrator/parser.js.map +1 -0
- package/dist/src/orchestrator/pipeline.js +343 -0
- package/dist/src/orchestrator/pipeline.js.map +1 -0
- package/dist/src/prompt/builder.js +531 -0
- package/dist/src/prompt/builder.js.map +1 -0
- package/dist/src/routes/browser.js +126 -0
- package/dist/src/routes/browser.js.map +1 -0
- package/dist/src/routes/quota.js +94 -0
- package/dist/src/routes/quota.js.map +1 -0
- package/dist/src/security/decode.js +23 -0
- package/dist/src/security/decode.js.map +1 -0
- package/dist/src/security/path-guards.js +62 -0
- package/dist/src/security/path-guards.js.map +1 -0
- package/dist/src/telegram/bot.js +469 -0
- package/dist/src/telegram/bot.js.map +1 -0
- package/dist/src/telegram/forwarder.js +93 -0
- package/dist/src/telegram/forwarder.js.map +1 -0
- package/package.json +80 -0
- package/public/css/chat.css +571 -0
- package/public/css/layout.css +350 -0
- package/public/css/markdown.css +270 -0
- package/public/css/modals.css +172 -0
- package/public/css/sidebar.css +225 -0
- package/public/css/variables.css +142 -0
- package/public/index.html +470 -0
- package/public/js/api.js +55 -0
- package/public/js/constants.js +119 -0
- package/public/js/features/appname.js +43 -0
- package/public/js/features/chat.js +242 -0
- package/public/js/features/employees.js +120 -0
- package/public/js/features/heartbeat.js +80 -0
- package/public/js/features/i18n.js +125 -0
- package/public/js/features/memory.js +85 -0
- package/public/js/features/settings.js +512 -0
- package/public/js/features/sidebar.js +88 -0
- package/public/js/features/skills.js +68 -0
- package/public/js/features/slash-commands.js +231 -0
- package/public/js/features/theme.js +40 -0
- package/public/js/locale.js +23 -0
- package/public/js/main.js +281 -0
- package/public/js/render.js +294 -0
- package/public/js/state.js +16 -0
- package/public/js/ui.js +172 -0
- package/public/js/ws.js +76 -0
- package/public/locales/en.json +180 -0
- package/public/locales/ko.json +180 -0
- package/public/theme-test.html +545 -0
- package/skills_ref/1password/SKILL.md +70 -0
- package/skills_ref/agents-sdk/SKILL.md +155 -0
- package/skills_ref/agents-sdk/references/callable.md +92 -0
- package/skills_ref/agents-sdk/references/codemode.md +207 -0
- package/skills_ref/agents-sdk/references/email.md +146 -0
- package/skills_ref/agents-sdk/references/mcp.md +154 -0
- package/skills_ref/agents-sdk/references/state-scheduling.md +164 -0
- package/skills_ref/agents-sdk/references/streaming-chat.md +178 -0
- package/skills_ref/agents-sdk/references/workflows.md +132 -0
- package/skills_ref/algorithmic-art/LICENSE.txt +202 -0
- package/skills_ref/algorithmic-art/SKILL.md +405 -0
- package/skills_ref/algorithmic-art/templates/generator_template.js +223 -0
- package/skills_ref/algorithmic-art/templates/viewer.html +599 -0
- package/skills_ref/apple-notes/SKILL.md +77 -0
- package/skills_ref/apple-reminders/SKILL.md +118 -0
- package/skills_ref/atlas/SKILL.md +99 -0
- package/skills_ref/brainstorming/SKILL.md +96 -0
- package/skills_ref/browser/SKILL.md +179 -0
- package/skills_ref/canvas-design/LICENSE.txt +202 -0
- package/skills_ref/canvas-design/SKILL.md +130 -0
- package/skills_ref/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
- package/skills_ref/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
- package/skills_ref/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
- package/skills_ref/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
- package/skills_ref/changelog-generator/SKILL.md +104 -0
- package/skills_ref/cloudflare-deploy/SKILL.md +207 -0
- package/skills_ref/codebase-orientation/SKILL.md +29 -0
- package/skills_ref/config-file-explainer/SKILL.md +26 -0
- package/skills_ref/context-compression/SKILL.md +265 -0
- package/skills_ref/context-compression/references/evaluation-framework.md +213 -0
- package/skills_ref/context-compression/scripts/compression_evaluator.py +658 -0
- package/skills_ref/data-structure-chooser/SKILL.md +26 -0
- package/skills_ref/debugging-checklist/SKILL.md +26 -0
- package/skills_ref/debugging-helpers/CREATION-LOG.md +119 -0
- package/skills_ref/debugging-helpers/SKILL.md +296 -0
- package/skills_ref/debugging-helpers/condition-based-waiting-example.ts +158 -0
- package/skills_ref/debugging-helpers/condition-based-waiting.md +115 -0
- package/skills_ref/debugging-helpers/defense-in-depth.md +122 -0
- package/skills_ref/debugging-helpers/find-polluter.sh +63 -0
- package/skills_ref/debugging-helpers/root-cause-tracing.md +169 -0
- package/skills_ref/debugging-helpers/test-academic.md +14 -0
- package/skills_ref/debugging-helpers/test-pressure-1.md +58 -0
- package/skills_ref/debugging-helpers/test-pressure-2.md +68 -0
- package/skills_ref/debugging-helpers/test-pressure-3.md +69 -0
- package/skills_ref/deep-research/.env.example +7 -0
- package/skills_ref/deep-research/README.md +246 -0
- package/skills_ref/deep-research/SKILL.md +106 -0
- package/skills_ref/deep-research/requirements.txt +2 -0
- package/skills_ref/deep-research/scripts/research.py +692 -0
- package/skills_ref/dependency-install-helper/SKILL.md +26 -0
- package/skills_ref/dev/SKILL.md +65 -0
- package/skills_ref/dev-backend/SKILL.md +61 -0
- package/skills_ref/dev-data/SKILL.md +76 -0
- package/skills_ref/dev-frontend/LICENSE.txt +177 -0
- package/skills_ref/dev-frontend/SKILL.md +42 -0
- package/skills_ref/dev-testing/LICENSE.txt +202 -0
- package/skills_ref/dev-testing/SKILL.md +96 -0
- package/skills_ref/dev-testing/examples/console_logging.py +35 -0
- package/skills_ref/dev-testing/examples/element_discovery.py +40 -0
- package/skills_ref/dev-testing/examples/static_html_automation.py +33 -0
- package/skills_ref/dev-testing/scripts/with_server.py +106 -0
- package/skills_ref/develop-web-game/SKILL.md +149 -0
- package/skills_ref/differential-review/.claude-plugin/plugin.json +10 -0
- package/skills_ref/differential-review/README.md +109 -0
- package/skills_ref/differential-review/commands/diff-review.md +21 -0
- package/skills_ref/differential-review/skills/differential-review/SKILL.md +220 -0
- package/skills_ref/differential-review/skills/differential-review/adversarial.md +203 -0
- package/skills_ref/differential-review/skills/differential-review/methodology.md +234 -0
- package/skills_ref/differential-review/skills/differential-review/patterns.md +300 -0
- package/skills_ref/differential-review/skills/differential-review/reporting.md +369 -0
- package/skills_ref/dispatching-parallel-agents/SKILL.md +180 -0
- package/skills_ref/doc-coauthoring/SKILL.md +375 -0
- package/skills_ref/docx/LICENSE.txt +30 -0
- package/skills_ref/docx/SKILL.md +481 -0
- package/skills_ref/docx/scripts/__init__.py +1 -0
- package/skills_ref/docx/scripts/accept_changes.py +135 -0
- package/skills_ref/docx/scripts/comment.py +318 -0
- package/skills_ref/docx/scripts/office/helpers/__init__.py +0 -0
- package/skills_ref/docx/scripts/office/helpers/merge_runs.py +199 -0
- package/skills_ref/docx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/skills_ref/docx/scripts/office/pack.py +159 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills_ref/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills_ref/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills_ref/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills_ref/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills_ref/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills_ref/docx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills_ref/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills_ref/docx/scripts/office/soffice.py +183 -0
- package/skills_ref/docx/scripts/office/unpack.py +132 -0
- package/skills_ref/docx/scripts/office/validate.py +111 -0
- package/skills_ref/docx/scripts/office/validators/__init__.py +15 -0
- package/skills_ref/docx/scripts/office/validators/base.py +847 -0
- package/skills_ref/docx/scripts/office/validators/docx.py +446 -0
- package/skills_ref/docx/scripts/office/validators/pptx.py +275 -0
- package/skills_ref/docx/scripts/office/validators/redlining.py +247 -0
- package/skills_ref/docx/scripts/templates/comments.xml +3 -0
- package/skills_ref/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills_ref/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills_ref/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills_ref/docx/scripts/templates/people.xml +3 -0
- package/skills_ref/durable-objects/SKILL.md +186 -0
- package/skills_ref/durable-objects/references/rules.md +286 -0
- package/skills_ref/durable-objects/references/testing.md +264 -0
- package/skills_ref/durable-objects/references/workers.md +346 -0
- package/skills_ref/email-draft-polish/SKILL.md +24 -0
- package/skills_ref/error-message-explainer/SKILL.md +27 -0
- package/skills_ref/fal-image-edit/SKILL.md +249 -0
- package/skills_ref/fal-image-edit/scripts/edit-image.sh +199 -0
- package/skills_ref/figma-implement-design/SKILL.md +264 -0
- package/skills_ref/git-worktrees/SKILL.md +218 -0
- package/skills_ref/github/SKILL.md +210 -0
- package/skills_ref/gog/SKILL.md +116 -0
- package/skills_ref/goplaces/SKILL.md +52 -0
- package/skills_ref/himalaya/SKILL.md +257 -0
- package/skills_ref/hugging-face-cli/SKILL.md +186 -0
- package/skills_ref/hugging-face-cli/references/commands.md +954 -0
- package/skills_ref/hugging-face-cli/references/examples.md +374 -0
- package/skills_ref/hugging-face-evaluation/SKILL.md +651 -0
- package/skills_ref/hugging-face-evaluation/examples/.env.example +7 -0
- package/skills_ref/hugging-face-evaluation/examples/USAGE_EXAMPLES.md +382 -0
- package/skills_ref/hugging-face-evaluation/examples/artificial_analysis_to_hub.py +141 -0
- package/skills_ref/hugging-face-evaluation/examples/example_readme_tables.md +135 -0
- package/skills_ref/hugging-face-evaluation/examples/metric_mapping.json +50 -0
- package/skills_ref/hugging-face-evaluation/requirements.txt +20 -0
- package/skills_ref/hugging-face-evaluation/scripts/evaluation_manager.py +1374 -0
- package/skills_ref/hugging-face-evaluation/scripts/inspect_eval_uv.py +104 -0
- package/skills_ref/hugging-face-evaluation/scripts/inspect_vllm_uv.py +317 -0
- package/skills_ref/hugging-face-evaluation/scripts/lighteval_vllm_uv.py +303 -0
- package/skills_ref/hugging-face-evaluation/scripts/run_eval_job.py +98 -0
- package/skills_ref/hugging-face-evaluation/scripts/run_vllm_eval_job.py +331 -0
- package/skills_ref/hugging-face-evaluation/scripts/test_extraction.py +206 -0
- package/skills_ref/hugging-face-model-trainer/SKILL.md +718 -0
- package/skills_ref/hugging-face-model-trainer/references/gguf_conversion.md +296 -0
- package/skills_ref/hugging-face-model-trainer/references/hardware_guide.md +283 -0
- package/skills_ref/hugging-face-model-trainer/references/hub_saving.md +364 -0
- package/skills_ref/hugging-face-model-trainer/references/reliability_principles.md +371 -0
- package/skills_ref/hugging-face-model-trainer/references/trackio_guide.md +189 -0
- package/skills_ref/hugging-face-model-trainer/references/training_methods.md +150 -0
- package/skills_ref/hugging-face-model-trainer/references/training_patterns.md +203 -0
- package/skills_ref/hugging-face-model-trainer/references/troubleshooting.md +282 -0
- package/skills_ref/hugging-face-model-trainer/references/unsloth.md +313 -0
- package/skills_ref/hugging-face-model-trainer/scripts/convert_to_gguf.py +424 -0
- package/skills_ref/hugging-face-model-trainer/scripts/dataset_inspector.py +417 -0
- package/skills_ref/hugging-face-model-trainer/scripts/estimate_cost.py +150 -0
- package/skills_ref/hugging-face-model-trainer/scripts/train_dpo_example.py +106 -0
- package/skills_ref/hugging-face-model-trainer/scripts/train_grpo_example.py +89 -0
- package/skills_ref/hugging-face-model-trainer/scripts/train_sft_example.py +122 -0
- package/skills_ref/hugging-face-model-trainer/scripts/unsloth_sft_example.py +512 -0
- package/skills_ref/imagegen/SKILL.md +174 -0
- package/skills_ref/insecure-defaults/.claude-plugin/plugin.json +10 -0
- package/skills_ref/insecure-defaults/README.md +45 -0
- package/skills_ref/insecure-defaults/skills/insecure-defaults/SKILL.md +117 -0
- package/skills_ref/insecure-defaults/skills/insecure-defaults/references/examples.md +409 -0
- package/skills_ref/jupyter-notebook/SKILL.md +107 -0
- package/skills_ref/linear/SKILL.md +87 -0
- package/skills_ref/linter-fix-guide/SKILL.md +27 -0
- package/skills_ref/log-summarizer/SKILL.md +27 -0
- package/skills_ref/mcp-builder/LICENSE.txt +202 -0
- package/skills_ref/mcp-builder/SKILL.md +236 -0
- package/skills_ref/mcp-builder/reference/evaluation.md +602 -0
- package/skills_ref/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/skills_ref/mcp-builder/reference/node_mcp_server.md +970 -0
- package/skills_ref/mcp-builder/reference/python_mcp_server.md +719 -0
- package/skills_ref/mcp-builder/scripts/connections.py +151 -0
- package/skills_ref/mcp-builder/scripts/evaluation.py +373 -0
- package/skills_ref/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills_ref/mcp-builder/scripts/requirements.txt +2 -0
- package/skills_ref/memory/SKILL.md +129 -0
- package/skills_ref/modern-python/.claude-plugin/plugin.json +10 -0
- package/skills_ref/modern-python/README.md +66 -0
- package/skills_ref/modern-python/hooks/hooks.json +16 -0
- package/skills_ref/modern-python/hooks/setup-shims.bats +70 -0
- package/skills_ref/modern-python/hooks/setup-shims.sh +24 -0
- package/skills_ref/modern-python/hooks/shims/pip +27 -0
- package/skills_ref/modern-python/hooks/shims/pip-shim.bats +45 -0
- package/skills_ref/modern-python/hooks/shims/pip3 +27 -0
- package/skills_ref/modern-python/hooks/shims/pipx +41 -0
- package/skills_ref/modern-python/hooks/shims/pipx-shim.bats +64 -0
- package/skills_ref/modern-python/hooks/shims/python +26 -0
- package/skills_ref/modern-python/hooks/shims/python-shim.bats +53 -0
- package/skills_ref/modern-python/hooks/shims/python3 +26 -0
- package/skills_ref/modern-python/hooks/shims/uv +27 -0
- package/skills_ref/modern-python/hooks/shims/uv-shim.bats +47 -0
- package/skills_ref/modern-python/skills/modern-python/SKILL.md +333 -0
- package/skills_ref/modern-python/skills/modern-python/references/dependabot.md +43 -0
- package/skills_ref/modern-python/skills/modern-python/references/migration-checklist.md +141 -0
- package/skills_ref/modern-python/skills/modern-python/references/pep723-scripts.md +259 -0
- package/skills_ref/modern-python/skills/modern-python/references/prek.md +211 -0
- package/skills_ref/modern-python/skills/modern-python/references/pyproject.md +254 -0
- package/skills_ref/modern-python/skills/modern-python/references/ruff-config.md +240 -0
- package/skills_ref/modern-python/skills/modern-python/references/security-setup.md +255 -0
- package/skills_ref/modern-python/skills/modern-python/references/testing.md +284 -0
- package/skills_ref/modern-python/skills/modern-python/references/uv-commands.md +200 -0
- package/skills_ref/modern-python/skills/modern-python/templates/dependabot.yml +36 -0
- package/skills_ref/modern-python/skills/modern-python/templates/pre-commit-config.yaml +66 -0
- package/skills_ref/nano-banana-pro/SKILL.md +58 -0
- package/skills_ref/netlify-deploy/SKILL.md +233 -0
- package/skills_ref/notion/SKILL.md +304 -0
- package/skills_ref/notion-knowledge-capture/SKILL.md +56 -0
- package/skills_ref/notion-meeting-intelligence/SKILL.md +60 -0
- package/skills_ref/notion-research-documentation/SKILL.md +59 -0
- package/skills_ref/notion-spec-to-implementation/SKILL.md +58 -0
- package/skills_ref/obsidian/SKILL.md +81 -0
- package/skills_ref/openai-docs/SKILL.md +56 -0
- package/skills_ref/openhue/SKILL.md +112 -0
- package/skills_ref/pdf/SKILL.md +69 -0
- package/skills_ref/postgres/README.md +77 -0
- package/skills_ref/postgres/SKILL.md +129 -0
- package/skills_ref/postgres/connections.example.json +34 -0
- package/skills_ref/postgres/requirements.txt +1 -0
- package/skills_ref/postgres/scripts/query.py +262 -0
- package/skills_ref/pptx/LICENSE.txt +30 -0
- package/skills_ref/pptx/SKILL.md +232 -0
- package/skills_ref/pptx/editing.md +205 -0
- package/skills_ref/pptx/pptxgenjs.md +420 -0
- package/skills_ref/pptx/scripts/__init__.py +0 -0
- package/skills_ref/pptx/scripts/add_slide.py +195 -0
- package/skills_ref/pptx/scripts/clean.py +286 -0
- package/skills_ref/pptx/scripts/office/helpers/__init__.py +0 -0
- package/skills_ref/pptx/scripts/office/helpers/merge_runs.py +199 -0
- package/skills_ref/pptx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/skills_ref/pptx/scripts/office/pack.py +159 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills_ref/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills_ref/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills_ref/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills_ref/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills_ref/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills_ref/pptx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills_ref/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills_ref/pptx/scripts/office/soffice.py +183 -0
- package/skills_ref/pptx/scripts/office/unpack.py +132 -0
- package/skills_ref/pptx/scripts/office/validate.py +111 -0
- package/skills_ref/pptx/scripts/office/validators/__init__.py +15 -0
- package/skills_ref/pptx/scripts/office/validators/base.py +847 -0
- package/skills_ref/pptx/scripts/office/validators/docx.py +446 -0
- package/skills_ref/pptx/scripts/office/validators/pptx.py +275 -0
- package/skills_ref/pptx/scripts/office/validators/redlining.py +247 -0
- package/skills_ref/pptx/scripts/thumbnail.py +289 -0
- package/skills_ref/property-based-testing/.claude-plugin/plugin.json +9 -0
- package/skills_ref/property-based-testing/README.md +47 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/README.md +88 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/SKILL.md +123 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/design.md +191 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/generating.md +204 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/interpreting-failures.md +239 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/libraries.md +130 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/refactoring.md +181 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/reviewing.md +209 -0
- package/skills_ref/property-based-testing/skills/property-based-testing/references/strategies.md +124 -0
- package/skills_ref/react-best-practices/AGENTS.md +2934 -0
- package/skills_ref/react-best-practices/README.md +123 -0
- package/skills_ref/react-best-practices/SKILL.md +136 -0
- package/skills_ref/react-best-practices/metadata.json +15 -0
- package/skills_ref/react-best-practices/rules/_sections.md +46 -0
- package/skills_ref/react-best-practices/rules/_template.md +28 -0
- package/skills_ref/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/skills_ref/react-best-practices/rules/advanced-init-once.md +42 -0
- package/skills_ref/react-best-practices/rules/advanced-use-latest.md +39 -0
- package/skills_ref/react-best-practices/rules/async-api-routes.md +38 -0
- package/skills_ref/react-best-practices/rules/async-defer-await.md +80 -0
- package/skills_ref/react-best-practices/rules/async-dependencies.md +51 -0
- package/skills_ref/react-best-practices/rules/async-parallel.md +28 -0
- package/skills_ref/react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/skills_ref/react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/skills_ref/react-best-practices/rules/bundle-conditional.md +31 -0
- package/skills_ref/react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/skills_ref/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/skills_ref/react-best-practices/rules/bundle-preload.md +50 -0
- package/skills_ref/react-best-practices/rules/client-event-listeners.md +74 -0
- package/skills_ref/react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/skills_ref/react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/skills_ref/react-best-practices/rules/client-swr-dedup.md +56 -0
- package/skills_ref/react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/skills_ref/react-best-practices/rules/js-cache-function-results.md +80 -0
- package/skills_ref/react-best-practices/rules/js-cache-property-access.md +28 -0
- package/skills_ref/react-best-practices/rules/js-cache-storage.md +70 -0
- package/skills_ref/react-best-practices/rules/js-combine-iterations.md +32 -0
- package/skills_ref/react-best-practices/rules/js-early-exit.md +50 -0
- package/skills_ref/react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/skills_ref/react-best-practices/rules/js-index-maps.md +37 -0
- package/skills_ref/react-best-practices/rules/js-length-check-first.md +49 -0
- package/skills_ref/react-best-practices/rules/js-min-max-loop.md +82 -0
- package/skills_ref/react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/skills_ref/react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/skills_ref/react-best-practices/rules/rendering-activity.md +26 -0
- package/skills_ref/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/skills_ref/react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/skills_ref/react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/skills_ref/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/skills_ref/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/skills_ref/react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/skills_ref/react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/skills_ref/react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/skills_ref/react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/skills_ref/react-best-practices/rules/rerender-dependencies.md +45 -0
- package/skills_ref/react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/skills_ref/react-best-practices/rules/rerender-derived-state.md +29 -0
- package/skills_ref/react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/skills_ref/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/skills_ref/react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/skills_ref/react-best-practices/rules/rerender-memo.md +44 -0
- package/skills_ref/react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/skills_ref/react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/skills_ref/react-best-practices/rules/rerender-transitions.md +40 -0
- package/skills_ref/react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/skills_ref/react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/skills_ref/react-best-practices/rules/server-auth-actions.md +96 -0
- package/skills_ref/react-best-practices/rules/server-cache-lru.md +41 -0
- package/skills_ref/react-best-practices/rules/server-cache-react.md +76 -0
- package/skills_ref/react-best-practices/rules/server-dedup-props.md +65 -0
- package/skills_ref/react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/skills_ref/react-best-practices/rules/server-serialization.md +38 -0
- package/skills_ref/receiving-code-review/SKILL.md +213 -0
- package/skills_ref/registry.json +1493 -0
- package/skills_ref/render-deploy/SKILL.md +462 -0
- package/skills_ref/requesting-code-review/SKILL.md +105 -0
- package/skills_ref/requesting-code-review/code-reviewer.md +146 -0
- package/skills_ref/screen-capture/SKILL.md +162 -0
- package/skills_ref/security-best-practices/LICENSE.txt +201 -0
- package/skills_ref/security-best-practices/SKILL.md +86 -0
- package/skills_ref/security-best-practices/agents/openai.yaml +4 -0
- package/skills_ref/security-best-practices/references/golang-general-backend-security.md +826 -0
- package/skills_ref/security-best-practices/references/javascript-express-web-server-security.md +1158 -0
- package/skills_ref/security-best-practices/references/javascript-general-web-frontend-security.md +747 -0
- package/skills_ref/security-best-practices/references/javascript-jquery-web-frontend-security.md +678 -0
- package/skills_ref/security-best-practices/references/javascript-typescript-nextjs-web-server-security.md +1144 -0
- package/skills_ref/security-best-practices/references/javascript-typescript-react-web-frontend-security.md +990 -0
- package/skills_ref/security-best-practices/references/javascript-typescript-vue-web-frontend-security.md +791 -0
- package/skills_ref/security-best-practices/references/python-django-web-server-security.md +882 -0
- package/skills_ref/security-best-practices/references/python-fastapi-web-server-security.md +1036 -0
- package/skills_ref/security-best-practices/references/python-flask-web-server-security.md +705 -0
- package/skills_ref/security-ownership-map/LICENSE.txt +201 -0
- package/skills_ref/security-ownership-map/SKILL.md +206 -0
- package/skills_ref/security-ownership-map/agents/openai.yaml +4 -0
- package/skills_ref/security-ownership-map/references/neo4j-import.md +60 -0
- package/skills_ref/security-ownership-map/scripts/build_ownership_map.py +956 -0
- package/skills_ref/security-ownership-map/scripts/community_maintainers.py +544 -0
- package/skills_ref/security-ownership-map/scripts/query_ownership.py +483 -0
- package/skills_ref/security-ownership-map/scripts/run_ownership_map.py +200 -0
- package/skills_ref/security-threat-model/LICENSE.txt +201 -0
- package/skills_ref/security-threat-model/SKILL.md +81 -0
- package/skills_ref/security-threat-model/agents/openai.yaml +4 -0
- package/skills_ref/security-threat-model/references/prompt-template.md +255 -0
- package/skills_ref/security-threat-model/references/security-controls-and-assets.md +32 -0
- package/skills_ref/sentry/SKILL.md +123 -0
- package/skills_ref/skill-creator/SKILL.md +372 -0
- package/skills_ref/sora/SKILL.md +153 -0
- package/skills_ref/speech/SKILL.md +144 -0
- package/skills_ref/spotify-player/SKILL.md +64 -0
- package/skills_ref/static-analysis/.claude-plugin/plugin.json +8 -0
- package/skills_ref/static-analysis/README.md +65 -0
- package/skills_ref/static-analysis/agents/semgrep-scanner.md +71 -0
- package/skills_ref/static-analysis/agents/semgrep-triager.md +107 -0
- package/skills_ref/static-analysis/skills/codeql/SKILL.md +119 -0
- package/skills_ref/static-analysis/skills/codeql/references/diagnostic-query-templates.md +339 -0
- package/skills_ref/static-analysis/skills/codeql/references/language-details.md +207 -0
- package/skills_ref/static-analysis/skills/codeql/references/performance-tuning.md +111 -0
- package/skills_ref/static-analysis/skills/codeql/references/ruleset-catalog.md +63 -0
- package/skills_ref/static-analysis/skills/codeql/references/threat-models.md +44 -0
- package/skills_ref/static-analysis/skills/codeql/workflows/build-database.md +669 -0
- package/skills_ref/static-analysis/skills/codeql/workflows/create-data-extensions.md +536 -0
- package/skills_ref/static-analysis/skills/codeql/workflows/run-analysis.md +436 -0
- package/skills_ref/static-analysis/skills/sarif-parsing/SKILL.md +479 -0
- package/skills_ref/static-analysis/skills/sarif-parsing/resources/jq-queries.md +162 -0
- package/skills_ref/static-analysis/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
- package/skills_ref/static-analysis/skills/semgrep/SKILL.md +431 -0
- package/skills_ref/static-analysis/skills/semgrep/references/rulesets.md +162 -0
- package/skills_ref/static-analysis/skills/semgrep/references/scanner-task-prompt.md +102 -0
- package/skills_ref/static-analysis/skills/semgrep/references/triage-task-prompt.md +122 -0
- package/skills_ref/static-analysis/skills/semgrep/scripts/merge_triaged_sarif.py +252 -0
- package/skills_ref/summarize/SKILL.md +87 -0
- package/skills_ref/tdd/SKILL.md +371 -0
- package/skills_ref/tdd/testing-anti-patterns.md +299 -0
- package/skills_ref/telegram-send/SKILL.md +99 -0
- package/skills_ref/terraform/README.md +105 -0
- package/skills_ref/terraform/code-generation/.claude-plugin/plugin.json +30 -0
- package/skills_ref/terraform/code-generation/skills/azure-verified-modules/SKILL.md +613 -0
- package/skills_ref/terraform/code-generation/skills/terraform-style-guide/SKILL.md +353 -0
- package/skills_ref/terraform/code-generation/skills/terraform-test/SKILL.md +1669 -0
- package/skills_ref/terraform/module-generation/.claude-plugin/plugin.json +30 -0
- package/skills_ref/terraform/module-generation/skills/refactor-module/SKILL.md +538 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/SKILL.md +468 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/references/api-monitoring.md +543 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/references/component-blocks.md +476 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/references/deployment-blocks.md +391 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/references/examples.md +1529 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/references/linked-stacks.md +187 -0
- package/skills_ref/terraform/module-generation/skills/terraform-stacks/references/troubleshooting.md +671 -0
- package/skills_ref/terraform/provider-development/.claude-plugin/plugin.json +13 -0
- package/skills_ref/terraform/provider-development/skills/new-terraform-provider/SKILL.md +25 -0
- package/skills_ref/terraform/provider-development/skills/new-terraform-provider/assets/main.go +40 -0
- package/skills_ref/terraform/provider-development/skills/provider-actions/SKILL.md +478 -0
- package/skills_ref/terraform/provider-development/skills/provider-resources/SKILL.md +599 -0
- package/skills_ref/terraform/provider-development/skills/run-acceptance-tests/SKILL.md +41 -0
- package/skills_ref/theme-factory/LICENSE.txt +202 -0
- package/skills_ref/theme-factory/SKILL.md +59 -0
- package/skills_ref/theme-factory/theme-showcase.pdf +0 -0
- package/skills_ref/theme-factory/themes/arctic-frost.md +19 -0
- package/skills_ref/theme-factory/themes/botanical-garden.md +19 -0
- package/skills_ref/theme-factory/themes/desert-rose.md +19 -0
- package/skills_ref/theme-factory/themes/forest-canopy.md +19 -0
- package/skills_ref/theme-factory/themes/golden-hour.md +19 -0
- package/skills_ref/theme-factory/themes/midnight-galaxy.md +19 -0
- package/skills_ref/theme-factory/themes/modern-minimalist.md +19 -0
- package/skills_ref/theme-factory/themes/ocean-depths.md +19 -0
- package/skills_ref/theme-factory/themes/sunset-boulevard.md +19 -0
- package/skills_ref/theme-factory/themes/tech-innovation.md +19 -0
- package/skills_ref/things-mac/SKILL.md +86 -0
- package/skills_ref/tmux/SKILL.md +153 -0
- package/skills_ref/transcribe/SKILL.md +81 -0
- package/skills_ref/trello/SKILL.md +95 -0
- package/skills_ref/tts/SKILL.md +99 -0
- package/skills_ref/vercel-deploy/SKILL.md +115 -0
- package/skills_ref/video-downloader/SKILL.md +99 -0
- package/skills_ref/video-downloader/scripts/download_video.py +145 -0
- package/skills_ref/video-frames/SKILL.md +46 -0
- package/skills_ref/vision-click/SKILL.md +128 -0
- package/skills_ref/weather/SKILL.md +112 -0
- package/skills_ref/web-artifacts-builder/LICENSE.txt +202 -0
- package/skills_ref/web-artifacts-builder/SKILL.md +74 -0
- package/skills_ref/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/skills_ref/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/skills_ref/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/skills_ref/web-perf/SKILL.md +193 -0
- package/skills_ref/web-routing/SKILL.md +26 -0
- package/skills_ref/whatsapp/SKILL.md +255 -0
- package/skills_ref/whatsapp/assets/agent-app-integration-example.json +35 -0
- package/skills_ref/whatsapp/assets/databases-example.json +11 -0
- package/skills_ref/whatsapp/assets/function-decide-route-interactive-buttons.json +6 -0
- package/skills_ref/whatsapp/assets/functions-example.json +5 -0
- package/skills_ref/whatsapp/assets/workflow-agent-simple.json +31 -0
- package/skills_ref/whatsapp/assets/workflow-api-template-wait-agent.json +59 -0
- package/skills_ref/whatsapp/assets/workflow-customer-support-intake-agent.json +56 -0
- package/skills_ref/whatsapp/assets/workflow-decision.json +83 -0
- package/skills_ref/whatsapp/assets/workflow-interactive-buttons-decide-ai.json +89 -0
- package/skills_ref/whatsapp/assets/workflow-interactive-buttons-decide-function.json +88 -0
- package/skills_ref/whatsapp/assets/workflow-linear.json +53 -0
- package/skills_ref/whatsapp/package.json +10 -0
- package/skills_ref/whatsapp/references/app-integrations.md +89 -0
- package/skills_ref/whatsapp/references/databases-reference.md +21 -0
- package/skills_ref/whatsapp/references/execution-context.md +42 -0
- package/skills_ref/whatsapp/references/function-contracts.md +55 -0
- package/skills_ref/whatsapp/references/functions-payloads.md +87 -0
- package/skills_ref/whatsapp/references/functions-reference.md +133 -0
- package/skills_ref/whatsapp/references/graph-contract.md +145 -0
- package/skills_ref/whatsapp/references/node-types.md +430 -0
- package/skills_ref/whatsapp/references/triggers.md +20 -0
- package/skills_ref/whatsapp/references/workflow-overview.md +22 -0
- package/skills_ref/whatsapp/references/workflow-reference.md +123 -0
- package/skills_ref/whatsapp/scripts/configure-prop.js +113 -0
- package/skills_ref/whatsapp/scripts/create-connect-token.js +38 -0
- package/skills_ref/whatsapp/scripts/create-function.js +64 -0
- package/skills_ref/whatsapp/scripts/create-integration.js +137 -0
- package/skills_ref/whatsapp/scripts/create-row.js +47 -0
- package/skills_ref/whatsapp/scripts/create-trigger.js +88 -0
- package/skills_ref/whatsapp/scripts/create-workflow.js +85 -0
- package/skills_ref/whatsapp/scripts/delete-integration.js +44 -0
- package/skills_ref/whatsapp/scripts/delete-row.js +49 -0
- package/skills_ref/whatsapp/scripts/delete-trigger.js +44 -0
- package/skills_ref/whatsapp/scripts/deploy-function.js +47 -0
- package/skills_ref/whatsapp/scripts/edit-graph.js +289 -0
- package/skills_ref/whatsapp/scripts/get-action-schema.js +44 -0
- package/skills_ref/whatsapp/scripts/get-context-value.js +80 -0
- package/skills_ref/whatsapp/scripts/get-execution-event.js +55 -0
- package/skills_ref/whatsapp/scripts/get-execution.js +44 -0
- package/skills_ref/whatsapp/scripts/get-function.js +43 -0
- package/skills_ref/whatsapp/scripts/get-graph.js +85 -0
- package/skills_ref/whatsapp/scripts/get-table.js +45 -0
- package/skills_ref/whatsapp/scripts/get-workflow.js +44 -0
- package/skills_ref/whatsapp/scripts/invoke-function.js +60 -0
- package/skills_ref/whatsapp/scripts/lib/databases/args.js +87 -0
- package/skills_ref/whatsapp/scripts/lib/databases/filters.js +30 -0
- package/skills_ref/whatsapp/scripts/lib/databases/kapso-api.js +70 -0
- package/skills_ref/whatsapp/scripts/lib/functions/args.js +55 -0
- package/skills_ref/whatsapp/scripts/lib/functions/kapso-api.js +70 -0
- package/skills_ref/whatsapp/scripts/lib/workflows/args.js +53 -0
- package/skills_ref/whatsapp/scripts/lib/workflows/kapso-api.js +123 -0
- package/skills_ref/whatsapp/scripts/lib/workflows/result.js +16 -0
- package/skills_ref/whatsapp/scripts/list-accounts.js +62 -0
- package/skills_ref/whatsapp/scripts/list-apps.js +42 -0
- package/skills_ref/whatsapp/scripts/list-execution-events.js +61 -0
- package/skills_ref/whatsapp/scripts/list-executions.js +53 -0
- package/skills_ref/whatsapp/scripts/list-function-invocations.js +53 -0
- package/skills_ref/whatsapp/scripts/list-functions.js +41 -0
- package/skills_ref/whatsapp/scripts/list-integrations.js +41 -0
- package/skills_ref/whatsapp/scripts/list-provider-models.js +48 -0
- package/skills_ref/whatsapp/scripts/list-tables.js +41 -0
- package/skills_ref/whatsapp/scripts/list-triggers.js +44 -0
- package/skills_ref/whatsapp/scripts/list-whatsapp-phone-numbers.js +56 -0
- package/skills_ref/whatsapp/scripts/list-workflows.js +44 -0
- package/skills_ref/whatsapp/scripts/openapi-explore.mjs +1273 -0
- package/skills_ref/whatsapp/scripts/query-rows.js +71 -0
- package/skills_ref/whatsapp/scripts/reload-props.js +110 -0
- package/skills_ref/whatsapp/scripts/resume-execution.js +75 -0
- package/skills_ref/whatsapp/scripts/search-actions.js +64 -0
- package/skills_ref/whatsapp/scripts/update-execution-status.js +51 -0
- package/skills_ref/whatsapp/scripts/update-function.js +65 -0
- package/skills_ref/whatsapp/scripts/update-graph.js +154 -0
- package/skills_ref/whatsapp/scripts/update-integration.js +82 -0
- package/skills_ref/whatsapp/scripts/update-row.js +51 -0
- package/skills_ref/whatsapp/scripts/update-trigger.js +60 -0
- package/skills_ref/whatsapp/scripts/update-workflow-settings.js +67 -0
- package/skills_ref/whatsapp/scripts/upsert-row.js +64 -0
- package/skills_ref/whatsapp/scripts/validate-graph.js +293 -0
- package/skills_ref/whatsapp/scripts/variables-delete.js +37 -0
- package/skills_ref/whatsapp/scripts/variables-list.js +55 -0
- package/skills_ref/whatsapp/scripts/variables-set.js +39 -0
- package/skills_ref/writing-plans/SKILL.md +116 -0
- package/skills_ref/xlsx/LICENSE.txt +30 -0
- package/skills_ref/xlsx/SKILL.md +292 -0
- package/skills_ref/xlsx/scripts/office/helpers/__init__.py +0 -0
- package/skills_ref/xlsx/scripts/office/helpers/merge_runs.py +199 -0
- package/skills_ref/xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/skills_ref/xlsx/scripts/office/pack.py +159 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills_ref/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills_ref/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills_ref/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills_ref/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills_ref/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills_ref/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills_ref/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills_ref/xlsx/scripts/office/soffice.py +183 -0
- package/skills_ref/xlsx/scripts/office/unpack.py +132 -0
- package/skills_ref/xlsx/scripts/office/validate.py +111 -0
- package/skills_ref/xlsx/scripts/office/validators/__init__.py +15 -0
- package/skills_ref/xlsx/scripts/office/validators/base.py +847 -0
- package/skills_ref/xlsx/scripts/office/validators/docx.py +446 -0
- package/skills_ref/xlsx/scripts/office/validators/pptx.py +275 -0
- package/skills_ref/xlsx/scripts/office/validators/redlining.py +247 -0
- package/skills_ref/xlsx/scripts/recalc.py +184 -0
- package/skills_ref/xurl/SKILL.md +461 -0
|
@@ -0,0 +1,1273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync, readdirSync, statSync } from 'fs'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import { parse as parseYaml } from 'yaml'
|
|
7
|
+
|
|
8
|
+
const HTTP_METHODS = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head']
|
|
9
|
+
const DEFAULT_PUBLISHED_WHATSAPP_OPENAPI = 'https://docs.kapso.ai/api/meta/whatsapp/openapi-whatsapp.yaml'
|
|
10
|
+
const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
+
|
|
12
|
+
function printHelp(exitCode = 0) {
|
|
13
|
+
const msg = `
|
|
14
|
+
Explore OpenAPI specs (YAML)
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
node openapi-explore.mjs [openapi.yaml ...] <command> [args]
|
|
18
|
+
node openapi-explore.mjs [--file <path> ...] <command> [args]
|
|
19
|
+
node openapi-explore.mjs --all <command> [args]
|
|
20
|
+
|
|
21
|
+
Default (no files passed):
|
|
22
|
+
Loads the published OpenAPI files from docs.kapso.ai:
|
|
23
|
+
- ${DEFAULT_PUBLISHED_WHATSAPP_OPENAPI}
|
|
24
|
+
- (plus platform + workflows, deduced from that URL)
|
|
25
|
+
|
|
26
|
+
Fallback:
|
|
27
|
+
If it can't fetch the published specs (offline, etc.), it falls back to local repo files:
|
|
28
|
+
api/**/openapi-*.yaml
|
|
29
|
+
|
|
30
|
+
Use --all to force local auto-discovery.
|
|
31
|
+
|
|
32
|
+
Commands:
|
|
33
|
+
specs
|
|
34
|
+
tags [--spec <id>]
|
|
35
|
+
ops [--spec <id>] [--tag <tag>] [--q <query>]
|
|
36
|
+
search <query> [--spec <id>]
|
|
37
|
+
op <operationId | specId:operationId | "METHOD /path"> [--spec <id>]
|
|
38
|
+
schema <SchemaName | specId:SchemaName> [--spec <id>]
|
|
39
|
+
where <SchemaName | specId:SchemaName> [--spec <id>]
|
|
40
|
+
|
|
41
|
+
Flags:
|
|
42
|
+
--file, -f <path> Load a spec file (repeatable)
|
|
43
|
+
--all Load all api/**/openapi-*.yaml files
|
|
44
|
+
--spec <id> Filter by spec id (platform, workflows, whatsapp, ...)
|
|
45
|
+
--json Output JSON (search/ops/where)
|
|
46
|
+
--limit <n> Limit results (default 30)
|
|
47
|
+
`
|
|
48
|
+
console.log(msg.trim())
|
|
49
|
+
process.exit(exitCode)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function die(msg, exitCode = 1) {
|
|
53
|
+
console.error(msg)
|
|
54
|
+
process.exit(exitCode)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function parseArgs(argv) {
|
|
58
|
+
const args = [...argv]
|
|
59
|
+
const opts = { files: [], all: false, spec: null, json: false, limit: 30, tag: null, q: null }
|
|
60
|
+
let command = null
|
|
61
|
+
const rest = []
|
|
62
|
+
|
|
63
|
+
for (let i = 0; i < args.length; i++) {
|
|
64
|
+
const a = args[i]
|
|
65
|
+
if (a === '--help' || a === '-h') printHelp(0)
|
|
66
|
+
|
|
67
|
+
if (a === '--all') {
|
|
68
|
+
opts.all = true
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
if (a === '--json') {
|
|
72
|
+
opts.json = true
|
|
73
|
+
continue
|
|
74
|
+
}
|
|
75
|
+
if (a === '--file' || a === '-f') {
|
|
76
|
+
const p = args[++i]
|
|
77
|
+
if (!p) die('Missing value for --file')
|
|
78
|
+
opts.files.push(p)
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
if (a === '--spec') {
|
|
82
|
+
opts.spec = args[++i] || null
|
|
83
|
+
if (!opts.spec) die('Missing value for --spec')
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
if (a === '--limit') {
|
|
87
|
+
const raw = args[++i]
|
|
88
|
+
const n = Number(raw)
|
|
89
|
+
if (!Number.isFinite(n) || n <= 0) die(`Invalid --limit: ${raw}`)
|
|
90
|
+
opts.limit = n
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
if (a === '--tag') {
|
|
94
|
+
opts.tag = args[++i] || null
|
|
95
|
+
if (!opts.tag) die('Missing value for --tag')
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
if (a === '--q') {
|
|
99
|
+
opts.q = args[++i] || null
|
|
100
|
+
if (!opts.q) die('Missing value for --q')
|
|
101
|
+
continue
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!command && (a.endsWith('.yaml') || a.endsWith('.yml'))) {
|
|
105
|
+
opts.files.push(a)
|
|
106
|
+
continue
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!command) command = a
|
|
110
|
+
else rest.push(a)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return { opts, command, rest }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function walk(dir, { filePattern, maxDepth = 10 } = {}, depth = 0, out = []) {
|
|
117
|
+
if (depth > maxDepth) return out
|
|
118
|
+
let entries
|
|
119
|
+
try {
|
|
120
|
+
entries = readdirSync(dir)
|
|
121
|
+
} catch {
|
|
122
|
+
return out
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (const entry of entries) {
|
|
126
|
+
const full = path.join(dir, entry)
|
|
127
|
+
let st
|
|
128
|
+
try {
|
|
129
|
+
st = statSync(full)
|
|
130
|
+
} catch {
|
|
131
|
+
continue
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (st.isDirectory()) {
|
|
135
|
+
walk(full, { filePattern, maxDepth }, depth + 1, out)
|
|
136
|
+
} else if (!filePattern || filePattern.test(entry)) {
|
|
137
|
+
out.push(full)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return out
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function findUpDir(startDir, targetDirName, { maxDepth = 12 } = {}) {
|
|
145
|
+
let current = path.resolve(startDir)
|
|
146
|
+
for (let i = 0; i <= maxDepth; i++) {
|
|
147
|
+
const candidate = path.join(current, targetDirName)
|
|
148
|
+
try {
|
|
149
|
+
const st = statSync(candidate)
|
|
150
|
+
if (st.isDirectory()) return candidate
|
|
151
|
+
} catch {
|
|
152
|
+
// ignore
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const parent = path.dirname(current)
|
|
156
|
+
if (parent === current) break
|
|
157
|
+
current = parent
|
|
158
|
+
}
|
|
159
|
+
return null
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function findLocalApiDir() {
|
|
163
|
+
return findUpDir(process.cwd(), 'api') || findUpDir(SCRIPT_DIR, 'api')
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function isUrl(s) {
|
|
167
|
+
return /^https?:\/\//i.test(String(s))
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function deducePublishedOpenApiUrls(whatsappUrl = DEFAULT_PUBLISHED_WHATSAPP_OPENAPI) {
|
|
171
|
+
const u = new URL(whatsappUrl)
|
|
172
|
+
const origin = u.origin
|
|
173
|
+
return [
|
|
174
|
+
whatsappUrl,
|
|
175
|
+
new URL('/api/platform/v1/openapi-platform.yaml', origin).toString(),
|
|
176
|
+
new URL('/api/platform/v1/openapi-workflows.yaml', origin).toString(),
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function inferSpecId(filePath, spec) {
|
|
181
|
+
const base = (isUrl(filePath) ? path.basename(new URL(filePath).pathname) : path.basename(filePath)).toLowerCase()
|
|
182
|
+
if (base.includes('whatsapp')) return 'whatsapp'
|
|
183
|
+
if (base.includes('workflows')) return 'workflows'
|
|
184
|
+
if (base.includes('platform')) return 'platform'
|
|
185
|
+
|
|
186
|
+
const title = (spec?.info?.title || '').toLowerCase()
|
|
187
|
+
if (title.includes('whatsapp')) return 'whatsapp'
|
|
188
|
+
if (title.includes('workflow')) return 'workflows'
|
|
189
|
+
if (title.includes('platform')) return 'platform'
|
|
190
|
+
|
|
191
|
+
return base.replace(/^openapi-/, '').replace(/\.(ya?ml)$/, '') || 'spec'
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function decodeJsonPointerToken(token) {
|
|
195
|
+
return token.replaceAll('~1', '/').replaceAll('~0', '~')
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function getByJsonPointer(doc, pointer) {
|
|
199
|
+
if (!pointer || !pointer.startsWith('#/')) return null
|
|
200
|
+
const parts = pointer.slice(2).split('/').map(decodeJsonPointerToken)
|
|
201
|
+
let cur = doc
|
|
202
|
+
for (const part of parts) {
|
|
203
|
+
if (cur == null) return null
|
|
204
|
+
cur = cur[part]
|
|
205
|
+
}
|
|
206
|
+
return cur ?? null
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function refName(ref) {
|
|
210
|
+
if (!ref) return null
|
|
211
|
+
const parts = String(ref).split('/')
|
|
212
|
+
return parts[parts.length - 1] || null
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function derefObject(obj, doc, stack = new Set()) {
|
|
216
|
+
if (!obj?.$ref) return obj
|
|
217
|
+
const ref = String(obj.$ref)
|
|
218
|
+
if (stack.has(ref)) return obj
|
|
219
|
+
stack.add(ref)
|
|
220
|
+
const resolved = getByJsonPointer(doc, ref)
|
|
221
|
+
if (!resolved) return obj
|
|
222
|
+
return derefObject(resolved, doc, stack)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function schemaTypeString(schema) {
|
|
226
|
+
if (!schema) return 'any'
|
|
227
|
+
if (schema.$ref) return refName(schema.$ref) || 'ref'
|
|
228
|
+
if (schema.const !== undefined) return `const ${JSON.stringify(schema.const)}`
|
|
229
|
+
if (schema.enum?.length) {
|
|
230
|
+
const vals = schema.enum.slice(0, 6).map((v) => JSON.stringify(v)).join(' | ')
|
|
231
|
+
return schema.enum.length > 6 ? `enum(${vals} | ...)` : `enum(${vals})`
|
|
232
|
+
}
|
|
233
|
+
if (schema.type) {
|
|
234
|
+
if (Array.isArray(schema.type)) return schema.type.join('|')
|
|
235
|
+
return schema.type
|
|
236
|
+
}
|
|
237
|
+
if (schema.oneOf) return 'oneOf'
|
|
238
|
+
if (schema.anyOf) return 'anyOf'
|
|
239
|
+
if (schema.allOf) return 'allOf'
|
|
240
|
+
if (schema.properties) return 'object'
|
|
241
|
+
if (schema.items) return 'array'
|
|
242
|
+
return 'any'
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function normalizeType(schema) {
|
|
246
|
+
if (!schema) return null
|
|
247
|
+
const t = schema.type
|
|
248
|
+
if (!t) return null
|
|
249
|
+
if (Array.isArray(t)) {
|
|
250
|
+
const nonNull = t.find((x) => x !== 'null')
|
|
251
|
+
return nonNull || t[0] || null
|
|
252
|
+
}
|
|
253
|
+
return t
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function mergeAllOf(schema, doc, seen = new Set()) {
|
|
257
|
+
if (!schema?.allOf?.length) return schema
|
|
258
|
+
|
|
259
|
+
const out = { ...schema }
|
|
260
|
+
delete out.allOf
|
|
261
|
+
|
|
262
|
+
let merged = { type: 'object', properties: {}, required: [] }
|
|
263
|
+
|
|
264
|
+
for (const part of schema.allOf) {
|
|
265
|
+
let s = part
|
|
266
|
+
if (s?.$ref) {
|
|
267
|
+
const name = refName(s.$ref)
|
|
268
|
+
if (name) {
|
|
269
|
+
if (seen.has(name)) continue
|
|
270
|
+
seen.add(name)
|
|
271
|
+
}
|
|
272
|
+
s = getByJsonPointer(doc, s.$ref) || s
|
|
273
|
+
}
|
|
274
|
+
if (s?.allOf) s = mergeAllOf(s, doc, seen)
|
|
275
|
+
|
|
276
|
+
if (s?.type && normalizeType(s) !== 'object' && s.properties) {
|
|
277
|
+
// some specs omit type: object but still have properties
|
|
278
|
+
} else if (normalizeType(s) && normalizeType(s) !== 'object' && !s.properties) {
|
|
279
|
+
return schema
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (s?.properties) Object.assign(merged.properties, s.properties)
|
|
283
|
+
if (Array.isArray(s?.required)) merged.required.push(...s.required)
|
|
284
|
+
if (s?.description && !merged.description) merged.description = s.description
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
merged.required = [...new Set(merged.required)]
|
|
288
|
+
return { ...merged, ...out }
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function formatSchemaPreview(schema, doc, { depth = 2, maxProps = 12 } = {}, indent = '', refStack = new Set()) {
|
|
292
|
+
if (!schema) return [`${indent}any`]
|
|
293
|
+
|
|
294
|
+
if (schema.$ref) {
|
|
295
|
+
const name = refName(schema.$ref) || schema.$ref
|
|
296
|
+
const resolved = getByJsonPointer(doc, schema.$ref)
|
|
297
|
+
const lines = [`${indent}${name}`]
|
|
298
|
+
const refKey = String(schema.$ref)
|
|
299
|
+
if (refStack.has(refKey)) return lines
|
|
300
|
+
refStack.add(refKey)
|
|
301
|
+
if (resolved && depth > 0) {
|
|
302
|
+
const next = resolved?.allOf ? mergeAllOf(resolved, doc) : resolved
|
|
303
|
+
const childLines = formatSchemaPreview(next, doc, { depth, maxProps }, indent + ' ', refStack)
|
|
304
|
+
// Avoid printing a single redundant "object" line for refs
|
|
305
|
+
if (!(childLines.length === 1 && childLines[0].trim() === 'object')) lines.push(...childLines)
|
|
306
|
+
}
|
|
307
|
+
refStack.delete(refKey)
|
|
308
|
+
return lines
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const normalized = schema.allOf ? mergeAllOf(schema, doc) : schema
|
|
312
|
+
|
|
313
|
+
const t = normalizeType(normalized) || schemaTypeString(normalized)
|
|
314
|
+
if (t === 'object' || normalized.properties) {
|
|
315
|
+
const props = normalized.properties || {}
|
|
316
|
+
const required = new Set(normalized.required || [])
|
|
317
|
+
const keys = Object.keys(props)
|
|
318
|
+
if (!keys.length) return [`${indent}object`]
|
|
319
|
+
|
|
320
|
+
const lines = []
|
|
321
|
+
for (const key of keys.slice(0, maxProps)) {
|
|
322
|
+
const s = props[key]
|
|
323
|
+
const typeStr = schemaTypeString(s)
|
|
324
|
+
const req = required.has(key) ? ' (required)' : ''
|
|
325
|
+
const desc = s?.description ? ` - ${String(s.description).replaceAll('\n', ' ').slice(0, 80)}` : ''
|
|
326
|
+
lines.push(`${indent}- ${key}: ${typeStr}${req}${desc}`)
|
|
327
|
+
if (depth > 0) {
|
|
328
|
+
const child = s?.$ref ? getByJsonPointer(doc, s.$ref) : s
|
|
329
|
+
const childNorm = child?.allOf ? mergeAllOf(child, doc) : child
|
|
330
|
+
const childType = normalizeType(childNorm)
|
|
331
|
+
if (childType === 'object' || childNorm?.properties || childNorm?.items) {
|
|
332
|
+
const nested = formatSchemaPreview(childNorm, doc, { depth: depth - 1, maxProps }, indent + ' ', refStack)
|
|
333
|
+
// Only include nested if it adds something beyond "object"/"array"
|
|
334
|
+
if (!(nested.length === 1 && ['object', 'array'].includes(nested[0].trim()))) lines.push(...nested)
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (keys.length > maxProps) lines.push(`${indent}- ... (${keys.length - maxProps} more)`)
|
|
339
|
+
return lines
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (t === 'array' || normalized.items) {
|
|
343
|
+
const itemType = schemaTypeString(normalized.items)
|
|
344
|
+
const lines = [`${indent}array<${itemType}>`]
|
|
345
|
+
if (normalized.items && depth > 0) {
|
|
346
|
+
const next = normalized.items?.$ref ? getByJsonPointer(doc, normalized.items.$ref) : normalized.items
|
|
347
|
+
const nextNorm = next?.allOf ? mergeAllOf(next, doc) : next
|
|
348
|
+
const nested = formatSchemaPreview(nextNorm, doc, { depth: depth - 1, maxProps }, indent + ' ', refStack)
|
|
349
|
+
const nestedTrim = nested.length === 1 ? nested[0].trim() : null
|
|
350
|
+
const redundant =
|
|
351
|
+
nestedTrim === null ? false : ['object', 'array'].includes(nestedTrim) || nestedTrim === itemType
|
|
352
|
+
if (!redundant) lines.push(...nested)
|
|
353
|
+
}
|
|
354
|
+
return lines
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (normalized.oneOf?.length) {
|
|
358
|
+
const opts = normalized.oneOf.slice(0, 5).map((s) => schemaTypeString(s)).join(' | ')
|
|
359
|
+
return [`${indent}oneOf(${opts}${normalized.oneOf.length > 5 ? ' | ...' : ''})`]
|
|
360
|
+
}
|
|
361
|
+
if (normalized.anyOf?.length) {
|
|
362
|
+
const opts = normalized.anyOf.slice(0, 5).map((s) => schemaTypeString(s)).join(' | ')
|
|
363
|
+
return [`${indent}anyOf(${opts}${normalized.anyOf.length > 5 ? ' | ...' : ''})`]
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return [`${indent}${schemaTypeString(normalized)}`]
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function placeholderForString(schema) {
|
|
370
|
+
if (schema?.enum?.length) return schema.enum[0]
|
|
371
|
+
if (schema?.const !== undefined) return schema.const
|
|
372
|
+
if (schema?.format === 'uuid') return '00000000-0000-0000-0000-000000000000'
|
|
373
|
+
if (schema?.format === 'date-time') return '2025-01-01T00:00:00Z'
|
|
374
|
+
if (schema?.format === 'date') return '2025-01-01'
|
|
375
|
+
if (schema?.format === 'email') return 'user@example.com'
|
|
376
|
+
if (schema?.format === 'uri' || schema?.format === 'url') return 'https://example.com'
|
|
377
|
+
return 'string'
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function exampleFromSchema(schema, doc, { depth = 3, includeOptional = false } = {}, stack = new Set()) {
|
|
381
|
+
if (!schema) return null
|
|
382
|
+
|
|
383
|
+
if (schema.$ref) {
|
|
384
|
+
const name = refName(schema.$ref)
|
|
385
|
+
if (name) {
|
|
386
|
+
if (stack.has(name)) return `<circular:${name}>`
|
|
387
|
+
stack.add(name)
|
|
388
|
+
}
|
|
389
|
+
const resolved = getByJsonPointer(doc, schema.$ref)
|
|
390
|
+
const out = exampleFromSchema(resolved || {}, doc, { depth, includeOptional }, stack)
|
|
391
|
+
if (name) stack.delete(name)
|
|
392
|
+
return out
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const normalized = schema.allOf ? mergeAllOf(schema, doc) : schema
|
|
396
|
+
|
|
397
|
+
if (normalized.const !== undefined) return normalized.const
|
|
398
|
+
if (normalized.enum?.length) return normalized.enum[0]
|
|
399
|
+
|
|
400
|
+
const t = normalizeType(normalized)
|
|
401
|
+
if (t === 'string') return placeholderForString(normalized)
|
|
402
|
+
if (t === 'integer') return 0
|
|
403
|
+
if (t === 'number') return 0
|
|
404
|
+
if (t === 'boolean') return true
|
|
405
|
+
if (t === 'null') return null
|
|
406
|
+
|
|
407
|
+
if ((t === 'array' || normalized.items) && depth > 0) {
|
|
408
|
+
return [exampleFromSchema(normalized.items || {}, doc, { depth: depth - 1, includeOptional }, stack)]
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if ((t === 'object' || normalized.properties || normalized.additionalProperties) && depth > 0) {
|
|
412
|
+
const props = normalized.properties || {}
|
|
413
|
+
const required = new Set(normalized.required || [])
|
|
414
|
+
const out = {}
|
|
415
|
+
|
|
416
|
+
const keys = Object.keys(props)
|
|
417
|
+
for (const key of keys) {
|
|
418
|
+
if (!includeOptional && !required.has(key)) continue
|
|
419
|
+
out[key] = exampleFromSchema(props[key], doc, { depth: depth - 1, includeOptional }, stack)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// If it is a free-form map, add a placeholder entry.
|
|
423
|
+
if (!keys.length && normalized.additionalProperties) {
|
|
424
|
+
out.key = exampleFromSchema(
|
|
425
|
+
normalized.additionalProperties === true ? {} : normalized.additionalProperties,
|
|
426
|
+
doc,
|
|
427
|
+
{ depth: depth - 1, includeOptional },
|
|
428
|
+
stack,
|
|
429
|
+
)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return out
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (normalized.oneOf?.length) return exampleFromSchema(normalized.oneOf[0], doc, { depth, includeOptional }, stack)
|
|
436
|
+
if (normalized.anyOf?.length) return exampleFromSchema(normalized.anyOf[0], doc, { depth, includeOptional }, stack)
|
|
437
|
+
|
|
438
|
+
return null
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function collectSchemaRefs(schema, doc, out = new Set(), stack = new Set()) {
|
|
442
|
+
if (!schema) return out
|
|
443
|
+
|
|
444
|
+
if (schema.$ref) {
|
|
445
|
+
const name = refName(schema.$ref)
|
|
446
|
+
if (name) out.add(name)
|
|
447
|
+
if (name) {
|
|
448
|
+
if (stack.has(name)) return out
|
|
449
|
+
stack.add(name)
|
|
450
|
+
}
|
|
451
|
+
const resolved = getByJsonPointer(doc, schema.$ref)
|
|
452
|
+
if (resolved) collectSchemaRefs(resolved, doc, out, stack)
|
|
453
|
+
if (name) stack.delete(name)
|
|
454
|
+
return out
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const normalized = schema.allOf ? mergeAllOf(schema, doc) : schema
|
|
458
|
+
|
|
459
|
+
for (const key of ['oneOf', 'anyOf', 'allOf']) {
|
|
460
|
+
if (Array.isArray(normalized[key])) {
|
|
461
|
+
for (const s of normalized[key]) collectSchemaRefs(s, doc, out, stack)
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (normalized.properties) {
|
|
466
|
+
for (const s of Object.values(normalized.properties)) collectSchemaRefs(s, doc, out, stack)
|
|
467
|
+
}
|
|
468
|
+
if (normalized.items) collectSchemaRefs(normalized.items, doc, out, stack)
|
|
469
|
+
if (normalized.additionalProperties && normalized.additionalProperties !== true) {
|
|
470
|
+
collectSchemaRefs(normalized.additionalProperties, doc, out, stack)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return out
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function collectSchemaFieldNames(schema, doc, out = new Set(), stack = new Set(), depth = 3) {
|
|
477
|
+
if (!schema || depth < 0) return out
|
|
478
|
+
|
|
479
|
+
if (schema.$ref) {
|
|
480
|
+
const ref = String(schema.$ref)
|
|
481
|
+
if (stack.has(ref)) return out
|
|
482
|
+
stack.add(ref)
|
|
483
|
+
const resolved = getByJsonPointer(doc, ref)
|
|
484
|
+
if (resolved) collectSchemaFieldNames(resolved, doc, out, stack, depth)
|
|
485
|
+
stack.delete(ref)
|
|
486
|
+
return out
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const normalized = schema.allOf ? mergeAllOf(schema, doc) : schema
|
|
490
|
+
|
|
491
|
+
for (const key of ['oneOf', 'anyOf', 'allOf']) {
|
|
492
|
+
if (Array.isArray(normalized[key])) {
|
|
493
|
+
for (const s of normalized[key]) collectSchemaFieldNames(s, doc, out, stack, depth)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (normalized.properties) {
|
|
498
|
+
for (const [k, s] of Object.entries(normalized.properties)) {
|
|
499
|
+
out.add(k)
|
|
500
|
+
collectSchemaFieldNames(s, doc, out, stack, depth - 1)
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (normalized.items) collectSchemaFieldNames(normalized.items, doc, out, stack, depth - 1)
|
|
505
|
+
if (normalized.additionalProperties && normalized.additionalProperties !== true) {
|
|
506
|
+
collectSchemaFieldNames(normalized.additionalProperties, doc, out, stack, depth - 1)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return out
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function normalizeOperationSecurity(op, spec) {
|
|
513
|
+
if (Object.prototype.hasOwnProperty.call(op, 'security')) return op.security
|
|
514
|
+
return spec.security
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function securityLabel(opSecurity, spec) {
|
|
518
|
+
if (!opSecurity) return null
|
|
519
|
+
if (Array.isArray(opSecurity) && opSecurity.length === 0) return 'none'
|
|
520
|
+
|
|
521
|
+
const schemes = spec?.components?.securitySchemes || {}
|
|
522
|
+
|
|
523
|
+
function schemeLabel(name) {
|
|
524
|
+
const s = schemes[name]
|
|
525
|
+
if (!s) return name
|
|
526
|
+
if (s.type === 'apiKey' && s.in === 'header' && s.name) return `${name} (${s.name} header)`
|
|
527
|
+
if (s.type === 'apiKey' && s.in) return `${name} (apiKey in ${s.in})`
|
|
528
|
+
if (s.type === 'http' && s.scheme === 'bearer') return `${name} (Authorization: Bearer ...)`
|
|
529
|
+
if (s.type === 'http') return `${name} (http ${s.scheme || ''})`.trim()
|
|
530
|
+
return `${name} (${s.type})`
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const requirementSets = []
|
|
534
|
+
for (const req of opSecurity || []) {
|
|
535
|
+
const keys = Object.keys(req || {})
|
|
536
|
+
if (!keys.length) continue
|
|
537
|
+
requirementSets.push(keys.map(schemeLabel).join(' + '))
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (!requirementSets.length) return null
|
|
541
|
+
return requirementSets.join(' OR ')
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function toShortSpec(s) {
|
|
545
|
+
return {
|
|
546
|
+
id: s.id,
|
|
547
|
+
title: s.title,
|
|
548
|
+
version: s.version,
|
|
549
|
+
file: s.filePath,
|
|
550
|
+
servers: s.servers,
|
|
551
|
+
operations: s.operations.length,
|
|
552
|
+
schemas: Object.keys(s.schemas).length,
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
async function readSpecSource(source) {
|
|
557
|
+
if (isUrl(source)) {
|
|
558
|
+
const res = await fetch(source, {
|
|
559
|
+
// Some CDNs / WAFs behave better with a UA.
|
|
560
|
+
headers: { 'User-Agent': 'kapso-openapi-explore/1.0 (+https://docs.kapso.ai)' },
|
|
561
|
+
})
|
|
562
|
+
if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}`)
|
|
563
|
+
return await res.text()
|
|
564
|
+
}
|
|
565
|
+
return readFileSync(source, 'utf-8')
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
async function loadSpecsAsync({ sources, sourceMode, specFilter }) {
|
|
569
|
+
if (!sources.length) die('No OpenAPI sources provided')
|
|
570
|
+
|
|
571
|
+
const seenIds = new Map()
|
|
572
|
+
const specs = []
|
|
573
|
+
const errors = []
|
|
574
|
+
|
|
575
|
+
for (const filePath of sources) {
|
|
576
|
+
let raw = null
|
|
577
|
+
try {
|
|
578
|
+
raw = await readSpecSource(filePath)
|
|
579
|
+
} catch (e) {
|
|
580
|
+
errors.push({ source: filePath, error: e })
|
|
581
|
+
if (sourceMode === 'explicit') console.error(`Skipping ${filePath}: ${e.message}`)
|
|
582
|
+
continue
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
let doc
|
|
586
|
+
try {
|
|
587
|
+
doc = parseYaml(raw)
|
|
588
|
+
} catch (e) {
|
|
589
|
+
errors.push({ source: filePath, error: e })
|
|
590
|
+
console.error(`Skipping ${filePath}: YAML parse error: ${e.message}`)
|
|
591
|
+
continue
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
const idBase = inferSpecId(filePath, doc)
|
|
595
|
+
const n = (seenIds.get(idBase) || 0) + 1
|
|
596
|
+
seenIds.set(idBase, n)
|
|
597
|
+
const id = n === 1 ? idBase : `${idBase}${n}`
|
|
598
|
+
|
|
599
|
+
if (specFilter && id !== specFilter) continue
|
|
600
|
+
|
|
601
|
+
const title = doc?.info?.title || id
|
|
602
|
+
const version = doc?.info?.version || '?'
|
|
603
|
+
const servers = (doc?.servers || []).map((s) => s?.url).filter(Boolean)
|
|
604
|
+
const tags = doc?.tags || []
|
|
605
|
+
const schemas = doc?.components?.schemas || {}
|
|
606
|
+
const schemaFieldCache = new Map()
|
|
607
|
+
|
|
608
|
+
const getSchemaFields = (schemaName) => {
|
|
609
|
+
if (schemaFieldCache.has(schemaName)) return schemaFieldCache.get(schemaName)
|
|
610
|
+
const schema = schemas?.[schemaName]
|
|
611
|
+
const fields = schema ? [...collectSchemaFieldNames(schema, doc)] : []
|
|
612
|
+
schemaFieldCache.set(schemaName, fields)
|
|
613
|
+
return fields
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const operations = []
|
|
617
|
+
const paths = doc?.paths || {}
|
|
618
|
+
for (const [p, pathItemRaw] of Object.entries(paths)) {
|
|
619
|
+
const pathItem = pathItemRaw || {}
|
|
620
|
+
const pathParams = Array.isArray(pathItem.parameters) ? pathItem.parameters.map((x) => derefObject(x, doc)) : []
|
|
621
|
+
|
|
622
|
+
for (const method of HTTP_METHODS) {
|
|
623
|
+
const op = pathItem[method]
|
|
624
|
+
if (!op) continue
|
|
625
|
+
|
|
626
|
+
const mergedParams = [...pathParams, ...((op.parameters || []).filter(Boolean))]
|
|
627
|
+
.map((x) => derefObject(x, doc))
|
|
628
|
+
.filter(Boolean)
|
|
629
|
+
const opSecurity = normalizeOperationSecurity(op, doc)
|
|
630
|
+
const opRequestBody = derefObject(op.requestBody || null, doc)
|
|
631
|
+
|
|
632
|
+
const refs = new Set()
|
|
633
|
+
// params
|
|
634
|
+
for (const param of mergedParams) {
|
|
635
|
+
if (param?.schema) collectSchemaRefs(param.schema, doc, refs)
|
|
636
|
+
if (param?.content) {
|
|
637
|
+
for (const media of Object.values(param.content)) {
|
|
638
|
+
if (media?.schema) collectSchemaRefs(media.schema, doc, refs)
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
// body
|
|
643
|
+
if (opRequestBody?.content) {
|
|
644
|
+
for (const media of Object.values(opRequestBody.content)) {
|
|
645
|
+
if (media?.schema) collectSchemaRefs(media.schema, doc, refs)
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
// responses
|
|
649
|
+
if (op?.responses) {
|
|
650
|
+
for (const resp of Object.values(op.responses)) {
|
|
651
|
+
const r = derefObject(resp, doc)
|
|
652
|
+
if (r?.content) {
|
|
653
|
+
for (const media of Object.values(r.content)) {
|
|
654
|
+
if (media?.schema) collectSchemaRefs(media.schema, doc, refs)
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const fieldsUsed = new Set()
|
|
661
|
+
for (const schemaName of refs) {
|
|
662
|
+
for (const f of getSchemaFields(schemaName)) fieldsUsed.add(f)
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
operations.push({
|
|
666
|
+
specId: id,
|
|
667
|
+
specTitle: title,
|
|
668
|
+
specFile: filePath,
|
|
669
|
+
method,
|
|
670
|
+
path: p,
|
|
671
|
+
operationId: op.operationId || null,
|
|
672
|
+
summary: op.summary || null,
|
|
673
|
+
description: op.description || null,
|
|
674
|
+
tags: op.tags || [],
|
|
675
|
+
deprecated: Boolean(op.deprecated),
|
|
676
|
+
security: opSecurity,
|
|
677
|
+
securityLabel: securityLabel(opSecurity, doc),
|
|
678
|
+
parameters: mergedParams,
|
|
679
|
+
requestBody: opRequestBody,
|
|
680
|
+
responses: op.responses || {},
|
|
681
|
+
refsUsed: refs,
|
|
682
|
+
fieldsUsed,
|
|
683
|
+
})
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
specs.push({
|
|
688
|
+
id,
|
|
689
|
+
filePath,
|
|
690
|
+
title,
|
|
691
|
+
version,
|
|
692
|
+
servers,
|
|
693
|
+
doc,
|
|
694
|
+
tags,
|
|
695
|
+
schemas,
|
|
696
|
+
operations,
|
|
697
|
+
})
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (!specs.length) {
|
|
701
|
+
if (sourceMode === 'default_remote' && errors.length) {
|
|
702
|
+
const apiDir = findLocalApiDir()
|
|
703
|
+
const local = apiDir ? walk(apiDir, { filePattern: /^openapi-.*\.ya?ml$/ }) : []
|
|
704
|
+
if (local.length) {
|
|
705
|
+
console.error(`Could not fetch published OpenAPI specs. Falling back to local repo specs (api/**/openapi-*.yaml).`)
|
|
706
|
+
return await loadSpecsAsync({ sources: local, sourceMode: 'explicit', specFilter })
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (specFilter) die(`No specs matched --spec ${specFilter}`)
|
|
710
|
+
die('No specs loaded')
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
if (sourceMode === 'default_remote' && errors.length) {
|
|
714
|
+
console.error(`Some published OpenAPI specs could not be fetched:`)
|
|
715
|
+
for (const e of errors) console.error(`- ${e.source}: ${e.error?.message || String(e.error)}`)
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
return specs
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function findOperation(specs, query, { specHint } = {}) {
|
|
722
|
+
const raw = query.trim()
|
|
723
|
+
const direct = raw.includes(':') ? raw.split(':') : null
|
|
724
|
+
const qSpec = direct?.[0] || specHint
|
|
725
|
+
const qId = direct?.[1] || raw
|
|
726
|
+
|
|
727
|
+
// METHOD /path
|
|
728
|
+
const m = raw.match(/^(get|post|put|patch|delete|options|head)\\s+(.+)$/i)
|
|
729
|
+
if (m) {
|
|
730
|
+
const method = m[1].toLowerCase()
|
|
731
|
+
const p = m[2].trim()
|
|
732
|
+
const matches = []
|
|
733
|
+
for (const s of specs) {
|
|
734
|
+
if (qSpec && s.id !== qSpec) continue
|
|
735
|
+
for (const op of s.operations) {
|
|
736
|
+
if (op.method === method && op.path === p) matches.push(op)
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return matches
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// operationId
|
|
743
|
+
const matches = []
|
|
744
|
+
for (const s of specs) {
|
|
745
|
+
if (qSpec && s.id !== qSpec) continue
|
|
746
|
+
for (const op of s.operations) {
|
|
747
|
+
if (op.operationId === qId) matches.push(op)
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return matches
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function findSchema(specs, query, { specHint } = {}) {
|
|
754
|
+
const raw = query.trim()
|
|
755
|
+
const direct = raw.includes(':') ? raw.split(':') : null
|
|
756
|
+
const qSpec = direct?.[0] || specHint
|
|
757
|
+
const qName = direct?.[1] || raw
|
|
758
|
+
|
|
759
|
+
const matches = []
|
|
760
|
+
for (const s of specs) {
|
|
761
|
+
if (qSpec && s.id !== qSpec) continue
|
|
762
|
+
if (Object.prototype.hasOwnProperty.call(s.schemas, qName)) {
|
|
763
|
+
matches.push({ spec: s, name: qName, schema: s.schemas[qName] })
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
return matches
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function scoreText(hay, q) {
|
|
770
|
+
if (!hay) return 0
|
|
771
|
+
const h = hay.toLowerCase()
|
|
772
|
+
if (h === q) return 100
|
|
773
|
+
if (h.startsWith(q)) return 60
|
|
774
|
+
if (h.includes(q)) return 30
|
|
775
|
+
return 0
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
function search(specs, query, { specHint, limit = 30 } = {}) {
|
|
779
|
+
const q = query.toLowerCase().trim()
|
|
780
|
+
if (!q) return { ops: [], schemas: [] }
|
|
781
|
+
|
|
782
|
+
const ops = []
|
|
783
|
+
const schemas = []
|
|
784
|
+
|
|
785
|
+
for (const s of specs) {
|
|
786
|
+
if (specHint && s.id !== specHint) continue
|
|
787
|
+
|
|
788
|
+
for (const op of s.operations) {
|
|
789
|
+
let score = 0
|
|
790
|
+
score += scoreText(op.operationId, q) * 3
|
|
791
|
+
score += scoreText(`${op.method} ${op.path}`, q) * 2
|
|
792
|
+
score += scoreText(op.summary, q) * 2
|
|
793
|
+
score += scoreText(op.description, q)
|
|
794
|
+
for (const t of op.tags || []) score += scoreText(t, q) * 2
|
|
795
|
+
score += scoreText((op.parameters || []).map((p) => p?.name).filter(Boolean).join(' '), q) * 2
|
|
796
|
+
score += scoreText([...op.refsUsed].join(' '), q) * 2
|
|
797
|
+
score += scoreText([...op.fieldsUsed].join(' '), q)
|
|
798
|
+
if (score > 0) ops.push({ score, op })
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
for (const [name, schema] of Object.entries(s.schemas)) {
|
|
802
|
+
let score = 0
|
|
803
|
+
score += scoreText(name, q) * 3
|
|
804
|
+
score += scoreText(schema?.description, q)
|
|
805
|
+
score += scoreText([...collectSchemaFieldNames(schema, s.doc)].join(' '), q) * 2
|
|
806
|
+
if (score > 0) schemas.push({ score, spec: s, name, schema })
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
ops.sort((a, b) => b.score - a.score)
|
|
811
|
+
schemas.sort((a, b) => b.score - a.score)
|
|
812
|
+
|
|
813
|
+
return {
|
|
814
|
+
ops: ops.slice(0, limit).map((x) => x.op),
|
|
815
|
+
schemas: schemas.slice(0, limit).map((x) => ({ specId: x.spec.id, name: x.name })),
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function printTable(rows, { sep = ' ' } = {}) {
|
|
820
|
+
if (!rows.length) return
|
|
821
|
+
const widths = []
|
|
822
|
+
for (const row of rows) {
|
|
823
|
+
row.forEach((cell, i) => {
|
|
824
|
+
widths[i] = Math.max(widths[i] || 0, String(cell).length)
|
|
825
|
+
})
|
|
826
|
+
}
|
|
827
|
+
for (const row of rows) {
|
|
828
|
+
const line = row
|
|
829
|
+
.map((cell, i) => String(cell).padEnd(widths[i], ' '))
|
|
830
|
+
.join(sep)
|
|
831
|
+
.trimEnd()
|
|
832
|
+
console.log(line)
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function printSpecs(specs, { json } = {}) {
|
|
837
|
+
if (json) {
|
|
838
|
+
console.log(JSON.stringify(specs.map(toShortSpec), null, 2))
|
|
839
|
+
return
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
const rows = [['id', 'version', 'operations', 'schemas', 'file']]
|
|
843
|
+
for (const s of specs) rows.push([s.id, s.version, String(s.operations.length), String(Object.keys(s.schemas).length), s.filePath])
|
|
844
|
+
printTable(rows)
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function printTags(specs, { specHint } = {}) {
|
|
848
|
+
const rows = [['spec', 'tag', 'description']]
|
|
849
|
+
for (const s of specs) {
|
|
850
|
+
if (specHint && s.id !== specHint) continue
|
|
851
|
+
for (const t of s.tags || []) rows.push([s.id, t.name, (t.description || '').replaceAll('\n', ' ').slice(0, 80)])
|
|
852
|
+
}
|
|
853
|
+
if (rows.length === 1) die('No tags found')
|
|
854
|
+
printTable(rows)
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function printOps(specs, { specHint, tag, q, json, limit = 30 } = {}) {
|
|
858
|
+
let ops = []
|
|
859
|
+
for (const s of specs) {
|
|
860
|
+
if (specHint && s.id !== specHint) continue
|
|
861
|
+
ops.push(...s.operations)
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
if (tag) ops = ops.filter((o) => (o.tags || []).includes(tag))
|
|
865
|
+
|
|
866
|
+
if (q) {
|
|
867
|
+
const res = search(specs, q, { specHint, limit: Math.max(limit, 200) })
|
|
868
|
+
const opSet = new Set(res.ops.map((o) => `${o.specId}:${o.operationId || o.method + ' ' + o.path}`))
|
|
869
|
+
ops = ops.filter((o) => opSet.has(`${o.specId}:${o.operationId || o.method + ' ' + o.path}`))
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
ops = ops.slice(0, limit)
|
|
873
|
+
|
|
874
|
+
if (json) {
|
|
875
|
+
console.log(
|
|
876
|
+
JSON.stringify(
|
|
877
|
+
ops.map((o) => ({
|
|
878
|
+
spec: o.specId,
|
|
879
|
+
operationId: o.operationId,
|
|
880
|
+
method: o.method,
|
|
881
|
+
path: o.path,
|
|
882
|
+
summary: o.summary,
|
|
883
|
+
})),
|
|
884
|
+
null,
|
|
885
|
+
2,
|
|
886
|
+
),
|
|
887
|
+
)
|
|
888
|
+
return
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const rows = [['spec', 'operationId', 'method', 'path', 'summary']]
|
|
892
|
+
for (const o of ops) rows.push([o.specId, o.operationId || '-', o.method.toUpperCase(), o.path, (o.summary || '').slice(0, 80)])
|
|
893
|
+
printTable(rows)
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
function splitParams(params) {
|
|
897
|
+
const out = { path: [], query: [], header: [], cookie: [], other: [] }
|
|
898
|
+
for (const p of params || []) {
|
|
899
|
+
const loc = p?.in
|
|
900
|
+
if (loc === 'path') out.path.push(p)
|
|
901
|
+
else if (loc === 'query') out.query.push(p)
|
|
902
|
+
else if (loc === 'header') out.header.push(p)
|
|
903
|
+
else if (loc === 'cookie') out.cookie.push(p)
|
|
904
|
+
else out.other.push(p)
|
|
905
|
+
}
|
|
906
|
+
return out
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function paramType(param) {
|
|
910
|
+
const s = param?.schema
|
|
911
|
+
if (s) return schemaTypeString(s)
|
|
912
|
+
if (param?.content) {
|
|
913
|
+
const media = Object.values(param.content)[0]
|
|
914
|
+
if (media?.schema) return schemaTypeString(media.schema)
|
|
915
|
+
}
|
|
916
|
+
return 'any'
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function printParamsBlock(title, params) {
|
|
920
|
+
if (!params.length) return
|
|
921
|
+
console.log(`\n${title}`)
|
|
922
|
+
const rows = [['name', 'in', 'required', 'type', 'description']]
|
|
923
|
+
for (const p of params) {
|
|
924
|
+
rows.push([
|
|
925
|
+
p.name || '-',
|
|
926
|
+
p.in || '-',
|
|
927
|
+
p.required ? 'yes' : 'no',
|
|
928
|
+
paramType(p),
|
|
929
|
+
(p.description || '').replaceAll('\n', ' ').slice(0, 80),
|
|
930
|
+
])
|
|
931
|
+
}
|
|
932
|
+
printTable(rows)
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
function printOperation(op, spec) {
|
|
936
|
+
const baseUrl = spec.servers?.[0] || ''
|
|
937
|
+
const full = baseUrl ? `${baseUrl}${op.path}` : op.path
|
|
938
|
+
|
|
939
|
+
const id = op.operationId ? `${op.specId}:${op.operationId}` : `${op.specId}:${op.method.toUpperCase()} ${op.path}`
|
|
940
|
+
|
|
941
|
+
console.log(id)
|
|
942
|
+
console.log(`${op.method.toUpperCase()} ${full}`)
|
|
943
|
+
|
|
944
|
+
if (op.summary) console.log(`\n${op.summary}`)
|
|
945
|
+
if (op.deprecated) console.log(`\nDeprecated: yes`)
|
|
946
|
+
|
|
947
|
+
const auth = op.securityLabel
|
|
948
|
+
if (auth) console.log(`\nAuth: ${auth}`)
|
|
949
|
+
|
|
950
|
+
if (op.tags?.length) console.log(`Tags: ${op.tags.join(', ')}`)
|
|
951
|
+
|
|
952
|
+
if (op.description) {
|
|
953
|
+
const desc = String(op.description).trim().replace(/\n{3,}/g, '\n\n')
|
|
954
|
+
const short = desc.length > 800 ? `${desc.slice(0, 800)}\n...` : desc
|
|
955
|
+
console.log(`\n${short}`)
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
const params = splitParams(op.parameters || [])
|
|
959
|
+
printParamsBlock('Path params', params.path)
|
|
960
|
+
printParamsBlock('Query params', params.query)
|
|
961
|
+
printParamsBlock('Header params', params.header)
|
|
962
|
+
|
|
963
|
+
if (op.requestBody?.content) {
|
|
964
|
+
console.log('\nBody')
|
|
965
|
+
const required = op.requestBody.required ? 'required' : 'optional'
|
|
966
|
+
console.log(`required: ${required}`)
|
|
967
|
+
|
|
968
|
+
const contentTypes = Object.keys(op.requestBody.content)
|
|
969
|
+
for (const ct of contentTypes) {
|
|
970
|
+
const schema = op.requestBody.content?.[ct]?.schema
|
|
971
|
+
if (!schema) continue
|
|
972
|
+
console.log(`\n${ct}`)
|
|
973
|
+
const lines = formatSchemaPreview(schema, spec.doc, { depth: 3, maxProps: 12 })
|
|
974
|
+
for (const l of lines) console.log(l)
|
|
975
|
+
|
|
976
|
+
if (ct === 'application/json') {
|
|
977
|
+
const ex = exampleFromSchema(schema, spec.doc, { depth: 3, includeOptional: false })
|
|
978
|
+
if (ex && typeof ex === 'object') {
|
|
979
|
+
console.log('\nexample (required fields)')
|
|
980
|
+
console.log(JSON.stringify(ex, null, 2))
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (op.responses && Object.keys(op.responses).length) {
|
|
987
|
+
console.log('\nResponses')
|
|
988
|
+
const codes = Object.keys(op.responses).sort((a, b) => {
|
|
989
|
+
const na = Number(a)
|
|
990
|
+
const nb = Number(b)
|
|
991
|
+
if (Number.isFinite(na) && Number.isFinite(nb)) return na - nb
|
|
992
|
+
if (a === 'default') return 1
|
|
993
|
+
if (b === 'default') return -1
|
|
994
|
+
return a.localeCompare(b)
|
|
995
|
+
})
|
|
996
|
+
|
|
997
|
+
for (const code of codes) {
|
|
998
|
+
const resp = derefObject(op.responses[code], spec.doc)
|
|
999
|
+
const desc = resp?.description ? ` - ${String(resp.description).replaceAll('\n', ' ').slice(0, 80)}` : ''
|
|
1000
|
+
console.log(`\n${code}${desc}`)
|
|
1001
|
+
|
|
1002
|
+
const content = resp?.content || {}
|
|
1003
|
+
for (const [ct, media] of Object.entries(content)) {
|
|
1004
|
+
if (!media?.schema) continue
|
|
1005
|
+
console.log(`${ct}`)
|
|
1006
|
+
const lines = formatSchemaPreview(media.schema, spec.doc, { depth: 3, maxProps: 12 })
|
|
1007
|
+
for (const l of lines) console.log(l)
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
console.log('\ncurl')
|
|
1013
|
+
console.log(formatCurl(op, spec))
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
function replacePathParams(p) {
|
|
1017
|
+
return p.replaceAll(/\{([^}]+)\}/g, '<$1>')
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
function formatCurl(op, spec) {
|
|
1021
|
+
const baseUrl = spec.servers?.[0] || ''
|
|
1022
|
+
let url = baseUrl ? `${baseUrl}${replacePathParams(op.path)}` : replacePathParams(op.path)
|
|
1023
|
+
|
|
1024
|
+
const requiredQuery = (op.parameters || [])
|
|
1025
|
+
.filter((p) => p?.in === 'query' && p?.required && p?.name)
|
|
1026
|
+
.map((p) => `${encodeURIComponent(p.name)}=<${p.name}>`)
|
|
1027
|
+
if (requiredQuery.length) url += `?${requiredQuery.join('&')}`
|
|
1028
|
+
|
|
1029
|
+
const lines = []
|
|
1030
|
+
lines.push(`curl -X ${op.method.toUpperCase()} '${url}' \\`)
|
|
1031
|
+
|
|
1032
|
+
// auth header if we can infer it
|
|
1033
|
+
const schemes = spec?.doc?.components?.securitySchemes || {}
|
|
1034
|
+
const sec = Array.isArray(op.security) ? op.security : null
|
|
1035
|
+
const candidates = (sec || []).filter((x) => x && typeof x === 'object')
|
|
1036
|
+
const preferred =
|
|
1037
|
+
candidates.find((req) =>
|
|
1038
|
+
Object.keys(req).some((name) => schemes[name]?.type === 'apiKey' && schemes[name]?.in === 'header'),
|
|
1039
|
+
) || candidates[0]
|
|
1040
|
+
|
|
1041
|
+
for (const name of Object.keys(preferred || {})) {
|
|
1042
|
+
const s = schemes[name]
|
|
1043
|
+
if (s?.type === 'apiKey' && s.in === 'header' && s.name) {
|
|
1044
|
+
lines.push(` -H '${s.name}: $KAPSO_API_KEY' \\`)
|
|
1045
|
+
} else if (s?.type === 'http' && s.scheme === 'bearer') {
|
|
1046
|
+
lines.push(` -H 'Authorization: Bearer $ACCESS_TOKEN' \\`)
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// content-type + body for JSON
|
|
1051
|
+
const jsonSchema = op.requestBody?.content?.['application/json']?.schema
|
|
1052
|
+
if (jsonSchema) {
|
|
1053
|
+
const ex = exampleFromSchema(jsonSchema, spec.doc, { depth: 4, includeOptional: false })
|
|
1054
|
+
lines.push(` -H 'Content-Type: application/json' \\`)
|
|
1055
|
+
lines.push(` -d '${JSON.stringify(ex ?? {}, null, 0)}'`)
|
|
1056
|
+
return lines.join('\n')
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// trim trailing backslash
|
|
1060
|
+
lines[lines.length - 1] = lines[lines.length - 1].replace(/ \\\\$/, '')
|
|
1061
|
+
return lines.join('\n')
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
function printSchemaDetails(match, specs, { includeUsedBy = true } = {}) {
|
|
1065
|
+
const { spec, name, schema } = match
|
|
1066
|
+
console.log(`${spec.id}:${name}`)
|
|
1067
|
+
|
|
1068
|
+
const normalized = schema?.allOf ? mergeAllOf(schema, spec.doc) : schema
|
|
1069
|
+
const typeStr = schemaTypeString(normalized)
|
|
1070
|
+
console.log(typeStr)
|
|
1071
|
+
|
|
1072
|
+
if (normalized?.description) console.log(`\n${String(normalized.description).trim()}`)
|
|
1073
|
+
|
|
1074
|
+
const required = normalized?.required || []
|
|
1075
|
+
if (required.length) console.log(`\nrequired: ${required.join(', ')}`)
|
|
1076
|
+
|
|
1077
|
+
if (normalized?.properties || normalized?.items) {
|
|
1078
|
+
console.log('\nshape')
|
|
1079
|
+
const lines = formatSchemaPreview(normalized, spec.doc, { depth: 3, maxProps: 25 })
|
|
1080
|
+
for (const l of lines) console.log(l)
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
const ex = exampleFromSchema(normalized, spec.doc, { depth: 4, includeOptional: false })
|
|
1084
|
+
if (ex && typeof ex === 'object') {
|
|
1085
|
+
console.log('\nexample (required fields)')
|
|
1086
|
+
console.log(JSON.stringify(ex, null, 2))
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
if (includeUsedBy) {
|
|
1090
|
+
const usedBy = []
|
|
1091
|
+
for (const s of specs) {
|
|
1092
|
+
for (const op of s.operations) {
|
|
1093
|
+
if (op.refsUsed?.has(name)) usedBy.push(op)
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
if (usedBy.length) {
|
|
1098
|
+
console.log('\nused by')
|
|
1099
|
+
const rows = [['spec', 'operationId', 'method', 'path']]
|
|
1100
|
+
for (const op of usedBy.slice(0, 30)) rows.push([op.specId, op.operationId || '-', op.method.toUpperCase(), op.path])
|
|
1101
|
+
printTable(rows)
|
|
1102
|
+
if (usedBy.length > 30) console.log(`... (${usedBy.length - 30} more)`)
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function printWhere(specs, schemaQuery, { specHint, json, limit = 30 } = {}) {
|
|
1108
|
+
const matches = findSchema(specs, schemaQuery, { specHint })
|
|
1109
|
+
if (!matches.length) die(`Schema not found: ${schemaQuery}`)
|
|
1110
|
+
if (matches.length > 1 && !schemaQuery.includes(':')) {
|
|
1111
|
+
die(`Schema exists in multiple specs. Use specId:SchemaName\n${matches.map((m) => `- ${m.spec.id}:${m.name}`).join('\n')}`)
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
const { name } = matches[0]
|
|
1115
|
+
const usedBy = []
|
|
1116
|
+
for (const s of specs) {
|
|
1117
|
+
if (specHint && s.id !== specHint) continue
|
|
1118
|
+
for (const op of s.operations) {
|
|
1119
|
+
if (op.refsUsed?.has(name)) usedBy.push(op)
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
if (json) {
|
|
1124
|
+
console.log(
|
|
1125
|
+
JSON.stringify(
|
|
1126
|
+
usedBy.slice(0, limit).map((o) => ({
|
|
1127
|
+
spec: o.specId,
|
|
1128
|
+
operationId: o.operationId,
|
|
1129
|
+
method: o.method,
|
|
1130
|
+
path: o.path,
|
|
1131
|
+
summary: o.summary,
|
|
1132
|
+
})),
|
|
1133
|
+
null,
|
|
1134
|
+
2,
|
|
1135
|
+
),
|
|
1136
|
+
)
|
|
1137
|
+
return
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
if (!usedBy.length) {
|
|
1141
|
+
console.log('No operations reference this schema (via $ref).')
|
|
1142
|
+
return
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
const rows = [['spec', 'operationId', 'method', 'path', 'summary']]
|
|
1146
|
+
for (const o of usedBy.slice(0, limit)) rows.push([o.specId, o.operationId || '-', o.method.toUpperCase(), o.path, (o.summary || '').slice(0, 80)])
|
|
1147
|
+
printTable(rows)
|
|
1148
|
+
if (usedBy.length > limit) console.log(`... (${usedBy.length - limit} more)`)
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
async function main() {
|
|
1152
|
+
const { opts, command, rest } = parseArgs(process.argv.slice(2))
|
|
1153
|
+
if (!command) printHelp(1)
|
|
1154
|
+
|
|
1155
|
+
let sources = []
|
|
1156
|
+
let sourceMode = 'explicit'
|
|
1157
|
+
|
|
1158
|
+
if (opts.files.length) {
|
|
1159
|
+
sources = opts.files
|
|
1160
|
+
sourceMode = 'explicit'
|
|
1161
|
+
} else if (opts.all) {
|
|
1162
|
+
const apiDir = findLocalApiDir()
|
|
1163
|
+
sources = apiDir ? walk(apiDir, { filePattern: /^openapi-.*\.ya?ml$/ }) : []
|
|
1164
|
+
sourceMode = 'explicit'
|
|
1165
|
+
} else {
|
|
1166
|
+
sources = deducePublishedOpenApiUrls(DEFAULT_PUBLISHED_WHATSAPP_OPENAPI)
|
|
1167
|
+
sourceMode = 'default_remote'
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
const specs = await loadSpecsAsync({ sources, sourceMode, specFilter: opts.spec })
|
|
1171
|
+
|
|
1172
|
+
if (command === 'specs') return printSpecs(specs, { json: opts.json })
|
|
1173
|
+
if (command === 'tags') return printTags(specs, { specHint: opts.spec })
|
|
1174
|
+
if (command === 'ops') return printOps(specs, { specHint: opts.spec, tag: opts.tag, q: opts.q, json: opts.json, limit: opts.limit })
|
|
1175
|
+
if (command === 'search') {
|
|
1176
|
+
const q = rest.join(' ').trim()
|
|
1177
|
+
if (!q) die('Usage: search <query>')
|
|
1178
|
+
const res = search(specs, q, { specHint: opts.spec, limit: opts.limit })
|
|
1179
|
+
if (opts.json) {
|
|
1180
|
+
return console.log(
|
|
1181
|
+
JSON.stringify(
|
|
1182
|
+
{
|
|
1183
|
+
ops: res.ops.map((o) => ({
|
|
1184
|
+
spec: o.specId,
|
|
1185
|
+
operationId: o.operationId,
|
|
1186
|
+
method: o.method,
|
|
1187
|
+
path: o.path,
|
|
1188
|
+
summary: o.summary,
|
|
1189
|
+
})),
|
|
1190
|
+
schemas: res.schemas,
|
|
1191
|
+
},
|
|
1192
|
+
null,
|
|
1193
|
+
2,
|
|
1194
|
+
),
|
|
1195
|
+
)
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
if (!res.ops.length && !res.schemas.length) {
|
|
1199
|
+
console.log('No matches.')
|
|
1200
|
+
return
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
if (res.ops.length) {
|
|
1204
|
+
console.log('ops')
|
|
1205
|
+
const rows = [['spec', 'operationId', 'method', 'path', 'summary']]
|
|
1206
|
+
for (const o of res.ops) rows.push([o.specId, o.operationId || '-', o.method.toUpperCase(), o.path, (o.summary || '').slice(0, 80)])
|
|
1207
|
+
printTable(rows)
|
|
1208
|
+
}
|
|
1209
|
+
if (res.schemas.length) {
|
|
1210
|
+
console.log('\nschemas')
|
|
1211
|
+
const rows = [['spec', 'name']]
|
|
1212
|
+
for (const s of res.schemas) rows.push([s.specId, s.name])
|
|
1213
|
+
printTable(rows)
|
|
1214
|
+
}
|
|
1215
|
+
return
|
|
1216
|
+
}
|
|
1217
|
+
if (command === 'op') {
|
|
1218
|
+
const q = rest.join(' ').trim()
|
|
1219
|
+
if (!q) die('Usage: op <operationId | specId:operationId | "METHOD /path">')
|
|
1220
|
+
const matches = findOperation(specs, q, { specHint: opts.spec })
|
|
1221
|
+
if (!matches.length) {
|
|
1222
|
+
const res = search(specs, q, { specHint: opts.spec, limit: 10 })
|
|
1223
|
+
if (res.ops.length) {
|
|
1224
|
+
console.log(`Operation not found: ${q}\n`)
|
|
1225
|
+
console.log('closest ops')
|
|
1226
|
+
const rows = [['spec', 'operationId', 'method', 'path', 'summary']]
|
|
1227
|
+
for (const o of res.ops) rows.push([o.specId, o.operationId || '-', o.method.toUpperCase(), o.path, (o.summary || '').slice(0, 80)])
|
|
1228
|
+
printTable(rows)
|
|
1229
|
+
process.exit(1)
|
|
1230
|
+
}
|
|
1231
|
+
die(`Operation not found: ${q}`)
|
|
1232
|
+
}
|
|
1233
|
+
if (matches.length > 1 && !q.includes(':') && !q.match(/^(get|post|put|patch|delete|options|head)\\s+/i)) {
|
|
1234
|
+
die(`OperationId exists in multiple specs. Use specId:operationId\n${matches.map((m) => `- ${m.specId}:${m.operationId}`).join('\n')}`)
|
|
1235
|
+
}
|
|
1236
|
+
const op = matches[0]
|
|
1237
|
+
const spec = specs.find((s) => s.id === op.specId)
|
|
1238
|
+
if (!spec) die(`Internal error: missing spec ${op.specId}`)
|
|
1239
|
+
printOperation(op, spec)
|
|
1240
|
+
return
|
|
1241
|
+
}
|
|
1242
|
+
if (command === 'schema') {
|
|
1243
|
+
const q = rest.join(' ').trim()
|
|
1244
|
+
if (!q) die('Usage: schema <SchemaName | specId:SchemaName>')
|
|
1245
|
+
const matches = findSchema(specs, q, { specHint: opts.spec })
|
|
1246
|
+
if (!matches.length) {
|
|
1247
|
+
const res = search(specs, q, { specHint: opts.spec, limit: 10 })
|
|
1248
|
+
if (res.schemas.length) {
|
|
1249
|
+
console.log(`Schema not found: ${q}\n`)
|
|
1250
|
+
console.log('closest schemas')
|
|
1251
|
+
const rows = [['spec', 'name']]
|
|
1252
|
+
for (const s of res.schemas) rows.push([s.specId, s.name])
|
|
1253
|
+
printTable(rows)
|
|
1254
|
+
process.exit(1)
|
|
1255
|
+
}
|
|
1256
|
+
die(`Schema not found: ${q}`)
|
|
1257
|
+
}
|
|
1258
|
+
if (matches.length > 1 && !q.includes(':')) {
|
|
1259
|
+
die(`Schema exists in multiple specs. Use specId:SchemaName\n${matches.map((m) => `- ${m.spec.id}:${m.name}`).join('\n')}`)
|
|
1260
|
+
}
|
|
1261
|
+
printSchemaDetails(matches[0], specs, { includeUsedBy: true })
|
|
1262
|
+
return
|
|
1263
|
+
}
|
|
1264
|
+
if (command === 'where') {
|
|
1265
|
+
const q = rest.join(' ').trim()
|
|
1266
|
+
if (!q) die('Usage: where <SchemaName | specId:SchemaName>')
|
|
1267
|
+
return printWhere(specs, q, { specHint: opts.spec, json: opts.json, limit: opts.limit })
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
die(`Unknown command: ${command}`)
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
main().catch((e) => die(e?.stack || e?.message || String(e)))
|