Skip to content

refactor: extract shared modules from monolithic files#1

Merged
rodrigoeqnit merged 7 commits into
mainfrom
feat/refactor-monoliths
Apr 19, 2026
Merged

refactor: extract shared modules from monolithic files#1
rodrigoeqnit merged 7 commits into
mainfrom
feat/refactor-monoliths

Conversation

@rodrigoeqnit

Copy link
Copy Markdown
Owner

Extração de módulos compartilhados identificados pelo code-review-graph. Fase 1: permissions (commandWrapperDetection + permissionChecker). Fase 2: UI hooks (useUnifiedItems, providerManagerHelpers). Fase 3: typeaheadHelpers. Fase 4: toolExecutionHelpers. 15 arquivos, +1563/-1358 linhas, zero regressões TS.

rodrigoeqnit and others added 7 commits April 19, 2026 15:32
…WrapperDetection

- Create permissionChecker.ts with shared matchingRulesForInput (was duplicated in bash and PS)
- Create commandWrapperDetection.ts with stripSafeWrappers, stripWrappersFromArgv, stripAllLeadingEnvVars, BINARY_HIJACK_VARS, SAFE_ENV_VARS, ANT_ONLY_SAFE_ENV_VARS
- bashPermissions.ts: 2598 → 2182 lines (-16%)
- powershellPermissions.ts: 1648 → 1624 lines (matchingRulesForInput now shared)
- Update importers: shouldUseSandbox.ts, pathValidation.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…anagePlugins

Extract ~270 lines of unified items computation (useUnifiedItems) and
the UnifiedInstalledItem type definition (unifiedTypes.ts) from the
2214-line ManagePlugins component. Also removes unused imports
(getPluginEditableScopes, getFlaggedPlugins).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract ~110 lines of pure utility functions (toDraft, presetToDraft,
profileSummary, GitHub credential helpers, Codex OAuth helpers) into
providerManagerHelpers.ts from the 1535-line ProviderManager component.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract ~290 lines of pure functions (regex patterns, token extraction,
suggestion application, shell completion, directory completion) into
typeaheadHelpers.ts from the 1040-line useTypeahead hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract ~190 lines of pure functions (classifyToolError, OTel source
mapping, MCP server lookup, image paste ID computation) into
toolExecutionHelpers.ts from the 1589-line toolExecution module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bot automático roda em todo pull_request + manual via workflow_dispatch.
Anti-alucinação: dois passes (review + verification). Requer secret
OPENROUTER_API_KEY no repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sem parênteses, `&&` tem precedência maior que `||`, fazendo o filtro
aceitar erros com source===pluginId sem verificar 'plugin' in e primeiro.

Adicionado parênteses: ('plugin' in e && e.plugin === name) || ...

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rodrigoeqnit

Copy link
Copy Markdown
Owner Author

Code Review Manual — feat/refactor-monoliths

Status: ✅ Aprovado com 1 fix commitado


[HIGH] CORRIGIDO — Bug de precedência em useUnifiedItems.ts:74

Operador || sem parênteses causava falsos positivos no filtro de erros de plugin.
Erros com source === pluginId passavam sem a guarda 'plugin' in e.

// ❌ Antes
e => 'plugin' in e && e.plugin === state.plugin.name || e.source === pluginId

// ✅ Depois  
e => ('plugin' in e && e.plugin === state.plugin.name) || e.source === pluginId

Fix commitado: 834573f


Sem outros problemas críticos

  • commandWrapperDetection.ts — extração correta, exports preservam comportamento de segurança
  • permissionChecker.ts — matchingRulesForInput compartilhada com assinatura consistente
  • toolExecutionHelpers.ts — import `../../types/message.js` quebrado é pré-existente no upstream (não regressão)
  • providerManagerHelpers.ts, typeaheadHelpers.ts — extrações limpas

⚠️ Próximos passos antes de merge

  1. Configurar secret OPENROUTER_API_KEY no repo → Settings → Secrets → Actions
  2. O code review bot vai rodar automaticamente nos próximos PRs

Review por: Claude Sonnet 4.6 via code-reviewer subagent

@rodrigoeqnit rodrigoeqnit merged commit c839d0f into main Apr 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant