openprompt-lang 1.4.0 → 1.6.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.
Files changed (120) hide show
  1. package/bin/cli.js +1 -14
  2. package/bin/mcp-plan.js +4 -4
  3. package/docs/02-STANDARDS/AGENTS.template.md +11 -5
  4. package/docs/02-STANDARDS/sections/00-first-5-min.md +40 -0
  5. package/docs/02-STANDARDS/sections/01-workflow.md +150 -0
  6. package/docs/02-STANDARDS/sections/02-annotations.md +89 -0
  7. package/docs/02-STANDARDS/sections/03-conventions.md +56 -0
  8. package/docs/02-STANDARDS/sections/04-commands.md +54 -0
  9. package/docs/02-STANDARDS/sections/05-reference.md +46 -0
  10. package/docs/02-STANDARDS/sections/06-project-setup.md +137 -0
  11. package/docs/AI_IMPROVEMENTS.md +3 -0
  12. package/docs/FRAMEWORK.md +7 -59
  13. package/package.json +1 -1
  14. package/src/cli/commands-context.js +69 -0
  15. package/src/cli/commands-misc.js +217 -4
  16. package/src/cli/commands-opl.js +12 -0
  17. package/src/cli/commands-teach.js +49 -0
  18. package/src/cli/commands-workflow.js +96 -38
  19. package/src/commands/init-core.js +226 -279
  20. package/src/commands/init-infer.js +313 -0
  21. package/src/commands/init.js +5 -14
  22. package/src/commands/knowledge.js +226 -3
  23. package/src/commands/opl-embeddings.js +177 -3
  24. package/src/commands/scar.js +106 -0
  25. package/src/commands/teach/assess/index.js +16 -30
  26. package/src/commands/teach/progress/index.js +14 -16
  27. package/src/commands/teach/project-guide/index.js +19 -30
  28. package/src/commands/teach/study/index.js +22 -31
  29. package/src/commands/ticket.js +76 -7
  30. package/src/commands/validate.js +84 -12
  31. package/src/commands/work-context/check.js +85 -0
  32. package/src/commands/work-context/init.js +68 -0
  33. package/src/commands/work-context/learn.js +45 -0
  34. package/src/commands/work-context/log.js +14 -0
  35. package/src/commands/work-context/plan.js +198 -0
  36. package/src/commands/work-context/report.js +45 -0
  37. package/src/commands/work-context/session.js +196 -0
  38. package/src/commands/work-context/utils.js +499 -0
  39. package/src/commands/work-context.js +7 -1028
  40. package/src/commands/workflow/close/index.js +23 -37
  41. package/src/commands/workflow/delivery/index.js +20 -33
  42. package/src/context/gates.js +136 -0
  43. package/src/context/index.js +280 -0
  44. package/src/context/plan.js +140 -0
  45. package/src/context/session.js +44 -0
  46. package/src/core/knowledge-graph/index.js +301 -0
  47. package/src/core/knowledge-graph/loader.js +356 -0
  48. package/src/core/knowledge-graph/store.js +210 -0
  49. package/src/core/knowledge-graph/types.js +280 -0
  50. package/src/core/search/anti-knowledge.js +292 -0
  51. package/src/core/search/echo-fusion.js +229 -0
  52. package/src/core/search/scar-integration.js +190 -0
  53. package/src/core/search/spreading-activation.js +312 -0
  54. package/src/core/workflow/gates.js +2 -2
  55. package/src/core/workflow/phases.js +1 -1
  56. package/src/core/workflow/selector.js +97 -641
  57. package/src/core/workflow/state-machine.js +1 -1
  58. package/src/docgen/session-docs.js +4 -5
  59. package/src/embeddings/chunker.js +79 -21
  60. package/src/embeddings/embedder.js +48 -9
  61. package/src/embeddings/index-pipeline.js +62 -35
  62. package/src/embeddings/vector-store.js +363 -352
  63. package/src/mcp-refactor/handlers/context.js +15 -20
  64. package/src/mcp-refactor/handlers/plan.js +339 -0
  65. package/src/mcp-refactor/handlers/teaching.js +9 -17
  66. package/src/mcp-refactor/handlers/workflow.js +8 -13
  67. package/src/mcp-refactor/router.js +21 -18
  68. package/src/mcp-refactor/tools.js +56 -67
  69. package/src/mcp-server.js +1 -1
  70. package/src/mcp-session.js +104 -84
  71. package/src/mcp-shared-state.js +64 -196
  72. package/src/mcp-workflow.js +90 -160
  73. package/src/persistence/json/store.js +364 -0
  74. package/src/utils/annotations.js +36 -7
  75. package/src/boost/agent-pool.js +0 -442
  76. package/src/boost/agents/index.js +0 -79
  77. package/src/boost/cache.js +0 -241
  78. package/src/boost/context-compressor.js +0 -354
  79. package/src/boost/fewshot-retriever.js +0 -332
  80. package/src/boost/hardware-detector.js +0 -486
  81. package/src/boost/hydrator.js +0 -398
  82. package/src/boost/index.js +0 -60
  83. package/src/boost/orchestrator.js +0 -615
  84. package/src/boost/preamble.js +0 -217
  85. package/src/boost/profile-registry.js +0 -264
  86. package/src/boost/self-learn.js +0 -247
  87. package/src/boost/skeletons/component.skeleton.js +0 -24
  88. package/src/boost/skeletons/hook.skeleton.js +0 -27
  89. package/src/boost/skeletons/index.js +0 -67
  90. package/src/boost/skeletons/page.skeleton.js +0 -22
  91. package/src/boost/skeletons/service.skeleton.js +0 -20
  92. package/src/boost/skeletons/store.skeleton.js +0 -18
  93. package/src/boost/skeletons/type.skeleton.js +0 -11
  94. package/src/boost/task-dispatcher.js +0 -142
  95. package/src/boost/validation-loop.js +0 -495
  96. package/src/cli/commands-ai.js +0 -58
  97. package/src/cli/commands-boost.js +0 -394
  98. package/src/cli/commands-init.js +0 -82
  99. package/src/cli/commands-knowledge.js +0 -79
  100. package/src/cli/commands-lang.js +0 -43
  101. package/src/cli/commands-learning.js +0 -54
  102. package/src/cli/commands-work.js +0 -95
  103. package/src/commands/context-compact.js +0 -129
  104. package/src/commands/wizard.js +0 -458
  105. package/src/commands/workflow/discovery/index.js +0 -86
  106. package/src/commands/workflow/specification/index.js +0 -115
  107. package/src/docgen/generator.js +0 -200
  108. package/src/docgen/mermaid/generator.js +0 -147
  109. package/src/docgen/templates/architecture.hbs +0 -51
  110. package/src/docgen/templates/backlog.hbs +0 -32
  111. package/src/docgen/templates/requirements.hbs +0 -44
  112. package/src/docgen/templates/user-stories.hbs +0 -27
  113. package/src/docgen/templates/vision.hbs +0 -20
  114. package/src/mcp-plan-server.js +0 -895
  115. package/src/mcp-refactor/handlers/boost.js +0 -295
  116. package/src/persistence/sqlite/connection.js +0 -125
  117. package/src/persistence/sqlite/migrations.js +0 -139
  118. package/src/persistence/sqlite/queries.js +0 -529
  119. package/src/persistence/sqlite/schema.js +0 -164
  120. package/src/wizard/orchestrator.js +0 -217
