@dsmm/dsmm 0.1.8 → 0.2.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/README.md +40 -22
- package/agent-presets/dsmm-builder/agent.cordis.yml +1949 -39
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +436 -14
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +56 -14
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-coding/agent.cordis.yml +588 -0
- package/agent-presets/dsmm-coding/preset.yml +3 -0
- package/agent-presets/dsmm-complex/agent.cordis.yml +1140 -0
- package/agent-presets/dsmm-complex/preset.yml +3 -0
- package/agent-presets/dsmm-creative/agent.cordis.yml +536 -12
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1163 -0
- package/agent-presets/dsmm-cross-cutting/preset.yml +3 -0
- package/agent-presets/dsmm-deep/agent.cordis.yml +1173 -0
- package/agent-presets/dsmm-deep/preset.yml +3 -0
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +56 -14
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-documenting/agent.cordis.yml +581 -0
- package/agent-presets/dsmm-documenting/preset.yml +3 -0
- package/agent-presets/dsmm-frontend/agent.cordis.yml +580 -0
- package/agent-presets/dsmm-frontend/preset.yml +3 -0
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +572 -0
- package/agent-presets/dsmm-hard-reasoning/preset.yml +3 -0
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +56 -14
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +546 -0
- package/agent-presets/dsmm-normal-task/preset.yml +3 -0
- package/agent-presets/dsmm-oracle/agent.cordis.yml +421 -12
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +421 -12
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +2023 -43
- package/agent-presets/dsmm-orchestrator/preset.yml +1 -1
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +416 -13
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +462 -13
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-quick/agent.cordis.yml +119 -0
- package/agent-presets/dsmm-quick/preset.yml +3 -0
- package/agent-presets/dsmm-research/agent.cordis.yml +141 -0
- package/agent-presets/dsmm-research/preset.yml +3 -0
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +420 -13
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/cordis.patch.yml +1 -5
- package/docs/agent-presets.md +64 -15
- package/docs/compatibility.md +67 -17
- package/docs/design.md +41 -0
- package/docs/lsp.md +12 -2
- package/docs/migration-from-ocmm.md +8 -0
- package/docs/profiles.md +42 -16
- package/docs/releasing.md +100 -28
- package/docs/roadmap.md +6 -0
- package/docs/runtime-recovery.md +12 -0
- package/docs/safety-guards.md +7 -3
- package/docs/settings-status.md +148 -7
- package/docs/skill-sync.md +52 -14
- package/lib/client/DeploymentPage.d.ts +18 -0
- package/lib/client/DeploymentPage.js +120 -0
- package/lib/client/ProfilesSection.js +4 -2
- package/lib/client/deployment-controller.d.ts +50 -0
- package/lib/client/deployment-controller.js +193 -0
- package/lib/client/deployment-data.d.ts +16 -0
- package/lib/client/deployment-data.js +109 -0
- package/lib/client/deployment-locales.d.ts +66 -0
- package/lib/client/deployment-locales.js +72 -0
- package/lib/client/index.js +50 -0
- package/lib/client/locales.d.ts +4 -0
- package/lib/client/locales.js +4 -2
- package/lib/client/plugins-contract.d.ts +27 -0
- package/lib/client/plugins-contract.js +2 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +16 -0
- package/lib/client.js +1048 -29
- package/lib/commands.js +3 -0
- package/lib/config-file-store.d.ts +23 -0
- package/lib/config-file-store.js +67 -0
- package/lib/deployment-config.d.ts +37 -0
- package/lib/deployment-config.js +184 -0
- package/lib/dsh-home.d.ts +3 -0
- package/lib/dsh-home.js +10 -0
- package/lib/dsh-types.d.ts +12 -65
- package/lib/guards.d.ts +2 -1
- package/lib/guards.js +19 -2
- package/lib/index.d.ts +8 -1
- package/lib/index.js +115 -25
- package/lib/lsp.d.ts +13 -0
- package/lib/lsp.js +60 -0
- package/lib/mode.js +42 -47
- package/lib/model-routing.js +5 -2
- package/lib/modules.d.ts +27 -0
- package/lib/modules.js +21 -0
- package/lib/native-scope.d.ts +9 -0
- package/lib/native-scope.js +20 -0
- package/lib/plan-validation.js +6 -44
- package/lib/preset-materializer.js +2 -0
- package/lib/preset-registry.d.ts +1 -1
- package/lib/preset-registry.js +7 -4
- package/lib/preset-skills.d.ts +4 -1
- package/lib/preset-skills.js +60 -19
- package/lib/profile-remote.d.ts +14 -0
- package/lib/profile-remote.js +197 -4
- package/lib/profile-rpc.d.ts +24 -1
- package/lib/profile-rpc.js +139 -1
- package/lib/profile-runtime.d.ts +24 -0
- package/lib/profile-runtime.js +177 -33
- package/lib/profile-store.d.ts +45 -1
- package/lib/profile-store.js +236 -102
- package/lib/profile-types.d.ts +55 -0
- package/lib/prompt-content.d.ts +25 -0
- package/lib/prompt-content.js +27 -0
- package/lib/prompts.d.ts +8 -2
- package/lib/prompts.js +46 -34
- package/lib/role-policy.d.ts +51 -0
- package/lib/role-policy.js +224 -0
- package/lib/role-providers.d.ts +6 -2
- package/lib/role-providers.js +72 -39
- package/lib/role-subagents.d.ts +6 -2
- package/lib/role-subagents.js +187 -48
- package/lib/roles.d.ts +16 -4
- package/lib/roles.js +86 -186
- package/lib/runtime-recovery.js +16 -5
- package/lib/session-scope.js +2 -0
- package/lib/settings.d.ts +69 -1
- package/lib/settings.js +262 -91
- package/lib/skills.d.ts +24 -9
- package/lib/skills.js +114 -35
- package/lib/state.d.ts +10 -6
- package/lib/state.js +48 -49
- package/lib/status.d.ts +25 -0
- package/lib/status.js +47 -9
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +19 -2
- package/prompts/deepwork.md +144 -20
- package/prompts/source/agents/clarifier.md +45 -0
- package/prompts/source/agents/orchestrator.md +63 -0
- package/prompts/source/agents/plan-critic.md +25 -0
- package/prompts/source/agents/planner.md +19 -0
- package/prompts/source/agents/reviewer.md +17 -0
- package/prompts/source/catalog.json +548 -0
- package/prompts/source/category/coding.md +46 -0
- package/prompts/source/category/complex.md +29 -0
- package/prompts/source/category/creative.md +38 -0
- package/prompts/source/category/cross-cutting.md +52 -0
- package/prompts/source/category/deep.md +62 -0
- package/prompts/source/category/documenting.md +62 -0
- package/prompts/source/category/frontend.md +38 -0
- package/prompts/source/category/hard-reasoning.md +53 -0
- package/prompts/source/category/normal-task.md +27 -0
- package/prompts/source/category/quick.md +34 -0
- package/prompts/source/category/research.md +56 -0
- package/prompts/source/deepwork/claude-opus-5.md +28 -0
- package/prompts/source/deepwork/codex.md +9 -0
- package/prompts/source/deepwork/default.md +129 -0
- package/prompts/source/deepwork/gemini.md +184 -0
- package/prompts/source/deepwork/glm.md +256 -0
- package/prompts/source/deepwork/gpt.md +43 -0
- package/prompts/source/deepwork/kimi-k27.md +13 -0
- package/prompts/source/deepwork/planner.md +41 -0
- package/prompts/source/deepwork/swe-2.md +13 -0
- package/prompts/source/manifest.json +3118 -0
- package/prompts/source/shared/dsh-host-contract.md +6 -0
- package/prompts/source/shared/locale.md +8 -0
- package/prompts/source/shared/shell-safety.md +7 -0
- package/prompts/source/terminal/builder.md +13 -0
- package/prompts/source/terminal/clarifier.md +41 -0
- package/prompts/source/terminal/code-search.md +39 -0
- package/prompts/source/terminal/coding.md +41 -0
- package/prompts/source/terminal/complex.md +43 -0
- package/prompts/source/terminal/creative.md +41 -0
- package/prompts/source/terminal/cross-cutting.md +43 -0
- package/prompts/source/terminal/deep.md +43 -0
- package/prompts/source/terminal/doc-search.md +39 -0
- package/prompts/source/terminal/documenting.md +41 -0
- package/prompts/source/terminal/frontend.md +41 -0
- package/prompts/source/terminal/hard-reasoning.md +41 -0
- package/prompts/source/terminal/media-reader.md +39 -0
- package/prompts/source/terminal/normal-task.md +41 -0
- package/prompts/source/terminal/oracle-2nd.md +53 -0
- package/prompts/source/terminal/oracle.md +53 -0
- package/prompts/source/terminal/orchestrator.md +26 -0
- package/prompts/source/terminal/plan-critic.md +41 -0
- package/prompts/source/terminal/planner.md +42 -0
- package/prompts/source/terminal/quick.md +39 -0
- package/prompts/source/terminal/research.md +39 -0
- package/prompts/source/terminal/reviewer.md +53 -0
- package/skills/ast-grep/LICENSE +21 -0
- package/skills/ast-grep/README.md +138 -0
- package/skills/ast-grep/SKILL.md +284 -0
- package/skills/ast-grep/SOURCE +1 -0
- package/skills/ast-grep/install.ps1 +235 -0
- package/skills/ast-grep/install.sh +286 -0
- package/skills/ast-grep/references/cli.md +233 -0
- package/skills/ast-grep/references/install.md +168 -0
- package/skills/ast-grep/references/patterns.md +149 -0
- package/skills/ast-grep/references/pitfalls.md +305 -0
- package/skills/ast-grep/references/recipes.md +404 -0
- package/skills/ast-grep/references/sgconfig.md +250 -0
- package/skills/ast-grep/references/yaml-rules.md +511 -0
- package/skills/ast-grep/scripts/ast_grep_helper.py +760 -0
- package/skills/ast-grep/tests/smoke.ps1 +129 -0
- package/skills/ast-grep/tests/smoke.sh +212 -0
- package/skills/ast-grep/tests/test_resolver.py +154 -0
- package/skills/brainstorming/SKILL.md +102 -9
- package/skills/coding-agent-sessions/LICENSE-UPSTREAM.md +82 -0
- package/skills/coding-agent-sessions/NOTICE.md +24 -0
- package/skills/coding-agent-sessions/SKILL.md +144 -0
- package/skills/coding-agent-sessions/agents/openai.yaml +4 -0
- package/skills/coding-agent-sessions/pyrightconfig.json +5 -0
- package/skills/coding-agent-sessions/references/all-platforms.md +77 -0
- package/skills/coding-agent-sessions/references/claude.md +34 -0
- package/skills/coding-agent-sessions/references/codex.md +32 -0
- package/skills/coding-agent-sessions/references/opencode.md +45 -0
- package/skills/coding-agent-sessions/references/senpi.md +29 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/__init__.py +1 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/aside_scanner.py +140 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/claude.py +66 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/cli.py +283 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/codex.py +105 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/file_scanners.py +275 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/jsonio.py +55 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/kiro_scanner.py +91 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/opencode.py +289 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/scanners.py +104 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_optional_scanners.py +203 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/sqlite_scanners.py +177 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/timeparse.py +51 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/transcript.py +149 -0
- package/skills/coding-agent-sessions/scripts/agent_sessions/types.py +57 -0
- package/skills/coding-agent-sessions/scripts/find-agent-sessions.py +19 -0
- package/skills/coding-agent-sessions/scripts/tests/test_agent_sessions.py +322 -0
- package/skills/coding-agent-sessions/scripts/tests/test_aside_scanner.py +131 -0
- package/skills/coding-agent-sessions/scripts/tests/test_cli_contract.py +126 -0
- package/skills/coding-agent-sessions/scripts/tests/test_extended_scanners.py +262 -0
- package/skills/coding-agent-sessions/scripts/tests/test_optional_sqlite_scanners.py +79 -0
- package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -0
- package/skills/debugging/SKILL.md +125 -4
- package/skills/debugging/references/logging.md +2 -0
- package/skills/debugging/references/methodology/00-setup.md +2 -0
- package/skills/debugging/references/methodology/02-investigate.md +8 -2
- package/skills/debugging/references/methodology/03-flaky-triage.md +3 -1
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +4 -2
- package/skills/debugging/references/methodology/05-escalate.md +2 -0
- package/skills/debugging/references/methodology/06-fix.md +2 -0
- package/skills/debugging/references/methodology/08-qa.md +2 -0
- package/skills/debugging/references/methodology/09-cleanup.md +2 -0
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +4 -2
- package/skills/debugging/references/runtimes/bundled-js-binary.md +2 -0
- package/skills/debugging/references/runtimes/go.md +2 -0
- package/skills/debugging/references/runtimes/native-binary.md +2 -0
- package/skills/debugging/references/runtimes/node.md +2 -0
- package/skills/debugging/references/runtimes/python.md +2 -0
- package/skills/debugging/references/runtimes/rust.md +2 -0
- package/skills/debugging/references/scripts/dap.test.mjs +539 -0
- package/skills/debugging/references/scripts/fixture-adapter.mjs +164 -0
- package/skills/debugging/references/tools/dap.md +3 -1
- package/skills/debugging/references/tools/ghidra.md +2 -0
- package/skills/debugging/references/tools/playwright-cli.md +2 -0
- package/skills/debugging/references/tools/pwndbg.md +2 -0
- package/skills/debugging/references/tools/pwntools.md +2 -0
- package/skills/dispatching-parallel-agents/SKILL.md +94 -7
- package/skills/frontend/.frontend-materialized.json +856 -0
- package/skills/frontend/ATTRIBUTION.md +37 -0
- package/skills/frontend/LICENSE-Apache-2.0.txt +201 -0
- package/skills/frontend/LICENSE-taste-skill.txt +21 -0
- package/skills/frontend/LICENSE-ui-ux-pro-max.txt +21 -0
- package/skills/frontend/SKILL.md +142 -0
- package/skills/frontend/references/design/README.md +256 -0
- package/skills/frontend/references/design/_INDEX.md +206 -0
- package/skills/frontend/references/design/airbnb.md +393 -0
- package/skills/frontend/references/design/airtable.md +92 -0
- package/skills/frontend/references/design/apple.md +250 -0
- package/skills/frontend/references/design/aside.md +211 -0
- package/skills/frontend/references/design/binance.md +348 -0
- package/skills/frontend/references/design/bmw.md +183 -0
- package/skills/frontend/references/design/brutalist-skill.md +92 -0
- package/skills/frontend/references/design/bugatti.md +271 -0
- package/skills/frontend/references/design/cal.md +262 -0
- package/skills/frontend/references/design/claude.md +315 -0
- package/skills/frontend/references/design/clay.md +307 -0
- package/skills/frontend/references/design/clickhouse.md +284 -0
- package/skills/frontend/references/design/clone-from-url.md +69 -0
- package/skills/frontend/references/design/cohere.md +269 -0
- package/skills/frontend/references/design/coinbase.md +132 -0
- package/skills/frontend/references/design/composio.md +310 -0
- package/skills/frontend/references/design/cursor.md +312 -0
- package/skills/frontend/references/design/design-system-architecture.md +250 -0
- package/skills/frontend/references/design/elevenlabs.md +268 -0
- package/skills/frontend/references/design/expo.md +284 -0
- package/skills/frontend/references/design/ferrari.md +317 -0
- package/skills/frontend/references/design/figma.md +223 -0
- package/skills/frontend/references/design/framer.md +249 -0
- package/skills/frontend/references/design/gpt-tasteskill.md +74 -0
- package/skills/frontend/references/design/hashicorp.md +281 -0
- package/skills/frontend/references/design/ibm.md +335 -0
- package/skills/frontend/references/design/image-to-code-skill.md +1228 -0
- package/skills/frontend/references/design/imagegen-brandkit.md +798 -0
- package/skills/frontend/references/design/imagegen-frontend-mobile.md +1465 -0
- package/skills/frontend/references/design/imagegen-frontend-web.md +987 -0
- package/skills/frontend/references/design/interaction-skill.md +52 -0
- package/skills/frontend/references/design/intercom.md +149 -0
- package/skills/frontend/references/design/kraken.md +128 -0
- package/skills/frontend/references/design/lamborghini.md +291 -0
- package/skills/frontend/references/design/linear.app.md +370 -0
- package/skills/frontend/references/design/lovable.md +301 -0
- package/skills/frontend/references/design/mastercard.md +368 -0
- package/skills/frontend/references/design/meta.md +369 -0
- package/skills/frontend/references/design/minimalist-skill.md +85 -0
- package/skills/frontend/references/design/minimax.md +260 -0
- package/skills/frontend/references/design/mintlify.md +329 -0
- package/skills/frontend/references/design/miro.md +111 -0
- package/skills/frontend/references/design/mistral.ai.md +264 -0
- package/skills/frontend/references/design/mongodb.md +269 -0
- package/skills/frontend/references/design/nike.md +366 -0
- package/skills/frontend/references/design/notion.md +312 -0
- package/skills/frontend/references/design/nvidia.md +296 -0
- package/skills/frontend/references/design/ollama.md +270 -0
- package/skills/frontend/references/design/opencode.ai.md +284 -0
- package/skills/frontend/references/design/output-skill.md +49 -0
- package/skills/frontend/references/design/pinterest.md +233 -0
- package/skills/frontend/references/design/playstation.md +367 -0
- package/skills/frontend/references/design/posthog.md +259 -0
- package/skills/frontend/references/design/raycast.md +271 -0
- package/skills/frontend/references/design/react-dev-tooling-skill.md +232 -0
- package/skills/frontend/references/design/redesign-skill.md +178 -0
- package/skills/frontend/references/design/renault.md +314 -0
- package/skills/frontend/references/design/replicate.md +264 -0
- package/skills/frontend/references/design/resend.md +306 -0
- package/skills/frontend/references/design/revolut.md +188 -0
- package/skills/frontend/references/design/runwayml.md +247 -0
- package/skills/frontend/references/design/sanity.md +360 -0
- package/skills/frontend/references/design/sentry.md +265 -0
- package/skills/frontend/references/design/shopify.md +353 -0
- package/skills/frontend/references/design/soft-skill.md +98 -0
- package/skills/frontend/references/design/spacex.md +197 -0
- package/skills/frontend/references/design/spotify.md +249 -0
- package/skills/frontend/references/design/starbucks.md +583 -0
- package/skills/frontend/references/design/stitch-design-example.md +121 -0
- package/skills/frontend/references/design/stitch-skill.md +184 -0
- package/skills/frontend/references/design/stripe.md +325 -0
- package/skills/frontend/references/design/supabase.md +258 -0
- package/skills/frontend/references/design/superhuman.md +255 -0
- package/skills/frontend/references/design/taste-skill.md +1206 -0
- package/skills/frontend/references/design/tesla.md +289 -0
- package/skills/frontend/references/design/theverge.md +342 -0
- package/skills/frontend/references/design/together.ai.md +266 -0
- package/skills/frontend/references/design/uber.md +298 -0
- package/skills/frontend/references/design/vercel.md +313 -0
- package/skills/frontend/references/design/vodafone.md +426 -0
- package/skills/frontend/references/design/voltagent.md +326 -0
- package/skills/frontend/references/design/warp.md +256 -0
- package/skills/frontend/references/design/webflow.md +95 -0
- package/skills/frontend/references/design/wired.md +281 -0
- package/skills/frontend/references/design/wise.md +176 -0
- package/skills/frontend/references/design/x.ai.md +260 -0
- package/skills/frontend/references/design/zapier.md +331 -0
- package/skills/frontend/references/perfection/README.md +264 -0
- package/skills/frontend/references/perfection/react-perf-tooling.md +234 -0
- package/skills/frontend/references/ui-ux-db/README.md +659 -0
- package/skills/frontend/references/ui-ux-db/data/app-interface.csv +31 -0
- package/skills/frontend/references/ui-ux-db/data/charts.csv +26 -0
- package/skills/frontend/references/ui-ux-db/data/colors.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/google-fonts.csv +1924 -0
- package/skills/frontend/references/ui-ux-db/data/icons.csv +106 -0
- package/skills/frontend/references/ui-ux-db/data/landing.csv +35 -0
- package/skills/frontend/references/ui-ux-db/data/products.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/react-performance.csv +45 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/angular.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/laravel.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/threejs.csv +54 -0
- package/skills/frontend/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/skills/frontend/references/ui-ux-db/data/styles.csv +85 -0
- package/skills/frontend/references/ui-ux-db/data/typography.csv +74 -0
- package/skills/frontend/references/ui-ux-db/data/ui-reasoning.csv +162 -0
- package/skills/frontend/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/skills/frontend/references/ui-ux-db/data/web-interface.csv +31 -0
- package/skills/frontend/references/ui-ux-db/scripts/core.py +262 -0
- package/skills/frontend/references/ui-ux-db/scripts/design_system.py +1148 -0
- package/skills/frontend/references/ui-ux-db/scripts/search.py +114 -0
- package/skills/frontend/scripts/perfection/lighthouse-audit.py +201 -0
- package/skills/git-master/SKILL.md +112 -0
- package/skills/git-master/agents/openai.yaml +13 -0
- package/skills/init-deep/SKILL.md +279 -0
- package/skills/receiving-code-review/SKILL.md +112 -7
- package/skills/remove-ai-slops/SKILL.md +159 -8
- package/skills/requesting-code-review/SKILL.md +96 -3
- package/skills/requesting-code-review/code-reviewer.md +47 -0
- package/skills/subagent-driven-development/SKILL.md +176 -6
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +23 -0
- package/skills/subagent-driven-development/implementer-prompt.md +69 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +32 -0
- package/skills/using-git-worktrees/SKILL.md +141 -0
- package/skills/writing-plans/SKILL.md +121 -7
- package/skills/writing-plans/plan-document-reviewer-prompt.md +38 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
> DSH adapter boundary: resolve this resource from the loaded skill's directory resourceBase. Examples are not authority: installation/download/login, private state, Git writes and destructive operations need exact explicit authorization. Use only tools and native roles actually exposed in the current catalog and allowed by the caller; otherwise use a real direct fallback or report the limitation. Translate shell examples to the active runtime.
|
|
2
|
+
|
|
3
|
+
# Pattern syntax — meta-variables and how patterns parse
|
|
4
|
+
|
|
5
|
+
ast-grep is **not regex**. Patterns are written in the **same syntax as the target language** (TypeScript, Python, Go, etc.), and ast-grep matches them against the AST of every file. The wildcards are called **meta-variables**.
|
|
6
|
+
|
|
7
|
+
This page is the canonical primer. If a pattern fails, 90% of the time it is one of the issues on this page.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## The three meta-variables
|
|
12
|
+
|
|
13
|
+
| Syntax | Matches | Capture |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `$VAR` | exactly **one** AST node | yes, by name |
|
|
16
|
+
| `$$$` | **zero or more** AST nodes (a list) | no (anonymous) |
|
|
17
|
+
| `$$$VAR` | zero or more AST nodes | yes, by name |
|
|
18
|
+
| `$_` | one AST node | no (anonymous) |
|
|
19
|
+
|
|
20
|
+
A meta-variable always replaces a **whole AST node**, never a substring of a node. `$VAR` cannot match the first three characters of an identifier, only an entire identifier (or expression, or statement, depending on context).
|
|
21
|
+
|
|
22
|
+
### Naming rules
|
|
23
|
+
|
|
24
|
+
- Must start with `$`.
|
|
25
|
+
- Then uppercase letters `A-Z`, digits, or underscores.
|
|
26
|
+
- **Valid**: `$X`, `$VAR`, `$VAR_1`, `$_`, `$_VAR`, `$ARG1`.
|
|
27
|
+
- **Invalid**: `$lower`, `$kebab-case`, `$1` (digit first), `$$single` (use `$_` for anonymous).
|
|
28
|
+
|
|
29
|
+
### Same-name = same content
|
|
30
|
+
|
|
31
|
+
Two occurrences of the same metavariable in a pattern must capture **identical text**:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// Pattern
|
|
35
|
+
$X === $X
|
|
36
|
+
|
|
37
|
+
// Matches
|
|
38
|
+
a === a
|
|
39
|
+
foo.bar === foo.bar
|
|
40
|
+
|
|
41
|
+
// Does NOT match
|
|
42
|
+
a === b
|
|
43
|
+
foo === foo.bar
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Useful for finding redundant comparisons, double assignments, etc.
|
|
47
|
+
|
|
48
|
+
### `$$$` is greedy
|
|
49
|
+
|
|
50
|
+
When you write `foo($$$A, b, $$$C)`, the matcher does **not** backtrack or try every possible split. It greedily fills `$$$A` until the pattern can match `b`, then everything left goes into `$$$C`.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// Pattern
|
|
54
|
+
foo($$$A, b, $$$C)
|
|
55
|
+
|
|
56
|
+
// Input
|
|
57
|
+
foo(a, c, b, b, c)
|
|
58
|
+
|
|
59
|
+
// Capture
|
|
60
|
+
$$$A = [a, c]
|
|
61
|
+
$$$C = [b, c]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If you need a different split, restructure the pattern (e.g. add a constraint).
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Patterns must be valid code
|
|
69
|
+
|
|
70
|
+
The pattern itself must parse with the target language's grammar. ast-grep treats `$VAR` and `$$$` as identifiers/argument lists during parsing, then matches structurally.
|
|
71
|
+
|
|
72
|
+
### What goes wrong
|
|
73
|
+
|
|
74
|
+
| Bad pattern | Why it fails | Fix |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `function $NAME` | Function declaration without body — not a valid AST node in JS/TS/Go/Rust. | `function $NAME($$$) { $$$ }` |
|
|
77
|
+
| `def $FN($$$):` | Trailing colon. ast-grep parses as a complete function definition; the colon makes it a statement. | `def $FN($$$)` |
|
|
78
|
+
| `class Foo:` | Same — Python class without body. | `class Foo($$$)` |
|
|
79
|
+
| `fn $NAME` | Rust fn without signature. | `fn $NAME($$$) -> $RET { $$$ }` |
|
|
80
|
+
| `if x` | Incomplete `if` — most languages require the body. | `if x { $$$ }` (curly-brace languages) or `if x: $$$` (Python uses `pattern.context`/`selector` instead) |
|
|
81
|
+
| `"key": "$VAL"` | JSON pattern — a key/value pair on its own isn't valid JSON. | Use `pattern: { context: '{"key": "$VAL"}', selector: pair }` |
|
|
82
|
+
|
|
83
|
+
### When a sub-expression isn't valid on its own
|
|
84
|
+
|
|
85
|
+
Sometimes you want to match an *expression* that the language only allows inside a larger context. Use the `pattern` object form:
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
pattern:
|
|
89
|
+
context: 'class A { $FIELD = $INIT }'
|
|
90
|
+
selector: field_definition
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This says: parse `class A { $FIELD = $INIT }` as a whole, then keep only the `field_definition` sub-tree as the actual pattern.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Strictness levels
|
|
98
|
+
|
|
99
|
+
When CST nodes don't match exactly (extra whitespace, different unnamed punctuation), ast-grep can be more or less forgiving. Pass `--strictness <LEVEL>` on the CLI, or set it in a YAML rule:
|
|
100
|
+
|
|
101
|
+
| Level | Matches |
|
|
102
|
+
|---|---|
|
|
103
|
+
| `cst` | Every node, including unnamed (commas, parens, etc.) |
|
|
104
|
+
| `smart` (default) | All except unnamed nodes in the **target** that aren't in the pattern |
|
|
105
|
+
| `ast` | Only named AST nodes |
|
|
106
|
+
| `relaxed` | Named AST nodes, ignoring comments |
|
|
107
|
+
| `signature` | Only node kinds — text and unnamed nodes ignored |
|
|
108
|
+
|
|
109
|
+
`smart` is almost always what you want. Reach for `signature` when you want to match "any function called `foo`" regardless of arguments.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Testing a pattern
|
|
114
|
+
|
|
115
|
+
Two tools help you confirm a pattern parses the way you expect:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Print the AST of the pattern itself
|
|
119
|
+
sg run -p 'console.log($MSG)' --lang ts --debug-query=ast
|
|
120
|
+
|
|
121
|
+
# Print the parsed CST of a file (great for figuring out kind names)
|
|
122
|
+
sg run -p '$_' --lang ts --debug-query=cst src/example.ts | head -40
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`--debug-query=ast` shows the named AST nodes only (cleaner). `--debug-query=cst` shows everything including punctuation. Both go to stderr, so they don't interfere with stdout JSON.
|
|
126
|
+
|
|
127
|
+
The web playground is also fast: <https://ast-grep.github.io/playground.html>.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## When ast-grep is the wrong tool
|
|
132
|
+
|
|
133
|
+
If your pattern is fundamentally text-shaped, switch to `grep` / `rg`:
|
|
134
|
+
|
|
135
|
+
- Match across multiple files **for any text** → `rg`
|
|
136
|
+
- Cross-language regex with alternation → `rg -e foo -e bar`
|
|
137
|
+
- Match comments only → `rg --type ts '^\s*//.*TODO'`
|
|
138
|
+
- Match URLs, emails, license headers → `rg`
|
|
139
|
+
|
|
140
|
+
ast-grep is for **code structure**: function shapes, call patterns, control flow, type annotations, imports, error handling. If your "pattern" only depends on the bytes of the file and not on the syntax, regex is the right tool.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## See also
|
|
145
|
+
|
|
146
|
+
- `references/pitfalls.md` — concrete regex anti-patterns and language-specific traps.
|
|
147
|
+
- `references/recipes.md` — copy-paste-ready patterns for TS/JS/Py/Go/Rust.
|
|
148
|
+
- `references/yaml-rules.md` — `kind`, `regex`, `inside`, `has`, `all`, `any`, `not`, `matches`.
|
|
149
|
+
- Official: <https://ast-grep.github.io/guide/pattern-syntax.html>
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
> DSH adapter boundary: resolve this resource from the loaded skill's directory resourceBase. Examples are not authority: installation/download/login, private state, Git writes and destructive operations need exact explicit authorization. Use only tools and native roles actually exposed in the current catalog and allowed by the caller; otherwise use a real direct fallback or report the limitation. Translate shell examples to the active runtime.
|
|
2
|
+
|
|
3
|
+
# Pitfalls — what breaks patterns and how to fix them
|
|
4
|
+
|
|
5
|
+
This is the failure-mode field guide. The `scripts/ast_grep_helper.py validate` subcommand mechanically checks for the items in §1 before calling `sg`; the rest are lower-frequency but still common.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Regex syntax does not work
|
|
10
|
+
|
|
11
|
+
ast-grep does **not** interpret regex inside patterns. The following all fail:
|
|
12
|
+
|
|
13
|
+
| Bad | Why | Use instead |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `foo\|bar` | `\|` is regex alternation. ast-grep does not alternate. | Two separate calls, OR `any: [pattern: foo, pattern: bar]` in a YAML rule, OR `rg -e foo -e bar`. |
|
|
16
|
+
| `foo.*bar` | `.*` is a regex wildcard. | `foo($$$) bar` if the gap is a list of nodes; otherwise switch to `rg`. |
|
|
17
|
+
| `\w+`, `\d+`, `\s` | Regex character classes. | `$VAR` to capture any identifier. For digits-only, use `kind: number_literal`. |
|
|
18
|
+
| `[a-z]+` | Regex character class. | No AST equivalent — switch to `rg`. |
|
|
19
|
+
| `^foo$` | Regex anchors. | Anchor by AST: use `kind: program > expression_statement` or use `inside`/`not has`. |
|
|
20
|
+
|
|
21
|
+
**Why this happens**: LLMs default to regex thinking. The mental switch is "ast-grep patterns are *code*, not *strings*."
|
|
22
|
+
|
|
23
|
+
When you genuinely need regex, use the `regex` rule field in YAML (matches node text with Rust regex):
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
rule:
|
|
27
|
+
all:
|
|
28
|
+
- kind: identifier
|
|
29
|
+
- regex: '^[A-Z][a-z]+$' # CamelCase identifiers only
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Note: `regex` matches the **whole node text** — no partial matches. Combine with `kind` or `pattern` for performance.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 2. Incomplete AST nodes
|
|
37
|
+
|
|
38
|
+
Patterns must be valid code that the parser accepts as a complete node. Common mistakes:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
# JS/TS
|
|
42
|
+
function foo ❌ no params, no body
|
|
43
|
+
function $NAME($$$) { $$$ } ✅
|
|
44
|
+
|
|
45
|
+
async function $NAME ❌
|
|
46
|
+
async function $NAME($$$) { $$$ } ✅
|
|
47
|
+
|
|
48
|
+
# Python
|
|
49
|
+
def foo: ❌ trailing colon makes it a statement
|
|
50
|
+
def $FN($$$) ✅
|
|
51
|
+
class Foo: ❌
|
|
52
|
+
class $C($$$) ✅
|
|
53
|
+
|
|
54
|
+
# Go
|
|
55
|
+
func foo ❌
|
|
56
|
+
func $NAME($$$) { $$$ } ✅
|
|
57
|
+
|
|
58
|
+
# Rust
|
|
59
|
+
fn foo ❌
|
|
60
|
+
fn $NAME($$$) -> $RET { $$$ } ✅
|
|
61
|
+
fn $NAME($$$) { $$$ } ✅ (-> () inferred)
|
|
62
|
+
|
|
63
|
+
# Java
|
|
64
|
+
public void foo ❌
|
|
65
|
+
public void $NAME($$$) { $$$ } ✅
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If a pattern returns 0 matches and looks correct, run `sg run -p '<pattern>' --lang <lang> --debug-query=ast --stdin <<< 'echo'` and see what the parser thinks the pattern is. If it returns an `ERROR` node, the pattern is malformed.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 3. Pattern parses as the wrong kind
|
|
73
|
+
|
|
74
|
+
A class field initializer `a = 123` *also* parses as an assignment expression. If you want only field definitions, you must disambiguate:
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
# WRONG — pattern parses as assignment_expression, not field_definition
|
|
78
|
+
pattern: a = 123
|
|
79
|
+
kind: field_definition
|
|
80
|
+
|
|
81
|
+
# CORRECT — use pattern object with context + selector
|
|
82
|
+
pattern:
|
|
83
|
+
context: 'class C { a = 123 }'
|
|
84
|
+
selector: field_definition
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`kind` and `pattern` are **independent constraints**, not modifiers of each other. ast-grep does not change *how* it parses based on `kind`.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 4. The `|` ambiguity
|
|
92
|
+
|
|
93
|
+
A bare `|` in a pattern is interpreted as bitwise-or in most languages, **not** alternation. So:
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
pattern: foo | bar # parses as: foo bitwise-or'd with bar
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
…matches expressions like `x | y`, not "either foo or bar". To get alternation, use `any`:
|
|
100
|
+
|
|
101
|
+
```yaml
|
|
102
|
+
rule:
|
|
103
|
+
any:
|
|
104
|
+
- pattern: foo
|
|
105
|
+
- pattern: bar
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
In TypeScript union types (`A | B`), `|` is part of the type syntax — `pattern: A | B` correctly parses as a union type and matches that.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 5. Same-name metavars collide
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
// Pattern: $X = $X
|
|
116
|
+
// Captures only when both sides are TEXTUALLY identical.
|
|
117
|
+
|
|
118
|
+
// Matches:
|
|
119
|
+
a = a
|
|
120
|
+
foo.bar = foo.bar
|
|
121
|
+
|
|
122
|
+
// Does NOT match:
|
|
123
|
+
a = b
|
|
124
|
+
let x = compute() // because $X needs to bind once and re-use
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
If you actually want two independent captures, name them differently: `$X = $Y`.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 6. `$$$` is greedy then commits
|
|
132
|
+
|
|
133
|
+
`$$$` does **not** backtrack. It captures as much as possible, then commits. If your pattern needs a non-greedy match, structure it differently:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
// You want "match foo($X), where $X is any single arg"
|
|
137
|
+
// BAD: foo($$$X) // matches foo(a), foo(a, b), foo(a, b, c) - too broad
|
|
138
|
+
// GOOD: foo($X) // matches only single-arg calls
|
|
139
|
+
|
|
140
|
+
// You want "match foo() with at least one arg"
|
|
141
|
+
// BAD: foo($$$X) // also matches foo()
|
|
142
|
+
// GOOD: foo($X, $$$REST) // forces at least one arg
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 7. `kind` names depend on tree-sitter grammar
|
|
148
|
+
|
|
149
|
+
`kind: function_declaration` works for JavaScript, but Python uses `function_definition`, Rust uses `function_item`, Go uses `function_declaration` (same as JS by coincidence). To find the right name, parse a known-good file:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
sg run -p '$_' --lang python --debug-query=cst path/to/example.py | grep -i function
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Or open <https://ast-grep.github.io/playground.html> and click on a node to see its `kind`.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 8. `inside` / `has` defaults to `stopBy: neighbor`
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
inside:
|
|
163
|
+
kind: function_declaration # only checks the IMMEDIATE parent
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
If you want "anywhere inside a function (any depth)":
|
|
167
|
+
|
|
168
|
+
```yaml
|
|
169
|
+
inside:
|
|
170
|
+
kind: function_declaration
|
|
171
|
+
stopBy: end # walks up to the file root
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Same for `has` (descendants):
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
has:
|
|
178
|
+
kind: return_statement
|
|
179
|
+
stopBy: end # walks down the whole subtree
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Without `stopBy: end`, `has` only matches direct children.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 9. CLI silently ignores `--update-all` when `--json` is set
|
|
187
|
+
|
|
188
|
+
This is the single biggest gotcha when scripting ast-grep. If you run:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
sg run -p 'foo()' -r 'bar()' --json=compact --update-all .
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
…you get the JSON output but **no files are mutated**. ast-grep silently drops `--update-all` when `--json` is on. To both preview and apply, run **two passes**:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Pass 1: preview as JSON
|
|
198
|
+
sg run -p 'foo()' -r 'bar()' --json=compact .
|
|
199
|
+
|
|
200
|
+
# Pass 2: actually apply
|
|
201
|
+
sg run -p 'foo()' -r 'bar()' --update-all .
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
`scripts/ast_grep_helper.py replace` does this automatically when `--apply` is set.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 10. Composite rules apply to a single node
|
|
209
|
+
|
|
210
|
+
`all` and `any` evaluate against **one target node** at a time:
|
|
211
|
+
|
|
212
|
+
```yaml
|
|
213
|
+
# WRONG — wants "node has BOTH a number child AND a string child"
|
|
214
|
+
has:
|
|
215
|
+
all:
|
|
216
|
+
- kind: number # impossible: one node cannot be both at once
|
|
217
|
+
- kind: string
|
|
218
|
+
|
|
219
|
+
# CORRECT
|
|
220
|
+
all:
|
|
221
|
+
- has: { kind: number }
|
|
222
|
+
- has: { kind: string }
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Lift relational rules out of composites when the relation is "the surrounding node has X children matching Y."
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 11. Field order is not guaranteed
|
|
230
|
+
|
|
231
|
+
When a rule object has multiple fields:
|
|
232
|
+
|
|
233
|
+
```yaml
|
|
234
|
+
rule:
|
|
235
|
+
pattern: $X = compute()
|
|
236
|
+
has: { kind: number }
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
…ast-grep evaluates them as an implicit `all`, but the **order** in which metavariables are captured is not guaranteed. If your `transform` or `fix` depends on capture order, use an explicit `all` array:
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
rule:
|
|
243
|
+
all:
|
|
244
|
+
- pattern: function $F() { $$$ }
|
|
245
|
+
- has: { pattern: $F() } # $F captured by pattern first; here we just check
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 12. `regex` without `kind` is slow
|
|
251
|
+
|
|
252
|
+
`regex` alone scans every node text in the file. On large repos this is noticeably slow. Always combine:
|
|
253
|
+
|
|
254
|
+
```yaml
|
|
255
|
+
# Slow
|
|
256
|
+
rule:
|
|
257
|
+
regex: '^TODO'
|
|
258
|
+
|
|
259
|
+
# Fast
|
|
260
|
+
rule:
|
|
261
|
+
all:
|
|
262
|
+
- kind: comment
|
|
263
|
+
- regex: '^//\s*TODO'
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 13. No scope / type / data-flow analysis
|
|
269
|
+
|
|
270
|
+
ast-grep is a **structural** matcher. It does NOT know:
|
|
271
|
+
|
|
272
|
+
- Whether two `foo` references point to the same variable.
|
|
273
|
+
- Whether a variable is shadowed.
|
|
274
|
+
- Whether a function is async, throws, returns a Promise.
|
|
275
|
+
- Whether a value flows from input to output.
|
|
276
|
+
|
|
277
|
+
For those questions, use a real type-aware tool: TypeScript LSP, Pyright, Semgrep with type inference, CodeQL, etc.
|
|
278
|
+
|
|
279
|
+
ast-grep is great when *the syntactic shape* is what you care about: "find every call to `eval(...)`", "find every `as any`", "find every empty catch block." It is weak for "find every variable that's never used."
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 14. Pattern testing is the fastest debugger
|
|
284
|
+
|
|
285
|
+
When a pattern returns 0 matches and you can't see why:
|
|
286
|
+
|
|
287
|
+
1. Open <https://ast-grep.github.io/playground.html>.
|
|
288
|
+
2. Paste your code into the left pane, your pattern into the top-right.
|
|
289
|
+
3. The bottom-right shows the parsed AST and which nodes matched (highlighted) or failed.
|
|
290
|
+
|
|
291
|
+
Or locally:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
sg run -p '<pattern>' --lang <lang> --debug-query=ast --stdin <<< '<sample-code>'
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
stderr shows the parsed pattern; stdout shows the JSON match result. If the pattern shows up as `ERROR (XXX)`, it doesn't parse.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## See also
|
|
302
|
+
|
|
303
|
+
- `references/patterns.md` — meta-variables, strictness, naming rules.
|
|
304
|
+
- `references/recipes.md` — known-good patterns by language.
|
|
305
|
+
- `references/cli.md` — `--debug-query`, `--strictness`, `--update-all`.
|