Español
Qué hace
architect-extractor ask ./mi-repo "¿cómo se calcula el total de un pedido?"
- Indexa tu repositorio: extrae cada función con su AST (ts-morph) y genera embeddings en local (sin GPU, sin enviar nada).
- Busca por significado, no por nombre: entiende preguntas en español sobre código escrito en inglés.
- Analiza las funciones que elijas con el LLM que prefieras y genera un artefacto por función:
---
function: "OrderService.calculateTotal"
file: "src/orders/order.service.ts"
lines: "42-71"
provider: "ollama"
model: "qwen2.5-coder:7b"
source_hash: "26e6ddbe…"
---
# OrderService.calculateTotal
## Resumen de negocio → qué problema resuelve y para quién
## Reglas de negocio → descuentos, validaciones, límites…
## Diagrama de flujo → Mermaid válido por construcción
## Pseudocódigo → agnóstico del lenguaje
El front-matter YAML hace que los artefactos estén listos para ingerir en un sistema RAG, y un catálogo artifacts/INDEX.md enlaza todos.
Artefacto real generado con Gemini sobre un repo de ejemplo (código a la izquierda, artefacto a la derecha):
Instalación
Requiere Node.js 22 o superior en Windows (x64/arm64), Linux (x64/arm64) o macOS con Apple Silicon.
macOS Intel no está soportado: LanceDB no publica binarios para esa plataforma.
npm install -g cli-architect-extractor
architect-extractor --help
O sin instalar: npx -p cli-architect-extractor architect-extractor --help
La primera indexación descarga el modelo de embeddings (~118 MB) a la carpeta global; después funciona sin conexión.
Inicio rápido
architect-extractor config # 1. elige provider y modelo (una sola vez)
architect-extractor index ./mi-repo # 2. indexa (incremental)
architect-extractor ask ./mi-repo "validación de stock" # 3. pregunta y elige funciones
architect-extractor interactive ./mi-repo # …o en una sesión interactiva
Providers LLM
| Provider |
Privacidad |
Requisitos |
ollama |
100% local: el código no sale de tu máquina |
Ollama + ollama pull qwen2.5-coder:7b |
gemini-cli |
El código de las funciones analizadas se envía a Google |
npm i -g @google/gemini-cli y ejecutar gemini una vez para iniciar sesión |
gemini |
Se envía a la API de Google |
API key de AI Studio |
minimax |
Se envía a la API de MiniMax |
API key de MiniMax |
La indexación y la búsqueda siempre son locales; solo las funciones que eliges analizar se envían al provider. La CLI muestra a qué endpoint va el código antes de cada extracción.
Comandos
| Comando |
Descripción |
config [--show] [--path] |
Asistente de configuración · muestra la config efectiva (claves enmascaradas) |
init [--force] |
Crea extractor.config.json (sin secretos, versionable) y .extractorignore |
index <ruta> [-r] [-l N] |
Indexa o actualiza el índice (solo procesa archivos cambiados; elimina los borrados) |
ask <ruta> "<pregunta>" |
Busca y genera artefactos. -k N resultados · -s "1,3"/-s all sin preguntar · -d solo listar · -f regenerar |
extract [ruta] |
Genera artefactos de todas las funciones. --function Clase.metodo · -d · -y · -f |
interactive <ruta> (i) |
Sesión: pregunta → elige → genera |
status <ruta> |
Estado del índice, artefactos y configuración |
Opciones comunes: -p/--provider, -m/--model, --lang es|en, -c/--concurrency N, -o/--output <dir>, -g/--global, --verbose, -q/--quiet.
Para scripts/CI: ask … --select all no pregunta nada; los errores devuelven código de salida 1.
Dónde se guarda todo
Tus repositorios quedan limpios: el índice y los artefactos se guardan en una carpeta global, una subcarpeta por proyecto.
Windows: C:\.architect-extractor\ macOS/Linux: ~/.architect-extractor/
├── config.json ← config global y API keys (nunca dentro de un repo)
├── models/ ← modelo de embeddings
└── mi-repo/
├── artifacts/
│ ├── INDEX.md ← catálogo
│ └── src/orders/order.service.ts/OrderService.calculateTotal.md
├── summary.md ← última consulta de "ask"
├── index_manifest.json
└── .index/ ← base vectorial LanceDB
Dos repos con el mismo nombre en rutas distintas no se mezclan. Cambia la ubicación con ARCHITECT_EXTRACTOR_HOME, o escribe en otra carpeta con --output/outputDir.
Configuración
Precedencia (de menor a mayor): valores por defecto → config.json global → extractor.config.json del proyecto → variables de entorno (y .env) → flags.
{
"modelProvider": "ollama",
"ollama": { "baseUrl": "http://localhost:11434", "model": "qwen2.5-coder:7b" },
"language": "es",
"embeddingModel": "multilingual",
"excludePatterns": ["**/node_modules/**", "**/*.test.*", "legacy/**"],
"concurrency": 0,
"timeoutMs": 180000,
"maxBodyChars": 24000,
"maxFileSizeKb": 512
}
embeddingModel: multilingual (por defecto, entiende preguntas en español) o minilm (solo inglés, 23 MB). Cambiarlo reconstruye el índice automáticamente.
.extractorignore en la raíz del repo: sintaxis tipo .gitignore, con !negación.
- Variables:
MODEL_PROVIDER, MODEL_NAME, OLLAMA_BASE_URL, OLLAMA_MODEL, GEMINI_API_KEY, GEMINI_MODEL, MINIMAX_API_KEY, MINIMAX_BASE_URL, MINIMAX_MODEL, OUTPUT_DIR, EXTRACTOR_LANGUAGE, ARCHITECT_EXTRACTOR_HOME. Ver .env.example.
Qué detecta
Funciones, arrow functions, function expressions, clases (métodos, constructores, getters/setters, propiedades flecha), métodos de objetos literales, CommonJS (module.exports, exports.x) y wrappers como catchAsync(async (req, res) => …). Archivos .ts .tsx .mts .cts .js .jsx .mjs .cjs.
Docker (100% local con Ollama)
docker compose up -d ollama
docker compose exec ollama ollama pull qwen2.5-coder:7b
REPO_PATH=../mi-repo docker compose run --rm extractor ask /repo "¿cómo se factura?" --select 1-3
Seguridad
- Las API keys se guardan en la config global del usuario, nunca en
extractor.config.json (la CLI avisa si encuentra alguna ahí).
- Un repositorio clonado no puede redirigir tu API key global: si su
extractor.config.json o .env cambia la URL de MiniMax a un host no oficial, la CLI se niega a enviar la clave; si apunta Ollama a un servidor remoto, te avisa.
- La config del directorio actual solo se aplica al proyecto que lo contiene (no a otro repo que analices desde ahí).
- Gemini CLI se ejecuta sin modo
--yolo y en un directorio temporal vacío: un comentario malicioso en el código analizado no puede hacer que ejecute comandos ni lea otros archivos.
- El código se envía al LLM delimitado como dato, con instrucciones de ignorar órdenes incrustadas.
Contribuir
Ver CONTRIBUTING.md · Cambios en CHANGELOG.md · Licencia MIT.
English
What it does
architect-extractor ask ./my-repo "how is an order total calculated?" --lang en
- Indexes your repository: every function is extracted from its AST (ts-morph) and embedded locally (no GPU, nothing is sent anywhere).
- Searches by meaning, not by name: the multilingual model understands questions in English or Spanish.
- Analyses the functions you pick with the LLM of your choice and writes one artefact per function: business summary, business rules, a Mermaid flowchart (valid by construction) and language-agnostic pseudocode, plus YAML front matter (function, file, lines, provider, model, hash) ready for RAG ingestion. An
artifacts/INDEX.md catalogue links them all.
Use --lang en (or "language": "en" in the config) to get artefacts in English.
Real artefact generated with Gemini on a sample repo (code on the left, artefact on the right; this one in Spanish):
Installation
Requires Node.js 22+ on Windows (x64/arm64), Linux (x64/arm64) or Apple Silicon macOS.
Intel macOS is not supported: LanceDB ships no binaries for that platform.
npm install -g cli-architect-extractor
architect-extractor --help
Or without installing: npx -p cli-architect-extractor architect-extractor --help
The first index downloads the embedding model (~118 MB) into the global folder; after that it works offline.
Quick start
architect-extractor config # 1. pick provider and model (once)
architect-extractor index ./my-repo # 2. index (incremental)
architect-extractor ask ./my-repo "stock validation" --lang en # 3. ask and pick functions
architect-extractor interactive ./my-repo # …or in an interactive session
LLM providers
| Provider |
Privacy |
Requirements |
ollama |
Fully local: code never leaves your machine |
Ollama + ollama pull qwen2.5-coder:7b |
gemini-cli |
Code of the analysed functions is sent to Google |
npm i -g @google/gemini-cli and run gemini once to sign in |
gemini |
Sent to Google's API |
API key from AI Studio |
minimax |
Sent to MiniMax's API |
MiniMax API key |
Indexing and search are always local; only the functions you choose to analyse are sent to the provider. The CLI shows which endpoint will receive the code before every extraction.
Commands
| Command |
Description |
config [--show] [--path] |
Setup wizard · show the effective config (keys masked) |
init [--force] |
Create extractor.config.json (no secrets, safe to commit) and .extractorignore |
index <path> [-r] [-l N] |
Build or update the index (only changed files; deleted files are pruned) |
ask <path> "<question>" |
Search and generate artefacts. -k N results · -s "1,3"/-s all no prompt · -d list only · -f regenerate |
extract [path] |
Generate artefacts for every function. --function Class.method · -d · -y · -f |
interactive <path> (i) |
Session: ask → pick → generate |
status <path> |
Index, artefacts and configuration status |
Common options: -p/--provider, -m/--model, --lang es|en, -c/--concurrency N, -o/--output <dir>, -g/--global, --verbose, -q/--quiet.
For scripts/CI: ask … --select all never prompts, and any failure exits with code 1.
Where everything is stored
Your repositories stay clean: the index and artefacts live in a global folder, one subfolder per project.
Windows: C:\.architect-extractor\ macOS/Linux: ~/.architect-extractor/
├── config.json ← global config and API keys (never inside a repo)
├── models/ ← embedding model
└── my-repo/
├── artifacts/
│ ├── INDEX.md ← catalogue
│ └── src/orders/order.service.ts/OrderService.calculateTotal.md
├── summary.md ← last "ask" query
├── index_manifest.json
└── .index/ ← LanceDB vector store
Two repos with the same name in different paths never get mixed up. Change the location with ARCHITECT_EXTRACTOR_HOME, or write somewhere else with --output/outputDir.
Configuration
Precedence (lowest to highest): defaults → global config.json → project extractor.config.json → environment variables (and .env) → CLI flags.
{
"modelProvider": "ollama",
"ollama": { "baseUrl": "http://localhost:11434", "model": "qwen2.5-coder:7b" },
"language": "en",
"embeddingModel": "multilingual",
"excludePatterns": ["**/node_modules/**", "**/*.test.*", "legacy/**"],
"concurrency": 0,
"timeoutMs": 180000,
"maxBodyChars": 24000,
"maxFileSizeKb": 512
}
embeddingModel: multilingual (default) or minilm (English only, 23 MB). Changing it rebuilds the index automatically.
.extractorignore at the repo root: .gitignore-style syntax, with !negation.
- Environment variables:
MODEL_PROVIDER, MODEL_NAME, OLLAMA_BASE_URL, OLLAMA_MODEL, GEMINI_API_KEY, GEMINI_MODEL, MINIMAX_API_KEY, MINIMAX_BASE_URL, MINIMAX_MODEL, OUTPUT_DIR, EXTRACTOR_LANGUAGE, ARCHITECT_EXTRACTOR_HOME. See .env.example.
What it detects
Functions, arrow functions, function expressions, classes (methods, constructors, getters/setters, arrow properties), object-literal methods, CommonJS (module.exports, exports.x) and wrappers such as catchAsync(async (req, res) => …). Files .ts .tsx .mts .cts .js .jsx .mjs .cjs.
Docker (fully local with Ollama)
docker compose up -d ollama
docker compose exec ollama ollama pull qwen2.5-coder:7b
REPO_PATH=../my-repo docker compose run --rm extractor ask /repo "how are invoices issued?" --select 1-3 --lang en
Security
- API keys are stored in the user's global config, never in
extractor.config.json (the CLI warns if it finds any there).
- A cloned repository cannot redirect your global API key: if its
extractor.config.json or .env points MiniMax to a non-official host, the CLI refuses to send the key; if it points Ollama to a remote server, you get a warning.
- The config in the current directory only applies to the project that contains it, not to another repo you analyse from there.
- Gemini CLI runs without
--yolo and inside an empty temporary folder: a malicious comment in the analysed code cannot make it run commands or read other files.
- Code is sent to the LLM delimited as data, with instructions to ignore any embedded orders.
Contributing
See CONTRIBUTING.md · Changes in CHANGELOG.md · MIT licence.