bps-kit 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/.agents/agents/backend-specialist.md +263 -0
- package/templates/.agents/agents/code-archaeologist.md +106 -0
- package/templates/.agents/agents/database-architect.md +226 -0
- package/templates/.agents/agents/debugger.md +225 -0
- package/templates/.agents/agents/devops-engineer.md +242 -0
- package/templates/.agents/agents/documentation-writer.md +104 -0
- package/templates/.agents/agents/explorer-agent.md +73 -0
- package/templates/.agents/agents/frontend-specialist.md +593 -0
- package/templates/.agents/agents/game-developer.md +162 -0
- package/templates/.agents/agents/mobile-developer.md +377 -0
- package/templates/.agents/agents/orchestrator.md +416 -0
- package/templates/.agents/agents/penetration-tester.md +188 -0
- package/templates/.agents/agents/performance-optimizer.md +187 -0
- package/templates/.agents/agents/product-manager.md +112 -0
- package/templates/.agents/agents/product-owner.md +95 -0
- package/templates/.agents/agents/project-planner.md +406 -0
- package/templates/.agents/agents/qa-automation-engineer.md +103 -0
- package/templates/.agents/agents/security-auditor.md +170 -0
- package/templates/.agents/agents/seo-specialist.md +111 -0
- package/templates/.agents/agents/test-engineer.md +158 -0
- package/templates/.agents/rules/GEMINI.md +219 -0
- package/templates/.agents/scripts/auto_preview.py +148 -0
- package/templates/.agents/scripts/checklist.py +217 -0
- package/templates/.agents/scripts/session_manager.py +120 -0
- package/templates/.agents/scripts/verify_all.py +327 -0
- package/templates/.agents/workflows/brainstorm.md +113 -0
- package/templates/.agents/workflows/create.md +59 -0
- package/templates/.agents/workflows/debug.md +103 -0
- package/templates/.agents/workflows/deploy.md +176 -0
- package/templates/.agents/workflows/enhance.md +63 -0
- package/templates/.agents/workflows/orchestrate.md +237 -0
- package/templates/.agents/workflows/plan.md +89 -0
- package/templates/.agents/workflows/preview.md +81 -0
- package/templates/.agents/workflows/setup-brain.md +39 -0
- package/templates/.agents/workflows/status.md +86 -0
- package/templates/.agents/workflows/test.md +144 -0
- package/templates/.agents/workflows/ui-ux-pro-max.md +296 -0
- package/templates/skills_normal/api-patterns/scripts/api_validator.py +211 -0
- package/templates/skills_normal/database-design/scripts/schema_validator.py +172 -0
- package/templates/skills_normal/frontend-design/scripts/accessibility_checker.py +183 -0
- package/templates/skills_normal/frontend-design/scripts/ux_audit.py +722 -0
- package/templates/skills_normal/git-pushing/scripts/smart_commit.sh +19 -0
- package/templates/skills_normal/lint-and-validate/scripts/lint_runner.py +184 -0
- package/templates/skills_normal/lint-and-validate/scripts/type_coverage.py +173 -0
- package/templates/skills_normal/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/templates/skills_normal/senior-fullstack/scripts/code_quality_analyzer.py +114 -0
- package/templates/skills_normal/senior-fullstack/scripts/fullstack_scaffolder.py +114 -0
- package/templates/skills_normal/senior-fullstack/scripts/project_scaffolder.py +114 -0
- package/templates/skills_normal/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/templates/skills_normal/testing-patterns/scripts/test_runner.py +219 -0
- package/templates/skills_normal/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/templates/vault/007/scripts/config.py +472 -0
- package/templates/vault/007/scripts/full_audit.py +1306 -0
- package/templates/vault/007/scripts/quick_scan.py +481 -0
- package/templates/vault/007/scripts/requirements.txt +26 -0
- package/templates/vault/007/scripts/scanners/__init__.py +0 -0
- package/templates/vault/007/scripts/scanners/dependency_scanner.py +1305 -0
- package/templates/vault/007/scripts/scanners/injection_scanner.py +1104 -0
- package/templates/vault/007/scripts/scanners/secrets_scanner.py +1008 -0
- package/templates/vault/007/scripts/score_calculator.py +693 -0
- package/templates/vault/agent-orchestrator/scripts/match_skills.py +329 -0
- package/templates/vault/agent-orchestrator/scripts/orchestrate.py +304 -0
- package/templates/vault/agent-orchestrator/scripts/requirements.txt +1 -0
- package/templates/vault/agent-orchestrator/scripts/scan_registry.py +508 -0
- package/templates/vault/ai-studio-image/scripts/config.py +613 -0
- package/templates/vault/ai-studio-image/scripts/generate.py +630 -0
- package/templates/vault/ai-studio-image/scripts/prompt_engine.py +424 -0
- package/templates/vault/ai-studio-image/scripts/requirements.txt +4 -0
- package/templates/vault/ai-studio-image/scripts/templates.py +349 -0
- package/templates/vault/android_ui_verification/scripts/verify_ui.sh +32 -0
- package/templates/vault/apify-audience-analysis/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-brand-reputation-monitoring/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-competitor-intelligence/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-content-analytics/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-ecommerce/reference/scripts/package.json +3 -0
- package/templates/vault/apify-ecommerce/reference/scripts/run_actor.js +369 -0
- package/templates/vault/apify-influencer-discovery/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-lead-generation/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-market-research/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-trend-analysis/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-ultimate-scraper/reference/scripts/run_actor.js +363 -0
- package/templates/vault/audio-transcriber/scripts/install-requirements.sh +190 -0
- package/templates/vault/audio-transcriber/scripts/transcribe.py +486 -0
- package/templates/vault/claude-monitor/scripts/api_bench.py +240 -0
- package/templates/vault/claude-monitor/scripts/config.py +69 -0
- package/templates/vault/claude-monitor/scripts/health_check.py +362 -0
- package/templates/vault/claude-monitor/scripts/monitor.py +296 -0
- package/templates/vault/content-creator/scripts/brand_voice_analyzer.py +185 -0
- package/templates/vault/content-creator/scripts/seo_optimizer.py +419 -0
- package/templates/vault/context-agent/scripts/active_context.py +227 -0
- package/templates/vault/context-agent/scripts/compressor.py +149 -0
- package/templates/vault/context-agent/scripts/config.py +69 -0
- package/templates/vault/context-agent/scripts/context_loader.py +155 -0
- package/templates/vault/context-agent/scripts/context_manager.py +302 -0
- package/templates/vault/context-agent/scripts/models.py +103 -0
- package/templates/vault/context-agent/scripts/project_registry.py +132 -0
- package/templates/vault/context-agent/scripts/requirements.txt +6 -0
- package/templates/vault/context-agent/scripts/search.py +115 -0
- package/templates/vault/context-agent/scripts/session_parser.py +206 -0
- package/templates/vault/context-agent/scripts/session_summary.py +319 -0
- package/templates/vault/context-guardian/scripts/context_snapshot.py +229 -0
- package/templates/vault/docx/ooxml/scripts/pack.py +159 -0
- package/templates/vault/docx/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/docx/ooxml/scripts/validate.py +69 -0
- package/templates/vault/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/docx/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/docx/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/docx/scripts/__init__.py +1 -0
- package/templates/vault/docx/scripts/document.py +1276 -0
- package/templates/vault/docx/scripts/templates/comments.xml +3 -0
- package/templates/vault/docx/scripts/templates/commentsExtended.xml +3 -0
- package/templates/vault/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/templates/vault/docx/scripts/templates/commentsIds.xml +3 -0
- package/templates/vault/docx/scripts/templates/people.xml +3 -0
- package/templates/vault/docx/scripts/utilities.py +374 -0
- package/templates/vault/docx-official/ooxml/scripts/pack.py +159 -0
- package/templates/vault/docx-official/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/docx-official/ooxml/scripts/validate.py +69 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/docx-official/scripts/__init__.py +1 -0
- package/templates/vault/docx-official/scripts/document.py +1276 -0
- package/templates/vault/docx-official/scripts/templates/comments.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/commentsExtended.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/commentsExtensible.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/commentsIds.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/people.xml +3 -0
- package/templates/vault/docx-official/scripts/utilities.py +374 -0
- package/templates/vault/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/templates/vault/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/templates/vault/i18n-localization/scripts/i18n_checker.py +241 -0
- package/templates/vault/instagram/scripts/account_setup.py +233 -0
- package/templates/vault/instagram/scripts/analyze.py +221 -0
- package/templates/vault/instagram/scripts/api_client.py +444 -0
- package/templates/vault/instagram/scripts/auth.py +411 -0
- package/templates/vault/instagram/scripts/comments.py +160 -0
- package/templates/vault/instagram/scripts/config.py +111 -0
- package/templates/vault/instagram/scripts/db.py +467 -0
- package/templates/vault/instagram/scripts/export.py +138 -0
- package/templates/vault/instagram/scripts/governance.py +233 -0
- package/templates/vault/instagram/scripts/hashtags.py +114 -0
- package/templates/vault/instagram/scripts/insights.py +170 -0
- package/templates/vault/instagram/scripts/media.py +65 -0
- package/templates/vault/instagram/scripts/messages.py +103 -0
- package/templates/vault/instagram/scripts/profile.py +58 -0
- package/templates/vault/instagram/scripts/publish.py +449 -0
- package/templates/vault/instagram/scripts/requirements.txt +5 -0
- package/templates/vault/instagram/scripts/run_all.py +189 -0
- package/templates/vault/instagram/scripts/schedule.py +189 -0
- package/templates/vault/instagram/scripts/serve_api.py +234 -0
- package/templates/vault/instagram/scripts/templates.py +155 -0
- package/templates/vault/junta-leiloeiros/scripts/db.py +216 -0
- package/templates/vault/junta-leiloeiros/scripts/export.py +137 -0
- package/templates/vault/junta-leiloeiros/scripts/requirements.txt +15 -0
- package/templates/vault/junta-leiloeiros/scripts/run_all.py +190 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/__init__.py +4 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/base_scraper.py +209 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/generic_scraper.py +110 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucap.py +110 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/juceac.py +72 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/juceal.py +72 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/juceb.py +68 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucec.py +63 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucema.py +211 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucemg.py +218 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucep.py +70 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepa.py +74 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepar.py +80 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepe.py +78 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepi.py +69 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucer.py +256 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucerja.py +170 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucern.py +71 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucesc.py +89 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucesp.py +233 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucetins.py +134 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucis_df.py +63 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucisrs.py +299 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/states.py +99 -0
- package/templates/vault/junta-leiloeiros/scripts/serve_api.py +164 -0
- package/templates/vault/junta-leiloeiros/scripts/web_scraper_fallback.py +233 -0
- package/templates/vault/last30days/scripts/last30days.py +521 -0
- package/templates/vault/last30days/scripts/lib/__init__.py +1 -0
- package/templates/vault/last30days/scripts/lib/cache.py +152 -0
- package/templates/vault/last30days/scripts/lib/dates.py +124 -0
- package/templates/vault/last30days/scripts/lib/dedupe.py +120 -0
- package/templates/vault/last30days/scripts/lib/env.py +149 -0
- package/templates/vault/last30days/scripts/lib/http.py +152 -0
- package/templates/vault/last30days/scripts/lib/models.py +175 -0
- package/templates/vault/last30days/scripts/lib/normalize.py +160 -0
- package/templates/vault/last30days/scripts/lib/openai_reddit.py +230 -0
- package/templates/vault/last30days/scripts/lib/reddit_enrich.py +232 -0
- package/templates/vault/last30days/scripts/lib/render.py +383 -0
- package/templates/vault/last30days/scripts/lib/schema.py +336 -0
- package/templates/vault/last30days/scripts/lib/score.py +311 -0
- package/templates/vault/last30days/scripts/lib/ui.py +324 -0
- package/templates/vault/last30days/scripts/lib/websearch.py +401 -0
- package/templates/vault/last30days/scripts/lib/xai_x.py +217 -0
- package/templates/vault/leiloeiro-avaliacao/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-avaliacao/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-edital/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-edital/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-ia/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-ia/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-juridico/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-juridico/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-mercado/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-mercado/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-risco/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-risco/scripts/requirements.txt +1 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/database.ts +24 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/db.ts +35 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/index.ts +2 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/migrations.ts +31 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/schema.sql +8 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/index.ts +44 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/routes/todos.ts +155 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/types/index.ts +35 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/App.css +384 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/App.tsx +81 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/api/todos.ts +57 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/ConfirmDialog.tsx +26 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/EmptyState.tsx +8 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/TodoForm.tsx +43 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/TodoItem.tsx +36 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/TodoList.tsx +27 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/hooks/useTodos.ts +81 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/index.css +48 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/main.tsx +10 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/vite-env.d.ts +1 -0
- package/templates/vault/loki-mode/scripts/export-to-vibe-kanban.sh +178 -0
- package/templates/vault/loki-mode/scripts/loki-wrapper.sh +281 -0
- package/templates/vault/loki-mode/scripts/take-screenshots.js +55 -0
- package/templates/vault/matematico-tao/scripts/complexity_analyzer.py +544 -0
- package/templates/vault/matematico-tao/scripts/dependency_graph.py +538 -0
- package/templates/vault/mcp-builder/scripts/connections.py +151 -0
- package/templates/vault/mcp-builder/scripts/evaluation.py +373 -0
- package/templates/vault/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/templates/vault/mcp-builder/scripts/requirements.txt +2 -0
- package/templates/vault/mobile-design/scripts/mobile_audit.py +670 -0
- package/templates/vault/notebooklm/scripts/__init__.py +81 -0
- package/templates/vault/notebooklm/scripts/ask_question.py +256 -0
- package/templates/vault/notebooklm/scripts/auth_manager.py +358 -0
- package/templates/vault/notebooklm/scripts/browser_session.py +255 -0
- package/templates/vault/notebooklm/scripts/browser_utils.py +107 -0
- package/templates/vault/notebooklm/scripts/cleanup_manager.py +302 -0
- package/templates/vault/notebooklm/scripts/config.py +44 -0
- package/templates/vault/notebooklm/scripts/notebook_manager.py +410 -0
- package/templates/vault/notebooklm/scripts/run.py +102 -0
- package/templates/vault/notebooklm/scripts/setup_environment.py +204 -0
- package/templates/vault/pdf/scripts/check_bounding_boxes.py +70 -0
- package/templates/vault/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/templates/vault/pdf/scripts/check_fillable_fields.py +12 -0
- package/templates/vault/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/templates/vault/pdf/scripts/create_validation_image.py +41 -0
- package/templates/vault/pdf/scripts/extract_form_field_info.py +152 -0
- package/templates/vault/pdf/scripts/fill_fillable_fields.py +114 -0
- package/templates/vault/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/templates/vault/pdf-official/scripts/check_bounding_boxes.py +70 -0
- package/templates/vault/pdf-official/scripts/check_bounding_boxes_test.py +226 -0
- package/templates/vault/pdf-official/scripts/check_fillable_fields.py +12 -0
- package/templates/vault/pdf-official/scripts/convert_pdf_to_images.py +35 -0
- package/templates/vault/pdf-official/scripts/create_validation_image.py +41 -0
- package/templates/vault/pdf-official/scripts/extract_form_field_info.py +152 -0
- package/templates/vault/pdf-official/scripts/fill_fillable_fields.py +114 -0
- package/templates/vault/pdf-official/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/templates/vault/planning-with-files/scripts/check-complete.sh +44 -0
- package/templates/vault/planning-with-files/scripts/init-session.sh +120 -0
- package/templates/vault/pptx/ooxml/scripts/pack.py +159 -0
- package/templates/vault/pptx/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/pptx/ooxml/scripts/validate.py +69 -0
- package/templates/vault/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/pptx/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/pptx/scripts/html2pptx.js +979 -0
- package/templates/vault/pptx/scripts/inventory.py +1020 -0
- package/templates/vault/pptx/scripts/rearrange.py +231 -0
- package/templates/vault/pptx/scripts/replace.py +385 -0
- package/templates/vault/pptx/scripts/thumbnail.py +450 -0
- package/templates/vault/pptx-official/ooxml/scripts/pack.py +159 -0
- package/templates/vault/pptx-official/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/pptx-official/ooxml/scripts/validate.py +69 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/pptx-official/scripts/html2pptx.js +979 -0
- package/templates/vault/pptx-official/scripts/inventory.py +1020 -0
- package/templates/vault/pptx-official/scripts/rearrange.py +231 -0
- package/templates/vault/pptx-official/scripts/replace.py +385 -0
- package/templates/vault/pptx-official/scripts/thumbnail.py +450 -0
- package/templates/vault/product-manager-toolkit/scripts/customer_interview_analyzer.py +441 -0
- package/templates/vault/product-manager-toolkit/scripts/rice_prioritizer.py +296 -0
- package/templates/vault/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/templates/vault/scripts/.skill_cache.json +7538 -0
- package/templates/vault/scripts/skill_search.py +228 -0
- package/templates/vault/senior-architect/scripts/architecture_diagram_generator.py +114 -0
- package/templates/vault/senior-architect/scripts/dependency_analyzer.py +114 -0
- package/templates/vault/senior-architect/scripts/project_architect.py +114 -0
- package/templates/vault/shopify-development/scripts/requirements.txt +19 -0
- package/templates/vault/shopify-development/scripts/shopify_graphql.py +428 -0
- package/templates/vault/shopify-development/scripts/shopify_init.py +441 -0
- package/templates/vault/shopify-development/scripts/tests/test_shopify_init.py +379 -0
- package/templates/vault/skill-creator/scripts/init_skill.py +303 -0
- package/templates/vault/skill-creator/scripts/package_skill.py +110 -0
- package/templates/vault/skill-creator/scripts/quick_validate.py +95 -0
- package/templates/vault/skill-installer/scripts/detect_skills.py +318 -0
- package/templates/vault/skill-installer/scripts/install_skill.py +1708 -0
- package/templates/vault/skill-installer/scripts/package_skill.py +417 -0
- package/templates/vault/skill-installer/scripts/requirements.txt +1 -0
- package/templates/vault/skill-installer/scripts/validate_skill.py +430 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/__init__.py +13 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/code_quality.py +247 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/cross_skill.py +134 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/dependencies.py +121 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/documentation.py +189 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/governance_audit.py +153 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/performance.py +164 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/security.py +189 -0
- package/templates/vault/skill-sentinel/scripts/config.py +158 -0
- package/templates/vault/skill-sentinel/scripts/cost_optimizer.py +146 -0
- package/templates/vault/skill-sentinel/scripts/db.py +354 -0
- package/templates/vault/skill-sentinel/scripts/governance.py +58 -0
- package/templates/vault/skill-sentinel/scripts/recommender.py +228 -0
- package/templates/vault/skill-sentinel/scripts/report_generator.py +224 -0
- package/templates/vault/skill-sentinel/scripts/requirements.txt +1 -0
- package/templates/vault/skill-sentinel/scripts/run_audit.py +290 -0
- package/templates/vault/skill-sentinel/scripts/scanner.py +271 -0
- package/templates/vault/stability-ai/scripts/config.py +266 -0
- package/templates/vault/stability-ai/scripts/generate.py +687 -0
- package/templates/vault/stability-ai/scripts/requirements.txt +4 -0
- package/templates/vault/stability-ai/scripts/styles.py +174 -0
- package/templates/vault/telegram/assets/boilerplate/nodejs/src/bot-client.ts +86 -0
- package/templates/vault/telegram/assets/boilerplate/nodejs/src/handlers.ts +79 -0
- package/templates/vault/telegram/assets/boilerplate/nodejs/src/index.ts +32 -0
- package/templates/vault/telegram/scripts/send_message.py +143 -0
- package/templates/vault/telegram/scripts/setup_project.py +103 -0
- package/templates/vault/telegram/scripts/test_bot.py +144 -0
- package/templates/vault/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/templates/vault/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/templates/vault/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/templates/vault/ui-ux-pro-max/scripts/core.py +257 -0
- package/templates/vault/ui-ux-pro-max/scripts/design_system.py +487 -0
- package/templates/vault/ui-ux-pro-max/scripts/search.py +76 -0
- package/templates/vault/videodb/scripts/ws_listener.py +204 -0
- package/templates/vault/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/templates/vault/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/templates/vault/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/templates/vault/webapp-testing/scripts/with_server.py +106 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/index.ts +125 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/template-manager.ts +67 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/types.ts +216 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/webhook-handler.ts +173 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/whatsapp-client.ts +193 -0
- package/templates/vault/whatsapp-cloud-api/scripts/send_test_message.py +137 -0
- package/templates/vault/whatsapp-cloud-api/scripts/setup_project.py +118 -0
- package/templates/vault/whatsapp-cloud-api/scripts/validate_config.py +190 -0
- package/templates/vault/youtube-summarizer/scripts/extract-transcript.py +65 -0
- package/templates/vault/youtube-summarizer/scripts/install-dependencies.sh +28 -0
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Script principal de geracao de imagens via Stability AI API.
|
|
3
|
+
|
|
4
|
+
Suporta: text-to-image (SD3.5, Ultra, Core), img2img, upscale, inpaint,
|
|
5
|
+
remove-background, search-and-replace, erase.
|
|
6
|
+
|
|
7
|
+
Uso:
|
|
8
|
+
python generate.py --prompt "a mountain sunset" --mode generate
|
|
9
|
+
python generate.py --prompt "watercolor style" --mode img2img --image foto.jpg
|
|
10
|
+
python generate.py --mode upscale --image foto.jpg
|
|
11
|
+
python generate.py --mode remove-bg --image produto.jpg
|
|
12
|
+
python generate.py --list-models
|
|
13
|
+
python generate.py --prompt "retrato fantasy" --analyze --json
|
|
14
|
+
|
|
15
|
+
Versao: 2.0.0
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import base64
|
|
21
|
+
import io
|
|
22
|
+
import json
|
|
23
|
+
import re
|
|
24
|
+
import sys
|
|
25
|
+
import time
|
|
26
|
+
from datetime import datetime
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
from urllib.error import HTTPError, URLError
|
|
29
|
+
from urllib.request import Request, urlopen
|
|
30
|
+
|
|
31
|
+
sys.path.insert(0, str(Path(__file__).parent))
|
|
32
|
+
|
|
33
|
+
from config import (
|
|
34
|
+
API_BASE,
|
|
35
|
+
ENDPOINTS,
|
|
36
|
+
MIME_MAP,
|
|
37
|
+
MODELS,
|
|
38
|
+
DEFAULT_MODEL,
|
|
39
|
+
OUTPUT_DIR,
|
|
40
|
+
OUTPUT_SETTINGS,
|
|
41
|
+
USER_AGENT,
|
|
42
|
+
get_api_key,
|
|
43
|
+
get_all_api_keys,
|
|
44
|
+
get_mime_type,
|
|
45
|
+
resolve_aspect_ratio,
|
|
46
|
+
safety_check_daily_limit,
|
|
47
|
+
increment_daily_counter,
|
|
48
|
+
validate_image_file,
|
|
49
|
+
)
|
|
50
|
+
from styles import apply_style, list_styles
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# ── Exceptions ───────────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class APIError(Exception):
|
|
57
|
+
"""Erro generico da API Stability AI."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, message: str, status_code: int = 0):
|
|
60
|
+
super().__init__(message)
|
|
61
|
+
self.status_code = status_code
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class RateLimitError(APIError):
|
|
65
|
+
"""Rate limit (429) atingido."""
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ContentFilteredError(APIError):
|
|
70
|
+
"""Conteudo filtrado pela moderacao."""
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class AuthenticationError(APIError):
|
|
75
|
+
"""API key invalida ou ausente (401)."""
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class InsufficientCreditsError(APIError):
|
|
80
|
+
"""Creditos insuficientes (402)."""
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# ── API Call ─────────────────────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def api_call(
|
|
88
|
+
endpoint: str,
|
|
89
|
+
api_key: str,
|
|
90
|
+
fields: dict,
|
|
91
|
+
files: dict | None = None,
|
|
92
|
+
accept: str = "image/*",
|
|
93
|
+
timeout: int = 180,
|
|
94
|
+
) -> tuple[bytes | dict, str, dict]:
|
|
95
|
+
"""
|
|
96
|
+
Faz chamada multipart/form-data para a Stability AI API.
|
|
97
|
+
|
|
98
|
+
Retorna (data, content_type, response_headers):
|
|
99
|
+
- Se accept="image/*": data = bytes da imagem
|
|
100
|
+
- Se accept="application/json": data = dict parseado
|
|
101
|
+
"""
|
|
102
|
+
url = f"{API_BASE}{endpoint}"
|
|
103
|
+
boundary = f"----StabilityBoundary{int(time.time() * 1000)}"
|
|
104
|
+
|
|
105
|
+
body = io.BytesIO()
|
|
106
|
+
|
|
107
|
+
# Campos de texto
|
|
108
|
+
for key, value in fields.items():
|
|
109
|
+
if value is None:
|
|
110
|
+
continue
|
|
111
|
+
body.write(f"--{boundary}\r\n".encode())
|
|
112
|
+
body.write(f'Content-Disposition: form-data; name="{key}"\r\n\r\n'.encode())
|
|
113
|
+
body.write(f"{value}\r\n".encode())
|
|
114
|
+
|
|
115
|
+
# Arquivos (imagens)
|
|
116
|
+
if files:
|
|
117
|
+
for key, filepath in files.items():
|
|
118
|
+
if filepath is None:
|
|
119
|
+
continue
|
|
120
|
+
filepath = Path(filepath)
|
|
121
|
+
validated = validate_image_file(filepath)
|
|
122
|
+
mime = get_mime_type(validated)
|
|
123
|
+
|
|
124
|
+
body.write(f"--{boundary}\r\n".encode())
|
|
125
|
+
body.write(
|
|
126
|
+
f'Content-Disposition: form-data; name="{key}"; '
|
|
127
|
+
f'filename="{validated.name}"\r\n'.encode()
|
|
128
|
+
)
|
|
129
|
+
body.write(f"Content-Type: {mime}\r\n\r\n".encode())
|
|
130
|
+
body.write(validated.read_bytes())
|
|
131
|
+
body.write(b"\r\n")
|
|
132
|
+
|
|
133
|
+
body.write(f"--{boundary}--\r\n".encode())
|
|
134
|
+
body_bytes = body.getvalue()
|
|
135
|
+
|
|
136
|
+
req = Request(
|
|
137
|
+
url,
|
|
138
|
+
data=body_bytes,
|
|
139
|
+
headers={
|
|
140
|
+
"Authorization": f"Bearer {api_key}",
|
|
141
|
+
"Content-Type": f"multipart/form-data; boundary={boundary}",
|
|
142
|
+
"Accept": accept,
|
|
143
|
+
"User-Agent": USER_AGENT,
|
|
144
|
+
},
|
|
145
|
+
method="POST",
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
with urlopen(req, timeout=timeout) as resp:
|
|
150
|
+
content_type = resp.headers.get("Content-Type", "")
|
|
151
|
+
headers = dict(resp.headers)
|
|
152
|
+
data = resp.read()
|
|
153
|
+
|
|
154
|
+
if "application/json" in content_type:
|
|
155
|
+
return json.loads(data.decode("utf-8")), "application/json", headers
|
|
156
|
+
return data, content_type, headers
|
|
157
|
+
|
|
158
|
+
except HTTPError as e:
|
|
159
|
+
error_body = e.read().decode("utf-8", errors="replace")
|
|
160
|
+
# Mask API key in error output to prevent credential leakage
|
|
161
|
+
if api_key and api_key in error_body:
|
|
162
|
+
masked_key = f"{api_key[:6]}...masked" if len(api_key) >= 6 else "***masked***"
|
|
163
|
+
error_body = error_body.replace(api_key, masked_key)
|
|
164
|
+
try:
|
|
165
|
+
error_json = json.loads(error_body)
|
|
166
|
+
error_msg = json.dumps(error_json, indent=2, ensure_ascii=False)
|
|
167
|
+
except json.JSONDecodeError:
|
|
168
|
+
error_msg = error_body[:500]
|
|
169
|
+
|
|
170
|
+
if e.code == 401:
|
|
171
|
+
raise AuthenticationError(f"API key invalida ou ausente.\n{error_msg}", e.code)
|
|
172
|
+
if e.code == 402:
|
|
173
|
+
raise InsufficientCreditsError(f"Creditos insuficientes.\n{error_msg}", e.code)
|
|
174
|
+
if e.code == 403:
|
|
175
|
+
raise ContentFilteredError(f"Conteudo filtrado pela moderacao.\n{error_msg}", e.code)
|
|
176
|
+
if e.code == 429:
|
|
177
|
+
raise RateLimitError(f"Rate limit atingido.\n{error_msg}", e.code)
|
|
178
|
+
raise APIError(f"HTTP {e.code}: {error_msg}", e.code)
|
|
179
|
+
|
|
180
|
+
except URLError as e:
|
|
181
|
+
raise APIError(f"Erro de conexao: {e.reason}")
|
|
182
|
+
except TimeoutError:
|
|
183
|
+
raise APIError(f"Timeout ({timeout}s) na chamada para {url}")
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# ── Geracao ──────────────────────────────────────────────────────────────────
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def generate_image(
|
|
190
|
+
prompt: str,
|
|
191
|
+
mode: str = "generate",
|
|
192
|
+
model: str = DEFAULT_MODEL,
|
|
193
|
+
aspect_ratio: str = "1:1",
|
|
194
|
+
style: str | None = None,
|
|
195
|
+
negative_prompt: str | None = None,
|
|
196
|
+
image_path: str | None = None,
|
|
197
|
+
mask_path: str | None = None,
|
|
198
|
+
search_prompt: str | None = None,
|
|
199
|
+
strength: float | None = None,
|
|
200
|
+
seed: int | None = None,
|
|
201
|
+
raw: bool = False,
|
|
202
|
+
output_dir: Path | None = None,
|
|
203
|
+
api_key: str | None = None,
|
|
204
|
+
) -> list[dict]:
|
|
205
|
+
"""
|
|
206
|
+
Gera imagem(ns) e salva no disco.
|
|
207
|
+
|
|
208
|
+
Retorna lista de dicts com info de cada imagem:
|
|
209
|
+
[{"path": Path, "size_kb": float, "time_s": float, "seed": int|None}]
|
|
210
|
+
"""
|
|
211
|
+
output_dir = output_dir or OUTPUT_DIR
|
|
212
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
213
|
+
|
|
214
|
+
# Safety check
|
|
215
|
+
allowed, msg = safety_check_daily_limit(1)
|
|
216
|
+
if not allowed:
|
|
217
|
+
print(f"BLOQUEADO: {msg}", file=sys.stderr)
|
|
218
|
+
return []
|
|
219
|
+
|
|
220
|
+
# Aplicar estilo
|
|
221
|
+
final_prompt = prompt or ""
|
|
222
|
+
style_negative = None
|
|
223
|
+
if not raw and style:
|
|
224
|
+
final_prompt, style_negative = apply_style(final_prompt, style)
|
|
225
|
+
if not negative_prompt and style_negative:
|
|
226
|
+
negative_prompt = style_negative
|
|
227
|
+
|
|
228
|
+
# Obter API keys
|
|
229
|
+
keys = [api_key] if api_key else get_all_api_keys()
|
|
230
|
+
if not keys:
|
|
231
|
+
print(
|
|
232
|
+
"\nERRO: Nenhuma STABILITY_API_KEY encontrada!\n"
|
|
233
|
+
"Configure em .env ou variavel de ambiente.\n"
|
|
234
|
+
"Obtenha sua key gratuita em: https://platform.stability.ai\n",
|
|
235
|
+
file=sys.stderr,
|
|
236
|
+
)
|
|
237
|
+
return []
|
|
238
|
+
|
|
239
|
+
# Determinar endpoint
|
|
240
|
+
endpoint = _resolve_endpoint(mode, model)
|
|
241
|
+
|
|
242
|
+
# Montar campos e arquivos
|
|
243
|
+
fields, files = _build_request(
|
|
244
|
+
mode=mode, model=model, prompt=final_prompt,
|
|
245
|
+
aspect_ratio=aspect_ratio, negative_prompt=negative_prompt,
|
|
246
|
+
image_path=image_path, mask_path=mask_path,
|
|
247
|
+
search_prompt=search_prompt, strength=strength, seed=seed,
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# Retry loop com fallback de keys
|
|
251
|
+
max_retries = 3
|
|
252
|
+
image_data = None
|
|
253
|
+
resp_headers: dict = {}
|
|
254
|
+
elapsed = 0.0
|
|
255
|
+
used_key_index = 0
|
|
256
|
+
|
|
257
|
+
for attempt in range(max_retries):
|
|
258
|
+
for i, key in enumerate(keys):
|
|
259
|
+
try:
|
|
260
|
+
start_time = time.time()
|
|
261
|
+
data, content_type, resp_headers = api_call(
|
|
262
|
+
endpoint=endpoint, api_key=key,
|
|
263
|
+
fields=fields, files=files, accept="image/*",
|
|
264
|
+
)
|
|
265
|
+
elapsed = time.time() - start_time
|
|
266
|
+
|
|
267
|
+
if isinstance(data, bytes) and len(data) > 100:
|
|
268
|
+
image_data = data
|
|
269
|
+
used_key_index = i
|
|
270
|
+
break
|
|
271
|
+
|
|
272
|
+
if isinstance(data, dict) and "image" in data:
|
|
273
|
+
image_data = base64.b64decode(data["image"])
|
|
274
|
+
used_key_index = i
|
|
275
|
+
break
|
|
276
|
+
|
|
277
|
+
print(f"Resposta inesperada (tipo: {content_type}, tamanho: {len(data) if isinstance(data, bytes) else 'dict'})",
|
|
278
|
+
file=sys.stderr)
|
|
279
|
+
|
|
280
|
+
except AuthenticationError as e:
|
|
281
|
+
print(f"Key {i+1} invalida: {e}", file=sys.stderr)
|
|
282
|
+
continue # Tentar proxima key
|
|
283
|
+
|
|
284
|
+
except InsufficientCreditsError as e:
|
|
285
|
+
print(f"ERRO: {e}", file=sys.stderr)
|
|
286
|
+
return [] # Nao adianta retry
|
|
287
|
+
|
|
288
|
+
except ContentFilteredError as e:
|
|
289
|
+
print(f"BLOQUEADO: Conteudo filtrado pela moderacao.\n{e}", file=sys.stderr)
|
|
290
|
+
return [] # Nao adianta retry
|
|
291
|
+
|
|
292
|
+
except RateLimitError:
|
|
293
|
+
wait = 15 * (attempt + 1)
|
|
294
|
+
print(f"Rate limit. Aguardando {wait}s...", file=sys.stderr)
|
|
295
|
+
time.sleep(wait)
|
|
296
|
+
break # Retry com todas as keys
|
|
297
|
+
|
|
298
|
+
except APIError as e:
|
|
299
|
+
is_last_key = i >= len(keys) - 1
|
|
300
|
+
if not is_last_key:
|
|
301
|
+
print(f"Key {i+1} falhou, tentando backup...", file=sys.stderr)
|
|
302
|
+
continue
|
|
303
|
+
if attempt < max_retries - 1:
|
|
304
|
+
wait = 5 * (attempt + 1)
|
|
305
|
+
print(f"Erro. Retry em {wait}s...", file=sys.stderr)
|
|
306
|
+
time.sleep(wait)
|
|
307
|
+
break
|
|
308
|
+
print(f"ERRO: {e}", file=sys.stderr)
|
|
309
|
+
return []
|
|
310
|
+
|
|
311
|
+
except Exception as e:
|
|
312
|
+
print(f"ERRO inesperado: {type(e).__name__}: {e}", file=sys.stderr)
|
|
313
|
+
if attempt >= max_retries - 1:
|
|
314
|
+
return []
|
|
315
|
+
time.sleep(5)
|
|
316
|
+
break
|
|
317
|
+
|
|
318
|
+
if image_data:
|
|
319
|
+
break
|
|
320
|
+
|
|
321
|
+
if not image_data:
|
|
322
|
+
print("ERRO: Nenhuma imagem gerada apos todas as tentativas.", file=sys.stderr)
|
|
323
|
+
return []
|
|
324
|
+
|
|
325
|
+
# Salvar imagem
|
|
326
|
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
327
|
+
style_tag = style or ("raw" if raw else "default")
|
|
328
|
+
filename = f"{mode}_{style_tag}_{timestamp}_0.png"
|
|
329
|
+
filepath = output_dir / filename
|
|
330
|
+
|
|
331
|
+
filepath.write_bytes(image_data)
|
|
332
|
+
increment_daily_counter(1)
|
|
333
|
+
|
|
334
|
+
size_kb = len(image_data) / 1024
|
|
335
|
+
resp_seed = resp_headers.get("seed") or resp_headers.get("Seed")
|
|
336
|
+
|
|
337
|
+
# Salvar metadados
|
|
338
|
+
if OUTPUT_SETTINGS["save_metadata"]:
|
|
339
|
+
metadata = {
|
|
340
|
+
"original_prompt": prompt,
|
|
341
|
+
"final_prompt": final_prompt,
|
|
342
|
+
"mode": mode,
|
|
343
|
+
"model": model,
|
|
344
|
+
"style": style,
|
|
345
|
+
"aspect_ratio": aspect_ratio,
|
|
346
|
+
"negative_prompt": negative_prompt,
|
|
347
|
+
"seed": resp_seed or seed,
|
|
348
|
+
"strength": strength,
|
|
349
|
+
"image_path": str(image_path) if image_path else None,
|
|
350
|
+
"mask_path": str(mask_path) if mask_path else None,
|
|
351
|
+
"search_prompt": search_prompt,
|
|
352
|
+
"raw": raw,
|
|
353
|
+
"generation_time_seconds": round(elapsed, 2),
|
|
354
|
+
"file_size_bytes": len(image_data),
|
|
355
|
+
"file_size_kb": round(size_kb, 1),
|
|
356
|
+
"generated_at": datetime.now().isoformat(),
|
|
357
|
+
"api_key_index": used_key_index,
|
|
358
|
+
"finish_reason": resp_headers.get("finish-reason", "SUCCESS"),
|
|
359
|
+
"skill_version": "2.0.0",
|
|
360
|
+
}
|
|
361
|
+
meta_path = output_dir / f"{filename}.meta.json"
|
|
362
|
+
meta_path.write_text(
|
|
363
|
+
json.dumps(metadata, indent=2, ensure_ascii=False, default=str),
|
|
364
|
+
encoding="utf-8",
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
print(f"Imagem salva: {filepath}")
|
|
368
|
+
print(f"Tamanho: {size_kb:.1f} KB")
|
|
369
|
+
print(f"Tempo: {elapsed:.1f}s")
|
|
370
|
+
|
|
371
|
+
return [{"path": filepath, "size_kb": round(size_kb, 1), "time_s": round(elapsed, 1), "seed": resp_seed}]
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
# ── Helpers ──────────────────────────────────────────────────────────────────
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def _resolve_endpoint(mode: str, model: str) -> str:
|
|
378
|
+
"""Determina o endpoint da API com base no modo e modelo."""
|
|
379
|
+
mode_map = {
|
|
380
|
+
"generate": MODELS.get(model, {}).get("endpoint", "generate_sd3"),
|
|
381
|
+
"ultra": "generate_ultra",
|
|
382
|
+
"core": "generate_core",
|
|
383
|
+
"img2img": "generate_sd3",
|
|
384
|
+
"upscale": "upscale_conservative",
|
|
385
|
+
"upscale-creative": "upscale_creative",
|
|
386
|
+
"remove-bg": "remove_bg",
|
|
387
|
+
"inpaint": "inpaint",
|
|
388
|
+
"search-replace": "search_replace",
|
|
389
|
+
"erase": "erase",
|
|
390
|
+
}
|
|
391
|
+
endpoint_key = mode_map.get(mode, "generate_sd3")
|
|
392
|
+
return ENDPOINTS.get(endpoint_key, ENDPOINTS["generate_sd3"])
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def _build_request(
|
|
396
|
+
mode: str,
|
|
397
|
+
model: str,
|
|
398
|
+
prompt: str,
|
|
399
|
+
aspect_ratio: str,
|
|
400
|
+
negative_prompt: str | None,
|
|
401
|
+
image_path: str | None,
|
|
402
|
+
mask_path: str | None,
|
|
403
|
+
search_prompt: str | None,
|
|
404
|
+
strength: float | None,
|
|
405
|
+
seed: int | None,
|
|
406
|
+
) -> tuple[dict, dict | None]:
|
|
407
|
+
"""Monta campos e arquivos para a request multipart."""
|
|
408
|
+
fields: dict = {}
|
|
409
|
+
files: dict | None = None
|
|
410
|
+
|
|
411
|
+
# Campos comuns de texto
|
|
412
|
+
common_text_fields = {}
|
|
413
|
+
if negative_prompt:
|
|
414
|
+
common_text_fields["negative_prompt"] = negative_prompt
|
|
415
|
+
if seed is not None:
|
|
416
|
+
common_text_fields["seed"] = str(seed)
|
|
417
|
+
common_text_fields["output_format"] = "png"
|
|
418
|
+
|
|
419
|
+
if mode in ("generate", "img2img"):
|
|
420
|
+
fields["prompt"] = prompt
|
|
421
|
+
fields.update(common_text_fields)
|
|
422
|
+
if mode == "generate":
|
|
423
|
+
fields["aspect_ratio"] = aspect_ratio
|
|
424
|
+
model_config = MODELS.get(model, MODELS[DEFAULT_MODEL])
|
|
425
|
+
if model_config["endpoint"] == "generate_sd3":
|
|
426
|
+
fields["model"] = model_config["id"]
|
|
427
|
+
if mode == "img2img" and image_path:
|
|
428
|
+
fields["mode"] = "image-to-image"
|
|
429
|
+
if strength is not None:
|
|
430
|
+
fields["strength"] = str(min(max(strength, 0.0), 1.0))
|
|
431
|
+
files = {"image": image_path}
|
|
432
|
+
|
|
433
|
+
elif mode in ("ultra", "core"):
|
|
434
|
+
fields["prompt"] = prompt
|
|
435
|
+
fields["aspect_ratio"] = aspect_ratio
|
|
436
|
+
fields.update(common_text_fields)
|
|
437
|
+
|
|
438
|
+
elif mode in ("upscale", "upscale-creative"):
|
|
439
|
+
fields.update(common_text_fields)
|
|
440
|
+
if prompt:
|
|
441
|
+
fields["prompt"] = prompt
|
|
442
|
+
files = {"image": image_path}
|
|
443
|
+
|
|
444
|
+
elif mode == "remove-bg":
|
|
445
|
+
fields["output_format"] = "png"
|
|
446
|
+
files = {"image": image_path}
|
|
447
|
+
|
|
448
|
+
elif mode == "inpaint":
|
|
449
|
+
fields["prompt"] = prompt
|
|
450
|
+
fields.update(common_text_fields)
|
|
451
|
+
files = {"image": image_path}
|
|
452
|
+
if mask_path:
|
|
453
|
+
files["mask"] = mask_path
|
|
454
|
+
|
|
455
|
+
elif mode == "search-replace":
|
|
456
|
+
fields["prompt"] = prompt
|
|
457
|
+
fields.update(common_text_fields)
|
|
458
|
+
if search_prompt:
|
|
459
|
+
fields["search_prompt"] = search_prompt
|
|
460
|
+
files = {"image": image_path}
|
|
461
|
+
|
|
462
|
+
elif mode == "erase":
|
|
463
|
+
fields["output_format"] = "png"
|
|
464
|
+
files = {"image": image_path}
|
|
465
|
+
if mask_path:
|
|
466
|
+
files["mask"] = mask_path
|
|
467
|
+
|
|
468
|
+
return fields, files
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def analyze_prompt(prompt: str) -> dict:
|
|
472
|
+
"""Analisa prompt e sugere configuracoes ideais."""
|
|
473
|
+
prompt_lower = prompt.lower()
|
|
474
|
+
|
|
475
|
+
# Detectar estilo
|
|
476
|
+
style = None
|
|
477
|
+
style_hints = {
|
|
478
|
+
"photorealistic": ["foto", "photo", "realistic", "camera", "portrait", "dslr"],
|
|
479
|
+
"anime": ["anime", "manga", "ghibli", "kawaii", "chibi", "otaku"],
|
|
480
|
+
"digital-art": ["digital", "artstation", "deviantart", "digital art"],
|
|
481
|
+
"oil-painting": ["oil", "oleo", "canvas", "pintura classica"],
|
|
482
|
+
"watercolor": ["watercolor", "aquarela", "wash", "aguada"],
|
|
483
|
+
"pixel-art": ["pixel", "8-bit", "16-bit", "retro game", "sprite"],
|
|
484
|
+
"3d-render": ["3d", "render", "blender", "unreal", "octane", "cinema4d"],
|
|
485
|
+
"concept-art": ["concept", "concept art", "game art", "matte painting"],
|
|
486
|
+
"comic": ["comic", "hq", "quadrinho", "manga style", "graphic novel"],
|
|
487
|
+
"fantasy": ["fantasy", "magic", "dragon", "elf", "medieval", "enchanted"],
|
|
488
|
+
"sci-fi": ["sci-fi", "cyberpunk", "futuristic", "space", "neon", "cyber"],
|
|
489
|
+
"sketch": ["sketch", "pencil", "drawing", "charcoal", "lapis", "rascunho"],
|
|
490
|
+
"noir": ["noir", "black and white", "detective", "moody", "shadows"],
|
|
491
|
+
"pop-art": ["pop art", "warhol", "bold colors", "vibrante"],
|
|
492
|
+
"minimalist": ["minimalist", "clean", "simple", "flat design"],
|
|
493
|
+
}
|
|
494
|
+
for style_name, keywords in style_hints.items():
|
|
495
|
+
if any(kw in prompt_lower for kw in keywords):
|
|
496
|
+
style = style_name
|
|
497
|
+
break
|
|
498
|
+
|
|
499
|
+
# Detectar aspect ratio
|
|
500
|
+
ratio = "1:1"
|
|
501
|
+
ratio_hints = {
|
|
502
|
+
"16:9": ["landscape", "paisagem", "wide", "panorama", "cinema", "wallpaper", "widescreen"],
|
|
503
|
+
"9:16": ["portrait", "retrato", "vertical", "stories", "mobile", "phone", "tiktok", "reels"],
|
|
504
|
+
"2:3": ["poster", "book", "cover", "pinterest", "cartaz"],
|
|
505
|
+
"3:2": ["photo", "foto", "horizontal", "banner"],
|
|
506
|
+
"4:5": ["instagram", "ig", "feed"],
|
|
507
|
+
}
|
|
508
|
+
for r, keywords in ratio_hints.items():
|
|
509
|
+
if any(kw in prompt_lower for kw in keywords):
|
|
510
|
+
ratio = r
|
|
511
|
+
break
|
|
512
|
+
|
|
513
|
+
# Detectar modelo
|
|
514
|
+
suggested_model = "sd3.5-large"
|
|
515
|
+
if any(kw in prompt_lower for kw in ["ultra", "premium", "best quality", "8k", "4k", "maximum"]):
|
|
516
|
+
suggested_model = "ultra"
|
|
517
|
+
elif any(kw in prompt_lower for kw in ["quick", "fast", "rapido", "draft", "rascunho"]):
|
|
518
|
+
suggested_model = "sd3.5-large-turbo"
|
|
519
|
+
elif any(kw in prompt_lower for kw in ["core", "simple", "simples", "basico"]):
|
|
520
|
+
suggested_model = "core"
|
|
521
|
+
|
|
522
|
+
# Detectar modo
|
|
523
|
+
suggested_mode = "generate"
|
|
524
|
+
if any(kw in prompt_lower for kw in ["upscale", "increase resolution", "melhorar resolucao", "aumentar"]):
|
|
525
|
+
suggested_mode = "upscale"
|
|
526
|
+
elif any(kw in prompt_lower for kw in ["remove background", "remover fundo", "sem fundo", "transparente"]):
|
|
527
|
+
suggested_mode = "remove-bg"
|
|
528
|
+
elif any(kw in prompt_lower for kw in ["inpaint", "editar parte", "modificar area"]):
|
|
529
|
+
suggested_mode = "inpaint"
|
|
530
|
+
elif any(kw in prompt_lower for kw in ["replace", "substituir", "trocar"]):
|
|
531
|
+
suggested_mode = "search-replace"
|
|
532
|
+
elif any(kw in prompt_lower for kw in ["erase", "apagar", "remover objeto"]):
|
|
533
|
+
suggested_mode = "erase"
|
|
534
|
+
|
|
535
|
+
return {
|
|
536
|
+
"suggested_style": style,
|
|
537
|
+
"suggested_aspect_ratio": ratio,
|
|
538
|
+
"suggested_model": suggested_model,
|
|
539
|
+
"suggested_mode": suggested_mode,
|
|
540
|
+
"prompt": prompt,
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
# ── CLI ──────────────────────────────────────────────────────────────────────
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def main():
|
|
548
|
+
parser = argparse.ArgumentParser(
|
|
549
|
+
description="Gerar imagens via Stability AI (Stable Diffusion 3.5, Ultra, Core)",
|
|
550
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
551
|
+
epilog=(
|
|
552
|
+
"Exemplos:\n"
|
|
553
|
+
' python generate.py --prompt "mountain sunset" --mode generate\n'
|
|
554
|
+
' python generate.py --prompt "watercolor cat" --style watercolor\n'
|
|
555
|
+
' python generate.py --prompt "epic portrait" --mode ultra --aspect-ratio wide\n'
|
|
556
|
+
' python generate.py --mode upscale --image foto.jpg\n'
|
|
557
|
+
' python generate.py --mode remove-bg --image produto.jpg\n'
|
|
558
|
+
" python generate.py --list-models\n"
|
|
559
|
+
" python generate.py --list-styles\n"
|
|
560
|
+
),
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
# Principal
|
|
564
|
+
parser.add_argument("--prompt", type=str, help="Prompt de texto para geracao")
|
|
565
|
+
parser.add_argument(
|
|
566
|
+
"--mode", type=str, default="generate",
|
|
567
|
+
choices=["generate", "ultra", "core", "img2img", "upscale", "upscale-creative",
|
|
568
|
+
"remove-bg", "inpaint", "search-replace", "erase"],
|
|
569
|
+
help="Modo de geracao (default: generate)",
|
|
570
|
+
)
|
|
571
|
+
|
|
572
|
+
# Modelo e estilo
|
|
573
|
+
parser.add_argument("--model", type=str, default=DEFAULT_MODEL, help=f"Modelo (default: {DEFAULT_MODEL})")
|
|
574
|
+
parser.add_argument("--style", type=str, default=None, help="Estilo pre-configurado")
|
|
575
|
+
parser.add_argument("--aspect-ratio", type=str, default="1:1", help="Aspect ratio (ex: 16:9, square, ig)")
|
|
576
|
+
parser.add_argument("--negative-prompt", type=str, default=None, help="O que evitar na imagem")
|
|
577
|
+
parser.add_argument("--seed", type=int, default=None, help="Seed para reprodutibilidade")
|
|
578
|
+
parser.add_argument("--strength", type=float, default=None, help="Forca para img2img (0.0-1.0)")
|
|
579
|
+
parser.add_argument("--raw", action="store_true", help="Nao aplicar estilo, usar prompt como esta")
|
|
580
|
+
|
|
581
|
+
# Imagens de entrada
|
|
582
|
+
parser.add_argument("--image", type=str, default=None, help="Imagem de entrada")
|
|
583
|
+
parser.add_argument("--mask", type=str, default=None, help="Mascara para inpainting/erase")
|
|
584
|
+
parser.add_argument("--search", type=str, default=None, help="Texto para search-and-replace")
|
|
585
|
+
|
|
586
|
+
# Output
|
|
587
|
+
parser.add_argument("--output", type=Path, default=None, help="Diretorio de saida")
|
|
588
|
+
|
|
589
|
+
# Utilidades
|
|
590
|
+
parser.add_argument("--analyze", action="store_true", help="Analisar prompt e sugerir config")
|
|
591
|
+
parser.add_argument("--list-models", action="store_true", help="Listar modelos disponiveis")
|
|
592
|
+
parser.add_argument("--list-styles", action="store_true", help="Listar estilos disponiveis")
|
|
593
|
+
parser.add_argument("--json", action="store_true", help="Saida em JSON")
|
|
594
|
+
|
|
595
|
+
args = parser.parse_args()
|
|
596
|
+
|
|
597
|
+
# --- Utilidades ---
|
|
598
|
+
if args.list_models:
|
|
599
|
+
if args.json:
|
|
600
|
+
print(json.dumps(MODELS, indent=2, ensure_ascii=False))
|
|
601
|
+
else:
|
|
602
|
+
print("\n Modelos Disponiveis:\n")
|
|
603
|
+
for key, m in MODELS.items():
|
|
604
|
+
print(f" {key:25s} {m['name']}")
|
|
605
|
+
print(f" {'':25s} {m['description']}")
|
|
606
|
+
print(f" {'':25s} Custo: {m['cost']}\n")
|
|
607
|
+
return
|
|
608
|
+
|
|
609
|
+
if args.list_styles:
|
|
610
|
+
styles = list_styles()
|
|
611
|
+
if args.json:
|
|
612
|
+
print(json.dumps(styles, indent=2, ensure_ascii=False))
|
|
613
|
+
else:
|
|
614
|
+
print("\n Estilos Disponiveis:\n")
|
|
615
|
+
for key, s in styles.items():
|
|
616
|
+
print(f" {key:20s} {s['name']}")
|
|
617
|
+
return
|
|
618
|
+
|
|
619
|
+
if args.analyze:
|
|
620
|
+
if not args.prompt:
|
|
621
|
+
print("ERRO: --analyze requer --prompt", file=sys.stderr)
|
|
622
|
+
sys.exit(1)
|
|
623
|
+
result = analyze_prompt(args.prompt)
|
|
624
|
+
if args.json:
|
|
625
|
+
print(json.dumps(result, indent=2, ensure_ascii=False))
|
|
626
|
+
else:
|
|
627
|
+
print("\n Analise do Prompt:\n")
|
|
628
|
+
for k, v in result.items():
|
|
629
|
+
print(f" {k:30s} {v}")
|
|
630
|
+
return
|
|
631
|
+
|
|
632
|
+
# --- Validacao ---
|
|
633
|
+
needs_prompt = args.mode in ("generate", "ultra", "core", "img2img", "inpaint", "search-replace")
|
|
634
|
+
needs_image = args.mode in ("img2img", "upscale", "upscale-creative", "remove-bg", "inpaint", "search-replace", "erase")
|
|
635
|
+
|
|
636
|
+
if needs_prompt and not args.prompt:
|
|
637
|
+
print(f"ERRO: modo '{args.mode}' requer --prompt", file=sys.stderr)
|
|
638
|
+
sys.exit(1)
|
|
639
|
+
if needs_image and not args.image:
|
|
640
|
+
print(f"ERRO: modo '{args.mode}' requer --image", file=sys.stderr)
|
|
641
|
+
sys.exit(1)
|
|
642
|
+
|
|
643
|
+
# --- Execucao ---
|
|
644
|
+
aspect = resolve_aspect_ratio(args.aspect_ratio)
|
|
645
|
+
|
|
646
|
+
print("=" * 60)
|
|
647
|
+
print(" STABILITY AI - Gerando Imagem")
|
|
648
|
+
print("=" * 60)
|
|
649
|
+
print(f" Modo: {args.mode}")
|
|
650
|
+
print(f" Modelo: {args.model}")
|
|
651
|
+
if args.style:
|
|
652
|
+
print(f" Estilo: {args.style}")
|
|
653
|
+
print(f" Aspect Ratio: {aspect}")
|
|
654
|
+
if args.image:
|
|
655
|
+
print(f" Imagem input: {args.image}")
|
|
656
|
+
print("=" * 60)
|
|
657
|
+
print()
|
|
658
|
+
|
|
659
|
+
results = generate_image(
|
|
660
|
+
prompt=args.prompt or "",
|
|
661
|
+
mode=args.mode, model=args.model, aspect_ratio=aspect,
|
|
662
|
+
style=args.style, negative_prompt=args.negative_prompt,
|
|
663
|
+
image_path=args.image, mask_path=args.mask,
|
|
664
|
+
search_prompt=args.search, strength=args.strength,
|
|
665
|
+
seed=args.seed, raw=args.raw, output_dir=args.output,
|
|
666
|
+
)
|
|
667
|
+
|
|
668
|
+
if args.json:
|
|
669
|
+
output = {
|
|
670
|
+
"generated": [str(r["path"]) for r in results],
|
|
671
|
+
"count": len(results),
|
|
672
|
+
"output_dir": str(results[0]["path"].parent) if results else None,
|
|
673
|
+
"details": [{
|
|
674
|
+
"path": str(r["path"]),
|
|
675
|
+
"size_kb": r["size_kb"],
|
|
676
|
+
"time_s": r["time_s"],
|
|
677
|
+
"seed": r.get("seed"),
|
|
678
|
+
} for r in results],
|
|
679
|
+
}
|
|
680
|
+
print(json.dumps(output, indent=2, ensure_ascii=False))
|
|
681
|
+
|
|
682
|
+
if not results:
|
|
683
|
+
sys.exit(1)
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
if __name__ == "__main__":
|
|
687
|
+
main()
|