@luanpdd/kit-mcp 1.9.0 → 1.11.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.
- package/CHANGELOG.md +86 -0
- package/README.md +58 -0
- package/gates/ai-prompt-stability.md +120 -0
- package/gates/golden-signals-coverage.md +133 -0
- package/gates/legacy-refactor-safety.md +178 -0
- package/gates/observability-coverage.md +151 -0
- package/gates/postmortem-template-required.md +127 -0
- package/gates/prr-checklist-coverage.md +128 -0
- package/gates/release-pipeline-policy.md +132 -0
- package/kit/COMANDOS.md +15 -0
- package/kit/agents/ai-mutation-tester.md +298 -0
- package/kit/agents/cascading-failures-auditor.md +306 -0
- package/kit/agents/executor.md +13 -0
- package/kit/agents/golden-signals-instrumenter.md +241 -0
- package/kit/agents/legacy-characterizer.md +378 -0
- package/kit/agents/load-shedding-instrumenter.md +297 -0
- package/kit/agents/observability-coverage-auditor.md +325 -0
- package/kit/agents/omm-auditor.md +99 -0
- package/kit/agents/payload-capture-instrumenter.md +283 -0
- package/kit/agents/planner.md +29 -0
- package/kit/agents/postmortem-writer.md +282 -0
- package/kit/agents/prr-conductor.md +296 -0
- package/kit/agents/refactor-safety-auditor.md +414 -0
- package/kit/agents/release-pipeline-auditor.md +360 -0
- package/kit/agents/seam-finder.md +367 -0
- package/kit/agents/shotgun-surgery-detector.md +359 -0
- package/kit/agents/storytelling-analyst.md +309 -0
- package/kit/agents/supabase-architect.md +49 -0
- package/kit/agents/supabase-edge-fn-writer.md +114 -0
- package/kit/agents/supabase-migration-writer.md +80 -0
- package/kit/agents/supabase-storage-implementer.md +156 -0
- package/kit/agents/toil-auditor.md +277 -0
- package/kit/agents/verifier.md +30 -0
- package/kit/commands/auditar-cascading.md +111 -0
- package/kit/commands/auditar-marco.md +124 -1
- package/kit/commands/auditar-observabilidade-cobertura.md +183 -0
- package/kit/commands/auditar-refactor.md +219 -0
- package/kit/commands/auditar-release.md +109 -0
- package/kit/commands/auditar-toil.md +129 -0
- package/kit/commands/capturar-payloads.md +193 -0
- package/kit/commands/caracterizar-prompt.md +195 -0
- package/kit/commands/caracterizar.md +212 -0
- package/kit/commands/concluir-marco.md +95 -1
- package/kit/commands/detectar-duplicacao.md +197 -0
- package/kit/commands/discutir-fase.md +41 -0
- package/kit/commands/encontrar-seams.md +136 -0
- package/kit/commands/forense.md +103 -1
- package/kit/commands/golden-signals.md +142 -0
- package/kit/commands/legacy.md +263 -0
- package/kit/commands/load-shedding.md +117 -0
- package/kit/commands/observabilidade.md +2 -0
- package/kit/commands/postmortem.md +179 -0
- package/kit/commands/prr.md +205 -0
- package/kit/commands/refactor-seguro.md +321 -0
- package/kit/commands/risk-budget.md +220 -0
- package/kit/commands/sre.md +230 -0
- package/kit/commands/storytelling.md +179 -0
- package/kit/skills/_shared-legacy/glossary.md +389 -0
- package/kit/skills/_shared-sre/glossary.md +712 -0
- package/kit/skills/ai-prompt-characterization/SKILL.md +335 -0
- package/kit/skills/blameless-postmortems/SKILL.md +340 -0
- package/kit/skills/cascading-failures/SKILL.md +307 -0
- package/kit/skills/eliminating-toil/SKILL.md +243 -0
- package/kit/skills/event-based-slos/SKILL.md +22 -0
- package/kit/skills/four-golden-signals/SKILL.md +314 -0
- package/kit/skills/hermetic-builds/SKILL.md +323 -0
- package/kit/skills/legacy-api-only-applications/SKILL.md +358 -0
- package/kit/skills/legacy-characterization-tests/SKILL.md +330 -0
- package/kit/skills/legacy-effect-analysis/SKILL.md +331 -0
- package/kit/skills/legacy-extract-class/SKILL.md +203 -0
- package/kit/skills/legacy-monster-methods/SKILL.md +444 -0
- package/kit/skills/legacy-programming-by-difference/SKILL.md +252 -0
- package/kit/skills/legacy-seams-and-test-harness/SKILL.md +460 -0
- package/kit/skills/legacy-shotgun-surgery/SKILL.md +286 -0
- package/kit/skills/legacy-sprout-wrap-techniques/SKILL.md +434 -0
- package/kit/skills/legacy-storytelling-naked-crc/SKILL.md +270 -0
- package/kit/skills/llm-as-dependency/SKILL.md +436 -0
- package/kit/skills/load-shedding-graceful-degradation/SKILL.md +396 -0
- package/kit/skills/pre-refactor-characterization/SKILL.md +421 -0
- package/kit/skills/production-readiness-review/SKILL.md +305 -0
- package/kit/skills/release-engineering/SKILL.md +367 -0
- package/kit/skills/retry-strategies/SKILL.md +372 -0
- package/kit/skills/sre-risk-management/SKILL.md +221 -0
- package/package.json +2 -2
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: golden-signals
|
|
3
|
+
description: Invoca golden-signals-instrumenter para serviço/Edge Function/fase — instrumenta 4 golden signals OTel (Latency histogram, Traffic counter, Errors counter, Saturation gauge).
|
|
4
|
+
argument-hint: "<target> [--service <name>] [--saturation <resource>] [--runtime <node|deno|python>]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Grep
|
|
10
|
+
- Glob
|
|
11
|
+
- Task
|
|
12
|
+
- AskUserQuestion
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Instrumentar um serviço/Edge Function/fase com os **4 golden signals** do cap 6 do livro Google SRE — Latency (histogram bucketed), Traffic (counter), Errors (counter por `error.type`), Saturation (gauge resource-specific). Invoca o agente [`golden-signals-instrumenter`](../agents/golden-signals-instrumenter.md) que aplica a skill [`four-golden-signals`](../skills/four-golden-signals/SKILL.md).
|
|
17
|
+
|
|
18
|
+
**Cria/Atualiza:**
|
|
19
|
+
- Patches OTel nos arquivos do `<target>` (Latency + Traffic + Errors + Saturation)
|
|
20
|
+
- `GOLDEN-SIGNALS.md` por target com tabela de instrumentação aplicada (output do agent)
|
|
21
|
+
|
|
22
|
+
**Após:** os 4 signals estão instrumentados e o user pode rodar smoke local para verificar histogram/counter/gauge no backend OTel.
|
|
23
|
+
</objective>
|
|
24
|
+
|
|
25
|
+
<context>
|
|
26
|
+
**Argumentos:** `$ARGUMENTS` — primeiro token é o `<target>` (path de arquivo, diretório de service, ou número de fase como `38`); restante são flags.
|
|
27
|
+
|
|
28
|
+
**Flags:**
|
|
29
|
+
- `--service <name>` — nome canônico do serviço (default: deriva de `package.json#name` ou diretório)
|
|
30
|
+
- `--saturation <resource>` — recurso de saturation (`db_connection_pool` | `cache_memory` | `queue_depth` | `concurrency_limit` | `cpu_load` | `egress_bandwidth`); se omitido, agent infere via heurística
|
|
31
|
+
- `--runtime <node|deno|python>` — runtime; se omitido, detecta via `package.json`/`deno.json`/`pyproject.toml`
|
|
32
|
+
|
|
33
|
+
**Exemplos:**
|
|
34
|
+
```
|
|
35
|
+
/golden-signals src/orders/handler.ts # 1 arquivo
|
|
36
|
+
/golden-signals supabase/functions/process-emails # 1 Edge Function
|
|
37
|
+
/golden-signals 38 # todos os arquivos modificados pela Phase 38
|
|
38
|
+
/golden-signals src/api --service orders-api --saturation db_connection_pool
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Pré-requisito:** OTel SDK pode estar ausente — agent flagga deps necessárias no output. Caller decide instalar.
|
|
42
|
+
</context>
|
|
43
|
+
|
|
44
|
+
<process>
|
|
45
|
+
|
|
46
|
+
## 1. Parsear argumentos
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
TARGET=$(echo "$ARGUMENTS" | awk '{print $1}')
|
|
50
|
+
SERVICE=$(echo "$ARGUMENTS" | grep -oE -- '--service [^ ]+' | awk '{print $2}')
|
|
51
|
+
SATURATION=$(echo "$ARGUMENTS" | grep -oE -- '--saturation [^ ]+' | awk '{print $2}')
|
|
52
|
+
RUNTIME=$(echo "$ARGUMENTS" | grep -oE -- '--runtime [^ ]+' | awk '{print $2}')
|
|
53
|
+
|
|
54
|
+
if [ -z "$TARGET" ]; then
|
|
55
|
+
echo "Uso: /golden-signals <target> [--service N] [--saturation R] [--runtime RT]"
|
|
56
|
+
echo "Exemplos:"
|
|
57
|
+
echo " /golden-signals src/orders/handler.ts"
|
|
58
|
+
echo " /golden-signals supabase/functions/process-emails"
|
|
59
|
+
echo " /golden-signals 38 # todos arquivos da Phase 38"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 2. Resolver target → lista de target_files
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# PT-BR: 3 modos de resolução
|
|
68
|
+
if [[ "$TARGET" =~ ^[0-9]+$ ]]; then
|
|
69
|
+
# Modo fase — extrai files_modified de PLAN.md(s) da Phase $TARGET
|
|
70
|
+
PHASE_STATE=$(node "./.claude/framework/bin/tools.cjs" init phase-op "$TARGET")
|
|
71
|
+
PHASE_DIR=$(echo "$PHASE_STATE" | jq -r .phase_dir)
|
|
72
|
+
if [ "$PHASE_DIR" = "null" ] || [ ! -d "$PHASE_DIR" ]; then
|
|
73
|
+
echo "Fase $TARGET ainda não foi planejada."
|
|
74
|
+
exit 1
|
|
75
|
+
fi
|
|
76
|
+
TARGET_FILES=$(grep -rh "^ - " "$PHASE_DIR"/*-PLAN-*.md | grep -oE '[a-zA-Z0-9_/.-]+\.(ts|js|py|deno|sql)' | sort -u | tr '\n' ' ')
|
|
77
|
+
elif [ -d "$TARGET" ]; then
|
|
78
|
+
# Modo diretório — todos arquivos relevantes (.ts, .js, .py)
|
|
79
|
+
TARGET_FILES=$(find "$TARGET" -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" \) | tr '\n' ' ')
|
|
80
|
+
elif [ -f "$TARGET" ]; then
|
|
81
|
+
# Modo arquivo único
|
|
82
|
+
TARGET_FILES="$TARGET"
|
|
83
|
+
else
|
|
84
|
+
echo "Erro: target '$TARGET' não é arquivo, diretório ou número de fase válido."
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
if [ -z "$TARGET_FILES" ]; then
|
|
89
|
+
echo "Nenhum arquivo encontrado para target '$TARGET'."
|
|
90
|
+
exit 0
|
|
91
|
+
fi
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 3. Dispatch para `golden-signals-instrumenter`
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
Task(
|
|
98
|
+
subagent_type="golden-signals-instrumenter",
|
|
99
|
+
prompt="
|
|
100
|
+
target_files: ${TARGET_FILES}
|
|
101
|
+
${SERVICE:+service_name: ${SERVICE}}
|
|
102
|
+
${RUNTIME:+runtime: ${RUNTIME}}
|
|
103
|
+
${SATURATION:+saturation_resource: ${SATURATION}}
|
|
104
|
+
|
|
105
|
+
Aplicar skill four-golden-signals. Gerar patches OTel para os 4 signals em cada arquivo:
|
|
106
|
+
1. Latency: histogram com explicitBucketBoundaries exponencial, dimension result=success|error
|
|
107
|
+
2. Traffic: counter incrementado antes de processar request
|
|
108
|
+
3. Errors: counter por error_type enum (5-15 valores; NÃO error.message)
|
|
109
|
+
4. Saturation: ObservableGauge do recurso mais escasso (callback lê estado real)
|
|
110
|
+
|
|
111
|
+
Validar 6 checks no Step 3 do agent (latency separado success/error, error_type enum, etc.).
|
|
112
|
+
Output: tabela de patches gerados + GOLDEN-SIGNALS.md por target.
|
|
113
|
+
"
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 4. Pós-output
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
═══════════════════════════════════════════════════════════
|
|
121
|
+
framework ► GOLDEN-SIGNALS ▸ ${TARGET}
|
|
122
|
+
═══════════════════════════════════════════════════════════
|
|
123
|
+
|
|
124
|
+
[output do golden-signals-instrumenter — ver Step 4 do agent]
|
|
125
|
+
|
|
126
|
+
## Próximos passos
|
|
127
|
+
1. Smoke local — enviar request e verificar histogram/counter/gauge no backend OTel
|
|
128
|
+
2. Cross-ref: rodar `/instrumentar-fase ${TARGET}` se spans/wide events ainda ausentes (complementar)
|
|
129
|
+
3. Após validar baseline, definir SLO event-based: `/observabilidade slo <feature>`
|
|
130
|
+
4. PRR antes de production: `/prr --service ${SERVICE:-<name>}`
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
</process>
|
|
134
|
+
|
|
135
|
+
<success_criteria>
|
|
136
|
+
- [ ] `<target>` parseado de $ARGUMENTS (arquivo, diretório, ou número de fase)
|
|
137
|
+
- [ ] `target_files` resolvido para lista não-vazia (3 modos suportados)
|
|
138
|
+
- [ ] `golden-signals-instrumenter` invocado via `Task(subagent_type=...)`
|
|
139
|
+
- [ ] Patches aplicados em todos os arquivos do target (4 signals cada)
|
|
140
|
+
- [ ] Output forwarded transparentemente do agent (sem post-processing)
|
|
141
|
+
- [ ] Próximos passos sugerem cross-ref para `/instrumentar-fase`, `/observabilidade slo`, `/prr`
|
|
142
|
+
</success_criteria>
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: legacy
|
|
3
|
+
description: Orquestrador da Suíte Legacy Code (Feathers) — dispatch para agents (legacy-characterizer, seam-finder, refactor-safety-auditor) com sinônimos PT/EN. 4ª suíte da família após /supabase, /observabilidade, /sre.
|
|
4
|
+
argument-hint: "<subcomando> [args...]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Grep
|
|
10
|
+
- Glob
|
|
11
|
+
- Task
|
|
12
|
+
- AskUserQuestion
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Orquestrador único da Suíte Legacy Code — quarta suíte da família após [`/supabase`](./supabase.md) (v1.8), [`/observabilidade`](./observabilidade.md) (v1.9) e [`/sre`](./sre.md) (v1.10). Recebe subcomando + args, faz dispatch via `Task(subagent_type=...)` para o agent correto. **Único ponto de chain de agents legacy** (anti-pitfall A10 mantido — agents permanecem função pura).
|
|
17
|
+
|
|
18
|
+
**Subcomandos cobrem capítulos do livro Feathers:**
|
|
19
|
+
- `caracterizar` — characterization tests (cap 13 + 23)
|
|
20
|
+
- `encontrar-seams` — dependency-breaking via cap 25
|
|
21
|
+
- `auditar-refactor` — gate canônico pre-refactor (cap 1 — cover-and-modify)
|
|
22
|
+
- `refactor` — orquestrador completo de refactor (chain de tudo acima + execução)
|
|
23
|
+
|
|
24
|
+
**Cria/Atualiza:** o que cada agent invocado cria (characterization tests, SEAM-ANALYSIS.md, REFACTOR-SAFETY.md).
|
|
25
|
+
|
|
26
|
+
**Após:** o usuário tem o output do agent (suite de tests + análise de seams + veredito do gate + execução de refactor).
|
|
27
|
+
</objective>
|
|
28
|
+
|
|
29
|
+
<execution_context>
|
|
30
|
+
Skills consultadas pelos agents: [`kit/skills/legacy-characterization-tests/SKILL.md`](../skills/legacy-characterization-tests/SKILL.md), [`kit/skills/legacy-seams-and-test-harness/SKILL.md`](../skills/legacy-seams-and-test-harness/SKILL.md), [`kit/skills/legacy-sprout-wrap-techniques/SKILL.md`](../skills/legacy-sprout-wrap-techniques/SKILL.md), [`kit/skills/legacy-effect-analysis/SKILL.md`](../skills/legacy-effect-analysis/SKILL.md), [`kit/skills/legacy-monster-methods/SKILL.md`](../skills/legacy-monster-methods/SKILL.md), [`kit/skills/pre-refactor-characterization/SKILL.md`](../skills/pre-refactor-characterization/SKILL.md) + glossário em [`kit/skills/_shared-legacy/glossary.md`](../skills/_shared-legacy/glossary.md).
|
|
31
|
+
|
|
32
|
+
Agents disponíveis:
|
|
33
|
+
- [`legacy-characterizer`](../agents/legacy-characterizer.md) — gera characterization tests
|
|
34
|
+
- [`seam-finder`](../agents/seam-finder.md) — analisa seams + recomenda dependency-breaking
|
|
35
|
+
- [`refactor-safety-auditor`](../agents/refactor-safety-auditor.md) — gate canônico (BLOCK/WARN/GO/GO-OVERRIDE)
|
|
36
|
+
</execution_context>
|
|
37
|
+
|
|
38
|
+
<context>
|
|
39
|
+
**Argumentos:** `$ARGUMENTS` — primeiro token é o subcomando; restante é passado para o agent como prompt.
|
|
40
|
+
|
|
41
|
+
**Subcomandos suportados (sinônimos PT-BR/EN):**
|
|
42
|
+
|
|
43
|
+
| Subcomando | Sinônimos | Comando subjacente | Cap livro |
|
|
44
|
+
|---|---|---|---|
|
|
45
|
+
| `caracterizar` | `characterize`, `char`, `gen-tests` | `/caracterizar` | 13 + 23 |
|
|
46
|
+
| `encontrar-seams` | `find-seams`, `seams`, `break-deps` | `/encontrar-seams` | 25 |
|
|
47
|
+
| `auditar-refactor` | `audit-refactor`, `audit`, `gate` | `/auditar-refactor` | 1 + 13 |
|
|
48
|
+
| `refactor` | `refactor-seguro`, `refactor-safe`, `refator` | `/refactor-seguro` | (chain — todos) |
|
|
49
|
+
| `capturar-payloads` | `capture`, `capture-payloads` | `/capturar-payloads` | (modernização) |
|
|
50
|
+
| `caracterizar-prompt` | `char-prompt`, `prompt-char` | `/caracterizar-prompt` | (modernização) |
|
|
51
|
+
| `storytelling` | `story`, `story-do-codigo` | `/storytelling` | 16-17 (modernização IA) |
|
|
52
|
+
| `detectar-duplicacao` | `dup`, `shotgun`, `detect-duplicates` | `/detectar-duplicacao` | 21 (modernização IA) |
|
|
53
|
+
| `audit-coverage` | `cobertura`, `coverage-audit` | `/auditar-observabilidade-cobertura` | (modernização cross-suite) |
|
|
54
|
+
| `help` | `ajuda`, `?` | exibe esta tabela inline | — |
|
|
55
|
+
|
|
56
|
+
**Roteamento de flags por subcomando:**
|
|
57
|
+
|
|
58
|
+
- `caracterizar <target_file>` — flags `--symbol --min-inputs --gap-fill --fixtures-dir --no-mutation`
|
|
59
|
+
- `encontrar-seams <target_file>` — flags `--symbol --prefer --output`
|
|
60
|
+
- `auditar-refactor <target_file>` — flags `--change-kind --mode --ticket --reason`
|
|
61
|
+
- `refactor <target_file>` — flags `--mode (full|sprout|safe-extract|override) --ticket --reason --skip-seams --skip-characterize --symbol`
|
|
62
|
+
|
|
63
|
+
**Exemplos:**
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
/legacy caracterizar src/orders/handler.ts # characterization tests
|
|
67
|
+
/legacy seams supabase/functions/webhook/index.ts # análise de seams
|
|
68
|
+
/legacy auditar-refactor src/api/v1/orders.ts # gate antes de PR de refactor
|
|
69
|
+
/legacy refactor src/orders/handler.ts # chain completo
|
|
70
|
+
/legacy refactor src/orders/handler.ts --mode=sprout # adicionar feature sem tocar legado
|
|
71
|
+
/legacy help # exibe tabela de subcomandos
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Quando este orquestrador é o caminho:**
|
|
75
|
+
- User quer dispatch único para legacy concerns
|
|
76
|
+
- Equipe usa também outras suítes (/sre, /supabase) e prefere namespace consistente
|
|
77
|
+
- Workflow integrado quer "legacy refactor" como capability nomeada
|
|
78
|
+
</context>
|
|
79
|
+
|
|
80
|
+
<process>
|
|
81
|
+
|
|
82
|
+
## 1. Parsear subcomando
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
SUBCMD=$(echo "$ARGUMENTS" | awk '{print $1}')
|
|
86
|
+
ARGS=$(echo "$ARGUMENTS" | cut -d' ' -f2-)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Se `$ARGUMENTS` for vazio ou `SUBCMD` for `help`/`ajuda`/`?`:** exibir tabela de subcomandos inline + exemplo de uso. Sair.
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
LEGACY SUITE — orquestrador
|
|
93
|
+
|
|
94
|
+
Subcomandos:
|
|
95
|
+
caracterizar gen characterization tests (cap 13 + 23)
|
|
96
|
+
sinônimos: characterize, char, gen-tests
|
|
97
|
+
uso: /legacy caracterizar <file> [opções]
|
|
98
|
+
|
|
99
|
+
encontrar-seams análise de dependency-breaking (cap 25)
|
|
100
|
+
sinônimos: find-seams, seams, break-deps
|
|
101
|
+
uso: /legacy seams <file> [opções]
|
|
102
|
+
|
|
103
|
+
auditar-refactor gate canônico antes de refactor
|
|
104
|
+
sinônimos: audit-refactor, audit, gate
|
|
105
|
+
uso: /legacy gate <file> [opções]
|
|
106
|
+
|
|
107
|
+
refactor chain completo (seams → char → audit → execução)
|
|
108
|
+
sinônimos: refactor-seguro, refactor-safe, refator
|
|
109
|
+
uso: /legacy refactor <file> [--mode=full|sprout|safe-extract|override]
|
|
110
|
+
|
|
111
|
+
Workflow recomendado:
|
|
112
|
+
1. /legacy auditar-refactor <file> (descobrir veredito do gate)
|
|
113
|
+
2. SE BLOCK: /legacy refactor <file> (chain completo) OR --mode=sprout
|
|
114
|
+
3. SE GO: refactor manual com confiança
|
|
115
|
+
|
|
116
|
+
Material-fonte: Working Effectively with Legacy Code — Feathers, 2004
|
|
117
|
+
ISBN 978-0-13-117705-5
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 2. Resolver sinônimos para subcomando canônico
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
caracterizar, characterize, char, gen-tests → /caracterizar
|
|
124
|
+
encontrar-seams, find-seams, seams, break-deps → /encontrar-seams
|
|
125
|
+
auditar-refactor, audit-refactor, audit, gate → /auditar-refactor
|
|
126
|
+
refactor, refactor-seguro, refactor-safe, refator → /refactor-seguro
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Se subcomando não resolve:** exibir erro inline com lista de subcomandos válidos. Sair.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
✗ Subcomando desconhecido: '<SUBCMD>'
|
|
133
|
+
|
|
134
|
+
Subcomandos válidos:
|
|
135
|
+
caracterizar → gen characterization tests
|
|
136
|
+
encontrar-seams → análise de dependency-breaking
|
|
137
|
+
auditar-refactor → gate pre-refactor
|
|
138
|
+
refactor → chain completo (seams + char + audit + exec)
|
|
139
|
+
|
|
140
|
+
Uso: /legacy <subcomando> <args...>
|
|
141
|
+
Exemplo: /legacy refactor src/orders/handler.ts
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 3. Dispatch — caminhos por subcomando
|
|
145
|
+
|
|
146
|
+
### 3a. `caracterizar` → `/caracterizar` (que invoca `legacy-characterizer`)
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
Comando equivalente:
|
|
150
|
+
/caracterizar ${ARGS}
|
|
151
|
+
|
|
152
|
+
Não há agent direto — orquestrador delega para o comando file.
|
|
153
|
+
Em IDEs sem support a slash-command-routing, dispatch direto:
|
|
154
|
+
|
|
155
|
+
Task(
|
|
156
|
+
subagent_type="legacy-characterizer",
|
|
157
|
+
prompt="
|
|
158
|
+
${ARGS}
|
|
159
|
+
|
|
160
|
+
Aplicar skill legacy-characterization-tests. Gerar characterization tests cobrindo 7 grupos canônicos de equivalência. Output: tests/characterization/<file_stem>/ + warning de revisão obrigatória dos snapshots.
|
|
161
|
+
"
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 3b. `encontrar-seams` → `/encontrar-seams` (que invoca `seam-finder`)
|
|
166
|
+
|
|
167
|
+
```text
|
|
168
|
+
Comando equivalente:
|
|
169
|
+
/encontrar-seams ${ARGS}
|
|
170
|
+
|
|
171
|
+
Dispatch direto:
|
|
172
|
+
Task(
|
|
173
|
+
subagent_type="seam-finder",
|
|
174
|
+
prompt="
|
|
175
|
+
${ARGS}
|
|
176
|
+
|
|
177
|
+
Aplicar skill legacy-seams-and-test-harness. Mapear deps bloqueantes, identificar tipos de seam disponíveis, recomendar técnica do cap 25 com menor custo. Output: .planning/SEAM-ANALYSIS.md.
|
|
178
|
+
"
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 3c. `auditar-refactor` → `/auditar-refactor` (que invoca `refactor-safety-auditor`)
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
Comando equivalente:
|
|
186
|
+
/auditar-refactor ${ARGS}
|
|
187
|
+
|
|
188
|
+
Dispatch direto:
|
|
189
|
+
Task(
|
|
190
|
+
subagent_type="refactor-safety-auditor",
|
|
191
|
+
prompt="
|
|
192
|
+
${ARGS}
|
|
193
|
+
|
|
194
|
+
Aplicar skill pre-refactor-characterization. Coletar evidências (linhas, contrato externo, coverage, mutation kill). Aplicar matriz de decisão (3 critérios canônicos). Output: .planning/REFACTOR-SAFETY.md com veredito GO/BLOCK/WARN/GO-OVERRIDE.
|
|
195
|
+
"
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 3d. `refactor` → `/refactor-seguro` (orquestrador interno)
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
Comando equivalente:
|
|
203
|
+
/refactor-seguro ${ARGS}
|
|
204
|
+
|
|
205
|
+
Não dispatch direto para agent — refactor-seguro é ele próprio orquestrador
|
|
206
|
+
que chama os 3 agents em sequência conforme mode escolhido.
|
|
207
|
+
|
|
208
|
+
Re-encaminhar via:
|
|
209
|
+
/refactor-seguro ${ARGS}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 4. Sugestões de chains comuns (pós-output)
|
|
213
|
+
|
|
214
|
+
Após dispatch, orquestrador pode sugerir chains comuns:
|
|
215
|
+
|
|
216
|
+
| Subcomando rodado | Chain natural |
|
|
217
|
+
|---|---|
|
|
218
|
+
| `caracterizar` | `/legacy auditar-refactor <same>` (verificar se gate libera) |
|
|
219
|
+
| `encontrar-seams` | aplicar técnicas + `/legacy caracterizar <same>` (após break-deps) |
|
|
220
|
+
| `auditar-refactor` (BLOCK) | `/legacy refactor <same> --mode=full` OR `--mode=sprout` |
|
|
221
|
+
| `auditar-refactor` (GO) | refactor manual + suite verde após cada commit |
|
|
222
|
+
| `refactor` (concluído) | `/instrumentar-fase` (v1.9) + `/prr <same>` (v1.10) |
|
|
223
|
+
|
|
224
|
+
## 5. Cross-suite — links para outras suítes
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
═══════════════════════════════════════════════════════════
|
|
228
|
+
LEGACY SUITE · cross-references com outras suítes
|
|
229
|
+
═══════════════════════════════════════════════════════════
|
|
230
|
+
|
|
231
|
+
Suíte Observabilidade (v1.9):
|
|
232
|
+
/instrumentar-fase — bundle telemetria com refactor (ODD)
|
|
233
|
+
/burn-rate-status — monitor SLO durante refactor
|
|
234
|
+
/investigar-producao — Core Analysis Loop se regression em prod
|
|
235
|
+
|
|
236
|
+
Suíte SRE (v1.10):
|
|
237
|
+
/prr — Production Readiness Review pós-refactor
|
|
238
|
+
/golden-signals — instrumentar 4 signals em código refatorado
|
|
239
|
+
/postmortem — após incident pós-refactor
|
|
240
|
+
|
|
241
|
+
Suíte Supabase (v1.8):
|
|
242
|
+
/supabase edge — supabase-edge-fn-writer já gera código testável
|
|
243
|
+
/supabase architect — design considera testabilidade upfront
|
|
244
|
+
|
|
245
|
+
Fluxo Framework:
|
|
246
|
+
/discutir-fase — detecta refactor intent + sugere /legacy automaticamente
|
|
247
|
+
/planejar-fase — plan-checker bloqueia plano se task=refactor sem char
|
|
248
|
+
/executar-fase — executor invoca refactor-safety-auditor antes de tocar arquivo flagged
|
|
249
|
+
/auditar-marco — gate legacy-refactor-safety opt-in
|
|
250
|
+
/forense — postmortems pós-refactor consultam REFACTOR-SAFETY.md
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
</process>
|
|
254
|
+
|
|
255
|
+
<success_criteria>
|
|
256
|
+
- [ ] Subcomando resolvido (4 subcomandos × seus sinônimos)
|
|
257
|
+
- [ ] Dispatch via comando-arquivo direto OR via Task(subagent_type=...) — único ponto de chain (anti-pitfall A10)
|
|
258
|
+
- [ ] Subcomando inválido → mensagem clara com lista de 4 subcomandos válidos
|
|
259
|
+
- [ ] Subcomando `help`/`ajuda`/`?` → exibe tabela inline com 5 linhas (4 + help)
|
|
260
|
+
- [ ] Args após subcomando passam transparentemente para o agent/comando
|
|
261
|
+
- [ ] Sugestões de chains comuns na tabela final (5 chains documentadas)
|
|
262
|
+
- [ ] Cross-references com Suítes Observabilidade, SRE, Supabase + fluxo framework
|
|
263
|
+
</success_criteria>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: load-shedding
|
|
3
|
+
description: Invoca load-shedding-instrumenter — aplica patches de load shedding em Edge Function/handler HTTP (concurrency limit, queue bound + drop policy, deadline-aware, server-side rate limit, slow start). Cap 22 livro Google SRE.
|
|
4
|
+
argument-hint: "<target_path> [--max-concurrent N] [--queue-max-size N] [--patterns ...]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Edit
|
|
9
|
+
- Bash
|
|
10
|
+
- Grep
|
|
11
|
+
- Glob
|
|
12
|
+
- Task
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Aplicar **patches de load shedding** em Edge Function ou handler HTTP, instrumentando defesas server-side: concurrency limit + queue bound + deadline-aware + rate limit + slow start. Invoca o agente [`load-shedding-instrumenter`](../agents/load-shedding-instrumenter.md) que aplica skill [`load-shedding-graceful-degradation`](../skills/load-shedding-graceful-degradation/SKILL.md).
|
|
17
|
+
|
|
18
|
+
**Cria/Atualiza:**
|
|
19
|
+
- Patches no `target_path`
|
|
20
|
+
- `supabase/functions/_shared/load-shedder.ts` (se não existe)
|
|
21
|
+
- `supabase/functions/_shared/token-bucket.ts` (se rate-limit aplicado)
|
|
22
|
+
|
|
23
|
+
**Após:** handler retorna 503 + Retry-After quando saturated, em vez de aceitar e cair. Defesa central contra cascade.
|
|
24
|
+
</objective>
|
|
25
|
+
|
|
26
|
+
<context>
|
|
27
|
+
**Argumentos:**
|
|
28
|
+
- `<target_path>` — arquivo a instrumentar (Edge Function ou handler HTTP) — OBRIGATÓRIO
|
|
29
|
+
- `--max-concurrent N` — concurrency limit (default: 1000)
|
|
30
|
+
- `--queue-max-size N` — queue bound (default: 10000)
|
|
31
|
+
- `--patterns <list>` — subset de `[concurrency-limit, queue-bound, deadline-aware, rate-limit, slow-start]` (default: aplicáveis)
|
|
32
|
+
|
|
33
|
+
**Exemplos:**
|
|
34
|
+
```
|
|
35
|
+
/load-shedding supabase/functions/process-orders/index.ts
|
|
36
|
+
/load-shedding src/handlers/webhook.ts --max-concurrent 500
|
|
37
|
+
/load-shedding supabase/functions/api/index.ts --patterns concurrency-limit,deadline-aware
|
|
38
|
+
```
|
|
39
|
+
</context>
|
|
40
|
+
|
|
41
|
+
<process>
|
|
42
|
+
|
|
43
|
+
## 1. Parsear argumentos
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
TARGET_PATH=$(echo "$ARGUMENTS" | awk '{print $1}')
|
|
47
|
+
MAX_CONCURRENT=$(echo "$ARGUMENTS" | grep -oE -- '--max-concurrent [0-9]+' | awk '{print $2}')
|
|
48
|
+
QUEUE_MAX_SIZE=$(echo "$ARGUMENTS" | grep -oE -- '--queue-max-size [0-9]+' | awk '{print $2}')
|
|
49
|
+
PATTERNS=$(echo "$ARGUMENTS" | grep -oE -- '--patterns [^ ]+' | awk '{print $2}')
|
|
50
|
+
|
|
51
|
+
[ -z "$MAX_CONCURRENT" ] && MAX_CONCURRENT=1000
|
|
52
|
+
[ -z "$QUEUE_MAX_SIZE" ] && QUEUE_MAX_SIZE=10000
|
|
53
|
+
|
|
54
|
+
if [ -z "$TARGET_PATH" ]; then
|
|
55
|
+
echo "ERROR: target_path obrigatório"
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
[ ! -f "$TARGET_PATH" ] && { echo "ERROR: arquivo não encontrado"; exit 1; }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 2. Dispatch para `load-shedding-instrumenter`
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
Task(
|
|
65
|
+
subagent_type="load-shedding-instrumenter",
|
|
66
|
+
prompt="
|
|
67
|
+
target_path: ${TARGET_PATH}
|
|
68
|
+
max_concurrent: ${MAX_CONCURRENT}
|
|
69
|
+
queue_max_size: ${QUEUE_MAX_SIZE}
|
|
70
|
+
${PATTERNS:+patterns: ${PATTERNS}}
|
|
71
|
+
|
|
72
|
+
Aplicar skill load-shedding-graceful-degradation. Patches:
|
|
73
|
+
1. Concurrency limit + 503 graceful (LoadShedder em _shared)
|
|
74
|
+
2. Deadline-aware handler (x-deadline-ms header parsing)
|
|
75
|
+
3. Queue bound + drop oldest (FIFO drop)
|
|
76
|
+
4. Server-side rate limit (token bucket per-client)
|
|
77
|
+
5. Slow start state machine (5 min ramp em recovery)
|
|
78
|
+
|
|
79
|
+
Verify compilação verde após patches. Output curto com lista de patches aplicados.
|
|
80
|
+
"
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 3. Pós-output
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
═══════════════════════════════════════════════════════════
|
|
88
|
+
framework ► LOAD-SHEDDING ▸ ${TARGET_PATH}
|
|
89
|
+
═══════════════════════════════════════════════════════════
|
|
90
|
+
|
|
91
|
+
[output do agent]
|
|
92
|
+
|
|
93
|
+
## Próximos passos
|
|
94
|
+
|
|
95
|
+
1. **Smoke local:** `deno task serve` ou `npm run dev`, request 200 OK
|
|
96
|
+
2. **Stress test:** rampar tráfego acima de --max-concurrent, verificar 503 + Retry-After
|
|
97
|
+
3. **Game day:** simular dep down, verificar graceful degradation
|
|
98
|
+
4. **/golden-signals <fn>** (v1.10) — instrumentar saturation gauge para acionar load shed
|
|
99
|
+
5. **/caracterizar <fn>** (v1.12) — characterization tests pós-patches
|
|
100
|
+
|
|
101
|
+
## Cross-suite
|
|
102
|
+
|
|
103
|
+
- /auditar-cascading (v1.11) — caller-side defesas complementam
|
|
104
|
+
- /golden-signals (v1.10) — Saturation gauge é trigger
|
|
105
|
+
- /prr (v1.10) — Axe 4 consume
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
</process>
|
|
109
|
+
|
|
110
|
+
<success_criteria>
|
|
111
|
+
- [ ] target_path obrigatório
|
|
112
|
+
- [ ] `load-shedding-instrumenter` invocado via Task
|
|
113
|
+
- [ ] Patches aplicados com Edit
|
|
114
|
+
- [ ] Compilação verde verificada
|
|
115
|
+
- [ ] Output forwarded
|
|
116
|
+
- [ ] Cross-references com /auditar-cascading, /golden-signals, /caracterizar
|
|
117
|
+
</success_criteria>
|
|
@@ -38,6 +38,7 @@ Agents disponíveis: `kit/agents/observability-instrumenter.md` (Phase 30), `kit
|
|
|
38
38
|
| `slo` | `definir-slo`, `slo-engineer` | `slo-engineer` |
|
|
39
39
|
| `burn-rate` | `burn`, `burn-rate-forecaster`, `forecast` | `burn-rate-forecaster` |
|
|
40
40
|
| `omm` | `auditar`, `audit`, `maturity` | `omm-auditor` |
|
|
41
|
+
| `audit-coverage` | `cobertura`, `coverage` | `observability-coverage-auditor` (v1.12 cross-suite) |
|
|
41
42
|
| `help` | `ajuda`, `?` | exibe esta tabela inline |
|
|
42
43
|
</context>
|
|
43
44
|
|
|
@@ -60,6 +61,7 @@ investigar, investigate, incident → incident-investigator
|
|
|
60
61
|
slo, definir-slo, slo-engineer → slo-engineer
|
|
61
62
|
burn-rate, burn, burn-rate-forecaster, forecast → burn-rate-forecaster
|
|
62
63
|
omm, auditar, audit, maturity → omm-auditor
|
|
64
|
+
audit-coverage, cobertura, coverage → observability-coverage-auditor (v1.12 — cross-suite com Legacy)
|
|
63
65
|
```
|
|
64
66
|
|
|
65
67
|
**Se subcomando não resolve:** exibir erro inline com lista de subcomandos válidos. Sair.
|