@fontdata/ai-harness 4.3.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/README.md +154 -3
  3. package/dist/cli.js +1 -0
  4. package/dist/config/config.js +45 -3
  5. package/dist/delphi/catalogo.js +299 -0
  6. package/dist/delphi/classificar.js +21 -0
  7. package/dist/delphi/command.js +144 -2
  8. package/dist/delphi/encoding.js +112 -0
  9. package/dist/doctor/checks.js +19 -1
  10. package/dist/init.js +16 -2
  11. package/dist/install/perfis.js +21 -0
  12. package/dist/install/plan.js +29 -2
  13. package/dist/install/settings.js +40 -3
  14. package/dist/mapa/extratores/pascal.js +1 -1
  15. package/dist/update/update.js +126 -7
  16. package/package.json +1 -1
  17. package/templates/CLAUDE.md +2 -1
  18. package/templates/catalog.json +11 -3
  19. package/templates/hooks/comentarios/check.mjs +62 -5
  20. package/templates/hooks/hooks.json +2 -1
  21. package/templates/hooks/lib/config.mjs +1 -0
  22. package/templates/hooks/padroes-proibidos.mjs +68 -0
  23. package/templates/perfis/delphi/hooks/encoding.mjs +317 -0
  24. package/templates/perfis/delphi/rules/build-e-verificacao.md +59 -0
  25. package/templates/perfis/delphi/rules/dados/cnpj-alfanumerico-nao-extrair-so-numeros.md +65 -0
  26. package/templates/perfis/delphi/rules/dados/data-hora-sql-nunca-round-trip-textual.md +78 -0
  27. package/templates/perfis/delphi/rules/dados/datestyle-sessao-firedac-postgres.md +60 -0
  28. package/templates/perfis/delphi/rules/dados/ddl-tabela-nova-exige-trigger-de-log.md +68 -0
  29. package/templates/perfis/delphi/rules/dados/divisao-e-conversao-numerica.md +53 -0
  30. package/templates/perfis/delphi/rules/dados/fieldbyname-value-variant-cru-em-aritmetica.md +73 -0
  31. package/templates/perfis/delphi/rules/dados/filtro-condicional-sql-par-add-parambyname.md +72 -0
  32. package/templates/perfis/delphi/rules/dados/firedac.md +51 -0
  33. package/templates/perfis/delphi/rules/dados/macro-firedac-exige-entrada-macrodata.md +96 -0
  34. package/templates/perfis/delphi/rules/dados/sql-qualificacao-colunas.md +36 -0
  35. package/templates/perfis/delphi/rules/dados/tmeminifile-getstrings-nao-limpa-destino.md +89 -0
  36. package/templates/perfis/delphi/rules/encoding-eol.md +130 -0
  37. package/templates/perfis/delphi/rules/linguagem/dataset-nao-se-le-depois-do-laco-eof.md +56 -0
  38. package/templates/perfis/delphi/rules/linguagem/existencia-nunca-se-testa-por-campo-formatado.md +60 -0
  39. package/templates/perfis/delphi/rules/linguagem/float-nunca-comparado-por-igualdade-com-literal.md +55 -0
  40. package/templates/perfis/delphi/rules/linguagem/literal-enum-de-dfm-exige-unit-no-uses.md +84 -0
  41. package/templates/perfis/delphi/rules/linguagem/reaproveitar-funcao-existente-antes-de-criar.md +172 -0
  42. package/templates/perfis/delphi/rules/linguagem/sem-clipboard-debug.md +43 -0
  43. package/templates/perfis/delphi/rules/linguagem/validacao-em-onexit-nao-protege-a-gravacao.md +65 -0
  44. package/templates/perfis/delphi/rules/linguagem/variavel-inline-sai-de-escopo-ao-envolver-bloco.md +69 -0
  45. package/templates/perfis/delphi/rules/telas/foco-decisao-por-canfocus-nao-tabstop.md +40 -0
  46. package/templates/perfis/delphi/rules/telas/form-dinamico-liberar-em-toda-saida.md +80 -0
  47. package/templates/perfis/delphi/rules/telas/heranca-de-form-e-grade-de-selecao.md +58 -0
  48. package/templates/perfis/delphi/rules/threads-e-timers.md +131 -0
  49. package/templates/perfis/delphi/rules/try-finally-e-vazamento.md +109 -0
  50. package/templates/perfis/delphi/skills/conhecimento-delphi/SKILL.md +70 -0
  51. package/templates/perfis/delphi/skills/conhecimento-delphi/references/ATRIBUICAO.md +29 -0
  52. package/templates/perfis/delphi/skills/conhecimento-delphi/references/acbr-nfce-integracao.md +60 -0
  53. package/templates/perfis/delphi/skills/conhecimento-delphi/references/build-via-bat-com-log.md +86 -0
  54. package/templates/perfis/delphi/skills/conhecimento-delphi/references/class-var-vaza-para-campos-de-instancia.md +73 -0
  55. package/templates/perfis/delphi/skills/conhecimento-delphi/references/componentes-designer-vs-runtime.md +47 -0
  56. package/templates/perfis/delphi/skills/conhecimento-delphi/references/console-writeln-sem-flush-nao-loga.md +47 -0
  57. package/templates/perfis/delphi/skills/conhecimento-delphi/references/conversao-numerica-locale.md +47 -0
  58. package/templates/perfis/delphi/skills/conhecimento-delphi/references/delphi13-breaking-changes.md +41 -0
  59. package/templates/perfis/delphi/skills/conhecimento-delphi/references/dpr-uses-project-manager.md +62 -0
  60. package/templates/perfis/delphi/skills/conhecimento-delphi/references/dproj-dcc-debuginformation-nao-booleano.md +78 -0
  61. package/templates/perfis/delphi/skills/conhecimento-delphi/references/dproj-projectguid-valido.md +38 -0
  62. package/templates/perfis/delphi/skills/conhecimento-delphi/references/firedac-registro-drivers.md +94 -0
  63. package/templates/perfis/delphi/skills/conhecimento-delphi/references/horse-gbswagger-rotas-jwt.md +61 -0
  64. package/templates/perfis/delphi/skills/conhecimento-delphi/references/msb6003-command-line-too-long.md +52 -0
  65. package/templates/perfis/delphi/skills/conhecimento-delphi/references/recursos-rcdata.md +67 -0
  66. package/templates/perfis/delphi-fiscal/rules/campo-novo-acbr-preenchimento-explicito.md +61 -0
  67. package/templates/perfis/delphi-fiscal/rules/retorno-de-evento-nfe-pelo-cstat.md +51 -0
  68. package/templates/perfis/delphi-fiscal/rules/sucesso-de-webservice-fiscal-nao-prova-documento.md +100 -0
  69. package/templates/perfis/delphi-fiscal/rules/total-tributo-acbr-soma-itens.md +63 -0
  70. package/templates/perfis/delphi-fiscal/skills/diagnosticar-rejeicao-nfse/SKILL.md +155 -0
  71. package/templates/perfis/delphi-fiscal/skills/patch-acbr/SKILL.md +143 -0
  72. package/templates/skills/auditar-performance/SKILL.md +9 -0
  73. package/templates/skills/auditar-performance/references/pontos-quentes.md +8 -0
  74. package/templates/skills/auditar-seguranca/SKILL.md +55 -14
  75. package/templates/skills/auditar-seguranca/templates/relatorios/TECNICO.md +5 -0
  76. package/templates/skills/auditar-ui/SKILL.md +18 -3
  77. package/templates/skills/auditar-ui/references/ATRIBUICAO.md +44 -0
  78. package/templates/skills/auditar-ui/references/web-interface-guidelines.md +191 -0
  79. package/templates/skills/harness/references/validar-ideia.md +7 -6
  80. package/templates/skills/security-audit/AI-AND-LLM.md +83 -0
  81. package/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
  82. package/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
  83. package/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
  84. package/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
  85. package/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
  86. package/templates/skills/security-audit/HUNTING.md +251 -0
  87. package/templates/skills/security-audit/LICENSE +21 -0
  88. package/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
  89. package/templates/skills/security-audit/ORIGEM.md +51 -0
  90. package/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
  91. package/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
  92. package/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
  93. package/templates/skills/security-audit/SKILL.md +192 -0
  94. package/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
  95. package/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
  96. package/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
  97. package/templates/skills/security-audit/report-schema.json +461 -0
  98. package/templates/skills/security-audit/validate-coverage-ledger.cjs +872 -0
  99. package/templates/skills/security-audit/validate-findings.cjs +773 -0
  100. package/templates/skills/supabase-postgres-best-practices/CHANGELOG.md +73 -0
  101. package/templates/skills/supabase-postgres-best-practices/LICENSE +21 -0
  102. package/templates/skills/supabase-postgres-best-practices/ORIGEM.md +43 -0
  103. package/templates/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  104. package/templates/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  105. package/templates/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  106. package/templates/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  107. package/templates/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  108. package/templates/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  109. package/templates/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  110. package/templates/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  111. package/templates/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  112. package/templates/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  113. package/templates/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  114. package/templates/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  115. package/templates/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  116. package/templates/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  117. package/templates/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  118. package/templates/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  119. package/templates/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  120. package/templates/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  121. package/templates/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  122. package/templates/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  123. package/templates/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  124. package/templates/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  125. package/templates/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  126. package/templates/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  127. package/templates/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  128. package/templates/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  129. package/templates/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  130. package/templates/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  131. package/templates/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  132. package/templates/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  133. package/templates/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  134. package/templates/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  135. package/templates/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  136. package/templates/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  137. package/templates/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
  138. package/templates/skills/vercel-react-best-practices/AGENTS.md +3810 -0
  139. package/templates/skills/vercel-react-best-practices/ORIGEM.md +39 -0
  140. package/templates/skills/vercel-react-best-practices/README.md +123 -0
  141. package/templates/skills/vercel-react-best-practices/SKILL.md +149 -0
  142. package/templates/skills/vercel-react-best-practices/metadata.json +15 -0
  143. package/templates/skills/vercel-react-best-practices/rules/_sections.md +46 -0
  144. package/templates/skills/vercel-react-best-practices/rules/_template.md +28 -0
  145. package/templates/skills/vercel-react-best-practices/rules/advanced-effect-event-deps.md +56 -0
  146. package/templates/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  147. package/templates/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  148. package/templates/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  149. package/templates/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  150. package/templates/skills/vercel-react-best-practices/rules/async-cheap-condition-before-await.md +37 -0
  151. package/templates/skills/vercel-react-best-practices/rules/async-defer-await.md +82 -0
  152. package/templates/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  153. package/templates/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  154. package/templates/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  155. package/templates/skills/vercel-react-best-practices/rules/bundle-analyzable-paths.md +63 -0
  156. package/templates/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +60 -0
  157. package/templates/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  158. package/templates/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  159. package/templates/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  160. package/templates/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  161. package/templates/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  162. package/templates/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  163. package/templates/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  164. package/templates/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  165. package/templates/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  166. package/templates/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  167. package/templates/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  168. package/templates/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  169. package/templates/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  170. package/templates/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  171. package/templates/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +60 -0
  172. package/templates/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  173. package/templates/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  174. package/templates/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  175. package/templates/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  176. package/templates/skills/vercel-react-best-practices/rules/js-request-idle-callback.md +105 -0
  177. package/templates/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  178. package/templates/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  179. package/templates/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  180. package/templates/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  181. package/templates/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  182. package/templates/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  183. package/templates/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  184. package/templates/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  185. package/templates/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  186. package/templates/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +85 -0
  187. package/templates/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +68 -0
  188. package/templates/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  189. package/templates/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  190. package/templates/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  191. package/templates/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  192. package/templates/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  193. package/templates/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  194. package/templates/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  195. package/templates/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  196. package/templates/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  197. package/templates/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  198. package/templates/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  199. package/templates/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +82 -0
  200. package/templates/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  201. package/templates/skills/vercel-react-best-practices/rules/rerender-split-combined-hooks.md +64 -0
  202. package/templates/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  203. package/templates/skills/vercel-react-best-practices/rules/rerender-use-deferred-value.md +59 -0
  204. package/templates/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  205. package/templates/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  206. package/templates/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  207. package/templates/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  208. package/templates/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  209. package/templates/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  210. package/templates/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +149 -0
  211. package/templates/skills/vercel-react-best-practices/rules/server-no-shared-module-state.md +50 -0
  212. package/templates/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  213. package/templates/skills/vercel-react-best-practices/rules/server-parallel-nested-fetching.md +34 -0
  214. package/templates/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  215. package/templates/skills/vercel-react-native-skills/AGENTS.md +2897 -0
  216. package/templates/skills/vercel-react-native-skills/ORIGEM.md +39 -0
  217. package/templates/skills/vercel-react-native-skills/README.md +165 -0
  218. package/templates/skills/vercel-react-native-skills/SKILL.md +121 -0
  219. package/templates/skills/vercel-react-native-skills/metadata.json +16 -0
  220. package/templates/skills/vercel-react-native-skills/rules/_sections.md +86 -0
  221. package/templates/skills/vercel-react-native-skills/rules/_template.md +28 -0
  222. package/templates/skills/vercel-react-native-skills/rules/animation-derived-value.md +53 -0
  223. package/templates/skills/vercel-react-native-skills/rules/animation-gesture-detector-press.md +95 -0
  224. package/templates/skills/vercel-react-native-skills/rules/animation-gpu-properties.md +65 -0
  225. package/templates/skills/vercel-react-native-skills/rules/design-system-compound-components.md +66 -0
  226. package/templates/skills/vercel-react-native-skills/rules/fonts-config-plugin.md +71 -0
  227. package/templates/skills/vercel-react-native-skills/rules/imports-design-system-folder.md +68 -0
  228. package/templates/skills/vercel-react-native-skills/rules/js-hoist-intl.md +61 -0
  229. package/templates/skills/vercel-react-native-skills/rules/list-performance-callbacks.md +44 -0
  230. package/templates/skills/vercel-react-native-skills/rules/list-performance-function-references.md +132 -0
  231. package/templates/skills/vercel-react-native-skills/rules/list-performance-images.md +53 -0
  232. package/templates/skills/vercel-react-native-skills/rules/list-performance-inline-objects.md +97 -0
  233. package/templates/skills/vercel-react-native-skills/rules/list-performance-item-expensive.md +94 -0
  234. package/templates/skills/vercel-react-native-skills/rules/list-performance-item-memo.md +82 -0
  235. package/templates/skills/vercel-react-native-skills/rules/list-performance-item-types.md +104 -0
  236. package/templates/skills/vercel-react-native-skills/rules/list-performance-virtualize.md +67 -0
  237. package/templates/skills/vercel-react-native-skills/rules/monorepo-native-deps-in-app.md +46 -0
  238. package/templates/skills/vercel-react-native-skills/rules/monorepo-single-dependency-versions.md +63 -0
  239. package/templates/skills/vercel-react-native-skills/rules/navigation-native-navigators.md +188 -0
  240. package/templates/skills/vercel-react-native-skills/rules/react-compiler-destructure-functions.md +50 -0
  241. package/templates/skills/vercel-react-native-skills/rules/react-compiler-reanimated-shared-values.md +48 -0
  242. package/templates/skills/vercel-react-native-skills/rules/react-state-dispatcher.md +91 -0
  243. package/templates/skills/vercel-react-native-skills/rules/react-state-fallback.md +56 -0
  244. package/templates/skills/vercel-react-native-skills/rules/react-state-minimize.md +65 -0
  245. package/templates/skills/vercel-react-native-skills/rules/rendering-no-falsy-and.md +74 -0
  246. package/templates/skills/vercel-react-native-skills/rules/rendering-text-in-text-component.md +36 -0
  247. package/templates/skills/vercel-react-native-skills/rules/scroll-position-no-state.md +82 -0
  248. package/templates/skills/vercel-react-native-skills/rules/state-ground-truth.md +80 -0
  249. package/templates/skills/vercel-react-native-skills/rules/ui-expo-image.md +66 -0
  250. package/templates/skills/vercel-react-native-skills/rules/ui-image-gallery.md +104 -0
  251. package/templates/skills/vercel-react-native-skills/rules/ui-measure-views.md +78 -0
  252. package/templates/skills/vercel-react-native-skills/rules/ui-menus.md +174 -0
  253. package/templates/skills/vercel-react-native-skills/rules/ui-native-modals.md +77 -0
  254. package/templates/skills/vercel-react-native-skills/rules/ui-pressable.md +61 -0
  255. package/templates/skills/vercel-react-native-skills/rules/ui-safe-area-scroll.md +65 -0
  256. package/templates/skills/vercel-react-native-skills/rules/ui-scrollview-content-inset.md +45 -0
  257. package/templates/skills/vercel-react-native-skills/rules/ui-styling.md +87 -0
