@dsmm/dsmm 0.1.9 → 0.2.2
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 +46 -58
- package/agent-presets/dsmm-builder/agent.cordis.yml +91 -186
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +120 -17
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-coding/agent.cordis.yml +169 -0
- package/agent-presets/dsmm-coding/preset.yml +3 -0
- package/agent-presets/dsmm-complex/agent.cordis.yml +154 -0
- package/agent-presets/dsmm-complex/preset.yml +3 -0
- package/agent-presets/dsmm-creative/agent.cordis.yml +122 -15
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +179 -0
- package/agent-presets/dsmm-cross-cutting/preset.yml +3 -0
- package/agent-presets/dsmm-deep/agent.cordis.yml +189 -0
- package/agent-presets/dsmm-deep/preset.yml +3 -0
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-documenting/agent.cordis.yml +168 -0
- package/agent-presets/dsmm-documenting/preset.yml +3 -0
- package/agent-presets/dsmm-frontend/agent.cordis.yml +161 -0
- package/agent-presets/dsmm-frontend/preset.yml +3 -0
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +153 -0
- package/agent-presets/dsmm-hard-reasoning/preset.yml +3 -0
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +72 -17
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +127 -0
- package/agent-presets/dsmm-normal-task/preset.yml +3 -0
- package/agent-presets/dsmm-oracle/agent.cordis.yml +109 -15
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +109 -15
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +174 -190
- package/agent-presets/dsmm-orchestrator/preset.yml +1 -1
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +102 -16
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +134 -15
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-quick/agent.cordis.yml +132 -0
- package/agent-presets/dsmm-quick/preset.yml +3 -0
- package/agent-presets/dsmm-research/agent.cordis.yml +156 -0
- package/agent-presets/dsmm-research/preset.yml +3 -0
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +108 -16
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/cordis.patch.yml +1 -5
- package/docs/agent-presets.md +48 -15
- package/docs/compatibility.md +58 -68
- package/docs/deferred-native-approval-risk.md +19 -0
- package/docs/design.md +43 -2
- package/docs/lsp.md +12 -12
- package/docs/migration-from-ocmm.md +10 -2
- package/docs/model-routing.md +84 -59
- package/docs/native-permissions.md +35 -0
- package/docs/profiles.md +43 -64
- package/docs/releasing.md +159 -8
- package/docs/roadmap.md +77 -17
- package/docs/runtime-recovery.md +12 -0
- package/docs/safety-guards.md +7 -3
- package/docs/settings-status.md +46 -40
- package/docs/skill-sync.md +89 -14
- package/lib/child-admission-contract.d.ts +37 -0
- package/lib/child-admission-contract.js +2 -0
- package/lib/child-admission.d.ts +42 -0
- package/lib/child-admission.js +162 -0
- package/lib/child-capture.d.ts +81 -0
- package/lib/child-capture.js +203 -0
- package/lib/child-evidence.d.ts +17 -0
- package/lib/child-evidence.js +43 -0
- package/lib/client/ChildrenPanel.d.ts +43 -0
- package/lib/client/ChildrenPanel.js +82 -0
- package/lib/client/DeploymentPage.d.ts +18 -0
- package/lib/client/DeploymentPage.js +127 -0
- package/lib/client/EditableChoice.d.ts +17 -0
- package/lib/client/EditableChoice.js +49 -0
- package/lib/client/PermissionsPanel.d.ts +14 -0
- package/lib/client/PermissionsPanel.js +46 -0
- package/lib/client/ProfilesSection.js +32 -15
- package/lib/client/RoleAvailability.d.ts +7 -0
- package/lib/client/RoleAvailability.js +19 -0
- package/lib/client/SessionProfiles.js +27 -9
- package/lib/client/StructuredEditor.js +15 -7
- package/lib/client/children-controller.d.ts +98 -0
- package/lib/client/children-controller.js +296 -0
- package/lib/client/children-locales.d.ts +367 -0
- package/lib/client/children-locales.js +69 -0
- package/lib/client/controller.d.ts +6 -1
- package/lib/client/controller.js +14 -8
- package/lib/client/deployment-controller.d.ts +50 -0
- package/lib/client/deployment-controller.js +193 -0
- package/lib/client/deployment-data.d.ts +17 -0
- package/lib/client/deployment-data.js +138 -0
- package/lib/client/deployment-locales.d.ts +70 -0
- package/lib/client/deployment-locales.js +81 -0
- package/lib/client/diagnostics.d.ts +14 -0
- package/lib/client/diagnostics.js +53 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +145 -1
- package/lib/client/locales.d.ts +58 -0
- package/lib/client/locales.js +38 -18
- package/lib/client/permission-client.d.ts +16 -0
- package/lib/client/permission-client.js +38 -0
- package/lib/client/permission-controller.d.ts +62 -0
- package/lib/client/permission-controller.js +149 -0
- package/lib/client/permission-locales.d.ts +114 -0
- package/lib/client/permission-locales.js +75 -0
- package/lib/client/plugins-contract.d.ts +27 -0
- package/lib/client/plugins-contract.js +2 -0
- package/lib/client/session-labels.js +4 -4
- package/lib/client/structured.js +19 -5
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +36 -0
- package/lib/client.js +6724 -1604
- 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/core-permission-authority.d.ts +18 -0
- package/lib/core-permission-authority.js +255 -0
- package/lib/core-permissions.d.ts +8 -0
- package/lib/core-permissions.js +33 -0
- package/lib/delivery-authority.d.ts +68 -0
- package/lib/delivery-authority.js +260 -0
- package/lib/deployment-config.d.ts +60 -0
- package/lib/deployment-config.js +205 -0
- package/lib/deployment-permission-rules.d.ts +55 -0
- package/lib/deployment-permission-rules.js +306 -0
- package/lib/dsh-home.d.ts +3 -0
- package/lib/dsh-home.js +10 -0
- package/lib/dsh-types.d.ts +22 -69
- package/lib/guards.d.ts +3 -2
- package/lib/guards.js +44 -6
- package/lib/host-llm-startup.d.ts +41 -0
- package/lib/host-llm-startup.js +65 -0
- package/lib/host-llm.d.ts +92 -0
- package/lib/host-llm.js +325 -0
- package/lib/index.d.ts +23 -5
- package/lib/index.js +383 -40
- package/lib/legacy-child-policy.d.ts +51 -0
- package/lib/legacy-child-policy.js +123 -0
- package/lib/legacy-read-composition.d.ts +20 -0
- package/lib/legacy-read-composition.js +144 -0
- package/lib/legacy-read-contracts.d.ts +157 -0
- package/lib/legacy-read-contracts.js +39 -0
- package/lib/legacy-read-host.d.ts +19 -0
- package/lib/legacy-read-host.js +67 -0
- package/lib/legacy-read-integration.d.ts +121 -0
- package/lib/legacy-read-integration.js +522 -0
- package/lib/legacy-read-proxy.d.ts +26 -0
- package/lib/legacy-read-proxy.js +237 -0
- package/lib/live-pi-ai-owner.d.ts +18 -0
- package/lib/live-pi-ai-owner.js +144 -0
- package/lib/llm-runtime.d.ts +11 -0
- package/lib/llm-runtime.js +21 -0
- package/lib/lsp.d.ts +13 -0
- package/lib/lsp.js +60 -0
- package/lib/managed-settings.d.ts +5 -0
- package/lib/managed-settings.js +14 -0
- package/lib/mode.js +42 -47
- package/lib/model-parameter-policy.d.ts +11 -0
- package/lib/model-parameter-policy.js +27 -0
- package/lib/model-routing.js +33 -19
- package/lib/modules.d.ts +35 -0
- package/lib/modules.js +37 -0
- package/lib/native-child-evidence.d.ts +42 -0
- package/lib/native-child-evidence.js +133 -0
- package/lib/native-pi-ai-wire.d.ts +37 -0
- package/lib/native-pi-ai-wire.js +261 -0
- package/lib/native-scope.d.ts +9 -0
- package/lib/native-scope.js +20 -0
- package/lib/permission-bash.d.ts +6 -0
- package/lib/permission-bash.js +7 -0
- package/lib/permission-control.d.ts +73 -0
- package/lib/permission-control.js +205 -0
- package/lib/permission-controller.d.ts +68 -0
- package/lib/permission-controller.js +317 -0
- package/lib/permission-errors.d.ts +7 -0
- package/lib/permission-errors.js +21 -0
- package/lib/permission-fs-search.d.ts +5 -0
- package/lib/permission-fs-search.js +7 -0
- package/lib/permission-fs.d.ts +5 -0
- package/lib/permission-fs.js +7 -0
- package/lib/permission-native-access.d.ts +11 -0
- package/lib/permission-native-access.js +6 -0
- package/lib/permission-native-command.d.ts +10 -0
- package/lib/permission-native-command.js +93 -0
- package/lib/permission-native-rules.d.ts +75 -0
- package/lib/permission-native-rules.js +278 -0
- package/lib/permission-pwsh.d.ts +6 -0
- package/lib/permission-pwsh.js +7 -0
- package/lib/permission-remote.d.ts +26 -0
- package/lib/permission-remote.js +53 -0
- package/lib/permission-rpc.d.ts +29 -0
- package/lib/permission-rpc.js +152 -0
- package/lib/permission-rules.d.ts +115 -0
- package/lib/permission-rules.js +256 -0
- package/lib/permission-settings.d.ts +45 -0
- package/lib/permission-settings.js +48 -0
- package/lib/permission-shell.d.ts +38 -0
- package/lib/permission-shell.js +150 -0
- package/lib/permission-web.d.ts +5 -0
- package/lib/permission-web.js +7 -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 +38 -24
- package/lib/preset-skills.d.ts +4 -1
- package/lib/preset-skills.js +60 -19
- package/lib/profile-diagnostics.d.ts +45 -0
- package/lib/profile-diagnostics.js +148 -0
- package/lib/profile-locale.d.ts +3 -0
- package/lib/profile-locale.js +2 -0
- package/lib/profile-remote.d.ts +22 -0
- package/lib/profile-remote.js +344 -27
- package/lib/profile-rpc.d.ts +25 -1
- package/lib/profile-rpc.js +143 -3
- package/lib/profile-runtime.d.ts +63 -0
- package/lib/profile-runtime.js +496 -77
- package/lib/profile-store.d.ts +56 -1
- package/lib/profile-store.js +377 -111
- package/lib/profile-types.d.ts +125 -1
- package/lib/profile-types.js +1 -0
- package/lib/profiles.d.ts +16 -2
- package/lib/profiles.js +156 -79
- package/lib/prompt-content.d.ts +25 -0
- package/lib/prompt-content.js +27 -0
- package/lib/prompts.d.ts +45 -4
- package/lib/prompts.js +157 -43
- package/lib/recovery-policy.js +20 -7
- package/lib/role-control-remote.d.ts +38 -0
- package/lib/role-control-remote.js +211 -0
- package/lib/role-control-rpc.d.ts +51 -0
- package/lib/role-control-rpc.js +377 -0
- package/lib/role-control-types.d.ts +92 -0
- package/lib/role-control-types.js +8 -0
- package/lib/role-invocation.d.ts +47 -0
- package/lib/role-invocation.js +135 -0
- package/lib/role-llm-runtime.d.ts +17 -0
- package/lib/role-llm-runtime.js +62 -0
- package/lib/role-llm.d.ts +31 -0
- package/lib/role-llm.js +66 -0
- package/lib/role-policy.d.ts +92 -0
- package/lib/role-policy.js +601 -0
- package/lib/role-providers.d.ts +7 -3
- package/lib/role-providers.js +74 -46
- package/lib/role-routing.d.ts +11 -2
- package/lib/role-routing.js +42 -25
- package/lib/role-runs.d.ts +135 -0
- package/lib/role-runs.js +304 -0
- package/lib/role-subagents.d.ts +63 -4
- package/lib/role-subagents.js +299 -47
- package/lib/roles.d.ts +20 -9
- package/lib/roles.js +87 -216
- package/lib/route-json.d.ts +19 -0
- package/lib/route-json.js +129 -0
- package/lib/routing-policy.d.ts +2 -0
- package/lib/routing-policy.js +12 -2
- package/lib/runtime-integration.d.ts +112 -0
- package/lib/runtime-integration.js +784 -0
- package/lib/runtime-recovery.js +34 -13
- package/lib/session-scope.js +2 -0
- package/lib/settings.d.ts +116 -14
- package/lib/settings.js +455 -149
- 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 +35 -1
- package/lib/status.js +58 -17
- package/lib/subagent-runtime.d.ts +45 -0
- package/lib/subagent-runtime.js +131 -0
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +112 -45
- package/patches/subagent-runtime.yml +15 -0
- package/prompts/deepseek-flash.md +1 -1
- package/prompts/deepseek-v4-pro.md +2 -2
- package/prompts/deepwork.md +153 -20
- package/prompts/source/agents/clarifier.md +47 -0
- package/prompts/source/agents/orchestrator.md +72 -0
- package/prompts/source/agents/plan-critic.md +29 -0
- package/prompts/source/agents/planner.md +21 -0
- package/prompts/source/agents/reviewer.md +23 -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 +40 -0
- package/prompts/source/category/cross-cutting.md +54 -0
- package/prompts/source/category/deep.md +64 -0
- package/prompts/source/category/documenting.md +68 -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 +58 -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 +136 -0
- package/prompts/source/deepwork/gemini.md +191 -0
- package/prompts/source/deepwork/glm.md +263 -0
- package/prompts/source/deepwork/gpt.md +49 -0
- package/prompts/source/deepwork/kimi-k27.md +13 -0
- package/prompts/source/deepwork/planner.md +44 -0
- package/prompts/source/deepwork/swe-2.md +13 -0
- package/prompts/source/manifest.json +3233 -0
- package/prompts/source/shared/dsh-host-contract.md +8 -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/scripts/cold-profile-composition.mjs +329 -0
- package/scripts/cold-profile-sources.mjs +238 -0
- package/scripts/migrate-cold-profile.mjs +315 -0
- package/skills/ast-grep/LICENSE +21 -0
- package/skills/ast-grep/README.md +138 -0
- package/skills/ast-grep/SKILL.md +287 -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 +123 -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 +147 -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 +130 -4
- package/skills/debugging/references/logging.md +2 -0
- package/skills/debugging/references/methodology/00-setup.md +16 -62
- package/skills/debugging/references/methodology/02-investigate.md +11 -5
- package/skills/debugging/references/methodology/03-flaky-triage.md +6 -4
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +6 -16
- package/skills/debugging/references/methodology/05-escalate.md +2 -0
- package/skills/debugging/references/methodology/06-fix.md +8 -6
- package/skills/debugging/references/methodology/08-qa.md +7 -5
- package/skills/debugging/references/methodology/09-cleanup.md +16 -152
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +7 -18
- package/skills/debugging/references/runtimes/bundled-js-binary.md +3 -16
- package/skills/debugging/references/runtimes/go.md +2 -0
- package/skills/debugging/references/runtimes/native-binary.md +11 -54
- package/skills/debugging/references/runtimes/node.md +6 -15
- package/skills/debugging/references/runtimes/python.md +5 -15
- package/skills/debugging/references/runtimes/rust.md +4 -18
- 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 +4 -2
- package/skills/debugging/references/tools/ghidra.md +6 -15
- package/skills/debugging/references/tools/playwright-cli.md +5 -15
- package/skills/debugging/references/tools/pwndbg.md +2 -0
- package/skills/debugging/references/tools/pwntools.md +6 -16
- package/skills/dispatching-parallel-agents/SKILL.md +96 -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 +145 -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 +115 -0
- package/skills/git-master/agents/openai.yaml +13 -0
- package/skills/init-deep/SKILL.md +282 -0
- package/skills/receiving-code-review/SKILL.md +117 -7
- package/skills/remove-ai-slops/SKILL.md +160 -8
- package/skills/requesting-code-review/SKILL.md +98 -3
- package/skills/requesting-code-review/code-reviewer.md +59 -0
- package/skills/subagent-driven-development/SKILL.md +179 -6
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +23 -0
- package/skills/subagent-driven-development/implementer-prompt.md +87 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +37 -0
- package/skills/using-git-worktrees/SKILL.md +144 -0
- package/skills/writing-plans/SKILL.md +126 -7
- package/skills/writing-plans/plan-document-reviewer-prompt.md +47 -0
|
@@ -0,0 +1,511 @@
|
|
|
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
|
+
# YAML rule reference — atomic, relational, composite, transform, fix
|
|
4
|
+
|
|
5
|
+
Use this when you outgrow inline `sg run -p ...` patterns and need a reusable, testable rule. A YAML rule is the unit of work for `sg scan`. Drop one or more files in `ruleDirs/` (configured via `sgconfig.yml`) and they get loaded automatically.
|
|
6
|
+
|
|
7
|
+
This page is the practical reference. The full upstream docs live at:
|
|
8
|
+
|
|
9
|
+
- <https://ast-grep.github.io/reference/yaml.html>
|
|
10
|
+
- <https://ast-grep.github.io/reference/rule.html>
|
|
11
|
+
- <https://ast-grep.github.io/cheatsheet/rule.html>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Skeleton
|
|
16
|
+
|
|
17
|
+
A single YAML file can hold multiple rules separated by `---`.
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
id: no-console
|
|
21
|
+
language: TypeScript
|
|
22
|
+
severity: warning
|
|
23
|
+
message: "Avoid console.* in production"
|
|
24
|
+
note: |
|
|
25
|
+
Use a proper logger so we can route logs to stderr in production
|
|
26
|
+
and silence them in tests.
|
|
27
|
+
url: https://internal.docs/rules/no-console
|
|
28
|
+
|
|
29
|
+
rule:
|
|
30
|
+
pattern: console.$METHOD($$$ARGS)
|
|
31
|
+
|
|
32
|
+
fix: logger.$METHOD($$$ARGS)
|
|
33
|
+
|
|
34
|
+
constraints:
|
|
35
|
+
METHOD:
|
|
36
|
+
not:
|
|
37
|
+
regex: '^(error|warn)$'
|
|
38
|
+
|
|
39
|
+
files:
|
|
40
|
+
- 'src/**/*.ts'
|
|
41
|
+
ignores:
|
|
42
|
+
- 'src/**/*.test.ts'
|
|
43
|
+
|
|
44
|
+
metadata:
|
|
45
|
+
category: logging
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Top-level fields
|
|
51
|
+
|
|
52
|
+
| Field | Required | Description |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `id` | yes | Unique identifier. Use `kebab-case`. |
|
|
55
|
+
| `language` | yes | One of: `Bash`, `C`, `Cpp`, `CSharp`, `Css`, `Elixir`, `Go`, `Haskell`, `Html`, `Java`, `JavaScript`, `Json`, `Kotlin`, `Lua`, `Nix`, `Php`, `Python`, `Ruby`, `Rust`, `Scala`, `Solidity`, `Swift`, `TypeScript`, `Tsx`, `Yaml`. **Capitalized PascalCase** is canonical, but lowercase often works. |
|
|
56
|
+
| `rule` | yes | The matching logic. Object containing one or more atomic / relational / composite rules. |
|
|
57
|
+
| `constraints` | no | Filter on captured single-metavariables (`$VAR`, not `$$$`). |
|
|
58
|
+
| `utils` | no | Local utility rules referenced by `matches:` in this file. |
|
|
59
|
+
| `transform` | no | Manipulate metavariable strings before `fix`. |
|
|
60
|
+
| `fix` | no | String or `FixConfig` for auto-rewrite. |
|
|
61
|
+
| `rewriters` | no | Rewriter rules for the `rewrite` transform. |
|
|
62
|
+
| `severity` | no | `hint` \| `info` \| `warning` \| `error` \| `off` (default: `hint`). |
|
|
63
|
+
| `message` | no | Concise lint message. May reference `$VAR` capture text. |
|
|
64
|
+
| `note` | no | Detailed markdown explanation (no `$VAR` interpolation). |
|
|
65
|
+
| `labels` | no | Custom diagnostic highlighting per-metavariable. |
|
|
66
|
+
| `files` | no | Glob include list. |
|
|
67
|
+
| `ignores` | no | Glob exclude list. |
|
|
68
|
+
| `url` | no | Doc link shown in editor diagnostics. |
|
|
69
|
+
| `metadata` | no | Free-form data ignored by `sg`, useful for external tooling. |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Atomic rules — match a single node
|
|
74
|
+
|
|
75
|
+
### `pattern`
|
|
76
|
+
|
|
77
|
+
Match by structural pattern. The most common rule.
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
# String form
|
|
81
|
+
rule:
|
|
82
|
+
pattern: console.log($MSG)
|
|
83
|
+
|
|
84
|
+
# Object form (when context is needed)
|
|
85
|
+
rule:
|
|
86
|
+
pattern:
|
|
87
|
+
context: 'class C { $FIELD = $INIT }'
|
|
88
|
+
selector: field_definition
|
|
89
|
+
strictness: relaxed # optional, default: smart
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### `kind`
|
|
93
|
+
|
|
94
|
+
Match by AST node type name. Tree-sitter grammar-specific.
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
rule:
|
|
98
|
+
kind: call_expression
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
ast-grep 0.39+ supports limited ESQuery selectors:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
rule:
|
|
105
|
+
kind: call_expression > identifier # direct child
|
|
106
|
+
kind: call_expression + identifier # next sibling
|
|
107
|
+
kind: call_expression ~ identifier # following sibling
|
|
108
|
+
kind: call_expression identifier # descendant
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
To find the right `kind`, parse a known-good file:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
sg run -p '$_' --lang ts --debug-query=cst src/foo.ts | head -40
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `regex`
|
|
118
|
+
|
|
119
|
+
Match node text against a Rust regex. Whole-text match (no partial). Always combine with `kind` or `pattern` for performance.
|
|
120
|
+
|
|
121
|
+
```yaml
|
|
122
|
+
rule:
|
|
123
|
+
all:
|
|
124
|
+
- kind: identifier
|
|
125
|
+
- regex: '^[A-Z][a-z]+$' # PascalCase
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Inline flags work: `(?i)apple`, `(?m)^foo`. No look-around, no backreferences.
|
|
129
|
+
|
|
130
|
+
### `nthChild`
|
|
131
|
+
|
|
132
|
+
Match by 1-based index among **named** siblings. Inspired by CSS `:nth-child`.
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
rule:
|
|
136
|
+
nthChild: 1 # first sibling
|
|
137
|
+
|
|
138
|
+
# Functional form
|
|
139
|
+
rule:
|
|
140
|
+
nthChild: 2n+1 # odd siblings
|
|
141
|
+
|
|
142
|
+
# With reverse and ofRule
|
|
143
|
+
rule:
|
|
144
|
+
nthChild:
|
|
145
|
+
position: 1
|
|
146
|
+
reverse: true # last
|
|
147
|
+
ofRule:
|
|
148
|
+
kind: function_declaration
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### `range`
|
|
152
|
+
|
|
153
|
+
Match by character range. Useful for tooling that pinpoints a known location.
|
|
154
|
+
|
|
155
|
+
```yaml
|
|
156
|
+
rule:
|
|
157
|
+
range:
|
|
158
|
+
start: { line: 0, column: 0 }
|
|
159
|
+
end: { line: 0, column: 11 }
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Relational rules — match by relation to other nodes
|
|
165
|
+
|
|
166
|
+
All four take a sub-rule object plus optional `stopBy` and (for `inside`/`has`) `field`.
|
|
167
|
+
|
|
168
|
+
### `inside` — target is inside parent/ancestor matching sub-rule
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
rule:
|
|
172
|
+
pattern: this.$PROP
|
|
173
|
+
inside:
|
|
174
|
+
kind: class_body
|
|
175
|
+
stopBy: end # walk up to file root, default: neighbor
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### `has` — target has child/descendant matching sub-rule
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
rule:
|
|
182
|
+
kind: function_declaration
|
|
183
|
+
has:
|
|
184
|
+
kind: throw_statement
|
|
185
|
+
stopBy: end
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### `precedes` — target appears before sibling matching sub-rule
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
rule:
|
|
192
|
+
kind: import_statement
|
|
193
|
+
precedes:
|
|
194
|
+
kind: function_declaration
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### `follows` — target appears after sibling matching sub-rule
|
|
198
|
+
|
|
199
|
+
```yaml
|
|
200
|
+
rule:
|
|
201
|
+
pattern: super($$$)
|
|
202
|
+
follows:
|
|
203
|
+
pattern: $X = $Y
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### `stopBy`
|
|
207
|
+
|
|
208
|
+
| Value | Behavior |
|
|
209
|
+
|---|---|
|
|
210
|
+
| `"neighbor"` (default) | Stop at immediate parent/child/sibling. |
|
|
211
|
+
| `"end"` | Walk all the way to root / leaf / sequence boundary. |
|
|
212
|
+
| Rule object | Stop when sub-rule matches (inclusive). |
|
|
213
|
+
|
|
214
|
+
### `field`
|
|
215
|
+
|
|
216
|
+
Specify the semantic role of the target inside its parent (e.g. `name`, `body`, `value`, `key`).
|
|
217
|
+
|
|
218
|
+
```yaml
|
|
219
|
+
rule:
|
|
220
|
+
kind: pair
|
|
221
|
+
has:
|
|
222
|
+
field: key
|
|
223
|
+
regex: '^password$'
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Composite rules — combine sub-rules
|
|
229
|
+
|
|
230
|
+
| Rule | Meaning |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `all` | All sub-rules must match the same target node. Metavariables from all sub-rules merge. |
|
|
233
|
+
| `any` | At least one sub-rule must match. Only metavars from the matched branch survive. |
|
|
234
|
+
| `not` | Inverse: target must NOT match the sub-rule. |
|
|
235
|
+
| `matches` | Reference a utility rule by id. |
|
|
236
|
+
|
|
237
|
+
```yaml
|
|
238
|
+
rule:
|
|
239
|
+
all:
|
|
240
|
+
- kind: call_expression
|
|
241
|
+
- pattern: $FN($$$ARGS)
|
|
242
|
+
- inside:
|
|
243
|
+
kind: function_declaration
|
|
244
|
+
stopBy: end
|
|
245
|
+
|
|
246
|
+
rule:
|
|
247
|
+
any:
|
|
248
|
+
- pattern: console.log($X)
|
|
249
|
+
- pattern: console.warn($X)
|
|
250
|
+
- pattern: console.error($X)
|
|
251
|
+
|
|
252
|
+
rule:
|
|
253
|
+
all:
|
|
254
|
+
- pattern: $E.unwrap()
|
|
255
|
+
- not:
|
|
256
|
+
inside:
|
|
257
|
+
kind: function_item
|
|
258
|
+
has:
|
|
259
|
+
kind: result_type
|
|
260
|
+
stopBy: end
|
|
261
|
+
|
|
262
|
+
rule:
|
|
263
|
+
matches: is-react-component
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
> Composites apply to a **single** target. To express "node X has BOTH a number child AND a string child," use two relational rules at the top level, not `all` inside `has`. See `references/pitfalls.md` §10.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Implicit `all` — multiple rule fields
|
|
271
|
+
|
|
272
|
+
A rule object with multiple fields is treated as an implicit `all`:
|
|
273
|
+
|
|
274
|
+
```yaml
|
|
275
|
+
# These two are equivalent
|
|
276
|
+
rule:
|
|
277
|
+
pattern: this.$PROP
|
|
278
|
+
inside: { kind: class_body }
|
|
279
|
+
|
|
280
|
+
rule:
|
|
281
|
+
all:
|
|
282
|
+
- pattern: this.$PROP
|
|
283
|
+
- inside: { kind: class_body }
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Use the explicit `all` array when capture order matters (rare, but possible with downstream `transform`).
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## `constraints` — post-match metavariable filtering
|
|
291
|
+
|
|
292
|
+
After the main `rule` matches, additional checks on captured single metavariables:
|
|
293
|
+
|
|
294
|
+
```yaml
|
|
295
|
+
rule:
|
|
296
|
+
pattern: function $NAME($$$P) { $$$B }
|
|
297
|
+
|
|
298
|
+
constraints:
|
|
299
|
+
NAME:
|
|
300
|
+
regex: '^[a-z][a-zA-Z0-9]*$' # camelCase only
|
|
301
|
+
not:
|
|
302
|
+
regex: '^_' # not starting with _
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Constraints **only apply to single metavars** (`$VAR`), not multi (`$$$VAR`).
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## `utils` — local reusable sub-rules
|
|
310
|
+
|
|
311
|
+
```yaml
|
|
312
|
+
utils:
|
|
313
|
+
is-literal:
|
|
314
|
+
any:
|
|
315
|
+
- kind: number
|
|
316
|
+
- kind: string
|
|
317
|
+
- kind: 'true'
|
|
318
|
+
- kind: 'false'
|
|
319
|
+
|
|
320
|
+
rule:
|
|
321
|
+
all:
|
|
322
|
+
- pattern: $X = $Y
|
|
323
|
+
- has:
|
|
324
|
+
matches: is-literal # references utils.is-literal
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
For utils accessible across multiple rule files, use `utilDirs` in `sgconfig.yml` and put each util in its own YAML file with `id` and `language`.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## `transform` — manipulate captures before `fix`
|
|
332
|
+
|
|
333
|
+
Operations: `replace`, `substring`, `convert`, `rewrite`.
|
|
334
|
+
|
|
335
|
+
### `replace` — regex search/replace on a captured string
|
|
336
|
+
|
|
337
|
+
```yaml
|
|
338
|
+
rule:
|
|
339
|
+
pattern: $OLD_FN($$$A)
|
|
340
|
+
constraints:
|
|
341
|
+
OLD_FN:
|
|
342
|
+
regex: '^debug_'
|
|
343
|
+
transform:
|
|
344
|
+
NEW_FN:
|
|
345
|
+
replace:
|
|
346
|
+
source: $OLD_FN
|
|
347
|
+
replace: '^debug_'
|
|
348
|
+
by: 'release_'
|
|
349
|
+
fix: $NEW_FN($$$A)
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### `substring` — character slicing (negative indices supported)
|
|
353
|
+
|
|
354
|
+
```yaml
|
|
355
|
+
transform:
|
|
356
|
+
INNER:
|
|
357
|
+
substring:
|
|
358
|
+
source: $WRAPPED
|
|
359
|
+
startChar: 1
|
|
360
|
+
endChar: -1
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### `convert` — case conversion
|
|
364
|
+
|
|
365
|
+
```yaml
|
|
366
|
+
transform:
|
|
367
|
+
KEBAB:
|
|
368
|
+
convert:
|
|
369
|
+
source: $CAMEL
|
|
370
|
+
toCase: kebabCase # camelCase | snakeCase | kebabCase | pascalCase | upperCase | lowerCase | capitalize
|
|
371
|
+
separatedBy: [underscore] # optional: dash | dot | space | slash | underscore | caseChange
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### `rewrite` — apply other rewriter rules (experimental)
|
|
375
|
+
|
|
376
|
+
```yaml
|
|
377
|
+
rewriters:
|
|
378
|
+
- id: stringify
|
|
379
|
+
rule: { pattern: "'' + $A" }
|
|
380
|
+
fix: "String($A)"
|
|
381
|
+
|
|
382
|
+
rule:
|
|
383
|
+
pattern: stringify-all($EXPR)
|
|
384
|
+
transform:
|
|
385
|
+
REWRITTEN:
|
|
386
|
+
rewrite:
|
|
387
|
+
source: $EXPR
|
|
388
|
+
rewriters: [stringify]
|
|
389
|
+
joinBy: "\n"
|
|
390
|
+
fix: $REWRITTEN
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Transforms can chain
|
|
394
|
+
|
|
395
|
+
Later transforms can reference variables produced by earlier ones:
|
|
396
|
+
|
|
397
|
+
```yaml
|
|
398
|
+
transform:
|
|
399
|
+
KEBABED:
|
|
400
|
+
convert: { source: $X, toCase: kebabCase }
|
|
401
|
+
PREFIXED:
|
|
402
|
+
replace:
|
|
403
|
+
source: $KEBABED
|
|
404
|
+
replace: '^'
|
|
405
|
+
by: 'css-'
|
|
406
|
+
fix: $PREFIXED
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## `fix` — auto-rewrite
|
|
412
|
+
|
|
413
|
+
### String form
|
|
414
|
+
|
|
415
|
+
```yaml
|
|
416
|
+
fix: logger.log($$$ARGS)
|
|
417
|
+
|
|
418
|
+
# Empty string deletes the match
|
|
419
|
+
fix: ""
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### FixConfig form (for list-item deletion that needs to expand the range)
|
|
423
|
+
|
|
424
|
+
When deleting one item from a comma-separated list, you also need to remove the trailing comma. Use `expandEnd`:
|
|
425
|
+
|
|
426
|
+
```yaml
|
|
427
|
+
rule:
|
|
428
|
+
kind: pair
|
|
429
|
+
has:
|
|
430
|
+
field: key
|
|
431
|
+
regex: '^password$'
|
|
432
|
+
|
|
433
|
+
fix:
|
|
434
|
+
template: ''
|
|
435
|
+
expandEnd:
|
|
436
|
+
regex: ','
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
`expandStart` and `expandEnd` accept `regex` matching characters that should be absorbed into the rewrite range.
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## `rewriters` — sub-rule library for `rewrite` transform
|
|
444
|
+
|
|
445
|
+
Top-level field defining one or more named rewriters:
|
|
446
|
+
|
|
447
|
+
```yaml
|
|
448
|
+
rewriters:
|
|
449
|
+
- id: nullable-to-optional
|
|
450
|
+
rule: { pattern: $X | null }
|
|
451
|
+
fix: '$X | undefined'
|
|
452
|
+
|
|
453
|
+
- id: stringify
|
|
454
|
+
rule: { pattern: "'' + $A" }
|
|
455
|
+
fix: 'String($A)'
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
Used inside `transform` via the `rewrite` operation (see above).
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## `labels` — custom diagnostic highlighting
|
|
463
|
+
|
|
464
|
+
```yaml
|
|
465
|
+
rule:
|
|
466
|
+
pattern: $FN($$$ARGS)
|
|
467
|
+
|
|
468
|
+
labels:
|
|
469
|
+
FN:
|
|
470
|
+
style: primary
|
|
471
|
+
message: "this function shouldn't be called"
|
|
472
|
+
ARGS:
|
|
473
|
+
style: secondary
|
|
474
|
+
message: "with these arguments"
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
Editor extensions render the diagnostic with these labels. Defaults are usually fine.
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
## `files` and `ignores` — file selection per-rule
|
|
482
|
+
|
|
483
|
+
```yaml
|
|
484
|
+
files:
|
|
485
|
+
- 'src/**/*.ts'
|
|
486
|
+
- 'lib/**/*.ts'
|
|
487
|
+
|
|
488
|
+
ignores:
|
|
489
|
+
- 'src/**/*.test.ts'
|
|
490
|
+
- '**/__generated__/**'
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
If omitted, the rule runs on every file matching its `language`. These globs override `sgconfig.yml`-level globs for this rule only.
|
|
494
|
+
|
|
495
|
+
Object form (rare):
|
|
496
|
+
|
|
497
|
+
```yaml
|
|
498
|
+
files:
|
|
499
|
+
- pattern: 'src/**/*.ts'
|
|
500
|
+
case_sensitive: true
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
## See also
|
|
506
|
+
|
|
507
|
+
- `references/recipes.md` — copy-paste rules by language.
|
|
508
|
+
- `references/cli.md` — `sg scan`, `sg test`.
|
|
509
|
+
- `references/sgconfig.md` — project-level configuration.
|
|
510
|
+
- Official rule reference: <https://ast-grep.github.io/reference/rule.html>
|
|
511
|
+
- Cheat sheets: <https://ast-grep.github.io/cheatsheet/rule.html>, <https://ast-grep.github.io/cheatsheet/yaml.html>
|