package/docs/FRAMEWORK.md CHANGED
@@ -186,37 +186,6 @@ npx openPrompt-Lang work-context learn
186
186
  npx openPrompt-Lang work-context report
187
187
  ```
188
188
 
189
- ### Plan y Modo (Planificación Ágil)
190
- ```
191
- opl plan → Cambiar a modo PLAN (bloquea tools de escritura)
192
- opl execute → Cambiar a modo EXECUTE (requiere plan aprobado)
193
- opl mode → Mostrar modo actual (plan/execute)
194
- opl workflow discovery → E.1 — Wizard de descubrimiento (8 bloques, 29 preguntas)
195
- opl workflow specification → E.2 — Generar documentos y diagramas Mermaid
196
- opl workflow delivery → E.3 — Iniciar desarrollo por tickets
197
- opl workflow close → E.4 — Cerrar sesión y documentar aprendizajes
198
- ```
199
-
200
- ### Teaching (Enseñanza Adaptativa)
201
- ```
202
- opl teach progress → Dashboard de progreso
203
- opl teach template <id> → Lección desde template @teachMe
204
- opl teach assess → Diagnosticar nivel de dominio
205
- opl teach study → Unidad pedagógica adaptada
206
- opl teach project-guide → Ruta de aprendizaje con tickets
207
- ```
208
-
209
- ### Ticket, Memoria y Diagnóstico
210
- ```
211
- opl ticket create --title "..." → Crear ticket de trabajo
212
- opl ticket list → Listar tickets (--status ready|backlog|done)
213
- opl ticket close <id> → Cerrar ticket
214
- opl recall "consulta" → Búsqueda en memoria del proyecto
215
- opl doctor → Diagnóstico del sistema OPL
216
- opl fix → Auto-corrección de errores
217
- opl rebuild → Reconstrucción de configuración
218
- ```
219
-
220
189
  ### QA, Extracción y AI
221
190
  ```
222
191
  npx openPrompt-Lang qa-gen [--lang L] [--source DIR] [--output DIR] [--dry-run] [--no-scan]
