@daniellins/power-claude 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @daniellins/power-claude might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/bin/cli.js +124 -0
- package/installer/__tests__/doctor-ready-oracles.test.cjs +140 -0
- package/installer/__tests__/merge-settings.test.cjs +330 -0
- package/installer/adopt.js +161 -0
- package/installer/copy.js +203 -0
- package/installer/doctor.js +266 -0
- package/installer/install.js +155 -0
- package/installer/manifest.js +102 -0
- package/installer/motor-scripts.js +50 -0
- package/installer/motor-scripts.json +39 -0
- package/installer/uninstall.js +99 -0
- package/installer/update.js +376 -0
- package/installer/util.js +113 -0
- package/installer/wizard.js +64 -0
- package/package.json +26 -0
- package/scripts/__fixtures__/anti-path-demo/agents/ap-writer.md +13 -0
- package/scripts/__fixtures__/anti-path-demo/templates/write-tmpl.md +7 -0
- package/scripts/__fixtures__/anti-path-demo/workflows/wf-ap.smoke.json +10 -0
- package/scripts/__fixtures__/anti-path-demo/workflows/wf-ap.yaml +25 -0
- package/scripts/__fixtures__/assess-tier/retrofit-leve/pod/agents/content-chief.md +1 -0
- package/scripts/__fixtures__/assess-tier/retrofit-leve/pod/workflows/wf-criacao-redteam.yaml +3 -0
- package/scripts/__fixtures__/assess-tier/retrofit-leve/pod-spec.json +13 -0
- package/scripts/__fixtures__/fidelity/fake-green-average-in-band.yaml +21 -0
- package/scripts/__fixtures__/fidelity/fake-green-average.yaml +18 -0
- package/scripts/__fixtures__/fidelity/fake-green-denominator.yaml +19 -0
- package/scripts/__fixtures__/fidelity/fake-green-missing-evidence.yaml +18 -0
- package/scripts/__fixtures__/fidelity/fake-green-threshold.yaml +18 -0
- package/scripts/__fixtures__/fidelity/fake-green-weight.yaml +18 -0
- package/scripts/__fixtures__/fidelity/golden.yaml +31 -0
- package/scripts/__fixtures__/fidelity/trindade-incoherent.yaml +15 -0
- package/scripts/__fixtures__/forge-canonical/pod-spec-example.json +37 -0
- package/scripts/__fixtures__/migrate-squad/authored/agents/offer-engineer.md +17 -0
- package/scripts/__fixtures__/migrate-squad/authored/knowledge/no-source.md +7 -0
- package/scripts/__fixtures__/migrate-squad/authored/knowledge/value-stack-method.md +8 -0
- package/scripts/__fixtures__/migrate-squad/authored/specs/wf-sample.smoke.json +24 -0
- package/scripts/__fixtures__/migrate-squad/authored/specs/wf-sample.spec.json +45 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/HEADLINE.md +3 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/README.md +4 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/agents/hormozi-offer.md +14 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/checklists/dead-redundant.md +4 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/checklists/method-guide.md +6 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/checklists/veto-screen.md +4 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/config/config.yaml +2 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/data/case-library.md +3 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/scripts/validate-mvn.py +16 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/sops/sop-sample.md +3 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/squad-io.yaml +14 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/tasks/gather-context.md +7 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/templates/output-tmpl.md +5 -0
- package/scripts/__fixtures__/migrate-squad/legacy-squad/workflows/wf-sample.yaml +24 -0
- package/scripts/__fixtures__/pipeline/pipelines/pipeline-checkpoint.yaml +21 -0
- package/scripts/__fixtures__/pipeline/pipelines/pipeline-demo.yaml +22 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-a/agents/maker.md +13 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-a/memory/learnings.consolidated.md +8 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-a/memory/learnings.jsonl +83 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-a/templates/make-tmpl.md +8 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-a/workflows/wf-a.yaml +16 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-b/agents/user.md +13 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-b/memory/learnings.consolidated.md +8 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-b/memory/learnings.jsonl +14 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-b/templates/use-tmpl.md +6 -0
- package/scripts/__fixtures__/pipeline/pods/pipe-b/workflows/wf-b.yaml +16 -0
- package/scripts/__fixtures__/pod-run/agents/forge-chief.md +13 -0
- package/scripts/__fixtures__/pod-run/agents/pod-critic.md +13 -0
- package/scripts/__fixtures__/pod-run/templates/build-tmpl.md +8 -0
- package/scripts/__fixtures__/pod-run/templates/gate-tmpl.md +6 -0
- package/scripts/__fixtures__/pod-run/workflows/wf-min.yaml +43 -0
- package/scripts/__fixtures__/pod-run/workflows/wf-skip-modes.yaml +50 -0
- package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-all-skippable.yaml +30 -0
- package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-criteria-escalar-de-bloco.yaml +40 -0
- package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-skip-mode-desconhecido.yaml +30 -0
- package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-unknown-key.yaml +29 -0
- package/scripts/__fixtures__/pod-workflow/invalid-cycle.yaml +26 -0
- package/scripts/__fixtures__/pod-workflow/invalid-fix-loop-backedge.yaml +29 -0
- package/scripts/__fixtures__/pod-workflow/invalid-fix-loop-forward.yaml +29 -0
- package/scripts/__fixtures__/pod-workflow/invalid-handoff-open.yaml +27 -0
- package/scripts/__fixtures__/pod-workflow/invalid-knowledge-shape.yaml +18 -0
- package/scripts/__fixtures__/pod-workflow/invalid-missing-agent.yaml +15 -0
- package/scripts/__fixtures__/pod-workflow/invalid-missing-outputs.yaml +15 -0
- package/scripts/__fixtures__/pod-workflow/invalid-missing-template.yaml +15 -0
- package/scripts/__fixtures__/pod-workflow/invalid-missing-veto.yaml +13 -0
- package/scripts/__fixtures__/pod-workflow/invalid-template-not-on-disk.yaml +16 -0
- package/scripts/__fixtures__/pod-workflow/invalid-veto-prose.yaml +17 -0
- package/scripts/__fixtures__/pod-workflow/knowledge/a.md +4 -0
- package/scripts/__fixtures__/pod-workflow/knowledge/b.md +4 -0
- package/scripts/__fixtures__/pod-workflow/knowledge/c.md +4 -0
- package/scripts/__fixtures__/pod-workflow/templates/step-tmpl.md +7 -0
- package/scripts/__fixtures__/pod-workflow/valid-checkpoint-skip-modes.yaml +29 -0
- package/scripts/__fixtures__/pod-workflow/valid-fix-loop.yaml +30 -0
- package/scripts/__fixtures__/pod-workflow/valid-knowledge.yaml +30 -0
- package/scripts/__fixtures__/pod-workflow/valid-veto-always-true.yaml +20 -0
- package/scripts/__fixtures__/pod-workflow/valid.yaml +27 -0
- package/scripts/__fixtures__/smoke-canary/agents/canary-reporter.md +13 -0
- package/scripts/__fixtures__/smoke-canary/agents/canary-researcher.md +13 -0
- package/scripts/__fixtures__/smoke-canary/agents/canary-synth.md +13 -0
- package/scripts/__fixtures__/smoke-canary/memory/learnings.consolidated.md +10 -0
- package/scripts/__fixtures__/smoke-canary/memory/learnings.jsonl +448 -0
- package/scripts/__fixtures__/smoke-canary/templates/report-tmpl.md +9 -0
- package/scripts/__fixtures__/smoke-canary/templates/research-tmpl.md +7 -0
- package/scripts/__fixtures__/smoke-canary/templates/synth-tmpl.md +9 -0
- package/scripts/__fixtures__/smoke-canary/workflows/wf-canary.smoke.json +11 -0
- package/scripts/__fixtures__/smoke-canary/workflows/wf-canary.yaml +53 -0
- package/scripts/__fixtures__/source-audit/fake-green-bronze-unsignaled.yaml +10 -0
- package/scripts/__fixtures__/source-audit/fake-green-counts.yaml +9 -0
- package/scripts/__fixtures__/source-audit/fake-green-missing-evidence.yaml +9 -0
- package/scripts/__fixtures__/source-audit/fake-green-unclassified.yaml +10 -0
- package/scripts/__fixtures__/source-audit/fake-green-verdict.yaml +10 -0
- package/scripts/__fixtures__/source-audit/golden-blocked.yaml +10 -0
- package/scripts/__fixtures__/source-audit/golden.yaml +11 -0
- package/scripts/__fixtures__/sweep-forms/agents/forms-count.md +13 -0
- package/scripts/__fixtures__/sweep-forms/agents/forms-field.md +13 -0
- package/scripts/__fixtures__/sweep-forms/agents/forms-fileref.md +13 -0
- package/scripts/__fixtures__/sweep-forms/agents/forms-json.md +13 -0
- package/scripts/__fixtures__/sweep-forms/agents/forms-section.md +13 -0
- package/scripts/__fixtures__/sweep-forms/specs/wf-forms.spec.json +5 -0
- package/scripts/__fixtures__/sweep-forms/templates/t_count.md +5 -0
- package/scripts/__fixtures__/sweep-forms/templates/t_field.md +3 -0
- package/scripts/__fixtures__/sweep-forms/templates/t_fileref.md +3 -0
- package/scripts/__fixtures__/sweep-forms/templates/t_json.md +0 -0
- package/scripts/__fixtures__/sweep-forms/templates/t_section.md +3 -0
- package/scripts/__fixtures__/sweep-forms/workflows/wf-forms.smoke.json +13 -0
- package/scripts/__fixtures__/sweep-forms/workflows/wf-forms.yaml +67 -0
- package/scripts/__fixtures__/validate-story-acs-corpus/corpus-1-noop-state-json.fixture.md +18 -0
- package/scripts/__fixtures__/validate-story-acs-corpus/corpus-2-crash-buildworkflowyaml.fixture.md +26 -0
- package/scripts/__fixtures__/validate-story-acs-corpus/corpus-3-nasce-verde-skip-modes.fixture.md +29 -0
- package/scripts/__fixtures__/validate-story-acs-corpus/corpus-4-guarda-sem-irmao.fixture.md +17 -0
- package/scripts/__fixtures__/validate-story-acs-corpus/corpus-5a-diff-stat-sem-guarda.fixture.md +17 -0
- package/scripts/__fixtures__/validate-story-acs-corpus/corpus-5b-test-f-sobre-diretorio.fixture.md +20 -0
- package/scripts/__fixtures__/veto-checks/copy-clean.md +4 -0
- package/scripts/__fixtures__/veto-checks/copy-dashes.md +4 -0
- package/scripts/__fixtures__/veto-checks/n8n-bad.md +18 -0
- package/scripts/__fixtures__/veto-checks/n8n-ok.md +22 -0
- package/scripts/__fixtures__/veto-checks/page-bad.html +7 -0
- package/scripts/__fixtures__/veto-checks/phash/copy.png +0 -0
- package/scripts/__fixtures__/veto-checks/phash/distinct.png +0 -0
- package/scripts/__fixtures__/veto-checks/phash/distinct2.png +0 -0
- package/scripts/__fixtures__/veto-checks/phash/make-fixtures.cjs +203 -0
- package/scripts/__fixtures__/veto-checks/phash/ref.png +0 -0
- package/scripts/__fixtures__/veto-checks/slide-ok.html +15 -0
- package/scripts/__fixtures__/veto-checks/slide-overflow.html +14 -0
- package/scripts/__fixtures__/veto-checks/sweep-pod/agents/vc-checker.md +13 -0
- package/scripts/__fixtures__/veto-checks/sweep-pod/templates/check-tmpl.md +6 -0
- package/scripts/__fixtures__/veto-checks/sweep-pod/workflows/wf-vc.smoke.json +10 -0
- package/scripts/__fixtures__/veto-checks/sweep-pod/workflows/wf-vc.yaml +19 -0
- package/scripts/__fixtures__/voz-do-dono/README.md +23 -0
- package/scripts/__fixtures__/voz-do-dono/dono-escalar.yaml +9 -0
- package/scripts/__fixtures__/voz-do-dono/dono-guia.yaml +10 -0
- package/scripts/__fixtures__/voz-do-dono/peca-3a-pessoa.md +6 -0
- package/scripts/__fixtures__/voz-do-dono/peca-com-lexico-proibido.md +6 -0
- package/scripts/__fixtures__/voz-do-dono/peca-limpa-1a-pessoa.md +6 -0
- package/scripts/__tests__/derive-ready-transitions.test.cjs +269 -0
- package/scripts/__tests__/enforce-cycle-authority.test.cjs +869 -0
- package/scripts/__tests__/enforce-git-push-authority.test.cjs +701 -0
- package/scripts/__tests__/enforce-ready-oracles.test.cjs +745 -0
- package/scripts/__tests__/motor-scripts.test.cjs +339 -0
- package/scripts/__tests__/pc-run-pod-counter.test.cjs +58 -0
- package/scripts/__tests__/pc-run-pod.test.cjs +578 -0
- package/scripts/__tests__/validate-pod-workflow.test.cjs +90 -0
- package/scripts/__tests__/validate-story-acs.test.cjs +607 -0
- package/scripts/anti-path.test.cjs +163 -0
- package/scripts/arena.cjs +514 -0
- package/scripts/arena.test.cjs +213 -0
- package/scripts/brief-leitura-obrigatoria.test.cjs +364 -0
- package/scripts/consolidate-knowledge-runner.test.cjs +249 -0
- package/scripts/default-funcional.test.cjs +153 -0
- package/scripts/derive-ready-transitions.cjs +325 -0
- package/scripts/forge-additive.test.cjs +158 -0
- package/scripts/forge-assess-tier.cjs +205 -0
- package/scripts/forge-assess-tier.test.cjs +114 -0
- package/scripts/forge-canonical.test.cjs +624 -0
- package/scripts/forge-generate.cjs +1303 -0
- package/scripts/forge-harden-learning.cjs +921 -0
- package/scripts/forge-harden-learning.test.cjs +242 -0
- package/scripts/forge-ingest-memory.cjs +136 -0
- package/scripts/forge-upgrade-pod.cjs +368 -0
- package/scripts/forge.test.cjs +609 -0
- package/scripts/harden-knowledge.test.cjs +612 -0
- package/scripts/harness-g5-lite.cjs +243 -0
- package/scripts/harness-g5-lite.test.cjs +134 -0
- package/scripts/hn-carousel-contrato-entrada.test.cjs +96 -0
- package/scripts/migrate-squad-orchestration.test.cjs +146 -0
- package/scripts/migration-manifest-sf3.2.test.cjs +382 -0
- package/scripts/migration-manifest-sf3.3.test.cjs +170 -0
- package/scripts/migration-manifest-sf5.5.test.cjs +189 -0
- package/scripts/migration-manifest.cjs +1146 -0
- package/scripts/migration-manifest.test.cjs +186 -0
- package/scripts/npm-scope-invocation.test.cjs +194 -0
- package/scripts/owner-layer.cjs +442 -0
- package/scripts/owner-layer.test.cjs +358 -0
- package/scripts/pc-run-pipeline.cjs +289 -0
- package/scripts/pc-run-pipeline.test.cjs +256 -0
- package/scripts/pc-run-pod-countgte.test.cjs +66 -0
- package/scripts/pc-run-pod.cjs +1355 -0
- package/scripts/phash-gate.test.cjs +433 -0
- package/scripts/pod-export-compile.cjs +487 -0
- package/scripts/pod-export-compile.test.cjs +312 -0
- package/scripts/pod-export-executor.cjs +678 -0
- package/scripts/pod-export-executor.test.cjs +1341 -0
- package/scripts/pod-export-hardening.test.cjs +531 -0
- package/scripts/pod-export-postprocess.cjs +427 -0
- package/scripts/pod-export-postprocess.test.cjs +558 -0
- package/scripts/pod-export-queue-race.test.cjs +865 -0
- package/scripts/pod-export-release.cjs +473 -0
- package/scripts/pod-export-release.test.cjs +267 -0
- package/scripts/pod-export-service.cjs +1297 -0
- package/scripts/pod-export-service.test.cjs +489 -0
- package/scripts/pod-export-tools.cjs +470 -0
- package/scripts/pod-export-ui.cjs +805 -0
- package/scripts/pod-export-ui.test.cjs +301 -0
- package/scripts/pod-memory-budget.test.cjs +309 -0
- package/scripts/pod-memory-note.cjs +357 -0
- package/scripts/pod-memory-note.test.cjs +452 -0
- package/scripts/pod-memory.cjs +1252 -0
- package/scripts/pod-memory.test.cjs +951 -0
- package/scripts/render-png.test.cjs +307 -0
- package/scripts/smoke-isolation.test.cjs +100 -0
- package/scripts/smoke-pod-workflow.cjs +755 -0
- package/scripts/smoke-sweep.test.cjs +170 -0
- package/scripts/validate-adopt.js +235 -0
- package/scripts/validate-branding.js +84 -0
- package/scripts/validate-budgets.js +140 -0
- package/scripts/validate-fidelity-output.cjs +267 -0
- package/scripts/validate-fidelity-output.test.cjs +101 -0
- package/scripts/validate-install.js +230 -0
- package/scripts/validate-no-clone.cjs +220 -0
- package/scripts/validate-no-clone.test.cjs +77 -0
- package/scripts/validate-pipeline.cjs +145 -0
- package/scripts/validate-pod-workflow.cjs +878 -0
- package/scripts/validate-source-audit.cjs +170 -0
- package/scripts/validate-source-audit.test.cjs +90 -0
- package/scripts/validate-story-acs.cjs +862 -0
- package/scripts/validate-update-scope-motor.js +421 -0
- package/scripts/veto-checks/html-valid.cjs +92 -0
- package/scripts/veto-checks/lexical-check.cjs +62 -0
- package/scripts/veto-checks/phash-gate.cjs +589 -0
- package/scripts/veto-checks/render-gate.cjs +165 -0
- package/scripts/veto-checks/render-png.cjs +358 -0
- package/scripts/veto-checks.test.cjs +219 -0
- package/scripts/watcher-audit.cjs +178 -0
- package/template/.claude/CLAUDE.md +103 -0
- package/template/.claude/agents/pc-analyst.md +100 -0
- package/template/.claude/agents/pc-architect.md +32 -0
- package/template/.claude/agents/pc-dev.md +27 -0
- package/template/.claude/agents/pc-devops.md +45 -0
- package/template/.claude/agents/pc-planner.md +32 -0
- package/template/.claude/agents/pc-po.md +25 -0
- package/template/.claude/agents/pc-qa.md +25 -0
- package/template/.claude/commands/power/academy.md +9 -0
- package/template/.claude/commands/power/automation.md +9 -0
- package/template/.claude/commands/power/content-carousel.md +267 -0
- package/template/.claude/commands/power/content.md +9 -0
- package/template/.claude/commands/power/dev.md +9 -0
- package/template/.claude/commands/power/forge.md +224 -0
- package/template/.claude/commands/power/hormozi.md +221 -0
- package/template/.claude/commands/power/modo.md +57 -0
- package/template/.claude/hooks/README.md +114 -0
- package/template/.claude/hooks/context-budget.cjs +64 -0
- package/template/.claude/hooks/enforce-cycle-authority.cjs +457 -0
- package/template/.claude/hooks/enforce-git-push-authority.cjs +925 -0
- package/template/.claude/hooks/enforce-ready-oracles.cjs +502 -0
- package/template/.claude/rules/authority.md +76 -0
- package/template/.claude/rules/curadoria-de-conhecimento.md +30 -0
- package/template/.claude/rules/model-matrix.md +34 -0
- package/template/.claude/rules/orchestration.md +133 -0
- package/template/.claude/settings.json +50 -0
- package/template/.claude/skills/pc-apply-qa-fixes/SKILL.md +108 -0
- package/template/.claude/skills/pc-apply-qa-fixes/references/fix-loop.md +40 -0
- package/template/.claude/skills/pc-apply-qa-fixes/references/fix-request-template.md +70 -0
- package/template/.claude/skills/pc-arena/SKILL.md +96 -0
- package/template/.claude/skills/pc-close-story/SKILL.md +105 -0
- package/template/.claude/skills/pc-commit/SKILL.md +108 -0
- package/template/.claude/skills/pc-develop-story/SKILL.md +116 -0
- package/template/.claude/skills/pc-full-cycle/SKILL.md +150 -0
- package/template/.claude/skills/pc-pipeline/SKILL.md +63 -0
- package/template/.claude/skills/pc-pipeline/references/gate-templates.md +46 -0
- package/template/.claude/skills/pc-review-story/SKILL.md +129 -0
- package/template/.claude/skills/pc-review-story/references/false-positive-detection.md +50 -0
- package/template/.claude/skills/pc-review-story/references/nfr-assess.md +47 -0
- package/template/.claude/skills/pc-review-story/references/risk-profile.md +75 -0
- package/template/.claude/skills/pc-review-story/references/security-checklist.md +69 -0
- package/template/.claude/skills/pc-review-story/references/test-design.md +37 -0
- package/template/.claude/skills/pc-review-story/references/trace-requirements.md +46 -0
- package/template/.claude/skills/pc-run-pod/SKILL.md +123 -0
- package/template/.claude/skills/pc-validate-story/SKILL.md +114 -0
- package/template/.claude/skills/pc-wave/SKILL.md +133 -0
- package/template/.env.example +10 -0
- package/template/knowledge/analyst/brainstorming.md +40 -0
- package/template/knowledge/analyst/brief-skeleton.md +32 -0
- package/template/knowledge/analyst/competitor-skeleton.md +39 -0
- package/template/knowledge/analyst/elicitation-menu.md +49 -0
- package/template/knowledge/analyst/market-research-skeleton.md +36 -0
- package/template/knowledge/analyst/research-prompt-structure.md +48 -0
- package/template/knowledge/analyst/roi-skeleton.md +51 -0
- package/template/knowledge/voice-dna/README.md +99 -0
- package/template/knowledge/voice-dna/voice-dna.example.yaml +157 -0
- package/template/pods/README.md +64 -0
- package/template/pods/academy/README.md +37 -0
- package/template/pods/academy/agents/academy-chief.md +27 -0
- package/template/pods/academy/examples/palestra.example.md +142 -0
- package/template/pods/academy/pod-spec.json +44 -0
- package/template/pods/academy/templates/materiais-tmpl.md +17 -0
- package/template/pods/academy/templates/revisao-didatica-tmpl.md +20 -0
- package/template/pods/academy/workflows/wf-materiais-revisao.yaml +30 -0
- package/template/pods/authority-content/README.md +43 -0
- package/template/pods/authority-content/agents/content-chief.md +28 -0
- package/template/pods/authority-content/pod-spec.json +45 -0
- package/template/pods/authority-content/templates/criacao-na-voz-tmpl.md +17 -0
- package/template/pods/authority-content/templates/red-team-factual-tmpl.md +23 -0
- package/template/pods/authority-content/workflows/wf-criacao-redteam.yaml +30 -0
- package/template/pods/automation/README.md +37 -0
- package/template/pods/automation/agents/langgraph-architect.md +30 -0
- package/template/pods/automation/agents/n8n-architect.md +30 -0
- package/template/pods/automation/examples/README.md +46 -0
- package/template/pods/automation/examples/n8n-content-radar.example.json +380 -0
- package/template/pods/automation/knowledge/langgraph-patterns.md +126 -0
- package/template/pods/automation/knowledge/n8n-patterns.md +131 -0
- package/template/pods/automation/memory/README.md +16 -0
- package/template/pods/automation/memory/learnings.consolidated.md +8 -0
- package/template/pods/automation/memory/learnings.jsonl +0 -0
- package/template/pods/automation/pod-spec.json +109 -0
- package/template/pods/automation/specs/wf-langgraph-build.spec.json +107 -0
- package/template/pods/automation/squad-io.yaml +28 -0
- package/template/pods/automation/templates/lg-build-tmpl.md +17 -0
- package/template/pods/automation/templates/lg-design-tmpl.md +23 -0
- package/template/pods/automation/templates/lg-discover-tmpl.md +20 -0
- package/template/pods/automation/templates/lg-handoff-tmpl.md +20 -0
- package/template/pods/automation/templates/lg-test-tmpl.md +20 -0
- package/template/pods/automation/templates/n8n-build-tmpl.md +14 -0
- package/template/pods/automation/templates/n8n-design-tmpl.md +23 -0
- package/template/pods/automation/templates/n8n-discover-tmpl.md +20 -0
- package/template/pods/automation/templates/n8n-handoff-tmpl.md +20 -0
- package/template/pods/automation/templates/n8n-test-tmpl.md +20 -0
- package/template/pods/automation/workflows/wf-langgraph-build.smoke.json +11 -0
- package/template/pods/automation/workflows/wf-langgraph-build.yaml +64 -0
- package/template/pods/automation/workflows/wf-n8n-build.smoke.json +11 -0
- package/template/pods/automation/workflows/wf-n8n-build.yaml +65 -0
- package/template/pods/content-carousel/README.md +91 -0
- package/template/pods/content-carousel/agents/carousel-builder.md +28 -0
- package/template/pods/content-carousel/agents/carousel-visual.md +24 -0
- package/template/pods/content-carousel/agents/hn-curator.md +74 -0
- package/template/pods/content-carousel/config/heuristic-watcher-rubric.yaml +59 -0
- package/template/pods/content-carousel/knowledge/aquisicao-ancora.md +443 -0
- package/template/pods/content-carousel/knowledge/cta-brief.md +25 -0
- package/template/pods/content-carousel/knowledge/dono.example.yaml +45 -0
- package/template/pods/content-carousel/knowledge/identidade-visual-mascote.md +62 -0
- package/template/pods/content-carousel/knowledge/image-generation.md +62 -0
- package/template/pods/content-carousel/knowledge/selecao-de-ancora.md +60 -0
- package/template/pods/content-carousel/knowledge/slides-html.md +56 -0
- package/template/pods/content-carousel/memory/README.md +18 -0
- package/template/pods/content-carousel/memory/learnings.consolidated.md +6 -0
- package/template/pods/content-carousel/memory/learnings.jsonl +0 -0
- package/template/pods/content-carousel/pod-spec.json +100 -0
- package/template/pods/content-carousel/squad-io.yaml +10 -0
- package/template/pods/content-carousel/templates/assembly-tmpl.md +23 -0
- package/template/pods/content-carousel/templates/digest-tmpl.md +29 -0
- package/template/pods/content-carousel/templates/visuals-tmpl.md +20 -0
- package/template/pods/content-carousel/workflows/wf-content-carousel.smoke.json +23 -0
- package/template/pods/content-carousel/workflows/wf-content-carousel.yaml +80 -0
- package/template/pods/dev-ia/README.md +45 -0
- package/template/pods/dev-ia/agents/db-architect.md +33 -0
- package/template/pods/dev-ia/agents/ux-architect.md +29 -0
- package/template/pods/dev-ia/knowledge/db/migration-protocol.md +95 -0
- package/template/pods/dev-ia/knowledge/db/rls-patterns.md +101 -0
- package/template/pods/dev-ia/knowledge/db/schema-review-checklist.md +76 -0
- package/template/pods/dev-ia/memory/README.md +16 -0
- package/template/pods/dev-ia/memory/learnings.consolidated.md +8 -0
- package/template/pods/dev-ia/memory/learnings.jsonl +0 -0
- package/template/pods/dev-ia/pod-spec.json +34 -0
- package/template/pods/dev-ia/templates/schema-review-tmpl.md +23 -0
- package/template/pods/dev-ia/templates/ux-flow-review-tmpl.md +23 -0
- package/template/pods/dev-ia/tools/db-ops/backup-manager.sh +321 -0
- package/template/pods/dev-ia/tools/db-ops/best-practices-auditor.sh +534 -0
- package/template/pods/dev-ia/tools/db-ops/bootstrap-runner.sh +255 -0
- package/template/pods/dev-ia/tools/db-ops/data-loader.sh +616 -0
- package/template/pods/dev-ia/tools/db-ops/detect-database.sh +113 -0
- package/template/pods/dev-ia/tools/db-ops/explain-analyzer.sh +285 -0
- package/template/pods/dev-ia/tools/db-ops/health-checker.sh +323 -0
- package/template/pods/dev-ia/tools/db-ops/migration-runner.sh +308 -0
- package/template/pods/dev-ia/tools/db-ops/postgresql-schema-loader.sh +334 -0
- package/template/pods/dev-ia/tools/db-ops/query-runner.sh +171 -0
- package/template/pods/dev-ia/tools/db-ops/rls-policy-installer.sh +480 -0
- package/template/pods/dev-ia/tools/db-ops/rls-test-suite.sh +172 -0
- package/template/pods/dev-ia/tools/db-ops/schema-context-loader.sh +176 -0
- package/template/pods/hormozi-method/README.md +52 -0
- package/template/pods/hormozi-method/agents/acquisition-strategist.md +33 -0
- package/template/pods/hormozi-method/agents/conversion-copywriter.md +34 -0
- package/template/pods/hormozi-method/agents/monetization-architect.md +35 -0
- package/template/pods/hormozi-method/agents/offer-engineer.md +37 -0
- package/template/pods/hormozi-method/knowledge/core-four-leads.md +51 -0
- package/template/pods/hormozi-method/knowledge/grand-slam-offer.md +66 -0
- package/template/pods/hormozi-method/knowledge/growth-decision.md +38 -0
- package/template/pods/hormozi-method/knowledge/hooks-and-ads.md +56 -0
- package/template/pods/hormozi-method/knowledge/launch-email.md +31 -0
- package/template/pods/hormozi-method/knowledge/money-model.md +46 -0
- package/template/pods/hormozi-method/knowledge/opportunity-screening.md +44 -0
- package/template/pods/hormozi-method/knowledge/pages.md +25 -0
- package/template/pods/hormozi-method/knowledge/pos-lancamento-leads.md +56 -0
- package/template/pods/hormozi-method/knowledge/pricing.md +36 -0
- package/template/pods/hormozi-method/knowledge/retention-ltv.md +37 -0
- package/template/pods/hormozi-method/knowledge/scale-roadmap.md +35 -0
- package/template/pods/hormozi-method/knowledge/swipefiles-curados.md +44 -0
- package/template/pods/hormozi-method/knowledge/value-equation-diagnostic.md +77 -0
- package/template/pods/hormozi-method/memory/README.md +16 -0
- package/template/pods/hormozi-method/memory/learnings.consolidated.md +6 -0
- package/template/pods/hormozi-method/memory/learnings.jsonl +0 -0
- package/template/pods/hormozi-method/pod-spec.json +50 -0
- package/template/pods/hormozi-method/specs/wf-full-launch-sequence.spec.json +149 -0
- package/template/pods/hormozi-method/specs/wf-lead-magnet-pipeline.spec.json +125 -0
- package/template/pods/hormozi-method/specs/wf-money-model-design.spec.json +117 -0
- package/template/pods/hormozi-method/specs/wf-paid-ads-campaign.spec.json +132 -0
- package/template/pods/hormozi-method/specs/wf-scaling-diagnostic.spec.json +121 -0
- package/template/pods/hormozi-method/squad-io.yaml +43 -0
- package/template/pods/hormozi-method/templates/conversion-copywriter-tmpl.md +20 -0
- package/template/pods/hormozi-method/templates/launch-execucao-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/launch-fechamento-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/launch-pos-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/launch-preparacao-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/lm-copy-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/lm-distribuicao-tmpl.md +18 -0
- package/template/pods/hormozi-method/templates/lm-estrategia-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/mm-arquitetura-tmpl.md +18 -0
- package/template/pods/hormozi-method/templates/mm-copy-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/mm-diagnostico-tmpl.md +14 -0
- package/template/pods/hormozi-method/templates/monetization-architect-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/offer-engineer-tmpl.md +20 -0
- package/template/pods/hormozi-method/templates/paid-criativos-tmpl.md +19 -0
- package/template/pods/hormozi-method/templates/paid-fundacao-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/paid-teste-escala-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/scaling-diagnostico-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/scaling-priorizacao-tmpl.md +17 -0
- package/template/pods/hormozi-method/templates/scaling-roadmap-tmpl.md +17 -0
- package/template/pods/hormozi-method/workflows/wf-full-launch-sequence.smoke.json +12 -0
- package/template/pods/hormozi-method/workflows/wf-full-launch-sequence.yaml +56 -0
- package/template/pods/hormozi-method/workflows/wf-grand-slam-offer.smoke.json +11 -0
- package/template/pods/hormozi-method/workflows/wf-grand-slam-offer.yaml +45 -0
- package/template/pods/hormozi-method/workflows/wf-lead-magnet-pipeline.smoke.json +9 -0
- package/template/pods/hormozi-method/workflows/wf-lead-magnet-pipeline.yaml +45 -0
- package/template/pods/hormozi-method/workflows/wf-money-model-design.smoke.json +11 -0
- package/template/pods/hormozi-method/workflows/wf-money-model-design.yaml +45 -0
- package/template/pods/hormozi-method/workflows/wf-paid-ads-campaign.smoke.json +9 -0
- package/template/pods/hormozi-method/workflows/wf-paid-ads-campaign.yaml +46 -0
- package/template/pods/hormozi-method/workflows/wf-scaling-diagnostic.smoke.json +11 -0
- package/template/pods/hormozi-method/workflows/wf-scaling-diagnostic.yaml +44 -0
- package/template/pods/squad-forge/README.md +53 -0
- package/template/pods/squad-forge/agents/forge-chief.md +31 -0
- package/template/pods/squad-forge/agents/mind-extractor.md +29 -0
- package/template/pods/squad-forge/agents/pod-critic.md +26 -0
- package/template/pods/squad-forge/config/heuristic-watcher-rubric.yaml +74 -0
- package/template/pods/squad-forge/knowledge/fidelity-rubric.yaml +176 -0
- package/template/pods/squad-forge/knowledge/g6-memory-check.md +17 -0
- package/template/pods/squad-forge/knowledge/memory-ingest.md +16 -0
- package/template/pods/squad-forge/knowledge/source-audit-rubric.yaml +60 -0
- package/template/pods/squad-forge/memory/README.md +16 -0
- package/template/pods/squad-forge/memory/learnings.consolidated.md +8 -0
- package/template/pods/squad-forge/memory/learnings.jsonl +0 -0
- package/template/pods/squad-forge/pod-spec.json +166 -0
- package/template/pods/squad-forge/squad-io.yaml +13 -0
- package/template/pods/squad-forge/tasks/pipeline.md +158 -0
- package/template/pods/squad-forge/templates/discovery-tmpl.md +40 -0
- package/template/pods/squad-forge/templates/generation-tmpl.md +18 -0
- package/template/pods/squad-forge/templates/red-team-tmpl.md +17 -0
- package/template/pods/squad-forge/templates/register-tmpl.md +17 -0
- package/template/pods/squad-forge/templates/workflow-tmpl.yaml +101 -0
- package/template/pods/squad-forge/workflows/wf-forge.smoke.json +12 -0
- package/template/pods/squad-forge/workflows/wf-forge.yaml +60 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Database Detection and Connection Script
|
|
3
|
+
# Detects PostgreSQL/Supabase connections for db-ops activation
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
# Color codes for output
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m' # No Color
|
|
13
|
+
|
|
14
|
+
# Detection result file
|
|
15
|
+
DETECTION_RESULT="/tmp/db_detection_$$.json"
|
|
16
|
+
|
|
17
|
+
# Function to detect database connections
|
|
18
|
+
detect_database() {
|
|
19
|
+
local db_type="none"
|
|
20
|
+
local db_url=""
|
|
21
|
+
local db_name=""
|
|
22
|
+
|
|
23
|
+
if [ -n "${SUPABASE_DB_URL:-}" ]; then
|
|
24
|
+
db_type="postgresql"
|
|
25
|
+
db_url="$SUPABASE_DB_URL"
|
|
26
|
+
db_name="supabase"
|
|
27
|
+
echo -e "${GREEN}✓${NC} Found SUPABASE_DB_URL (PostgreSQL/Supabase)"
|
|
28
|
+
|
|
29
|
+
elif [ -n "${DATABASE_URL:-}" ]; then
|
|
30
|
+
db_type="postgresql"
|
|
31
|
+
db_url="$DATABASE_URL"
|
|
32
|
+
db_name="postgresql"
|
|
33
|
+
echo -e "${GREEN}✓${NC} Found DATABASE_URL (PostgreSQL)"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Write detection result to JSON file
|
|
37
|
+
cat > "$DETECTION_RESULT" <<EOF
|
|
38
|
+
{
|
|
39
|
+
"db_type": "$db_type",
|
|
40
|
+
"db_url": "$db_url",
|
|
41
|
+
"db_name": "$db_name",
|
|
42
|
+
"detected_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
43
|
+
}
|
|
44
|
+
EOF
|
|
45
|
+
|
|
46
|
+
# Return detection result
|
|
47
|
+
if [ "$db_type" = "none" ]; then
|
|
48
|
+
echo -e "${RED}✗${NC} No database connection detected"
|
|
49
|
+
echo -e "${BLUE}ℹ${NC} Please set one of the following environment variables:"
|
|
50
|
+
echo " - SUPABASE_DB_URL (for Supabase PostgreSQL)"
|
|
51
|
+
echo " - DATABASE_URL (for PostgreSQL)"
|
|
52
|
+
return 1
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
return 0
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Function to test database connection
|
|
59
|
+
test_connection() {
|
|
60
|
+
local db_type="$1"
|
|
61
|
+
local db_url="$2"
|
|
62
|
+
|
|
63
|
+
echo -e "${BLUE}ℹ${NC} Testing connection..."
|
|
64
|
+
|
|
65
|
+
case "$db_type" in
|
|
66
|
+
postgresql)
|
|
67
|
+
if psql "$db_url" -c "SELECT 1" >/dev/null 2>&1; then
|
|
68
|
+
echo -e "${GREEN}✓${NC} Connection successful"
|
|
69
|
+
return 0
|
|
70
|
+
else
|
|
71
|
+
echo -e "${RED}✗${NC} Connection failed"
|
|
72
|
+
return 1
|
|
73
|
+
fi
|
|
74
|
+
;;
|
|
75
|
+
|
|
76
|
+
*)
|
|
77
|
+
echo -e "${RED}✗${NC} Unknown database type: $db_type"
|
|
78
|
+
return 1
|
|
79
|
+
;;
|
|
80
|
+
esac
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Main execution
|
|
84
|
+
main() {
|
|
85
|
+
echo "════════════════════════════════════════════"
|
|
86
|
+
echo " Database Detection - Super Agentes Framework"
|
|
87
|
+
echo "════════════════════════════════════════════"
|
|
88
|
+
echo
|
|
89
|
+
|
|
90
|
+
# Detect database
|
|
91
|
+
if detect_database; then
|
|
92
|
+
# Read detection result
|
|
93
|
+
db_type=$(grep '"db_type"' "$DETECTION_RESULT" | cut -d'"' -f4)
|
|
94
|
+
db_url=$(grep '"db_url"' "$DETECTION_RESULT" | cut -d'"' -f4)
|
|
95
|
+
|
|
96
|
+
# Test connection
|
|
97
|
+
if test_connection "$db_type" "$db_url"; then
|
|
98
|
+
echo
|
|
99
|
+
echo -e "${GREEN}Database ready for use!${NC}"
|
|
100
|
+
echo "Detection result saved to: $DETECTION_RESULT"
|
|
101
|
+
else
|
|
102
|
+
echo
|
|
103
|
+
echo -e "${YELLOW}⚠ Database detected but connection failed${NC}"
|
|
104
|
+
echo "Please check your credentials and network connection"
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
else
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Run main function
|
|
113
|
+
main "$@"
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Explain Analyzer - Analyze query performance with automatic recommendations
|
|
3
|
+
# Economia: ~85% dos tokens vs análise manual
|
|
4
|
+
# Uso: ./explain-analyzer.sh "<query>" [--format json|text] [--buffers] [--analyze]
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
CYAN='\033[0;36m'
|
|
14
|
+
NC='\033[0m'
|
|
15
|
+
|
|
16
|
+
# Check requirements
|
|
17
|
+
DB_URL="${SUPABASE_DB_URL:-${DATABASE_URL:-}}"
|
|
18
|
+
if [ -z "$DB_URL" ]; then
|
|
19
|
+
echo -e "${RED}ERROR: SUPABASE_DB_URL or DATABASE_URL not set${NC}"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Parse arguments
|
|
24
|
+
QUERY="${1:-}"
|
|
25
|
+
FORMAT="text"
|
|
26
|
+
USE_BUFFERS=false
|
|
27
|
+
USE_ANALYZE=false
|
|
28
|
+
|
|
29
|
+
if [ -z "$QUERY" ]; then
|
|
30
|
+
echo "Usage: $0 \"<query>\" [--format json|text] [--buffers] [--analyze]"
|
|
31
|
+
echo "Example: $0 \"SELECT * FROM users WHERE user_id = 'uuid'\""
|
|
32
|
+
echo "Example: $0 \"SELECT * FROM sources JOIN fragments ON ...\" --analyze --buffers"
|
|
33
|
+
exit 1
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Parse flags
|
|
37
|
+
shift
|
|
38
|
+
while [ $# -gt 0 ]; do
|
|
39
|
+
case "$1" in
|
|
40
|
+
--format)
|
|
41
|
+
shift
|
|
42
|
+
FORMAT="$1"
|
|
43
|
+
;;
|
|
44
|
+
--buffers)
|
|
45
|
+
USE_BUFFERS=true
|
|
46
|
+
;;
|
|
47
|
+
--analyze)
|
|
48
|
+
USE_ANALYZE=true
|
|
49
|
+
;;
|
|
50
|
+
*)
|
|
51
|
+
echo "Unknown option: $1"
|
|
52
|
+
exit 1
|
|
53
|
+
;;
|
|
54
|
+
esac
|
|
55
|
+
shift || true
|
|
56
|
+
done
|
|
57
|
+
|
|
58
|
+
# Build EXPLAIN command
|
|
59
|
+
EXPLAIN_CMD="EXPLAIN "
|
|
60
|
+
if [ "$USE_ANALYZE" = true ]; then
|
|
61
|
+
EXPLAIN_CMD+="(ANALYZE true, "
|
|
62
|
+
else
|
|
63
|
+
EXPLAIN_CMD+="("
|
|
64
|
+
fi
|
|
65
|
+
if [ "$USE_BUFFERS" = true ]; then
|
|
66
|
+
EXPLAIN_CMD+="BUFFERS true, "
|
|
67
|
+
fi
|
|
68
|
+
EXPLAIN_CMD+="FORMAT JSON) "
|
|
69
|
+
|
|
70
|
+
echo "🔍 Query Performance Analyzer v1.0"
|
|
71
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
72
|
+
echo ""
|
|
73
|
+
|
|
74
|
+
# Step 1: Run EXPLAIN
|
|
75
|
+
echo -e "${BLUE}Running EXPLAIN analysis...${NC}"
|
|
76
|
+
|
|
77
|
+
EXPLAIN_RESULT=$(psql "$DB_URL" -t -A << SQL 2>/dev/null
|
|
78
|
+
${EXPLAIN_CMD}${QUERY}
|
|
79
|
+
SQL
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if [ -z "$EXPLAIN_RESULT" ]; then
|
|
83
|
+
echo -e "${RED}ERROR: Failed to analyze query${NC}"
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# Step 2: Extract metrics from JSON
|
|
88
|
+
PLAN=$(echo "$EXPLAIN_RESULT" | jq -r '.[0].Plan' 2>/dev/null)
|
|
89
|
+
|
|
90
|
+
if [ -z "$PLAN" ] || [ "$PLAN" = "null" ]; then
|
|
91
|
+
echo -e "${RED}ERROR: Could not parse EXPLAIN output${NC}"
|
|
92
|
+
echo "Raw output:"
|
|
93
|
+
echo "$EXPLAIN_RESULT"
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Extract key metrics
|
|
98
|
+
TOTAL_COST=$(echo "$PLAN" | jq -r '.["Total Cost"] // .["cost"] // 0' 2>/dev/null)
|
|
99
|
+
STARTUP_COST=$(echo "$PLAN" | jq -r '.["Startup Cost"] // .["startup_cost"] // 0' 2>/dev/null)
|
|
100
|
+
PLAN_ROWS=$(echo "$PLAN" | jq -r '.["Plan Rows"] // .["rows"] // 0' 2>/dev/null)
|
|
101
|
+
PLAN_WIDTH=$(echo "$PLAN" | jq -r '.["Plan Width"] // .["width"] // 0' 2>/dev/null)
|
|
102
|
+
NODE_TYPE=$(echo "$PLAN" | jq -r '.["Node Type"] // "Unknown"' 2>/dev/null)
|
|
103
|
+
|
|
104
|
+
# If ANALYZE was used, get actual metrics
|
|
105
|
+
if [ "$USE_ANALYZE" = true ]; then
|
|
106
|
+
ACTUAL_ROWS=$(echo "$PLAN" | jq -r '.["Actual Rows"] // 0' 2>/dev/null)
|
|
107
|
+
ACTUAL_TIME=$(echo "$PLAN" | jq -r '.["Actual Total Time"] // 0' 2>/dev/null)
|
|
108
|
+
ACTUAL_LOOPS=$(echo "$PLAN" | jq -r '.["Actual Loops"] // 1' 2>/dev/null)
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Step 3: Analyze for issues
|
|
112
|
+
echo ""
|
|
113
|
+
echo -e "${CYAN}📊 Query Metrics:${NC}"
|
|
114
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
115
|
+
echo " Node Type: $NODE_TYPE"
|
|
116
|
+
echo " Total Cost: $TOTAL_COST"
|
|
117
|
+
echo " Estimated Rows: $PLAN_ROWS"
|
|
118
|
+
|
|
119
|
+
if [ "$USE_ANALYZE" = true ]; then
|
|
120
|
+
echo " Actual Rows: $ACTUAL_ROWS"
|
|
121
|
+
echo " Execution Time: ${ACTUAL_TIME}ms"
|
|
122
|
+
|
|
123
|
+
# Check estimation accuracy
|
|
124
|
+
if [ "$PLAN_ROWS" -gt 0 ] && [ "$ACTUAL_ROWS" -gt 0 ]; then
|
|
125
|
+
ESTIMATION_RATIO=$(echo "scale=2; $ACTUAL_ROWS / $PLAN_ROWS" | bc 2>/dev/null || echo "1")
|
|
126
|
+
if (( $(echo "$ESTIMATION_RATIO > 10" | bc -l) )) || (( $(echo "$ESTIMATION_RATIO < 0.1" | bc -l) )); then
|
|
127
|
+
echo -e " ${YELLOW}⚠ Poor estimation accuracy (${ESTIMATION_RATIO}x off)${NC}"
|
|
128
|
+
fi
|
|
129
|
+
fi
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
# Step 4: Detect performance issues
|
|
133
|
+
echo ""
|
|
134
|
+
echo -e "${CYAN}🔎 Performance Analysis:${NC}"
|
|
135
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
136
|
+
|
|
137
|
+
ISSUES_FOUND=0
|
|
138
|
+
RECOMMENDATIONS=()
|
|
139
|
+
|
|
140
|
+
# Check for sequential scans on large tables
|
|
141
|
+
if echo "$EXPLAIN_RESULT" | grep -q "Seq Scan"; then
|
|
142
|
+
TABLE_NAME=$(echo "$EXPLAIN_RESULT" | jq -r '.. | select(.["Node Type"]? == "Seq Scan") | .["Relation Name"] // "unknown"' 2>/dev/null | head -1)
|
|
143
|
+
echo -e " ${YELLOW}⚠ Sequential Scan detected on: $TABLE_NAME${NC}"
|
|
144
|
+
RECOMMENDATIONS+=("Consider adding an index on frequently queried columns of $TABLE_NAME")
|
|
145
|
+
((ISSUES_FOUND++))
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
# Check for missing indexes on joins
|
|
149
|
+
if echo "$EXPLAIN_RESULT" | grep -q "Nested Loop" && [ "$TOTAL_COST" -gt 1000 ]; then
|
|
150
|
+
echo -e " ${YELLOW}⚠ Expensive Nested Loop Join detected${NC}"
|
|
151
|
+
RECOMMENDATIONS+=("Consider adding indexes on join columns")
|
|
152
|
+
((ISSUES_FOUND++))
|
|
153
|
+
fi
|
|
154
|
+
|
|
155
|
+
# Check for sorts without indexes
|
|
156
|
+
if echo "$EXPLAIN_RESULT" | grep -q "Sort" && ! echo "$EXPLAIN_RESULT" | grep -q "Index Scan"; then
|
|
157
|
+
echo -e " ${YELLOW}⚠ Sort without index detected${NC}"
|
|
158
|
+
RECOMMENDATIONS+=("Consider adding an index on ORDER BY columns")
|
|
159
|
+
((ISSUES_FOUND++))
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
# Check for high cost operations
|
|
163
|
+
if (( $(echo "$TOTAL_COST > 10000" | bc -l) )); then
|
|
164
|
+
echo -e " ${RED}⚠ Very high query cost: $TOTAL_COST${NC}"
|
|
165
|
+
RECOMMENDATIONS+=("Query may need significant optimization")
|
|
166
|
+
((ISSUES_FOUND++))
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
# Check buffer usage if available
|
|
170
|
+
if [ "$USE_BUFFERS" = true ]; then
|
|
171
|
+
SHARED_HIT=$(echo "$EXPLAIN_RESULT" | jq -r '.. | .["Shared Hit Blocks"]? // 0' | awk '{s+=$1} END {print s}')
|
|
172
|
+
SHARED_READ=$(echo "$EXPLAIN_RESULT" | jq -r '.. | .["Shared Read Blocks"]? // 0' | awk '{s+=$1} END {print s}')
|
|
173
|
+
|
|
174
|
+
if [ "$SHARED_READ" -gt 0 ] && [ "$SHARED_HIT" -gt 0 ]; then
|
|
175
|
+
HIT_RATIO=$(echo "scale=2; $SHARED_HIT / ($SHARED_HIT + $SHARED_READ) * 100" | bc 2>/dev/null || echo "0")
|
|
176
|
+
echo " Buffer Cache Hit Ratio: ${HIT_RATIO}%"
|
|
177
|
+
|
|
178
|
+
if (( $(echo "$HIT_RATIO < 90" | bc -l) )); then
|
|
179
|
+
echo -e " ${YELLOW}⚠ Low cache hit ratio${NC}"
|
|
180
|
+
RECOMMENDATIONS+=("Consider increasing shared_buffers or warming cache")
|
|
181
|
+
((ISSUES_FOUND++))
|
|
182
|
+
fi
|
|
183
|
+
fi
|
|
184
|
+
fi
|
|
185
|
+
|
|
186
|
+
if [ $ISSUES_FOUND -eq 0 ]; then
|
|
187
|
+
echo -e " ${GREEN}✓ No major performance issues detected${NC}"
|
|
188
|
+
fi
|
|
189
|
+
|
|
190
|
+
# Step 5: Index suggestions
|
|
191
|
+
echo ""
|
|
192
|
+
echo -e "${CYAN}🔧 Index Analysis:${NC}"
|
|
193
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
194
|
+
|
|
195
|
+
# Extract table names from query
|
|
196
|
+
TABLES=$(echo "$QUERY" | grep -oE 'FROM\s+(\w+)|JOIN\s+(\w+)' | awk '{print $2}' | sort -u)
|
|
197
|
+
|
|
198
|
+
if [ -n "$TABLES" ]; then
|
|
199
|
+
for TABLE in $TABLES; do
|
|
200
|
+
# Check existing indexes
|
|
201
|
+
INDEX_COUNT=$(psql "$DB_URL" -t -A -c "SELECT COUNT(*) FROM pg_indexes WHERE tablename = '$TABLE';" 2>/dev/null || echo "0")
|
|
202
|
+
echo " Table: $TABLE (${INDEX_COUNT} indexes)"
|
|
203
|
+
|
|
204
|
+
# Check if table appears in WHERE clause
|
|
205
|
+
if echo "$QUERY" | grep -q "WHERE.*$TABLE"; then
|
|
206
|
+
WHERE_COLUMNS=$(echo "$QUERY" | grep -oE "$TABLE\.\w+|WHERE\s+\w+" | grep -oE '\w+$' | sort -u)
|
|
207
|
+
if [ -n "$WHERE_COLUMNS" ]; then
|
|
208
|
+
echo " → Check indexes on WHERE columns: $WHERE_COLUMNS"
|
|
209
|
+
fi
|
|
210
|
+
fi
|
|
211
|
+
done
|
|
212
|
+
else
|
|
213
|
+
echo " Unable to extract table names from query"
|
|
214
|
+
fi
|
|
215
|
+
|
|
216
|
+
# Step 6: Generate recommendations
|
|
217
|
+
if [ ${#RECOMMENDATIONS[@]} -gt 0 ]; then
|
|
218
|
+
echo ""
|
|
219
|
+
echo -e "${CYAN}💡 Recommendations:${NC}"
|
|
220
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
221
|
+
|
|
222
|
+
i=1
|
|
223
|
+
for rec in "${RECOMMENDATIONS[@]}"; do
|
|
224
|
+
echo " $i. $rec"
|
|
225
|
+
((i++))
|
|
226
|
+
done
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
# Step 7: Generate optimization script
|
|
230
|
+
if [ $ISSUES_FOUND -gt 0 ]; then
|
|
231
|
+
OPTIMIZE_SCRIPT="/tmp/optimize_query_$(date +%Y%m%d_%H%M%S).sql"
|
|
232
|
+
|
|
233
|
+
echo "" > "$OPTIMIZE_SCRIPT"
|
|
234
|
+
echo "-- Query Optimization Suggestions" >> "$OPTIMIZE_SCRIPT"
|
|
235
|
+
echo "-- Generated: $(date)" >> "$OPTIMIZE_SCRIPT"
|
|
236
|
+
echo "" >> "$OPTIMIZE_SCRIPT"
|
|
237
|
+
echo "-- Original Query:" >> "$OPTIMIZE_SCRIPT"
|
|
238
|
+
echo "-- $QUERY" >> "$OPTIMIZE_SCRIPT"
|
|
239
|
+
echo "" >> "$OPTIMIZE_SCRIPT"
|
|
240
|
+
|
|
241
|
+
# Add index creation templates
|
|
242
|
+
for TABLE in $TABLES; do
|
|
243
|
+
echo "-- Index suggestions for $TABLE:" >> "$OPTIMIZE_SCRIPT"
|
|
244
|
+
echo "-- CREATE INDEX idx_${TABLE}_column ON $TABLE (column_name);" >> "$OPTIMIZE_SCRIPT"
|
|
245
|
+
echo "" >> "$OPTIMIZE_SCRIPT"
|
|
246
|
+
done
|
|
247
|
+
|
|
248
|
+
echo "-- Run ANALYZE after creating indexes:" >> "$OPTIMIZE_SCRIPT"
|
|
249
|
+
echo "-- ANALYZE $TABLES;" >> "$OPTIMIZE_SCRIPT"
|
|
250
|
+
|
|
251
|
+
echo ""
|
|
252
|
+
echo " Optimization script saved to: $OPTIMIZE_SCRIPT"
|
|
253
|
+
fi
|
|
254
|
+
|
|
255
|
+
# Step 8: Output full plan if requested
|
|
256
|
+
if [ "$FORMAT" = "json" ]; then
|
|
257
|
+
echo ""
|
|
258
|
+
echo -e "${CYAN}📋 Full Execution Plan (JSON):${NC}"
|
|
259
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
260
|
+
echo "$EXPLAIN_RESULT" | jq '.'
|
|
261
|
+
elif [ "$FORMAT" = "text" ] && [ $ISSUES_FOUND -gt 0 ]; then
|
|
262
|
+
echo ""
|
|
263
|
+
echo -e "${CYAN}📋 Query Plan Tree:${NC}"
|
|
264
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
265
|
+
|
|
266
|
+
# Re-run with text format for readability
|
|
267
|
+
psql "$DB_URL" << SQL 2>/dev/null | head -30
|
|
268
|
+
EXPLAIN (COSTS, FORMAT TEXT) ${QUERY};
|
|
269
|
+
SQL
|
|
270
|
+
fi
|
|
271
|
+
|
|
272
|
+
# Summary
|
|
273
|
+
echo ""
|
|
274
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
275
|
+
if [ $ISSUES_FOUND -eq 0 ]; then
|
|
276
|
+
echo -e "${GREEN}✅ Query Performance: GOOD${NC}"
|
|
277
|
+
else
|
|
278
|
+
echo -e "${YELLOW}⚠ Query Performance: NEEDS OPTIMIZATION${NC}"
|
|
279
|
+
echo ""
|
|
280
|
+
echo "Next steps:"
|
|
281
|
+
echo " 1. Review recommendations above"
|
|
282
|
+
echo " 2. Test with ANALYZE for actual metrics: $0 \"$QUERY\" --analyze"
|
|
283
|
+
echo " 3. Create missing indexes"
|
|
284
|
+
echo " 4. Re-test after optimization"
|
|
285
|
+
fi
|