devflow-kit 1.8.2 → 2.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/CHANGELOG.md +191 -6
- package/LICENSE +1 -1
- package/README.md +139 -219
- package/dist/cli/agents-view/index.js +9 -0
- package/dist/cli/agents-view/render.js +310 -0
- package/dist/cli/agents-view/state.js +423 -0
- package/dist/cli/agents-view/terminal.js +179 -0
- package/dist/cli/commands/agents.js +585 -0
- package/dist/cli/commands/ambient.js +231 -0
- package/dist/cli/commands/capture.js +133 -0
- package/dist/cli/commands/compliance-prompts.js +174 -0
- package/dist/cli/commands/compliance.js +337 -0
- package/dist/cli/commands/context.js +66 -0
- package/dist/cli/commands/debug.js +122 -0
- package/dist/cli/commands/flags.js +119 -0
- package/dist/cli/commands/hud.js +229 -0
- package/dist/cli/commands/init-seed.js +226 -0
- package/dist/cli/commands/init.js +1786 -0
- package/dist/cli/commands/knowledge/index.js +25 -0
- package/dist/cli/commands/knowledge/list.js +115 -0
- package/dist/cli/commands/knowledge/toggle.js +84 -0
- package/dist/cli/commands/learning.js +311 -0
- package/dist/cli/commands/legacy-hooks.js +40 -0
- package/dist/cli/commands/memory.js +349 -0
- package/dist/cli/commands/proxy.js +1435 -0
- package/dist/cli/commands/rules.js +334 -0
- package/dist/cli/commands/safe-delete.js +140 -0
- package/dist/cli/commands/security.js +179 -0
- package/dist/cli/commands/skills.js +140 -0
- package/dist/cli/commands/uninstall.js +1214 -0
- package/dist/cli.js +35 -10
- package/dist/commands/bug-analysis.md +400 -0
- package/dist/commands/code-review.md +403 -0
- package/dist/commands/debug.md +282 -0
- package/dist/commands/dynamic-build.md +972 -0
- package/dist/commands/dynamic-plan.md +383 -0
- package/dist/commands/dynamic-profile.md +206 -0
- package/dist/commands/dynamic-tickets.md +583 -0
- package/dist/commands/explore.md +208 -0
- package/dist/commands/implement.md +590 -0
- package/dist/commands/plan.md +570 -0
- package/dist/commands/release.md +206 -0
- package/dist/commands/research.md +212 -0
- package/dist/commands/resolve.md +731 -0
- package/dist/commands/self-review.md +251 -0
- package/dist/core/agent-frontmatter.js +209 -0
- package/dist/core/agent-models.js +556 -0
- package/dist/core/agent-state.js +44 -0
- package/dist/core/assets.js +39 -0
- package/dist/core/cache.js +205 -0
- package/dist/core/codex-auth-inspect.js +128 -0
- package/dist/core/compliance-compose.js +458 -0
- package/dist/core/compliance.js +165 -0
- package/dist/core/external-models.js +76 -0
- package/dist/core/feature-config.js +125 -0
- package/dist/core/flags.js +309 -0
- package/dist/core/fs-atomic.js +74 -0
- package/dist/core/git.js +61 -0
- package/dist/core/learning-queue-cleanup.js +92 -0
- package/dist/core/learning-tuning-config.js +78 -0
- package/dist/core/manifest.js +171 -0
- package/dist/core/migrations.js +330 -0
- package/dist/core/model-discovery.js +655 -0
- package/dist/core/observation-io.js +50 -0
- package/dist/core/observations.js +109 -0
- package/dist/core/orphan-sweep.js +92 -0
- package/dist/core/paths.js +48 -0
- package/dist/core/plugins.js +525 -0
- package/dist/core/project-paths.js +159 -0
- package/dist/core/proxy-log.js +165 -0
- package/dist/core/proxy-state.js +305 -0
- package/dist/core/safe-delete-install.js +191 -0
- package/dist/core/teammate-mode-cleanup.js +33 -0
- package/dist/hud/colors.js +13 -2
- package/dist/hud/components/config-counts.js +2 -2
- package/dist/hud/components/context-usage.js +2 -2
- package/dist/hud/components/learning-counts.js +92 -0
- package/dist/hud/components/session-cost.js +10 -2
- package/dist/hud/components/usage-quota.js +43 -8
- package/dist/hud/components/version-badge.js +17 -7
- package/dist/hud/config.js +4 -2
- package/dist/hud/cost-history.js +281 -0
- package/dist/hud/git.js +112 -71
- package/dist/hud/index.js +47 -4
- package/dist/hud/render.js +8 -20
- package/dist/hud/transcript.js +5 -6
- package/dist/targets/claude-code/claude-paths.js +106 -0
- package/dist/targets/claude-code/compliance-install.js +305 -0
- package/dist/targets/claude-code/hooks.js +9 -0
- package/dist/targets/claude-code/installer.js +458 -0
- package/dist/targets/claude-code/legacy.js +239 -0
- package/dist/targets/claude-code/post-install.js +971 -0
- package/package.json +23 -17
- package/src/assets/agents/code.md +244 -0
- package/src/assets/agents/design.md +113 -0
- package/src/assets/agents/diagnose.md +210 -0
- package/src/assets/agents/evaluate.md +117 -0
- package/src/assets/agents/git.md +938 -0
- package/src/assets/agents/knowledge.md +89 -0
- package/src/assets/agents/learning.md +203 -0
- package/src/assets/agents/research.md +134 -0
- package/src/assets/agents/review.md +220 -0
- package/src/assets/agents/scrutinize.md +95 -0
- package/src/assets/agents/simplify.md +108 -0
- package/src/assets/agents/skim.md +136 -0
- package/src/assets/agents/synthesize.md +402 -0
- package/src/assets/agents/test.md +155 -0
- package/src/assets/agents/triage.md +141 -0
- package/src/assets/agents/validate.md +103 -0
- package/src/assets/commands/_partials/_compliance.mds +5 -0
- package/src/assets/commands/_partials/_decisions.mds +20 -0
- package/src/assets/commands/_partials/_engine.mds +244 -0
- package/src/assets/commands/_partials/_factory.mds +216 -0
- package/src/assets/commands/_partials/_knowledge.mds +95 -0
- package/src/assets/commands/_partials/_plan_contract.mds +51 -0
- package/src/assets/commands/_partials/_preamble.mds +82 -0
- package/src/assets/commands/_partials/_publication.mds +7 -0
- package/src/assets/commands/_partials/_roster.mds +31 -0
- package/src/assets/commands/_partials/_ticket_template.mds +59 -0
- package/src/assets/commands/_partials/_wave.mds +123 -0
- package/src/assets/commands/bug-analysis.mds +353 -0
- package/src/assets/commands/code-review.mds +355 -0
- package/src/assets/commands/debug.mds +224 -0
- package/src/assets/commands/dynamic-build.mds +534 -0
- package/src/assets/commands/dynamic-plan.mds +244 -0
- package/src/assets/commands/dynamic-profile.mds +132 -0
- package/src/assets/commands/dynamic-tickets.mds +226 -0
- package/src/assets/commands/explore.mds +150 -0
- package/src/assets/commands/implement.mds +496 -0
- package/src/assets/commands/plan.mds +523 -0
- package/src/assets/commands/release.md +206 -0
- package/src/assets/commands/research.mds +164 -0
- package/src/assets/commands/resolve.mds +636 -0
- package/src/assets/commands/self-review.mds +156 -0
- package/src/assets/rules/accessibility.md +11 -0
- package/src/assets/rules/compliance.md +15 -0
- package/src/assets/rules/engineering.md +13 -0
- package/src/assets/rules/go.md +12 -0
- package/src/assets/rules/java.md +12 -0
- package/src/assets/rules/python.md +12 -0
- package/src/assets/rules/quality.md +14 -0
- package/src/assets/rules/react.md +11 -0
- package/src/assets/rules/reliability.md +12 -0
- package/src/assets/rules/rust.md +12 -0
- package/src/assets/rules/security.md +12 -0
- package/src/assets/rules/typescript.md +12 -0
- package/src/assets/rules/ui-design.md +11 -0
- package/src/assets/scripts/hooks/assets/orchestrator-charter.md +21 -0
- package/src/assets/scripts/hooks/background-memory-update +460 -0
- package/src/assets/scripts/hooks/capture-prompt +87 -0
- package/src/assets/scripts/hooks/capture-question +153 -0
- package/src/assets/scripts/hooks/capture-turn +105 -0
- package/src/assets/scripts/hooks/debug-trace +75 -0
- package/src/assets/scripts/hooks/decisions-usage-scan.cjs +131 -0
- package/src/assets/scripts/hooks/ensure-devflow-init +39 -0
- package/src/assets/scripts/hooks/ensure-proxy +294 -0
- package/src/assets/scripts/hooks/ensure-root-gitignore +116 -0
- package/src/assets/scripts/hooks/get-mtime +23 -0
- package/src/assets/scripts/hooks/git-marker +16 -0
- package/src/assets/scripts/hooks/hook-bootstrap +25 -0
- package/src/assets/scripts/hooks/hook-log-init +41 -0
- package/src/assets/scripts/hooks/json-helper.cjs +725 -0
- package/src/assets/scripts/hooks/json-parse +243 -0
- package/src/assets/scripts/hooks/learning-lock +44 -0
- package/src/assets/scripts/hooks/lib/decisions-format.cjs +301 -0
- package/src/assets/scripts/hooks/lib/mkdir-lock.cjs +106 -0
- package/src/assets/scripts/hooks/lib/project-paths.cjs +230 -0
- package/src/assets/scripts/hooks/lib/render-decisions.cjs +398 -0
- package/src/assets/scripts/hooks/lib/safe-path.cjs +29 -0
- package/src/assets/scripts/hooks/log-paths +24 -0
- package/src/assets/scripts/hooks/memory-worker +101 -0
- package/src/assets/scripts/hooks/pre-compact-memory +126 -0
- package/src/assets/scripts/hooks/preamble +77 -0
- package/src/assets/scripts/hooks/queue-append +120 -0
- package/src/assets/scripts/hooks/resolve-project-root +37 -0
- package/src/assets/scripts/hooks/run-hook +31 -0
- package/src/assets/scripts/hooks/session-start-context +180 -0
- package/src/assets/scripts/hooks/session-start-memory +318 -0
- package/src/assets/scripts/hooks/session-start-orchestrator +54 -0
- package/src/assets/scripts/hud.sh +5 -0
- package/src/assets/scripts/redact-secrets.cjs +410 -0
- package/src/assets/skills/accessibility/SKILL.md +145 -0
- package/src/assets/skills/accessibility/references/patterns.md +398 -0
- package/src/assets/skills/accessibility/references/sources.md +26 -0
- package/src/assets/skills/accessibility/references/violations.md +358 -0
- package/src/assets/skills/apply-decisions/SKILL.md +100 -0
- package/src/assets/skills/apply-feature-knowledge/SKILL.md +69 -0
- package/src/assets/skills/architecture/SKILL.md +138 -0
- package/src/assets/skills/architecture/references/patterns.md +378 -0
- package/src/assets/skills/architecture/references/sources.md +41 -0
- package/src/assets/skills/architecture/references/violations.md +314 -0
- package/src/assets/skills/boundary-validation/SKILL.md +119 -0
- package/src/assets/skills/boundary-validation/references/detection.md +283 -0
- package/src/assets/skills/boundary-validation/references/patterns.md +283 -0
- package/src/assets/skills/boundary-validation/references/sources.md +41 -0
- package/src/assets/skills/boundary-validation/references/violations.md +211 -0
- package/src/assets/skills/complexity/SKILL.md +150 -0
- package/src/assets/skills/compliance/SKILL.md +121 -0
- package/src/assets/skills/compliance/frameworks/gdpr/fragment.md +11 -0
- package/src/assets/skills/compliance/frameworks/gdpr/reference.md +50 -0
- package/src/assets/skills/compliance/frameworks/hipaa/fragment.md +11 -0
- package/src/assets/skills/compliance/frameworks/hipaa/reference.md +44 -0
- package/src/assets/skills/compliance/frameworks/iso-27001/fragment.md +10 -0
- package/src/assets/skills/compliance/frameworks/iso-27001/reference.md +45 -0
- package/src/assets/skills/compliance/frameworks/pci-dss/fragment.md +11 -0
- package/src/assets/skills/compliance/frameworks/pci-dss/reference.md +55 -0
- package/src/assets/skills/compliance/frameworks/soc2/fragment.md +10 -0
- package/src/assets/skills/compliance/frameworks/soc2/reference.md +53 -0
- package/src/assets/skills/compliance/frameworks/sox/fragment.md +10 -0
- package/src/assets/skills/compliance/frameworks/sox/reference.md +67 -0
- package/src/assets/skills/compliance/references/detection.md +108 -0
- package/src/assets/skills/compliance/references/sources.md +28 -0
- package/src/assets/skills/consistency/SKILL.md +140 -0
- package/src/assets/skills/database/SKILL.md +134 -0
- package/src/assets/skills/dependencies/SKILL.md +141 -0
- package/src/assets/skills/dependency-research/SKILL.md +133 -0
- package/src/assets/skills/dependency-research/references/evaluation-criteria.md +101 -0
- package/src/assets/skills/design-review/SKILL.md +155 -0
- package/src/assets/skills/design-review/references/anti-patterns.md +207 -0
- package/src/assets/skills/docs-framework/SKILL.md +190 -0
- package/src/assets/skills/docs-framework/references/patterns.md +381 -0
- package/src/assets/skills/docs-framework/references/violations.md +221 -0
- package/src/assets/skills/documentation/SKILL.md +126 -0
- package/src/assets/skills/feature-knowledge/SKILL.md +341 -0
- package/src/assets/skills/gap-analysis/SKILL.md +151 -0
- package/src/assets/skills/gap-analysis/references/check-layers.md +125 -0
- package/src/assets/skills/git/SKILL.md +287 -0
- package/src/assets/skills/git/references/github-api.md +666 -0
- package/src/assets/skills/git/references/patterns.md +324 -0
- package/src/assets/skills/git/references/sources.md +16 -0
- package/src/assets/skills/git/references/violations.md +128 -0
- package/src/assets/skills/go/SKILL.md +147 -0
- package/src/assets/skills/go/references/concurrency.md +335 -0
- package/src/assets/skills/go/references/patterns.md +278 -0
- package/src/assets/skills/go/references/sources.md +41 -0
- package/src/assets/skills/go/references/violations.md +262 -0
- package/src/assets/skills/java/SKILL.md +148 -0
- package/src/assets/skills/java/references/modern-java.md +335 -0
- package/src/assets/skills/java/references/patterns.md +311 -0
- package/src/assets/skills/java/references/sources.md +44 -0
- package/src/assets/skills/java/references/violations.md +257 -0
- package/src/assets/skills/patterns/SKILL.md +162 -0
- package/src/assets/skills/performance/SKILL.md +135 -0
- package/src/assets/skills/performance/references/patterns.md +516 -0
- package/src/assets/skills/performance/references/sources.md +41 -0
- package/src/assets/skills/performance/references/violations.md +417 -0
- package/src/assets/skills/python/SKILL.md +156 -0
- package/src/assets/skills/python/references/async.md +255 -0
- package/src/assets/skills/python/references/patterns.md +280 -0
- package/src/assets/skills/python/references/sources.md +41 -0
- package/src/assets/skills/python/references/violations.md +272 -0
- package/src/assets/skills/qa/SKILL.md +136 -0
- package/src/assets/skills/qa/references/browser-testing.md +97 -0
- package/src/assets/skills/qa/references/patterns.md +118 -0
- package/src/assets/skills/qa/references/scenario-templates.md +102 -0
- package/src/assets/skills/qa/references/sources.md +30 -0
- package/src/assets/skills/qa/references/violations.md +98 -0
- package/src/assets/skills/quality-gates/SKILL.md +152 -0
- package/src/assets/skills/quality-gates/references/stub-detection.md +135 -0
- package/src/assets/skills/react/SKILL.md +143 -0
- package/src/assets/skills/react/references/error-handling.md +179 -0
- package/src/assets/skills/react/references/forms.md +214 -0
- package/src/assets/skills/react/references/hooks.md +193 -0
- package/src/assets/skills/react/references/patterns.md +1336 -0
- package/src/assets/skills/react/references/sources.md +35 -0
- package/src/assets/skills/react/references/violations.md +570 -0
- package/src/assets/skills/regression/SKILL.md +146 -0
- package/src/assets/skills/reliability/SKILL.md +153 -0
- package/src/assets/skills/reliability/references/detection.md +66 -0
- package/src/assets/skills/reliability/references/patterns.md +151 -0
- package/src/assets/skills/reliability/references/sources.md +27 -0
- package/src/assets/skills/reliability/references/violations.md +125 -0
- package/src/assets/skills/research-codebase/SKILL.md +135 -0
- package/src/assets/skills/research-competitor/SKILL.md +145 -0
- package/src/assets/skills/research-external/SKILL.md +141 -0
- package/src/assets/skills/research-market/SKILL.md +145 -0
- package/src/assets/skills/research-technology/SKILL.md +180 -0
- package/src/assets/skills/review-methodology/SKILL.md +121 -0
- package/src/assets/skills/review-methodology/references/patterns.md +186 -0
- package/src/assets/skills/review-methodology/references/report-template.md +142 -0
- package/src/assets/skills/review-methodology/references/violations.md +125 -0
- package/src/assets/skills/rust/SKILL.md +148 -0
- package/src/assets/skills/rust/references/ownership.md +278 -0
- package/src/assets/skills/rust/references/patterns.md +247 -0
- package/src/assets/skills/rust/references/sources.md +46 -0
- package/src/assets/skills/rust/references/violations.md +252 -0
- package/src/assets/skills/security/SKILL.md +121 -0
- package/src/assets/skills/security/references/patterns.md +271 -0
- package/src/assets/skills/security/references/sources.md +41 -0
- package/src/assets/skills/security/references/violations.md +241 -0
- package/src/assets/skills/software-design/SKILL.md +143 -0
- package/src/assets/skills/software-design/references/checklist.md +259 -0
- package/src/assets/skills/software-design/references/code-smell-violations.md +189 -0
- package/src/assets/skills/software-design/references/patterns.md +359 -0
- package/src/assets/skills/software-design/references/sources.md +41 -0
- package/src/assets/skills/software-design/references/violations.md +341 -0
- package/src/assets/skills/test-driven-development/SKILL.md +197 -0
- package/src/assets/skills/testing/SKILL.md +139 -0
- package/src/assets/skills/testing/references/patterns.md +346 -0
- package/src/assets/skills/testing/references/sources.md +53 -0
- package/src/assets/skills/testing/references/violations.md +322 -0
- package/src/assets/skills/typescript/SKILL.md +150 -0
- package/src/assets/skills/typescript/references/async.md +333 -0
- package/src/assets/skills/typescript/references/patterns.md +440 -0
- package/src/assets/skills/typescript/references/sources.md +41 -0
- package/src/assets/skills/typescript/references/type-guards.md +333 -0
- package/src/assets/skills/typescript/references/utility-types.md +255 -0
- package/src/assets/skills/typescript/references/violations.md +285 -0
- package/src/assets/skills/ui-design/SKILL.md +144 -0
- package/src/assets/skills/ui-design/references/patterns.md +341 -0
- package/src/assets/skills/ui-design/references/sources.md +41 -0
- package/src/assets/skills/ui-design/references/violations.md +312 -0
- package/src/assets/skills/worktree-support/SKILL.md +92 -0
- package/src/targets/claude-code/templates/claudeignore.template +188 -0
- package/src/targets/claude-code/templates/settings.json +86 -0
- package/dist/cli.d.ts +0 -3
- package/dist/commands/ambient.d.ts +0 -18
- package/dist/commands/ambient.js +0 -137
- package/dist/commands/hud.d.ts +0 -22
- package/dist/commands/hud.js +0 -180
- package/dist/commands/init.d.ts +0 -16
- package/dist/commands/init.js +0 -738
- package/dist/commands/list.d.ts +0 -24
- package/dist/commands/list.js +0 -89
- package/dist/commands/memory.d.ts +0 -22
- package/dist/commands/memory.js +0 -175
- package/dist/commands/skills.d.ts +0 -11
- package/dist/commands/skills.js +0 -116
- package/dist/commands/uninstall.d.ts +0 -22
- package/dist/commands/uninstall.js +0 -558
- package/dist/hud/cache.d.ts +0 -14
- package/dist/hud/cache.js +0 -54
- package/dist/hud/colors.d.ts +0 -23
- package/dist/hud/components/config-counts.d.ts +0 -8
- package/dist/hud/components/context-usage.d.ts +0 -8
- package/dist/hud/components/diff-stats.d.ts +0 -3
- package/dist/hud/components/directory.d.ts +0 -3
- package/dist/hud/components/git-ahead-behind.d.ts +0 -3
- package/dist/hud/components/git-branch.d.ts +0 -3
- package/dist/hud/components/model.d.ts +0 -3
- package/dist/hud/components/release-info.d.ts +0 -3
- package/dist/hud/components/session-cost.d.ts +0 -3
- package/dist/hud/components/session-duration.d.ts +0 -3
- package/dist/hud/components/todo-progress.d.ts +0 -3
- package/dist/hud/components/usage-quota.d.ts +0 -3
- package/dist/hud/components/version-badge.d.ts +0 -3
- package/dist/hud/components/worktree-count.d.ts +0 -3
- package/dist/hud/config.d.ts +0 -10
- package/dist/hud/credentials.d.ts +0 -17
- package/dist/hud/credentials.js +0 -99
- package/dist/hud/git.d.ts +0 -7
- package/dist/hud/index.d.ts +0 -2
- package/dist/hud/render.d.ts +0 -7
- package/dist/hud/stdin.d.ts +0 -6
- package/dist/hud/transcript.d.ts +0 -7
- package/dist/hud/types.d.ts +0 -116
- package/dist/hud/usage-api.d.ts +0 -7
- package/dist/hud/usage-api.js +0 -84
- package/dist/plugins.d.ts +0 -46
- package/dist/plugins.js +0 -233
- package/dist/utils/cli.d.ts +0 -5
- package/dist/utils/cli.js +0 -14
- package/dist/utils/git.d.ts +0 -11
- package/dist/utils/git.js +0 -36
- package/dist/utils/installer.d.ts +0 -41
- package/dist/utils/installer.js +0 -195
- package/dist/utils/manifest.d.ts +0 -46
- package/dist/utils/manifest.js +0 -100
- package/dist/utils/paths.d.ts +0 -42
- package/dist/utils/paths.js +0 -106
- package/dist/utils/post-install.d.ts +0 -87
- package/dist/utils/post-install.js +0 -546
- package/dist/utils/safe-delete-install.d.ts +0 -29
- package/dist/utils/safe-delete-install.js +0 -191
- package/dist/utils/safe-delete.d.ts +0 -12
- package/plugins/devflow-accessibility/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-accessibility/skills/accessibility/SKILL.md +0 -229
- package/plugins/devflow-accessibility/skills/accessibility/references/patterns.md +0 -670
- package/plugins/devflow-accessibility/skills/accessibility/references/violations.md +0 -419
- package/plugins/devflow-ambient/.claude-plugin/plugin.json +0 -33
- package/plugins/devflow-ambient/README.md +0 -68
- package/plugins/devflow-ambient/agents/coder.md +0 -135
- package/plugins/devflow-ambient/agents/reviewer.md +0 -165
- package/plugins/devflow-ambient/agents/scrutinizer.md +0 -82
- package/plugins/devflow-ambient/agents/shepherd.md +0 -108
- package/plugins/devflow-ambient/agents/simplifier.md +0 -102
- package/plugins/devflow-ambient/agents/skimmer.md +0 -143
- package/plugins/devflow-ambient/agents/validator.md +0 -86
- package/plugins/devflow-ambient/skills/ambient-router/SKILL.md +0 -145
- package/plugins/devflow-ambient/skills/ambient-router/references/skill-catalog.md +0 -74
- package/plugins/devflow-ambient/skills/debug-orchestration/SKILL.md +0 -69
- package/plugins/devflow-ambient/skills/implementation-orchestration/SKILL.md +0 -92
- package/plugins/devflow-ambient/skills/plan-orchestration/SKILL.md +0 -71
- package/plugins/devflow-audit-claude/.claude-plugin/plugin.json +0 -19
- package/plugins/devflow-audit-claude/README.md +0 -46
- package/plugins/devflow-audit-claude/agents/claude-md-auditor.md +0 -134
- package/plugins/devflow-audit-claude/commands/audit-claude.md +0 -89
- package/plugins/devflow-code-review/.claude-plugin/plugin.json +0 -38
- package/plugins/devflow-code-review/README.md +0 -73
- package/plugins/devflow-code-review/agents/git.md +0 -277
- package/plugins/devflow-code-review/agents/reviewer.md +0 -165
- package/plugins/devflow-code-review/agents/synthesizer.md +0 -211
- package/plugins/devflow-code-review/commands/code-review-teams.md +0 -285
- package/plugins/devflow-code-review/commands/code-review.md +0 -163
- package/plugins/devflow-code-review/skills/agent-teams/SKILL.md +0 -124
- package/plugins/devflow-code-review/skills/agent-teams/references/cleanup.md +0 -104
- package/plugins/devflow-code-review/skills/agent-teams/references/communication.md +0 -122
- package/plugins/devflow-code-review/skills/agent-teams/references/team-patterns.md +0 -217
- package/plugins/devflow-code-review/skills/architecture-patterns/SKILL.md +0 -153
- package/plugins/devflow-code-review/skills/architecture-patterns/references/patterns.md +0 -873
- package/plugins/devflow-code-review/skills/architecture-patterns/references/violations.md +0 -575
- package/plugins/devflow-code-review/skills/complexity-patterns/SKILL.md +0 -143
- package/plugins/devflow-code-review/skills/consistency-patterns/SKILL.md +0 -140
- package/plugins/devflow-code-review/skills/database-patterns/SKILL.md +0 -134
- package/plugins/devflow-code-review/skills/dependencies-patterns/SKILL.md +0 -141
- package/plugins/devflow-code-review/skills/documentation-patterns/SKILL.md +0 -125
- package/plugins/devflow-code-review/skills/knowledge-persistence/SKILL.md +0 -128
- package/plugins/devflow-code-review/skills/knowledge-persistence/references/examples.md +0 -44
- package/plugins/devflow-code-review/skills/performance-patterns/SKILL.md +0 -154
- package/plugins/devflow-code-review/skills/performance-patterns/references/patterns.md +0 -503
- package/plugins/devflow-code-review/skills/performance-patterns/references/violations.md +0 -354
- package/plugins/devflow-code-review/skills/regression-patterns/SKILL.md +0 -146
- package/plugins/devflow-code-review/skills/review-methodology/SKILL.md +0 -119
- package/plugins/devflow-code-review/skills/review-methodology/references/patterns.md +0 -186
- package/plugins/devflow-code-review/skills/review-methodology/references/report-template.md +0 -142
- package/plugins/devflow-code-review/skills/review-methodology/references/violations.md +0 -125
- package/plugins/devflow-code-review/skills/security-patterns/SKILL.md +0 -156
- package/plugins/devflow-code-review/skills/security-patterns/references/patterns.md +0 -507
- package/plugins/devflow-code-review/skills/security-patterns/references/violations.md +0 -237
- package/plugins/devflow-code-review/skills/test-patterns/SKILL.md +0 -183
- package/plugins/devflow-code-review/skills/test-patterns/references/patterns.md +0 -220
- package/plugins/devflow-code-review/skills/test-patterns/references/violations.md +0 -221
- package/plugins/devflow-core-skills/.claude-plugin/plugin.json +0 -31
- package/plugins/devflow-core-skills/README.md +0 -50
- package/plugins/devflow-core-skills/skills/core-patterns/SKILL.md +0 -162
- package/plugins/devflow-core-skills/skills/core-patterns/references/checklist.md +0 -276
- package/plugins/devflow-core-skills/skills/core-patterns/references/code-smell-violations.md +0 -144
- package/plugins/devflow-core-skills/skills/core-patterns/references/patterns.md +0 -576
- package/plugins/devflow-core-skills/skills/core-patterns/references/violations.md +0 -369
- package/plugins/devflow-core-skills/skills/docs-framework/SKILL.md +0 -143
- package/plugins/devflow-core-skills/skills/docs-framework/references/patterns.md +0 -346
- package/plugins/devflow-core-skills/skills/docs-framework/references/violations.md +0 -221
- package/plugins/devflow-core-skills/skills/git-safety/SKILL.md +0 -122
- package/plugins/devflow-core-skills/skills/git-safety/references/patterns.md +0 -289
- package/plugins/devflow-core-skills/skills/git-safety/references/violations.md +0 -18
- package/plugins/devflow-core-skills/skills/git-workflow/SKILL.md +0 -158
- package/plugins/devflow-core-skills/skills/git-workflow/references/commit-patterns.md +0 -115
- package/plugins/devflow-core-skills/skills/git-workflow/references/commit-violations.md +0 -77
- package/plugins/devflow-core-skills/skills/git-workflow/references/pr-patterns.md +0 -127
- package/plugins/devflow-core-skills/skills/git-workflow/references/pr-violations.md +0 -96
- package/plugins/devflow-core-skills/skills/github-patterns/SKILL.md +0 -153
- package/plugins/devflow-core-skills/skills/github-patterns/references/patterns.md +0 -572
- package/plugins/devflow-core-skills/skills/github-patterns/references/violations.md +0 -298
- package/plugins/devflow-core-skills/skills/input-validation/SKILL.md +0 -148
- package/plugins/devflow-core-skills/skills/input-validation/references/detection.md +0 -283
- package/plugins/devflow-core-skills/skills/input-validation/references/patterns.md +0 -361
- package/plugins/devflow-core-skills/skills/input-validation/references/violations.md +0 -224
- package/plugins/devflow-core-skills/skills/search-first/SKILL.md +0 -133
- package/plugins/devflow-core-skills/skills/search-first/references/evaluation-criteria.md +0 -101
- package/plugins/devflow-core-skills/skills/test-driven-development/SKILL.md +0 -137
- package/plugins/devflow-core-skills/skills/test-patterns/SKILL.md +0 -183
- package/plugins/devflow-core-skills/skills/test-patterns/references/detection.md +0 -149
- package/plugins/devflow-core-skills/skills/test-patterns/references/patterns.md +0 -220
- package/plugins/devflow-core-skills/skills/test-patterns/references/report-template.md +0 -108
- package/plugins/devflow-core-skills/skills/test-patterns/references/violations.md +0 -221
- package/plugins/devflow-debug/.claude-plugin/plugin.json +0 -26
- package/plugins/devflow-debug/README.md +0 -65
- package/plugins/devflow-debug/agents/git.md +0 -277
- package/plugins/devflow-debug/agents/synthesizer.md +0 -211
- package/plugins/devflow-debug/commands/debug-teams.md +0 -245
- package/plugins/devflow-debug/commands/debug.md +0 -174
- package/plugins/devflow-debug/skills/agent-teams/SKILL.md +0 -124
- package/plugins/devflow-debug/skills/agent-teams/references/cleanup.md +0 -104
- package/plugins/devflow-debug/skills/agent-teams/references/communication.md +0 -122
- package/plugins/devflow-debug/skills/agent-teams/references/team-patterns.md +0 -217
- package/plugins/devflow-debug/skills/git-safety/SKILL.md +0 -122
- package/plugins/devflow-debug/skills/git-safety/references/detection.md +0 -290
- package/plugins/devflow-debug/skills/git-safety/references/patterns.md +0 -289
- package/plugins/devflow-debug/skills/git-safety/references/violations.md +0 -18
- package/plugins/devflow-debug/skills/knowledge-persistence/SKILL.md +0 -128
- package/plugins/devflow-debug/skills/knowledge-persistence/references/examples.md +0 -44
- package/plugins/devflow-frontend-design/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-frontend-design/skills/frontend-design/SKILL.md +0 -254
- package/plugins/devflow-frontend-design/skills/frontend-design/references/patterns.md +0 -511
- package/plugins/devflow-frontend-design/skills/frontend-design/references/violations.md +0 -453
- package/plugins/devflow-go/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-go/skills/go/SKILL.md +0 -187
- package/plugins/devflow-go/skills/go/references/concurrency.md +0 -312
- package/plugins/devflow-go/skills/go/references/patterns.md +0 -232
- package/plugins/devflow-go/skills/go/references/violations.md +0 -205
- package/plugins/devflow-implement/.claude-plugin/plugin.json +0 -35
- package/plugins/devflow-implement/README.md +0 -71
- package/plugins/devflow-implement/agents/coder.md +0 -135
- package/plugins/devflow-implement/agents/git.md +0 -277
- package/plugins/devflow-implement/agents/scrutinizer.md +0 -82
- package/plugins/devflow-implement/agents/shepherd.md +0 -108
- package/plugins/devflow-implement/agents/simplifier.md +0 -102
- package/plugins/devflow-implement/agents/skimmer.md +0 -143
- package/plugins/devflow-implement/agents/synthesizer.md +0 -211
- package/plugins/devflow-implement/agents/validator.md +0 -86
- package/plugins/devflow-implement/commands/implement-teams.md +0 -620
- package/plugins/devflow-implement/commands/implement.md +0 -430
- package/plugins/devflow-implement/skills/agent-teams/SKILL.md +0 -124
- package/plugins/devflow-implement/skills/agent-teams/references/cleanup.md +0 -104
- package/plugins/devflow-implement/skills/agent-teams/references/communication.md +0 -122
- package/plugins/devflow-implement/skills/agent-teams/references/team-patterns.md +0 -217
- package/plugins/devflow-implement/skills/implementation-patterns/SKILL.md +0 -162
- package/plugins/devflow-implement/skills/knowledge-persistence/SKILL.md +0 -128
- package/plugins/devflow-implement/skills/knowledge-persistence/references/examples.md +0 -44
- package/plugins/devflow-implement/skills/self-review/SKILL.md +0 -149
- package/plugins/devflow-implement/skills/self-review/references/stub-detection.md +0 -135
- package/plugins/devflow-java/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-java/skills/java/SKILL.md +0 -183
- package/plugins/devflow-java/skills/java/references/modern-java.md +0 -270
- package/plugins/devflow-java/skills/java/references/patterns.md +0 -235
- package/plugins/devflow-java/skills/java/references/violations.md +0 -213
- package/plugins/devflow-python/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-python/skills/python/SKILL.md +0 -188
- package/plugins/devflow-python/skills/python/references/async.md +0 -220
- package/plugins/devflow-python/skills/python/references/patterns.md +0 -226
- package/plugins/devflow-python/skills/python/references/violations.md +0 -204
- package/plugins/devflow-react/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-react/skills/react/SKILL.md +0 -276
- package/plugins/devflow-react/skills/react/references/patterns.md +0 -1331
- package/plugins/devflow-react/skills/react/references/violations.md +0 -565
- package/plugins/devflow-resolve/.claude-plugin/plugin.json +0 -29
- package/plugins/devflow-resolve/README.md +0 -65
- package/plugins/devflow-resolve/agents/git.md +0 -277
- package/plugins/devflow-resolve/agents/resolver.md +0 -131
- package/plugins/devflow-resolve/agents/simplifier.md +0 -102
- package/plugins/devflow-resolve/commands/resolve-teams.md +0 -307
- package/plugins/devflow-resolve/commands/resolve.md +0 -246
- package/plugins/devflow-resolve/skills/agent-teams/SKILL.md +0 -124
- package/plugins/devflow-resolve/skills/agent-teams/references/cleanup.md +0 -104
- package/plugins/devflow-resolve/skills/agent-teams/references/communication.md +0 -122
- package/plugins/devflow-resolve/skills/agent-teams/references/team-patterns.md +0 -217
- package/plugins/devflow-resolve/skills/implementation-patterns/SKILL.md +0 -162
- package/plugins/devflow-resolve/skills/implementation-patterns/references/patterns.md +0 -1063
- package/plugins/devflow-resolve/skills/implementation-patterns/references/violations.md +0 -483
- package/plugins/devflow-resolve/skills/knowledge-persistence/SKILL.md +0 -128
- package/plugins/devflow-resolve/skills/knowledge-persistence/references/examples.md +0 -44
- package/plugins/devflow-resolve/skills/security-patterns/SKILL.md +0 -156
- package/plugins/devflow-resolve/skills/security-patterns/references/detection.md +0 -287
- package/plugins/devflow-resolve/skills/security-patterns/references/patterns.md +0 -507
- package/plugins/devflow-resolve/skills/security-patterns/references/violations.md +0 -237
- package/plugins/devflow-rust/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-rust/skills/rust/SKILL.md +0 -193
- package/plugins/devflow-rust/skills/rust/references/ownership.md +0 -242
- package/plugins/devflow-rust/skills/rust/references/patterns.md +0 -210
- package/plugins/devflow-rust/skills/rust/references/violations.md +0 -191
- package/plugins/devflow-self-review/.claude-plugin/plugin.json +0 -26
- package/plugins/devflow-self-review/README.md +0 -38
- package/plugins/devflow-self-review/agents/scrutinizer.md +0 -82
- package/plugins/devflow-self-review/agents/simplifier.md +0 -102
- package/plugins/devflow-self-review/agents/validator.md +0 -86
- package/plugins/devflow-self-review/commands/self-review.md +0 -132
- package/plugins/devflow-self-review/skills/core-patterns/SKILL.md +0 -162
- package/plugins/devflow-self-review/skills/core-patterns/references/checklist.md +0 -276
- package/plugins/devflow-self-review/skills/core-patterns/references/code-smell-violations.md +0 -144
- package/plugins/devflow-self-review/skills/core-patterns/references/detection.md +0 -303
- package/plugins/devflow-self-review/skills/core-patterns/references/patterns.md +0 -576
- package/plugins/devflow-self-review/skills/core-patterns/references/violations.md +0 -369
- package/plugins/devflow-self-review/skills/self-review/SKILL.md +0 -149
- package/plugins/devflow-self-review/skills/self-review/references/patterns.md +0 -405
- package/plugins/devflow-self-review/skills/self-review/references/report-template.md +0 -253
- package/plugins/devflow-self-review/skills/self-review/references/stub-detection.md +0 -135
- package/plugins/devflow-self-review/skills/self-review/references/violations.md +0 -308
- package/plugins/devflow-specify/.claude-plugin/plugin.json +0 -25
- package/plugins/devflow-specify/README.md +0 -46
- package/plugins/devflow-specify/agents/skimmer.md +0 -143
- package/plugins/devflow-specify/agents/synthesizer.md +0 -211
- package/plugins/devflow-specify/commands/specify-teams.md +0 -321
- package/plugins/devflow-specify/commands/specify.md +0 -186
- package/plugins/devflow-specify/skills/agent-teams/SKILL.md +0 -124
- package/plugins/devflow-specify/skills/agent-teams/references/cleanup.md +0 -104
- package/plugins/devflow-specify/skills/agent-teams/references/communication.md +0 -122
- package/plugins/devflow-specify/skills/agent-teams/references/team-patterns.md +0 -217
- package/plugins/devflow-typescript/.claude-plugin/plugin.json +0 -21
- package/plugins/devflow-typescript/skills/typescript/SKILL.md +0 -176
- package/plugins/devflow-typescript/skills/typescript/references/patterns.md +0 -1105
- package/plugins/devflow-typescript/skills/typescript/references/violations.md +0 -433
- package/scripts/hooks/ambient-prompt +0 -50
- package/scripts/hooks/background-memory-update +0 -257
- package/scripts/hooks/ensure-memory-gitignore +0 -17
- package/scripts/hooks/pre-compact-memory +0 -87
- package/scripts/hooks/run-hook +0 -23
- package/scripts/hooks/session-start-memory +0 -165
- package/scripts/hooks/stop-update-memory +0 -85
- package/scripts/hud/cache.d.ts +0 -14
- package/scripts/hud/cache.d.ts.map +0 -1
- package/scripts/hud/cache.js +0 -54
- package/scripts/hud/cache.js.map +0 -1
- package/scripts/hud/colors.d.ts +0 -23
- package/scripts/hud/colors.d.ts.map +0 -1
- package/scripts/hud/colors.js +0 -62
- package/scripts/hud/colors.js.map +0 -1
- package/scripts/hud/components/config-counts.d.ts +0 -8
- package/scripts/hud/components/config-counts.d.ts.map +0 -1
- package/scripts/hud/components/config-counts.js +0 -91
- package/scripts/hud/components/config-counts.js.map +0 -1
- package/scripts/hud/components/context-usage.d.ts +0 -8
- package/scripts/hud/components/context-usage.d.ts.map +0 -1
- package/scripts/hud/components/context-usage.js +0 -49
- package/scripts/hud/components/context-usage.js.map +0 -1
- package/scripts/hud/components/diff-stats.d.ts +0 -3
- package/scripts/hud/components/diff-stats.d.ts.map +0 -1
- package/scripts/hud/components/diff-stats.js +0 -36
- package/scripts/hud/components/diff-stats.js.map +0 -1
- package/scripts/hud/components/directory.d.ts +0 -3
- package/scripts/hud/components/directory.d.ts.map +0 -1
- package/scripts/hud/components/directory.js +0 -10
- package/scripts/hud/components/directory.js.map +0 -1
- package/scripts/hud/components/git-ahead-behind.d.ts +0 -3
- package/scripts/hud/components/git-ahead-behind.d.ts.map +0 -1
- package/scripts/hud/components/git-ahead-behind.js +0 -16
- package/scripts/hud/components/git-ahead-behind.js.map +0 -1
- package/scripts/hud/components/git-branch.d.ts +0 -3
- package/scripts/hud/components/git-branch.d.ts.map +0 -1
- package/scripts/hud/components/git-branch.js +0 -14
- package/scripts/hud/components/git-branch.js.map +0 -1
- package/scripts/hud/components/model.d.ts +0 -3
- package/scripts/hud/components/model.d.ts.map +0 -1
- package/scripts/hud/components/model.js +0 -21
- package/scripts/hud/components/model.js.map +0 -1
- package/scripts/hud/components/release-info.d.ts +0 -3
- package/scripts/hud/components/release-info.d.ts.map +0 -1
- package/scripts/hud/components/release-info.js +0 -9
- package/scripts/hud/components/release-info.js.map +0 -1
- package/scripts/hud/components/session-cost.d.ts +0 -3
- package/scripts/hud/components/session-cost.d.ts.map +0 -1
- package/scripts/hud/components/session-cost.js +0 -9
- package/scripts/hud/components/session-cost.js.map +0 -1
- package/scripts/hud/components/session-duration.d.ts +0 -3
- package/scripts/hud/components/session-duration.d.ts.map +0 -1
- package/scripts/hud/components/session-duration.js +0 -18
- package/scripts/hud/components/session-duration.js.map +0 -1
- package/scripts/hud/components/todo-progress.d.ts +0 -3
- package/scripts/hud/components/todo-progress.d.ts.map +0 -1
- package/scripts/hud/components/todo-progress.js +0 -11
- package/scripts/hud/components/todo-progress.js.map +0 -1
- package/scripts/hud/components/usage-quota.d.ts +0 -3
- package/scripts/hud/components/usage-quota.d.ts.map +0 -1
- package/scripts/hud/components/usage-quota.js +0 -45
- package/scripts/hud/components/usage-quota.js.map +0 -1
- package/scripts/hud/components/version-badge.d.ts +0 -3
- package/scripts/hud/components/version-badge.d.ts.map +0 -1
- package/scripts/hud/components/version-badge.js +0 -80
- package/scripts/hud/components/version-badge.js.map +0 -1
- package/scripts/hud/components/worktree-count.d.ts +0 -3
- package/scripts/hud/components/worktree-count.d.ts.map +0 -1
- package/scripts/hud/components/worktree-count.js +0 -8
- package/scripts/hud/components/worktree-count.js.map +0 -1
- package/scripts/hud/config.d.ts +0 -10
- package/scripts/hud/config.d.ts.map +0 -1
- package/scripts/hud/config.js +0 -55
- package/scripts/hud/config.js.map +0 -1
- package/scripts/hud/credentials.d.ts +0 -17
- package/scripts/hud/credentials.d.ts.map +0 -1
- package/scripts/hud/credentials.js +0 -99
- package/scripts/hud/credentials.js.map +0 -1
- package/scripts/hud/git.d.ts +0 -7
- package/scripts/hud/git.d.ts.map +0 -1
- package/scripts/hud/git.js +0 -153
- package/scripts/hud/git.js.map +0 -1
- package/scripts/hud/index.d.ts +0 -2
- package/scripts/hud/index.d.ts.map +0 -1
- package/scripts/hud/index.js +0 -81
- package/scripts/hud/index.js.map +0 -1
- package/scripts/hud/render.d.ts +0 -7
- package/scripts/hud/render.d.ts.map +0 -1
- package/scripts/hud/render.js +0 -111
- package/scripts/hud/render.js.map +0 -1
- package/scripts/hud/stdin.d.ts +0 -6
- package/scripts/hud/stdin.d.ts.map +0 -1
- package/scripts/hud/stdin.js +0 -25
- package/scripts/hud/stdin.js.map +0 -1
- package/scripts/hud/transcript.d.ts +0 -7
- package/scripts/hud/transcript.d.ts.map +0 -1
- package/scripts/hud/transcript.js +0 -130
- package/scripts/hud/transcript.js.map +0 -1
- package/scripts/hud/types.d.ts +0 -116
- package/scripts/hud/types.d.ts.map +0 -1
- package/scripts/hud/types.js +0 -2
- package/scripts/hud/types.js.map +0 -1
- package/scripts/hud/usage-api.d.ts +0 -7
- package/scripts/hud/usage-api.d.ts.map +0 -1
- package/scripts/hud/usage-api.js +0 -84
- package/scripts/hud/usage-api.js.map +0 -1
- package/scripts/hud.sh +0 -5
- package/shared/agents/coder.md +0 -135
- package/shared/agents/git.md +0 -277
- package/shared/agents/resolver.md +0 -131
- package/shared/agents/reviewer.md +0 -165
- package/shared/agents/scrutinizer.md +0 -82
- package/shared/agents/shepherd.md +0 -108
- package/shared/agents/simplifier.md +0 -102
- package/shared/agents/skimmer.md +0 -143
- package/shared/agents/synthesizer.md +0 -211
- package/shared/agents/validator.md +0 -86
- package/shared/skills/accessibility/SKILL.md +0 -229
- package/shared/skills/accessibility/references/detection.md +0 -171
- package/shared/skills/accessibility/references/patterns.md +0 -670
- package/shared/skills/accessibility/references/violations.md +0 -419
- package/shared/skills/agent-teams/SKILL.md +0 -124
- package/shared/skills/agent-teams/references/cleanup.md +0 -104
- package/shared/skills/agent-teams/references/communication.md +0 -122
- package/shared/skills/agent-teams/references/team-patterns.md +0 -217
- package/shared/skills/ambient-router/SKILL.md +0 -145
- package/shared/skills/ambient-router/references/skill-catalog.md +0 -74
- package/shared/skills/architecture-patterns/SKILL.md +0 -153
- package/shared/skills/architecture-patterns/references/detection.md +0 -337
- package/shared/skills/architecture-patterns/references/patterns.md +0 -873
- package/shared/skills/architecture-patterns/references/violations.md +0 -575
- package/shared/skills/complexity-patterns/SKILL.md +0 -143
- package/shared/skills/complexity-patterns/references/detection.md +0 -264
- package/shared/skills/complexity-patterns/references/patterns.md +0 -487
- package/shared/skills/complexity-patterns/references/violations.md +0 -361
- package/shared/skills/consistency-patterns/SKILL.md +0 -140
- package/shared/skills/consistency-patterns/references/detection.md +0 -207
- package/shared/skills/consistency-patterns/references/patterns.md +0 -202
- package/shared/skills/consistency-patterns/references/violations.md +0 -213
- package/shared/skills/core-patterns/SKILL.md +0 -162
- package/shared/skills/core-patterns/references/checklist.md +0 -276
- package/shared/skills/core-patterns/references/code-smell-violations.md +0 -144
- package/shared/skills/core-patterns/references/detection.md +0 -303
- package/shared/skills/core-patterns/references/patterns.md +0 -576
- package/shared/skills/core-patterns/references/violations.md +0 -369
- package/shared/skills/database-patterns/SKILL.md +0 -134
- package/shared/skills/database-patterns/references/detection.md +0 -208
- package/shared/skills/database-patterns/references/patterns.md +0 -394
- package/shared/skills/database-patterns/references/violations.md +0 -332
- package/shared/skills/debug-orchestration/SKILL.md +0 -69
- package/shared/skills/dependencies-patterns/SKILL.md +0 -141
- package/shared/skills/dependencies-patterns/references/detection.md +0 -181
- package/shared/skills/dependencies-patterns/references/patterns.md +0 -225
- package/shared/skills/dependencies-patterns/references/violations.md +0 -247
- package/shared/skills/docs-framework/SKILL.md +0 -143
- package/shared/skills/docs-framework/references/patterns.md +0 -346
- package/shared/skills/docs-framework/references/violations.md +0 -221
- package/shared/skills/documentation-patterns/SKILL.md +0 -125
- package/shared/skills/documentation-patterns/references/detection.md +0 -190
- package/shared/skills/documentation-patterns/references/patterns.md +0 -189
- package/shared/skills/documentation-patterns/references/violations.md +0 -163
- package/shared/skills/frontend-design/SKILL.md +0 -254
- package/shared/skills/frontend-design/references/detection.md +0 -184
- package/shared/skills/frontend-design/references/patterns.md +0 -511
- package/shared/skills/frontend-design/references/violations.md +0 -453
- package/shared/skills/git-safety/SKILL.md +0 -122
- package/shared/skills/git-safety/references/detection.md +0 -290
- package/shared/skills/git-safety/references/patterns.md +0 -289
- package/shared/skills/git-safety/references/violations.md +0 -18
- package/shared/skills/git-workflow/SKILL.md +0 -158
- package/shared/skills/git-workflow/references/commit-patterns.md +0 -115
- package/shared/skills/git-workflow/references/commit-violations.md +0 -77
- package/shared/skills/git-workflow/references/pr-patterns.md +0 -127
- package/shared/skills/git-workflow/references/pr-violations.md +0 -96
- package/shared/skills/github-patterns/SKILL.md +0 -153
- package/shared/skills/github-patterns/references/patterns.md +0 -572
- package/shared/skills/github-patterns/references/violations.md +0 -298
- package/shared/skills/go/SKILL.md +0 -187
- package/shared/skills/go/references/concurrency.md +0 -312
- package/shared/skills/go/references/detection.md +0 -129
- package/shared/skills/go/references/patterns.md +0 -232
- package/shared/skills/go/references/violations.md +0 -205
- package/shared/skills/implementation-orchestration/SKILL.md +0 -92
- package/shared/skills/implementation-patterns/SKILL.md +0 -162
- package/shared/skills/implementation-patterns/references/patterns.md +0 -1063
- package/shared/skills/implementation-patterns/references/violations.md +0 -483
- package/shared/skills/input-validation/SKILL.md +0 -148
- package/shared/skills/input-validation/references/detection.md +0 -283
- package/shared/skills/input-validation/references/patterns.md +0 -361
- package/shared/skills/input-validation/references/violations.md +0 -224
- package/shared/skills/java/SKILL.md +0 -183
- package/shared/skills/java/references/detection.md +0 -120
- package/shared/skills/java/references/modern-java.md +0 -270
- package/shared/skills/java/references/patterns.md +0 -235
- package/shared/skills/java/references/violations.md +0 -213
- package/shared/skills/knowledge-persistence/SKILL.md +0 -128
- package/shared/skills/knowledge-persistence/references/examples.md +0 -44
- package/shared/skills/performance-patterns/SKILL.md +0 -154
- package/shared/skills/performance-patterns/references/detection.md +0 -351
- package/shared/skills/performance-patterns/references/patterns.md +0 -503
- package/shared/skills/performance-patterns/references/violations.md +0 -354
- package/shared/skills/plan-orchestration/SKILL.md +0 -71
- package/shared/skills/python/SKILL.md +0 -188
- package/shared/skills/python/references/async.md +0 -220
- package/shared/skills/python/references/detection.md +0 -128
- package/shared/skills/python/references/patterns.md +0 -226
- package/shared/skills/python/references/violations.md +0 -204
- package/shared/skills/react/SKILL.md +0 -276
- package/shared/skills/react/references/patterns.md +0 -1331
- package/shared/skills/react/references/violations.md +0 -565
- package/shared/skills/regression-patterns/SKILL.md +0 -146
- package/shared/skills/regression-patterns/references/detection.md +0 -237
- package/shared/skills/regression-patterns/references/patterns.md +0 -226
- package/shared/skills/regression-patterns/references/violations.md +0 -225
- package/shared/skills/review-methodology/SKILL.md +0 -119
- package/shared/skills/review-methodology/references/patterns.md +0 -186
- package/shared/skills/review-methodology/references/report-template.md +0 -142
- package/shared/skills/review-methodology/references/violations.md +0 -125
- package/shared/skills/rust/SKILL.md +0 -193
- package/shared/skills/rust/references/detection.md +0 -131
- package/shared/skills/rust/references/ownership.md +0 -242
- package/shared/skills/rust/references/patterns.md +0 -210
- package/shared/skills/rust/references/violations.md +0 -191
- package/shared/skills/search-first/SKILL.md +0 -133
- package/shared/skills/search-first/references/evaluation-criteria.md +0 -101
- package/shared/skills/security-patterns/SKILL.md +0 -156
- package/shared/skills/security-patterns/references/detection.md +0 -287
- package/shared/skills/security-patterns/references/patterns.md +0 -507
- package/shared/skills/security-patterns/references/violations.md +0 -237
- package/shared/skills/self-review/SKILL.md +0 -149
- package/shared/skills/self-review/references/patterns.md +0 -405
- package/shared/skills/self-review/references/report-template.md +0 -253
- package/shared/skills/self-review/references/stub-detection.md +0 -135
- package/shared/skills/self-review/references/violations.md +0 -308
- package/shared/skills/test-driven-development/SKILL.md +0 -137
- package/shared/skills/test-driven-development/references/rationalization-prevention.md +0 -111
- package/shared/skills/test-patterns/SKILL.md +0 -183
- package/shared/skills/test-patterns/references/detection.md +0 -149
- package/shared/skills/test-patterns/references/patterns.md +0 -220
- package/shared/skills/test-patterns/references/report-template.md +0 -108
- package/shared/skills/test-patterns/references/violations.md +0 -221
- package/shared/skills/typescript/SKILL.md +0 -176
- package/shared/skills/typescript/references/patterns.md +0 -1105
- package/shared/skills/typescript/references/violations.md +0 -433
- package/src/templates/claudeignore.template +0 -188
- package/src/templates/settings.json +0 -59
- /package/dist/{utils → core}/safe-delete.js +0 -0
- /package/{plugins/devflow-accessibility → src/assets}/skills/accessibility/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/architecture-patterns → src/assets/skills/architecture}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/complexity-patterns → src/assets/skills/complexity}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/complexity-patterns → src/assets/skills/complexity}/references/patterns.md +0 -0
- /package/{plugins/devflow-code-review/skills/complexity-patterns → src/assets/skills/complexity}/references/violations.md +0 -0
- /package/{plugins/devflow-code-review/skills/consistency-patterns → src/assets/skills/consistency}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/consistency-patterns → src/assets/skills/consistency}/references/patterns.md +0 -0
- /package/{plugins/devflow-code-review/skills/consistency-patterns → src/assets/skills/consistency}/references/violations.md +0 -0
- /package/{plugins/devflow-code-review/skills/database-patterns → src/assets/skills/database}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/database-patterns → src/assets/skills/database}/references/patterns.md +0 -0
- /package/{plugins/devflow-code-review/skills/database-patterns → src/assets/skills/database}/references/violations.md +0 -0
- /package/{plugins/devflow-code-review/skills/dependencies-patterns → src/assets/skills/dependencies}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/dependencies-patterns → src/assets/skills/dependencies}/references/patterns.md +0 -0
- /package/{plugins/devflow-code-review/skills/dependencies-patterns → src/assets/skills/dependencies}/references/violations.md +0 -0
- /package/{plugins/devflow-code-review/skills/documentation-patterns → src/assets/skills/documentation}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/documentation-patterns → src/assets/skills/documentation}/references/patterns.md +0 -0
- /package/{plugins/devflow-code-review/skills/documentation-patterns → src/assets/skills/documentation}/references/violations.md +0 -0
- /package/{plugins/devflow-core-skills/skills/git-safety → src/assets/skills/git}/references/detection.md +0 -0
- /package/{plugins/devflow-go → src/assets}/skills/go/references/detection.md +0 -0
- /package/{plugins/devflow-java → src/assets}/skills/java/references/detection.md +0 -0
- /package/{plugins/devflow-implement/skills/implementation-patterns → src/assets/skills/patterns}/references/patterns.md +0 -0
- /package/{plugins/devflow-implement/skills/implementation-patterns → src/assets/skills/patterns}/references/violations.md +0 -0
- /package/{plugins/devflow-code-review/skills/performance-patterns → src/assets/skills/performance}/references/detection.md +0 -0
- /package/{plugins/devflow-python → src/assets}/skills/python/references/detection.md +0 -0
- /package/{plugins/devflow-implement/skills/self-review → src/assets/skills/quality-gates}/references/patterns.md +0 -0
- /package/{plugins/devflow-implement/skills/self-review → src/assets/skills/quality-gates}/references/report-template.md +0 -0
- /package/{plugins/devflow-implement/skills/self-review → src/assets/skills/quality-gates}/references/violations.md +0 -0
- /package/{plugins/devflow-code-review/skills/regression-patterns → src/assets/skills/regression}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/regression-patterns → src/assets/skills/regression}/references/patterns.md +0 -0
- /package/{plugins/devflow-code-review/skills/regression-patterns → src/assets/skills/regression}/references/violations.md +0 -0
- /package/{plugins/devflow-rust → src/assets}/skills/rust/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/security-patterns → src/assets/skills/security}/references/detection.md +0 -0
- /package/{plugins/devflow-core-skills/skills/core-patterns → src/assets/skills/software-design}/references/detection.md +0 -0
- /package/{plugins/devflow-core-skills → src/assets}/skills/test-driven-development/references/rationalization-prevention.md +0 -0
- /package/{plugins/devflow-code-review/skills/test-patterns → src/assets/skills/testing}/references/detection.md +0 -0
- /package/{plugins/devflow-code-review/skills/test-patterns → src/assets/skills/testing}/references/report-template.md +0 -0
- /package/{plugins/devflow-frontend-design/skills/frontend-design → src/assets/skills/ui-design}/references/detection.md +0 -0
- /package/src/{templates → targets/claude-code/templates}/managed-settings.json +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* @file proxy-log.ts
|
|
5
|
+
*
|
|
6
|
+
* SEC-2: Proxy log hardening and child-env scoping helpers.
|
|
7
|
+
*
|
|
8
|
+
* Exports:
|
|
9
|
+
* - scrubChildEnv — literal allowlist env for relay/doctor children (SEC-2)
|
|
10
|
+
* - openProxyLog — 0700-parent + 0600-file open with best-effort chmod (SEC-2)
|
|
11
|
+
* - rotateProxyLogIfLarge — pre-spawn-only 2MB→1MB rotation that preserves 0600 mode
|
|
12
|
+
*
|
|
13
|
+
* avoids PF-009: every failure path is non-fatal (wrapped in try/catch); one bad
|
|
14
|
+
* chmod or rotation error must never abort the enable flow.
|
|
15
|
+
*/
|
|
16
|
+
/** 2 MB max log size before rotation (mirrors ensure-proxy _LOG_MAX_BYTES). */
|
|
17
|
+
export const PROXY_LOG_MAX_BYTES = 2_097_152;
|
|
18
|
+
/** 1 MB tail to retain after rotation (mirrors ensure-proxy _LOG_TAIL_BYTES). */
|
|
19
|
+
export const PROXY_LOG_TAIL_BYTES = 1_048_576;
|
|
20
|
+
/**
|
|
21
|
+
* Build a scrubbed child process environment for relay/doctor subprocesses.
|
|
22
|
+
*
|
|
23
|
+
* Returns a literal allowlist copied from process.env:
|
|
24
|
+
* posix: PATH, HOME, TMPDIR, LANG, LC_ALL, NODE_EXTRA_CA_CERTS (when set)
|
|
25
|
+
* win32: additionally SystemRoot, APPDATA, USERPROFILE, ComSpec
|
|
26
|
+
*
|
|
27
|
+
* Variables absent from process.env are omitted rather than set to undefined.
|
|
28
|
+
* Call sites compose on top of this result to add process-specific vars
|
|
29
|
+
* (e.g. SUBSWITCH_CONFIG for the relay spawn and doctor spawn).
|
|
30
|
+
*
|
|
31
|
+
* applies ADR-003: the prior denylist rationale is gone — the routing runtime
|
|
32
|
+
* reads exactly three env vars (ANTHROPIC_API_KEY, FORCE_COLOR, SUBSWITCH_CONFIG).
|
|
33
|
+
* Verified by whole-dist grep of the 0.2.0 package. An allowlist is the correct
|
|
34
|
+
* shape: 61 inherited vars → 6.
|
|
35
|
+
*
|
|
36
|
+
* HOME is retained: the runtime's loadConfig resolves ~ paths via homedir().
|
|
37
|
+
*
|
|
38
|
+
* NODE_EXTRA_CA_CERTS is included so corporate-TLS deployments can supply a CA
|
|
39
|
+
* bundle; it is omitted when unset (the absent-→-omit loop handles this).
|
|
40
|
+
* NODE_OPTIONS is deliberately excluded: it permits arbitrary code execution via
|
|
41
|
+
* --require/--import. Mirrored in the ensure-proxy bash hook's _RELAY_ENV array
|
|
42
|
+
* (avoids PF-017); both allowlists must be kept in sync.
|
|
43
|
+
*/
|
|
44
|
+
export function scrubChildEnv() {
|
|
45
|
+
const POSIX_ALLOWLIST = ['PATH', 'HOME', 'TMPDIR', 'LANG', 'LC_ALL', 'NODE_EXTRA_CA_CERTS'];
|
|
46
|
+
const WIN32_ALLOWLIST = ['SystemRoot', 'APPDATA', 'USERPROFILE', 'ComSpec'];
|
|
47
|
+
const keys = process.platform === 'win32'
|
|
48
|
+
? [...POSIX_ALLOWLIST, ...WIN32_ALLOWLIST]
|
|
49
|
+
: [...POSIX_ALLOWLIST];
|
|
50
|
+
const env = {};
|
|
51
|
+
for (const key of keys) {
|
|
52
|
+
const val = process.env[key];
|
|
53
|
+
if (val !== undefined) {
|
|
54
|
+
env[key] = val;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return env;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Open proxy.log for appending, ensuring the parent directory and the file
|
|
61
|
+
* itself are created with restricted permissions:
|
|
62
|
+
*
|
|
63
|
+
* 1. mkdir parent with { recursive: true, mode: 0o700 } — new directories
|
|
64
|
+
* land at 0700; already-existing directories are unaffected by mkdir.
|
|
65
|
+
* 2. fs.open(logPath, 'a', 0o600) — mode 0600 applies on creation only;
|
|
66
|
+
* a pre-existing file retains its current mode at this step.
|
|
67
|
+
* 3. best-effort fs.chmod(logPath, 0o600) — widens a pre-existing file
|
|
68
|
+
* that was created before this guard existed (e.g. mode 0644 on disk).
|
|
69
|
+
* Non-fatal: a chmod failure (EPERM, ENOENT race) must never prevent the
|
|
70
|
+
* handle from being returned — avoids PF-009 failure-isolation principle.
|
|
71
|
+
* Follows the SEC-1 precedent in src/core/fs-atomic.ts (commit 5755d56):
|
|
72
|
+
* chmod in try/catch, never fatal, with a comment citing the rationale.
|
|
73
|
+
*
|
|
74
|
+
* @param logPath - Absolute path to proxy.log.
|
|
75
|
+
* @returns A FileHandle open in append mode (0600 or best-effort).
|
|
76
|
+
*/
|
|
77
|
+
export async function openProxyLog(logPath) {
|
|
78
|
+
// Step 1: ensure parent directory exists at 0700.
|
|
79
|
+
// mode: 0o700 applies to newly created directories only; pre-existing
|
|
80
|
+
// directories at 0755 are not narrowed — chmod the dir if needed separately.
|
|
81
|
+
await fs.mkdir(path.dirname(logPath), { recursive: true, mode: 0o700 });
|
|
82
|
+
// Step 2: open (or create) file for appending.
|
|
83
|
+
// 0o600 mode applies on creation only — does not change a pre-existing mode.
|
|
84
|
+
const handle = await fs.open(logPath, 'a', 0o600);
|
|
85
|
+
// Step 3: best-effort chmod for a pre-existing file that has a wider mode.
|
|
86
|
+
// Non-fatal: chmod failure must not prevent the handle from being returned.
|
|
87
|
+
// avoids PF-009: failure-isolation — one bad chmod must never abort the enable flow.
|
|
88
|
+
try {
|
|
89
|
+
await fs.chmod(logPath, 0o600);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// EPERM, ENOENT race, or unsupported platform — use the mode already on disk.
|
|
93
|
+
// The open() in step 2 already succeeded; the file is usable regardless.
|
|
94
|
+
}
|
|
95
|
+
return handle;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Rotate proxy.log in-place when it exceeds PROXY_LOG_MAX_BYTES.
|
|
99
|
+
*
|
|
100
|
+
* Writes the last PROXY_LOG_TAIL_BYTES to a sibling .tmp.$PID file under
|
|
101
|
+
* mode 0o600 (written directly, not via chmod-after-rename), then atomically
|
|
102
|
+
* replaces the original with a rename. The rename replaces the inode, so the
|
|
103
|
+
* replacement carries the tmp file's 0o600 mode — this is the stronger
|
|
104
|
+
* guarantee (no race window between rename and chmod).
|
|
105
|
+
*
|
|
106
|
+
* This mirrors the ensure-proxy shell hook which creates the rotation tmp
|
|
107
|
+
* under `umask 077` for the same reason.
|
|
108
|
+
*
|
|
109
|
+
* SAFETY INVARIANT — MUST BE CALLED PRE-SPAWN ONLY:
|
|
110
|
+
* rename() replaces the inode at the log path. If the detached relay process
|
|
111
|
+
* already holds an append fd on the old inode, all subsequent relay output
|
|
112
|
+
* goes to an unlinked inode (orphaned fd). This function is therefore called
|
|
113
|
+
* ONLY from the runEnable path BEFORE spawnRelayAndWaitForPort — at that
|
|
114
|
+
* point no relay process exists and no fd is open on proxy.log.
|
|
115
|
+
* Never call this function from realSpawnDoctor or any post-spawn context.
|
|
116
|
+
*
|
|
117
|
+
* Non-fatal: rotation failure (disk full, EPERM, read error) leaves the
|
|
118
|
+
* original log untouched and the enable proceeds with an oversized log.
|
|
119
|
+
* avoids PF-009: one rotation error must never abort the enable flow.
|
|
120
|
+
*
|
|
121
|
+
* @param logPath - Absolute path to proxy.log.
|
|
122
|
+
*/
|
|
123
|
+
export async function rotateProxyLogIfLarge(logPath) {
|
|
124
|
+
let stat;
|
|
125
|
+
try {
|
|
126
|
+
stat = await fs.stat(logPath);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// File does not exist yet — nothing to rotate.
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (stat.size <= PROXY_LOG_MAX_BYTES)
|
|
133
|
+
return;
|
|
134
|
+
const tmpPath = `${logPath}.tmp.${process.pid}`;
|
|
135
|
+
try {
|
|
136
|
+
// Read the tail portion (last PROXY_LOG_TAIL_BYTES).
|
|
137
|
+
const srcHandle = await fs.open(logPath, 'r');
|
|
138
|
+
let tail;
|
|
139
|
+
try {
|
|
140
|
+
const offset = Math.max(0, stat.size - PROXY_LOG_TAIL_BYTES);
|
|
141
|
+
const readLen = stat.size - offset;
|
|
142
|
+
const buf = Buffer.allocUnsafe(readLen);
|
|
143
|
+
const { bytesRead } = await srcHandle.read(buf, 0, readLen, offset);
|
|
144
|
+
tail = buf.subarray(0, bytesRead);
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await srcHandle.close();
|
|
148
|
+
}
|
|
149
|
+
// Write tail to tmp with mode 0o600 at open time — the post-rename inode
|
|
150
|
+
// carries this mode without needing a subsequent chmod (no race window).
|
|
151
|
+
await fs.writeFile(tmpPath, tail, { mode: 0o600 });
|
|
152
|
+
// Atomic replace — readers and writers see old-or-new, never absent.
|
|
153
|
+
await fs.rename(tmpPath, logPath);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Rotation failed (ENOSPC, EPERM, read error, etc.) — clean up tmp and
|
|
157
|
+
// continue. The original log is untouched; an oversized log is preferable
|
|
158
|
+
// to a broken enable.
|
|
159
|
+
try {
|
|
160
|
+
await fs.unlink(tmpPath);
|
|
161
|
+
}
|
|
162
|
+
catch { /* already gone or never written */ }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=proxy-log.js.map
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy state persistence and routing config helpers for the Devflow external
|
|
3
|
+
* model routing feature.
|
|
4
|
+
*
|
|
5
|
+
* applies ADR-013: pure core-layer module — no Claude Code adapter concerns.
|
|
6
|
+
* avoids PF-014: never call process.exit() inside finally-guarded scopes; all
|
|
7
|
+
* fallible operations return Result instead of throwing.
|
|
8
|
+
*
|
|
9
|
+
* State file: ~/.devflow/proxy.json
|
|
10
|
+
* Routing config: ~/.devflow/proxy-routing.json (written by proxy CLI command)
|
|
11
|
+
*
|
|
12
|
+
* NOTE: the internal routing runtime package name ("subswitch") must NEVER appear
|
|
13
|
+
* in user-visible strings or error messages. User-facing vocabulary:
|
|
14
|
+
* "external model routing" / "Devflow proxy".
|
|
15
|
+
*/
|
|
16
|
+
import { createRequire } from 'module';
|
|
17
|
+
import { join } from 'path';
|
|
18
|
+
import { promises as fs } from 'fs';
|
|
19
|
+
import { writeFileAtomicExclusive } from './fs-atomic.js';
|
|
20
|
+
function Ok(value) {
|
|
21
|
+
return { ok: true, value };
|
|
22
|
+
}
|
|
23
|
+
function Err(error) {
|
|
24
|
+
return { ok: false, error };
|
|
25
|
+
}
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Proxy state schema
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/** Default port for the Devflow proxy. */
|
|
30
|
+
export const DEFAULT_PROXY_PORT = 4141;
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Read / write
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* Read proxy state from ~/.devflow/proxy.json with tolerant parsing.
|
|
36
|
+
* Returns a default disabled state when the file is missing.
|
|
37
|
+
*/
|
|
38
|
+
export async function readProxyState(devflowDir) {
|
|
39
|
+
const statePath = join(devflowDir, 'proxy.json');
|
|
40
|
+
try {
|
|
41
|
+
const content = await fs.readFile(statePath, 'utf-8');
|
|
42
|
+
const data = JSON.parse(content);
|
|
43
|
+
// Tolerant parse: provide safe defaults for missing/invalid fields.
|
|
44
|
+
const state = {
|
|
45
|
+
version: 1,
|
|
46
|
+
enabled: typeof data.enabled === 'boolean' ? data.enabled : false,
|
|
47
|
+
port: typeof data.port === 'number' && data.port > 0 ? data.port : DEFAULT_PROXY_PORT,
|
|
48
|
+
binPath: typeof data.binPath === 'string' ? data.binPath : null,
|
|
49
|
+
configPath: typeof data.configPath === 'string' ? data.configPath : null,
|
|
50
|
+
resolvedAt: typeof data.resolvedAt === 'string' ? data.resolvedAt : null,
|
|
51
|
+
devflowVersion: typeof data.devflowVersion === 'string' ? data.devflowVersion : null,
|
|
52
|
+
};
|
|
53
|
+
return Ok(state);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const code = err.code;
|
|
57
|
+
if (code === 'ENOENT') {
|
|
58
|
+
// File missing → return a default disabled state (not an error).
|
|
59
|
+
return Ok({
|
|
60
|
+
version: 1,
|
|
61
|
+
enabled: false,
|
|
62
|
+
port: DEFAULT_PROXY_PORT,
|
|
63
|
+
binPath: null,
|
|
64
|
+
configPath: null,
|
|
65
|
+
resolvedAt: null,
|
|
66
|
+
devflowVersion: null,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return Err(`Failed to read proxy state: ${err.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Atomically write proxy state to ~/.devflow/proxy.json.
|
|
74
|
+
* Creates the parent directory if needed.
|
|
75
|
+
*/
|
|
76
|
+
export async function writeProxyState(devflowDir, state) {
|
|
77
|
+
const statePath = join(devflowDir, 'proxy.json');
|
|
78
|
+
try {
|
|
79
|
+
await fs.mkdir(devflowDir, { recursive: true });
|
|
80
|
+
await writeFileAtomicExclusive(statePath, JSON.stringify(state, null, 2) + '\n');
|
|
81
|
+
return Ok(undefined);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
return Err(`Failed to write proxy state: ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// Pure helpers
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* Accepted top-level keys for the subswitch 0.2.0 FileConfigSchema (z.strictObject).
|
|
92
|
+
* Unknown top-level keys cause a hard relay startup error — never emit them.
|
|
93
|
+
*
|
|
94
|
+
* @D-EFR-4 Subswitch 0.2.0 routing config contract:
|
|
95
|
+
* FileConfigSchema is a z.strictObject with exactly 5 accepted top-level keys:
|
|
96
|
+
* port, logLevel, anthropic, providers, limits. Unknown keys cause a hard startup
|
|
97
|
+
* error — the relay refuses to start. anthropic and limits are themselves
|
|
98
|
+
* strictObject + prefault({}), so they may be partially specified.
|
|
99
|
+
*
|
|
100
|
+
* connectTimeoutMs default: subswitch 0.2.0 applies anthropic.connectTimeoutMs
|
|
101
|
+
* as upstream.setTimeout() at anthropic-passthrough.js:86 — a socket *inactivity*
|
|
102
|
+
* timeout, not a connect timeout. The 10s default kills any Anthropic request
|
|
103
|
+
* whose upstream takes >10s to emit the first response byte — routine for long
|
|
104
|
+
* opus requests (confirmed: 99 spurious 504s clustered at 10004-10098ms while
|
|
105
|
+
* successful requests ran 25s-99s). Default overridden to 120 000ms; a
|
|
106
|
+
* user-specified value always wins.
|
|
107
|
+
*
|
|
108
|
+
* limits.connectTimeoutMs is a registered LEGACY KEY that causes a hard startup
|
|
109
|
+
* error. Strip it from the limits block when preserving existing config.
|
|
110
|
+
*/
|
|
111
|
+
const ROUTING_CONFIG_ALLOWED_TOP_KEYS = new Set([
|
|
112
|
+
'port', 'logLevel', 'anthropic', 'providers', 'limits',
|
|
113
|
+
]);
|
|
114
|
+
/** Default anthropic.connectTimeoutMs injected when not specified by the user (ms). */
|
|
115
|
+
export const DEFAULT_ANTHROPIC_CONNECT_TIMEOUT_MS = 120_000;
|
|
116
|
+
/**
|
|
117
|
+
* Build the routing config JSON for ~/.devflow/proxy-routing.json.
|
|
118
|
+
*
|
|
119
|
+
* Authoritatively sets `port`. Preserves any existing valid `anthropic`,
|
|
120
|
+
* `limits`, `logLevel`, and `providers` blocks from `existingContent`,
|
|
121
|
+
* filtering out unknown top-level keys and the legacy `limits.connectTimeoutMs`
|
|
122
|
+
* field (which causes a hard relay startup error in 0.2.0).
|
|
123
|
+
*
|
|
124
|
+
* Injects a default `anthropic.connectTimeoutMs` of 120 000ms when the user
|
|
125
|
+
* has not set one — see @D-EFR-4 for the rationale.
|
|
126
|
+
*
|
|
127
|
+
* If `existingContent` is missing or malformed, falls back to a clean config
|
|
128
|
+
* with only `port` and `anthropic.connectTimeoutMs`.
|
|
129
|
+
*
|
|
130
|
+
* applies ADR-013: pure core-layer function — no I/O.
|
|
131
|
+
* @D-EFR-4: see note above for the strict top-key constraint and timeout rationale.
|
|
132
|
+
*/
|
|
133
|
+
export function buildRoutingConfigJson(port, existingContent) {
|
|
134
|
+
// Parse existing config tolerantly; a malformed file falls back to clean defaults.
|
|
135
|
+
const preserved = {};
|
|
136
|
+
if (existingContent !== undefined) {
|
|
137
|
+
try {
|
|
138
|
+
const parsed = JSON.parse(existingContent);
|
|
139
|
+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
140
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
141
|
+
// Only preserve the 5 accepted top-level keys; port is always ours.
|
|
142
|
+
if (ROUTING_CONFIG_ALLOWED_TOP_KEYS.has(k) && k !== 'port') {
|
|
143
|
+
preserved[k] = v;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Malformed existing config — fall through to clean defaults.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const config = { port };
|
|
153
|
+
// Preserve logLevel if present in existing config.
|
|
154
|
+
if (preserved.logLevel !== undefined) {
|
|
155
|
+
config.logLevel = preserved.logLevel;
|
|
156
|
+
}
|
|
157
|
+
// Anthropic block: preserve user settings; inject connectTimeoutMs default when absent.
|
|
158
|
+
// @D-EFR-4: the 10s upstream inactivity timeout kills long opus requests.
|
|
159
|
+
const existingAnthropic = typeof preserved.anthropic === 'object' &&
|
|
160
|
+
preserved.anthropic !== null &&
|
|
161
|
+
!Array.isArray(preserved.anthropic)
|
|
162
|
+
? { ...preserved.anthropic }
|
|
163
|
+
: {};
|
|
164
|
+
if (!Object.prototype.hasOwnProperty.call(existingAnthropic, 'connectTimeoutMs')) {
|
|
165
|
+
existingAnthropic.connectTimeoutMs = DEFAULT_ANTHROPIC_CONNECT_TIMEOUT_MS;
|
|
166
|
+
}
|
|
167
|
+
config.anthropic = existingAnthropic;
|
|
168
|
+
// Preserve providers block if present.
|
|
169
|
+
if (preserved.providers !== undefined) {
|
|
170
|
+
config.providers = preserved.providers;
|
|
171
|
+
}
|
|
172
|
+
// Preserve limits block if present; strip legacy limits.connectTimeoutMs that
|
|
173
|
+
// causes a hard startup error in 0.2.0 (use anthropic.connectTimeoutMs instead).
|
|
174
|
+
if (preserved.limits !== undefined) {
|
|
175
|
+
if (typeof preserved.limits === 'object' &&
|
|
176
|
+
preserved.limits !== null &&
|
|
177
|
+
!Array.isArray(preserved.limits)) {
|
|
178
|
+
const limitsObj = { ...preserved.limits };
|
|
179
|
+
delete limitsObj['connectTimeoutMs'];
|
|
180
|
+
config.limits = limitsObj;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
config.limits = preserved.limits;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return JSON.stringify(config, null, 2) + '\n';
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Build a complete ProxyState object with the current timestamp.
|
|
190
|
+
* Pure constructor helper — no I/O.
|
|
191
|
+
*/
|
|
192
|
+
export function buildProxyState(opts) {
|
|
193
|
+
return {
|
|
194
|
+
version: 1,
|
|
195
|
+
enabled: opts.enabled,
|
|
196
|
+
port: opts.port,
|
|
197
|
+
binPath: opts.binPath,
|
|
198
|
+
configPath: opts.configPath,
|
|
199
|
+
resolvedAt: new Date().toISOString(),
|
|
200
|
+
devflowVersion: opts.devflowVersion,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns the proxy base URL for the given port.
|
|
205
|
+
* Pure function.
|
|
206
|
+
*/
|
|
207
|
+
export function proxyBaseUrl(port) {
|
|
208
|
+
return `http://127.0.0.1:${port}`;
|
|
209
|
+
}
|
|
210
|
+
// ---------------------------------------------------------------------------
|
|
211
|
+
// isProxyEnabled — the primary contract other modules consume
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
/**
|
|
214
|
+
* Check whether the Devflow proxy is currently enabled.
|
|
215
|
+
* Returns false when the proxy state file is missing, unreadable, or malformed.
|
|
216
|
+
* This is the SOLE export that agent-models and cli commands use to check proxy state.
|
|
217
|
+
*
|
|
218
|
+
* @param devflowDir - Path to the ~/.devflow directory (injected for testability).
|
|
219
|
+
*/
|
|
220
|
+
export async function isProxyEnabled(devflowDir) {
|
|
221
|
+
const result = await readProxyState(devflowDir);
|
|
222
|
+
if (!result.ok)
|
|
223
|
+
return false;
|
|
224
|
+
return result.value.enabled;
|
|
225
|
+
}
|
|
226
|
+
// ---------------------------------------------------------------------------
|
|
227
|
+
// resolveProxyBin — locate the routing runtime entry point
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
/**
|
|
230
|
+
* Regex for acceptable routing runtime version strings used as cache-key
|
|
231
|
+
* path components. Rejects path-traversal attempts (e.g. '../../etc/x'),
|
|
232
|
+
* excessively long strings, and empty strings.
|
|
233
|
+
*
|
|
234
|
+
* SECURITY: version is used as a path component in cache keys.
|
|
235
|
+
* path.join normalises '..', so an unvalidated version string is an
|
|
236
|
+
* arbitrary-file-overwrite primitive through writeFileAtomicExclusive.
|
|
237
|
+
* This is the second, independent layer; Phase A's path-containment
|
|
238
|
+
* assertion in cache.ts is the first.
|
|
239
|
+
*/
|
|
240
|
+
export const RUNTIME_VERSION_RE = /^[A-Za-z0-9.+-]{1,32}$/;
|
|
241
|
+
/**
|
|
242
|
+
* Resolve the routing runtime binary from devflow's own node_modules.
|
|
243
|
+
*
|
|
244
|
+
* Uses createRequire(import.meta.url).resolve('subswitch/package.json') to find
|
|
245
|
+
* the package, then reads its `bin` field to locate the JS entry point.
|
|
246
|
+
*
|
|
247
|
+
* Returns the absolute path so callers can spawn as `node <path>`.
|
|
248
|
+
* (npm does not guarantee exec bits on installed package binaries.)
|
|
249
|
+
*
|
|
250
|
+
* Returns a Result error whose user-facing message is:
|
|
251
|
+
* "routing runtime missing — reinstall devflow-kit"
|
|
252
|
+
* when the routing runtime is not found (MODULE_NOT_FOUND). The internal package
|
|
253
|
+
* name MUST NOT appear in user-visible strings per the branding constraint.
|
|
254
|
+
*
|
|
255
|
+
* Includes `npxWarning: true` when the resolved path contains `/_npx/` —
|
|
256
|
+
* npx-cached installs are not guaranteed to persist across machine restarts.
|
|
257
|
+
*
|
|
258
|
+
* Includes `version` when the package.json version passes RUNTIME_VERSION_RE.
|
|
259
|
+
* When validation fails the field is absent — the bin is still usable but
|
|
260
|
+
* callers that need the version for cache keys must treat it as unavailable.
|
|
261
|
+
*/
|
|
262
|
+
export async function resolveProxyBin() {
|
|
263
|
+
// createRequire is the ESM-safe way to resolve CommonJS/package paths.
|
|
264
|
+
const require = createRequire(import.meta.url);
|
|
265
|
+
let pkgJsonPath;
|
|
266
|
+
try {
|
|
267
|
+
pkgJsonPath = require.resolve('subswitch/package.json');
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
const code = err.code;
|
|
271
|
+
if (code === 'MODULE_NOT_FOUND') {
|
|
272
|
+
return Err('routing runtime missing — reinstall devflow-kit');
|
|
273
|
+
}
|
|
274
|
+
return Err(`Failed to resolve routing runtime: ${err.message}`);
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, 'utf-8'));
|
|
278
|
+
const bin = pkgJson.bin;
|
|
279
|
+
let binRelPath;
|
|
280
|
+
if (typeof bin === 'string') {
|
|
281
|
+
binRelPath = bin;
|
|
282
|
+
}
|
|
283
|
+
else if (typeof bin === 'object' && bin !== null) {
|
|
284
|
+
// bin is a { name: relPath } map — prefer the 'subswitch' key, fall back to first entry.
|
|
285
|
+
const binObj = bin;
|
|
286
|
+
binRelPath = binObj['subswitch'] ?? Object.values(binObj)[0];
|
|
287
|
+
}
|
|
288
|
+
if (!binRelPath) {
|
|
289
|
+
return Err('routing runtime missing — reinstall devflow-kit');
|
|
290
|
+
}
|
|
291
|
+
const pkgDir = join(pkgJsonPath, '..');
|
|
292
|
+
const binPath = join(pkgDir, binRelPath);
|
|
293
|
+
const npxWarning = binPath.includes('/_npx/');
|
|
294
|
+
// Validate version for safe use as a cache-key path component (AC-S4).
|
|
295
|
+
const rawVersion = pkgJson.version;
|
|
296
|
+
const version = typeof rawVersion === 'string' && RUNTIME_VERSION_RE.test(rawVersion)
|
|
297
|
+
? rawVersion
|
|
298
|
+
: undefined;
|
|
299
|
+
return Ok({ binPath, npxWarning, version });
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
return Err(`Failed to read routing runtime package info: ${err.message}`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=proxy-state.js.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
const START_MARKER = '# >>> Devflow safe-delete >>>';
|
|
4
|
+
const END_MARKER = '# <<< Devflow safe-delete <<<';
|
|
5
|
+
/** Bump this when the safe-delete block changes. */
|
|
6
|
+
export const SAFE_DELETE_BLOCK_VERSION = 2;
|
|
7
|
+
/**
|
|
8
|
+
* Generate the safe-delete shell function block with markers.
|
|
9
|
+
* Returns null for unsupported shells.
|
|
10
|
+
*/
|
|
11
|
+
export function generateSafeDeleteBlock(shell, platform, trashCommand) {
|
|
12
|
+
if (shell === 'unknown')
|
|
13
|
+
return null;
|
|
14
|
+
if (shell === 'bash' || shell === 'zsh') {
|
|
15
|
+
const cmd = trashCommand ?? 'trash';
|
|
16
|
+
return [
|
|
17
|
+
START_MARKER,
|
|
18
|
+
`# v${SAFE_DELETE_BLOCK_VERSION}`,
|
|
19
|
+
`rm() {`,
|
|
20
|
+
` local files=()`,
|
|
21
|
+
` for arg in "$@"; do`,
|
|
22
|
+
` [[ "$arg" =~ ^- ]] || files+=("$arg")`,
|
|
23
|
+
` done`,
|
|
24
|
+
` local existing=()`,
|
|
25
|
+
` for f in "\${files[@]}"; do`,
|
|
26
|
+
` [ -e "$f" ] || [ -L "$f" ] && existing+=("$f")`,
|
|
27
|
+
` done`,
|
|
28
|
+
` if (( \${#existing[@]} > 0 )); then`,
|
|
29
|
+
` ${cmd} "\${existing[@]}"`,
|
|
30
|
+
` fi`,
|
|
31
|
+
`}`,
|
|
32
|
+
`command() {`,
|
|
33
|
+
` if [[ "$1" == "rm" ]]; then`,
|
|
34
|
+
` shift; rm "$@"`,
|
|
35
|
+
` else`,
|
|
36
|
+
` builtin command "$@"`,
|
|
37
|
+
` fi`,
|
|
38
|
+
`}`,
|
|
39
|
+
END_MARKER,
|
|
40
|
+
].join('\n');
|
|
41
|
+
}
|
|
42
|
+
if (shell === 'fish') {
|
|
43
|
+
const cmd = trashCommand ?? 'trash';
|
|
44
|
+
return [
|
|
45
|
+
START_MARKER,
|
|
46
|
+
`# v${SAFE_DELETE_BLOCK_VERSION}`,
|
|
47
|
+
`function rm --description "Safe delete via trash"`,
|
|
48
|
+
` set -l files`,
|
|
49
|
+
` for arg in $argv`,
|
|
50
|
+
` if not string match -q -- '-*' $arg`,
|
|
51
|
+
` set files $files $arg`,
|
|
52
|
+
` end`,
|
|
53
|
+
` end`,
|
|
54
|
+
` set -l existing`,
|
|
55
|
+
` for f in $files`,
|
|
56
|
+
` if test -e $f; or test -L $f`,
|
|
57
|
+
` set existing $existing $f`,
|
|
58
|
+
` end`,
|
|
59
|
+
` end`,
|
|
60
|
+
` if test (count $existing) -gt 0`,
|
|
61
|
+
` ${cmd} $existing`,
|
|
62
|
+
` end`,
|
|
63
|
+
`end`,
|
|
64
|
+
END_MARKER,
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
if (shell === 'powershell') {
|
|
68
|
+
if (platform === 'win32') {
|
|
69
|
+
return [
|
|
70
|
+
START_MARKER,
|
|
71
|
+
`# v${SAFE_DELETE_BLOCK_VERSION}`,
|
|
72
|
+
`if (Get-Alias rm -ErrorAction SilentlyContinue) {`,
|
|
73
|
+
` Remove-Alias rm -Force -Scope Global`,
|
|
74
|
+
`}`,
|
|
75
|
+
`function rm {`,
|
|
76
|
+
` $files = $args | Where-Object { $_ -notlike '-*' }`,
|
|
77
|
+
` if ($files) {`,
|
|
78
|
+
` Add-Type -AssemblyName Microsoft.VisualBasic`,
|
|
79
|
+
` foreach ($f in $files) {`,
|
|
80
|
+
` $p = Resolve-Path $f -ErrorAction SilentlyContinue`,
|
|
81
|
+
` if ($p) {`,
|
|
82
|
+
` if (Test-Path $p -PathType Container) {`,
|
|
83
|
+
` [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory(`,
|
|
84
|
+
` $p, 'OnlyErrorDialogs', 'SendToRecycleBin')`,
|
|
85
|
+
` } else {`,
|
|
86
|
+
` [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(`,
|
|
87
|
+
` $p, 'OnlyErrorDialogs', 'SendToRecycleBin')`,
|
|
88
|
+
` }`,
|
|
89
|
+
` }`,
|
|
90
|
+
` }`,
|
|
91
|
+
` }`,
|
|
92
|
+
`}`,
|
|
93
|
+
END_MARKER,
|
|
94
|
+
].join('\n');
|
|
95
|
+
}
|
|
96
|
+
// macOS/Linux PowerShell
|
|
97
|
+
const cmd = trashCommand ?? 'trash';
|
|
98
|
+
return [
|
|
99
|
+
START_MARKER,
|
|
100
|
+
`# v${SAFE_DELETE_BLOCK_VERSION}`,
|
|
101
|
+
`if (Get-Alias rm -ErrorAction SilentlyContinue) {`,
|
|
102
|
+
` Remove-Alias rm -Force -Scope Global`,
|
|
103
|
+
`}`,
|
|
104
|
+
`function rm {`,
|
|
105
|
+
` $files = $args | Where-Object { $_ -notlike '-*' }`,
|
|
106
|
+
` $existing = $files | Where-Object { Test-Path $_ }`,
|
|
107
|
+
` if ($existing) { & ${cmd} @existing }`,
|
|
108
|
+
`}`,
|
|
109
|
+
END_MARKER,
|
|
110
|
+
].join('\n');
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if the safe-delete block is already installed in a profile file.
|
|
116
|
+
*/
|
|
117
|
+
export async function isAlreadyInstalled(profilePath) {
|
|
118
|
+
try {
|
|
119
|
+
const content = await fs.readFile(profilePath, 'utf-8');
|
|
120
|
+
return content.includes(START_MARKER) && content.includes(END_MARKER);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Append the safe-delete block to a profile file.
|
|
128
|
+
* Creates parent directories and the file if they don't exist.
|
|
129
|
+
*/
|
|
130
|
+
export async function installToProfile(profilePath, block) {
|
|
131
|
+
await fs.mkdir(path.dirname(profilePath), { recursive: true });
|
|
132
|
+
let existing = '';
|
|
133
|
+
try {
|
|
134
|
+
existing = await fs.readFile(profilePath, 'utf-8');
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// File doesn't exist yet — will be created
|
|
138
|
+
}
|
|
139
|
+
const separator = existing.length > 0 && !existing.endsWith('\n') ? '\n\n' : '\n';
|
|
140
|
+
const content = existing.length > 0 ? existing + separator + block + '\n' : block + '\n';
|
|
141
|
+
await fs.writeFile(profilePath, content, 'utf-8');
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Extract the installed safe-delete block version from a profile file.
|
|
145
|
+
* Returns 0 (not installed), 1 (legacy block without version stamp), or N (versioned block).
|
|
146
|
+
*/
|
|
147
|
+
export async function getInstalledVersion(profilePath) {
|
|
148
|
+
try {
|
|
149
|
+
const content = await fs.readFile(profilePath, 'utf-8');
|
|
150
|
+
const startIdx = content.indexOf(START_MARKER);
|
|
151
|
+
if (startIdx === -1)
|
|
152
|
+
return 0;
|
|
153
|
+
const afterMarker = content.slice(startIdx + START_MARKER.length);
|
|
154
|
+
const match = afterMarker.match(/^\n# v(\d+)/);
|
|
155
|
+
return match ? parseInt(match[1], 10) : 1;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Remove the safe-delete block from a profile file.
|
|
163
|
+
* Returns true if the block was found and removed, false otherwise.
|
|
164
|
+
* For fish function files, deletes the file if it becomes empty.
|
|
165
|
+
*/
|
|
166
|
+
export async function removeFromProfile(profilePath) {
|
|
167
|
+
let content;
|
|
168
|
+
try {
|
|
169
|
+
content = await fs.readFile(profilePath, 'utf-8');
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
const startIdx = content.indexOf(START_MARKER);
|
|
175
|
+
const endIdx = content.indexOf(END_MARKER);
|
|
176
|
+
if (startIdx === -1 || endIdx === -1)
|
|
177
|
+
return false;
|
|
178
|
+
const before = content.slice(0, startIdx);
|
|
179
|
+
const after = content.slice(endIdx + END_MARKER.length);
|
|
180
|
+
// Clean up surrounding whitespace
|
|
181
|
+
const cleaned = (before.trimEnd() + after.trimStart()).trim();
|
|
182
|
+
if (cleaned.length === 0) {
|
|
183
|
+
// File is empty after removal — delete it (fish function files)
|
|
184
|
+
await fs.unlink(profilePath);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
await fs.writeFile(profilePath, cleaned + '\n', 'utf-8');
|
|
188
|
+
}
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=safe-delete-install.js.map
|