@@ -228,12 +197,6 @@ npx openPrompt-Lang db-rules [--list] [--id ID] [--tag TAG]
228
197
  npx openPrompt-Lang scaffold folders FRAMEWORK [--name N] [--force]
229
198
  ```
230
199
 
231
- ### MCP Servers
232
- ```
233
- npx openPrompt-Lang mcp → Iniciar servidor MCP principal (tools OPL)
234
- npx openPrompt-Lang mcp-plan → Iniciar servidor MCP de planificación (tools plan_*)
235
- ```
236
-
237
200
  ### MCP Server
238
201
  ```
239
202
  npx openPrompt-Lang mcp
@@ -271,21 +234,6 @@ npx openPrompt-Lang mcp
271
234
  | `work_context_start` | Iniciar sesión con tracking | `task` (req), `domain?` |
272
235
  | `work_context_status` | Estado actual de la sesión | — |
273
236
  | `work_context_close` | Cerrar sesión y registrar métricas | `summary` (req) |
274
- | `teach_progress` | Mostrar progreso de aprendizaje | `userId?`, `domain?` |
275
- | `teach_assess` | Diagnosticar nivel de dominio | `conceptId` (req), `domain?` |
276
- | `teach_study` | Generar unidad pedagógica adaptada | `conceptId` (req), `level?`, `includeExercises?` |
277
-
278
- ### Servidor OPL-Plan (tools adicionales)
279
-
280
- | Herramienta | Descripción | Parámetros |
281
- |------------|-------------|------------|
282
- | `plan_recommend_stack` | Analizar proyecto y recomendar stack | `description` (req) |
283
- | `plan_wizard` | Wizard interactivo de configuración | `project_name` (req), `context` (req) |
284
- | `plan_create` | Crear plan formal @workflow | `project_name` (req), `language` (req), `stack` (req) |
285
- | `plan_validate` | Validar que el plan esté completo | `plan_id?` |
286
- | `plan_status` | Mostrar estado del plan actual | `plan_id?` |
287
- | `plan_switch_mode` | Cambiar a EXECUTE mode | `plan_id?` |
288
- | `plan_knowledge_filter` | Filtrar biblioteca por dominio | `domain` (req), `features?` |
289
237
 
290
238
  ## 11. Reglas Estrictas
291
239
 
@@ -329,8 +277,8 @@ Explorar: `opl system list` para ver los 10 sistemas disponibles.
329
277
  | fundamentals | Fundamentos de programación y lenguajes | 8/8 |
330
278
  | architecture | Arquitectura de software y patrones de diseño transversales | 5/5 |
331
279
  | typescript | TypeScript: sistema de tipos, patrones, React+TS, tooling | 0/0 |
332
- | saas | Patrones SaaS: licenciamiento, monetización, multi-tenant, soft-lock, POS | 0/1 |
333
- | restaurant | Dominio gastronómico: POS, KDS, delivery, inventario, microservicios | 0/1 |
280
+ | saas | Patrones SaaS: licenciamiento, monetización, multi-tenant, soft-lock, POS | 1/1 |
281
+ | restaurant | Dominio gastronómico: POS, KDS, delivery, inventario, microservicios | 1/1 |
334
282
 
335
283
  ### Catálogo de Libros
336
284
 
@@ -369,9 +317,9 @@ Explorar: `opl system list` para ver los 10 sistemas disponibles.
369
317
  | scrum-y-xp-desde-las-trincheras | scrum-y-xp-desde-las-trincheras | 122 | 185 | native | ✓ |
370
318
  | typescript-introduccion-adictos-trabajo | typescript-introduccion-adictos-trabajo | 9 | 7 | native | ✓ |
371
319
  | flow-api-docs | Flow API — Documentación de Integración de Pagos | 49 | 45 | web | ✓ |
372
- | 97-cosas-que-todo-programador-deberia-saber | 97 Cosas Que Todo Programador Debería Saber | 186 | 120 | native | |
373
- | proyecto-microservicios-restaurant-springboot | Proyecto Real: Microservicios Restaurant Spring Boot | 280 | 12 | analysis | |
374
- | proyecto-saas-distribuidora-retamal | Proyecto Real: SaaS Distribuidora Retamal | 260 | 12 | analysis | |
320
+ | 97-cosas-que-todo-programador-deberia-saber | 97 Cosas Que Todo Programador Debería Saber | 186 | 120 | native ||
321
+ | proyecto-microservicios-restaurant-springboot | Proyecto Real: Microservicios Restaurant Spring Boot | 280 | 12 | analysis ||
322
+ | proyecto-saas-distribuidora-retamal | Proyecto Real: SaaS Distribuidora Retamal | 260 | 12 | analysis ||
375
323
 
376
324
  ### Playbooks Disponibles
377
325
 
