devflow-kit 1.8.3 → 2.0.1
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 +182 -7
- 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 +14 -4
- 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,725 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/assets/scripts/hooks/json-helper.cjs
|
|
4
|
+
// Provides jq-equivalent operations for hooks when jq is not installed.
|
|
5
|
+
// SECURITY: This is a local CLI helper invoked only by shell hooks with controlled arguments.
|
|
6
|
+
// File path arguments come from hook-owned variables, not from external/untrusted input.
|
|
7
|
+
// Usage: node json-helper.cjs <operation> [args...]
|
|
8
|
+
//
|
|
9
|
+
// Operations:
|
|
10
|
+
// get-field <field> [default] Read field from stdin JSON
|
|
11
|
+
// get-field-file <file> <field> [def] Read field from JSON file
|
|
12
|
+
// validate Exit 0 if stdin is valid JSON, 1 otherwise
|
|
13
|
+
// compact Compact stdin JSON to single line
|
|
14
|
+
// construct <json-template> [--arg k v] Build JSON object with args
|
|
15
|
+
// update-field <field> <value> [--json] Set field on stdin JSON (--json parses value)
|
|
16
|
+
// update-fields <json-patches> Apply multiple field updates from stdin JSON
|
|
17
|
+
// extract-cwd-field <field> Extract cwd + arbitrary field, SOH-byte delimited
|
|
18
|
+
// extract-text-messages Extract text content from Claude message format
|
|
19
|
+
// merge-evidence Flatten, dedupe, limit to 10 from stdin JSON
|
|
20
|
+
// slurp-sort <file> <field> [limit] Read JSONL, sort by field desc, limit results
|
|
21
|
+
// slurp-cap <file> <field> <limit> Read JSONL, sort by field desc, output limit lines
|
|
22
|
+
// array-length <path> Get length of array at dotted path in stdin JSON
|
|
23
|
+
// array-item <path> <index> Get item at index from array at path in stdin JSON
|
|
24
|
+
// session-output <context> Build SessionStart output envelope
|
|
25
|
+
// prompt-output <context> Build UserPromptSubmit output envelope
|
|
26
|
+
// backup-construct Build pre-compact backup JSON from --arg pairs
|
|
27
|
+
// assign-anchor <type> <obs_id> Claim next ADR/PF number, render both .md files
|
|
28
|
+
// retire-anchor <anchor_id> <status> Flip ledger row status, re-render both .md files
|
|
29
|
+
// rotate-observations [<log>] [<arch>] Archive observing rows older than 30 days
|
|
30
|
+
|
|
31
|
+
'use strict';
|
|
32
|
+
|
|
33
|
+
const fs = require('fs');
|
|
34
|
+
const path = require('path');
|
|
35
|
+
|
|
36
|
+
const op = process.argv[2];
|
|
37
|
+
const args = process.argv.slice(3);
|
|
38
|
+
|
|
39
|
+
const { safePath } = require('./lib/safe-path.cjs');
|
|
40
|
+
const {
|
|
41
|
+
getDecisionsUsagePath,
|
|
42
|
+
getDecisionsLockDir,
|
|
43
|
+
getDecisionsLedgerPath,
|
|
44
|
+
getDecisionsLogPath,
|
|
45
|
+
getDecisionsArchivePath,
|
|
46
|
+
getObservationsLockDir,
|
|
47
|
+
} = require('./lib/project-paths.cjs');
|
|
48
|
+
const {
|
|
49
|
+
initDecisionsContent,
|
|
50
|
+
toLedgerRow,
|
|
51
|
+
} = require('./lib/decisions-format.cjs');
|
|
52
|
+
const {
|
|
53
|
+
renderAndWriteAll,
|
|
54
|
+
parseLedger,
|
|
55
|
+
} = require('./lib/render-decisions.cjs');
|
|
56
|
+
const { acquireMkdirLock, releaseLock } = require('./lib/mkdir-lock.cjs');
|
|
57
|
+
|
|
58
|
+
function readStdin() {
|
|
59
|
+
try {
|
|
60
|
+
return fs.readFileSync('/dev/stdin', 'utf8').trim();
|
|
61
|
+
} catch {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getNestedField(obj, field) {
|
|
67
|
+
const parts = field.split('.');
|
|
68
|
+
let current = obj;
|
|
69
|
+
for (const part of parts) {
|
|
70
|
+
if (current == null || typeof current !== 'object') return undefined;
|
|
71
|
+
current = current[part];
|
|
72
|
+
}
|
|
73
|
+
return current;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function parseJsonl(file) {
|
|
77
|
+
const lines = fs.readFileSync(safePath(file), 'utf8').trim().split('\n').filter(Boolean);
|
|
78
|
+
return lines.map(l => {
|
|
79
|
+
try { return JSON.parse(l); } catch { return null; }
|
|
80
|
+
}).filter(Boolean);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Strip leading YAML frontmatter from content that the model may have included
|
|
85
|
+
* despite being told not to. Belt-and-suspenders defense against duplicate frontmatter.
|
|
86
|
+
*/
|
|
87
|
+
function stripLeadingFrontmatter(text) {
|
|
88
|
+
if (!text) return '';
|
|
89
|
+
const trimmed = text.replace(/^\s*\n/, '');
|
|
90
|
+
if (!trimmed.startsWith('---')) return text;
|
|
91
|
+
const match = trimmed.match(/^---\s*\n[\s\S]*?\n---\s*\n?/);
|
|
92
|
+
return match ? trimmed.slice(match[0].length) : text;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Write `tmp` with O_EXCL (wx flag) so the kernel rejects the open if a file or
|
|
97
|
+
* symlink already exists at that path, preventing TOCTOU symlink-follow attacks.
|
|
98
|
+
* On EEXIST (stale or attacker-placed .tmp) we unlink and retry once.
|
|
99
|
+
* @param {string} tmp - Path to the temporary file.
|
|
100
|
+
* @param {string} content - Content to write.
|
|
101
|
+
*/
|
|
102
|
+
function writeExclusive(tmp, content) {
|
|
103
|
+
try {
|
|
104
|
+
fs.writeFileSync(tmp, content, { flag: 'wx' });
|
|
105
|
+
} catch (err) {
|
|
106
|
+
if (err.code !== 'EEXIST') throw err;
|
|
107
|
+
// Stale or attacker-placed .tmp — remove it and retry once.
|
|
108
|
+
try { fs.unlinkSync(tmp); } catch { /* race — already removed */ }
|
|
109
|
+
fs.writeFileSync(tmp, content, { flag: 'wx' });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function writeJsonlAtomic(file, entries) {
|
|
114
|
+
// PID-scope the tmp name so concurrent writers from different processes
|
|
115
|
+
// never collide on the same .tmp path. mirrors fs-atomic.ts and proxy-log.ts.
|
|
116
|
+
const tmp = file + '.tmp.' + process.pid;
|
|
117
|
+
const content = entries.length > 0
|
|
118
|
+
? entries.map(e => JSON.stringify(e)).join('\n') + '\n'
|
|
119
|
+
: '';
|
|
120
|
+
writeExclusive(tmp, content);
|
|
121
|
+
fs.renameSync(tmp, file);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Atomically write a text file via a .tmp sibling and rename. */
|
|
125
|
+
function writeFileAtomic(file, content) {
|
|
126
|
+
// PID-scope the tmp name so concurrent writers from different processes
|
|
127
|
+
// never collide on the same .tmp path. mirrors fs-atomic.ts and proxy-log.ts.
|
|
128
|
+
const tmp = file + '.tmp.' + process.pid;
|
|
129
|
+
writeExclusive(tmp, content);
|
|
130
|
+
fs.renameSync(tmp, file);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Compute the next anchor ID for the given type by scanning the anchored ledger.
|
|
135
|
+
* O(anchored) — single pass. Includes ALL anchored rows (Retired, Deprecated, Superseded).
|
|
136
|
+
* ADR and PF sequences are independent.
|
|
137
|
+
*
|
|
138
|
+
* @param {object[]} ledgerRows - All rows from the ledger (from parseLedger)
|
|
139
|
+
* @param {'decision'|'pitfall'} type
|
|
140
|
+
* @returns {{ anchorId: string, nextN: string }}
|
|
141
|
+
*/
|
|
142
|
+
function nextAnchorFromLedger(ledgerRows, type) {
|
|
143
|
+
const prefix = type === 'decision' ? 'ADR' : 'PF';
|
|
144
|
+
const prefixRe = new RegExp(`^${prefix}-`);
|
|
145
|
+
let maxN = 0;
|
|
146
|
+
for (const row of ledgerRows) {
|
|
147
|
+
if (!row.anchor_id || !prefixRe.test(row.anchor_id)) continue;
|
|
148
|
+
const m = row.anchor_id.match(/(\d+)$/);
|
|
149
|
+
if (m) {
|
|
150
|
+
const n = parseInt(m[1], 10);
|
|
151
|
+
if (n > maxN) maxN = n;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const nextN = (maxN + 1).toString().padStart(3, '0');
|
|
155
|
+
return { anchorId: `${prefix}-${nextN}`, nextN };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Read .decisions-usage.json. Returns {version, entries} or empty default.
|
|
160
|
+
* @param {string} projectRoot - Path to project root (cwd)
|
|
161
|
+
* @returns {{version: number, entries: Object}}
|
|
162
|
+
*/
|
|
163
|
+
function readUsageFile(projectRoot) {
|
|
164
|
+
const filePath = getDecisionsUsagePath(projectRoot);
|
|
165
|
+
try {
|
|
166
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
167
|
+
const data = JSON.parse(raw);
|
|
168
|
+
if (data && data.version === 1 && typeof data.entries === 'object') return data;
|
|
169
|
+
} catch { /* ENOENT or malformed — return default */ }
|
|
170
|
+
return { version: 1, entries: {} };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Write .decisions-usage.json atomically.
|
|
175
|
+
* @param {string} projectRoot - Path to project root (cwd)
|
|
176
|
+
* @param {{version: number, entries: Object}} data
|
|
177
|
+
*/
|
|
178
|
+
function writeUsageFile(projectRoot, data) {
|
|
179
|
+
writeFileAtomic(getDecisionsUsagePath(projectRoot), JSON.stringify(data, null, 2) + '\n');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Register an entry in .decisions-usage.json with initial cite count.
|
|
184
|
+
* @param {string} projectRoot - Path to project root (cwd)
|
|
185
|
+
* @param {string} anchorId - e.g. 'ADR-001' or 'PF-003'
|
|
186
|
+
*/
|
|
187
|
+
function registerUsageEntry(projectRoot, anchorId) {
|
|
188
|
+
const data = readUsageFile(projectRoot);
|
|
189
|
+
if (!data.entries[anchorId]) {
|
|
190
|
+
data.entries[anchorId] = {
|
|
191
|
+
cites: 0,
|
|
192
|
+
last_cited: null,
|
|
193
|
+
created: new Date().toISOString(),
|
|
194
|
+
};
|
|
195
|
+
writeUsageFile(projectRoot, data);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Internal rotation logic for rotate-observations. Separated for testability.
|
|
201
|
+
* Moves rows where status === 'observing' AND no anchor_id AND age > 30 days
|
|
202
|
+
* from logPath to archivePath (append). Returns count of rotated rows.
|
|
203
|
+
*
|
|
204
|
+
* @param {string} logPath - Path to decisions-log.jsonl
|
|
205
|
+
* @param {string} archivePath - Path to decisions-log.archive.jsonl
|
|
206
|
+
* @param {number} nowMs - Current time as epoch ms (injectable for tests)
|
|
207
|
+
* @returns {number} count of rotated rows
|
|
208
|
+
*/
|
|
209
|
+
function rotateObservations(logPath, archivePath, nowMs) {
|
|
210
|
+
const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
211
|
+
const cutoffMs = nowMs - THIRTY_DAYS_MS;
|
|
212
|
+
|
|
213
|
+
let logEntries = [];
|
|
214
|
+
if (fs.existsSync(logPath)) {
|
|
215
|
+
logEntries = parseLedger(logPath);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const kept = [];
|
|
219
|
+
const stale = [];
|
|
220
|
+
|
|
221
|
+
for (const row of logEntries) {
|
|
222
|
+
// Only move 'observing' rows without anchor_id (unanchored)
|
|
223
|
+
if (row.status !== 'observing' || row.anchor_id) {
|
|
224
|
+
kept.push(row);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
// Check age using last_seen if present, else first_seen
|
|
228
|
+
const tsField = row.last_seen || row.first_seen;
|
|
229
|
+
if (!tsField) {
|
|
230
|
+
kept.push(row);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const rowMs = new Date(tsField).getTime();
|
|
234
|
+
if (isNaN(rowMs) || rowMs > cutoffMs) {
|
|
235
|
+
kept.push(row);
|
|
236
|
+
} else {
|
|
237
|
+
stale.push(row);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (stale.length === 0) return 0;
|
|
242
|
+
|
|
243
|
+
// D003: Dedup stale rows against the existing archive by id before appending.
|
|
244
|
+
// An interrupt-then-retry (process killed after archive write but before log
|
|
245
|
+
// rewrite) would re-classify the same rows as stale and attempt to archive
|
|
246
|
+
// them a second time. Reading existing archive IDs into a Set and filtering
|
|
247
|
+
// prevents duplicate rows in the archive. Cost is O(archive) on retry; O(1)
|
|
248
|
+
// on the normal path when the archive is absent.
|
|
249
|
+
//
|
|
250
|
+
// True append (appendFileSync) is used instead of read-entire-archive+rewrite
|
|
251
|
+
// so cost is O(stale) rather than O(archive) on the write path. The archive
|
|
252
|
+
// is gitignored/recovery-only, so an incomplete final newline on ENOENT is
|
|
253
|
+
// safe — parseLedger handles trailing-newline variance.
|
|
254
|
+
const existingArchiveIds = new Set();
|
|
255
|
+
if (fs.existsSync(archivePath)) {
|
|
256
|
+
const existingRows = parseLedger(archivePath);
|
|
257
|
+
for (const r of existingRows) {
|
|
258
|
+
if (r.id) existingArchiveIds.add(r.id);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const newStale = stale.filter(r => !existingArchiveIds.has(r.id));
|
|
263
|
+
if (newStale.length > 0) {
|
|
264
|
+
// True append — O(newStale), not O(archive)
|
|
265
|
+
const appendContent = newStale.map(r => JSON.stringify(r)).join('\n') + '\n';
|
|
266
|
+
fs.appendFileSync(archivePath, appendContent, 'utf8');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Write remaining rows back to log
|
|
270
|
+
writeJsonlAtomic(logPath, kept);
|
|
271
|
+
|
|
272
|
+
return stale.length;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function parseArgs(argList) {
|
|
276
|
+
const result = {};
|
|
277
|
+
const jsonArgs = {};
|
|
278
|
+
for (let i = 0; i < argList.length; i++) {
|
|
279
|
+
if (argList[i] === '--arg' && i + 2 < argList.length) {
|
|
280
|
+
result[argList[i + 1]] = argList[i + 2];
|
|
281
|
+
i += 2;
|
|
282
|
+
} else if (argList[i] === '--argjson' && i + 2 < argList.length) {
|
|
283
|
+
try {
|
|
284
|
+
jsonArgs[argList[i + 1]] = JSON.parse(argList[i + 2]);
|
|
285
|
+
} catch {
|
|
286
|
+
jsonArgs[argList[i + 1]] = argList[i + 2];
|
|
287
|
+
}
|
|
288
|
+
i += 2;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { ...result, ...jsonArgs };
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (require.main === module) {
|
|
295
|
+
try {
|
|
296
|
+
switch (op) {
|
|
297
|
+
case 'get-field': {
|
|
298
|
+
const input = JSON.parse(readStdin());
|
|
299
|
+
const field = args[0];
|
|
300
|
+
const def = args[1] || '';
|
|
301
|
+
const val = getNestedField(input, field);
|
|
302
|
+
console.log(val != null ? String(val) : def);
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
case 'get-field-file': {
|
|
307
|
+
const file = safePath(args[0]);
|
|
308
|
+
const field = args[1];
|
|
309
|
+
const def = args[2] || '';
|
|
310
|
+
const content = fs.readFileSync(file, 'utf8').trim();
|
|
311
|
+
const input = JSON.parse(content);
|
|
312
|
+
const val = getNestedField(input, field);
|
|
313
|
+
console.log(val != null ? String(val) : def);
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
case 'validate': {
|
|
318
|
+
try {
|
|
319
|
+
const text = readStdin();
|
|
320
|
+
if (!text) process.exit(1);
|
|
321
|
+
JSON.parse(text);
|
|
322
|
+
process.exit(0);
|
|
323
|
+
} catch {
|
|
324
|
+
process.exit(1);
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
case 'compact': {
|
|
330
|
+
const input = JSON.parse(readStdin());
|
|
331
|
+
console.log(JSON.stringify(input));
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
case 'construct': {
|
|
336
|
+
// Build JSON from --arg/--argjson pairs
|
|
337
|
+
const template = parseArgs(args);
|
|
338
|
+
console.log(JSON.stringify(template));
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
case 'update-field': {
|
|
343
|
+
const input = JSON.parse(readStdin());
|
|
344
|
+
const field = args[0];
|
|
345
|
+
const value = args[1];
|
|
346
|
+
const isJson = args[2] === '--json';
|
|
347
|
+
input[field] = isJson ? JSON.parse(value) : value;
|
|
348
|
+
console.log(JSON.stringify(input));
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
case 'update-fields': {
|
|
353
|
+
// Read stdin JSON, apply field updates from args: field1=val1 field2=val2
|
|
354
|
+
const input = JSON.parse(readStdin());
|
|
355
|
+
for (const arg of args) {
|
|
356
|
+
const eqIdx = arg.indexOf('=');
|
|
357
|
+
if (eqIdx > 0) {
|
|
358
|
+
const key = arg.slice(0, eqIdx);
|
|
359
|
+
const val = arg.slice(eqIdx + 1);
|
|
360
|
+
// Try to parse as JSON, fall back to string
|
|
361
|
+
try { input[key] = JSON.parse(val); } catch { input[key] = val; }
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
console.log(JSON.stringify(input));
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
case 'extract-cwd-field': {
|
|
369
|
+
// Extract cwd and an arbitrary top-level field from hook JSON in one pass.
|
|
370
|
+
// Outputs: cwd + ASCII SOH (0x01) + field value (no trailing newline).
|
|
371
|
+
// Caller splits with bash parameter expansion on $'\001' (bash 3.2 safe).
|
|
372
|
+
const field = args[0];
|
|
373
|
+
const input = JSON.parse(readStdin());
|
|
374
|
+
const cwd = input.cwd || '';
|
|
375
|
+
const value = (field && input[field]) || '';
|
|
376
|
+
process.stdout.write(cwd + '\x01' + value);
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
case 'extract-text-messages': {
|
|
381
|
+
const input = JSON.parse(readStdin());
|
|
382
|
+
const content = input?.message?.content;
|
|
383
|
+
if (typeof content === 'string') {
|
|
384
|
+
console.log(content);
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
if (!Array.isArray(content)) {
|
|
388
|
+
console.log('');
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
const texts = content
|
|
392
|
+
.filter(c => c.type === 'text')
|
|
393
|
+
.map(c => c.text);
|
|
394
|
+
console.log(texts.join('\n'));
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
case 'merge-evidence': {
|
|
399
|
+
const input = JSON.parse(readStdin());
|
|
400
|
+
// input is [[old_evidence], [new_evidence]] — flatten, dedupe, limit
|
|
401
|
+
const flat = input.flat();
|
|
402
|
+
const unique = [...new Set(flat)];
|
|
403
|
+
console.log(JSON.stringify(unique.slice(0, 10)));
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
case 'slurp-sort': {
|
|
408
|
+
const file = args[0];
|
|
409
|
+
const field = args[1];
|
|
410
|
+
const limit = parseInt(args[2]) || 30;
|
|
411
|
+
const parsed = parseJsonl(file);
|
|
412
|
+
parsed.sort((a, b) => (b[field] || 0) - (a[field] || 0));
|
|
413
|
+
console.log(JSON.stringify(parsed.slice(0, limit)));
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
case 'slurp-cap': {
|
|
418
|
+
// Read JSONL, sort by field desc, output top N as JSONL (one per line)
|
|
419
|
+
const file = args[0];
|
|
420
|
+
const field = args[1];
|
|
421
|
+
const limit = parseInt(args[2]) || 100;
|
|
422
|
+
const parsed = parseJsonl(file);
|
|
423
|
+
parsed.sort((a, b) => (b[field] || 0) - (a[field] || 0));
|
|
424
|
+
for (const item of parsed.slice(0, limit)) {
|
|
425
|
+
console.log(JSON.stringify(item));
|
|
426
|
+
}
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
case 'array-length': {
|
|
431
|
+
const input = JSON.parse(readStdin());
|
|
432
|
+
const dotPath = args[0];
|
|
433
|
+
const arr = getNestedField(input, dotPath);
|
|
434
|
+
console.log(Array.isArray(arr) ? arr.length : 0);
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
case 'array-item': {
|
|
439
|
+
const input = JSON.parse(readStdin());
|
|
440
|
+
const dotPath = args[0];
|
|
441
|
+
const index = parseInt(args[1]);
|
|
442
|
+
const arr = getNestedField(input, dotPath);
|
|
443
|
+
if (Array.isArray(arr) && index >= 0 && index < arr.length) {
|
|
444
|
+
console.log(JSON.stringify(arr[index]));
|
|
445
|
+
} else {
|
|
446
|
+
console.log('null');
|
|
447
|
+
}
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
case 'session-output': {
|
|
452
|
+
const ctx = args[0];
|
|
453
|
+
console.log(JSON.stringify({
|
|
454
|
+
hookSpecificOutput: {
|
|
455
|
+
hookEventName: 'SessionStart',
|
|
456
|
+
additionalContext: ctx,
|
|
457
|
+
},
|
|
458
|
+
}));
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
case 'prompt-output': {
|
|
463
|
+
const ctx = args[0];
|
|
464
|
+
console.log(JSON.stringify({
|
|
465
|
+
hookSpecificOutput: {
|
|
466
|
+
hookEventName: 'UserPromptSubmit',
|
|
467
|
+
additionalContext: ctx,
|
|
468
|
+
},
|
|
469
|
+
}));
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
case 'backup-construct': {
|
|
474
|
+
const data = parseArgs(args);
|
|
475
|
+
console.log(JSON.stringify({
|
|
476
|
+
timestamp: data.ts || '',
|
|
477
|
+
trigger: 'pre-compact',
|
|
478
|
+
memory_snapshot: data.memory || '',
|
|
479
|
+
git: {
|
|
480
|
+
branch: data.branch || '',
|
|
481
|
+
status: data.status || '',
|
|
482
|
+
log: data.log || '',
|
|
483
|
+
diff_stat: data.diff || '',
|
|
484
|
+
},
|
|
485
|
+
}, null, 2));
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// -------------------------------------------------------------------------
|
|
490
|
+
// assign-anchor <type> <obs_id>
|
|
491
|
+
// AC-A2: Assign next anchor ID for the given type (decision|pitfall) to the
|
|
492
|
+
// observation identified by obs_id in decisions-log.jsonl. Atomic under a
|
|
493
|
+
// single .decisions.lock acquisition. Registers usage, re-renders both .md.
|
|
494
|
+
//
|
|
495
|
+
// Locking discipline: holds ONLY .decisions.lock (never .observations.lock).
|
|
496
|
+
// O(anchored) — single pass for max numeric suffix (AC-P2).
|
|
497
|
+
// -------------------------------------------------------------------------
|
|
498
|
+
case 'assign-anchor': {
|
|
499
|
+
const assignType = args[0]; // 'decision' or 'pitfall'
|
|
500
|
+
const assignObsId = args[1];
|
|
501
|
+
|
|
502
|
+
if (!assignType || !assignObsId) {
|
|
503
|
+
process.stderr.write('assign-anchor: usage: assign-anchor <type> <obs_id>\n');
|
|
504
|
+
process.exit(1);
|
|
505
|
+
}
|
|
506
|
+
if (assignType !== 'decision' && assignType !== 'pitfall') {
|
|
507
|
+
process.stderr.write(`assign-anchor: type must be 'decision' or 'pitfall', got '${assignType}'\n`);
|
|
508
|
+
process.exit(1);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const aaProjectRoot = process.cwd();
|
|
512
|
+
const aaLedgerPath = getDecisionsLedgerPath(aaProjectRoot);
|
|
513
|
+
const aaLogPath = getDecisionsLogPath(aaProjectRoot);
|
|
514
|
+
const aaLockDir = getDecisionsLockDir(aaProjectRoot);
|
|
515
|
+
|
|
516
|
+
fs.mkdirSync(path.dirname(aaLockDir), { recursive: true });
|
|
517
|
+
|
|
518
|
+
if (!acquireMkdirLock(aaLockDir, 30000, 60000)) {
|
|
519
|
+
process.stderr.write(`assign-anchor: timeout acquiring lock at ${aaLockDir}\n`);
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
try {
|
|
524
|
+
// Read existing ledger (absent = empty)
|
|
525
|
+
const aaLedgerRows = parseLedger(aaLedgerPath);
|
|
526
|
+
|
|
527
|
+
// Compute next anchor — O(anchored), single pass
|
|
528
|
+
const { anchorId: aaAnchorId } = nextAnchorFromLedger(aaLedgerRows, assignType);
|
|
529
|
+
|
|
530
|
+
// Read observation from log
|
|
531
|
+
let aaLogEntries = parseLedger(aaLogPath);
|
|
532
|
+
const aaObsIdx = aaLogEntries.findIndex(e => e.id === assignObsId);
|
|
533
|
+
if (aaObsIdx === -1) {
|
|
534
|
+
// throw instead of process.exit so the finally block releases the lock
|
|
535
|
+
throw new Error(`assign-anchor: obs_id '${assignObsId}' not found in ${aaLogPath}`);
|
|
536
|
+
}
|
|
537
|
+
const aaObs = aaLogEntries[aaObsIdx];
|
|
538
|
+
|
|
539
|
+
// Precondition assertions — both checked under the lock so they are
|
|
540
|
+
// race-free against concurrent assign-anchor callers (avoids silent
|
|
541
|
+
// ledger corruption; assert-preconditions per reliability rule).
|
|
542
|
+
//
|
|
543
|
+
// (a) The newly computed anchor_id must not already appear in the ledger.
|
|
544
|
+
// nextAnchorFromLedger is deterministic-monotone, so this should
|
|
545
|
+
// never fire in normal operation — it guards against double-assign
|
|
546
|
+
// bugs (e.g. assign called twice for the same obs_id in a crash loop).
|
|
547
|
+
if (aaLedgerRows.some(r => r.anchor_id === aaAnchorId)) {
|
|
548
|
+
// throw instead of process.exit so the finally block releases the lock
|
|
549
|
+
throw new Error(
|
|
550
|
+
`assign-anchor: anchor_id '${aaAnchorId}' already present in ledger — ` +
|
|
551
|
+
`possible double-assign; refusing to overwrite committed entry`
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
//
|
|
555
|
+
// (b) The target observation must not already have an anchor_id set.
|
|
556
|
+
// Re-anchoring an already-anchored obs would mint a duplicate number
|
|
557
|
+
// (the old anchor would remain in the ledger AND the new one would
|
|
558
|
+
// be added), corrupting the committed source of truth.
|
|
559
|
+
if (aaObs.anchor_id) {
|
|
560
|
+
// throw instead of process.exit so the finally block releases the lock
|
|
561
|
+
throw new Error(
|
|
562
|
+
`assign-anchor: obs_id '${assignObsId}' is already anchored as '${aaObs.anchor_id}'; ` +
|
|
563
|
+
`use retire-anchor to change its status instead`
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Build canonical committed-ledger row via toLedgerRow projector.
|
|
568
|
+
// Whitelists only the canonical fields — excludes all observation-lifecycle
|
|
569
|
+
// state (evidence, confidence, quality_ok, count, first_seen, last_seen, …)
|
|
570
|
+
// that must stay in the log only. applies ADR-008.
|
|
571
|
+
const aaDate = new Date().toISOString().slice(0, 10);
|
|
572
|
+
const aaActiveStatus = assignType === 'decision' ? 'Accepted' : 'Active';
|
|
573
|
+
// Date set on decisions only (byte-compat asymmetry — formatDecisionBody
|
|
574
|
+
// emits "- **Date**: …"; pitfall rows have no date field)
|
|
575
|
+
const aaDecisionDate = assignType === 'decision' ? (aaObs.date || aaDate) : undefined;
|
|
576
|
+
const aaLedgerRow = toLedgerRow(aaObs, {
|
|
577
|
+
anchorId: aaAnchorId,
|
|
578
|
+
status: aaActiveStatus,
|
|
579
|
+
date: aaDecisionDate,
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// Append anchored row to ledger (atomic temp+rename).
|
|
583
|
+
//
|
|
584
|
+
// D002: Crash window — if the process is killed between this write and
|
|
585
|
+
// renderAndWriteAll below, the ledger will be ahead of decisions.md /
|
|
586
|
+
// pitfalls.md. This is git-recoverable: the ledger is the source of
|
|
587
|
+
// truth and `render-decisions.cjs render <worktree>` re-renders the
|
|
588
|
+
// .md files. The render is kept as the FINAL write under the lock so
|
|
589
|
+
// the window is as narrow as possible.
|
|
590
|
+
const aaNewLedgerRows = [...aaLedgerRows, aaLedgerRow];
|
|
591
|
+
const aaLedgerContent = aaNewLedgerRows.map(r => JSON.stringify(r)).join('\n') + '\n';
|
|
592
|
+
writeFileAtomic(aaLedgerPath, aaLedgerContent);
|
|
593
|
+
|
|
594
|
+
// Mark log row as created
|
|
595
|
+
aaLogEntries[aaObsIdx] = Object.assign({}, aaObs, { status: 'created' });
|
|
596
|
+
writeJsonlAtomic(aaLogPath, aaLogEntries);
|
|
597
|
+
|
|
598
|
+
// Register usage entry
|
|
599
|
+
registerUsageEntry(aaProjectRoot, aaAnchorId);
|
|
600
|
+
|
|
601
|
+
// Re-render both .md files (lock-free — we already hold .decisions.lock).
|
|
602
|
+
// This is the FINAL write in the lock scope — see D002 above.
|
|
603
|
+
renderAndWriteAll(aaProjectRoot, aaNewLedgerRows);
|
|
604
|
+
|
|
605
|
+
// Print assigned anchor id to stdout
|
|
606
|
+
process.stdout.write(aaAnchorId + '\n');
|
|
607
|
+
} finally {
|
|
608
|
+
releaseLock(aaLockDir);
|
|
609
|
+
}
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// -------------------------------------------------------------------------
|
|
614
|
+
// retire-anchor <anchor_id> <status>
|
|
615
|
+
// AC-A3, AC-F5, AC-F7: Flip decisions_status on the ledger row. Idempotent.
|
|
616
|
+
// Re-renders both .md (retired entry vanishes from .md, stays in ledger).
|
|
617
|
+
//
|
|
618
|
+
// status must be Deprecated | Superseded | Retired.
|
|
619
|
+
// Locking discipline: holds ONLY .decisions.lock.
|
|
620
|
+
// -------------------------------------------------------------------------
|
|
621
|
+
case 'retire-anchor': {
|
|
622
|
+
const retireAnchorId = args[0];
|
|
623
|
+
const retireStatus = args[1];
|
|
624
|
+
|
|
625
|
+
const RETIRE_STATUSES = new Set(['Deprecated', 'Superseded', 'Retired']);
|
|
626
|
+
|
|
627
|
+
if (!retireAnchorId || !retireStatus) {
|
|
628
|
+
process.stderr.write('retire-anchor: usage: retire-anchor <anchor_id> <status>\n');
|
|
629
|
+
process.exit(1);
|
|
630
|
+
}
|
|
631
|
+
if (!RETIRE_STATUSES.has(retireStatus)) {
|
|
632
|
+
process.stderr.write(`retire-anchor: status must be Deprecated|Superseded|Retired, got '${retireStatus}'\n`);
|
|
633
|
+
process.exit(1);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const raProjectRoot = process.cwd();
|
|
637
|
+
const raLedgerPath = getDecisionsLedgerPath(raProjectRoot);
|
|
638
|
+
const raLockDir = getDecisionsLockDir(raProjectRoot);
|
|
639
|
+
|
|
640
|
+
fs.mkdirSync(path.dirname(raLockDir), { recursive: true });
|
|
641
|
+
|
|
642
|
+
if (!acquireMkdirLock(raLockDir, 30000, 60000)) {
|
|
643
|
+
process.stderr.write(`retire-anchor: timeout acquiring lock at ${raLockDir}\n`);
|
|
644
|
+
process.exit(1);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
try {
|
|
648
|
+
const raRows = parseLedger(raLedgerPath);
|
|
649
|
+
const raIdx = raRows.findIndex(r => r.anchor_id === retireAnchorId);
|
|
650
|
+
if (raIdx === -1) {
|
|
651
|
+
// throw instead of process.exit so the finally block releases the lock
|
|
652
|
+
throw new Error(`retire-anchor: anchor_id '${retireAnchorId}' not found in ledger`);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
// Idempotent: if already set to same status, still write (no-op equivalent)
|
|
656
|
+
raRows[raIdx] = Object.assign({}, raRows[raIdx], { decisions_status: retireStatus });
|
|
657
|
+
const raLedgerContent = raRows.map(r => JSON.stringify(r)).join('\n') + '\n';
|
|
658
|
+
writeFileAtomic(raLedgerPath, raLedgerContent);
|
|
659
|
+
|
|
660
|
+
// Re-render both .md (lock-free — we already hold .decisions.lock)
|
|
661
|
+
renderAndWriteAll(raProjectRoot, raRows);
|
|
662
|
+
} finally {
|
|
663
|
+
releaseLock(raLockDir);
|
|
664
|
+
}
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// -------------------------------------------------------------------------
|
|
669
|
+
// rotate-observations [<log>] [<archive>]
|
|
670
|
+
// AC-F9, AC-P3: Move stale observing rows (>30 days old) to archive.
|
|
671
|
+
// NEVER moves anchored or created/ready rows — only stale 'observing' rows.
|
|
672
|
+
// Runs under .observations.lock (NOT .decisions.lock).
|
|
673
|
+
//
|
|
674
|
+
// Default paths derived from cwd. Accepts explicit log/archive paths as args.
|
|
675
|
+
// For testability, _now_ is injectable via the _nowMs parameter in the
|
|
676
|
+
// internal function; CLI always uses Date.now().
|
|
677
|
+
// -------------------------------------------------------------------------
|
|
678
|
+
case 'rotate-observations': {
|
|
679
|
+
// Args may be: [] | [log] | [log, archive]
|
|
680
|
+
const roProjectRoot = process.cwd();
|
|
681
|
+
const roLogPath = args[0] ? safePath(args[0]) : getDecisionsLogPath(roProjectRoot);
|
|
682
|
+
const roArchivePath = args[1] ? safePath(args[1]) : getDecisionsArchivePath(roProjectRoot);
|
|
683
|
+
const roLockDir = getObservationsLockDir(roProjectRoot);
|
|
684
|
+
|
|
685
|
+
fs.mkdirSync(path.dirname(roLogPath), { recursive: true });
|
|
686
|
+
fs.mkdirSync(path.dirname(roArchivePath), { recursive: true });
|
|
687
|
+
fs.mkdirSync(path.dirname(roLockDir), { recursive: true });
|
|
688
|
+
|
|
689
|
+
if (!acquireMkdirLock(roLockDir, 30000, 60000)) {
|
|
690
|
+
process.stderr.write('rotate-observations: timeout acquiring .observations.lock\n');
|
|
691
|
+
process.exit(1);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
try {
|
|
695
|
+
const roRotated = rotateObservations(roLogPath, roArchivePath, Date.now());
|
|
696
|
+
process.stdout.write(`rotated ${roRotated} observing rows\n`);
|
|
697
|
+
} finally {
|
|
698
|
+
releaseLock(roLockDir);
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
default:
|
|
704
|
+
process.stderr.write(`json-helper: unknown operation "${op}"\n`);
|
|
705
|
+
process.exit(1);
|
|
706
|
+
}
|
|
707
|
+
} catch (err) {
|
|
708
|
+
process.stderr.write(`json-helper error: ${err && err.message ? err.message : String(err)}\n`);
|
|
709
|
+
process.exit(1);
|
|
710
|
+
}
|
|
711
|
+
} // end if (require.main === module)
|
|
712
|
+
|
|
713
|
+
// Expose helpers for unit testing (only when required as a module, not run as CLI)
|
|
714
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
715
|
+
module.exports = {
|
|
716
|
+
readUsageFile,
|
|
717
|
+
writeUsageFile,
|
|
718
|
+
registerUsageEntry,
|
|
719
|
+
writeFileAtomic,
|
|
720
|
+
writeJsonlAtomic,
|
|
721
|
+
initDecisionsContent,
|
|
722
|
+
nextAnchorFromLedger,
|
|
723
|
+
rotateObservations,
|
|
724
|
+
};
|
|
725
|
+
}
|