@khoavu882/doflow 0.0.0-stage → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +132 -2
- package/bin/doflow.js +44 -0
- package/core/.antigravity-plugin/hooks.json +39 -0
- package/core/.antigravity-plugin/mcp_config.json +18 -0
- package/core/.antigravity-plugin/plugin.json +31 -0
- package/core/.claude-plugin/marketplace.json +20 -0
- package/core/.claude-plugin/plugin.json +21 -0
- package/core/.codex-plugin/marketplace.json +20 -0
- package/core/.codex-plugin/plugin.json +35 -0
- package/core/.plugin/plugin.json +19 -0
- package/core/harnesses/antigravity/hooks/pre-implementation-gate.sh +9 -0
- package/core/harnesses/antigravity/hooks/stop-check.sh +10 -0
- package/core/harnesses/claude/hooks/lib.sh +304 -0
- package/core/harnesses/claude/hooks/mcp-tool-guard.sh +20 -0
- package/core/harnesses/claude/hooks/permission-audit.sh +47 -0
- package/core/harnesses/claude/hooks/post-compact.sh +74 -0
- package/core/harnesses/claude/hooks/post-edit-lint.sh +36 -0
- package/core/harnesses/claude/hooks/post-tool-failure.sh +47 -0
- package/core/harnesses/claude/hooks/pre-bash-guard.sh +20 -0
- package/core/harnesses/claude/hooks/pre-compact.sh +43 -0
- package/core/harnesses/claude/hooks/pre-implement-gate.sh +21 -0
- package/core/harnesses/claude/hooks/session-end.sh +89 -0
- package/core/harnesses/claude/hooks/session-start.sh +5 -0
- package/core/harnesses/claude/hooks/skill-config-audit.sh +39 -0
- package/core/harnesses/claude/hooks/stop-check.sh +5 -0
- package/core/harnesses/claude/hooks/subagent-audit.sh +7 -0
- package/core/harnesses/claude/hooks/user-prompt-submit.sh +5 -0
- package/core/harnesses/claude/settings/keybindings.json +20 -0
- package/core/harnesses/claude/settings/settings.json +201 -0
- package/core/harnesses/claude/statusline/doflow-statusline.sh +49 -0
- package/core/harnesses/codex/agents/core-implementer.toml +7 -0
- package/core/harnesses/codex/agents/quality-guardian.toml +8 -0
- package/core/harnesses/codex/agents/research-writer.toml +8 -0
- package/core/harnesses/codex/agents/spec-analyst.toml +8 -0
- package/core/harnesses/codex/agents/system-architect.toml +9 -0
- package/core/harnesses/codex/config/config.toml +10 -0
- package/core/harnesses/codex/hooks/hooks.json +122 -0
- package/core/harnesses/codex/hooks/lib.sh +335 -0
- package/core/harnesses/codex/hooks/mcp-tool-guard.sh +18 -0
- package/core/harnesses/codex/hooks/post-edit-lint.impl.sh +52 -0
- package/core/harnesses/codex/hooks/post-edit-lint.sh +6 -0
- package/core/harnesses/codex/hooks/pre-bash-guard.sh +18 -0
- package/core/harnesses/codex/hooks/pre-compact.impl.sh +46 -0
- package/core/harnesses/codex/hooks/pre-compact.sh +9 -0
- package/core/harnesses/codex/hooks/pre-implement-gate.sh +19 -0
- package/core/harnesses/codex/hooks/session-end.impl.sh +92 -0
- package/core/harnesses/codex/hooks/session-end.sh +5 -0
- package/core/harnesses/codex/hooks/session-start.sh +5 -0
- package/core/harnesses/codex/hooks/stop-check.sh +8 -0
- package/core/harnesses/codex/hooks/subagent-audit.sh +8 -0
- package/core/harnesses/codex/hooks/user-prompt-submit.sh +6 -0
- package/core/harnesses/gemini/hooks/hooks.json +77 -0
- package/core/harnesses/gemini/hooks/lib.sh +302 -0
- package/core/harnesses/gemini/hooks/mcp-tool-guard.sh +21 -0
- package/core/harnesses/gemini/hooks/post-edit-lint.sh +39 -0
- package/core/harnesses/gemini/hooks/pre-bash-guard.sh +21 -0
- package/core/harnesses/gemini/hooks/pre-compact.sh +38 -0
- package/core/harnesses/gemini/hooks/pre-implement-gate.sh +22 -0
- package/core/harnesses/gemini/hooks/session-end.impl.sh +89 -0
- package/core/harnesses/gemini/hooks/session-end.sh +5 -0
- package/core/harnesses/gemini/hooks/session-start.sh +5 -0
- package/core/harnesses/gemini/settings/adapter-defaults.json +4 -0
- package/core/harnesses/kiro/agents/doflow.json +58 -0
- package/core/harnesses/kiro/hooks/doflow.json +53 -0
- package/core/harnesses/kiro/hooks/lib.sh +324 -0
- package/core/harnesses/kiro/hooks/mcp-tool-guard.sh +9 -0
- package/core/harnesses/kiro/hooks/pre-bash-guard.sh +9 -0
- package/core/harnesses/kiro/hooks/pre-implement-gate.sh +9 -0
- package/core/harnesses/kiro/hooks/session-start.sh +9 -0
- package/core/harnesses/kiro/hooks/stop-check.sh +43 -0
- package/core/harnesses/shared/hooks/ENVELOPE_MIGRATION.md +39 -0
- package/core/harnesses/shared/hooks/adapters/antigravity.js +111 -0
- package/core/harnesses/shared/hooks/adapters/arg-fields.js +19 -0
- package/core/harnesses/shared/hooks/adapters/gemini.js +114 -0
- package/core/harnesses/shared/hooks/hooks.json +47 -0
- package/core/harnesses/shared/hooks/policies/blocked-patterns.conf +91 -0
- package/core/harnesses/shared/hooks/policies/capture-failure.sh +97 -0
- package/core/harnesses/shared/hooks/policies/deny-json.sh +29 -0
- package/core/harnesses/shared/hooks/policies/lib.sh +501 -0
- package/core/harnesses/shared/hooks/policies/mcp-policy.conf +21 -0
- package/core/harnesses/shared/hooks/policies/mcp-tool-guard.sh +91 -0
- package/core/harnesses/shared/hooks/policies/pre-bash-guard.sh +328 -0
- package/core/harnesses/shared/hooks/policies/pre-implementation-gate.sh +496 -0
- package/core/harnesses/shared/hooks/policies/prompt-nudge.jq +131 -0
- package/core/harnesses/shared/hooks/policies/session-context.sh +141 -0
- package/core/harnesses/shared/hooks/policies/stop-check.sh +264 -0
- package/core/harnesses/shared/hooks/policies/subagent-audit.sh +46 -0
- package/core/harnesses/shared/hooks/policies/user-prompt-submit.sh +235 -0
- package/core/harnesses/shared/hooks/stream-hook-runner.js +590 -0
- package/core/harnesses/shared/locator/doflow-run +87 -0
- package/core/registry/advice.json +101 -0
- package/core/registry/assets.json +792 -0
- package/core/registry/capabilities.json +120 -0
- package/core/registry/contracts.json +189 -0
- package/core/registry/external-tools.json +191 -0
- package/core/registry/harnesses.json +2062 -0
- package/core/registry/lifecycle.json +231 -0
- package/core/registry/mcp.json +18 -0
- package/core/registry/models.json +79 -0
- package/core/registry/readiness-templates.json +118 -0
- package/core/registry/routes.json +47 -0
- package/core/registry/storage.json +1057 -0
- package/core/registry/verification.json +258 -0
- package/core/registry/workflows.json +790 -0
- package/core/shared/agent-specs/core-implementer.md +73 -0
- package/core/shared/agent-specs/quality-guardian.md +28 -0
- package/core/shared/agent-specs/research-writer.md +31 -0
- package/core/shared/agent-specs/spec-analyst.md +33 -0
- package/core/shared/agent-specs/system-architect.md +29 -0
- package/core/shared/guidance/DOFLOW_CORE.md +8 -0
- package/core/shared/guidance/FLAGS.md +25 -0
- package/core/shared/guidance/PRINCIPLES.md +61 -0
- package/core/shared/guidance/VERSION +1 -0
- package/core/shared/guidance/mcp/MCP_Context7.md +18 -0
- package/core/shared/guidance/mcp/MCP_Sequential.md +17 -0
- package/core/shared/guidance/modes/MODE_Brainstorming.md +46 -0
- package/core/shared/guidance/modes/MODE_DeepResearch.md +69 -0
- package/core/shared/guidance/modes/MODE_Introspection.md +33 -0
- package/core/shared/guidance/modes/MODE_Orchestration.md +57 -0
- package/core/shared/guidance/modes/MODE_Task_Management.md +74 -0
- package/core/shared/guidance/pointers/claude-gemini.md +2 -0
- package/core/shared/guidance/pointers/codex.md +6 -0
- package/core/shared/guidance/references/ARTIFACT_FORMAT.md +373 -0
- package/core/shared/guidance/references/ARTIFACT_VOICE.md +104 -0
- package/core/shared/guidance/references/CONSTITUTION_BASE.md +47 -0
- package/core/shared/guidance/references/DIAGRAM_GUIDE.md +161 -0
- package/core/shared/guidance/references/DOFLOW_CHAIN.md +87 -0
- package/core/shared/guidance/references/EVIDENCE_LEDGER.md +93 -0
- package/core/shared/guidance/references/MODEL_SELECTION.md +74 -0
- package/core/shared/guidance/references/ORCHESTRATION.md +36 -0
- package/core/shared/guidance/references/RESEARCH_CONFIG.md +21 -0
- package/core/shared/guidance/references/WORKFLOW_HANDOFF.md +81 -0
- package/core/shared/guidance/rules/RULE_01_SAFETY.md +25 -0
- package/core/shared/guidance/rules/RULE_02_WORKFLOW.md +23 -0
- package/core/shared/guidance/rules/RULE_03_QUALITY.md +14 -0
- package/core/shared/guidance/rules/RULE_04_QUESTIONS.md +46 -0
- package/core/shared/scripts/doflow/assets/mermaid-theme.json +46 -0
- package/core/shared/scripts/doflow/bash/do-exec-paths.sh +167 -0
- package/core/shared/scripts/doflow/bash/do-git-state.sh +546 -0
- package/core/shared/scripts/doflow/bash/do-parallel-check.sh +208 -0
- package/core/shared/scripts/doflow/bash/do-paths.sh +347 -0
- package/core/shared/scripts/doflow/bash/do-prereqs.sh +66 -0
- package/core/shared/scripts/doflow/bash/do-review-package.sh +127 -0
- package/core/shared/scripts/doflow/bash/do-task-brief.sh +698 -0
- package/core/shared/scripts/doflow/bash/render-audit.sh +224 -0
- package/core/shared/scripts/doflow/bash/render-diagrams.sh +177 -0
- package/core/shared/scripts/doflow/bash/render-puml.sh +223 -0
- package/core/shared/scripts/doflow/bash/sync-context.sh +66 -0
- package/core/shared/scripts/doflow/bash/validate-artifacts.sh +526 -0
- package/core/shared/scripts/doflow/bin/doflow-run +592 -0
- package/core/shared/skills/do/SKILL.md +128 -0
- package/core/shared/skills/do/references/estimation.md +13 -0
- package/core/shared/skills/do/references/pm_routing.md +25 -0
- package/core/shared/skills/do/references/tool_matrix.md +52 -0
- package/core/shared/skills/do-brainstorm/SKILL.md +252 -0
- package/core/shared/skills/do-code-review/README.md +49 -0
- package/core/shared/skills/do-code-review/SKILL.md +333 -0
- package/core/shared/skills/do-code-review/assets/sample_c_clean.c +71 -0
- package/core/shared/skills/do-code-review/assets/sample_c_smells.c +66 -0
- package/core/shared/skills/do-code-review/assets/sample_cpp_shift.cpp +19 -0
- package/core/shared/skills/do-code-review/assets/sample_csharp_clean.cs +100 -0
- package/core/shared/skills/do-code-review/assets/sample_csharp_smells.cs +78 -0
- package/core/shared/skills/do-code-review/assets/sample_java_clean.java +55 -0
- package/core/shared/skills/do-code-review/assets/sample_java_smells.java +56 -0
- package/core/shared/skills/do-code-review/assets/sample_json_clean.json +7 -0
- package/core/shared/skills/do-code-review/assets/sample_markdown_clean.md +30 -0
- package/core/shared/skills/do-code-review/assets/sample_markdown_smells.md +29 -0
- package/core/shared/skills/do-code-review/assets/sample_shell_heredoc.sh +38 -0
- package/core/shared/skills/do-code-review/assets/sample_shell_smells.sh +15 -0
- package/core/shared/skills/do-code-review/assets/sample_typescript_strings.ts +36 -0
- package/core/shared/skills/do-code-review/assets/sample_yaml_smells.yaml +6 -0
- package/core/shared/skills/do-code-review/content-types/config.md +83 -0
- package/core/shared/skills/do-code-review/content-types/markdown.md +132 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_c_clean_quality.json +79 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_c_smells_quality.json +169 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_cpp_shift_quality.json +49 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_csharp_clean_quality.json +149 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_csharp_smells_quality.json +157 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_java_clean_quality.json +67 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_java_smells_quality.json +97 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_json_clean_quality.json +33 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_markdown_clean_quality.json +1 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_markdown_smells_quality.json +16 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_shell_heredoc_quality.json +54 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_shell_smells_quality.json +91 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_typescript_strings_quality.json +60 -0
- package/core/shared/skills/do-code-review/expected_outputs/sample_yaml_smells_quality.json +46 -0
- package/core/shared/skills/do-code-review/languages/c.md +103 -0
- package/core/shared/skills/do-code-review/languages/cpp.md +103 -0
- package/core/shared/skills/do-code-review/languages/csharp.md +97 -0
- package/core/shared/skills/do-code-review/languages/dart.md +108 -0
- package/core/shared/skills/do-code-review/languages/go.md +92 -0
- package/core/shared/skills/do-code-review/languages/java.md +103 -0
- package/core/shared/skills/do-code-review/languages/kotlin.md +88 -0
- package/core/shared/skills/do-code-review/languages/php.md +109 -0
- package/core/shared/skills/do-code-review/languages/python.md +94 -0
- package/core/shared/skills/do-code-review/languages/ruby.md +105 -0
- package/core/shared/skills/do-code-review/languages/rust.md +99 -0
- package/core/shared/skills/do-code-review/languages/shell.md +90 -0
- package/core/shared/skills/do-code-review/languages/swift.md +88 -0
- package/core/shared/skills/do-code-review/languages/typescript.md +97 -0
- package/core/shared/skills/do-code-review/review-policy.json +47 -0
- package/core/shared/skills/do-code-review/rules/universal.md +49 -0
- package/core/shared/skills/do-code-review/scripts/code_quality_checker.py +1696 -0
- package/core/shared/skills/do-code-review/scripts/doc_quality_checker.py +532 -0
- package/core/shared/skills/do-code-review/scripts/pr_analyzer.py +620 -0
- package/core/shared/skills/do-code-review/scripts/review_report_generator.py +505 -0
- package/core/shared/skills/do-constitution/SKILL.md +72 -0
- package/core/shared/skills/do-design/SKILL.md +212 -0
- package/core/shared/skills/do-diagnose/SKILL.md +156 -0
- package/core/shared/skills/do-diagnose/references/code_audit.md +15 -0
- package/core/shared/skills/do-diagnose/references/refactoring.md +12 -0
- package/core/shared/skills/do-diagnose/references/root_cause.md +17 -0
- package/core/shared/skills/do-document/SKILL.md +81 -0
- package/core/shared/skills/do-document/references/api-reference.md +42 -0
- package/core/shared/skills/do-document/references/deep_research.md +18 -0
- package/core/shared/skills/do-document/references/embedded-research.md +11 -0
- package/core/shared/skills/do-document/references/implementation-flow.md +105 -0
- package/core/shared/skills/do-document/references/index_generator.md +9 -0
- package/core/shared/skills/do-document/references/user-guide.md +22 -0
- package/core/shared/skills/do-execute-plan/SKILL.md +261 -0
- package/core/shared/skills/do-execute-plan/references/handoff_record.md +57 -0
- package/core/shared/skills/do-execute-plan/references/parallel_dispatch.md +92 -0
- package/core/shared/skills/do-execute-plan/references/readiness_gate.md +155 -0
- package/core/shared/skills/do-execute-plan/references/run_position.md +63 -0
- package/core/shared/skills/do-execute-plan/references/scaffold.md +441 -0
- package/core/shared/skills/do-execute-plan/references/task_attempts.md +41 -0
- package/core/shared/skills/do-flow/SKILL.md +186 -0
- package/core/shared/skills/do-flow/references/task_classes.md +134 -0
- package/core/shared/skills/do-git/SKILL.md +115 -0
- package/core/shared/skills/do-git/references/hotfix-ritual.md +44 -0
- package/core/shared/skills/do-git/references/lifecycle-policy.md +54 -0
- package/core/shared/skills/do-git/references/release-ritual.md +64 -0
- package/core/shared/skills/do-implement/SKILL.md +222 -0
- package/core/shared/skills/do-plan/SKILL.md +219 -0
- package/core/shared/skills/do-test/SKILL.md +113 -0
- package/core/shared/templates/doflow/constitution-template.md +28 -0
- package/core/shared/templates/doflow/data-model-template.md +169 -0
- package/core/shared/templates/doflow/design-template.md +193 -0
- package/core/shared/templates/doflow/external-contract-template.md +35 -0
- package/core/shared/templates/doflow/intent-template.md +45 -0
- package/core/shared/templates/doflow/plan-template.md +151 -0
- package/core/shared/templates/doflow/question-log-template.md +51 -0
- package/core/shared/templates/doflow/requirement-template.md +126 -0
- package/core/shared/templates/doflow/specs-template.md +55 -0
- package/core/shared/templates/doflow/state-template.md +59 -0
- package/core/shared/workflows/do-flow-chain.md +17 -0
- package/package.json +46 -4
- package/src/adapters/antigravity/index.ts +631 -0
- package/src/adapters/claude/index.ts +548 -0
- package/src/adapters/claude/mcp.ts +94 -0
- package/src/adapters/codex/agents.ts +208 -0
- package/src/adapters/codex/config.ts +272 -0
- package/src/adapters/codex/hooks.ts +203 -0
- package/src/adapters/codex/index.ts +707 -0
- package/src/adapters/codex/mcp.ts +271 -0
- package/src/adapters/codex/native-projection.ts +34 -0
- package/src/adapters/copilot/index.ts +413 -0
- package/src/adapters/copy-tree.ts +620 -0
- package/src/adapters/gemini/hooks.ts +210 -0
- package/src/adapters/gemini/index.ts +390 -0
- package/src/adapters/hook-commands.ts +60 -0
- package/src/adapters/index.ts +106 -0
- package/src/adapters/kiro/index.ts +310 -0
- package/src/adapters/mcp-entries.ts +331 -0
- package/src/adapters/opencode/index.ts +466 -0
- package/src/adapters/pi/index.ts +279 -0
- package/src/adapters/pi/json-members.ts +185 -0
- package/src/adapters/pi/mcp.ts +373 -0
- package/src/adapters/resolve-source.ts +19 -0
- package/src/cli/commands/install.ts +218 -0
- package/src/cli/commands/list-backups.ts +21 -0
- package/src/cli/commands/reconcile.ts +120 -0
- package/src/cli/commands/remove.ts +82 -0
- package/src/cli/commands/rollback.ts +172 -0
- package/src/cli/commands/self-update.ts +33 -0
- package/src/cli/commands/status.ts +138 -0
- package/src/cli/commands/tools.ts +92 -0
- package/src/cli/commands/update.ts +162 -0
- package/src/cli/index.ts +568 -0
- package/src/cli/runtime-commands.ts +281 -0
- package/src/cli/shared.ts +218 -0
- package/src/helper/bash-helper.ts +34 -0
- package/src/helper/git.ts +24 -0
- package/src/helper/guardrails.ts +49 -0
- package/src/helper/harness-paths.ts +140 -0
- package/src/helper/marker-merge.ts +116 -0
- package/src/helper/prompt.ts +61 -0
- package/src/helper/repo-root.ts +29 -0
- package/src/helper/settings-merge.ts +151 -0
- package/src/helper/settings-scope.ts +33 -0
- package/src/helper/toml.ts +244 -0
- package/src/install/backup-set.ts +149 -0
- package/src/install/backup.ts +724 -0
- package/src/install/context.ts +58 -0
- package/src/install/manifest.ts +145 -0
- package/src/install/mcp.ts +254 -0
- package/src/install/paths.ts +84 -0
- package/src/install/targets.ts +90 -0
- package/src/install/tool-lifecycle.ts +151 -0
- package/src/lifecycle/bash-availability.ts +25 -0
- package/src/lifecycle/index.ts +812 -0
- package/src/lifecycle/mcp-index.ts +28 -0
- package/src/lifecycle/policies.ts +73 -0
- package/src/lifecycle/view.ts +175 -0
- package/src/registry/index.ts +611 -0
- package/src/release/sync-plugin-versions.ts +66 -0
- package/src/runtime/advice/cli.ts +283 -0
- package/src/runtime/advice/client.ts +324 -0
- package/src/runtime/advice/config.ts +189 -0
- package/src/runtime/advice/doctor.ts +169 -0
- package/src/runtime/advice/endpoint-guard.ts +134 -0
- package/src/runtime/advice/kinds.ts +154 -0
- package/src/runtime/advice/providers/ollama-systemone.ts +209 -0
- package/src/runtime/advice/record.ts +166 -0
- package/src/runtime/advice/registry.ts +170 -0
- package/src/runtime/advice/strength.ts +66 -0
- package/src/runtime/brief-tools.ts +342 -0
- package/src/runtime/c4-project.ts +371 -0
- package/src/runtime/capability-router.ts +484 -0
- package/src/runtime/checkouts.ts +170 -0
- package/src/runtime/claims.ts +468 -0
- package/src/runtime/cli-result.ts +55 -0
- package/src/runtime/cli.ts +678 -0
- package/src/runtime/command-detect.ts +516 -0
- package/src/runtime/context-pack.ts +492 -0
- package/src/runtime/decision-register.ts +493 -0
- package/src/runtime/evidence-ledger.ts +338 -0
- package/src/runtime/failure/capture.ts +272 -0
- package/src/runtime/failure/classifier.ts +68 -0
- package/src/runtime/failure/cli.ts +178 -0
- package/src/runtime/failure/home.ts +64 -0
- package/src/runtime/failure/store.ts +226 -0
- package/src/runtime/feature-resolve.ts +79 -0
- package/src/runtime/freshness.ts +177 -0
- package/src/runtime/health.ts +863 -0
- package/src/runtime/history-compactor.ts +237 -0
- package/src/runtime/implementation-gate.ts +321 -0
- package/src/runtime/inventory/coverage.ts +218 -0
- package/src/runtime/inventory/identity.ts +65 -0
- package/src/runtime/inventory/index.ts +705 -0
- package/src/runtime/inventory/precedence.ts +134 -0
- package/src/runtime/inventory/read-scopes.ts +131 -0
- package/src/runtime/inventory/siblings.ts +192 -0
- package/src/runtime/knowledge/chunker.ts +124 -0
- package/src/runtime/knowledge/hybrid.ts +149 -0
- package/src/runtime/knowledge/index-store.ts +145 -0
- package/src/runtime/knowledge/retrieval.ts +194 -0
- package/src/runtime/leak-scan.ts +185 -0
- package/src/runtime/lifecycle/cli.ts +276 -0
- package/src/runtime/lifecycle/event-store.ts +340 -0
- package/src/runtime/lifecycle/fold.ts +353 -0
- package/src/runtime/lifecycle/followup.ts +432 -0
- package/src/runtime/lifecycle/goal.ts +249 -0
- package/src/runtime/lifecycle/intent-writer.ts +86 -0
- package/src/runtime/lifecycle/overview.ts +292 -0
- package/src/runtime/lifecycle/release.ts +241 -0
- package/src/runtime/lifecycle/report-store.ts +221 -0
- package/src/runtime/lifecycle/retention.ts +212 -0
- package/src/runtime/lifecycle/root.ts +71 -0
- package/src/runtime/lifecycle/status.ts +353 -0
- package/src/runtime/lifecycle/store-upkeep.ts +393 -0
- package/src/runtime/locator-resolve.ts +158 -0
- package/src/runtime/mask.ts +210 -0
- package/src/runtime/mcp-consultations.ts +412 -0
- package/src/runtime/mcp-reach.ts +157 -0
- package/src/runtime/model-router.ts +153 -0
- package/src/runtime/outcome.ts +467 -0
- package/src/runtime/reach.ts +148 -0
- package/src/runtime/readiness-record.ts +150 -0
- package/src/runtime/readiness.ts +435 -0
- package/src/runtime/recovery.ts +282 -0
- package/src/runtime/research-request.ts +231 -0
- package/src/runtime/retrieval-plan.ts +578 -0
- package/src/runtime/scaffold/artifacts.ts +217 -0
- package/src/runtime/scaffold/fingerprint.ts +56 -0
- package/src/runtime/scaffold/generate.ts +911 -0
- package/src/runtime/scaffold/languages.ts +245 -0
- package/src/runtime/storage/cli.ts +64 -0
- package/src/runtime/storage/engine.ts +249 -0
- package/src/runtime/storage/registry.ts +130 -0
- package/src/runtime/storage/roots.ts +63 -0
- package/src/runtime/storage/rules.ts +282 -0
- package/src/runtime/storage/upkeep.ts +243 -0
- package/src/runtime/storage/work-status.ts +326 -0
- package/src/runtime/task-attempts.ts +415 -0
- package/src/runtime/task-classifier.ts +550 -0
- package/src/runtime/task-scope.ts +130 -0
- package/src/runtime/task-state.ts +176 -0
- package/src/runtime/trace/indicators.ts +235 -0
- package/src/runtime/trace/ledger.ts +626 -0
- package/src/runtime/trace/render.ts +76 -0
- package/src/runtime/trace/views.ts +459 -0
- package/src/runtime/verification/contract-runner.ts +341 -0
- package/src/runtime/verification/engine.ts +1461 -0
- package/src/runtime/verification/registry.ts +130 -0
- package/src/runtime/verification/scope-bound.ts +418 -0
- package/src/runtime/verification/test-selection.ts +172 -0
- package/src/runtime/workflow-engine.ts +588 -0
- package/src/runtime/workflow-orchestrator.ts +953 -0
- package/src/runtime/worktree.ts +340 -0
- package/src/state/index.ts +193 -0
- package/src/state/lockfile.ts +136 -0
- package/src/state/run-lock.ts +408 -0
- package/types/node-commonjs.d.ts +68 -0
- package/types/runtime.d.ts +91 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"file": "assets/sample_json_clean.json",
|
|
3
|
+
"language": "json",
|
|
4
|
+
"analysis_kind": "declarative",
|
|
5
|
+
"metrics": {
|
|
6
|
+
"lines": {
|
|
7
|
+
"total": 8,
|
|
8
|
+
"code": 7,
|
|
9
|
+
"blank": 1,
|
|
10
|
+
"comment": 0
|
|
11
|
+
},
|
|
12
|
+
"max_depth": 2,
|
|
13
|
+
"parses": true
|
|
14
|
+
},
|
|
15
|
+
"smells": [],
|
|
16
|
+
"solid_violations": [],
|
|
17
|
+
"quality_score": 100,
|
|
18
|
+
"grade": "A",
|
|
19
|
+
"policy": {
|
|
20
|
+
"tiers": [
|
|
21
|
+
"built-in",
|
|
22
|
+
"review-policy.json"
|
|
23
|
+
],
|
|
24
|
+
"thresholds": {
|
|
25
|
+
"long_function_lines": 50,
|
|
26
|
+
"too_many_parameters": 5,
|
|
27
|
+
"high_complexity": 10,
|
|
28
|
+
"god_class_methods": 20,
|
|
29
|
+
"max_imports": 15,
|
|
30
|
+
"max_declarative_depth": 8
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
package/core/shared/skills/do-code-review/expected_outputs/sample_markdown_smells_quality.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"file": "assets/sample_markdown_smells.md",
|
|
4
|
+
"line": 21,
|
|
5
|
+
"rule": "dangling_reference",
|
|
6
|
+
"severity": "high",
|
|
7
|
+
"message": "'references/does-not-exist.md' does not resolve to a real file relative to assets or ../../guidance."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"file": "assets/sample_markdown_smells.md",
|
|
11
|
+
"line": 24,
|
|
12
|
+
"rule": "staleness_marker",
|
|
13
|
+
"severity": "low",
|
|
14
|
+
"message": "Possible staleness marker 'deprecated' \u2014 confirm this prose actually asserts the surrounding content is outdated, not a rule/instruction quoting the word as a detection target."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"file": "assets/sample_shell_heredoc.sh",
|
|
3
|
+
"language": "shell",
|
|
4
|
+
"metrics": {
|
|
5
|
+
"lines": {
|
|
6
|
+
"total": 39,
|
|
7
|
+
"code": 28,
|
|
8
|
+
"blank": 5,
|
|
9
|
+
"comment": 6
|
|
10
|
+
},
|
|
11
|
+
"functions": 3,
|
|
12
|
+
"classes": 0,
|
|
13
|
+
"avg_complexity": 3.0
|
|
14
|
+
},
|
|
15
|
+
"quality_score": 100,
|
|
16
|
+
"grade": "A",
|
|
17
|
+
"smells": [],
|
|
18
|
+
"solid_violations": [],
|
|
19
|
+
"function_details": [
|
|
20
|
+
{
|
|
21
|
+
"name": "usage",
|
|
22
|
+
"parameters": 1,
|
|
23
|
+
"lines": 8,
|
|
24
|
+
"complexity": 1
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "emit",
|
|
28
|
+
"parameters": 1,
|
|
29
|
+
"lines": 10,
|
|
30
|
+
"complexity": 4
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "unterminated",
|
|
34
|
+
"parameters": 1,
|
|
35
|
+
"lines": 10,
|
|
36
|
+
"complexity": 4
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"class_details": [],
|
|
40
|
+
"policy": {
|
|
41
|
+
"tiers": [
|
|
42
|
+
"built-in",
|
|
43
|
+
"review-policy.json"
|
|
44
|
+
],
|
|
45
|
+
"thresholds": {
|
|
46
|
+
"long_function_lines": 50,
|
|
47
|
+
"too_many_parameters": 5,
|
|
48
|
+
"high_complexity": 10,
|
|
49
|
+
"god_class_methods": 20,
|
|
50
|
+
"max_imports": 15,
|
|
51
|
+
"max_declarative_depth": 8
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"file": "assets/sample_shell_smells.sh",
|
|
3
|
+
"language": "shell",
|
|
4
|
+
"metrics": {
|
|
5
|
+
"lines": {
|
|
6
|
+
"total": 16,
|
|
7
|
+
"code": 10,
|
|
8
|
+
"blank": 4,
|
|
9
|
+
"comment": 2
|
|
10
|
+
},
|
|
11
|
+
"functions": 2,
|
|
12
|
+
"classes": 0,
|
|
13
|
+
"avg_complexity": 1.0
|
|
14
|
+
},
|
|
15
|
+
"quality_score": 50,
|
|
16
|
+
"grade": "F",
|
|
17
|
+
"smells": [
|
|
18
|
+
{
|
|
19
|
+
"type": "no_error_handling",
|
|
20
|
+
"severity": "high",
|
|
21
|
+
"message": "Script has no 'set -e'/'set -u'/'set -o pipefail' \u2014 a failing command is silently ignored and the script continues with bad state",
|
|
22
|
+
"location": "line 1"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "unquoted_expansion",
|
|
26
|
+
"severity": "high",
|
|
27
|
+
"message": "Unquoted variable expansion in a command that acts on paths \u2014 a value containing spaces or globs will not do what it looks like",
|
|
28
|
+
"location": "line 5"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "unchecked_cd",
|
|
32
|
+
"severity": "medium",
|
|
33
|
+
"message": "'cd' without '|| exit' or 'set -e' \u2014 the rest of the script runs in the wrong directory if it fails",
|
|
34
|
+
"location": "line 5"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "unquoted_expansion",
|
|
38
|
+
"severity": "high",
|
|
39
|
+
"message": "Unquoted variable expansion in a command that acts on paths \u2014 a value containing spaces or globs will not do what it looks like",
|
|
40
|
+
"location": "line 6"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "unquoted_expansion",
|
|
44
|
+
"severity": "high",
|
|
45
|
+
"message": "Unquoted variable expansion in a command that acts on paths \u2014 a value containing spaces or globs will not do what it looks like",
|
|
46
|
+
"location": "line 7"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "unchecked_cd",
|
|
50
|
+
"severity": "medium",
|
|
51
|
+
"message": "'cd' without '|| exit' or 'set -e' \u2014 the rest of the script runs in the wrong directory if it fails",
|
|
52
|
+
"location": "line 11"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "unquoted_expansion",
|
|
56
|
+
"severity": "high",
|
|
57
|
+
"message": "Unquoted variable expansion in a command that acts on paths \u2014 a value containing spaces or globs will not do what it looks like",
|
|
58
|
+
"location": "line 12"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"solid_violations": [],
|
|
62
|
+
"function_details": [
|
|
63
|
+
{
|
|
64
|
+
"name": "deploy_release",
|
|
65
|
+
"parameters": 1,
|
|
66
|
+
"lines": 5,
|
|
67
|
+
"complexity": 1
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "rollback",
|
|
71
|
+
"parameters": 0,
|
|
72
|
+
"lines": 6,
|
|
73
|
+
"complexity": 1
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
"class_details": [],
|
|
77
|
+
"policy": {
|
|
78
|
+
"tiers": [
|
|
79
|
+
"built-in",
|
|
80
|
+
"review-policy.json"
|
|
81
|
+
],
|
|
82
|
+
"thresholds": {
|
|
83
|
+
"long_function_lines": 50,
|
|
84
|
+
"too_many_parameters": 5,
|
|
85
|
+
"high_complexity": 10,
|
|
86
|
+
"god_class_methods": 20,
|
|
87
|
+
"max_imports": 15,
|
|
88
|
+
"max_declarative_depth": 8
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
package/core/shared/skills/do-code-review/expected_outputs/sample_typescript_strings_quality.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"file": "assets/sample_typescript_strings.ts",
|
|
3
|
+
"language": "typescript",
|
|
4
|
+
"metrics": {
|
|
5
|
+
"lines": {
|
|
6
|
+
"total": 37,
|
|
7
|
+
"code": 24,
|
|
8
|
+
"blank": 6,
|
|
9
|
+
"comment": 7
|
|
10
|
+
},
|
|
11
|
+
"functions": 4,
|
|
12
|
+
"classes": 0,
|
|
13
|
+
"avg_complexity": 1.5
|
|
14
|
+
},
|
|
15
|
+
"quality_score": 100,
|
|
16
|
+
"grade": "A",
|
|
17
|
+
"smells": [],
|
|
18
|
+
"solid_violations": [],
|
|
19
|
+
"function_details": [
|
|
20
|
+
{
|
|
21
|
+
"name": "has",
|
|
22
|
+
"parameters": 0,
|
|
23
|
+
"lines": 4,
|
|
24
|
+
"complexity": 1
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "describeOutcome",
|
|
28
|
+
"parameters": 0,
|
|
29
|
+
"lines": 16,
|
|
30
|
+
"complexity": 2
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "the",
|
|
34
|
+
"parameters": 0,
|
|
35
|
+
"lines": 9,
|
|
36
|
+
"complexity": 1
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "pick",
|
|
40
|
+
"parameters": 0,
|
|
41
|
+
"lines": 4,
|
|
42
|
+
"complexity": 2
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"class_details": [],
|
|
46
|
+
"policy": {
|
|
47
|
+
"tiers": [
|
|
48
|
+
"built-in",
|
|
49
|
+
"review-policy.json"
|
|
50
|
+
],
|
|
51
|
+
"thresholds": {
|
|
52
|
+
"long_function_lines": 50,
|
|
53
|
+
"too_many_parameters": 5,
|
|
54
|
+
"high_complexity": 10,
|
|
55
|
+
"god_class_methods": 20,
|
|
56
|
+
"max_imports": 15,
|
|
57
|
+
"max_declarative_depth": 8
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"file": "assets/sample_yaml_smells.yaml",
|
|
3
|
+
"language": "yaml",
|
|
4
|
+
"analysis_kind": "declarative",
|
|
5
|
+
"metrics": {
|
|
6
|
+
"lines": {
|
|
7
|
+
"total": 7,
|
|
8
|
+
"code": 6,
|
|
9
|
+
"blank": 1,
|
|
10
|
+
"comment": 0
|
|
11
|
+
},
|
|
12
|
+
"max_depth": 2,
|
|
13
|
+
"parses": true
|
|
14
|
+
},
|
|
15
|
+
"smells": [
|
|
16
|
+
{
|
|
17
|
+
"type": "duplicate_key",
|
|
18
|
+
"severity": "high",
|
|
19
|
+
"message": "Key 'name' is defined twice at the same level \u2014 the later value silently wins (first seen at line 2)",
|
|
20
|
+
"location": "line 3"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "plaintext_secret",
|
|
24
|
+
"severity": "high",
|
|
25
|
+
"message": "A credential-shaped key carries a literal value \u2014 secrets belong in a secret store, not in a committed config file",
|
|
26
|
+
"location": "line 5"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"solid_violations": [],
|
|
30
|
+
"quality_score": 70,
|
|
31
|
+
"grade": "C",
|
|
32
|
+
"policy": {
|
|
33
|
+
"tiers": [
|
|
34
|
+
"built-in",
|
|
35
|
+
"review-policy.json"
|
|
36
|
+
],
|
|
37
|
+
"thresholds": {
|
|
38
|
+
"long_function_lines": 50,
|
|
39
|
+
"too_many_parameters": 5,
|
|
40
|
+
"high_complexity": 10,
|
|
41
|
+
"god_class_methods": 20,
|
|
42
|
+
"max_imports": 15,
|
|
43
|
+
"max_declarative_depth": 8
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: c
|
|
3
|
+
extensions: [".c", ".h"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# C — Language-Specific Review Notes
|
|
7
|
+
|
|
8
|
+
Load this file alongside `rules/universal.md`. Universal rules are not repeated here — only C-specific rules and idioms.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## PR Analyzer — C Risk Signals
|
|
13
|
+
|
|
14
|
+
- `printf` / debug `fprintf(stderr, ...)` statements left in production code
|
|
15
|
+
- `// TODO` / `// FIXME` comments near memory management code — high risk
|
|
16
|
+
- Disabled compiler warnings (`#pragma GCC diagnostic ignore`, `-w` flags in Makefile)
|
|
17
|
+
- Hardcoded credentials or keys in source
|
|
18
|
+
- Use of banned functions: `gets`, `strcpy`, `strcat`, `sprintf`, `scanf` without width limits
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Code Quality — C Checks
|
|
23
|
+
|
|
24
|
+
- Functions longer than 50 lines — C functions tend to grow organically and become hard to reason about
|
|
25
|
+
- Missing `NULL` check after `malloc` / `calloc` / `realloc`
|
|
26
|
+
- Return value of functions ignored without explicit `(void)` cast
|
|
27
|
+
- Global mutable state used across translation units without clear ownership
|
|
28
|
+
- Magic numbers without `#define` or `const` — especially sizes and offsets
|
|
29
|
+
- Mixed `malloc`/`free` ownership — unclear which caller is responsible for freeing
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Security
|
|
34
|
+
|
|
35
|
+
- Flag `gets()` — no bounds checking, always a buffer overflow; replace with `fgets()`
|
|
36
|
+
- Flag `strcpy()` / `strcat()` — use `strncpy()` / `strncat()` with explicit size, or `strlcpy()` / `strlcat()`
|
|
37
|
+
- Flag `sprintf()` — use `snprintf()` with explicit buffer size
|
|
38
|
+
- Flag `scanf("%s", buf)` without a width specifier — unbounded read
|
|
39
|
+
- Flag `strlen()` result used as a signed integer — potential truncation on 64-bit
|
|
40
|
+
- Flag user-controlled data used as a format string (`printf(user_input)`) — format string attack
|
|
41
|
+
- Flag integer arithmetic used as array index without bounds check
|
|
42
|
+
- Flag signed integer overflow — undefined behavior in C
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Async / Concurrency
|
|
47
|
+
|
|
48
|
+
- Flag shared global or `static` variables accessed from multiple threads without a mutex or `_Atomic`
|
|
49
|
+
- Flag `pthread_mutex_t` / `sem_t` not initialized before use
|
|
50
|
+
- Flag signal handlers that call non-async-signal-safe functions (`malloc`, `printf`, etc.)
|
|
51
|
+
- Flag `volatile` used as a substitute for proper synchronization — it is not sufficient
|
|
52
|
+
- Flag lock acquisition order inconsistency across call sites — deadlock risk
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Resource Management
|
|
57
|
+
|
|
58
|
+
- Flag every `malloc` / `calloc` / `realloc` path — verify a matching `free` exists on all exit paths
|
|
59
|
+
- Flag `fopen` without a matching `fclose` on all paths including error paths
|
|
60
|
+
- Flag `dup` / `socket` / `open` file descriptors not closed on all paths
|
|
61
|
+
- Flag stack-allocated VLAs (variable-length arrays) of unbounded size — stack overflow risk
|
|
62
|
+
- Flag `realloc` return value assigned directly to the source pointer — leaks on failure
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Exception Handling
|
|
67
|
+
|
|
68
|
+
- Flag ignored return values from `malloc`, `fopen`, `read`, `write`, `close` — all can fail
|
|
69
|
+
- Flag `errno` checked after a function that doesn't set it, or not checked immediately after one that does
|
|
70
|
+
- Flag `perror` / `strerror` as the sole error handling in library code — propagate errors to callers
|
|
71
|
+
- Flag functions that return `-1` on error without documenting which `errno` values are possible
|
|
72
|
+
- Flag `assert()` used for runtime error handling — disabled by `NDEBUG` in production builds
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Performance
|
|
77
|
+
|
|
78
|
+
- Flag `strlen()` called repeatedly on the same string in a loop — cache the result
|
|
79
|
+
- Flag unnecessary copies of large structs passed by value — pass by pointer
|
|
80
|
+
- Flag `memcpy` / `memset` on overlapping regions — use `memmove` for overlapping
|
|
81
|
+
- Flag repeated heap allocations in a tight loop — consider a pool or stack allocation
|
|
82
|
+
- Flag `volatile` on variables not accessed by hardware or signal handlers — prevents optimization
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Idioms and Best Practices
|
|
87
|
+
|
|
88
|
+
### Memory Safety
|
|
89
|
+
- Every pointer must have a clear owner responsible for freeing it — document ownership in comments
|
|
90
|
+
- Set pointers to `NULL` immediately after `free` to catch use-after-free early
|
|
91
|
+
- Prefer `calloc` over `malloc` + `memset` for zero-initialized allocations
|
|
92
|
+
- Use `const` on pointer parameters that the function does not modify
|
|
93
|
+
|
|
94
|
+
### Defensive Coding
|
|
95
|
+
- Always check `NULL` returns from allocation functions
|
|
96
|
+
- Use `size_t` for sizes and counts — never `int`
|
|
97
|
+
- Prefer `snprintf` and `fgets` over any unbounded string function
|
|
98
|
+
- Compile with `-Wall -Wextra -Werror` and treat warnings as errors
|
|
99
|
+
|
|
100
|
+
### Portability
|
|
101
|
+
- Do not assume pointer size equals `int` size — use `intptr_t` / `uintptr_t`
|
|
102
|
+
- Do not rely on undefined behavior for performance — use compiler intrinsics instead
|
|
103
|
+
- Use `stdint.h` types (`uint32_t`, `int64_t`) for fixed-width requirements
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: cpp
|
|
3
|
+
extensions: [".cpp", ".cc", ".cxx", ".hpp", ".hh", ".hxx"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# C++ — Language-Specific Review Notes
|
|
7
|
+
|
|
8
|
+
Load this file alongside `rules/universal.md`. Universal rules are not repeated here — only C++-specific rules and idioms.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## PR Analyzer — C++ Risk Signals
|
|
13
|
+
|
|
14
|
+
- Raw `new` / `delete` outside of smart pointer wrappers
|
|
15
|
+
- `reinterpret_cast` — almost always a red flag; require justification
|
|
16
|
+
- Disabled compiler warnings (`#pragma warning(disable:...)`, `-w`)
|
|
17
|
+
- `// TODO` / `// FIXME` near ownership or lifetime code
|
|
18
|
+
- Hardcoded credentials or keys in source
|
|
19
|
+
- Use of deprecated C-style functions: `strcpy`, `sprintf`, `gets`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Code Quality — C++ Checks
|
|
24
|
+
|
|
25
|
+
- Raw owning pointers (`T*`) used where `unique_ptr` / `shared_ptr` would express ownership
|
|
26
|
+
- `shared_ptr` overused where `unique_ptr` suffices — implies shared ownership unnecessarily
|
|
27
|
+
- `std::endl` used in hot paths — flushes the buffer every call; prefer `'\n'`
|
|
28
|
+
- Implicit conversions between signed and unsigned integers
|
|
29
|
+
- Virtual destructor missing on base classes with virtual methods
|
|
30
|
+
- `catch (...)` swallowing all exceptions without logging or re-throwing
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Security
|
|
35
|
+
|
|
36
|
+
- Flag `reinterpret_cast` on user-controlled data — potential type confusion
|
|
37
|
+
- Flag raw array indexing without bounds check — use `.at()` or assert bounds
|
|
38
|
+
- Flag `std::string` data passed to C APIs without null-termination guarantee — use `.c_str()`
|
|
39
|
+
- Flag hardcoded buffer sizes — derive from `sizeof` or use `std::array<T, N>`
|
|
40
|
+
- Flag `sscanf` / `sprintf` — use `std::istringstream` or `std::format` (C++20)
|
|
41
|
+
- Flag user-controlled data used as a format string
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Async / Concurrency
|
|
46
|
+
|
|
47
|
+
- Flag `std::shared_ptr` accessed from multiple threads — the pointer itself is not thread-safe for write; use `std::atomic<std::shared_ptr<T>>` (C++20) or external locking
|
|
48
|
+
- Flag `std::vector` / `std::map` mutated from multiple threads without a mutex
|
|
49
|
+
- Flag `std::mutex` locked twice in the same thread without `std::recursive_mutex` — deadlock
|
|
50
|
+
- Flag detached threads (`std::thread::detach`) with no lifetime coordination
|
|
51
|
+
- Flag `volatile` used instead of `std::atomic` for inter-thread communication
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Resource Management
|
|
56
|
+
|
|
57
|
+
- Flag raw `new` returning an owning pointer — wrap immediately in `std::make_unique` or `std::make_shared`
|
|
58
|
+
- Flag `delete` called manually outside of a destructor or smart pointer — ownership confusion
|
|
59
|
+
- Flag RAII violations — resources acquired in constructor but not released via destructor
|
|
60
|
+
- Flag `std::ifstream` / `std::ofstream` not checked for open failure before use
|
|
61
|
+
- Flag exceptions thrown from destructors — causes `std::terminate` if thrown during stack unwinding
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Exception Handling
|
|
66
|
+
|
|
67
|
+
- Flag `catch (...)` that swallows exceptions without logging or re-throwing
|
|
68
|
+
- Flag exceptions thrown from destructors — wrap in `try/catch` inside the destructor
|
|
69
|
+
- Flag `noexcept` on functions that can actually throw — causes `std::terminate`
|
|
70
|
+
- Flag exception specifications (`throw(...)`) — deprecated since C++11, removed in C++17
|
|
71
|
+
- Flag using exceptions for control flow in performance-critical paths
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Performance
|
|
76
|
+
|
|
77
|
+
- Flag pass-by-value for non-trivial types where pass-by-const-reference suffices
|
|
78
|
+
- Flag `std::vector::push_back` in a loop without `reserve` when size is known — repeated reallocations
|
|
79
|
+
- Flag `std::map` used where `std::unordered_map` would give O(1) lookup
|
|
80
|
+
- Flag `std::endl` in loops — prefer `'\n'` to avoid repeated buffer flushes
|
|
81
|
+
- Flag unnecessary copies from missing `std::move` on local temporaries being returned or passed
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Idioms and Best Practices
|
|
86
|
+
|
|
87
|
+
### Ownership and Lifetime
|
|
88
|
+
- Prefer `std::unique_ptr` for sole ownership, `std::shared_ptr` only for shared ownership
|
|
89
|
+
- Prefer `std::make_unique` / `std::make_shared` over `new` — exception-safe
|
|
90
|
+
- Use `std::weak_ptr` to break `shared_ptr` cycles
|
|
91
|
+
- Never use raw owning pointers in new code — they are for non-owning observation only
|
|
92
|
+
|
|
93
|
+
### Modern C++ (17/20)
|
|
94
|
+
- Prefer `std::optional<T>` over sentinel values or nullable pointers for optional returns
|
|
95
|
+
- Prefer `std::variant` over tagged unions
|
|
96
|
+
- Prefer `std::string_view` over `const std::string&` for read-only string parameters
|
|
97
|
+
- Prefer range-based `for` loops over index loops where the index isn't needed
|
|
98
|
+
- Prefer `if constexpr` over `#ifdef` for compile-time branching
|
|
99
|
+
|
|
100
|
+
### Type Safety
|
|
101
|
+
- Prefer `static_cast` over C-style casts — explicit and auditable
|
|
102
|
+
- Avoid `reinterpret_cast` except in low-level I/O or FFI code with a comment
|
|
103
|
+
- Use `enum class` over plain `enum` to avoid implicit integer conversions
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: csharp
|
|
3
|
+
extensions: [".cs", ".csx", ".razor", ".cshtml"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# C# / .NET — Language-Specific Review Notes
|
|
7
|
+
|
|
8
|
+
Load this file alongside `rules/universal.md`. Universal rules are not repeated here — only C#-specific rules and idioms.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## PR Analyzer — C# Risk Signals
|
|
13
|
+
|
|
14
|
+
- `#pragma warning disable` and `[SuppressMessage]` — verify they are justified
|
|
15
|
+
- `unsafe { }` blocks — require explicit sign-off
|
|
16
|
+
- Null-forgiving operator (`!`) used broadly without justification
|
|
17
|
+
- `dynamic` used outside of interop scenarios
|
|
18
|
+
- Hardcoded connection strings in source files
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Code Quality — C# Checks
|
|
23
|
+
|
|
24
|
+
- `async void` methods (except event handlers)
|
|
25
|
+
- `Task` returned but not awaited
|
|
26
|
+
- `IDisposable` objects not in `using` / `using var`
|
|
27
|
+
- Bare `catch { }` or `catch (Exception e) { }` swallowing silently
|
|
28
|
+
- Nullable reference types feature disabled at project level
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Security
|
|
33
|
+
|
|
34
|
+
- Flag raw string interpolation in SQL queries — require parameterized queries (`SqlCommand`) or EF Core
|
|
35
|
+
- Flag missing `[ValidateAntiForgeryToken]` on state-changing controller actions
|
|
36
|
+
- Flag user-controlled data passed to `Process.Start()` or `File` APIs without validation
|
|
37
|
+
- Flag hardcoded connection strings — require `appsettings.json` + secrets management
|
|
38
|
+
- Flag `[AllowAnonymous]` on endpoints that should be protected
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Async / Await
|
|
43
|
+
|
|
44
|
+
- Flag `async void` methods outside of event handlers — cannot be awaited and swallow exceptions
|
|
45
|
+
- Flag `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()` on `Task` — causes deadlocks in ASP.NET contexts
|
|
46
|
+
- Flag missing `ConfigureAwait(false)` in library (non-application) code
|
|
47
|
+
- Flag `Task.Run()` wrapping synchronous code inside ASP.NET request handlers unnecessarily
|
|
48
|
+
- Flag `CancellationToken` not threaded through to downstream async calls
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Resource Management
|
|
53
|
+
|
|
54
|
+
- Flag `IDisposable` objects (`SqlConnection`, `HttpClient`, `FileStream`, etc.) not wrapped in `using` / `using var`
|
|
55
|
+
- Flag `HttpClient` instantiated with `new` inside a method — use `IHttpClientFactory` or a shared static instance to avoid socket exhaustion
|
|
56
|
+
- Flag `DbContext` registered as a singleton in DI — it must be scoped
|
|
57
|
+
- Flag `MemoryStream` / `MemoryCache` growing unboundedly without eviction policy
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Exception Handling
|
|
62
|
+
|
|
63
|
+
- Flag `catch { }` or `catch (Exception) { }` with no logging or re-throw — silent swallow
|
|
64
|
+
- Flag `catch (Exception e) { throw e; }` — resets the stack trace; use `throw;` instead
|
|
65
|
+
- Flag catching `Exception` when a specific type (`IOException`, `HttpRequestException`) is appropriate
|
|
66
|
+
- Flag exception filters (`when`) used for side effects that suppress the exception
|
|
67
|
+
- Flag exceptions used for control flow in hot paths — use `Try*` pattern methods instead
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Performance
|
|
72
|
+
|
|
73
|
+
- Flag `.ToList()` / `.ToArray()` on `IQueryable` before filtering — forces all rows into memory; filter server-side first
|
|
74
|
+
- Flag `string` concatenation in loops — use `StringBuilder`
|
|
75
|
+
- Flag `Enumerable.Count()` on `IQueryable` when only an existence check is needed — use `Any()`
|
|
76
|
+
- Flag `await` in a loop where `Task.WhenAll()` would parallelize the work
|
|
77
|
+
- Flag synchronous file or network I/O in an `async` method — use the async overload
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Idioms and Best Practices
|
|
82
|
+
|
|
83
|
+
### Null Safety
|
|
84
|
+
- Ensure `<Nullable>enable</Nullable>` is set in the project file
|
|
85
|
+
- Flag excessive use of `!` (null-forgiving) without a comment explaining why
|
|
86
|
+
- Prefer `is null` / `is not null` over `== null` for null checks
|
|
87
|
+
|
|
88
|
+
### LINQ
|
|
89
|
+
- Flag `First()` where `FirstOrDefault()` is safer
|
|
90
|
+
- Flag complex LINQ chains that would be clearer as explicit loops
|
|
91
|
+
|
|
92
|
+
### Modern C# (10+)
|
|
93
|
+
- Prefer `record` types for immutable data carriers
|
|
94
|
+
- Prefer `switch` expressions over `switch` statements where a value is returned
|
|
95
|
+
- Prefer primary constructors (C# 12) for simple dependency injection
|
|
96
|
+
- Prefer file-scoped namespaces (`namespace Foo;`) over block-scoped
|
|
97
|
+
- Prefer `is` pattern matching over explicit casts
|