@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.

Files changed (467) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/bin/cli.js +124 -0
  4. package/installer/__tests__/doctor-ready-oracles.test.cjs +140 -0
  5. package/installer/__tests__/merge-settings.test.cjs +330 -0
  6. package/installer/adopt.js +161 -0
  7. package/installer/copy.js +203 -0
  8. package/installer/doctor.js +266 -0
  9. package/installer/install.js +155 -0
  10. package/installer/manifest.js +102 -0
  11. package/installer/motor-scripts.js +50 -0
  12. package/installer/motor-scripts.json +39 -0
  13. package/installer/uninstall.js +99 -0
  14. package/installer/update.js +376 -0
  15. package/installer/util.js +113 -0
  16. package/installer/wizard.js +64 -0
  17. package/package.json +26 -0
  18. package/scripts/__fixtures__/anti-path-demo/agents/ap-writer.md +13 -0
  19. package/scripts/__fixtures__/anti-path-demo/templates/write-tmpl.md +7 -0
  20. package/scripts/__fixtures__/anti-path-demo/workflows/wf-ap.smoke.json +10 -0
  21. package/scripts/__fixtures__/anti-path-demo/workflows/wf-ap.yaml +25 -0
  22. package/scripts/__fixtures__/assess-tier/retrofit-leve/pod/agents/content-chief.md +1 -0
  23. package/scripts/__fixtures__/assess-tier/retrofit-leve/pod/workflows/wf-criacao-redteam.yaml +3 -0
  24. package/scripts/__fixtures__/assess-tier/retrofit-leve/pod-spec.json +13 -0
  25. package/scripts/__fixtures__/fidelity/fake-green-average-in-band.yaml +21 -0
  26. package/scripts/__fixtures__/fidelity/fake-green-average.yaml +18 -0
  27. package/scripts/__fixtures__/fidelity/fake-green-denominator.yaml +19 -0
  28. package/scripts/__fixtures__/fidelity/fake-green-missing-evidence.yaml +18 -0
  29. package/scripts/__fixtures__/fidelity/fake-green-threshold.yaml +18 -0
  30. package/scripts/__fixtures__/fidelity/fake-green-weight.yaml +18 -0
  31. package/scripts/__fixtures__/fidelity/golden.yaml +31 -0
  32. package/scripts/__fixtures__/fidelity/trindade-incoherent.yaml +15 -0
  33. package/scripts/__fixtures__/forge-canonical/pod-spec-example.json +37 -0
  34. package/scripts/__fixtures__/migrate-squad/authored/agents/offer-engineer.md +17 -0
  35. package/scripts/__fixtures__/migrate-squad/authored/knowledge/no-source.md +7 -0
  36. package/scripts/__fixtures__/migrate-squad/authored/knowledge/value-stack-method.md +8 -0
  37. package/scripts/__fixtures__/migrate-squad/authored/specs/wf-sample.smoke.json +24 -0
  38. package/scripts/__fixtures__/migrate-squad/authored/specs/wf-sample.spec.json +45 -0
  39. package/scripts/__fixtures__/migrate-squad/legacy-squad/HEADLINE.md +3 -0
  40. package/scripts/__fixtures__/migrate-squad/legacy-squad/README.md +4 -0
  41. package/scripts/__fixtures__/migrate-squad/legacy-squad/agents/hormozi-offer.md +14 -0
  42. package/scripts/__fixtures__/migrate-squad/legacy-squad/checklists/dead-redundant.md +4 -0
  43. package/scripts/__fixtures__/migrate-squad/legacy-squad/checklists/method-guide.md +6 -0
  44. package/scripts/__fixtures__/migrate-squad/legacy-squad/checklists/veto-screen.md +4 -0
  45. package/scripts/__fixtures__/migrate-squad/legacy-squad/config/config.yaml +2 -0
  46. package/scripts/__fixtures__/migrate-squad/legacy-squad/data/case-library.md +3 -0
  47. package/scripts/__fixtures__/migrate-squad/legacy-squad/scripts/validate-mvn.py +16 -0
  48. package/scripts/__fixtures__/migrate-squad/legacy-squad/sops/sop-sample.md +3 -0
  49. package/scripts/__fixtures__/migrate-squad/legacy-squad/squad-io.yaml +14 -0
  50. package/scripts/__fixtures__/migrate-squad/legacy-squad/tasks/gather-context.md +7 -0
  51. package/scripts/__fixtures__/migrate-squad/legacy-squad/templates/output-tmpl.md +5 -0
  52. package/scripts/__fixtures__/migrate-squad/legacy-squad/workflows/wf-sample.yaml +24 -0
  53. package/scripts/__fixtures__/pipeline/pipelines/pipeline-checkpoint.yaml +21 -0
  54. package/scripts/__fixtures__/pipeline/pipelines/pipeline-demo.yaml +22 -0
  55. package/scripts/__fixtures__/pipeline/pods/pipe-a/agents/maker.md +13 -0
  56. package/scripts/__fixtures__/pipeline/pods/pipe-a/memory/learnings.consolidated.md +8 -0
  57. package/scripts/__fixtures__/pipeline/pods/pipe-a/memory/learnings.jsonl +83 -0
  58. package/scripts/__fixtures__/pipeline/pods/pipe-a/templates/make-tmpl.md +8 -0
  59. package/scripts/__fixtures__/pipeline/pods/pipe-a/workflows/wf-a.yaml +16 -0
  60. package/scripts/__fixtures__/pipeline/pods/pipe-b/agents/user.md +13 -0
  61. package/scripts/__fixtures__/pipeline/pods/pipe-b/memory/learnings.consolidated.md +8 -0
  62. package/scripts/__fixtures__/pipeline/pods/pipe-b/memory/learnings.jsonl +14 -0
  63. package/scripts/__fixtures__/pipeline/pods/pipe-b/templates/use-tmpl.md +6 -0
  64. package/scripts/__fixtures__/pipeline/pods/pipe-b/workflows/wf-b.yaml +16 -0
  65. package/scripts/__fixtures__/pod-run/agents/forge-chief.md +13 -0
  66. package/scripts/__fixtures__/pod-run/agents/pod-critic.md +13 -0
  67. package/scripts/__fixtures__/pod-run/templates/build-tmpl.md +8 -0
  68. package/scripts/__fixtures__/pod-run/templates/gate-tmpl.md +6 -0
  69. package/scripts/__fixtures__/pod-run/workflows/wf-min.yaml +43 -0
  70. package/scripts/__fixtures__/pod-run/workflows/wf-skip-modes.yaml +50 -0
  71. package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-all-skippable.yaml +30 -0
  72. package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-criteria-escalar-de-bloco.yaml +40 -0
  73. package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-skip-mode-desconhecido.yaml +30 -0
  74. package/scripts/__fixtures__/pod-workflow/invalid-checkpoint-unknown-key.yaml +29 -0
  75. package/scripts/__fixtures__/pod-workflow/invalid-cycle.yaml +26 -0
  76. package/scripts/__fixtures__/pod-workflow/invalid-fix-loop-backedge.yaml +29 -0
  77. package/scripts/__fixtures__/pod-workflow/invalid-fix-loop-forward.yaml +29 -0
  78. package/scripts/__fixtures__/pod-workflow/invalid-handoff-open.yaml +27 -0
  79. package/scripts/__fixtures__/pod-workflow/invalid-knowledge-shape.yaml +18 -0
  80. package/scripts/__fixtures__/pod-workflow/invalid-missing-agent.yaml +15 -0
  81. package/scripts/__fixtures__/pod-workflow/invalid-missing-outputs.yaml +15 -0
  82. package/scripts/__fixtures__/pod-workflow/invalid-missing-template.yaml +15 -0
  83. package/scripts/__fixtures__/pod-workflow/invalid-missing-veto.yaml +13 -0
  84. package/scripts/__fixtures__/pod-workflow/invalid-template-not-on-disk.yaml +16 -0
  85. package/scripts/__fixtures__/pod-workflow/invalid-veto-prose.yaml +17 -0
  86. package/scripts/__fixtures__/pod-workflow/knowledge/a.md +4 -0
  87. package/scripts/__fixtures__/pod-workflow/knowledge/b.md +4 -0
  88. package/scripts/__fixtures__/pod-workflow/knowledge/c.md +4 -0
  89. package/scripts/__fixtures__/pod-workflow/templates/step-tmpl.md +7 -0
  90. package/scripts/__fixtures__/pod-workflow/valid-checkpoint-skip-modes.yaml +29 -0
  91. package/scripts/__fixtures__/pod-workflow/valid-fix-loop.yaml +30 -0
  92. package/scripts/__fixtures__/pod-workflow/valid-knowledge.yaml +30 -0
  93. package/scripts/__fixtures__/pod-workflow/valid-veto-always-true.yaml +20 -0
  94. package/scripts/__fixtures__/pod-workflow/valid.yaml +27 -0
  95. package/scripts/__fixtures__/smoke-canary/agents/canary-reporter.md +13 -0
  96. package/scripts/__fixtures__/smoke-canary/agents/canary-researcher.md +13 -0
  97. package/scripts/__fixtures__/smoke-canary/agents/canary-synth.md +13 -0
  98. package/scripts/__fixtures__/smoke-canary/memory/learnings.consolidated.md +10 -0
  99. package/scripts/__fixtures__/smoke-canary/memory/learnings.jsonl +448 -0
  100. package/scripts/__fixtures__/smoke-canary/templates/report-tmpl.md +9 -0
  101. package/scripts/__fixtures__/smoke-canary/templates/research-tmpl.md +7 -0
  102. package/scripts/__fixtures__/smoke-canary/templates/synth-tmpl.md +9 -0
  103. package/scripts/__fixtures__/smoke-canary/workflows/wf-canary.smoke.json +11 -0
  104. package/scripts/__fixtures__/smoke-canary/workflows/wf-canary.yaml +53 -0
  105. package/scripts/__fixtures__/source-audit/fake-green-bronze-unsignaled.yaml +10 -0
  106. package/scripts/__fixtures__/source-audit/fake-green-counts.yaml +9 -0
  107. package/scripts/__fixtures__/source-audit/fake-green-missing-evidence.yaml +9 -0
  108. package/scripts/__fixtures__/source-audit/fake-green-unclassified.yaml +10 -0
  109. package/scripts/__fixtures__/source-audit/fake-green-verdict.yaml +10 -0
  110. package/scripts/__fixtures__/source-audit/golden-blocked.yaml +10 -0
  111. package/scripts/__fixtures__/source-audit/golden.yaml +11 -0
  112. package/scripts/__fixtures__/sweep-forms/agents/forms-count.md +13 -0
  113. package/scripts/__fixtures__/sweep-forms/agents/forms-field.md +13 -0
  114. package/scripts/__fixtures__/sweep-forms/agents/forms-fileref.md +13 -0
  115. package/scripts/__fixtures__/sweep-forms/agents/forms-json.md +13 -0
  116. package/scripts/__fixtures__/sweep-forms/agents/forms-section.md +13 -0
  117. package/scripts/__fixtures__/sweep-forms/specs/wf-forms.spec.json +5 -0
  118. package/scripts/__fixtures__/sweep-forms/templates/t_count.md +5 -0
  119. package/scripts/__fixtures__/sweep-forms/templates/t_field.md +3 -0
  120. package/scripts/__fixtures__/sweep-forms/templates/t_fileref.md +3 -0
  121. package/scripts/__fixtures__/sweep-forms/templates/t_json.md +0 -0
  122. package/scripts/__fixtures__/sweep-forms/templates/t_section.md +3 -0
  123. package/scripts/__fixtures__/sweep-forms/workflows/wf-forms.smoke.json +13 -0
  124. package/scripts/__fixtures__/sweep-forms/workflows/wf-forms.yaml +67 -0
  125. package/scripts/__fixtures__/validate-story-acs-corpus/corpus-1-noop-state-json.fixture.md +18 -0
  126. package/scripts/__fixtures__/validate-story-acs-corpus/corpus-2-crash-buildworkflowyaml.fixture.md +26 -0
  127. package/scripts/__fixtures__/validate-story-acs-corpus/corpus-3-nasce-verde-skip-modes.fixture.md +29 -0
  128. package/scripts/__fixtures__/validate-story-acs-corpus/corpus-4-guarda-sem-irmao.fixture.md +17 -0
  129. package/scripts/__fixtures__/validate-story-acs-corpus/corpus-5a-diff-stat-sem-guarda.fixture.md +17 -0
  130. package/scripts/__fixtures__/validate-story-acs-corpus/corpus-5b-test-f-sobre-diretorio.fixture.md +20 -0
  131. package/scripts/__fixtures__/veto-checks/copy-clean.md +4 -0
  132. package/scripts/__fixtures__/veto-checks/copy-dashes.md +4 -0
  133. package/scripts/__fixtures__/veto-checks/n8n-bad.md +18 -0
  134. package/scripts/__fixtures__/veto-checks/n8n-ok.md +22 -0
  135. package/scripts/__fixtures__/veto-checks/page-bad.html +7 -0
  136. package/scripts/__fixtures__/veto-checks/phash/copy.png +0 -0
  137. package/scripts/__fixtures__/veto-checks/phash/distinct.png +0 -0
  138. package/scripts/__fixtures__/veto-checks/phash/distinct2.png +0 -0
  139. package/scripts/__fixtures__/veto-checks/phash/make-fixtures.cjs +203 -0
  140. package/scripts/__fixtures__/veto-checks/phash/ref.png +0 -0
  141. package/scripts/__fixtures__/veto-checks/slide-ok.html +15 -0
  142. package/scripts/__fixtures__/veto-checks/slide-overflow.html +14 -0
  143. package/scripts/__fixtures__/veto-checks/sweep-pod/agents/vc-checker.md +13 -0
  144. package/scripts/__fixtures__/veto-checks/sweep-pod/templates/check-tmpl.md +6 -0
  145. package/scripts/__fixtures__/veto-checks/sweep-pod/workflows/wf-vc.smoke.json +10 -0
  146. package/scripts/__fixtures__/veto-checks/sweep-pod/workflows/wf-vc.yaml +19 -0
  147. package/scripts/__fixtures__/voz-do-dono/README.md +23 -0
  148. package/scripts/__fixtures__/voz-do-dono/dono-escalar.yaml +9 -0
  149. package/scripts/__fixtures__/voz-do-dono/dono-guia.yaml +10 -0
  150. package/scripts/__fixtures__/voz-do-dono/peca-3a-pessoa.md +6 -0
  151. package/scripts/__fixtures__/voz-do-dono/peca-com-lexico-proibido.md +6 -0
  152. package/scripts/__fixtures__/voz-do-dono/peca-limpa-1a-pessoa.md +6 -0
  153. package/scripts/__tests__/derive-ready-transitions.test.cjs +269 -0
  154. package/scripts/__tests__/enforce-cycle-authority.test.cjs +869 -0
  155. package/scripts/__tests__/enforce-git-push-authority.test.cjs +701 -0
  156. package/scripts/__tests__/enforce-ready-oracles.test.cjs +745 -0
  157. package/scripts/__tests__/motor-scripts.test.cjs +339 -0
  158. package/scripts/__tests__/pc-run-pod-counter.test.cjs +58 -0
  159. package/scripts/__tests__/pc-run-pod.test.cjs +578 -0
  160. package/scripts/__tests__/validate-pod-workflow.test.cjs +90 -0
  161. package/scripts/__tests__/validate-story-acs.test.cjs +607 -0
  162. package/scripts/anti-path.test.cjs +163 -0
  163. package/scripts/arena.cjs +514 -0
  164. package/scripts/arena.test.cjs +213 -0
  165. package/scripts/brief-leitura-obrigatoria.test.cjs +364 -0
  166. package/scripts/consolidate-knowledge-runner.test.cjs +249 -0
  167. package/scripts/default-funcional.test.cjs +153 -0
  168. package/scripts/derive-ready-transitions.cjs +325 -0
  169. package/scripts/forge-additive.test.cjs +158 -0
  170. package/scripts/forge-assess-tier.cjs +205 -0
  171. package/scripts/forge-assess-tier.test.cjs +114 -0
  172. package/scripts/forge-canonical.test.cjs +624 -0
  173. package/scripts/forge-generate.cjs +1303 -0
  174. package/scripts/forge-harden-learning.cjs +921 -0
  175. package/scripts/forge-harden-learning.test.cjs +242 -0
  176. package/scripts/forge-ingest-memory.cjs +136 -0
  177. package/scripts/forge-upgrade-pod.cjs +368 -0
  178. package/scripts/forge.test.cjs +609 -0
  179. package/scripts/harden-knowledge.test.cjs +612 -0
  180. package/scripts/harness-g5-lite.cjs +243 -0
  181. package/scripts/harness-g5-lite.test.cjs +134 -0
  182. package/scripts/hn-carousel-contrato-entrada.test.cjs +96 -0
  183. package/scripts/migrate-squad-orchestration.test.cjs +146 -0
  184. package/scripts/migration-manifest-sf3.2.test.cjs +382 -0
  185. package/scripts/migration-manifest-sf3.3.test.cjs +170 -0
  186. package/scripts/migration-manifest-sf5.5.test.cjs +189 -0
  187. package/scripts/migration-manifest.cjs +1146 -0
  188. package/scripts/migration-manifest.test.cjs +186 -0
  189. package/scripts/npm-scope-invocation.test.cjs +194 -0
  190. package/scripts/owner-layer.cjs +442 -0
  191. package/scripts/owner-layer.test.cjs +358 -0
  192. package/scripts/pc-run-pipeline.cjs +289 -0
  193. package/scripts/pc-run-pipeline.test.cjs +256 -0
  194. package/scripts/pc-run-pod-countgte.test.cjs +66 -0
  195. package/scripts/pc-run-pod.cjs +1355 -0
  196. package/scripts/phash-gate.test.cjs +433 -0
  197. package/scripts/pod-export-compile.cjs +487 -0
  198. package/scripts/pod-export-compile.test.cjs +312 -0
  199. package/scripts/pod-export-executor.cjs +678 -0
  200. package/scripts/pod-export-executor.test.cjs +1341 -0
  201. package/scripts/pod-export-hardening.test.cjs +531 -0
  202. package/scripts/pod-export-postprocess.cjs +427 -0
  203. package/scripts/pod-export-postprocess.test.cjs +558 -0
  204. package/scripts/pod-export-queue-race.test.cjs +865 -0
  205. package/scripts/pod-export-release.cjs +473 -0
  206. package/scripts/pod-export-release.test.cjs +267 -0
  207. package/scripts/pod-export-service.cjs +1297 -0
  208. package/scripts/pod-export-service.test.cjs +489 -0
  209. package/scripts/pod-export-tools.cjs +470 -0
  210. package/scripts/pod-export-ui.cjs +805 -0
  211. package/scripts/pod-export-ui.test.cjs +301 -0
  212. package/scripts/pod-memory-budget.test.cjs +309 -0
  213. package/scripts/pod-memory-note.cjs +357 -0
  214. package/scripts/pod-memory-note.test.cjs +452 -0
  215. package/scripts/pod-memory.cjs +1252 -0
  216. package/scripts/pod-memory.test.cjs +951 -0
  217. package/scripts/render-png.test.cjs +307 -0
  218. package/scripts/smoke-isolation.test.cjs +100 -0
  219. package/scripts/smoke-pod-workflow.cjs +755 -0
  220. package/scripts/smoke-sweep.test.cjs +170 -0
  221. package/scripts/validate-adopt.js +235 -0
  222. package/scripts/validate-branding.js +84 -0
  223. package/scripts/validate-budgets.js +140 -0
  224. package/scripts/validate-fidelity-output.cjs +267 -0
  225. package/scripts/validate-fidelity-output.test.cjs +101 -0
  226. package/scripts/validate-install.js +230 -0
  227. package/scripts/validate-no-clone.cjs +220 -0
  228. package/scripts/validate-no-clone.test.cjs +77 -0
  229. package/scripts/validate-pipeline.cjs +145 -0
  230. package/scripts/validate-pod-workflow.cjs +878 -0
  231. package/scripts/validate-source-audit.cjs +170 -0
  232. package/scripts/validate-source-audit.test.cjs +90 -0
  233. package/scripts/validate-story-acs.cjs +862 -0
  234. package/scripts/validate-update-scope-motor.js +421 -0
  235. package/scripts/veto-checks/html-valid.cjs +92 -0
  236. package/scripts/veto-checks/lexical-check.cjs +62 -0
  237. package/scripts/veto-checks/phash-gate.cjs +589 -0
  238. package/scripts/veto-checks/render-gate.cjs +165 -0
  239. package/scripts/veto-checks/render-png.cjs +358 -0
  240. package/scripts/veto-checks.test.cjs +219 -0
  241. package/scripts/watcher-audit.cjs +178 -0
  242. package/template/.claude/CLAUDE.md +103 -0
  243. package/template/.claude/agents/pc-analyst.md +100 -0
  244. package/template/.claude/agents/pc-architect.md +32 -0
  245. package/template/.claude/agents/pc-dev.md +27 -0
  246. package/template/.claude/agents/pc-devops.md +45 -0
  247. package/template/.claude/agents/pc-planner.md +32 -0
  248. package/template/.claude/agents/pc-po.md +25 -0
  249. package/template/.claude/agents/pc-qa.md +25 -0
  250. package/template/.claude/commands/power/academy.md +9 -0
  251. package/template/.claude/commands/power/automation.md +9 -0
  252. package/template/.claude/commands/power/content-carousel.md +267 -0
  253. package/template/.claude/commands/power/content.md +9 -0
  254. package/template/.claude/commands/power/dev.md +9 -0
  255. package/template/.claude/commands/power/forge.md +224 -0
  256. package/template/.claude/commands/power/hormozi.md +221 -0
  257. package/template/.claude/commands/power/modo.md +57 -0
  258. package/template/.claude/hooks/README.md +114 -0
  259. package/template/.claude/hooks/context-budget.cjs +64 -0
  260. package/template/.claude/hooks/enforce-cycle-authority.cjs +457 -0
  261. package/template/.claude/hooks/enforce-git-push-authority.cjs +925 -0
  262. package/template/.claude/hooks/enforce-ready-oracles.cjs +502 -0
  263. package/template/.claude/rules/authority.md +76 -0
  264. package/template/.claude/rules/curadoria-de-conhecimento.md +30 -0
  265. package/template/.claude/rules/model-matrix.md +34 -0
  266. package/template/.claude/rules/orchestration.md +133 -0
  267. package/template/.claude/settings.json +50 -0
  268. package/template/.claude/skills/pc-apply-qa-fixes/SKILL.md +108 -0
  269. package/template/.claude/skills/pc-apply-qa-fixes/references/fix-loop.md +40 -0
  270. package/template/.claude/skills/pc-apply-qa-fixes/references/fix-request-template.md +70 -0
  271. package/template/.claude/skills/pc-arena/SKILL.md +96 -0
  272. package/template/.claude/skills/pc-close-story/SKILL.md +105 -0
  273. package/template/.claude/skills/pc-commit/SKILL.md +108 -0
  274. package/template/.claude/skills/pc-develop-story/SKILL.md +116 -0
  275. package/template/.claude/skills/pc-full-cycle/SKILL.md +150 -0
  276. package/template/.claude/skills/pc-pipeline/SKILL.md +63 -0
  277. package/template/.claude/skills/pc-pipeline/references/gate-templates.md +46 -0
  278. package/template/.claude/skills/pc-review-story/SKILL.md +129 -0
  279. package/template/.claude/skills/pc-review-story/references/false-positive-detection.md +50 -0
  280. package/template/.claude/skills/pc-review-story/references/nfr-assess.md +47 -0
  281. package/template/.claude/skills/pc-review-story/references/risk-profile.md +75 -0
  282. package/template/.claude/skills/pc-review-story/references/security-checklist.md +69 -0
  283. package/template/.claude/skills/pc-review-story/references/test-design.md +37 -0
  284. package/template/.claude/skills/pc-review-story/references/trace-requirements.md +46 -0
  285. package/template/.claude/skills/pc-run-pod/SKILL.md +123 -0
  286. package/template/.claude/skills/pc-validate-story/SKILL.md +114 -0
  287. package/template/.claude/skills/pc-wave/SKILL.md +133 -0
  288. package/template/.env.example +10 -0
  289. package/template/knowledge/analyst/brainstorming.md +40 -0
  290. package/template/knowledge/analyst/brief-skeleton.md +32 -0
  291. package/template/knowledge/analyst/competitor-skeleton.md +39 -0
  292. package/template/knowledge/analyst/elicitation-menu.md +49 -0
  293. package/template/knowledge/analyst/market-research-skeleton.md +36 -0
  294. package/template/knowledge/analyst/research-prompt-structure.md +48 -0
  295. package/template/knowledge/analyst/roi-skeleton.md +51 -0
  296. package/template/knowledge/voice-dna/README.md +99 -0
  297. package/template/knowledge/voice-dna/voice-dna.example.yaml +157 -0
  298. package/template/pods/README.md +64 -0
  299. package/template/pods/academy/README.md +37 -0
  300. package/template/pods/academy/agents/academy-chief.md +27 -0
  301. package/template/pods/academy/examples/palestra.example.md +142 -0
  302. package/template/pods/academy/pod-spec.json +44 -0
  303. package/template/pods/academy/templates/materiais-tmpl.md +17 -0
  304. package/template/pods/academy/templates/revisao-didatica-tmpl.md +20 -0
  305. package/template/pods/academy/workflows/wf-materiais-revisao.yaml +30 -0
  306. package/template/pods/authority-content/README.md +43 -0
  307. package/template/pods/authority-content/agents/content-chief.md +28 -0
  308. package/template/pods/authority-content/pod-spec.json +45 -0
  309. package/template/pods/authority-content/templates/criacao-na-voz-tmpl.md +17 -0
  310. package/template/pods/authority-content/templates/red-team-factual-tmpl.md +23 -0
  311. package/template/pods/authority-content/workflows/wf-criacao-redteam.yaml +30 -0
  312. package/template/pods/automation/README.md +37 -0
  313. package/template/pods/automation/agents/langgraph-architect.md +30 -0
  314. package/template/pods/automation/agents/n8n-architect.md +30 -0
  315. package/template/pods/automation/examples/README.md +46 -0
  316. package/template/pods/automation/examples/n8n-content-radar.example.json +380 -0
  317. package/template/pods/automation/knowledge/langgraph-patterns.md +126 -0
  318. package/template/pods/automation/knowledge/n8n-patterns.md +131 -0
  319. package/template/pods/automation/memory/README.md +16 -0
  320. package/template/pods/automation/memory/learnings.consolidated.md +8 -0
  321. package/template/pods/automation/memory/learnings.jsonl +0 -0
  322. package/template/pods/automation/pod-spec.json +109 -0
  323. package/template/pods/automation/specs/wf-langgraph-build.spec.json +107 -0
  324. package/template/pods/automation/squad-io.yaml +28 -0
  325. package/template/pods/automation/templates/lg-build-tmpl.md +17 -0
  326. package/template/pods/automation/templates/lg-design-tmpl.md +23 -0
  327. package/template/pods/automation/templates/lg-discover-tmpl.md +20 -0
  328. package/template/pods/automation/templates/lg-handoff-tmpl.md +20 -0
  329. package/template/pods/automation/templates/lg-test-tmpl.md +20 -0
  330. package/template/pods/automation/templates/n8n-build-tmpl.md +14 -0
  331. package/template/pods/automation/templates/n8n-design-tmpl.md +23 -0
  332. package/template/pods/automation/templates/n8n-discover-tmpl.md +20 -0
  333. package/template/pods/automation/templates/n8n-handoff-tmpl.md +20 -0
  334. package/template/pods/automation/templates/n8n-test-tmpl.md +20 -0
  335. package/template/pods/automation/workflows/wf-langgraph-build.smoke.json +11 -0
  336. package/template/pods/automation/workflows/wf-langgraph-build.yaml +64 -0
  337. package/template/pods/automation/workflows/wf-n8n-build.smoke.json +11 -0
  338. package/template/pods/automation/workflows/wf-n8n-build.yaml +65 -0
  339. package/template/pods/content-carousel/README.md +91 -0
  340. package/template/pods/content-carousel/agents/carousel-builder.md +28 -0
  341. package/template/pods/content-carousel/agents/carousel-visual.md +24 -0
  342. package/template/pods/content-carousel/agents/hn-curator.md +74 -0
  343. package/template/pods/content-carousel/config/heuristic-watcher-rubric.yaml +59 -0
  344. package/template/pods/content-carousel/knowledge/aquisicao-ancora.md +443 -0
  345. package/template/pods/content-carousel/knowledge/cta-brief.md +25 -0
  346. package/template/pods/content-carousel/knowledge/dono.example.yaml +45 -0
  347. package/template/pods/content-carousel/knowledge/identidade-visual-mascote.md +62 -0
  348. package/template/pods/content-carousel/knowledge/image-generation.md +62 -0
  349. package/template/pods/content-carousel/knowledge/selecao-de-ancora.md +60 -0
  350. package/template/pods/content-carousel/knowledge/slides-html.md +56 -0
  351. package/template/pods/content-carousel/memory/README.md +18 -0
  352. package/template/pods/content-carousel/memory/learnings.consolidated.md +6 -0
  353. package/template/pods/content-carousel/memory/learnings.jsonl +0 -0
  354. package/template/pods/content-carousel/pod-spec.json +100 -0
  355. package/template/pods/content-carousel/squad-io.yaml +10 -0
  356. package/template/pods/content-carousel/templates/assembly-tmpl.md +23 -0
  357. package/template/pods/content-carousel/templates/digest-tmpl.md +29 -0
  358. package/template/pods/content-carousel/templates/visuals-tmpl.md +20 -0
  359. package/template/pods/content-carousel/workflows/wf-content-carousel.smoke.json +23 -0
  360. package/template/pods/content-carousel/workflows/wf-content-carousel.yaml +80 -0
  361. package/template/pods/dev-ia/README.md +45 -0
  362. package/template/pods/dev-ia/agents/db-architect.md +33 -0
  363. package/template/pods/dev-ia/agents/ux-architect.md +29 -0
  364. package/template/pods/dev-ia/knowledge/db/migration-protocol.md +95 -0
  365. package/template/pods/dev-ia/knowledge/db/rls-patterns.md +101 -0
  366. package/template/pods/dev-ia/knowledge/db/schema-review-checklist.md +76 -0
  367. package/template/pods/dev-ia/memory/README.md +16 -0
  368. package/template/pods/dev-ia/memory/learnings.consolidated.md +8 -0
  369. package/template/pods/dev-ia/memory/learnings.jsonl +0 -0
  370. package/template/pods/dev-ia/pod-spec.json +34 -0
  371. package/template/pods/dev-ia/templates/schema-review-tmpl.md +23 -0
  372. package/template/pods/dev-ia/templates/ux-flow-review-tmpl.md +23 -0
  373. package/template/pods/dev-ia/tools/db-ops/backup-manager.sh +321 -0
  374. package/template/pods/dev-ia/tools/db-ops/best-practices-auditor.sh +534 -0
  375. package/template/pods/dev-ia/tools/db-ops/bootstrap-runner.sh +255 -0
  376. package/template/pods/dev-ia/tools/db-ops/data-loader.sh +616 -0
  377. package/template/pods/dev-ia/tools/db-ops/detect-database.sh +113 -0
  378. package/template/pods/dev-ia/tools/db-ops/explain-analyzer.sh +285 -0
  379. package/template/pods/dev-ia/tools/db-ops/health-checker.sh +323 -0
  380. package/template/pods/dev-ia/tools/db-ops/migration-runner.sh +308 -0
  381. package/template/pods/dev-ia/tools/db-ops/postgresql-schema-loader.sh +334 -0
  382. package/template/pods/dev-ia/tools/db-ops/query-runner.sh +171 -0
  383. package/template/pods/dev-ia/tools/db-ops/rls-policy-installer.sh +480 -0
  384. package/template/pods/dev-ia/tools/db-ops/rls-test-suite.sh +172 -0
  385. package/template/pods/dev-ia/tools/db-ops/schema-context-loader.sh +176 -0
  386. package/template/pods/hormozi-method/README.md +52 -0
  387. package/template/pods/hormozi-method/agents/acquisition-strategist.md +33 -0
  388. package/template/pods/hormozi-method/agents/conversion-copywriter.md +34 -0
  389. package/template/pods/hormozi-method/agents/monetization-architect.md +35 -0
  390. package/template/pods/hormozi-method/agents/offer-engineer.md +37 -0
  391. package/template/pods/hormozi-method/knowledge/core-four-leads.md +51 -0
  392. package/template/pods/hormozi-method/knowledge/grand-slam-offer.md +66 -0
  393. package/template/pods/hormozi-method/knowledge/growth-decision.md +38 -0
  394. package/template/pods/hormozi-method/knowledge/hooks-and-ads.md +56 -0
  395. package/template/pods/hormozi-method/knowledge/launch-email.md +31 -0
  396. package/template/pods/hormozi-method/knowledge/money-model.md +46 -0
  397. package/template/pods/hormozi-method/knowledge/opportunity-screening.md +44 -0
  398. package/template/pods/hormozi-method/knowledge/pages.md +25 -0
  399. package/template/pods/hormozi-method/knowledge/pos-lancamento-leads.md +56 -0
  400. package/template/pods/hormozi-method/knowledge/pricing.md +36 -0
  401. package/template/pods/hormozi-method/knowledge/retention-ltv.md +37 -0
  402. package/template/pods/hormozi-method/knowledge/scale-roadmap.md +35 -0
  403. package/template/pods/hormozi-method/knowledge/swipefiles-curados.md +44 -0
  404. package/template/pods/hormozi-method/knowledge/value-equation-diagnostic.md +77 -0
  405. package/template/pods/hormozi-method/memory/README.md +16 -0
  406. package/template/pods/hormozi-method/memory/learnings.consolidated.md +6 -0
  407. package/template/pods/hormozi-method/memory/learnings.jsonl +0 -0
  408. package/template/pods/hormozi-method/pod-spec.json +50 -0
  409. package/template/pods/hormozi-method/specs/wf-full-launch-sequence.spec.json +149 -0
  410. package/template/pods/hormozi-method/specs/wf-lead-magnet-pipeline.spec.json +125 -0
  411. package/template/pods/hormozi-method/specs/wf-money-model-design.spec.json +117 -0
  412. package/template/pods/hormozi-method/specs/wf-paid-ads-campaign.spec.json +132 -0
  413. package/template/pods/hormozi-method/specs/wf-scaling-diagnostic.spec.json +121 -0
  414. package/template/pods/hormozi-method/squad-io.yaml +43 -0
  415. package/template/pods/hormozi-method/templates/conversion-copywriter-tmpl.md +20 -0
  416. package/template/pods/hormozi-method/templates/launch-execucao-tmpl.md +17 -0
  417. package/template/pods/hormozi-method/templates/launch-fechamento-tmpl.md +17 -0
  418. package/template/pods/hormozi-method/templates/launch-pos-tmpl.md +17 -0
  419. package/template/pods/hormozi-method/templates/launch-preparacao-tmpl.md +17 -0
  420. package/template/pods/hormozi-method/templates/lm-copy-tmpl.md +17 -0
  421. package/template/pods/hormozi-method/templates/lm-distribuicao-tmpl.md +18 -0
  422. package/template/pods/hormozi-method/templates/lm-estrategia-tmpl.md +17 -0
  423. package/template/pods/hormozi-method/templates/mm-arquitetura-tmpl.md +18 -0
  424. package/template/pods/hormozi-method/templates/mm-copy-tmpl.md +17 -0
  425. package/template/pods/hormozi-method/templates/mm-diagnostico-tmpl.md +14 -0
  426. package/template/pods/hormozi-method/templates/monetization-architect-tmpl.md +17 -0
  427. package/template/pods/hormozi-method/templates/offer-engineer-tmpl.md +20 -0
  428. package/template/pods/hormozi-method/templates/paid-criativos-tmpl.md +19 -0
  429. package/template/pods/hormozi-method/templates/paid-fundacao-tmpl.md +17 -0
  430. package/template/pods/hormozi-method/templates/paid-teste-escala-tmpl.md +17 -0
  431. package/template/pods/hormozi-method/templates/scaling-diagnostico-tmpl.md +17 -0
  432. package/template/pods/hormozi-method/templates/scaling-priorizacao-tmpl.md +17 -0
  433. package/template/pods/hormozi-method/templates/scaling-roadmap-tmpl.md +17 -0
  434. package/template/pods/hormozi-method/workflows/wf-full-launch-sequence.smoke.json +12 -0
  435. package/template/pods/hormozi-method/workflows/wf-full-launch-sequence.yaml +56 -0
  436. package/template/pods/hormozi-method/workflows/wf-grand-slam-offer.smoke.json +11 -0
  437. package/template/pods/hormozi-method/workflows/wf-grand-slam-offer.yaml +45 -0
  438. package/template/pods/hormozi-method/workflows/wf-lead-magnet-pipeline.smoke.json +9 -0
  439. package/template/pods/hormozi-method/workflows/wf-lead-magnet-pipeline.yaml +45 -0
  440. package/template/pods/hormozi-method/workflows/wf-money-model-design.smoke.json +11 -0
  441. package/template/pods/hormozi-method/workflows/wf-money-model-design.yaml +45 -0
  442. package/template/pods/hormozi-method/workflows/wf-paid-ads-campaign.smoke.json +9 -0
  443. package/template/pods/hormozi-method/workflows/wf-paid-ads-campaign.yaml +46 -0
  444. package/template/pods/hormozi-method/workflows/wf-scaling-diagnostic.smoke.json +11 -0
  445. package/template/pods/hormozi-method/workflows/wf-scaling-diagnostic.yaml +44 -0
  446. package/template/pods/squad-forge/README.md +53 -0
  447. package/template/pods/squad-forge/agents/forge-chief.md +31 -0
  448. package/template/pods/squad-forge/agents/mind-extractor.md +29 -0
  449. package/template/pods/squad-forge/agents/pod-critic.md +26 -0
  450. package/template/pods/squad-forge/config/heuristic-watcher-rubric.yaml +74 -0
  451. package/template/pods/squad-forge/knowledge/fidelity-rubric.yaml +176 -0
  452. package/template/pods/squad-forge/knowledge/g6-memory-check.md +17 -0
  453. package/template/pods/squad-forge/knowledge/memory-ingest.md +16 -0
  454. package/template/pods/squad-forge/knowledge/source-audit-rubric.yaml +60 -0
  455. package/template/pods/squad-forge/memory/README.md +16 -0
  456. package/template/pods/squad-forge/memory/learnings.consolidated.md +8 -0
  457. package/template/pods/squad-forge/memory/learnings.jsonl +0 -0
  458. package/template/pods/squad-forge/pod-spec.json +166 -0
  459. package/template/pods/squad-forge/squad-io.yaml +13 -0
  460. package/template/pods/squad-forge/tasks/pipeline.md +158 -0
  461. package/template/pods/squad-forge/templates/discovery-tmpl.md +40 -0
  462. package/template/pods/squad-forge/templates/generation-tmpl.md +18 -0
  463. package/template/pods/squad-forge/templates/red-team-tmpl.md +17 -0
  464. package/template/pods/squad-forge/templates/register-tmpl.md +17 -0
  465. package/template/pods/squad-forge/templates/workflow-tmpl.yaml +101 -0
  466. package/template/pods/squad-forge/workflows/wf-forge.smoke.json +12 -0
  467. package/template/pods/squad-forge/workflows/wf-forge.yaml +60 -0