@@ -488,8 +436,8 @@ knowledge_concept → { bookId, conceptSlug? }
488
436
  ## 14. Stack del Proyecto
489
437
 
490
438
  - **Lenguaje:** node
491
- - **Stack base:** node, javascript, esm, commander
492
- - **Extensiones:** vitest, eslint, inquirer, chalk, pdf-parse
439
+ - **Stack base:** node, javascript, esm, commander, mcp
440
+ - **Extensiones:** vitest, eslint, inquirer, chalk, pdf-parse, ajv
493
441
  - **Perfil:** senior
494
442
  - **Modo oscuro:** por defecto
495
443
  - **Testing:** Vitest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openprompt-lang",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "PromptLang CLI — Context Engine de anotaciones para desarrollo asistido por IA",
5
5
  "type": "module",
6
6
  "main": "./bin/cli.js",
@@ -192,4 +192,73 @@ export function register(program) {
192
192
  const { patternList } = await import("../commands/pattern.js")
193
193
  await patternList(options)
194
194
  })
195
+
196
+ // ── from commands-init.js ──
197
+ const init = program
198
+ .command("init")
199
+ .description("Inicializar proyecto o biblioteca de conocimiento personal")
200
+ .option("--name <name>", "Nombre del proyecto")
201
+ .option("--describe <text>", "Descripción del proyecto para sugerencia IA")
202
+ .option("--existing", "Configurar en proyecto existente (solo archivos de configuración)")
203
+ .option(
204
+ "--rebuild",
205
+ "Reconstruir integración OPL en proyecto existente (force-regenera archivos generados, aplica migraciones)"
206
+ )
207
+ .option("--knowledge", "Configurar biblioteca de conocimiento personal (~/.opl/knowledge/)")
208
+ .option("--dry-run", "Previsualizar sin crear archivos")
209
+ .option(
210
+ "--stack <items>",
211
+ "Stack base (separado por comas, ej: react,typescript,vite,tailwind)"
212
+ )
213
+ .option(
214
+ "--preset <name>",
215
+ "Usar preset pre-ensamblado (ej: react-supabase-stripe, vue-firebase-netlify)"
216
+ )
217
+ .option("--list-presets", "Listar presets disponibles y salir")
218
+ .option("--list-stacks", "Listar stacks disponibles y salir")
219
+ .option(
220
+ "--learn-from <file>",
221
+ "Ruta a perfil de aprendizaje (aprendizaje-perfil.json) para heredar patrones"
222
+ )
223
+ .option("--plan-only", "Solo crear estructura básica + plan MCP, sin preguntar stack")
224
+ .option("--no-interactive", "Saltar preguntas interactivas y usar defaults")
225
+ .action(async (options) => {
226
+ if (options.knowledge) {
227
+ const { initKnowledgeRepo } = await import("../commands/opl-init-knowledge.js")
228
+ await initKnowledgeRepo(options)
229
+ return
230
+ }
231
+ if (options.listStacks) {
232
+ const { listStacks } = await import("../commands/init.js")
233
+ await listStacks()
234
+ return
235
+ }
236
+ if (options.listPresets) {
237
+ const { listPresets } = await import("../commands/init.js")
238
+ await listPresets()
239
+ return
240
+ }
241
+ const { init } = await import("../commands/init.js")
242
+ await init(options)
243
+ })
244
+
245
+ program
246
+ .command("figma")
247
+ .description("Generar prompt para diseño en Figma con convenciones React + Tailwind")
248
+ .action(async () => {
249
+ const { figma } = await import("../commands/figma.js")
250
+ await figma()
251
+ })
252
+
253
+ program
254
+ .command("suggest")
255
+ .description("Sugerir o aplicar anotaciones automáticamente en archivos del proyecto")
256
+ .option("--auto-kind", "Inferir @kind para archivos sin anotaciones")
257
+ .option("--apply", "Aplicar las sugerencias directamente (escribe los archivos)")
258
+ .option("--dir <path>", "Directorio del proyecto (default: cwd)")
259
+ .option("--targets <paths>", "Archivos o directorios específicos (separados por coma)")
260
+ .action(async (options) => {
261
+ const { suggest } = await import("../commands/suggest.js")
262
+ await suggest(options)
263
+ })
195
264
  }
