@yandy-r/ycc-opencode 0.0.0-bootstrap.0 → 6.0.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/AGENTS.md +38 -0
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/agents/ansible-automation-expert.md +115 -0
- package/agents/api-docs-expert.md +146 -0
- package/agents/api-documenter.md +105 -0
- package/agents/architect.md +264 -0
- package/agents/architecture-analyst.md +99 -0
- package/agents/backport-conflict-resolver.md +134 -0
- package/agents/cloudflare-architect.md +85 -0
- package/agents/cloudflare-developer.md +196 -0
- package/agents/code-architect.md +101 -0
- package/agents/code-documenter.md +114 -0
- package/agents/code-explorer.md +99 -0
- package/agents/code-finder.md +83 -0
- package/agents/code-researcher.md +102 -0
- package/agents/code-reviewer.md +268 -0
- package/agents/code-simplifier.md +77 -0
- package/agents/codebase-advisor.md +130 -0
- package/agents/db-modifier.md +235 -0
- package/agents/docs-git-committer.md +220 -0
- package/agents/documentation-writer.md +92 -0
- package/agents/feature-researcher.md +121 -0
- package/agents/feature-writer.md +89 -0
- package/agents/frontend-ui-developer.md +98 -0
- package/agents/git-cleanup.md +173 -0
- package/agents/go-api-architect.md +172 -0
- package/agents/go-expert-architect.md +147 -0
- package/agents/implementor.md +167 -0
- package/agents/library-docs-writer.md +128 -0
- package/agents/nextjs-ux-ui-expert.md +127 -0
- package/agents/nodejs-backend-architect.md +112 -0
- package/agents/nodejs-backend-developer.md +184 -0
- package/agents/planner.md +257 -0
- package/agents/pr-comment-fixer.md +284 -0
- package/agents/practices-researcher.md +80 -0
- package/agents/project-file-cleaner.md +140 -0
- package/agents/prp-researcher.md +231 -0
- package/agents/python-developer.md +171 -0
- package/agents/python-expert-architect.md +188 -0
- package/agents/readme-generator.md +100 -0
- package/agents/release-fix-applier.md +194 -0
- package/agents/releaser.md +147 -0
- package/agents/research-specialist.md +106 -0
- package/agents/reverse-proxy-architect.md +131 -0
- package/agents/review-fixer.md +264 -0
- package/agents/root-cause-analyzer.md +105 -0
- package/agents/rust-build-resolver.md +183 -0
- package/agents/rust-expert-architect.md +149 -0
- package/agents/rust-reviewer.md +126 -0
- package/agents/sql-database-developer.md +195 -0
- package/agents/systems-engineering-expert.md +203 -0
- package/agents/terraform-architect.md +109 -0
- package/agents/terraform-developer.md +229 -0
- package/agents/test-strategy-planner.md +126 -0
- package/agents/turso-database-architect.md +139 -0
- package/agents/typescript-developer.md +170 -0
- package/agents/typescript-expert-architect.md +167 -0
- package/index.js +260 -0
- package/package.json +33 -7
- package/registration.json +4384 -0
- package/shared/references/agent-native-setup.md +121 -0
- package/shared/references/branch-prep.md +31 -0
- package/shared/references/branching-model.md +162 -0
- package/shared/references/ci-monitoring.md +445 -0
- package/shared/references/forge-detection.md +162 -0
- package/shared/references/goal-pairing.md +53 -0
- package/shared/references/pr-base-and-backport.md +143 -0
- package/shared/references/review-artifact-format.md +141 -0
- package/shared/references/review-checklist.md +161 -0
- package/shared/references/review-dispatch.md +71 -0
- package/shared/references/session-state.md +159 -0
- package/shared/references/standalone-dispatch.md +298 -0
- package/shared/references/target-capability-matrix.md +325 -0
- package/shared/references/visual-mode.md +155 -0
- package/shared/references/worktree-strategy.md +310 -0
- package/shared/scripts/backport-audit.sh +283 -0
- package/shared/scripts/ci-monitor.sh +637 -0
- package/shared/scripts/lib/backport-lib.sh +47 -0
- package/shared/scripts/lib/ci-classify.sh +103 -0
- package/shared/scripts/lib/forge.sh +264 -0
- package/shared/scripts/lib/release-state-lib.sh +300 -0
- package/shared/scripts/list-worktrees.sh +178 -0
- package/shared/scripts/merge-children.sh +82 -0
- package/shared/scripts/move-plan-to-worktree.sh +231 -0
- package/shared/scripts/pr-guard.sh +283 -0
- package/shared/scripts/prepare-feature-branch.sh +326 -0
- package/shared/scripts/release-ci-monitor.sh +671 -0
- package/shared/scripts/release-state-update.sh +216 -0
- package/shared/scripts/release-state.sh +178 -0
- package/shared/scripts/report-bundle-drift.sh +343 -0
- package/shared/scripts/require-python.sh +17 -0
- package/shared/scripts/resolve-plans-dir.sh +262 -0
- package/shared/scripts/rules-pointer.sh +20 -0
- package/shared/scripts/rules_pointer.py +267 -0
- package/shared/scripts/setup-worktree.sh +288 -0
- package/shared/scripts/validate-file-paths.sh +249 -0
- package/shared/scripts/visual-egress-guard.sh +303 -0
- package/shared/scripts/visual-recap-collect.sh +247 -0
- package/shared/scripts/worktree-paths.sh +86 -0
- package/skills/backport/SKILL.md +291 -0
- package/skills/backport/scripts/cherry-pick-pr.sh +232 -0
- package/skills/backport/scripts/find-pending.sh +199 -0
- package/skills/blueprint/SKILL.md +410 -0
- package/skills/blueprint/references/bootstrap-mapping.md +87 -0
- package/skills/bundle-author/SKILL.md +119 -0
- package/skills/bundle-author/references/surface-map.md +128 -0
- package/skills/bundle-author/references/templates/agent-template.md +21 -0
- package/skills/bundle-author/references/templates/skill-template.md +36 -0
- package/skills/bundle-author/references/when-not-to-scaffold.md +85 -0
- package/skills/bundle-author/scripts/scaffold-skill.sh +156 -0
- package/skills/bundle-release/SKILL.md +188 -0
- package/skills/bundle-release/references/release-checklist.md +196 -0
- package/skills/bundle-release/references/release-notes-template.md +48 -0
- package/skills/bundle-release/references/version-policy.md +150 -0
- package/skills/bundle-release/scripts/bump-version.sh +97 -0
- package/skills/bundle-release/scripts/draft-notes.sh +222 -0
- package/skills/bundle-release/scripts/preflight.sh +164 -0
- package/skills/bundle-release/scripts/release_versions.py +361 -0
- package/skills/clean/SKILL.md +107 -0
- package/skills/clean/references/agent-prompts.md +199 -0
- package/skills/clean/references/safety-config.md +125 -0
- package/skills/clean/scripts/detect-project-type.sh +423 -0
- package/skills/clean/scripts/generate-report.sh +245 -0
- package/skills/clean/scripts/validate-safety.sh +401 -0
- package/skills/code-report/SKILL.md +375 -0
- package/skills/code-report/scripts/check-prerequisites.sh +65 -0
- package/skills/code-report/templates/report-structure.md +202 -0
- package/skills/code-review/SKILL.md +153 -0
- package/skills/code-review/references/pr-procedure.md +311 -0
- package/skills/compatibility-audit/SKILL.md +226 -0
- package/skills/compatibility-audit/references/reading-the-report.md +159 -0
- package/skills/compatibility-audit/scripts/audit-install-assumptions.sh +372 -0
- package/skills/compatibility-audit/scripts/audit-target-features.sh +558 -0
- package/skills/deep-research/SKILL.md +251 -0
- package/skills/deep-research/references/analysis-prompts.md +702 -0
- package/skills/deep-research/references/completion-summary-template.md +66 -0
- package/skills/deep-research/references/persona-analogical.md +159 -0
- package/skills/deep-research/references/persona-archaeological.md +69 -0
- package/skills/deep-research/references/persona-contrarian.md +155 -0
- package/skills/deep-research/references/persona-futurist.md +70 -0
- package/skills/deep-research/references/persona-historical.md +142 -0
- package/skills/deep-research/references/persona-journalistic.md +69 -0
- package/skills/deep-research/references/persona-negative-space.md +70 -0
- package/skills/deep-research/references/persona-systems.md +69 -0
- package/skills/deep-research/references/synthesis-template.md +569 -0
- package/skills/deep-research/references/verification-log-template.md +32 -0
- package/skills/deep-research/scripts/check-prerequisites.sh +153 -0
- package/skills/deep-research/scripts/validate-research.sh +244 -0
- package/skills/feature-research/SKILL.md +292 -0
- package/skills/feature-research/scripts/validate-research.sh +159 -0
- package/skills/feature-research/scripts/validate-spec.sh +270 -0
- package/skills/feature-research/templates/research-agents.md +569 -0
- package/skills/feature-research/templates/spec-structure.md +437 -0
- package/skills/formatters/SKILL.md +207 -0
- package/skills/formatters/references/best-practices.md +78 -0
- package/skills/formatters/references/flag-reference.md +178 -0
- package/skills/formatters/references/stack-detection.md +119 -0
- package/skills/formatters/references/templates/husky-pre-commit.tmpl +13 -0
- package/skills/formatters/references/templates/justfile-snippet.just.tmpl +31 -0
- package/skills/formatters/references/templates/lefthook.yml.tmpl +22 -0
- package/skills/formatters/references/templates/lint-autofix.yml.tmpl +94 -0
- package/skills/formatters/references/templates/lint.yml.tmpl +85 -0
- package/skills/formatters/references/templates/makefile-snippet.mk.tmpl +34 -0
- package/skills/formatters/references/templates/package-json-scripts.json.tmpl +14 -0
- package/skills/formatters/references/templates/readme-section.md.tmpl +118 -0
- package/skills/formatters/scripts/apply-aliases.sh +245 -0
- package/skills/formatters/scripts/apply-ci.sh +136 -0
- package/skills/formatters/scripts/apply-docs.sh +187 -0
- package/skills/formatters/scripts/apply-hooks.sh +261 -0
- package/skills/formatters/scripts/bundle/format.sh +15 -0
- package/skills/formatters/scripts/bundle/go-tools.sh +119 -0
- package/skills/formatters/scripts/bundle/init-formatters.sh +517 -0
- package/skills/formatters/scripts/bundle/install-shellcheck.sh +85 -0
- package/skills/formatters/scripts/bundle/lib/excludes.sh +179 -0
- package/skills/formatters/scripts/bundle/lib/modified-files.sh +222 -0
- package/skills/formatters/scripts/bundle/lib/shellcheck-resolve.sh +81 -0
- package/skills/formatters/scripts/bundle/lib/shellcheck-version.sh +5 -0
- package/skills/formatters/scripts/bundle/lint.sh +15 -0
- package/skills/formatters/scripts/bundle/style.sh +1410 -0
- package/skills/formatters/scripts/bundle/templates/biome.json +81 -0
- package/skills/formatters/scripts/bundle/templates/clippy.toml +2 -0
- package/skills/formatters/scripts/bundle/templates/markdownlint.json +14 -0
- package/skills/formatters/scripts/bundle/templates/markdownlintignore +38 -0
- package/skills/formatters/scripts/bundle/templates/prettierignore +45 -0
- package/skills/formatters/scripts/bundle/templates/prettierrc.json +11 -0
- package/skills/formatters/scripts/bundle/templates/python-pyproject.toml +80 -0
- package/skills/formatters/scripts/bundle/templates/rustfmt.toml +41 -0
- package/skills/formatters/scripts/bundle/templates/tsconfig.json +21 -0
- package/skills/formatters/scripts/profile-style.sh +264 -0
- package/skills/frontend-design/SKILL.md +151 -0
- package/skills/frontend-patterns/SKILL.md +66 -0
- package/skills/frontend-patterns/references/animation.md +21 -0
- package/skills/frontend-patterns/references/components-and-state.md +40 -0
- package/skills/frontend-patterns/references/data-and-performance.md +34 -0
- package/skills/frontend-patterns/references/forms-errors-a11y.md +35 -0
- package/skills/git-cleanup/SKILL.md +286 -0
- package/skills/git-cleanup/references/active-code-rules.md +318 -0
- package/skills/git-cleanup/references/host-detection.md +217 -0
- package/skills/git-workflow/SKILL.md +130 -0
- package/skills/git-workflow/references/ci-monitoring-phase.md +130 -0
- package/skills/git-workflow/references/commit-phases.md +247 -0
- package/skills/git-workflow/references/examples-and-troubleshooting.md +47 -0
- package/skills/git-workflow/references/goal-pairing.md +23 -0
- package/skills/git-workflow/references/pr-creation.md +269 -0
- package/skills/git-workflow/scripts/analyze-changes.sh +266 -0
- package/skills/git-workflow/scripts/create-pr.sh +464 -0
- package/skills/git-workflow/scripts/validate-commit.sh +235 -0
- package/skills/git-workflow/templates/agent-prompts.md +518 -0
- package/skills/git-workflow/templates/commit-types.md +504 -0
- package/skills/git-workflow/templates/documentation-decision.md +509 -0
- package/skills/git-workflow/templates/pr-template.md +772 -0
- package/skills/go-patterns/SKILL.md +89 -0
- package/skills/go-patterns/references/design-and-tooling.md +336 -0
- package/skills/go-patterns/references/errors-and-concurrency.md +292 -0
- package/skills/go-testing/SKILL.md +133 -0
- package/skills/go-testing/references/advanced-testing.md +349 -0
- package/skills/go-testing/references/test-structure.md +277 -0
- package/skills/hooks-workflow/SKILL.md +232 -0
- package/skills/hooks-workflow/references/support-notes.md +134 -0
- package/skills/hooks-workflow/references/templates/claude-settings.json.tmpl +13 -0
- package/skills/hooks-workflow/references/templates/codex-config-fragment.toml.tmpl +9 -0
- package/skills/hooks-workflow/references/templates/cursor-rule-fragment.mdc.tmpl +16 -0
- package/skills/hooks-workflow/scripts/build-hook-config.sh +487 -0
- package/skills/hooks-workflow/scripts/verify-hooks.sh +257 -0
- package/skills/implement-plan/SKILL.md +221 -0
- package/skills/implement-plan/references/agent-task-prompt.md +214 -0
- package/skills/implement-plan/references/output-formats.md +150 -0
- package/skills/implement-plan/references/plan-inputs.md +126 -0
- package/skills/implement-plan/scripts/check-prerequisites.sh +78 -0
- package/skills/implement-plan/scripts/parse-dependencies.sh +206 -0
- package/skills/init/SKILL.md +272 -0
- package/skills/init/references/conventional-commits.md +114 -0
- package/skills/init/references/flag-reference.md +236 -0
- package/skills/init/references/label-taxonomy.md +115 -0
- package/skills/init/references/project-profile-heuristics.md +156 -0
- package/skills/init/references/template-library.md +129 -0
- package/skills/init/scripts/count-source-files.sh +60 -0
- package/skills/init/scripts/generate-agent-catalog.sh +193 -0
- package/skills/init/scripts/generate-mcp-catalog.sh +214 -0
- package/skills/init/scripts/migrate-rules.py +459 -0
- package/skills/init/scripts/migrate-rules.sh +26 -0
- package/skills/init/scripts/profile-project.sh +453 -0
- package/skills/init/scripts/render-template.py +226 -0
- package/skills/init/scripts/render-template.sh +25 -0
- package/skills/init/scripts/rules-report.sh +31 -0
- package/skills/init/scripts/rules_file_lib.py +41 -0
- package/skills/init/templates/AGENTS.md.tmpl +38 -0
- package/skills/init/templates/CLAUDE.md.tmpl +7 -0
- package/skills/init/templates/ai-rule.md.tmpl +3 -0
- package/skills/init/templates/cursor-rule.mdc.tmpl +7 -0
- package/skills/init/templates/git/commitlint.config.cjs.tmpl +40 -0
- package/skills/init/templates/git/gitignore.tmpl +120 -0
- package/skills/init/templates/git/gitmessage.tmpl +27 -0
- package/skills/init/templates/git/install-lefthook.sh.tmpl +131 -0
- package/skills/init/templates/git/lefthook-usage.md.tmpl +101 -0
- package/skills/init/templates/git/lefthook.yml.tmpl +64 -0
- package/skills/init/templates/github/bug_report.yml.tmpl +78 -0
- package/skills/init/templates/github/config.yml.tmpl +5 -0
- package/skills/init/templates/github/copilot-instructions.md.tmpl +24 -0
- package/skills/init/templates/github/docs_request.yml.tmpl +41 -0
- package/skills/init/templates/github/feature_request.yml.tmpl +59 -0
- package/skills/init/templates/github/labels.md.tmpl +75 -0
- package/skills/init/templates/github/pull_request_template.md.tmpl +66 -0
- package/skills/init/templates/github/workflows/pr-title-autofix.yml.tmpl +101 -0
- package/skills/init/templates/github/workflows/pr-title.yml.tmpl +55 -0
- package/skills/init/templates/workspace-report.md +83 -0
- package/skills/orchestrate/SKILL.md +165 -0
- package/skills/orchestrate/references/agent-catalog.md +601 -0
- package/skills/orchestrate/references/agent-prompts.md +495 -0
- package/skills/orchestrate/references/dispatch-playbook.md +333 -0
- package/skills/orchestrate/references/task-breakdown.md +410 -0
- package/skills/orchestrate/scripts/analyze-task.sh +139 -0
- package/skills/orchestrate/scripts/summarize-results.sh +160 -0
- package/skills/orchestrate/scripts/validate-agents.sh +92 -0
- package/skills/parallel-plan/SKILL.md +124 -0
- package/skills/plan/SKILL.md +134 -0
- package/skills/plan/references/enhanced-personas.md +131 -0
- package/skills/plan/references/personas-and-merge.md +77 -0
- package/skills/plan/references/plan-validation.md +65 -0
- package/skills/plan/references/planner-prompts.md +68 -0
- package/skills/plan/references/planning-tracks.md +73 -0
- package/skills/plan-workflow/SKILL.md +406 -0
- package/skills/plan-workflow/references/checkpoint-messages.md +370 -0
- package/skills/plan-workflow/references/plan-structure.md +238 -0
- package/skills/plan-workflow/references/planning-agents.md +511 -0
- package/skills/plan-workflow/references/research-agents-optimized.md +348 -0
- package/skills/plan-workflow/references/research-agents.md +436 -0
- package/skills/plan-workflow/references/shared-structure.md +152 -0
- package/skills/plan-workflow/references/validation-agents.md +363 -0
- package/skills/plan-workflow/scripts/check-prerequisites.sh +65 -0
- package/skills/plan-workflow/scripts/check-state.sh +190 -0
- package/skills/plan-workflow/scripts/persist-or-fail.sh +135 -0
- package/skills/plan-workflow/scripts/validate-analysis-artifacts.sh +216 -0
- package/skills/plan-workflow/scripts/validate-research-artifacts.sh +225 -0
- package/skills/plan-workflow/scripts/validate-shared.sh +229 -0
- package/skills/plan-workflow/scripts/validate-workflow-plan.sh +256 -0
- package/skills/pr-autofix/SKILL.md +307 -0
- package/skills/pr-autofix/references/ci-loop.md +64 -0
- package/skills/pr-autofix/references/comment-sources.md +197 -0
- package/skills/pr-autofix/references/data-shapes.md +87 -0
- package/skills/pr-autofix/references/goal-example.md +30 -0
- package/skills/pr-autofix/references/output-templates.md +162 -0
- package/skills/pr-autofix/references/prompt-injection-safety.md +165 -0
- package/skills/pr-autofix/references/related-skills.md +11 -0
- package/skills/pr-autofix/references/severity-mapping.md +146 -0
- package/skills/pr-autofix/scripts/fetch-pr-comments.sh +364 -0
- package/skills/pr-autofix/scripts/post-summary.sh +226 -0
- package/skills/pr-autofix/scripts/resolve-thread.sh +251 -0
- package/skills/prp-commit/SKILL.md +128 -0
- package/skills/prp-implement/SKILL.md +177 -0
- package/skills/prp-implement/references/agent-task-prompt.md +36 -0
- package/skills/prp-implement/references/detection.md +49 -0
- package/skills/prp-implement/references/dry-run.md +0 -0
- package/skills/prp-implement/references/report-output.md +204 -0
- package/skills/prp-implement/references/validation-and-failures.md +118 -0
- package/skills/prp-plan/SKILL.md +323 -0
- package/skills/prp-plan/references/enhanced-researchers.md +425 -0
- package/skills/prp-plan/references/parallel-additions.md +56 -0
- package/skills/prp-plan/references/plan-template.md +264 -0
- package/skills/prp-plan/references/synthesis-map.md +25 -0
- package/skills/prp-plan/scripts/preflight-enhanced-agents.sh +111 -0
- package/skills/prp-plan/scripts/validate-prp-plan.sh +368 -0
- package/skills/prp-pr/SKILL.md +402 -0
- package/skills/prp-prd/SKILL.md +442 -0
- package/skills/prp-spec/SKILL.md +274 -0
- package/skills/python-patterns/SKILL.md +103 -0
- package/skills/python-patterns/references/core-idioms.md +304 -0
- package/skills/python-patterns/references/design-and-tooling.md +407 -0
- package/skills/python-testing/SKILL.md +114 -0
- package/skills/python-testing/references/mocking-and-integration.md +395 -0
- package/skills/python-testing/references/pytest-core.md +366 -0
- package/skills/quick-fix/SKILL.md +246 -0
- package/skills/quick-review/SKILL.md +304 -0
- package/skills/release-model/SKILL.md +231 -0
- package/skills/release-model/references/pointer-and-labels.md +83 -0
- package/skills/release-model/references/signals-and-proposal.md +68 -0
- package/skills/release-model/references/template-placeholders.md +42 -0
- package/skills/release-model/references/upgrade-and-audit.md +131 -0
- package/skills/release-model/scripts/collect-signals.sh +459 -0
- package/skills/release-model/scripts/pointer-targets.sh +29 -0
- package/skills/release-model/templates/RELEASING.md.tmpl +151 -0
- package/skills/releaser/SKILL.md +251 -0
- package/skills/releaser/references/ci-optimization-checklist.md +149 -0
- package/skills/releaser/references/ci-templates/docker-release.yml +88 -0
- package/skills/releaser/references/ci-templates/generic-release.yml +69 -0
- package/skills/releaser/references/ci-templates/go-release.yml +50 -0
- package/skills/releaser/references/ci-templates/node-release.yml +126 -0
- package/skills/releaser/references/ci-templates/python-release.yml +95 -0
- package/skills/releaser/references/ci-templates/rust-release.yml +128 -0
- package/skills/releaser/references/ci-workflow-modes.md +42 -0
- package/skills/releaser/references/goal-pairing.md +37 -0
- package/skills/releaser/references/output-templates.md +143 -0
- package/skills/releaser/references/project-type-matrix.md +144 -0
- package/skills/releaser/references/release-branches.md +138 -0
- package/skills/releaser/references/release-ci-loop.md +249 -0
- package/skills/releaser/references/release-notes-template.md +42 -0
- package/skills/releaser/references/release-preparation.md +210 -0
- package/skills/releaser/scripts/check-release-branch.sh +235 -0
- package/skills/releaser/scripts/detect-project.sh +234 -0
- package/skills/releaser/scripts/draft-changelog.sh +387 -0
- package/skills/releaser/scripts/publish-release.sh +302 -0
- package/skills/research-to-issues/SKILL.md +285 -0
- package/skills/research-to-issues/references/label-taxonomy.md +48 -0
- package/skills/research-to-issues/references/parse-deep-research.md +86 -0
- package/skills/research-to-issues/references/parse-feature-spec.md +143 -0
- package/skills/research-to-issues/references/parse-parallel-plan.md +124 -0
- package/skills/research-to-issues/references/parse-prd.md +184 -0
- package/skills/research-to-issues/references/parse-prp-plan.md +237 -0
- package/skills/research-to-issues/references/plan-display-format.md +136 -0
- package/skills/research-to-issues/scripts/validate-prerequisites.sh +312 -0
- package/skills/research-to-issues/templates/feature-issue.md +131 -0
- package/skills/research-to-issues/templates/task-issue.md +104 -0
- package/skills/research-to-issues/templates/tracking-issue.md +126 -0
- package/skills/resume-session/SKILL.md +152 -0
- package/skills/review-fix/SKILL.md +229 -0
- package/skills/review-fix/references/fix-report.md +121 -0
- package/skills/review-fix/references/fixer-dispatch.md +79 -0
- package/skills/review-fix/references/plan.md +119 -0
- package/skills/rust-patterns/SKILL.md +85 -0
- package/skills/rust-patterns/references/concurrency-unsafe-modules.md +243 -0
- package/skills/rust-patterns/references/ownership-errors-types.md +262 -0
- package/skills/rust-testing/SKILL.md +99 -0
- package/skills/rust-testing/references/advanced-testing.md +247 -0
- package/skills/rust-testing/references/unit-and-integration.md +193 -0
- package/skills/save-session/SKILL.md +159 -0
- package/skills/shared-context/SKILL.md +101 -0
- package/skills/ts-patterns/SKILL.md +159 -0
- package/skills/ts-patterns/references/async-runtimes-tooling.md +375 -0
- package/skills/ts-patterns/references/types-errors-modules.md +336 -0
- package/skills/ts-testing/SKILL.md +151 -0
- package/skills/ts-testing/references/advanced-testing.md +350 -0
- package/skills/ts-testing/references/vitest-core.md +318 -0
- package/skills/visual-plan/SKILL.md +221 -0
- package/skills/visual-plan/references/canvas.md +132 -0
- package/skills/visual-plan/references/document-quality.md +178 -0
- package/skills/visual-plan/references/exemplar.md +120 -0
- package/skills/visual-plan/references/wireframe.md +212 -0
- package/skills/visual-plan/scripts/derive-visual-dir.sh +77 -0
- package/skills/visual-recap/SKILL.md +238 -0
- package/skills/visual-recap/references/wireframe.md +237 -0
- package/skills/write-docs/SKILL.md +354 -0
- package/skills/write-docs/scripts/audit-documentation.sh +190 -0
- package/skills/write-docs/scripts/generate-doc-index.sh +125 -0
- package/skills/write-docs/scripts/verify-links.sh +81 -0
- package/skills/write-docs/templates/docs-readme.md +34 -0
- package/skills/write-docs/templates/documentation-strategy.md +91 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shared-context
|
|
3
|
+
description: Creates verified shared.md research context through plan-workflow. Use
|
|
4
|
+
when gathering codebase context, preparing shared context for parallel-plan, or
|
|
5
|
+
researching without generating a plan.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## MANDATORY FORCED MODE - READ FIRST
|
|
9
|
+
|
|
10
|
+
This skill is a thin alias. It ALWAYS runs canonical `plan-workflow` with
|
|
11
|
+
`--research-only --no-checkpoint` (stop after `shared.md` + validation, print
|
|
12
|
+
summary, no interactive checkpoint), regardless of `$ARGUMENTS`.
|
|
13
|
+
|
|
14
|
+
**Flag policy (unambiguous):**
|
|
15
|
+
|
|
16
|
+
- Supported: the feature name, `--dry-run`.
|
|
17
|
+
- Redundant — silently ignored because already forced: `--research-only`, `--no-checkpoint`.
|
|
18
|
+
- Every other flag (including `--plan-only`, `--no-worktree`, `--worktree`, `--visual`, `--optimized`, and any unknown `-`/`--` token) → abort with the usage error below. Do not read the canonical skill or write anything.
|
|
19
|
+
|
|
20
|
+
## SCOPE LIMITATION - READ FIRST
|
|
21
|
+
|
|
22
|
+
**THIS SKILL ONLY CREATES RESEARCH CONTEXT FILES. IT NEVER PLANS OR IMPLEMENTS.**
|
|
23
|
+
|
|
24
|
+
- DO NOT run the parallel-plan skill
|
|
25
|
+
- DO NOT run the implement-plan skill
|
|
26
|
+
- DO NOT execute implementation tasks
|
|
27
|
+
- DO NOT modify application source files
|
|
28
|
+
|
|
29
|
+
**Outputs**:
|
|
30
|
+
|
|
31
|
+
- `${PLANS_DIR}/[feature-name]/research-architecture.md`
|
|
32
|
+
- `${PLANS_DIR}/[feature-name]/research-patterns.md`
|
|
33
|
+
- `${PLANS_DIR}/[feature-name]/research-integration.md`
|
|
34
|
+
- `${PLANS_DIR}/[feature-name]/research-docs.md`
|
|
35
|
+
- `${PLANS_DIR}/[feature-name]/shared.md`
|
|
36
|
+
|
|
37
|
+
After creating the shared context files and displaying the summary, **STOP COMPLETELY**.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# Shared Context (alias)
|
|
42
|
+
|
|
43
|
+
> **OpenCode V2 compatibility:** `--team` is unsupported. If it is supplied, abort before setup or dispatch and ask the caller to rerun without it. This target uses native standalone `subagent` calls only.
|
|
44
|
+
|
|
45
|
+
## Arguments
|
|
46
|
+
|
|
47
|
+
**Target**: `$ARGUMENTS`
|
|
48
|
+
|
|
49
|
+
- **--dry-run**: Show orchestration plan without creating files. Writes nothing.
|
|
50
|
+
- **feature-name**: Required. Directory name under `${PLANS_DIR}` (kebab-case).
|
|
51
|
+
|
|
52
|
+
If any unsupported flag is present (see Flag policy above), abort with a usage error and STOP:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
Usage: /ycc:shared-context [feature-name] [--dry-run]
|
|
56
|
+
This alias always runs plan-workflow --research-only --no-checkpoint.
|
|
57
|
+
Unsupported flag: <flag>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If no feature name provided, abort with the same usage plus examples:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
/ycc:shared-context user-authentication
|
|
64
|
+
/ycc:shared-context payment-integration --dry-run
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Execution
|
|
68
|
+
|
|
69
|
+
Build the **effective `$ARGUMENTS`** for canonical `plan-workflow`:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
<feature-name> --research-only --no-checkpoint [--dry-run]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
1. Read `{{package-root}}/skills/plan-workflow/SKILL.md`.
|
|
77
|
+
2. Execute as orchestrator with the effective `$ARGUMENTS` above substituted for `$ARGUMENTS`, so the canonical parser itself sets `RESEARCH_ONLY=true` and `NO_CHECKPOINT=true` (those variables are explanatory only — never invocation syntax).
|
|
78
|
+
3. On completion print the research summary and STOP. Never plan or implement.
|
|
79
|
+
|
|
80
|
+
## Summary
|
|
81
|
+
|
|
82
|
+
```markdown
|
|
83
|
+
# Shared Context Created
|
|
84
|
+
|
|
85
|
+
## Location
|
|
86
|
+
|
|
87
|
+
${feature_dir}/shared.md
|
|
88
|
+
|
|
89
|
+
## Research Files
|
|
90
|
+
|
|
91
|
+
- ${feature_dir}/research-architecture.md
|
|
92
|
+
- ${feature_dir}/research-patterns.md
|
|
93
|
+
- ${feature_dir}/research-integration.md
|
|
94
|
+
- ${feature_dir}/research-docs.md
|
|
95
|
+
|
|
96
|
+
## Next Step (User Triggered)
|
|
97
|
+
|
|
98
|
+
/ycc:parallel-plan [feature-name]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**STOP**: Do not execute parallel-plan. Do not write any more files. Do not modify any code. This skill is complete.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ts-patterns
|
|
3
|
+
description: Guides framework-agnostic TypeScript types, modules, and async code.
|
|
4
|
+
Use when designing typed APIs, configuring strict tsconfig, or publishing ESM and
|
|
5
|
+
CJS libraries.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# TypeScript Development Patterns
|
|
9
|
+
|
|
10
|
+
Idiomatic TypeScript patterns for building safe, maintainable, inference-friendly
|
|
11
|
+
applications and libraries. TypeScript is JavaScript with a layered type system;
|
|
12
|
+
this skill covers language-level idioms, the type system, modules, async,
|
|
13
|
+
cross-runtime concerns, and the Vite + Vitest toolchain stack. Framework-agnostic —
|
|
14
|
+
for Next.js, React components, or Node backend architecture, defer to
|
|
15
|
+
`nextjs-ux-ui-expert`, `frontend-ui-developer`, or `nodejs-backend-architect`.
|
|
16
|
+
|
|
17
|
+
## Critical Rules
|
|
18
|
+
|
|
19
|
+
- Strict `tsconfig`: `"strict": true`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`.
|
|
20
|
+
- `catch` binds `unknown` — narrow explicitly; never assume `Error`.
|
|
21
|
+
- Discriminated unions with `never` exhaustiveness for states; `satisfies` over annotation.
|
|
22
|
+
- Inference-first APIs: design so callers don't pass type arguments.
|
|
23
|
+
- `Result<T, E>` for expected failures; `throw` only for bugs.
|
|
24
|
+
- Pass `AbortSignal` through every async call boundary.
|
|
25
|
+
- Web standards first (`fetch`, `URL`, `crypto.subtle`); `node:` prefix when Node-only.
|
|
26
|
+
|
|
27
|
+
## References
|
|
28
|
+
|
|
29
|
+
Paths are relative to this SKILL.md's directory. Read only the file that matches the task. If a file cannot be read, say so.
|
|
30
|
+
|
|
31
|
+
- [references/types-errors-modules.md](references/types-errors-modules.md)
|
|
32
|
+
Read when: type system (generics, conditional types, discriminated unions, `satisfies`, branded types, `unknown` narrowing in `catch`); error handling with `Result` for expected failures; modules, ESM/CJS dual publishing, `exports` maps.
|
|
33
|
+
|
|
34
|
+
- [references/async-runtimes-tooling.md](references/async-runtimes-tooling.md)
|
|
35
|
+
Read when: async and concurrency with `Promise` combinators and `AbortController`; iterators and higher-order functions; runtimes (Node/Deno/Bun/browser/edge); Vite + Vitest toolchain.
|
|
36
|
+
|
|
37
|
+
## When to Use
|
|
38
|
+
|
|
39
|
+
- Writing new TypeScript code
|
|
40
|
+
- Reviewing TypeScript code
|
|
41
|
+
- Refactoring existing TypeScript
|
|
42
|
+
- Designing libraries for npm (dual ESM/CJS publishing)
|
|
43
|
+
- Tuning `tsconfig.json` for strict mode
|
|
44
|
+
- Choosing a runtime (Node / Deno / Bun / browser / edge)
|
|
45
|
+
- Configuring Vite for apps or libraries
|
|
46
|
+
|
|
47
|
+
## How It Works
|
|
48
|
+
|
|
49
|
+
This skill enforces idiomatic TypeScript across seven key areas: a strict,
|
|
50
|
+
type-driven design that encodes invariants into the compiler; generic APIs where
|
|
51
|
+
inference flows naturally so callers don't annotate; discriminated unions with
|
|
52
|
+
`never` exhaustiveness to make illegal states unrepresentable; errors as values
|
|
53
|
+
with `unknown` in `catch` and typed boundaries; ESM-first modules with dual-publish
|
|
54
|
+
`exports` maps for libraries; `Promise`/`AbortController`-based async with Web
|
|
55
|
+
standards preferred over Node-only APIs; and a Vite + Vitest toolchain on a Node
|
|
56
|
+
host with clean paths to Deno, Bun, browser, and edge deploys.
|
|
57
|
+
|
|
58
|
+
## Core Principles
|
|
59
|
+
|
|
60
|
+
1. **Strict by default** — `"strict": true`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`
|
|
61
|
+
2. **Inference over annotation** — design APIs so callers don't pass type arguments
|
|
62
|
+
3. **Errors as values** — `Result<T, E>` at expected-failure boundaries; narrow `unknown` in `catch`
|
|
63
|
+
4. **Type-driven design** — encode invariants in types, not comments
|
|
64
|
+
5. **Zero-`any`** — except at clearly documented external boundaries
|
|
65
|
+
6. **Cross-runtime aware** — Web standards first; `node:` prefix when Node-only
|
|
66
|
+
|
|
67
|
+
## Quick Reference: TypeScript Idioms
|
|
68
|
+
|
|
69
|
+
| Idiom | Description |
|
|
70
|
+
| --------------------------- | ---------------------------------------------------------------------------------- |
|
|
71
|
+
| Strict by default | `"strict": true` + `noUncheckedIndexedAccess` + `exactOptionalPropertyTypes` |
|
|
72
|
+
| Discriminated unions | Model states as `\| { kind: 'a'; … } \| { kind: 'b'; … }` + `never` exhaustiveness |
|
|
73
|
+
| `satisfies` over annotation | Preserves literal types while type-checking against a wider shape |
|
|
74
|
+
| `unknown` in `catch` | Narrow explicitly; never assume `Error` |
|
|
75
|
+
| Errors as values | `Result<T, E>` for expected failures; throw for bugs |
|
|
76
|
+
| Inference-first APIs | Design so callers don't pass type arguments |
|
|
77
|
+
| Branded types | `T & { readonly [brand]: true }` prevents primitive mixups |
|
|
78
|
+
| ESM-first + `exports` map | Dual-publish with conditional exports; `sideEffects: false` |
|
|
79
|
+
| `AbortController` | Thread `signal` through every async boundary |
|
|
80
|
+
| Web standards first | Prefer `fetch` / `URL` / `crypto.subtle` over Node-only when portable |
|
|
81
|
+
| `readonly` at boundaries | Signal intent; prevent accidental mutation |
|
|
82
|
+
| Union over `enum` | `const` object + `keyof typeof` instead of `enum` |
|
|
83
|
+
|
|
84
|
+
## Anti-Patterns to Avoid
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// Bad: `any` leaks type errors everywhere
|
|
88
|
+
function process(data: any) {
|
|
89
|
+
return data.items.map((x: any) => x.name); // zero type safety
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Bad: double-cast bypasses the type system
|
|
93
|
+
const user = json as unknown as User; // use zod/valibot to parse+validate instead
|
|
94
|
+
|
|
95
|
+
// Bad: non-null assertion `!` in production code
|
|
96
|
+
const el = document.getElementById('root')!.innerHTML; // crashes if null
|
|
97
|
+
|
|
98
|
+
// Bad: `namespace` (legacy; use modules)
|
|
99
|
+
namespace MyLib {
|
|
100
|
+
export function foo() {}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Bad: `enum` (generates runtime code, weird semantics)
|
|
104
|
+
enum Status {
|
|
105
|
+
Active = 'active',
|
|
106
|
+
Inactive = 'inactive',
|
|
107
|
+
}
|
|
108
|
+
// Better: const object + union type
|
|
109
|
+
const Status = { Active: 'active', Inactive: 'inactive' } as const;
|
|
110
|
+
type Status = (typeof Status)[keyof typeof Status];
|
|
111
|
+
|
|
112
|
+
// Bad: `Function` / `Object` / `{}` (no safety)
|
|
113
|
+
function run(cb: Function) {
|
|
114
|
+
cb();
|
|
115
|
+
}
|
|
116
|
+
// Better: explicit signature
|
|
117
|
+
function runGood(cb: () => void) {
|
|
118
|
+
cb();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Bad: throwing from a library where failure is part of the contract
|
|
122
|
+
export function parseConfig(text: string): Config {
|
|
123
|
+
const data = JSON.parse(text); // throws — caller may not expect
|
|
124
|
+
return data;
|
|
125
|
+
}
|
|
126
|
+
// Better: return a Result or throw a typed error
|
|
127
|
+
|
|
128
|
+
// Bad: blocking in async context
|
|
129
|
+
async function badAsync() {
|
|
130
|
+
const buf = fs.readFileSync('file.txt'); // blocks the event loop
|
|
131
|
+
}
|
|
132
|
+
// Better:
|
|
133
|
+
import { readFile } from 'node:fs/promises';
|
|
134
|
+
async function goodAsync() {
|
|
135
|
+
const buf = await readFile('file.txt');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Bad: fire-and-forget await
|
|
139
|
+
async function saveUser(user: User): Promise<void> {
|
|
140
|
+
/* … */
|
|
141
|
+
}
|
|
142
|
+
saveUser(user); // errors swallowed silently
|
|
143
|
+
// Enable `@typescript-eslint/no-floating-promises` to catch this
|
|
144
|
+
|
|
145
|
+
// Bad: `as` cast instead of narrowing
|
|
146
|
+
function handle(value: unknown) {
|
|
147
|
+
const str = value as string;
|
|
148
|
+
return str.toUpperCase(); // crashes if value is not a string
|
|
149
|
+
}
|
|
150
|
+
// Better: type guard
|
|
151
|
+
function handleGood(value: unknown) {
|
|
152
|
+
if (typeof value !== 'string') throw new TypeError('expected string');
|
|
153
|
+
return value.toUpperCase();
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Remember**: Great TypeScript is invisible. Let the type system encode invariants,
|
|
158
|
+
let inference do the work, and reach for `any` only at clearly documented boundaries.
|
|
159
|
+
If the compiler can't catch it, the runtime will — and by then it's too late.
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# TypeScript Development Patterns: Async, Runtimes, and Tooling
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Async and Concurrency
|
|
6
|
+
- Iterators and Higher-Order Functions
|
|
7
|
+
- Runtimes
|
|
8
|
+
- Tooling (Vite + Vitest Stack)
|
|
9
|
+
|
|
10
|
+
## Async and Concurrency
|
|
11
|
+
|
|
12
|
+
### Promise Combinators
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
// Good: parallel fetches, fail fast on any rejection
|
|
16
|
+
const [user, orders, prefs] = await Promise.all([fetchUser(id), fetchOrders(id), fetchPrefs(id)]);
|
|
17
|
+
|
|
18
|
+
// Good: collect all results including failures
|
|
19
|
+
const results = await Promise.allSettled([task1(), task2(), task3()]);
|
|
20
|
+
for (const r of results) {
|
|
21
|
+
if (r.status === 'fulfilled') handle(r.value);
|
|
22
|
+
else logError(r.reason);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Good: race with timeout — abort the loser so it stops running
|
|
26
|
+
const taskController = new AbortController();
|
|
27
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
28
|
+
try {
|
|
29
|
+
await Promise.race([
|
|
30
|
+
longRunningTask(taskController.signal),
|
|
31
|
+
new Promise<never>((_, reject) => {
|
|
32
|
+
timeout = setTimeout(() => {
|
|
33
|
+
reject(new Error('timeout'));
|
|
34
|
+
taskController.abort();
|
|
35
|
+
}, 5000);
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
} finally {
|
|
39
|
+
clearTimeout(timeout!);
|
|
40
|
+
taskController.abort();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Good: `Promise.any` — first success wins, all failures aggregate
|
|
44
|
+
const fastest = await Promise.any([
|
|
45
|
+
fetch('https://mirror1.example.com/data'),
|
|
46
|
+
fetch('https://mirror2.example.com/data'),
|
|
47
|
+
fetch('https://mirror3.example.com/data'),
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
// Bad: sequential awaits when parallel is possible
|
|
51
|
+
const userBad = await fetchUser(id);
|
|
52
|
+
const ordersBad = await fetchOrders(id); // waits unnecessarily
|
|
53
|
+
const prefsBad = await fetchPrefs(id);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### `AbortController` for Cancellation
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// Good: cancellable fetch with timeout
|
|
60
|
+
async function fetchWithTimeout(url: string, ms: number): Promise<Response> {
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const timer = setTimeout(() => controller.abort(), ms);
|
|
63
|
+
try {
|
|
64
|
+
return await fetch(url, { signal: controller.signal });
|
|
65
|
+
} finally {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Good: thread an external signal through every async boundary
|
|
71
|
+
async function fetchUsers(signal?: AbortSignal): Promise<User[]> {
|
|
72
|
+
const res = await fetch('/api/users', { signal });
|
|
73
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
74
|
+
return res.json();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Good: combine signals with `AbortSignal.any` (modern)
|
|
78
|
+
const combined = AbortSignal.any([userSignal, timeoutSignal]);
|
|
79
|
+
await fetchUsers(combined);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Async Iterators for Streaming
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
// Good: stream large datasets without buffering everything in memory
|
|
86
|
+
async function* paginate<T>(
|
|
87
|
+
fetchPage: (cursor: string | null) => Promise<{ items: T[]; next: string | null }>
|
|
88
|
+
): AsyncGenerator<T> {
|
|
89
|
+
let cursor: string | null = null;
|
|
90
|
+
do {
|
|
91
|
+
const { items, next } = await fetchPage(cursor);
|
|
92
|
+
for (const item of items) yield item;
|
|
93
|
+
cursor = next;
|
|
94
|
+
} while (cursor !== null);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Usage
|
|
98
|
+
for await (const user of paginate(fetchUserPage)) {
|
|
99
|
+
process(user);
|
|
100
|
+
if (shouldStop()) break; // iterator cleans up automatically
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Iterators and Higher-Order Functions
|
|
105
|
+
|
|
106
|
+
### Prefer `map` / `filter` / `reduce` Over Imperative Loops
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// Good: declarative and composable
|
|
110
|
+
const activeEmails = users.filter((u) => u.isActive).map((u) => u.email);
|
|
111
|
+
|
|
112
|
+
// Good: reduce for aggregation with explicit accumulator type
|
|
113
|
+
const byId = users.reduce<Record<string, User>>((acc, u) => {
|
|
114
|
+
acc[u.id] = u;
|
|
115
|
+
return acc;
|
|
116
|
+
}, {});
|
|
117
|
+
|
|
118
|
+
// Good: group with `reduce` on the ES2022 baseline
|
|
119
|
+
// (`Object.groupBy` needs an ES2024 lib and runtime)
|
|
120
|
+
const byRole = users.reduce<Record<string, User[]>>((acc, u) => {
|
|
121
|
+
(acc[u.role] ??= []).push(u);
|
|
122
|
+
return acc;
|
|
123
|
+
}, {});
|
|
124
|
+
|
|
125
|
+
// Bad: mutable accumulator with an imperative loop
|
|
126
|
+
const activeEmailsBad: string[] = [];
|
|
127
|
+
for (const u of users) {
|
|
128
|
+
if (u.isActive) activeEmailsBad.push(u.email);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Generators for Lazy Iteration
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// Good: lazy range without allocating an array
|
|
136
|
+
function* range(start: number, end: number, step = 1): Generator<number> {
|
|
137
|
+
if (!Number.isFinite(step) || step <= 0) throw new Error('step must be a positive finite number');
|
|
138
|
+
for (let i = start; i < end; i += step) yield i;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const n of range(0, 1_000_000)) {
|
|
142
|
+
if (n > 100) break; // only 101 numbers produced
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Immutability by Default
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
// Good: `readonly` signals intent and prevents accidental mutation
|
|
150
|
+
function total(items: readonly { price: number }[]): number {
|
|
151
|
+
return items.reduce((sum, item) => sum + item.price, 0);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Good: return new objects rather than mutating
|
|
155
|
+
function addItem(cart: readonly Item[], item: Item): readonly Item[] {
|
|
156
|
+
return [...cart, item];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Good: use `Readonly<T>` and `ReadonlyArray<T>` at API boundaries
|
|
160
|
+
function render(props: Readonly<{ name: string; items: ReadonlyArray<Item> }>): void {
|
|
161
|
+
/* can't mutate props.items */
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Runtimes
|
|
166
|
+
|
|
167
|
+
TypeScript runs on many runtimes; pick based on deployment model, cold-start
|
|
168
|
+
tolerance, API surface needs, and operational complexity.
|
|
169
|
+
|
|
170
|
+
### Node (primary)
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
// Primary tooling host — Vite, Vitest, tsc, ESLint all run on Node
|
|
174
|
+
// Primary deploy target for servers, CLIs, scripts, build tools
|
|
175
|
+
// Use `node:` prefix for built-ins — forces Node resolver, avoids shadowing
|
|
176
|
+
import { readFile } from 'node:fs/promises';
|
|
177
|
+
import { createHash } from 'node:crypto';
|
|
178
|
+
import { setTimeout } from 'node:timers/promises';
|
|
179
|
+
|
|
180
|
+
await setTimeout(100);
|
|
181
|
+
const data = await readFile('config.json', 'utf8');
|
|
182
|
+
const hash = createHash('sha256').update(data).digest('hex');
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Deno
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
// Secure by default — explicit permissions at run time
|
|
189
|
+
// $ deno run --allow-read --allow-net script.ts
|
|
190
|
+
// Single-file tooling: deno fmt, deno lint, deno test, deno bundle
|
|
191
|
+
// npm compat: `import pkg from 'npm:pkg@1.0.0'`
|
|
192
|
+
|
|
193
|
+
const data = await Deno.readTextFile('config.json');
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Bun
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
// Fast install + run; Jest-compatible test runner; native bundler
|
|
200
|
+
// Drop-in Node compatibility for most packages
|
|
201
|
+
// $ bun install && bun run dev
|
|
202
|
+
// $ bun test
|
|
203
|
+
|
|
204
|
+
import { file } from 'bun';
|
|
205
|
+
const text = await file('config.json').text();
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Browser
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
// Use Web standards only — no Node built-ins
|
|
212
|
+
// Bundle for target browsers via Vite (`vite build`)
|
|
213
|
+
const res = await fetch('/api/config');
|
|
214
|
+
const config = await res.json();
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Edge (Cloudflare Workers, Vercel Edge, Deno Deploy)
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
// V8 isolates — cold starts measured in milliseconds
|
|
221
|
+
// Web standard APIs only; no `fs`, no long-lived processes
|
|
222
|
+
// Rely on fetch, URL, Request/Response, crypto.subtle, streams
|
|
223
|
+
|
|
224
|
+
export default {
|
|
225
|
+
async fetch(request: Request): Promise<Response> {
|
|
226
|
+
const url = new URL(request.url);
|
|
227
|
+
return new Response(`hello from ${url.pathname}`);
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Tooling (Vite + Vitest Stack)
|
|
233
|
+
|
|
234
|
+
### Strict `tsconfig` Baseline
|
|
235
|
+
|
|
236
|
+
```jsonc
|
|
237
|
+
// tsconfig.json — recommended strict baseline
|
|
238
|
+
{
|
|
239
|
+
"compilerOptions": {
|
|
240
|
+
"target": "ES2022",
|
|
241
|
+
"module": "ESNext",
|
|
242
|
+
"moduleResolution": "bundler",
|
|
243
|
+
"strict": true,
|
|
244
|
+
"noUncheckedIndexedAccess": true,
|
|
245
|
+
"exactOptionalPropertyTypes": true,
|
|
246
|
+
"noImplicitReturns": true,
|
|
247
|
+
"noFallthroughCasesInSwitch": true,
|
|
248
|
+
"noUnusedLocals": true,
|
|
249
|
+
"noUnusedParameters": true,
|
|
250
|
+
"isolatedModules": true,
|
|
251
|
+
"esModuleInterop": true,
|
|
252
|
+
"skipLibCheck": true,
|
|
253
|
+
"forceConsistentCasingInFileNames": true,
|
|
254
|
+
"resolveJsonModule": true,
|
|
255
|
+
"verbatimModuleSyntax": true,
|
|
256
|
+
"noEmit": true,
|
|
257
|
+
},
|
|
258
|
+
"include": ["src/**/*", "tests/**/*"],
|
|
259
|
+
"exclude": ["dist", "node_modules"],
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Vite for Apps
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
// vite.config.ts — dev server + production bundle
|
|
267
|
+
import { defineConfig } from 'vite';
|
|
268
|
+
import { resolve } from 'node:path';
|
|
269
|
+
|
|
270
|
+
export default defineConfig({
|
|
271
|
+
build: {
|
|
272
|
+
target: 'es2022',
|
|
273
|
+
sourcemap: true,
|
|
274
|
+
rollupOptions: {
|
|
275
|
+
input: { main: resolve(__dirname, 'index.html') },
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
server: { port: 5173 },
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Vite for Libraries (`vite build --lib`)
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
// vite.config.ts — dual-publish library build
|
|
286
|
+
import { defineConfig } from 'vite';
|
|
287
|
+
import dts from 'vite-plugin-dts';
|
|
288
|
+
import { resolve } from 'node:path';
|
|
289
|
+
|
|
290
|
+
export default defineConfig({
|
|
291
|
+
plugins: [dts({ rollupTypes: true })],
|
|
292
|
+
build: {
|
|
293
|
+
lib: {
|
|
294
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
295
|
+
formats: ['es', 'cjs'],
|
|
296
|
+
fileName: (format) => `index.${format === 'es' ? 'mjs' : 'cjs'}`,
|
|
297
|
+
},
|
|
298
|
+
rollupOptions: {
|
|
299
|
+
// Don't bundle peer dependencies
|
|
300
|
+
external: ['react', 'react-dom'],
|
|
301
|
+
},
|
|
302
|
+
sourcemap: true,
|
|
303
|
+
minify: false, // let downstream bundlers minify
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### `vitest.config.ts` Sharing Vite's Pipeline
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
// vitest.config.ts — reuse dev/build transform pipeline for tests
|
|
312
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
313
|
+
import viteConfig from './vite.config';
|
|
314
|
+
|
|
315
|
+
export default mergeConfig(
|
|
316
|
+
viteConfig,
|
|
317
|
+
defineConfig({
|
|
318
|
+
test: {
|
|
319
|
+
globals: false,
|
|
320
|
+
environment: 'node',
|
|
321
|
+
coverage: {
|
|
322
|
+
provider: 'v8',
|
|
323
|
+
reporter: ['text', 'html', 'lcov'],
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
})
|
|
327
|
+
);
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### pnpm Workspaces for Monorepos
|
|
331
|
+
|
|
332
|
+
```yaml
|
|
333
|
+
# pnpm-workspace.yaml
|
|
334
|
+
packages:
|
|
335
|
+
- 'packages/*'
|
|
336
|
+
- 'apps/*'
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
```jsonc
|
|
340
|
+
// turbo.json — coordinate builds across workspaces
|
|
341
|
+
{
|
|
342
|
+
"pipeline": {
|
|
343
|
+
"build": { "dependsOn": ["^build"], "outputs": ["dist/**"] },
|
|
344
|
+
"test": { "dependsOn": ["build"] },
|
|
345
|
+
"lint": {},
|
|
346
|
+
},
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Linting and Formatting
|
|
351
|
+
|
|
352
|
+
```jsonc
|
|
353
|
+
// biome.json — all-in-one formatter + linter (fastest option in 2026)
|
|
354
|
+
{
|
|
355
|
+
"linter": {
|
|
356
|
+
"enabled": true,
|
|
357
|
+
"rules": { "recommended": true },
|
|
358
|
+
},
|
|
359
|
+
"formatter": {
|
|
360
|
+
"enabled": true,
|
|
361
|
+
"indentStyle": "space",
|
|
362
|
+
"indentWidth": 2,
|
|
363
|
+
},
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### When to Reach for Something Other Than Vite
|
|
368
|
+
|
|
369
|
+
- **tsup** — Node libraries with dozens of entry points; tsup's multi-entry support
|
|
370
|
+
is simpler than Vite's lib mode for this shape.
|
|
371
|
+
- **esbuild directly** — custom build scripts where raw bundle speed matters and
|
|
372
|
+
you want minimal config.
|
|
373
|
+
- **Rollup directly** — maximum control over output; Vite already uses Rollup for
|
|
374
|
+
production builds, so you can drop into config-level Rollup when needed.
|
|
375
|
+
- **webpack** — legacy projects with loaders that haven't been ported to Vite.
|