@@ -0,0 +1,334 @@
1
+ #!/bin/bash
2
+ # PostgreSQL/Supabase Schema Loader - Deterministic and Error-Proof
3
+ # Always loads ALL tables, columns, relationships, constraints
4
+ # Output: JSON file with complete schema information
5
+
6
+ set -euo pipefail
7
+
8
+ # Output file
9
+ OUTPUT_FILE="/tmp/postgresql_schema_$$.json"
10
+ ERROR_LOG="/tmp/postgresql_schema_error_$$.log"
11
+
12
+ # Trap errors and cleanup
13
+ trap 'handle_error $? $LINENO' ERR
14
+
15
+ handle_error() {
16
+ local exit_code=$1
17
+ local line_number=$2
18
+ echo "{\"error\": true, \"message\": \"Script failed at line $line_number with exit code $exit_code\", \"timestamp\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"}" > "$OUTPUT_FILE"
19
+ exit $exit_code
20
+ }
21
+
22
+ # Function to safely execute PostgreSQL queries
23
+ safe_psql_query() {
24
+ local query="$1"
25
+ local description="$2"
26
+
27
+ # Execute query with error handling
28
+ if ! result=$(psql "$DB_URL" -t -A -c "$query" 2>>"$ERROR_LOG"); then
29
+ echo "null"
30
+ return 1
31
+ fi
32
+
33
+ echo "$result"
34
+ return 0
35
+ }
36
+
37
+ # Main schema loading function
38
+ load_postgresql_schema() {
39
+ local db_url="${1:-}"
40
+
41
+ # Check if database URL is provided
42
+ if [ -z "$db_url" ]; then
43
+ # Try to auto-detect
44
+ if [ -n "${SUPABASE_DB_URL:-}" ]; then
45
+ db_url="$SUPABASE_DB_URL"
46
+ elif [ -n "${DATABASE_URL:-}" ]; then
47
+ db_url="$DATABASE_URL"
48
+ else
49
+ echo "{\"error\": true, \"message\": \"No PostgreSQL database URL found\"}" > "$OUTPUT_FILE"
50
+ exit 1
51
+ fi
52
+ fi
53
+
54
+ # Export for use in safe_psql_query
55
+ export DB_URL="$db_url"
56
+
57
+ # Start JSON output
58
+ echo "{" > "$OUTPUT_FILE"
59
+ echo " \"database_type\": \"postgresql\"," >> "$OUTPUT_FILE"
60
+ echo " \"timestamp\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"," >> "$OUTPUT_FILE"
61
+
62
+ # 1. Database version
63
+ version=$(safe_psql_query "SELECT version()" "database version" | head -1 | sed 's/"/\\"/g')
64
+ echo " \"version\": \"$version\"," >> "$OUTPUT_FILE"
65
+
66
+ # 2. Count tables
67
+ table_count=$(safe_psql_query "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE'" "table count")
68
+ echo " \"table_count\": $table_count," >> "$OUTPUT_FILE"
69
+
70
+ # 3. Load all tables with columns
71
+ echo " \"tables\": {" >> "$OUTPUT_FILE"
72
+
73
+ # Get all table names
74
+ tables=$(safe_psql_query "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE' ORDER BY table_name" "table list")
75
+
76
+ first_table=true
77
+ while IFS= read -r table; do
78
+ [ -z "$table" ] && continue
79
+
80
+ if [ "$first_table" = false ]; then
81
+ echo "," >> "$OUTPUT_FILE"
82
+ fi
83
+ first_table=false
84
+
85
+ echo -n " \"$table\": {" >> "$OUTPUT_FILE"
86
+
87
+ # Get row count (with timeout to prevent hanging on large tables)
88
+ row_count=$(timeout 5 psql "$DB_URL" -t -A -c "SELECT COUNT(*) FROM \"$table\"" 2>/dev/null || echo "null")
89
+ echo -n "\"row_count\": $row_count, " >> "$OUTPUT_FILE"
90
+
91
+ # Get columns for this table
92
+ echo -n "\"columns\": [" >> "$OUTPUT_FILE"
93
+
94
+ columns=$(safe_psql_query "
95
+ SELECT json_build_object(
96
+ 'name', column_name,
97
+ 'type', data_type,
98
+ 'nullable', is_nullable,
99
+ 'default', column_default,
100
+ 'max_length', character_maximum_length
101
+ )::text
102
+ FROM information_schema.columns
103
+ WHERE table_schema = 'public'
104
+ AND table_name = '$table'
105
+ ORDER BY ordinal_position
106
+ " "columns for $table")
107
+
108
+ first_col=true
109
+ while IFS= read -r col; do
110
+ [ -z "$col" ] && continue
111
+ if [ "$first_col" = false ]; then
112
+ echo -n ", " >> "$OUTPUT_FILE"
113
+ fi
114
+ first_col=false
115
+ echo -n "$col" >> "$OUTPUT_FILE"
116
+ done <<< "$columns"
117
+
118
+ echo -n "]" >> "$OUTPUT_FILE"
119
+
120
+ # Get primary key
121
+ pk=$(safe_psql_query "
122
+ SELECT string_agg(a.attname, ', ')
123
+ FROM pg_index i
124
+ JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
125
+ WHERE i.indrelid = '\"$table\"'::regclass AND i.indisprimary
126
+ " "primary key for $table")
127
+
128
+ if [ -n "$pk" ] && [ "$pk" != "null" ]; then
129
+ echo -n ", \"primary_key\": \"$pk\"" >> "$OUTPUT_FILE"
130
+ fi
131
+
132
+ # Get indexes
133
+ echo -n ", \"indexes\": [" >> "$OUTPUT_FILE"
134
+
135
+ indexes=$(safe_psql_query "
136
+ SELECT json_build_object(
137
+ 'name', indexname,
138
+ 'columns', indexdef
139
+ )::text
140
+ FROM pg_indexes
141
+ WHERE schemaname = 'public' AND tablename = '$table'
142
+ " "indexes for $table")
143
+
144
+ first_idx=true
145
+ while IFS= read -r idx; do
146
+ [ -z "$idx" ] && continue
147
+ if [ "$first_idx" = false ]; then
148
+ echo -n ", " >> "$OUTPUT_FILE"
149
+ fi
150
+ first_idx=false
151
+ echo -n "$idx" >> "$OUTPUT_FILE"
152
+ done <<< "$indexes"
153
+
154
+ echo -n "]}" >> "$OUTPUT_FILE"
155
+
156
+ done <<< "$tables"
157
+
158
+ echo "" >> "$OUTPUT_FILE"
159
+ echo " }," >> "$OUTPUT_FILE"
160
+
161
+ # 4. Load all foreign key relationships
162
+ echo " \"relationships\": [" >> "$OUTPUT_FILE"
163
+
164
+ relationships=$(safe_psql_query "
165
+ SELECT json_build_object(
166
+ 'from_table', tc.table_name,
167
+ 'from_column', kcu.column_name,
168
+ 'to_table', ccu.table_name,
169
+ 'to_column', ccu.column_name,
170
+ 'constraint_name', tc.constraint_name
171
+ )::text
172
+ FROM information_schema.table_constraints AS tc
173
+ JOIN information_schema.key_column_usage AS kcu
174
+ ON tc.constraint_name = kcu.constraint_name
175
+ AND tc.table_schema = kcu.table_schema
176
+ JOIN information_schema.constraint_column_usage AS ccu
177
+ ON ccu.constraint_name = tc.constraint_name
178
+ AND ccu.table_schema = tc.table_schema
179
+ WHERE tc.constraint_type = 'FOREIGN KEY'
180
+ AND tc.table_schema = 'public'
181
+ ORDER BY tc.table_name, tc.constraint_name
182
+ " "foreign key relationships")
183
+
184
+ first_rel=true
185
+ while IFS= read -r rel; do
186
+ [ -z "$rel" ] && continue
187
+ if [ "$first_rel" = false ]; then
188
+ echo "," >> "$OUTPUT_FILE"
189
+ fi
190
+ first_rel=false
191
+ echo -n " $rel" >> "$OUTPUT_FILE"
192
+ done <<< "$relationships"
193
+
194
+ echo "" >> "$OUTPUT_FILE"
195
+ echo " ]," >> "$OUTPUT_FILE"
196
+
197
+ # 5. Check constraints
198
+ echo " \"check_constraints\": [" >> "$OUTPUT_FILE"
199
+
200
+ constraints=$(safe_psql_query "
201
+ SELECT json_build_object(
202
+ 'table', tc.table_name,
203
+ 'constraint', tc.constraint_name,
204
+ 'definition', pgc.consrc
205
+ )::text
206
+ FROM information_schema.table_constraints tc
207
+ JOIN pg_constraint pgc ON pgc.conname = tc.constraint_name
208
+ WHERE tc.constraint_type = 'CHECK'
209
+ AND tc.table_schema = 'public'
210
+ ORDER BY tc.table_name, tc.constraint_name
211
+ " "check constraints" || echo "")
212
+
213
+ first_con=true
214
+ while IFS= read -r con; do
215
+ [ -z "$con" ] && continue
216
+ if [ "$first_con" = false ]; then
217
+ echo "," >> "$OUTPUT_FILE"
218
+ fi
219
+ first_con=false
220
+ echo -n " $con" >> "$OUTPUT_FILE"
221
+ done <<< "$constraints"
222
+
223
+ echo "" >> "$OUTPUT_FILE"
224
+ echo " ]," >> "$OUTPUT_FILE"
225
+
226
+ # 6. Functions and stored procedures
227
+ echo " \"functions\": [" >> "$OUTPUT_FILE"
228
+
229
+ functions=$(safe_psql_query "
230
+ SELECT json_build_object(
231
+ 'name', proname,
232
+ 'arguments', pg_get_function_arguments(oid),
233
+ 'returns', pg_get_function_result(oid),
234
+ 'language', prolang::regtype::text
235
+ )::text
236
+ FROM pg_proc
237
+ WHERE pronamespace = 'public'::regnamespace
238
+ ORDER BY proname
239
+ " "functions" || echo "")
240
+
241
+ first_func=true
242
+ while IFS= read -r func; do
243
+ [ -z "$func" ] && continue
244
+ if [ "$first_func" = false ]; then
245
+ echo "," >> "$OUTPUT_FILE"
246
+ fi
247
+ first_func=false
248
+ echo -n " $func" >> "$OUTPUT_FILE"
249
+ done <<< "$functions"
250
+
251
+ echo "" >> "$OUTPUT_FILE"
252
+ echo " ]," >> "$OUTPUT_FILE"
253
+
254
+ # 7. Views
255
+ echo " \"views\": [" >> "$OUTPUT_FILE"
256
+
257
+ views=$(safe_psql_query "
258
+ SELECT json_build_object(
259
+ 'name', table_name,
260
+ 'definition', view_definition
261
+ )::text
262
+ FROM information_schema.views
263
+ WHERE table_schema = 'public'
264
+ ORDER BY table_name
265
+ " "views" || echo "")
266
+
267
+ first_view=true
268
+ while IFS= read -r view; do
269
+ [ -z "$view" ] && continue
270
+ if [ "$first_view" = false ]; then
271
+ echo "," >> "$OUTPUT_FILE"
272
+ fi
273
+ first_view=false
274
+ echo -n " $view" >> "$OUTPUT_FILE"
275
+ done <<< "$views"
276
+
277
+ echo "" >> "$OUTPUT_FILE"
278
+ echo " ]," >> "$OUTPUT_FILE"
279
+
280
+ # 8. RLS (Row Level Security) status
281
+ echo " \"rls_status\": [" >> "$OUTPUT_FILE"
282
+
283
+ rls=$(safe_psql_query "
284
+ SELECT json_build_object(
285
+ 'table', schemaname || '.' || tablename,
286
+ 'rls_enabled', rowsecurity
287
+ )::text
288
+ FROM pg_tables
289
+ WHERE schemaname = 'public'
290
+ ORDER BY tablename
291
+ " "RLS status" || echo "")
292
+
293
+ first_rls=true
294
+ while IFS= read -r rls_item; do
295
+ [ -z "$rls_item" ] && continue
296
+ if [ "$first_rls" = false ]; then
297
+ echo "," >> "$OUTPUT_FILE"
298
+ fi
299
+ first_rls=false
300
+ echo -n " $rls_item" >> "$OUTPUT_FILE"
301
+ done <<< "$rls"
302
+
303
+ echo "" >> "$OUTPUT_FILE"
304
+ echo " ]," >> "$OUTPUT_FILE"
305
+
306
+ # Final success status
307
+ echo " \"success\": true," >> "$OUTPUT_FILE"
308
+ echo " \"error\": false" >> "$OUTPUT_FILE"
309
+ echo "}" >> "$OUTPUT_FILE"
310
+ }
311
+
312
+ # Execute main function
313
+ load_postgresql_schema "$@" >&2
314
+ output="$OUTPUT_FILE"
315
+
316
+ # Display summary to stderr so it doesn't interfere with output capture
317
+ if [ -f "$output" ]; then
318
+ # Extract summary info
319
+ table_count=$(grep '"table_count"' "$output" | grep -o '[0-9]*')
320
+ rel_count=$(grep -c '"from_table"' "$output" || echo 0)
321
+
322
+ {
323
+ echo "═══════════════════════════════════════════"
324
+ echo " PostgreSQL Schema Load Complete"
325
+ echo "═══════════════════════════════════════════"
326
+ echo " Tables: $table_count"
327
+ echo " Relationships: $rel_count"
328
+ echo " Output: $output"
329
+ echo "═══════════════════════════════════════════"
330
+ } >&2
331
+ fi
332
+
333
+ # Only output the file path to stdout for the calling script to capture
334
+ echo "$OUTPUT_FILE"
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # query-runner.sh - Safe SQL Execution (Worker Script)
4
+ # =============================================================================
5
+ # execution_type: Worker
6
+ # pattern: EXEC-W-001
7
+ # tasks: db-run-sql
8
+ # token_savings: 85%
9
+ # =============================================================================
10
+
11
+ set -euo pipefail
12
+
13
+ # Colors
14
+ RED='\033[0;31m'
15
+ GREEN='\033[0;32m'
16
+ YELLOW='\033[1;33m'
17
+ BLUE='\033[0;34m'
18
+ NC='\033[0m'
19
+
20
+ # Defaults
21
+ DRY_RUN=false
22
+ TIMEOUT=30
23
+ TRANSACTION=true
24
+ DB_URL=""
25
+
26
+ usage() {
27
+ cat << EOF
28
+ Usage: $(basename "$0") [OPTIONS] <sql_file_or_statement>
29
+
30
+ Execute SQL safely with transaction support and timing.
31
+
32
+ OPTIONS:
33
+ --file <path> Execute SQL file
34
+ --sql <statement> Execute inline SQL
35
+ --dry-run Rollback after execution (test mode)
36
+ --no-transaction Execute without transaction wrapper
37
+ --timeout <sec> Statement timeout in seconds (default: 30)
38
+ -v, --verbose Verbose output
39
+ -h, --help Show this help
40
+
41
+ EXAMPLES:
42
+ $(basename "$0") --file migrations/001_create_users.sql
43
+ $(basename "$0") --sql "SELECT * FROM users LIMIT 10"
44
+ $(basename "$0") --file script.sql --dry-run
45
+ $(basename "$0") --sql "UPDATE users SET active=true" --timeout 60
46
+
47
+ ENVIRONMENT:
48
+ SUPABASE_DB_URL or DATABASE_URL Required. PostgreSQL connection string.
49
+ EOF
50
+ }
51
+
52
+ log_info() { echo -e "${BLUE}ℹ${NC} $1"; }
53
+ log_success() { echo -e "${GREEN}✓${NC} $1"; }
54
+ log_warning() { echo -e "${YELLOW}⚠${NC} $1"; }
55
+ log_error() { echo -e "${RED}✗${NC} $1"; }
56
+
57
+ check_env() {
58
+ DB_URL="${SUPABASE_DB_URL:-${DATABASE_URL:-}}"
59
+ if [[ -z "$DB_URL" ]]; then
60
+ log_error "SUPABASE_DB_URL or DATABASE_URL not set"
61
+ exit 1
62
+ fi
63
+ }
64
+
65
+ execute_sql() {
66
+ local sql="$1"
67
+ local start_time end_time duration
68
+
69
+ # Build psql options
70
+ local psql_opts="-v ON_ERROR_STOP=1"
71
+
72
+ if $TRANSACTION; then
73
+ if $DRY_RUN; then
74
+ log_info "Mode: DRY-RUN (will rollback)"
75
+ sql="BEGIN; $sql; ROLLBACK;"
76
+ else
77
+ sql="BEGIN; $sql; COMMIT;"
78
+ fi
79
+ fi
80
+
81
+ # Set timeout
82
+ sql="SET statement_timeout = '${TIMEOUT}s'; $sql"
83
+
84
+ log_info "Executing SQL..."
85
+ echo ""
86
+
87
+ start_time=$(date +%s.%N)
88
+
89
+ # Execute
90
+ if echo "$sql" | psql "$DB_URL" $psql_opts; then
91
+ end_time=$(date +%s.%N)
92
+ duration=$(echo "$end_time - $start_time" | bc)
93
+
94
+ echo ""
95
+ log_success "Execution completed in ${duration}s"
96
+
97
+ if $DRY_RUN; then
98
+ log_warning "DRY-RUN: Changes were rolled back"
99
+ fi
100
+ else
101
+ log_error "Execution failed"
102
+ exit 1
103
+ fi
104
+ }
105
+
106
+ execute_file() {
107
+ local file="$1"
108
+
109
+ if [[ ! -f "$file" ]]; then
110
+ log_error "File not found: $file"
111
+ exit 1
112
+ fi
113
+
114
+ log_info "File: $file"
115
+ log_info "Size: $(du -h "$file" | cut -f1)"
116
+ log_info "Lines: $(wc -l < "$file")"
117
+
118
+ local sql
119
+ sql=$(cat "$file")
120
+
121
+ execute_sql "$sql"
122
+ }
123
+
124
+ # Parse arguments
125
+ SQL_FILE=""
126
+ SQL_INLINE=""
127
+ VERBOSE=false
128
+
129
+ while [[ $# -gt 0 ]]; do
130
+ case $1 in
131
+ --file) SQL_FILE="$2"; shift 2 ;;
132
+ --sql) SQL_INLINE="$2"; shift 2 ;;
133
+ --dry-run) DRY_RUN=true; shift ;;
134
+ --no-transaction) TRANSACTION=false; shift ;;
135
+ --timeout) TIMEOUT="$2"; shift 2 ;;
136
+ -v|--verbose) VERBOSE=true; shift ;;
137
+ -h|--help) usage; exit 0 ;;
138
+ *)
139
+ # Assume it's a file or SQL
140
+ if [[ -f "$1" ]]; then
141
+ SQL_FILE="$1"
142
+ else
143
+ SQL_INLINE="$1"
144
+ fi
145
+ shift
146
+ ;;
147
+ esac
148
+ done
149
+
150
+ if [[ -z "$SQL_FILE" && -z "$SQL_INLINE" ]]; then
151
+ usage
152
+ exit 1
153
+ fi
154
+
155
+ check_env
156
+
157
+ echo ""
158
+ echo "================================================"
159
+ echo " DB-OPS Query Runner"
160
+ echo " Timeout: ${TIMEOUT}s"
161
+ echo " Transaction: $TRANSACTION"
162
+ echo " Dry-run: $DRY_RUN"
163
+ echo "================================================"
164
+ echo ""
165
+
166
+ if [[ -n "$SQL_FILE" ]]; then
167
+ execute_file "$SQL_FILE"
168
+ elif [[ -n "$SQL_INLINE" ]]; then
169
+ log_info "Inline SQL: ${SQL_INLINE:0:100}..."
170
+ execute_sql "$SQL_INLINE"
171
+ fi