@@ -200,10 +200,10 @@ export function register(program) {
200
200
 
201
201
  program
202
202
  .command("mcp-plan")
203
- .description("Start MCP Plan server for planning mode via stdio")
203
+ .description("(merged into main mcp server) Start MCP OPL server plan tools are included")
204
204
  .action(async () => {
205
- const { startPlanServer } = await import("../mcp-plan-server.js")
206
- await startPlanServer()
205
+ const { startServer } = await import("../mcp-server.js")
206
+ await startServer()
207
207
  })
208
208
 
209
209
  // ──────────────────────────────────────────────
@@ -263,7 +263,7 @@ export function register(program) {
263
263
  console.log(` Workflow: ${state.workflow_compliant ? "✅ compliant" : "⏳ pendiente"}`)
264
264
  console.log("")
265
265
  if (state.mode === "plan") {
266
- console.log(chalk.gray(" 💡 Para empezar a planificar, usa plan_wizard o abre opencode."))
266
+ console.log(chalk.gray(" 💡 Para empezar a planificar, usa plan_create o abre opencode."))
267
267
  } else {
268
268
  console.log(chalk.gray(" 💡 Para implementar, usa analyze_project como primer paso."))
269
269
  }
@@ -440,4 +440,217 @@ export function register(program) {
440
440
  const { initExisting } = await import("../commands/init-existing.js")
441
441
  await initExisting({ rebuild: true, dir: options.dir || process.cwd() })
442
442
  })
443
+
444
+ // ── from commands-ai.js ──
445
+ program
446
+ .command("ai-gen")
447
+ .description("Generate components from natural language descriptions")
448
+ .option("--description <text>", "Description of what to generate")
449
+ .option("--name <name>", "Component name (auto-suggested if omitted)")
450
+ .option("--lang <lang>", "Language module (default: react)")
451
+ .option("--profile <profile>", "senior | mid | junior (default: mid)")
452
+ .option(
453
+ "--provider <provider>",
454
+ "AI provider: openai | anthropic | ollama | mock (default: auto-detect)"
455
+ )
456
+ .option("--output <dir>", "Output directory (default: src/components)")
457
+ .option("--force", "Overwrite existing files without asking")
458
+ .option("--validate", "Run annotation validation after generation")
459
+ .option("--verbose", "Show prompt and extended output")
460
+ .option("--temperature <num>", "Temperature for generation (default: 0.3)")
461
+ .option("--max-tokens <num>", "Max tokens for generation (default: 4096)")
462
+ .action(async (options) => {
463
+ const { aiGen } = await import("../commands/ai-gen.js")
464
+ await aiGen(options)
465
+ })
466
+
467
+ program
468
+ .command("ai-providers")
469
+ .description("List available AI providers and their status")
470
+ .action(async () => {
471
+ const { aiProviders } = await import("../commands/ai-gen.js")
472
+ await aiProviders()
473
+ })
474
+
475
+ program
476
+ .command("learn")
477
+ .description("Aprender desde documentación: genera módulos de lenguaje usando IA")
478
+ .option("--docs <paths...>", "Rutas a archivos/directorios de documentación")
479
+ .option("--from <paths...>", "Proyectos reales para extraer patrones (opcional)")
480
+ .option("--name <name>", "Nombre del lenguaje (si no se puede detectar automáticamente)")
481
+ .option(
482
+ "--output <dir>",
483
+ "Directorio de salida (default: ~/.openprompt/knowledge/langs/<name>)"
484
+ )
485
+ .option("--update <dir>", "Actualizar módulo existente en lugar de crear nuevo")
486
+ .option("--integrate", "Copiar el módulo generado a src/templates/langs/ (solo maintainers)")
487
+ .option("--dry-run", "Analizar y mostrar preview sin escribir archivos")
488
+ .option("--provider <provider>", "AI provider: openai | anthropic | ollama | mock")
489
+ .action(async (options) => {
490
+ const { learn } = await import("../commands/learn.js")
491
+ await learn(options)
492
+ })
493
+
494
+ // ── from commands-lang.js ──
495
+ const lang = program.command("lang").description("Gestionar módulos de lenguaje plugables")
496
+
497
+ lang
498
+ .command("list")
499
+ .description("Listar lenguajes disponibles")
500
+ .action(async () => {
501
+ const { langList } = await import("../commands/lang.js")
502
+ await langList()
503
+ })
504
+
505
+ lang
506
+ .command("index <langId>")
507
+ .description("Mostrar índice de templates de un lenguaje")
508
+ .option("--category <category>", "Filtrar por categoría")
509
+ .action(async (langId, options) => {
510
+ const { langIndex } = await import("../commands/lang.js")
511
+ await langIndex(langId, options)
512
+ })
513
+
514
+ lang
515
+ .command("search <query>")
516
+ .description("Buscar templates en todos los lenguajes")
517
+ .option("--lang <lang>", "Filtrar por lenguaje")
518
+ .action(async (query, options) => {
519
+ const { langSearch } = await import("../commands/lang.js")
520
+ await langSearch(query, options)
521
+ })
522
+
523
+ lang
524
+ .command("errors [langId]")
525
+ .description("Mostrar errores aprendidos")
526
+ .option("--template <id>", "Filtrar por template ID")
527
+ .action(async (langId, options) => {
528
+ const { langErrors } = await import("../commands/lang.js")
529
+ await langErrors(langId || "react", options)
530
+ })
531
+
532
+ // ── from commands-knowledge.js ──
533
+ const knowledge = program
534
+ .command("knowledge")
535
+ .description("Gestionar repositorio de conocimiento: ingesta y proceso de PDFs")
536
+
537
+ knowledge
538
+ .command("init")
539
+ .description("Inicializar estructura knowledge/ en el proyecto")
540
+ .action(async () => {
541
+ const { init } = await import("../commands/knowledge.js")
542
+ await init()
543
+ })
544
+
545
+ knowledge
546
+ .command("ingest <file>")
547
+ .description("Procesar un PDF: extraer texto, detectar capítulos y almacenar")
548
+ .option("--ocr", "Forzar OCR incluso si el PDF tiene texto nativo")
549
+ .option("--auto-ocr", "Detectar automáticamente si necesita OCR (baja densidad de texto)")
550
+ .option("--force", "Re-procesar PDF aunque ya exista en el índice")
551
+ .option("--verbose", "Mostrar progreso detallado (especialmente OCR)")
552
+ .option("--no-embed", "Saltar la generación automática de embeddings")
553
+ .action(async (file, options) => {
554
+ const { ingest } = await import("../commands/knowledge.js")
555
+ await ingest(file, options)
556
+ })
557
+
558
+ knowledge
559
+ .command("list")
560
+ .description("Listar PDFs procesados con metadatos")
561
+ .option(
562
+ "--domain <domain>",
563
+ "Filtrar por dominio (programming, reports, business, legal, product, technical-writing)"
564
+ )
565
+ .action(async (options) => {
566
+ const { list } = await import("../commands/knowledge.js")
567
+ await list(options)
568
+ })
569
+
570
+ knowledge
571
+ .command("status [id]")
572
+ .description("Mostrar estado detallado de uno o todos los PDFs procesados")
573
+ .action(async (id) => {
574
+ const { status } = await import("../commands/knowledge.js")
575
+ await status(id)
576
+ })
577
+
578
+ knowledge
579
+ .command("to-learning")
580
+ .description("Integrar PDFs procesados a la memoria semántica (learning)")
581
+ .option("--all", "Procesar todos los PDFs disponibles")
582
+ .option("--pdf <id>", "Integrar solo un PDF específico por ID")
583
+ .option("--force", "Re-integran aunque ya estn integrados")
584
+ .action(async (options) => {
585
+ const { toLearning } = await import("../commands/knowledge.js")
586
+ await toLearning(options)
587
+ })
588
+
589
+ knowledge
590
+ .command("rebuild")
591
+ .description("Reconstruir índice desde metadatos individuales")
592
+ .action(async () => {
593
+ const { rebuild } = await import("../commands/knowledge.js")
594
+ await rebuild()
595
+ })
596
+
597
+ knowledge
598
+ .command("sync")
599
+ .description("Sincronizar y activar libros desde la biblioteca empaquetada de npm")
600
+ .option("--all", "Activar todos los libros disponibles sin preguntar")
601
+ .action(async (options) => {
602
+ const { sync } = await import("../commands/knowledge.js")
603
+ await sync(options)
604
+ })
605
+
606
+ knowledge
607
+ .command("synthesize <topic>")
608
+ .description(
609
+ "Sintetizar nuevo conocimiento: crea estructura, valida con sandbox, indexa embeddings"
610
+ )
611
+ .option("--dry-run", "Solo preparar estructura sin indexar")
612
+ .option("--validate <cmd>", "Comando de validación (ej: node test.js)")
613
+ .option("--domain <domain>", "Dominio del nuevo conocimiento")
614
+ .action(async (topic, options) => {
615
+ const { synthesize } = await import("../commands/knowledge.js")
616
+ await synthesize(topic, options)
617
+ })
618
+
619
+ // ── scar: Anti-conocimiento ────────────────────────────────────────
620
+
621
+ const scar = program.command("scar").description("Anti-conocimiento: gestiona cicatrices de guerra (@scar)")
622
+
623
+ scar
624
+ .command("list")
625
+ .description("Lista todos los scars registrados")
626
+ .option("--category <cat>", "Filtrar por categoria (bug, error-pattern, anti-pattern, regression)")
627
+ .option("--severity <sev>", "Filtrar por severidad (blocker, critical, warning, info)")
628
+ .action(async (options) => {
629
+ const { listScarsAction } = await import("../commands/scar.js")
630
+ await listScarsAction(options)
631
+ })
632
+
633
+ scar
634
+ .command("search <query>")
635
+ .description("Busca scars por texto en id, symptom, cause, fix")
636
+ .action(async (query) => {
637
+ const { searchScarsAction } = await import("../commands/scar.js")
638
+ await searchScarsAction(query)
639
+ })
640
+
641
+ scar
642
+ .command("show <id>")
643
+ .description("Muestra detalle de un scar especifico")
644
+ .action(async (id) => {
645
+ const { showScarAction } = await import("../commands/scar.js")
646
+ await showScarAction(id)
647
+ })
648
+
649
+ scar
650
+ .command("stats")
651
+ .description("Estadisticas de anti-conocimiento")
652
+ .action(async () => {
653
+ const { statsScarAction } = await import("../commands/scar.js")
654
+ await statsScarAction()
655
+ })
443
656
  }
