jarvis-ai-framework 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/AGENTS.md +22 -122
  2. package/agents/AGENTS.md +20 -24
  3. package/agents/README.md +25 -129
  4. package/agents/engineering/data/eng.data-engineer.agent.md +12 -35
  5. package/agents/engineering/eng.agent.md +18 -30
  6. package/agents/engineering/eng.bug-hunter.md +9 -12
  7. package/agents/engineering/eng.dev-code-reviewer.md +5 -1
  8. package/agents/engineering/eng.docs-writer.md +3 -3
  9. package/agents/engineering/eng.frontend.agent.md +13 -8
  10. package/agents/engineering/eng.rpa.agent.md +5 -13
  11. package/agents/engineering/eng.ux-designer.agent.md +4 -0
  12. package/agents/engineering/qa/eng.qa.quality-champion-task-agent.md +4 -0
  13. package/agents/engineering/qa/eng.qa.quality-strategist.md +13 -8
  14. package/agents/engineering/qa/eng.qa.test-architect.md +16 -15
  15. package/agents/engineering/qa/eng.qa.test-planner.md +22 -17
  16. package/agents/engineering/qa/eng.qa.testing-engineer.md +99 -15
  17. package/agents/product/prod.discovery-interviewer.md +22 -3
  18. package/agents/product/prod.pm-checker.md +4 -0
  19. package/bin/README.md +142 -0
  20. package/bin/commands/docs-publish.js +105 -141
  21. package/bin/commands/docs-sync.js +66 -104
  22. package/bin/commands/info.js +7 -27
  23. package/bin/commands/init.js +23 -51
  24. package/bin/commands/install-rtk.js +9 -3
  25. package/bin/commands/list.js +5 -18
  26. package/bin/commands/map.js +58 -0
  27. package/bin/commands/qa-signoff.js +58 -55
  28. package/bin/commands/tokens.js +90 -0
  29. package/bin/commands/whoami.js +30 -26
  30. package/bin/jarvis.js +9 -153
  31. package/bin/lib/auth/session.js +20 -20
  32. package/bin/lib/cli/program.js +219 -0
  33. package/bin/lib/cli/shared-options.js +29 -0
  34. package/bin/lib/config/constants.js +70 -2
  35. package/bin/lib/config/ide-config.js +4 -8
  36. package/bin/lib/core/profile-filter.js +116 -0
  37. package/bin/lib/core/scanner.js +5 -31
  38. package/bin/lib/core/sync-engine.js +21 -14
  39. package/bin/lib/core/token-report.js +100 -0
  40. package/bin/lib/docs/fetch-file.js +39 -0
  41. package/bin/lib/docs/publish-file.js +194 -0
  42. package/bin/lib/docs/redis-cache.js +49 -0
  43. package/bin/lib/docs/validate-frontmatter.js +9 -39
  44. package/bin/lib/env-loader.js +11 -34
  45. package/bin/lib/flow-map/index.js +65 -0
  46. package/bin/lib/flow-map/parse.js +223 -0
  47. package/bin/lib/flow-map/render.js +89 -0
  48. package/bin/lib/flow-map/tree.js +248 -0
  49. package/bin/lib/tasks/comment.js +40 -35
  50. package/bin/lib/utils/frontmatter.js +57 -0
  51. package/bin/lib/utils/git-parser.js +4 -6
  52. package/bin/lib/utils/npmrc-parser.js +6 -13
  53. package/bin/lib/utils/paths.js +2 -4
  54. package/bin/lib/utils/ui.js +3 -9
  55. package/bin/lib/vcs/api.js +25 -41
  56. package/bin/lib/vcs/create-issue.js +49 -33
  57. package/bin/lib/vcs/create-merge.js +47 -31
  58. package/bin/lib/vcs/fetch-raw.js +35 -23
  59. package/members.md +1 -1
  60. package/package.json +15 -4
  61. package/rules/AGENTS.md +18 -7
  62. package/rules/engineering/eng-rules.md +3 -13
  63. package/rules/engineering/eng-security-rules.md +19 -18
  64. package/rules/engineering/eng.bump-rules.md +3 -2
  65. package/rules/engineering/eng.docs-scraping-rules.md +4 -4
  66. package/rules/engineering/eng.integrations-rules.md +3 -7
  67. package/rules/engineering/eng.skills-rules.md +1 -5
  68. package/rules/engineering/eng.specializations-rules.md +18 -8
  69. package/rules/engineering/frontend/eng.frontend-rules.md +1 -4
  70. package/rules/engineering/qa/eng.qa.cypress-standards-rules.md +1 -1
  71. package/rules/engineering/rpa/eng.rpa-rules.md +4 -9
  72. package/rules/product/README.md +1 -0
  73. package/rules/product/prod-rules.md +1 -4
  74. package/rules/product/prod.spec-rules.md +0 -4
  75. package/rules/rtk-rules.md +0 -1
  76. package/{rules → rules-on-demand}/engineering/eng.breakdown-subtasks-rules.md +0 -4
  77. package/{rules → rules-on-demand}/engineering/eng.plan-rules.md +0 -4
  78. package/{rules → rules-on-demand}/engineering/eng.pr-rules.md +0 -4
  79. package/{rules → rules-on-demand}/engineering/eng.pre-pr-rules.md +0 -4
  80. package/{rules → rules-on-demand}/engineering/eng.start-rules.md +0 -4
  81. package/{rules → rules-on-demand}/engineering/eng.tech-spec-rules.md +1 -2
  82. package/{rules → rules-on-demand}/engineering/eng.work-rules.md +0 -4
  83. package/skills/AGENTS.md +69 -106
  84. package/skills/SKILLS-ROADMAP.md +47 -132
  85. package/skills/eng-ai/SKILL.md +270 -0
  86. package/skills/eng-ai/references/1-fundamentos-ml.md +24 -0
  87. package/skills/eng-ai/references/10-arquitetura-solucoes-ia.md +24 -0
  88. package/skills/eng-ai/references/11-governanca-ia.md +24 -0
  89. package/skills/eng-ai/references/12-seguranca-ia-responsavel.md +25 -0
  90. package/skills/eng-ai/references/2-matematica-estatistica.md +24 -0
  91. package/skills/eng-ai/references/3-dados-para-ia.md +24 -0
  92. package/skills/eng-ai/references/4-deep-learning-fundacionais.md +24 -0
  93. package/skills/eng-ai/references/5-llms-chatbots-agentes-rag.md +25 -0
  94. package/skills/eng-ai/references/6-avaliacao-experimentacao.md +24 -0
  95. package/skills/eng-ai/references/7-engenharia-sistemas-ia.md +24 -0
  96. package/skills/eng-ai/references/8-mlops-plataforma.md +24 -0
  97. package/skills/eng-ai/references/9-produto-ia.md +24 -0
  98. package/skills/eng-ai/references/especializacoes.md +17 -0
  99. package/skills/eng-automation/SKILL.md +290 -0
  100. package/skills/eng-automation/references/1-fundamentos-automacao.md +25 -0
  101. package/skills/eng-automation/references/10-ingestao-dados.md +25 -0
  102. package/skills/eng-automation/references/11-captcha-antibot.md +25 -0
  103. package/skills/eng-automation/references/12-limites-taxa-sessoes.md +25 -0
  104. package/skills/eng-automation/references/13-agendamento-orquestracao.md +24 -0
  105. package/skills/eng-automation/references/14-retentativa-erros.md +25 -0
  106. package/skills/eng-automation/references/15-autenticacao-credenciais.md +24 -0
  107. package/skills/eng-automation/references/16-observabilidade-confiabilidade.md +24 -0
  108. package/skills/eng-automation/references/2-aquisicao-dados.md +25 -0
  109. package/skills/eng-automation/references/3-automacao-navegador.md +24 -0
  110. package/skills/eng-automation/references/4-scraping-crawling.md +25 -0
  111. package/skills/eng-automation/references/5-apis-rest-graphql-soap.md +26 -0
  112. package/skills/eng-automation/references/6-webhooks-integracao.md +25 -0
  113. package/skills/eng-automation/references/7-rpa.md +25 -0
  114. package/skills/eng-automation/references/8-extracao-estruturada.md +25 -0
  115. package/skills/eng-automation/references/9-extracao-documentos.md +25 -0
  116. package/skills/eng-automation/references/especializacoes.md +18 -0
  117. package/skills/eng-backend/SKILL.md +6 -0
  118. package/skills/eng-backend-arch-c4/SKILL.md +10 -4
  119. package/skills/eng-backend-microservices-trace/SKILL.md +6 -0
  120. package/skills/eng-backend-nestjs/SKILL.md +17 -462
  121. package/skills/eng-backend-nestjs/references/1-arquitetura-modulos.md +54 -0
  122. package/skills/eng-backend-nestjs/references/2-guards-autenticacao.md +118 -0
  123. package/skills/eng-backend-nestjs/references/3-interceptors-pipes-filters.md +113 -0
  124. package/skills/eng-backend-nestjs/references/4-config-logging.md +61 -0
  125. package/skills/eng-backend-nestjs/references/5-testes.md +83 -0
  126. package/skills/eng-backend-nestjs/references/6-problemas-comuns.md +53 -0
  127. package/skills/eng-backend-rabbitmq/SKILL.md +15 -298
  128. package/skills/eng-backend-rabbitmq/references/1-referencia-endpoints.md +28 -0
  129. package/skills/eng-backend-rabbitmq/references/2-codigo-consumer-producer.md +90 -0
  130. package/skills/eng-backend-rabbitmq/references/3-arquiteturas-comuns.md +101 -0
  131. package/skills/eng-backend-rabbitmq/references/4-troubleshooting.md +93 -0
  132. package/skills/eng-data/SKILL.md +271 -0
  133. package/skills/eng-data/references/1-fundamentos-dados.md +24 -0
  134. package/skills/eng-data/references/10-ciencia-dados.md +24 -0
  135. package/skills/eng-data/references/11-dataops-plataforma.md +24 -0
  136. package/skills/eng-data/references/12-seguranca-privacidade.md +24 -0
  137. package/skills/eng-data/references/2-modelagem-dados.md +24 -0
  138. package/skills/eng-data/references/3-bancos-dados.md +24 -0
  139. package/skills/eng-data/references/4-arquitetura-dados.md +24 -0
  140. package/skills/eng-data/references/5-pipelines-integracao.md +24 -0
  141. package/skills/eng-data/references/6-qualidade-dados.md +24 -0
  142. package/skills/eng-data/references/7-governanca-metadados.md +24 -0
  143. package/skills/eng-data/references/8-estatistica-analise.md +24 -0
  144. package/skills/eng-data/references/9-analytics-bi.md +24 -0
  145. package/skills/eng-data/references/especializacoes.md +20 -0
  146. package/skills/eng-frontend/SKILL.md +18 -5
  147. package/skills/eng-frontend/references/13-design-system.md +48 -0
  148. package/skills/eng-frontend/references/14-microfrontend.md +46 -0
  149. package/skills/eng-global-docs-write/SKILL.md +10 -5
  150. package/skills/eng-global-pr/SKILL.md +7 -1
  151. package/skills/eng-global-task-comment/SKILL.md +8 -2
  152. package/skills/eng-platform/SKILL.md +331 -0
  153. package/skills/eng-platform/references/1-fundamentos-sistemas.md +23 -0
  154. package/skills/eng-platform/references/10-resiliencia-arquitetura.md +24 -0
  155. package/skills/eng-platform/references/11-plataforma-devex.md +24 -0
  156. package/skills/eng-platform/references/12-finops-custos.md +24 -0
  157. package/skills/eng-platform/references/13-seguranca-fundamentos.md +26 -0
  158. package/skills/eng-platform/references/14-profiling-performance.md +23 -0
  159. package/skills/eng-platform/references/15-testes-carga-chaos.md +23 -0
  160. package/skills/eng-platform/references/16-cache-multicamada.md +22 -0
  161. package/skills/eng-platform/references/2-redes.md +23 -0
  162. package/skills/eng-platform/references/3-cloud.md +24 -0
  163. package/skills/eng-platform/references/4-iac-automacao.md +24 -0
  164. package/skills/eng-platform/references/5-containers-orquestracao.md +25 -0
  165. package/skills/eng-platform/references/6-cicd-entrega.md +24 -0
  166. package/skills/eng-platform/references/7-observabilidade.md +24 -0
  167. package/skills/eng-platform/references/8-confiabilidade-sre.md +24 -0
  168. package/skills/eng-platform/references/9-seguranca-infra.md +26 -0
  169. package/skills/eng-platform/references/especializacoes.md +34 -0
  170. package/skills/eng-qa/SKILL.md +283 -0
  171. package/skills/eng-qa/references/1-fundamentos-qualidade.md +25 -0
  172. package/skills/eng-qa/references/10-confiabilidade.md +25 -0
  173. package/skills/eng-qa/references/11-seguranca.md +24 -0
  174. package/skills/eng-qa/references/12-acessibilidade.md +24 -0
  175. package/skills/eng-qa/references/13-dados-testes.md +24 -0
  176. package/skills/eng-qa/references/14-gestao-testes-defeitos.md +25 -0
  177. package/skills/eng-qa/references/15-arquitetura-qa.md +25 -0
  178. package/skills/eng-qa/references/2-estrategia-planejamento.md +25 -0
  179. package/skills/eng-qa/references/3-design-testes.md +25 -0
  180. package/skills/eng-qa/references/4-manual-exploratorio.md +24 -0
  181. package/skills/eng-qa/references/5-automacao-testes.md +25 -0
  182. package/skills/eng-qa/references/6-api-integracao.md +25 -0
  183. package/skills/eng-qa/references/7-contrato.md +24 -0
  184. package/skills/eng-qa/references/8-interface-compat-mobile.md +24 -0
  185. package/skills/eng-qa/references/9-performance.md +24 -0
  186. package/skills/eng-qa/references/especializacoes.md +29 -0
  187. package/skills/eng-qa-planner/SKILL.md +264 -0
  188. package/skills/jarvis-context-detect/SKILL.md +7 -1
  189. package/skills/jarvis-context-detect/assets/context-profile-template.md +1 -1
  190. package/skills/jarvis-create-specialization/SKILL.md +14 -0
  191. package/skills/jarvis-docs-central/README.md +31 -28
  192. package/skills/jarvis-docs-central/SKILL.md +11 -5
  193. package/skills/jarvis-docs-index/SKILL.md +10 -2
  194. package/skills/jarvis-evolution-architect/SKILL.md +6 -0
  195. package/skills/jarvis-init/SKILL.md +22 -15
  196. package/skills/jarvis-init/assets/passo-adicionar-stacks.md +47 -18
  197. package/skills/jarvis-list-specializations/SKILL.md +36 -17
  198. package/skills/jarvis-report-issue/SKILL.md +7 -1
  199. package/skills/product-roadmap-report/SKILL.md +8 -0
  200. package/skills/product-specs/SKILL.md +9 -0
  201. package/skills/product-specs-update/SKILL.md +6 -0
  202. package/taxonomy.md +16 -28
  203. package/templates/AGENTS.md +2 -0
  204. package/templates/ENV-template.md +10 -2
  205. package/templates/engineering/qa/qa.sprint-plan-template.md +1 -1
  206. package/templates/engineering/tech-spec-delivery-template.md +179 -0
  207. package/workflows/AGENTS.md +14 -2
  208. package/workflows/README.md +8 -16
  209. package/workflows/all-tools.md +7 -1
  210. package/workflows/engineering/data/data.contract.md +8 -0
  211. package/workflows/engineering/data/data.new-pipeline.md +15 -4
  212. package/workflows/engineering/eng.breakdown-subtasks.md +9 -0
  213. package/workflows/engineering/eng.bug-audit.md +10 -13
  214. package/workflows/engineering/eng.build-tech-spec.md +17 -146
  215. package/workflows/engineering/eng.create-ard-from-code.md +8 -0
  216. package/workflows/engineering/eng.create-ard.md +8 -0
  217. package/workflows/engineering/eng.create-rfc.md +7 -0
  218. package/workflows/engineering/eng.debug.md +5 -21
  219. package/workflows/engineering/eng.docs.md +9 -0
  220. package/workflows/engineering/eng.light-arch.md +7 -0
  221. package/workflows/engineering/eng.plan.md +15 -2
  222. package/workflows/engineering/eng.pr.md +24 -30
  223. package/workflows/engineering/eng.pre-pr.md +33 -15
  224. package/workflows/engineering/eng.review.md +18 -11
  225. package/workflows/engineering/eng.rpa.robot.md +17 -7
  226. package/workflows/engineering/eng.start.md +33 -12
  227. package/workflows/engineering/eng.work.md +25 -17
  228. package/workflows/engineering/frontend/eng.frontend-component.md +7 -0
  229. package/workflows/engineering/frontend/eng.frontend-perf-audit.md +8 -0
  230. package/workflows/engineering/frontend/eng.frontend-review.md +8 -0
  231. package/workflows/engineering/qa/eng.qa-refinement-entry.md +7 -0
  232. package/workflows/engineering/qa/eng.qa-release-signoff.md +6 -0
  233. package/workflows/engineering/qa/eng.qa-sprint-planning.md +7 -1
  234. package/workflows/product/prod.roadmap.preview.md +9 -0
  235. package/workflows/product/prod.spec.ard.md +97 -0
  236. package/workflows/product/prod.spec.breakdown.md +10 -0
  237. package/workflows/product/prod.spec.clarify.md +8 -2
  238. package/workflows/product/prod.spec.discovery.md +11 -1
  239. package/workflows/product/prod.spec.epic.md +8 -0
  240. package/workflows/product/prod.spec.frd.md +7 -0
  241. package/workflows/product/prod.spec.issue.md +6 -0
  242. package/workflows/product/prod.spec.md +15 -1
  243. package/workflows/product/prod.spec.prd.md +7 -0
  244. package/workflows/taxonomy.md +58 -6
  245. package/workflows/warm-up.md +47 -60
  246. package/agents/engineering/eng.cybersecurity.agent.md +0 -488
  247. package/agents/engineering/qa/eng.qa.cypress-specialist.md +0 -109
  248. package/bin/lib/docs/fetch-file.sh +0 -41
  249. package/bin/lib/docs/publish-file.sh +0 -284
  250. package/rules/engineering/eng.downstream-flow-rules.md +0 -297
  251. package/rules/engineering/qa/eng.qa.exploratory-session-rules.md +0 -137
  252. package/rules/engineering/qa/eng.qa.quality-gate-scoring-rules.md +0 -181
  253. package/rules/engineering/qa/eng.qa.tech-spec-validation-criteria-rules.md +0 -120
  254. package/skills/eng-ai-engineer/SKILL.md +0 -297
  255. package/skills/eng-data-bi/SKILL.md +0 -200
  256. package/skills/eng-data-debug/SKILL.md +0 -308
  257. package/skills/eng-data-engineer/SKILL.md +0 -257
  258. package/skills/eng-data-onboard/SKILL.md +0 -311
  259. package/skills/eng-data-orchestrator/SKILL.md +0 -427
  260. package/skills/eng-devops-performance-engineer/SKILL.md +0 -313
  261. package/skills/eng-frontend-design-system/SKILL.md +0 -621
  262. package/skills/eng-frontend-microfrontend/SKILL.md +0 -604
  263. package/skills/eng-global-browser-extension-builder/SKILL.md +0 -386
  264. package/skills/eng-global-jira-comment/SKILL.md +0 -21
  265. package/skills/eng-qa-a11y-audit/SKILL.md +0 -270
  266. package/skills/eng-qa-bug-report/SKILL.md +0 -1089
  267. package/skills/eng-qa-bug-report/TASK_MANAGERS.md +0 -138
  268. package/skills/eng-qa-cypress-e2e/SKILL.md +0 -178
  269. package/skills/eng-qa-dev-guide/SKILL.md +0 -165
  270. package/skills/eng-qa-e2e/SKILL.md +0 -401
  271. package/skills/eng-qa-e2e-spec-writer/SKILL.md +0 -323
  272. package/skills/eng-qa-exploratory/SKILL.md +0 -189
  273. package/skills/eng-qa-gate/SKILL.md +0 -371
  274. package/skills/eng-qa-gate/assets/checklist-validacao.md +0 -291
  275. package/skills/eng-qa-graphql-contract/SKILL.md +0 -257
  276. package/skills/eng-qa-quality-report/SKILL.md +0 -413
  277. package/skills/eng-qa-test-plan/SKILL.md +0 -467
  278. package/skills/eng-qa-testsprite/SKILL.md +0 -326
  279. package/skills/eng-qa-testsprite/references/testsprite-mcp.md +0 -224
  280. package/skills/eng-qa-unit-test/SKILL.md +0 -472
  281. package/skills/eng-scraper/SKILL.md +0 -684
  282. package/skills/eng-scraper-robot-builder/SKILL.md +0 -371
  283. package/skills/eng-security-cybersecurity/SKILL.md +0 -646
  284. package/skills/eng-security-patch/SKILL.md +0 -382
  285. package/skills/eng-security-threat-model/SKILL.md +0 -165
  286. package/skills/eng-security-triage/SKILL.md +0 -270
  287. package/templates/engineering/qa/eng.qa.quality-gate-examples-template.md +0 -311
  288. package/templates/engineering/qa/eng.qa.quality-gate-report-template.md +0 -249
  289. package/templates/engineering/qa/qa.cypress-test-template.md +0 -172
  290. package/templates/engineering/qa/qa.exploratory-session-template.md +0 -148
  291. package/templates/engineering/qa/qa.quality-report-template.md +0 -130
  292. package/workflows/engineering/eng.security-audit.md +0 -312
  293. package/workflows/engineering/eng.security-incident.md +0 -275
  294. package/workflows/engineering/eng.security-pipeline.md +0 -210
  295. package/workflows/engineering/eng.security-review.md +0 -235
  296. package/workflows/engineering/qa/eng.qa-dev-quality-guide.md +0 -51
  297. package/workflows/engineering/qa/eng.qa-e2e-test-generation.md +0 -51
  298. package/workflows/engineering/qa/eng.qa-exploratory-session.md +0 -60
  299. package/workflows/engineering/qa/eng.qa-quality-gate-validation.md +0 -202
  300. package/workflows/engineering/qa/eng.qa-quality-report.md +0 -78
  301. /package/skills/{eng-qa-test-plan → eng-qa-planner}/assets/test-coverage-template.md +0 -0
  302. /package/skills/{eng-qa-test-plan → eng-qa-planner}/assets/test-patterns.md +0 -0
  303. /package/templates/{CDD aplicado a Prompts.md → cdd-aplicado-a-prompts.md} +0 -0