@@ -1,12 +1,20 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { basename, dirname, extname, join, resolve } from 'node:path';
3
+ import { readConfig } from '../config/config.js';
3
4
  import { acharRaiz } from '../raiz.js';
5
+ import { git } from '../trabalhos/arquivar.js';
6
+ import { acharUnitsFontdata, CAMINHO_CATALOGO, estadoDoCatalogo, gerarCatalogo, pastasDoSearchPath } from './catalogo.js';
4
7
  import { classificarRes, detectarDelphi, emRepositorioGit } from './classificar.js';
8
+ import { casaGlob, checarArquivo, converterParaUtf8Bom, detectarEncoding, detectarEol, EXTENSOES_CONVERTER, EXTENSOES_DELPHI, } from './encoding.js';
5
9
  import { extrairIcone } from './icone.js';
6
10
  import { lerRes } from './res.js';
7
11
  const USO = `Uso:
8
12
  npx @fontdata/ai-harness delphi classificar [raiz] [--json]
9
- npx @fontdata/ai-harness delphi extrair-icone <arquivo.res> [--saida <arquivo.ico>]`;
13
+ npx @fontdata/ai-harness delphi extrair-icone <arquivo.res> [--saida <arquivo.ico>]
14
+ npx @fontdata/ai-harness delphi encoding detectar <arquivos...|--todos>
15
+ npx @fontdata/ai-harness delphi encoding converter <arquivos .pas/.dpr/.dpk/.inc...>
16
+ npx @fontdata/ai-harness delphi encoding checar <arquivos...|--todos>
17
+ npx @fontdata/ai-harness delphi catalogo [--pasta <dir> ...] [--check]`;
10
18
  function classificar(args) {
11
19
  const json = args.includes('--json');
12
20
  const posicionais = args.filter((arg) => arg !== '--json');
@@ -65,12 +73,146 @@ function extrairIconeDoRes(args) {
65
73
  console.log(`Ícone MAINICON gravado em ${destino}.`);
66
74
  return 0;
67
75
  }
76
+ /** Com `--todos`, os fontes Delphi versionados da raiz fora de `delphi.ignorar`; senão, os arquivos pedidos. */
77
+ function fontesPedidas(args) {
78
+ if (!args.includes('--todos'))
79
+ return args.map((nome) => ({ nome, caminho: resolve(process.cwd(), nome) }));
80
+ const raiz = acharRaiz();
81
+ const saida = git(raiz, ['ls-files', '-z', '--', ...EXTENSOES_DELPHI.map((ext) => `:(icase)*${ext}`)]);
82
+ if (saida === null) {
83
+ console.error('Não é um repositório git: --todos precisa do git ls-files.');
84
+ return null;
85
+ }
86
+ const { ignorar } = readConfig(raiz).config.delphi;
87
+ return saida
88
+ .split('\0')
89
+ .filter((nome) => nome && !casaGlob(nome, ignorar) && existsSync(join(raiz, nome)))
90
+ .map((nome) => ({ nome, caminho: join(raiz, nome) }));
91
+ }
92
+ function lerFonte(fonte) {
93
+ try {
94
+ return readFileSync(fonte.caminho);
95
+ }
96
+ catch (erro) {
97
+ const mensagem = erro instanceof Error ? erro.message : String(erro);
98
+ console.error(`Não foi possível ler ${fonte.nome}: ${mensagem}`);
99
+ return null;
100
+ }
101
+ }
102
+ function detectar(fontes) {
103
+ let codigo = 0;
104
+ for (const fonte of fontes) {
105
+ const bytes = lerFonte(fonte);
106
+ if (!bytes) {
107
+ codigo = 1;
108
+ continue;
109
+ }
110
+ const encoding = detectarEncoding(bytes);
111
+ console.log(encoding === 'dfm-binario' ? `${fonte.nome}: ${encoding}` : `${fonte.nome}: ${encoding}, ${detectarEol(bytes)}`);
112
+ }
113
+ return codigo;
114
+ }
115
+ function converter(fontes) {
116
+ const recusadas = fontes.filter((fonte) => !EXTENSOES_CONVERTER.includes(extname(fonte.nome).toLowerCase()));
117
+ if (recusadas.length > 0) {
118
+ for (const fonte of recusadas) {
119
+ console.error(`${fonte.nome}: só .pas, .dpr, .dpk e .inc são convertidos; o encoding do .dfm é preservado.`);
120
+ }
121
+ return 1;
122
+ }
123
+ let codigo = 0;
124
+ for (const fonte of fontes) {
125
+ const bytes = lerFonte(fonte);
126
+ if (!bytes) {
127
+ codigo = 1;
128
+ continue;
129
+ }
130
+ const antes = detectarEncoding(bytes);
131
+ const convertido = converterParaUtf8Bom(bytes);
132
+ if (convertido === bytes) {
133
+ console.log(`${fonte.nome}: já está em UTF-8 com BOM, nada alterado.`);
134
+ continue;
135
+ }
136
+ writeFileSync(fonte.caminho, convertido);
137
+ console.log(`${fonte.nome}: ${antes} -> utf8-bom (EOL preservado).`);
138
+ }
139
+ return codigo;
140
+ }
141
+ function checar(fontes) {
142
+ let codigo = 0;
143
+ let achados = 0;
144
+ for (const fonte of fontes) {
145
+ const bytes = lerFonte(fonte);
146
+ if (!bytes) {
147
+ codigo = 1;
148
+ continue;
149
+ }
150
+ for (const problema of checarArquivo(fonte.nome, bytes)) {
151
+ console.log(`${fonte.nome}:${problema.linha}: ${problema.mensagem}`);
152
+ achados++;
153
+ }
154
+ }
155
+ console.log(achados === 0 ? `Nenhum problema de encoding em ${fontes.length} arquivo(s).` : `${achados} problema(s) de encoding.`);
156
+ return achados > 0 ? 1 : codigo;
157
+ }
158
+ function encoding(args) {
159
+ const [sub, ...resto] = args;
160
+ const acao = sub === 'detectar' ? detectar : sub === 'converter' ? converter : sub === 'checar' ? checar : undefined;
161
+ const todos = resto.includes('--todos');
162
+ if (!acao || resto.length === 0 || (todos && (sub === 'converter' || resto.length > 1))) {
163
+ console.error(USO);
164
+ return 1;
165
+ }
166
+ const fontes = fontesPedidas(resto);
167
+ return fontes ? acao(fontes) : 1;
168
+ }
169
+ function catalogo(args) {
170
+ const pastas = [];
171
+ let check = false;
172
+ for (let i = 0; i < args.length; i++) {
173
+ const pasta = args[i] === '--pasta' ? args[++i] : undefined;
174
+ if (pasta)
175
+ pastas.push(resolve(process.cwd(), pasta));
176
+ else if (args[i] === '--check')
177
+ check = true;
178
+ else {
179
+ console.error(USO);
180
+ return 1;
181
+ }
182
+ }
183
+ const raiz = acharRaiz();
184
+ const units = acharUnitsFontdata(pastas.length > 0 ? pastas : pastasDoSearchPath(raiz));
185
+ if (units.length === 0) {
186
+ const onde = pastas.length > 0 ? 'nas pastas informadas' : 'no DCC_UnitSearchPath dos .dproj do projeto';
187
+ console.error(`Nenhuma unit Fontdata.*.pas encontrada ${onde}. Passe --pasta <dir> com a pasta das units.`);
188
+ return 1;
189
+ }
190
+ const destino = join(raiz, CAMINHO_CATALOGO);
191
+ if (check) {
192
+ const estado = estadoDoCatalogo(destino, units);
193
+ if (estado === 'em-dia') {
194
+ console.log(`O catálogo ${CAMINHO_CATALOGO} está em dia com ${units.length} unit(s) Fontdata.`);
195
+ return 0;
196
+ }
197
+ const motivo = estado === 'ausente' ? 'não existe' : 'está desatualizado';
198
+ console.error(`O catálogo ${CAMINHO_CATALOGO} ${motivo}: rode npx @fontdata/ai-harness delphi catalogo.`);
199
+ return 1;
200
+ }
201
+ mkdirSync(dirname(destino), { recursive: true });
202
+ writeFileSync(destino, gerarCatalogo(units));
203
+ console.log(`Catálogo de ${units.length} unit(s) Fontdata gravado em ${CAMINHO_CATALOGO}.`);
204
+ return 0;
205
+ }
68
206
  export async function runDelphiCommand(args) {
69
207
  const [sub, ...resto] = args;
70
208
  if (sub === 'classificar')
71
209
  return classificar(resto);
72
210
  if (sub === 'extrair-icone')
73
211
  return extrairIconeDoRes(resto);
212
+ if (sub === 'encoding')
213
+ return encoding(resto);
214
+ if (sub === 'catalogo')
215
+ return catalogo(resto);
74
216
  console.error(USO);
75
217
  return 1;
76
218
  }
@@ -0,0 +1,112 @@
1
+ export const EXTENSOES_CONVERTER = ['.pas', '.dpr', '.dpk', '.inc'];
2
+ export const EXTENSOES_DELPHI = [...EXTENSOES_CONVERTER, '.dfm'];
3
+ const BOM = Buffer.from([0xef, 0xbb, 0xbf]);
4
+ function temBom(bytes) {
5
+ return bytes.length >= 3 && bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf;
6
+ }
7
+ function utf8Valido(bytes) {
8
+ try {
9
+ new TextDecoder('utf-8', { fatal: true }).decode(bytes);
10
+ return true;
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
16
+ export function detectarEncoding(bytes) {
17
+ if (bytes.subarray(0, 3).equals(Buffer.from([0xff, 0x0a, 0x00])) || bytes.subarray(0, 4).toString('latin1') === 'TPF0') {
18
+ return 'dfm-binario';
19
+ }
20
+ if (temBom(bytes))
21
+ return 'utf8-bom';
22
+ return utf8Valido(bytes) ? 'utf8-sem-bom' : 'cp1252';
23
+ }
24
+ function contarEol(texto) {
25
+ const crlf = texto.match(/\r\n/g)?.length ?? 0;
26
+ const lf = (texto.match(/\n/g)?.length ?? 0) - crlf;
27
+ return { crlf, lf };
28
+ }
29
+ export function detectarEol(bytes) {
30
+ const { crlf, lf } = contarEol(bytes.toString('latin1'));
31
+ if (crlf && lf)
32
+ return 'misto';
33
+ if (crlf)
34
+ return 'crlf';
35
+ return lf ? 'lf' : 'nenhum';
36
+ }
37
+ /** Texto do arquivo sem o BOM: UTF-8 quando é UTF-8 válido, senão CP1252. */
38
+ export function decodificar(bytes) {
39
+ const corpo = temBom(bytes) ? bytes.subarray(3) : bytes;
40
+ return utf8Valido(corpo) ? corpo.toString('utf8') : new TextDecoder('windows-1252').decode(corpo);
41
+ }
42
+ /**
43
+ * Bytes em UTF-8 com BOM. UTF-8 com BOM volta o mesmo Buffer; UTF-8 sem BOM só ganha o BOM; o resto é lido como
44
+ * CP1252. O EOL não muda porque CR e LF são os mesmos bytes nos dois encodings.
45
+ */
46
+ export function converterParaUtf8Bom(bytes) {
47
+ const encoding = detectarEncoding(bytes);
48
+ if (encoding === 'utf8-bom' || encoding === 'dfm-binario')
49
+ return bytes;
50
+ if (encoding === 'utf8-sem-bom')
51
+ return Buffer.concat([BOM, bytes]);
52
+ return Buffer.concat([BOM, Buffer.from(new TextDecoder('windows-1252').decode(bytes), 'utf8')]);
53
+ }
54
+ const SEGUNDO_BYTE_UTF8 = new TextDecoder('windows-1252').decode(Uint8Array.from({ length: 0x40 }, (_, i) => 0x80 + i));
55
+ const DUPLA_CODIFICACAO = new RegExp(`[ÃÂ][${SEGUNDO_BYTE_UTF8.replace(/[\\\]^-]/g, '\\$&')}]|â€`);
56
+ function extensao(caminho) {
57
+ const ponto = caminho.lastIndexOf('.');
58
+ return ponto < 0 ? '' : caminho.slice(ponto).toLowerCase();
59
+ }
60
+ /** Problemas de encoding do arquivo, com a linha (1 em diante); `.dfm` binário não tem nenhum. */
61
+ export function checarArquivo(caminho, bytes) {
62
+ const encoding = detectarEncoding(bytes);
63
+ if (encoding === 'dfm-binario')
64
+ return [];
65
+ const problemas = [];
66
+ if (encoding !== 'utf8-bom' && EXTENSOES_CONVERTER.includes(extensao(caminho))) {
67
+ problemas.push({ linha: 1, mensagem: `BOM ausente (${encoding})` });
68
+ }
69
+ const texto = decodificar(bytes);
70
+ const linhas = texto.split('\n');
71
+ const eol = detectarEol(bytes);
72
+ const { crlf, lf } = contarEol(texto);
73
+ const eolMaioria = lf > crlf ? 'lf' : 'crlf';
74
+ linhas.forEach((linha, i) => {
75
+ const numero = i + 1;
76
+ if (linha.includes('�'))
77
+ problemas.push({ linha: numero, mensagem: 'caractere U+FFFD' });
78
+ const dupla = linha.match(DUPLA_CODIFICACAO);
79
+ if (dupla)
80
+ problemas.push({ linha: numero, mensagem: `dupla codificação ('${dupla[0]}')` });
81
+ if (eol === 'misto' && i < linhas.length - 1 && (linha.endsWith('\r') ? 'crlf' : 'lf') !== eolMaioria) {
82
+ problemas.push({ linha: numero, mensagem: `EOL misto (${eolMaioria === 'crlf' ? 'LF' : 'CRLF'} num arquivo ${eolMaioria.toUpperCase()})` });
83
+ }
84
+ });
85
+ return problemas;
86
+ }
87
+ function globParaRegex(glob) {
88
+ let fonte = '';
89
+ for (let i = 0; i < glob.length; i++) {
90
+ if (glob.startsWith('**/', i)) {
91
+ fonte += '(?:.*/)?';
92
+ i += 2;
93
+ }
94
+ else if (glob.startsWith('**', i)) {
95
+ fonte += '.*';
96
+ i += 1;
97
+ }
98
+ else if (glob[i] === '*')
99
+ fonte += '[^/]*';
100
+ else
101
+ fonte += glob[i].replace(/[.+?^${}()|[\]\\]/g, '\\$&');
102
+ }
103
+ return new RegExp(`^${fonte}$`, 'i');
104
+ }
105
+ /**
106
+ * Se o caminho relativo casa com algum glob: `**` vale qualquer profundidade (inclusive zero pastas) e `*` fica dentro
107
+ * de um segmento. Barra invertida conta como separador e a comparação ignora maiúsculas, como no Windows.
108
+ */
109
+ export function casaGlob(caminho, padroes) {
110
+ const normalizado = caminho.replace(/\\/g, '/').replace(/^\.\//, '');
111
+ return padroes.some((padrao) => globParaRegex(padrao.replace(/\\/g, '/')).test(normalizado));
112
+ }
@@ -8,6 +8,7 @@ import { COMMENTS_HOOK_PATH, hookProprioRegistrado } from '../comentarios/instal
8
8
  import { CONFIG_PATH, readConfig } from '../config/config.js';
9
9
  import { ARCHIVE_DIR_NAME, ARTIFACT_TYPES, listWorkFiles, readArtifact, validateAllWorks, WORKS_DIR } from '../contratos/artefatos.js';
10
10
  import { validateEventLog } from '../contratos/eventos.js';
11
+ import { CAMINHO_CATALOGO, checarCatalogo } from '../delphi/catalogo.js';
11
12
  import { classificarRes } from '../delphi/classificar.js';
12
13
  import { hashContent, LOCK_PATH, LOCK_VERSION } from '../install/lock.js';
13
14
  import { agentsForaDoLock, itemSources } from '../install/plan.js';
@@ -264,6 +265,23 @@ function checkDelphiRes(root) {
264
265
  correcao: 'Rode a etapa `/harness ignores` para classificar, extrair o ícone se preciso e tirar o .res do versionamento com aprovação.',
265
266
  }));
266
267
  }
268
+ function checkCatalogoFontdata(root, lock) {
269
+ if (!lock.itens.some((item) => item.tipo === 'perfil' && item.id === 'delphi'))
270
+ return [];
271
+ const estado = checarCatalogo(root);
272
+ if (estado !== 'ausente' && estado !== 'desatualizado')
273
+ return [];
274
+ return [
275
+ {
276
+ id: `catalogo-fontdata-${estado}`,
277
+ severidade: 'aviso',
278
+ mensagem: estado === 'ausente'
279
+ ? `O search path do projeto tem units Fontdata.*, mas o catálogo ${CAMINHO_CATALOGO} não existe.`
280
+ : `O catálogo ${CAMINHO_CATALOGO} não bate com as units Fontdata.* do search path.`,
281
+ correcao: 'Rode `npx @fontdata/ai-harness delphi catalogo` para gerar o catálogo de novo.',
282
+ },
283
+ ];
284
+ }
267
285
  function checkWorks(root) {
268
286
  return validateAllWorks(root).map((problem) => ({
269
287
  id: `contrato-${problem.regra}`,
@@ -655,7 +673,7 @@ export function runDoctor(root, options = {}) {
655
673
  return [
656
674
  ...checkNode(options.nodeVersion ?? process.versions.node),
657
675
  ...lockFindings,
658
- ...(lock ? [...checkFiles(root, lock), ...checkRequiredSkills(root, lock), ...checkMissingHarnessAgents(root, lock), ...checkComments(root, lock, config)] : []),
676
+ ...(lock ? [...checkFiles(root, lock), ...checkRequiredSkills(root, lock), ...checkMissingHarnessAgents(root, lock), ...checkComments(root, lock, config), ...checkCatalogoFontdata(root, lock)] : []),
659
677
  ...checkShadowedCommands(root),
660
678
  ...checkOldCommentsBlock(root),
661
679
  ...checkAgents(root),
package/dist/init.js CHANGED
@@ -12,6 +12,20 @@ import { detectProjectKind } from './install/selection.js';
12
12
  export { detectProjectKind, neededSkillsFor, resolveSelection } from './install/selection.js';
13
13
  const PLUGIN_HOOKS_NOTE = 'O plugin fontdata@ai-harness está habilitado: os hooks já rodam por ele e não foram instalados no projeto, para não rodarem duas vezes.';
14
14
  const PLUGIN_MCP_NOTE = 'O plugin fontdata@ai-harness está habilitado: o servidor MCP de banco já roda por ele e não foi registrado no .mcp.json, para não duplicar.';
15
+ const PERFIL_DELPHI_NOTE = 'Perfil Delphi instalado (projeto Delphi detectado): rules em .claude/rules/delphi/, a skill conhecimento-delphi e o ' +
16
+ 'hook de encoding em .claude/hooks/delphi/, registrado em .claude/settings.json; para recusar, use perfis.delphi: false ' +
17
+ 'no .ai-harness/config.json.';
18
+ const PERFIL_FISCAL_NOTE = 'Perfil delphi-fiscal instalado (projeto usa ACBr): rules em .claude/rules/delphi-fiscal/ e as skills patch-acbr e ' +
19
+ "diagnosticar-rejeicao-nfse; para recusar, use perfis[\"delphi-fiscal\"]: false no .ai-harness/config.json.";
20
+ function resumo(plan, skippedForPlugin = false) {
21
+ const fiscal = plan.items.some((item) => item.tipo === 'perfil' && item.id === 'delphi-fiscal');
22
+ return [
23
+ describePlan(plan),
24
+ ...(skippedForPlugin ? [PLUGIN_HOOKS_NOTE] : []),
25
+ ...(plan.registerPerfilDelphi ? [PERFIL_DELPHI_NOTE] : []),
26
+ ...(fiscal ? [PERFIL_FISCAL_NOTE] : []),
27
+ ].join(EOL + EOL);
28
+ }
15
29
  /** Registra o MCP de banco no .mcp.json quando não foi recusado (flag, wizard ou config) e o plugin não o fornece. */
16
30
  export function decidirRegistroMcp(options, root, home = homedir()) {
17
31
  return options.mcpBanco && readConfig(root).config.banco_dados.registrar_mcp && !isHarnessPluginEnabled(root, home);
@@ -110,7 +124,7 @@ function runNonInteractive(args) {
110
124
  options.hooks = false;
111
125
  const plan = planInstall(catalog, repoPath, options);
112
126
  applyMcpDecision(plan, options, repoPath);
113
- const summary = [describePlan(plan), ...(skippedForPlugin ? [PLUGIN_HOOKS_NOTE] : [])].join(EOL + EOL);
127
+ const summary = resumo(plan, skippedForPlugin);
114
128
  if (!args.yes) {
115
129
  console.log(`Simulação — nada foi gravado em ${repoPath}.\n\n${summary}\n\nRode de novo com --yes para aplicar.`);
116
130
  return;
@@ -252,7 +266,7 @@ async function runWizard(args) {
252
266
  executePlan(repoPath, plan, packageInfo());
253
267
  prepareProjectFiles(repoPath);
254
268
  s.stop('Instalação concluída.');
255
- p.note(describePlan(plan), `Resumo · ${repoPath}`);
269
+ p.note(resumo(plan), `Resumo · ${repoPath}`);
256
270
  p.outro('Abra o projeto no Claude Code e digite "/" para ver os comandos instalados.');
257
271
  }
258
272
  export async function runInit(argv = []) {
@@ -0,0 +1,21 @@
1
+ import { PERFIS_DO_CONFIG } from '../config/config.js';
2
+ import { detectarAcbr, detectarDelphi } from '../delphi/classificar.js';
3
+ export const PERFIS = PERFIS_DO_CONFIG;
4
+ export const PERFIL_DELPHI_HOOK_COMMAND = 'node "${CLAUDE_PROJECT_DIR}/.claude/hooks/delphi/encoding.mjs"';
5
+ /** Perfis que o projeto recebe: a stack foi detectada e o config não guarda a recusa. O fiscal depende do Delphi. */
6
+ export function perfisDoProjeto(root, config) {
7
+ if (!config.perfis.delphi || !detectarDelphi(root))
8
+ return [];
9
+ return config.perfis['delphi-fiscal'] && detectarAcbr(root) ? ['delphi', 'delphi-fiscal'] : ['delphi'];
10
+ }
11
+ /** A recusa do perfil no config; a do Delphi recusa também o fiscal. */
12
+ export function perfilRecusadoNoConfig(perfil, config) {
13
+ return !config.perfis.delphi || !config.perfis[perfil];
14
+ }
15
+ export function perfilDelphiHooksConfig() {
16
+ const hooks = () => [{ type: 'command', command: PERFIL_DELPHI_HOOK_COMMAND }];
17
+ return {
18
+ PreToolUse: [{ matcher: 'Edit|MultiEdit', hooks: hooks() }],
19
+ PostToolUse: [{ matcher: 'Write|Edit|MultiEdit', hooks: hooks() }],
20
+ };
21
+ }
@@ -7,8 +7,9 @@ import { buildLockItem, hashContent, LOCK_VERSION, readLock, writeLock } from '.
7
7
  import { HOOKS_ITEM_ID, PROJECT_HOOKS_DIR, projectHooksConfig } from './hooks.js';
8
8
  import { neededSkillsFor, resolveSelection } from './selection.js';
9
9
  import { BANCO_MCP_NOME, bancoMcpServer, MCP_PATH, mergeMcpServers } from './mcp.js';
10
- import { gravarInstalarComentarios, gravarRegistrarMcp } from '../config/config.js';
10
+ import { gravarInstalarComentarios, gravarRegistrarMcp, readConfig } from '../config/config.js';
11
11
  import { COMMENTS_RULE_PATH, commentsHooksConfig, ensureCommentsBaseline, hookProprio, hookProprioRegistrado } from '../comentarios/instalar.js';
12
+ import { perfilDelphiHooksConfig, perfisDoProjeto } from './perfis.js';
12
13
  import { combineHooks, HARNESS_DENY, harnessPermissions, mergeSettings } from './settings.js';
13
14
  /** Rule de convenção com o que é específico do projeto (D-38): é do projeto, então fica fora do lock. */
14
15
  export const PROJECT_RULE_PATH = '.claude/rules/harness-projeto.md';
@@ -76,11 +77,31 @@ export function itemSources(catalog, tipo, id) {
76
77
  if (tipo === 'rule' && id === 'comentarios') {
77
78
  return [{ path: COMMENTS_RULE_PATH, source: join(templatesDir, 'rules', 'comentarios.md') }];
78
79
  }
80
+ if (tipo === 'perfil') {
81
+ const perfil = catalog.perfis?.find((candidate) => candidate.id === id);
82
+ if (!perfil)
83
+ return null;
84
+ const base = join(templatesDir, perfil.dir);
85
+ return listFiles(base).flatMap((rel) => {
86
+ const destino = perfilDestino(id, rel);
87
+ return destino ? [{ path: destino, source: join(base, rel) }] : [];
88
+ });
89
+ }
79
90
  if (tipo === 'hook' && id === 'comentarios') {
80
91
  return [{ path: '.claude/hooks/comentarios/check.mjs', source: join(templatesDir, 'hooks', 'comentarios', 'check.mjs') }];
81
92
  }
82
93
  return null;
83
94
  }
95
+ /** Rules e hooks do perfil ficam numa subpasta com o id dele; as skills mantêm o próprio nome. */
96
+ function perfilDestino(id, rel) {
97
+ const [pasta, ...resto] = rel.split('/');
98
+ const caminho = resto.join('/');
99
+ if (pasta === 'rules' || pasta === 'hooks')
100
+ return `.claude/${pasta}/${id}/${caminho}`;
101
+ if (pasta === 'skills')
102
+ return `.claude/skills/${caminho}`;
103
+ return null;
104
+ }
84
105
  /** Agents do catálogo que o lock não tem. Lock sem nenhum agent é a recusa do `--sem-agents`: nada falta. */
85
106
  export function agentsForaDoLock(catalog, lock) {
86
107
  const noLock = new Set(lock.itens.filter((item) => item.tipo === 'agent').map((item) => item.id));
@@ -160,6 +181,12 @@ export function planInstall(catalog, root, options) {
160
181
  if (options.agents)
161
182
  for (const agent of catalog.agents ?? [])
162
183
  add('agent', agent.id);
184
+ // O perfil não depende de options.hooks: o plugin e o --sem-hooks tratam só dos hooks do pacote.
185
+ for (const perfil of perfisDoProjeto(root, readConfig(root).config)) {
186
+ add('perfil', perfil);
187
+ if (perfil === 'delphi')
188
+ plan.registerPerfilDelphi = true;
189
+ }
163
190
  if (plan.registerComments) {
164
191
  add('rule', 'comentarios');
165
192
  add('hook', 'comentarios');
@@ -191,7 +218,7 @@ export function executePlan(root, plan, pkg, now = new Date()) {
191
218
  }
192
219
  applyAtomically(root, plan.files);
193
220
  const permission = needsEventPermission(plan);
194
- const hooks = combineHooks(plan.registerHooks ? projectHooksConfig() : {}, plan.registerComments ? commentsHooksConfig() : {});
221
+ const hooks = combineHooks(plan.registerHooks ? projectHooksConfig() : {}, plan.registerComments ? commentsHooksConfig() : {}, plan.registerPerfilDelphi ? perfilDelphiHooksConfig() : {});
195
222
  if (Object.keys(hooks).length || permission) {
196
223
  mergeSettings(root, { hooks, allow: permission ? harnessPermissions({ banco: bancoAtivo(plan) }) : [], deny: permission ? HARNESS_DENY : [] }, now);
197
224
  }
@@ -101,6 +101,38 @@ export function hookCommands(hooks) {
101
101
  export function normalizarComandoHook(command) {
102
102
  return command.replace(/\$CLAUDE_PROJECT_DIR\b/g, '${CLAUDE_PROJECT_DIR}');
103
103
  }
104
+ /**
105
+ * Tira de `hooks` as entradas com esses comandos, nas duas grafias de `CLAUDE_PROJECT_DIR`, e apaga os grupos, os
106
+ * eventos e a chave `hooks` que ficarem vazios. As outras chaves e os valores fora do formato esperado ficam como estão.
107
+ */
108
+ export function removeHookCommands(settings, comandos) {
109
+ if (!isPlainObject(settings.hooks))
110
+ return settings;
111
+ const remover = new Set(comandos.map(normalizarComandoHook));
112
+ const hooks = {};
113
+ let removido = false;
114
+ for (const [event, groups] of Object.entries(settings.hooks)) {
115
+ if (!Array.isArray(groups)) {
116
+ hooks[event] = groups;
117
+ continue;
118
+ }
119
+ const restantes = groups.flatMap((group) => {
120
+ if (!isPlainObject(group) || !Array.isArray(group.hooks))
121
+ return [group];
122
+ const mantidos = group.hooks.filter((hook) => !(isPlainObject(hook) && typeof hook.command === 'string' && remover.has(normalizarComandoHook(hook.command))));
123
+ if (mantidos.length === group.hooks.length)
124
+ return [group];
125
+ removido = true;
126
+ return mantidos.length ? [{ ...group, hooks: mantidos }] : [];
127
+ });
128
+ if (restantes.length || !groups.length)
129
+ hooks[event] = restantes;
130
+ }
131
+ if (!removido)
132
+ return settings;
133
+ const { hooks: _hooks, ...resto } = settings;
134
+ return (Object.keys(hooks).length ? { ...resto, hooks } : resto);
135
+ }
104
136
  export function mergeHooksIntoSettings(root, hooks, now = new Date()) {
105
137
  return mergeSettings(root, { hooks }, now);
106
138
  }
@@ -109,7 +141,7 @@ export function mergeHooksIntoSettings(root, hooks, now = new Date()) {
109
141
  * sem perder o que já existe. Um hook é considerado presente quando algum grupo do mesmo
110
142
  * evento já tem o mesmo `command`, nas duas grafias de `CLAUDE_PROJECT_DIR`, e uma regra quando já está na lista, o que torna a
111
143
  * operação idempotente. As regras de `removeAllow` saem de `permissions.allow`. Tudo é gravado de uma vez, com um único backup datado do arquivo
112
- * original; JSON inválido é recusado sem tocar em nada.
144
+ * original; JSON inválido é recusado sem tocar em nada. Os hooks de `removeHooks` saem antes dos acréscimos.
113
145
  */
114
146
  export function mergeSettings(root, additions, now = new Date()) {
115
147
  const file = join(root, SETTINGS_PATH);
@@ -136,11 +168,16 @@ export function mergeSettings(root, additions, now = new Date()) {
136
168
  }
137
169
  settings = parsed;
138
170
  }
139
- const next = { ...settings };
171
+ let next = { ...settings };
140
172
  let changed = false;
173
+ if (additions.removeHooks?.length) {
174
+ const semComandos = removeHookCommands(next, additions.removeHooks);
175
+ changed = semComandos !== next;
176
+ next = semComandos;
177
+ }
141
178
  const hookEntries = Object.entries(additions.hooks ?? {});
142
179
  if (hookEntries.length) {
143
- const merged = { ...(settings.hooks ?? {}) };
180
+ const merged = { ...(next.hooks ?? {}) };
144
181
  for (const [event, groups] of hookEntries) {
145
182
  const eventGroups = [...(merged[event] ?? [])];
146
183
  const known = new Set(hookCommands({ [event]: eventGroups }).map(normalizarComandoHook));
@@ -1,4 +1,4 @@
1
- function semComentariosPascal(texto) {
1
+ export function semComentariosPascal(texto) {
2
2
  return texto.replace(/\{[^}]*\}|\(\*[\s\S]*?\*\)|\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ' '));
3
3
  }
4
4
  function simbolosPascal(texto) {