@@ -286,6 +286,18 @@ export function register(program) {
286
286
  await embeddings("remove", { docId })
287
287
  })
288
288
 
289
+ embeddings
290
+ .command("index-all")
291
+ .description("Indexar todos los documentos disponibles en el conocimiento")
292
+ .option("--strategy <s>", "Estrategia de chunking: section, paragraph, fixed", "section")
293
+ .option("--provider <p>", "Proveedor de embeddings: ollama, transformers")
294
+ .option("--dry-run", "Simular indexación sin persistir")
295
+ .option("--resume", "Saltar chunks ya indexados")
296
+ .action(async (options) => {
297
+ const { embeddings } = await import("../commands/opl-embeddings.js")
298
+ await embeddings("index-all", options)
299
+ })
300
+
289
301
  embeddings
290
302
  .command("config")
291
303
  .description("Ver o configurar el proveedor de embeddings")
@@ -87,4 +87,53 @@ export function register(program) {
87
87
  conceptId: options.conceptId,
88
88
  })
89
89
  })
90
+
91
+ // ── from commands-learning.js ──
92
+ const learning = program
93
+ .command("learning")
94
+ .description("Gestionar memoria semántica: conceptos, variantes y relaciones")
95
+
96
+ learning
97
+ .command("init")
98
+ .description("Inicializar sistema de memoria semántica")
99
+ .action(async () => {
100
+ const { init } = await import("../commands/learning.js")
101
+ await init()
102
+ })
103
+
104
+ learning
105
+ .command("search <query>")
106
+ .description("Buscar conceptos por nombre, tipo o tag")
107
+ .option("--category <cat>", "Filtrar por categoría (visual, ui, backend, product, ai)")
108
+ .option("--domain <domain>", "Filtrar por dominio (programming, reports, business, etc.)")
109
+ .action(async (query, options) => {
110
+ const { search } = await import("../commands/learning.js")
111
+ await search(query, options)
112
+ })
113
+
114
+ learning
115
+ .command("add <name>")
116
+ .description("Crear un nuevo concepto con template")
117
+ .option("--category <cat>", "Categoría del concepto (default: visual)")
118
+ .option("--tags <tags>", "Tags separados por coma (ej: modal,accesibilidad)")
119
+ .action(async (name, options) => {
120
+ const { add } = await import("../commands/learning.js")
121
+ await add(name, options)
122
+ })
123
+
124
+ learning
125
+ .command("map")
126
+ .description("Generar mapa visual (Mermaid) desde el grafo de relaciones")
127
+ .action(async () => {
128
+ const { map } = await import("../commands/learning.js")
129
+ await map()
130
+ })
131
+
132
+ learning
133
+ .command("import-personal <file>")
134
+ .description("Importar documento de vocabulario personal (formato ### Término + descripción)")
135
+ .action(async (file) => {
136
+ const { importPersonal } = await import("../commands/learning.js")
137
+ await importPersonal(file)
138
+ })
90
139
  }