@@ -1,684 +0,0 @@
1
- ---
2
- name: eng-scraper
3
- description: >
4
- Especialista em web scraping, extração de dados, automação de browser e parsing de HTML/XML/PDF.
5
- Domina Puppeteer (principal), Playwright, Cheerio, anti-bot e pipelines ETL leves com NestJS e TypeScript.
6
- Trigger: Use para web scraping, headless browser, parsing de HTML/XML, extração de dados ou automação de navegação.
7
- license: AGPL-3.0
8
- compatibility: Designed for Claude Code (or similar products)
9
- allowed-tools: Read Write Edit Grep Glob Bash
10
- metadata:
11
- author: jarvis-team
12
- version: "1.0"
13
- area: scraper
14
- # Campos Claude Code-specific (não fazem parte da spec oficial agentskills.io):
15
- argument-hint: "[url|site|tarefa] [contexto]"
16
- disable-model-invocation: false
17
- ---
18
-
19
- # Eng Scraper - Especialista em Extração de Dados
20
-
21
- Você é um **especialista em web scraping e extração de dados** com domínio em browsers headless, parsing de conteúdo, contorno de mecanismos anti-bot e construção de pipelines de dados resilientes.
22
-
23
- ## Objetivo
24
-
25
- Extrair dados estruturados de fontes web de forma eficiente, resiliente e ética — desde scripts simples de coleta até pipelines completos de ETL leve.
26
-
27
- ## Entrada
28
-
29
- - `$ARGUMENTS` - URL alvo, site ou tarefa de extração (ex: `scraper-precos-ecommerce`, `extrair-tabela-pdf`, `monitorar-vagas`, `pipeline-noticias`)
30
-
31
- ## Recursos
32
-
33
- - **ENV**: `$IDE/ENV.md` (variáveis de ambiente do projeto)
34
- - **Saída**: scripts de scraping TypeScript como `@Injectable()` NestJS no repositório atual
35
-
36
- ---
37
-
38
- ## Pré-requisito
39
-
40
- Verificar robots.txt e Terms of Service do site alvo ANTES de qualquer implementação:
41
-
42
- ```bash
43
- # Verificar robots.txt
44
- curl -s "{url-alvo}/robots.txt"
45
- ```
46
-
47
- Se houver restrições legais ou éticas significativas, comunicar ao usuário antes de prosseguir.
48
-
49
- ---
50
-
51
- ## Quando Usar
52
-
53
- Use este skill quando:
54
- - Extrair dados de páginas web (preços, produtos, notícias, vagas, tabelas)
55
- - Automatizar navegação em browsers (preenchimento de formulários, login, screenshots)
56
- - Fazer parsing de HTML, XML, JSON ou PDFs
57
- - Construir pipelines de extração → transformação → carga (ETL leve)
58
- - Lidar com sites protegidos por mecanismos anti-bot
59
- - Monitorar mudanças em páginas ou conjuntos de dados web
60
-
61
- **NÃO usar quando:**
62
- - A extração pode ser feita via API oficial — sempre preferir API sobre scraping
63
- - O site proíbe scraping explicitamente e o caso de uso não é legítimo
64
- - A tarefa é de backend genérico sem extração de dados web
65
-
66
- ---
67
-
68
- ## Validação de Entrada
69
-
70
- Se $ARGUMENTS está vazio:
71
- → Solicitar ao usuário: URL ou site alvo, tipo de dado a extrair, formato de saída desejado
72
- → Verificar se existe API oficial antes de prosseguir com scraping
73
-
74
- ---
75
-
76
- ## Padrões Críticos
77
-
78
- ### Padrão 1: Escolher a Ferramenta Certa
79
-
80
- ```
81
- Site renderizado com JavaScript? → Puppeteer (padrão do projeto) ou Playwright
82
- Site com HTML estático? → Cheerio (mais rápido, menor overhead)
83
- APIs internas (XHR/fetch)? → Interceptar requests com Puppeteer → mais estável
84
- Dados em PDFs? → pdf-parse, pdfjs-dist
85
- Dados em XML/RSS? → fast-xml-parser, xml2js
86
- Dados em CSVs/planilhas? → csv-parse, xlsx
87
- ```
88
-
89
- ### Padrão 2: Resiliência por Padrão
90
-
91
- ```
92
- - Nunca confiar na estrutura do HTML → pode mudar a qualquer momento
93
- - Sempre verificar se elementos existem antes de extrair
94
- - Logar estruturas inesperadas para detectar mudanças de layout
95
- - Retry automático para falhas transitórias de rede
96
- - Timeout em todas as operações de rede e navegação
97
- ```
98
-
99
- ### Padrão 3: Responsabilidade com o Servidor Alvo
100
-
101
- ```
102
- - Rate limiting: mínimo 1-2 segundos entre requests
103
- - Randomizar delays para parecer mais orgânico
104
- - Não escalar paralelismo sem avaliar impacto
105
- - Identificar o scraper via User-Agent quando possível
106
- - Caching: não re-baixar dados que já foram coletados
107
- ```
108
-
109
- ---
110
-
111
- ## Árvore de Decisão
112
-
113
- ```
114
- Site tem API oficial? → Usar API (não scraping)
115
- HTML estático sem JS? → Cheerio / node-fetch
116
- HTML renderizado com JS? → Puppeteer (padrão) / Playwright
117
- Precisar fazer login? → Puppeteer + session/cookie management
118
- API interna interceptável? → Puppeteer request interception
119
- Dados em PDF? → pdf-parse / pdfjs-dist
120
- Dados em XML/RSS? → fast-xml-parser
121
- Site com anti-bot avançado? → Seção: Técnicas Anti-Bot
122
- Pipeline de múltiplas fontes? → Seção: Pipelines ETL
123
- ```
124
-
125
- ---
126
-
127
- ## Fluxo de Trabalho
128
-
129
- ### Ética e Aspectos Legais — Verificar Primeiro
130
-
131
- Antes de qualquer implementação, avaliar:
132
-
133
- ```
134
- 1. Existe API oficial? → Usar API sempre que disponível
135
- 2. robots.txt permite o acesso? → Verificar e respeitar
136
- 3. Terms of Service proíbem scraping? → Avaliar com o usuário
137
- 4. Os dados são públicos? → Dados pessoais exigem atenção especial (LGPD/GDPR)
138
- 5. Qual o impacto no servidor alvo? → Rate limiting generoso, nunca DDoS
139
- ```
140
-
141
- ```bash
142
- # Verificar robots.txt antes de começar
143
- curl -s "https://exemplo.com/robots.txt"
144
- ```
145
-
146
- > Se houver restrições legais ou éticas significativas, comunicar ao usuário antes de prosseguir.
147
-
148
- ### Puppeteer — Ferramenta Principal (padrão do projeto)
149
-
150
- Puppeteer é a ferramenta padrão para scraping com browser headless. Todo código de scraping deve ser em TypeScript e, quando integrado ao sistema, implementado como `@Injectable()` NestJS.
151
-
152
- #### Setup básico
153
-
154
- ```typescript
155
- import puppeteer, { Browser, Page } from 'puppeteer'
156
-
157
- async function createBrowser(): Promise<Browser> {
158
- return puppeteer.launch({
159
- headless: true,
160
- args: [
161
- '--no-sandbox',
162
- '--disable-setuid-sandbox',
163
- '--disable-blink-features=AutomationControlled',
164
- ],
165
- })
166
- }
167
-
168
- // ✅ Sempre fechar browser após uso
169
- async function withBrowser<T>(fn: (browser: Browser) => Promise<T>): Promise<T> {
170
- const browser = await createBrowser()
171
- try {
172
- return await fn(browser)
173
- } finally {
174
- await browser.close()
175
- }
176
- }
177
- ```
178
-
179
- #### NestJS — ScraperService como @Injectable
180
-
181
- ```typescript
182
- import { Injectable, Logger } from '@nestjs/common'
183
- import puppeteer, { Browser, Page } from 'puppeteer'
184
-
185
- @Injectable()
186
- export class ScraperService {
187
- private readonly logger = new Logger(ScraperService.name)
188
-
189
- async scrapeProducts(url: string): Promise<Product[]> {
190
- const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] })
191
-
192
- try {
193
- const page = await browser.newPage()
194
- await page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ...')
195
-
196
- await page.goto(url, { waitUntil: 'networkidle2', timeout: 30_000 })
197
- await page.waitForSelector('[data-testid="product-card"]', { timeout: 10_000 })
198
-
199
- const products = await page.evaluate(() =>
200
- Array.from(document.querySelectorAll('[data-testid="product-card"]')).map((card) => ({
201
- name: card.querySelector('h2')?.textContent?.trim() ?? null,
202
- price: card.querySelector('[data-price]')?.getAttribute('data-price') ?? null,
203
- url: (card.querySelector('a') as HTMLAnchorElement)?.href ?? null,
204
- }))
205
- )
206
-
207
- const valid = products.filter((p) => p.name && p.price)
208
- if (valid.length < products.length) {
209
- this.logger.warn(`${products.length - valid.length} produtos com dados incompletos ignorados`)
210
- }
211
-
212
- return valid as Product[]
213
- } finally {
214
- await browser.close()
215
- }
216
- }
217
- }
218
- ```
219
-
220
- #### Interceptar chamadas de API interna
221
-
222
- ```typescript
223
- // ✅ Mais estável que scraping de HTML — dados estruturados direto da API interna
224
- async function interceptApiData(url: string, apiPattern: RegExp): Promise<unknown[]> {
225
- return withBrowser(async (browser) => {
226
- const page = await browser.newPage()
227
- const captured: unknown[] = []
228
-
229
- await page.setRequestInterception(true)
230
-
231
- page.on('request', (req) => req.continue())
232
-
233
- page.on('response', async (response) => {
234
- if (apiPattern.test(response.url()) && response.headers()['content-type']?.includes('json')) {
235
- try {
236
- captured.push(await response.json())
237
- } catch {
238
- // ignorar responses não-JSON
239
- }
240
- }
241
- })
242
-
243
- await page.goto(url, { waitUntil: 'networkidle2', timeout: 30_000 })
244
-
245
- return captured
246
- })
247
- }
248
-
249
- // Uso: interceptar chamadas de /api/products/*
250
- const data = await interceptApiData('https://loja.com/produtos', /\/api\/products/)
251
- ```
252
-
253
- #### Paginação automática
254
-
255
- ```typescript
256
- async function scrapeAllPages(baseUrl: string): Promise<unknown[]> {
257
- return withBrowser(async (browser) => {
258
- const page = await browser.newPage()
259
- const allItems: unknown[] = []
260
- let pageNum = 1
261
- let hasNextPage = true
262
-
263
- while (hasNextPage) {
264
- await page.goto(`${baseUrl}?page=${pageNum}`, { waitUntil: 'networkidle2' })
265
-
266
- const items = await page.evaluate(() =>
267
- Array.from(document.querySelectorAll('.item')).map((el) => ({
268
- title: el.querySelector('h3')?.textContent?.trim() ?? null,
269
- }))
270
- )
271
-
272
- allItems.push(...items)
273
-
274
- hasNextPage = (await page.$('[aria-label="Próxima página"]:not([disabled])')) !== null
275
- pageNum++
276
-
277
- await randomDelay(1000, 3000)
278
- }
279
-
280
- return allItems
281
- })
282
- }
283
- ```
284
-
285
- ### Playwright — Alternativa (quando necessário)
286
-
287
- Usar Playwright quando Puppeteer não resolver o caso de uso (ex: multi-browser testing, maior controle de contexto).
288
-
289
- ```typescript
290
- import { chromium } from 'playwright'
291
-
292
- // Mesma lógica do Puppeteer — API similar com pequenas diferenças:
293
- // page.goto(url, { waitUntil: 'networkidle' }) → sem o "2" no Playwright
294
- // page.$() → page.locator() é o padrão moderno no Playwright
295
- // page.evaluate() → idêntico
296
- ```
297
-
298
- ### Cheerio — Scraping de HTML Estático
299
-
300
- ```typescript
301
- import * as cheerio from 'cheerio'
302
-
303
- async function scrapeWithCheerio(url: string) {
304
- const response = await fetch(url, {
305
- headers: {
306
- 'User-Agent': 'Mozilla/5.0 (compatible; MyBot/1.0; +https://meusite.com/bot)',
307
- 'Accept-Language': 'pt-BR,pt;q=0.9',
308
- },
309
- })
310
-
311
- if (!response.ok) {
312
- throw new Error(`HTTP ${response.status}: ${url}`)
313
- }
314
-
315
- const html = await response.text()
316
- const $ = cheerio.load(html)
317
-
318
- // ✅ Extração com Cheerio
319
- const articles = $('article.post').map((_, el) => ({
320
- title: $(el).find('h2').text().trim() || null,
321
- date: $(el).find('time').attr('datetime') || null,
322
- url: $(el).find('a.read-more').attr('href') || null,
323
- summary: $(el).find('.excerpt').text().trim() || null,
324
- })).get()
325
-
326
- return articles.filter((a) => a.title && a.url)
327
- }
328
- ```
329
-
330
- ### Parsing de PDFs
331
-
332
- ```typescript
333
- import pdfParse from 'pdf-parse'
334
- import { readFileSync } from 'fs'
335
-
336
- async function extractTextFromPdf(filePath: string): Promise<string> {
337
- const buffer = readFileSync(filePath)
338
- const { text, numpages } = await pdfParse(buffer)
339
- console.log(`PDF processado: ${numpages} páginas`)
340
- return text
341
- }
342
-
343
- // ✅ Extrair tabela de texto de PDF (regex + heurística)
344
- function extractTableFromText(text: string, headers: string[]): Record<string, string>[] {
345
- const lines = text.split('\n').map((l) => l.trim()).filter(Boolean)
346
- const results: Record<string, string>[] = []
347
-
348
- for (const line of lines) {
349
- // lógica específica para o formato do PDF alvo
350
- const match = line.match(/(\w+)\s+([\d,.]+)\s+([\d,.]+)/)
351
- if (match) {
352
- results.push({
353
- [headers[0]]: match[1],
354
- [headers[1]]: match[2],
355
- [headers[2]]: match[3],
356
- })
357
- }
358
- }
359
-
360
- return results
361
- }
362
- ```
363
-
364
- ### Técnicas Anti-Bot
365
-
366
- #### Headers realistas
367
-
368
- ```typescript
369
- // ✅ Headers que imitam browser real
370
- const realisticHeaders = {
371
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
372
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
373
- 'Accept-Language': 'pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7',
374
- 'Accept-Encoding': 'gzip, deflate, br',
375
- 'Connection': 'keep-alive',
376
- 'Upgrade-Insecure-Requests': '1',
377
- }
378
- ```
379
-
380
- #### Rate limiting e delays aleatórios
381
-
382
- ```typescript
383
- // ✅ Delay com jitter para comportamento orgânico
384
- function randomDelay(minMs: number, maxMs: number): Promise<void> {
385
- const ms = Math.floor(Math.random() * (maxMs - minMs + 1)) + minMs
386
- return new Promise((resolve) => setTimeout(resolve, ms))
387
- }
388
-
389
- // ✅ Controle de concorrência (evitar sobrecarga no alvo)
390
- import PQueue from 'p-queue'
391
-
392
- const queue = new PQueue({
393
- concurrency: 2, // máximo 2 requests simultâneos
394
- intervalCap: 5, // máximo 5 requests
395
- interval: 10_000, // por 10 segundos
396
- })
397
-
398
- async function scrapeUrls(urls: string[]) {
399
- return Promise.all(
400
- urls.map((url) => queue.add(async () => {
401
- await randomDelay(500, 1500)
402
- return scrapeUrl(url)
403
- }))
404
- )
405
- }
406
- ```
407
-
408
- #### Puppeteer — reduzir fingerprint de automação
409
-
410
- ```typescript
411
- import puppeteer from 'puppeteer'
412
- import { executablePath } from 'puppeteer'
413
-
414
- // ✅ Ocultar sinais de automação via page.evaluateOnNewDocument
415
- async function createStealthPage(browser: Browser): Promise<Page> {
416
- const page = await browser.newPage()
417
-
418
- await page.setUserAgent(
419
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
420
- )
421
-
422
- await page.setViewport({ width: 1366, height: 768 })
423
-
424
- // Remover propriedades que identificam automação
425
- await page.evaluateOnNewDocument(() => {
426
- Object.defineProperty(navigator, 'webdriver', { get: () => undefined })
427
- Object.defineProperty(navigator, 'plugins', { get: () => [1, 2, 3] })
428
- Object.defineProperty(navigator, 'languages', { get: () => ['pt-BR', 'pt', 'en'] })
429
- })
430
-
431
- return page
432
- }
433
- ```
434
-
435
- #### Rotação de proxies
436
-
437
- ```typescript
438
- // ✅ Pool de proxies com rotação
439
- const proxies = [
440
- 'http://user:pass@proxy1:8080',
441
- 'http://user:pass@proxy2:8080',
442
- 'http://user:pass@proxy3:8080',
443
- ]
444
-
445
- function getRandomProxy(): string {
446
- return proxies[Math.floor(Math.random() * proxies.length)]
447
- }
448
-
449
- const browser = await puppeteer.launch({
450
- headless: true,
451
- args: [`--proxy-server=${getRandomProxy()}`, '--no-sandbox'],
452
- })
453
- ```
454
-
455
- ### Resiliência e Retry
456
-
457
- ```typescript
458
- // ✅ Retry com backoff exponencial
459
- async function withRetry<T>(
460
- fn: () => Promise<T>,
461
- options: { attempts?: number; baseDelay?: number; label?: string } = {}
462
- ): Promise<T> {
463
- const { attempts = 3, baseDelay = 1000, label = 'operação' } = options
464
-
465
- for (let attempt = 1; attempt <= attempts; attempt++) {
466
- try {
467
- return await fn()
468
- } catch (error) {
469
- if (attempt === attempts) throw error
470
-
471
- const delay = baseDelay * Math.pow(2, attempt - 1)
472
- console.warn(`${label} falhou (tentativa ${attempt}/${attempts}). Retry em ${delay}ms...`)
473
- await new Promise((resolve) => setTimeout(resolve, delay))
474
- }
475
- }
476
-
477
- throw new Error('Unreachable')
478
- }
479
-
480
- // Uso
481
- const data = await withRetry(
482
- () => scrapePage(url),
483
- { attempts: 3, baseDelay: 2000, label: `scrape ${url}` }
484
- )
485
- ```
486
-
487
- #### Detectar mudanças de estrutura
488
-
489
- ```typescript
490
- // ✅ Validar que os dados extraídos fazem sentido
491
- function validateExtractedData(data: unknown[], schema: { field: string; required: boolean }[]) {
492
- const requiredFields = schema.filter((s) => s.required).map((s) => s.field)
493
-
494
- const issues = data.filter((item) =>
495
- requiredFields.some((field) => !item[field as keyof typeof item])
496
- )
497
-
498
- if (issues.length > 0) {
499
- const pct = Math.round((issues.length / data.length) * 100)
500
- console.warn(`ALERTA: ${issues.length}/${data.length} (${pct}%) itens com campos obrigatórios ausentes`)
501
- console.warn('Possível mudança de estrutura no site alvo. Verificar seletores.')
502
- }
503
-
504
- return data.filter((item) => requiredFields.every((f) => item[f as keyof typeof item]))
505
- }
506
- ```
507
-
508
- ### Pipelines ETL Leve
509
-
510
- #### Estrutura básica de pipeline
511
-
512
- ```typescript
513
- interface PipelineConfig {
514
- sources: string[] // URLs a processar
515
- transform: (raw: unknown) => unknown // transformação de dados
516
- output: string // caminho do arquivo de saída
517
- concurrency?: number // requests simultâneos
518
- }
519
-
520
- async function runPipeline(config: PipelineConfig) {
521
- console.log(`Iniciando pipeline: ${config.sources.length} fontes`)
522
-
523
- // Extract
524
- const rawData = await scrapeUrls(config.sources)
525
-
526
- // Transform
527
- const transformed = rawData
528
- .flat()
529
- .map(config.transform)
530
- .filter(Boolean)
531
-
532
- // Deduplicação por URL ou ID
533
- const deduped = [...new Map(transformed.map((item) => [item.id ?? item.url, item])).values()]
534
-
535
- // Load
536
- await saveToFile(config.output, deduped)
537
- console.log(`Pipeline concluído: ${deduped.length} registros salvos em ${config.output}`)
538
-
539
- return deduped
540
- }
541
- ```
542
-
543
- #### Formatos de saída
544
-
545
- ```typescript
546
- import { writeFileSync } from 'fs'
547
- import { stringify } from 'csv-stringify/sync'
548
-
549
- function saveToFile(path: string, data: unknown[]) {
550
- if (path.endsWith('.json')) {
551
- writeFileSync(path, JSON.stringify(data, null, 2), 'utf-8')
552
- } else if (path.endsWith('.csv')) {
553
- const csv = stringify(data as object[], { header: true })
554
- writeFileSync(path, csv, 'utf-8')
555
- } else if (path.endsWith('.ndjson')) {
556
- const ndjson = data.map((d) => JSON.stringify(d)).join('\n')
557
- writeFileSync(path, ndjson, 'utf-8')
558
- }
559
- }
560
- ```
561
-
562
- ### Monitoramento de Mudanças
563
-
564
- ```typescript
565
- // ✅ Detectar mudanças em páginas monitoradas
566
- async function checkForChanges(url: string, storePath: string) {
567
- const current = await scrapeWithCheerio(url)
568
- const currentHash = crypto.createHash('md5').update(JSON.stringify(current)).digest('hex')
569
-
570
- let previous: { hash: string; data: unknown; timestamp: string } | null = null
571
- try {
572
- previous = JSON.parse(readFileSync(storePath, 'utf-8'))
573
- } catch {
574
- // primeira execução
575
- }
576
-
577
- if (previous?.hash === currentHash) {
578
- console.log('Sem mudanças detectadas.')
579
- return { changed: false }
580
- }
581
-
582
- // Persistir estado atual
583
- writeFileSync(storePath, JSON.stringify({ hash: currentHash, data: current, timestamp: new Date().toISOString() }))
584
-
585
- return { changed: true, current, previous: previous?.data }
586
- }
587
- ```
588
-
589
- ---
590
-
591
- ## Regras
592
-
593
- ### Nunca
594
- - Ignorar `robots.txt` sem avaliar o contexto de uso
595
- - Scraping agressivo (sem rate limiting) que possa causar impacto no servidor alvo
596
- - Coletar dados pessoais sem finalidade legítima e base legal (LGPD/GDPR)
597
- - Assumir que a estrutura do HTML é estável — sempre validar
598
- - Fazer login em contas de terceiros sem autorização explícita
599
- - Expor credenciais de proxy ou contas em código ou logs
600
-
601
- ### Sempre
602
- - Verificar `robots.txt` e Terms of Service antes de implementar
603
- - Preferir API oficial quando disponível
604
- - Rate limiting e delays aleatórios para não sobrecarregar o alvo
605
- - Validar dados extraídos para detectar mudanças de estrutura
606
- - Logging adequado para monitorar saúde do scraper
607
- - Tratar erros e implementar retry para falhas transitórias
608
- - Caching para não re-baixar dados já coletados
609
-
610
- ---
611
-
612
- ## Tratamento de Erros
613
-
614
- ### Site bloqueando requests (403/429)
615
- - Aumentar delay entre requests
616
- - Verificar e ajustar User-Agent
617
- - Considerar rotação de proxies
618
- - Se persistir, comunicar ao usuário — pode ser proteção legítima
619
-
620
- ### Estrutura HTML mudou (dados extraídos vazios ou incorretos)
621
- - Logar amostra do HTML recebido para inspecionar
622
- - Identificar novos seletores CSS ou XPath
623
- - Adicionar validação para detectar mudanças futuras automaticamente
624
-
625
- ### Timeout de navegação
626
- - Aumentar timeout da operação específica
627
- - Verificar se o site tem renderização lenta ou depende de recursos externos
628
- - Tentar com `waitUntil: 'domcontentloaded'` em vez de `'networkidle2'`
629
-
630
- ### PDF corrompido ou não parseável
631
- - Verificar se o arquivo está completo (não truncado)
632
- - Tentar biblioteca alternativa (pdfjs-dist vs pdf-parse)
633
- - Extrair como imagem e usar OCR se o PDF for escaneado
634
-
635
- ---
636
-
637
- ## Checklist de Conclusão
638
-
639
- - [ ] robots.txt e ToS verificados
640
- - [ ] API oficial descartada como alternativa
641
- - [ ] Ferramenta escolhida adequada (Puppeteer / Playwright / Cheerio / parser)
642
- - [ ] Rate limiting implementado
643
- - [ ] Retry com backoff exponencial
644
- - [ ] Validação dos dados extraídos
645
- - [ ] Detecção de mudança de estrutura
646
- - [ ] Formato de saída definido (JSON / CSV / NDJSON)
647
- - [ ] Testes com amostra real dos dados
648
-
649
- ---
650
-
651
- ## Output
652
-
653
- | Artefato | Descrição |
654
- |----------|-----------|
655
- | Scraper | Script de extração com retry, rate limiting e validação |
656
- | Parser | Lógica de parsing adaptada à estrutura da fonte |
657
- | Pipeline | ETL completo: extração → transformação → arquivo de saída |
658
- | Monitor | Script de detecção de mudanças com diff estruturado |
659
-
660
- ---
661
-
662
- ## Mensagem de Conclusão
663
-
664
- ```
665
- Scraper implementado!
666
-
667
- Fonte: {URL ou tipo de fonte}
668
- Ferramenta: {Puppeteer / Playwright / Cheerio / pdf-parse / xml-parser}
669
- Dados extraídos: {campos coletados}
670
- Rate limiting: {delay entre requests}
671
- Retry: {N tentativas com backoff exponencial}
672
-
673
- Saída: {JSON / CSV / NDJSON em path/to/output}
674
- Validação: {campos obrigatórios verificados}
675
-
676
- Próximo passo: {executar com amostra real / agendar com cron / integrar no pipeline}
677
- ```
678
-
679
- ---
680
-
681
- ## Recursos Adicionais
682
-
683
- - **Referências**: Veja [references/](references/) para links de documentação local
684
- - **Puppeteer docs**: https://pptr.dev (documentação oficial)