⚙️ Infrastructure Scripts

Automação, Discovery e Análise do AIOS

📊 Visão Geral dos Scripts

ScriptLOCEpicFunção
qa-loop-orchestrator.js1262Epic 6Loop review → fix → re-review
gotchas-documenter.js1295Epic 7Extrai gotchas de insights
test-discovery.js1259Gap AnalysisDetecta frameworks de teste
cicd-discovery.js1268Gap AnalysisDetecta CI/CD infrastructure
documentation-synchronizer.js1431-Sincroniza docs com código
squad-generator.js1405SQS-4Gera estrutura de squads
pattern-learner.js1224-Aprende padrões de sucesso
greeting-builder.js1404ACT-7Constrói greetings contextuais

🔄 QA Loop Orchestrator

Orquestra o ciclo automatizado de review → fix → re-review com state management completo.

Acceptance Criteria (Story 6.5)

  • AC1: Loop automático: review → fix → re-review
  • AC2: Máximo 5 iterações (configurável via autoClaude.qaLoop.maxIterations)
  • AC3: Após 5 iterações: escala para humano com full context
  • AC4: Track iteração atual em qa/loop-status.json
  • AC5: Interrupção manual via *stop-qa-loop
  • AC6: Summary ao final com histórico de iterações
  • AC7: Integra com status.json para dashboard

Loop Status

const LoopStatus = {
  PENDING: 'pending',      // ⏳
  IN_PROGRESS: 'in_progress', // 🔄
  COMPLETED: 'completed',  // ✅
  STOPPED: 'stopped',      // ⏹️
  ESCALATED: 'escalated',  // 🚨
};

const Verdict = {
  APPROVE: 'APPROVE',  // ✅
  REJECT: 'REJECT',    // ❌
  BLOCKED: 'BLOCKED',  // 🚫
};

Configuration

  • defaultMaxIterations: 5
  • reviewTimeout: 30 minutes
  • fixTimeout: 60 minutes
  • abandonedThreshold: 1 hour

📝 Gotchas Documenter

Extrai gotchas automaticamente de session insights e consolida em knowledge base pesquisável.

Output Format (AC3)

{
  wrong: "O que estava errado",
  right: "A forma correta",
  reason: "Por que isso importa",
  category: "API|Frontend|Database|...",
  severity: "high|medium|low"
}

Categories (AC4)

STATE_MANAGEMENT zustand, redux, state, store
API fetch, axios, http, endpoint
DATABASE sql, postgres, prisma, supabase
FRONTEND react, component, hook, jsx
TESTING test, jest, vitest, mock
TYPESCRIPT type, interface, generic
SECURITY xss, csrf, injection
PERFORMANCE memory, optimization, cache

Outputs

  • .aios/gotchas.md - Consolidated markdown
  • .aios/gotchas.json - Structured JSON

🧪 Test Discovery

Auto-detecta frameworks de teste, arquivos de teste, e provê execução inteligente.

Frameworks Suportados

FrameworkConfig FilesTest Patterns
Jestjest.config.js, .ts, .json*.test.js, *.spec.js
Vitestvitest.config.js, vite.config.js*.test.ts, *.spec.ts
Mocha.mocharc.js, .json, .yamltest/**/*.js
Pytestpytest.ini, pyproject.tomltest_*.py, *_test.py
RSpec.rspec, spec/spec_helper.rbspec/**/*_spec.rb
Go Testgo.mod*_test.go
PHPUnitphpunit.xml*Test.php
JUnitpom.xml, build.gradle*Test.java
Playwrightplaywright.config.js*.spec.ts (e2e)
Cypresscypress.config.js*.cy.js (e2e)

Capabilities

  • Auto-detection de framework pelo package.json
  • Run command generation (--coverage, --watch)
  • Selective testing (--findRelatedTests)
  • E2E vs Unit test differentiation

🚀 CI/CD Discovery

Auto-detecta CI/CD infrastructure e provê integration points para AIOS workflows.

Providers Suportados

ProviderConfig PathTriggers
GitHub Actions.github/workflows/*.ymlpush, pull_request, schedule
GitLab CI.gitlab-ci.ymlpush, merge_request, schedule
JenkinsJenkinsfilescm, cron, upstream
CircleCI.circleci/config.ymlpush, pull_request, api
Travis CI.travis.ymlpush, pull_request, cron
Azure Pipelinesazure-pipelines.ymlpush, pull_request, manual
Bitbucketbitbucket-pipelines.ymlpush, pull_request
AWS CodePipelinebuildspec.ymlpush, manual

ConfigParser

Parser YAML simplificado sem dependências externas. Também parseia Jenkinsfile (Groovy-based).

📚 Documentation Synchronizer

Sincroniza automaticamente documentação com mudanças de código.

Sync Strategies

  • jsdoc - Sync JSDoc comments com markdown docs
  • markdown - Update markdown files com code changes
  • schema - Sync YAML/JSON schemas com structures
  • api - Update API docs com endpoint changes
  • examples - Update code examples em docs

Configuration

{
  autoSync: true,
  syncInterval: 60000, // 1 minute
  docFormats: ['.md', '.yaml', '.yml', '.json'],
  codeFormats: ['.js', '.jsx', '.ts', '.tsx'],
  syncStrategies: ['jsdoc', 'markdown', 'schema', 'api', 'examples']
}

🎭 Squad Generator

Gera estrutura de squad seguindo arquitetura task-first. Usado pelo *create-squad task do squad-creator agent.

Squad Structure

squads/my-squad/
├── config/
├── agents/
├── tasks/
├── workflows/
├── checklists/
├── templates/
├── tools/
├── scripts/
└── data/

Templates Disponíveis

  • basic - Squad básico
  • etl - Squad de ETL/data
  • agent-only - Só agentes

Config Modes

  • extend - Estende config existente
  • override - Sobrescreve config
  • none - Sem config changes

🧠 Pattern Learner & Greeting Builder

Pattern Learner (1224 LOC)

Aprende de modificações bem-sucedidas para sugerir melhorias.

  • Threshold: 3 ocorrências para aprender
  • Similaridade: 80% para match
  • Extrai: code patterns, structural, refactoring, dependency, performance

Greeting Builder (1404 LOC)

Constrói greetings inteligentes baseado em contexto.

  • Session type: new/existing/workflow
  • Git config status
  • Project status (narrative)
  • Previous agent handoff
  • Timeout: 150ms per section