@@ -7,13 +7,11 @@
7
7
  * Registra los comandos de workflow OPL.
8
8
  *
9
9
  * Comandos:
10
- * opl workflow discovery → E.1 — Wizard de descubrimiento
11
- * opl workflow specification → E.2 — Generación de documentos
12
- * opl workflow delivery → E.3 — Desarrollo por tickets
13
- * opl workflow close → E.4 — Cierre de sesión
14
- * opl workflow select → E.5 — Selector inteligente de workflow
15
- * opl epic → E.6 — Gestión de épicas
16
- * opl sprint → E.7 — Gestión de sprints
10
+ * opl workflow delivery → E.1 — Desarrollo por tickets
11
+ * opl workflow close → E.2 — Cierre de sesión
12
+ * opl workflow select → E.3 — Selector inteligente de workflow
13
+ * opl epic → E.4 — Gestión de épicas
14
+ * opl sprint → E.5 — Gestión de sprints
17
15
  */
18
16
 
19
17
  export function register(program) {
@@ -23,39 +21,9 @@ export function register(program) {
23
21
  const workflow = program
24
22
  .command("workflow")
25
23
  .description(
26
- "Gestionar workflows de proyecto: discovery, specification, delivery, close, select"
24
+ "Gestionar workflows de proyecto: delivery, close, select"
27
25
  )
28
26
 
29
- workflow
30
- .command("discovery")
31
- .description("Iniciar wizard de descubrimiento del proyecto (8 bloques, 29 preguntas)")
32
- .option("-p, --project <id>", "ID del proyecto")
33
- .option("-f, --force", "Re-ejecutar aunque exista discovery previo")
34
- .option("-b, --blocks <blocks>", "Bloques específicos (comma-separado)")
35
- .action(async (options) => {
36
- const { discovery } = await import("../commands/workflow/discovery/index.js")
37
- await discovery({
38
- projectId: options.project,
39
- force: options.force || false,
40
- blocks: options.blocks ? options.blocks.split(",") : undefined,
41
- })
42
- })
43
-
44
- workflow
45
- .command("specification")
46
- .description("Generar documentación del proyecto desde el wizard")
47
- .option("-p, --project <id>", "ID del proyecto")
48
- .option("-t, --templates <templates>", "Templates específicos (comma-separado)")
49
- .option("-o, --output <dir>", "Directorio de salida (default: docs/project)")
50
- .action(async (options) => {
51
- const { specification } = await import("../commands/workflow/specification/index.js")
52
- await specification({
53
- projectId: options.project,
54
- templates: options.templates ? options.templates.split(",") : undefined,
55
- outputDir: options.output,
56
- })
57
- })
58
-
59
27
  workflow
60
28
  .command("delivery")
61
29
  .description("Iniciar desarrollo por tickets (seleccionar o crear ticket)")
@@ -190,4 +158,94 @@ export function register(program) {
190
158
  const { sprintClose } = await import("../commands/workflow/sprint-cli.js")
191
159
  await sprintClose(sprintId)
192
160
  })
161
+
162
+ // ── from commands-work.js ──
163
+ const workContext = program
164
+ .command("work-context")
165
+ .description(
166
+ "Gestionar contexto de trabajo (integrado con 'opl workflow' — start≈delivery, close≈close)"
167
+ )
168
+
169
+ workContext
170
+ .command("init")
171
+ .description("Inicializar sistema work-context en proyecto existente")
172
+ .action(async () => {
173
+ const { init } = await import("../commands/work-context.js")
174
+ await init()
175
+ })
176
+
177
+ workContext
178
+ .command("status")
179
+ .description("Mostrar estado actual del contexto de trabajo")
180
+ .action(async () => {
181
+ const { status } = await import("../commands/work-context.js")
182
+ await status()
183
+ })
184
+
185
+ workContext
186
+ .command("start <description>")
187
+ .description("Iniciar una nueva sesión de trabajo")
188
+ .action(async (description) => {
189
+ const { start } = await import("../commands/work-context.js")
190
+ await start(description)
191
+ })
192
+
193
+ workContext
194
+ .command("log <message>")
195
+ .description("Añadir entrada a la bitácora")
196
+ .action(async (message) => {
197
+ const { log } = await import("../commands/work-context.js")
198
+ await log(message)
199
+ })
200
+
201
+ const planCmd = workContext.command("plan").description("Gestionar planes de trabajo")
202
+
203
+ planCmd
204
+ .command("new <name>")
205
+ .description("Crear un nuevo plan de trabajo")
206
+ .option("--task <description>", "Descripción de la tarea para búsqueda de conocimiento")
207
+ .action(async (name, options) => {
208
+ const { plan } = await import("../commands/work-context.js")
209
+ await plan(name, options)
210
+ })
211
+
212
+ planCmd
213
+ .command("check [name]")
214
+ .description("Verificar un plan existente contra el conocimiento actual")
215
+ .action(async (name) => {
216
+ const { planCheck } = await import("../commands/work-context.js")
217
+ await planCheck(name)
218
+ })
219
+
220
+ workContext
221
+ .command("close")
222
+ .description("Cerrar la sesión activa y generar reporte")
223
+ .action(async () => {
224
+ const { close } = await import("../commands/work-context.js")
225
+ await close()
226
+ })
227
+
228
+ workContext
229
+ .command("learn")
230
+ .description("Extraer aprendizajes de la sesión a LEARNINGS.md")
231
+ .action(async () => {
232
+ const { learn } = await import("../commands/work-context.js")
233
+ await learn()
234
+ })
235
+
236
+ workContext
237
+ .command("report")
238
+ .description("Generar reporte completo del contexto de trabajo")
239
+ .action(async () => {
240
+ const { report } = await import("../commands/work-context.js")
241
+ await report()
242
+ })
243
+
244
+ workContext
245
+ .command("check")
246
+ .description("Verificar consistencia del work-context")
247
+ .action(async () => {
248
+ const { check } = await import("../commands/work-context.js")
249
+ await check()
250
+ })
193
251
  }