nexakit 0.0.0-stage → 0.2.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/.claude-plugin/marketplace.json +28 -0
- package/LICENSE +26 -0
- package/README.md +79 -2
- package/agents/claude/docs-researcher.md +9 -0
- package/agents/claude/implementation-tutor.md +9 -0
- package/agents/claude/project-explorer.md +9 -0
- package/agents/claude/quality-reviewer.md +9 -0
- package/agents/claude/requirements-analyst.md +9 -0
- package/agents/claude/solution-architect.md +9 -0
- package/agents/codex/docs-researcher.toml +10 -0
- package/agents/codex/implementation-tutor.toml +10 -0
- package/agents/codex/project-explorer.toml +10 -0
- package/agents/codex/quality-reviewer.toml +10 -0
- package/agents/codex/requirements-analyst.toml +11 -0
- package/agents/codex/solution-architect.toml +10 -0
- package/assets/brand/README.md +38 -0
- package/assets/brand/agent-toolkit-mark.png +0 -0
- package/assets/brand/agent-toolkit-mark.svg +13 -0
- package/assets/brand/agent-toolkit-tui-hero.png +0 -0
- package/assets/brand/nexakit-readme-hero.png +0 -0
- package/assets/brand/nexakit-readme-hero.svg +21 -0
- package/assets/runtime/package-lock.json +1425 -0
- package/bin/agent-task.js +14 -0
- package/bin/agent-toolkit-gemini.js +13 -0
- package/bin/agent-toolkit-inbox.js +14 -0
- package/bin/agent-toolkit-mcp.js +17 -0
- package/bin/agent-toolkit.js +13 -0
- package/bin/nexakit.js +13 -0
- package/bin/project-memory-mcp.js +22 -0
- package/bin/project-memory.js +7 -0
- package/catalogs/skills/api-design-principles/LICENSE.txt +21 -0
- package/catalogs/skills/api-design-principles/SKILL.md +110 -0
- package/catalogs/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/catalogs/skills/api-design-principles/assets/rest-api-template.py +185 -0
- package/catalogs/skills/api-design-principles/references/details.md +413 -0
- package/catalogs/skills/api-design-principles/references/graphql-schema-design.md +589 -0
- package/catalogs/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/catalogs/skills/nodejs-backend-patterns/LICENSE.txt +21 -0
- package/catalogs/skills/nodejs-backend-patterns/SKILL.md +45 -0
- package/catalogs/skills/nodejs-backend-patterns/references/advanced-patterns.md +430 -0
- package/catalogs/skills/nodejs-backend-patterns/references/details.md +599 -0
- package/catalogs/skills/supabase-postgres-best-practices/CHANGELOG.md +73 -0
- package/catalogs/skills/supabase-postgres-best-practices/LICENSE.txt +21 -0
- package/catalogs/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/catalogs/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/catalogs/skills/vercel-composition-patterns/AGENTS.md +946 -0
- package/catalogs/skills/vercel-composition-patterns/LICENSE.txt +27 -0
- package/catalogs/skills/vercel-composition-patterns/README.md +60 -0
- package/catalogs/skills/vercel-composition-patterns/SKILL.md +89 -0
- package/catalogs/skills/vercel-composition-patterns/metadata.json +11 -0
- package/catalogs/skills/vercel-composition-patterns/rules/_sections.md +29 -0
- package/catalogs/skills/vercel-composition-patterns/rules/_template.md +24 -0
- package/catalogs/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/catalogs/skills/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
- package/catalogs/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/catalogs/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/catalogs/skills/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/catalogs/skills/vercel-composition-patterns/rules/state-context-interface.md +191 -0
- package/catalogs/skills/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/catalogs/skills/vercel-composition-patterns/rules/state-lift-state.md +125 -0
- package/catalogs/skills/vercel-react-best-practices/AGENTS.md +3810 -0
- package/catalogs/skills/vercel-react-best-practices/LICENSE.txt +27 -0
- package/catalogs/skills/vercel-react-best-practices/README.md +123 -0
- package/catalogs/skills/vercel-react-best-practices/SKILL.md +149 -0
- package/catalogs/skills/vercel-react-best-practices/metadata.json +15 -0
- package/catalogs/skills/vercel-react-best-practices/rules/_sections.md +46 -0
- package/catalogs/skills/vercel-react-best-practices/rules/_template.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-effect-event-deps.md +56 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/catalogs/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-cheap-condition-before-await.md +37 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-defer-await.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-analyzable-paths.md +63 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +60 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/catalogs/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/catalogs/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-flatmap-filter.md +60 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-request-idle-callback.md +105 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/catalogs/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-resource-hints.md +85 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-script-defer-async.md +68 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-no-inline-components.md +82 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-split-combined-hooks.md +64 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-use-deferred-value.md +59 -0
- package/catalogs/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-hoist-static-io.md +149 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-no-shared-module-state.md +50 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-parallel-nested-fetching.md +34 -0
- package/catalogs/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/catalogs/skills/webapp-testing/LICENSE.txt +202 -0
- package/catalogs/skills/webapp-testing/SKILL.md +96 -0
- package/catalogs/skills/webapp-testing/examples/console_logging.py +35 -0
- package/catalogs/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/catalogs/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/catalogs/skills/webapp-testing/scripts/with_server.py +106 -0
- package/catalogs/skills.json +1115 -0
- package/docs/skills/evidencias/2026-10-28-evaluacion-inicial-mcp-seguridad.md +118 -0
- package/docs/skills/evidencias/2026-10-28-incorporacion-mcp-seguridad.json +152 -0
- package/docs/skills/evidencias/2026-10-28-recomendador-preparacion.md +50 -0
- package/package.json +73 -4
- package/plugins/nexakit-modelo/.claude-plugin/plugin.json +1 -0
- package/plugins/nexakit-modelo/hooks/hooks.json +1 -0
- package/plugins/nexakit-modelo/hooks/register.js +48 -0
- package/plugins/nexakit-modelo/hooks/status.js +8 -0
- package/plugins/nexakit-modelo/tests/register.test.ts +21 -0
- package/plugins/nexakit-panel/.claude-plugin/plugin.json +1 -0
- package/plugins/nexakit-panel/README.md +20 -0
- package/plugins/nexakit-panel/hooks/hooks.json +1 -0
- package/plugins/nexakit-panel/hooks/lienzo.js +382 -0
- package/plugins/nexakit-panel/hooks/panel.js +279 -0
- package/plugins/nexakit-panel/hooks/register.tsx +248 -0
- package/plugins/nexakit-panel/tests/lienzo.test.ts +142 -0
- package/plugins/nexakit-panel/tests/panel.test.ts +240 -0
- package/plugins/nexakit-panel/tests/register.test.ts +167 -0
- package/plugins/nexakit-panel/types/index.d.ts +41 -0
- package/plugins/nexakit-sesion/.claude-plugin/plugin.json +1 -0
- package/plugins/nexakit-sesion/README.md +12 -0
- package/plugins/nexakit-sesion/hooks/aviso.js +38 -0
- package/plugins/nexakit-sesion/hooks/hooks.json +1 -0
- package/plugins/nexakit-sesion/hooks/register.js +28 -0
- package/plugins/nexakit-sesion/tests/register.test.ts +96 -0
- package/plugins/niveles/.claude-plugin/plugin.json +5 -0
- package/plugins/niveles/agents/nivel-alto.md +13 -0
- package/plugins/niveles/agents/nivel-exigente.md +13 -0
- package/plugins/niveles/agents/nivel-ligero.md +13 -0
- package/plugins/niveles/agents/nivel-normal.md +13 -0
- package/schemas/agent-client-adapter.schema.json +786 -0
- package/schemas/agent-client-auth-diagnostic.schema.json +801 -0
- package/schemas/agent-client-isolated-variant.schema.json +105 -0
- package/schemas/agent-client-isolated-verification.schema.json +99 -0
- package/schemas/agent-client-managed-preferences-invocation.schema.json +67 -0
- package/schemas/agent-client-managed-preferences.schema.json +63 -0
- package/schemas/agent-client-native-diagnostics.schema.json +85 -0
- package/schemas/agent-client-native-evaluation.schema.json +171 -0
- package/schemas/agent-client-native-preflight.schema.json +90 -0
- package/schemas/agent-client-output.schema.json +551 -0
- package/schemas/agent-client-runtime-fixture.schema.json +90 -0
- package/schemas/agent-client-runtime-local.schema.json +95 -0
- package/schemas/agent-client-runtime.schema.json +1288 -0
- package/schemas/agent-client-selective-config.schema.json +77 -0
- package/schemas/agent-client-supervised-local.schema.json +135 -0
- package/schemas/agent-client-supervised.schema.json +186 -0
- package/schemas/agent-model-preference.schema.json +573 -0
- package/schemas/agent-model-selection.schema.json +311 -0
- package/schemas/agent-task-approvals.schema.json +362 -0
- package/schemas/agent-task-prepare.schema.json +1324 -0
- package/schemas/agent-task-verify.schema.json +198 -0
- package/schemas/project-memory-update.schema.json +33 -0
- package/schemas/project-memory.schema.json +298 -0
- package/schemas/skill-catalog.schema.json +246 -0
- package/schemas/task-workflow-plan-output.schema.json +35 -0
- package/scripts/prepare-package.js +6 -0
- package/scripts/validate-skill-catalog.js +41 -0
- package/skills/cerrar-avisens/SKILL.md +12 -0
- package/skills/cerrar-memoria/SKILL.md +96 -0
- package/skills/cerrar-memoria/references/cierre.md +76 -0
- package/skills/decision-records/SKILL.md +27 -0
- package/skills/decision-records/agents/openai.yaml +7 -0
- package/skills/decision-records/references/adr-template.md +35 -0
- package/skills/differential-review/LICENSE.txt +427 -0
- package/skills/differential-review/SKILL.md +225 -0
- package/skills/differential-review/adversarial.md +203 -0
- package/skills/differential-review/agents/openai.yaml +6 -0
- package/skills/differential-review/assets/trail-of-bits-mark.svg +1 -0
- package/skills/differential-review/methodology.md +234 -0
- package/skills/differential-review/patterns.md +300 -0
- package/skills/differential-review/reporting.md +369 -0
- package/skills/elegir-modelo/SKILL.md +68 -0
- package/skills/elegir-modelo/modelos.mjs +108 -0
- package/skills/frontend-design/LICENSE.txt +177 -0
- package/skills/frontend-design/SKILL.md +71 -0
- package/skills/gemini/SKILL.md +52 -0
- package/skills/imagen/SKILL.md +12 -0
- package/skills/investigar/SKILL.md +11 -0
- package/skills/mcp-builder/LICENSE.txt +202 -0
- package/skills/mcp-builder/SKILL.md +236 -0
- package/skills/mcp-builder/reference/evaluation.md +602 -0
- package/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/skills/mcp-builder/scripts/connections.py +151 -0
- package/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/skills/ordenar-proyecto/SKILL.md +56 -0
- package/skills/project-handoff/SKILL.md +53 -0
- package/skills/project-handoff/agents/openai.yaml +7 -0
- package/skills/project-handoff/references/handoff-template.md +35 -0
- package/skills/quality-gate/LICENSE.txt +26 -0
- package/skills/quality-gate/SKILL.md +44 -0
- package/skills/quality-gate/agents/openai.yaml +7 -0
- package/skills/quality-gate/references/review-checklist.md +42 -0
- package/skills/revisar/SKILL.md +11 -0
- package/skills/revisar-skill/LICENSE-find-skills.txt +26 -0
- package/skills/revisar-skill/SKILL.md +94 -0
- package/skills/revision-cruzada/SKILL.md +59 -0
- package/skills/web-design-guidelines/AGENTS.md +156 -0
- package/skills/web-design-guidelines/LICENSE.txt +21 -0
- package/skills/web-design-guidelines/SKILL.md +29 -0
- package/src/agent-models.js +131 -0
- package/src/brand.js +117 -0
- package/src/claude-code-runner.js +642 -0
- package/src/cli-executable.js +88 -0
- package/src/cli.js +778 -0
- package/src/client-adapter-plan.js +271 -0
- package/src/client-auth-diagnostic-parser.js +211 -0
- package/src/client-auth-diagnostic.js +257 -0
- package/src/client-isolated-variant.js +106 -0
- package/src/client-isolated-verification.js +130 -0
- package/src/client-local-platform.js +14 -0
- package/src/client-managed-preferences-invocation.js +209 -0
- package/src/client-managed-preferences.js +78 -0
- package/src/client-native-access.js +134 -0
- package/src/client-native-diagnostics.js +253 -0
- package/src/client-native-evaluation.js +106 -0
- package/src/client-native-preflight-files.js +68 -0
- package/src/client-native-preflight.js +95 -0
- package/src/client-output-json.js +118 -0
- package/src/client-output-parser.js +278 -0
- package/src/client-runtime-admission.js +80 -0
- package/src/client-runtime-coordinator.js +70 -0
- package/src/client-runtime-core.js +92 -0
- package/src/client-runtime-fixture-permit.js +20 -0
- package/src/client-runtime-fixture-protocol.js +39 -0
- package/src/client-runtime-state.js +67 -0
- package/src/client-runtime-store-files.js +91 -0
- package/src/client-runtime-store.js +239 -0
- package/src/client-runtime-supervisor.js +146 -0
- package/src/client-selective-config.js +195 -0
- package/src/client-selective-files.js +126 -0
- package/src/client-supervised-codes.js +32 -0
- package/src/client-supervised-contract.js +52 -0
- package/src/client-supervised-coordinator.js +36 -0
- package/src/client-supervised-permit.js +20 -0
- package/src/client-supervised-protocol.js +37 -0
- package/src/client-supervised-store.js +167 -0
- package/src/client-supervised-supervisor.js +167 -0
- package/src/client-supervised.js +160 -0
- package/src/codex-cli-runner.js +358 -0
- package/src/codex-delivery.js +101 -0
- package/src/connect.js +703 -0
- package/src/doctor.js +795 -0
- package/src/gemini-cli.js +76 -0
- package/src/gemini-files.js +45 -0
- package/src/gemini-tools.js +249 -0
- package/src/init.js +473 -0
- package/src/install-lock.js +127 -0
- package/src/install-registry.js +61 -0
- package/src/legacy-repair.js +71 -0
- package/src/level-agents.js +111 -0
- package/src/link-states.js +172 -0
- package/src/memory-connection-artifacts.js +192 -0
- package/src/memory-connection-descriptor.js +158 -0
- package/src/memory-connection-diagnostic.js +177 -0
- package/src/memory-connection-files.js +191 -0
- package/src/memory-connection-manifest.js +118 -0
- package/src/memory-connection-package.js +176 -0
- package/src/memory-connection-plan.js +211 -0
- package/src/memory-connection-skill.js +211 -0
- package/src/memory-connection-toml.js +153 -0
- package/src/memory-locator.js +118 -0
- package/src/memory-mcp-policy.js +181 -0
- package/src/memory-mcp-server.js +166 -0
- package/src/memory-mcp-transport.js +59 -0
- package/src/missing-dependencies.js +21 -0
- package/src/model-command.js +147 -0
- package/src/model-preference.js +235 -0
- package/src/model-selection.js +368 -0
- package/src/native/managed-preferences.c +100 -0
- package/src/native/managed-preferences.h +17 -0
- package/src/package-lock-path.js +13 -0
- package/src/panel-cli.js +182 -0
- package/src/peer-handoff.js +27 -0
- package/src/peer-inbox-cli.js +211 -0
- package/src/peer-review-mcp.js +210 -0
- package/src/peer-review-store.js +532 -0
- package/src/platform.js +24 -0
- package/src/project-root.js +41 -0
- package/src/project-signals.js +339 -0
- package/src/recommend-report.js +77 -0
- package/src/review-instructions.js +211 -0
- package/src/review-policy.js +35 -0
- package/src/revision-adapters.js +157 -0
- package/src/revision-context.js +86 -0
- package/src/revision-isolation.js +222 -0
- package/src/revision-process.js +103 -0
- package/src/revision-provenance.js +89 -0
- package/src/revision-snapshot.js +120 -0
- package/src/revision.js +242 -0
- package/src/runtime-fixtures/runtime-supervisor/child.cjs +3 -0
- package/src/runtime-fixtures/runtime-supervisor/fixture.cjs +49 -0
- package/src/runtime-fixtures/supervised/child.cjs +3 -0
- package/src/runtime-fixtures/supervised/fixture.cjs +47 -0
- package/src/sensitive-data.js +21 -0
- package/src/setup-apply.js +231 -0
- package/src/setup-plan.js +231 -0
- package/src/setup-state.js +277 -0
- package/src/setup-tui.js +555 -0
- package/src/skill-catalog-add.js +91 -0
- package/src/skill-catalog-audit.js +68 -0
- package/src/skill-catalog.js +170 -0
- package/src/skill-files.js +39 -0
- package/src/skill-recommendations.js +1673 -0
- package/src/skill-scan-report.js +14 -0
- package/src/skill-scan.js +178 -0
- package/src/stable-command.js +53 -0
- package/src/stable-install.js +222 -0
- package/src/status.js +200 -0
- package/src/superpowers.js +133 -0
- package/src/sync-apply.js +227 -0
- package/src/sync-files.js +109 -0
- package/src/sync-inspect.js +394 -0
- package/src/sync-ledger.js +94 -0
- package/src/sync-markdown.js +151 -0
- package/src/sync-proposal.js +84 -0
- package/src/sync-record.js +459 -0
- package/src/sync.js +360 -0
- package/src/task-approvals.js +367 -0
- package/src/task-cli.js +79 -0
- package/src/task-external-verifier.js +584 -0
- package/src/task-prepare-files.js +115 -0
- package/src/task-prepare.js +180 -0
- package/src/task-verify-cli.js +67 -0
- package/src/task-verify-files.js +188 -0
- package/src/task-verify.js +118 -0
- package/src/task-workflow-mcp.js +544 -0
- package/src/task-workflow-store.js +254 -0
- package/src/terminal-text.js +68 -0
- package/src/toolkit-cli.js +543 -0
- package/src/toolkit-commands-guide.js +107 -0
- package/src/toolkit-setup.js +614 -0
- package/src/usage-metrics.js +43 -0
- package/templates/agent-team/01-encargo.md +158 -0
- package/templates/agent-team/02-propuesta.md +132 -0
- package/templates/agent-team/03-revision.md +150 -0
- package/templates/agent-team/README.md +213 -0
- package/templates/model-inventory/01-inventario.md +154 -0
- package/templates/model-inventory/README.md +115 -0
- package/templates/project-memory/README.md +67 -0
- package/templates/project-memory/project-memory.example.json +53 -0
- package/templates/project-memory/skill/project-id/SKILL.md +37 -0
- package/templates/project-memory/skill/project-id/references/project-profile.md +44 -0
- package/templates/project-memory/vault/00-INICIO/Estado actual.md +44 -0
- package/templates/project-memory/vault/00-INICIO/Fuentes de verdad.md +30 -0
- package/templates/project-memory/vault/00-INICIO/Inicio del proyecto.md +44 -0
- package/templates/project-memory/vault/00-INICIO/Mantenimiento de la memoria.md +26 -0
- package/templates/project-memory/vault/00-INICIO/Mapa de la memoria.md +33 -0
- package/templates/project-memory/vault/00-INICIO/Registro de sincronizaci/303/263n.md" +28 -0
- package/templates/project-memory/vault/01-PRODUCTO/Producto.md +16 -0
- package/templates/project-memory/vault/02-ARQUITECTURA/Arquitectura.md +16 -0
- package/templates/project-memory/vault/03-IMPLEMENTACION/Implementaci/303/263n.md +15 -0
- package/templates/project-memory/vault/04-DECISIONES/Decisiones.md +19 -0
- package/templates/project-memory/vault/05-ENTREGAS/Entregas.md +12 -0
- package/templates/project-memory/vault/06-OPERACION/Operaci/303/263n.md +15 -0
- package/templates/project-memory/vault/07-AGENTES/Protocolo de agentes.md +33 -0
- package/templates/project-memory/vault/08-RECURSOS/Recursos.md +12 -0
- package/templates/project-memory/vault/09-ARCHIVO/README.md +5 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { deserializeMessage, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
2
|
+
import { MEMORY_MCP_LIMITS, MemoryMcpError } from "./memory-mcp-policy.js";
|
|
3
|
+
import { decode, parseEventJson } from "./client-output-json.js";
|
|
4
|
+
|
|
5
|
+
/** Byte-framed STDIO: limits apply to each message, not a batch of valid lines. */
|
|
6
|
+
export class MemoryMcpTransport {
|
|
7
|
+
constructor(input, output, hooks = {}) {
|
|
8
|
+
this.input = input; this.output = output; this.hooks = hooks;
|
|
9
|
+
this.parts = []; this.bytes = 0; this.closed = false; this.started = false;
|
|
10
|
+
this.data = chunk => this.accept(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
11
|
+
this.end = () => { void this.close(); };
|
|
12
|
+
this.error = () => this.fail("RG_PROTOCOL_ERROR");
|
|
13
|
+
}
|
|
14
|
+
async start() {
|
|
15
|
+
if (this.started || this.closed) throw new MemoryMcpError("RG_PROTOCOL_ERROR");
|
|
16
|
+
this.started = true;
|
|
17
|
+
this.input.on("data", this.data); this.input.on("end", this.end); this.input.on("error", this.error);
|
|
18
|
+
}
|
|
19
|
+
fail(code) { this.hooks.onFatal?.(code); this.onerror?.(new MemoryMcpError(code, true)); void this.close(); }
|
|
20
|
+
accept(chunk) {
|
|
21
|
+
if (this.closed) return;
|
|
22
|
+
let offset = 0;
|
|
23
|
+
while (offset < chunk.length && !this.closed) {
|
|
24
|
+
const newline = chunk.indexOf(10, offset), stop = newline === -1 ? chunk.length : newline;
|
|
25
|
+
this.bytes += stop - offset;
|
|
26
|
+
if (this.bytes > MEMORY_MCP_LIMITS.requestBytes) { this.fail("RG_INPUT_LIMIT"); return; }
|
|
27
|
+
this.parts.push(chunk.subarray(offset, stop));
|
|
28
|
+
if (newline === -1) return;
|
|
29
|
+
const bytes = Buffer.concat(this.parts, this.bytes); this.parts = []; this.bytes = 0;
|
|
30
|
+
try {
|
|
31
|
+
// Reject invalid UTF-8 and duplicate JSON keys before SDK dispatch.
|
|
32
|
+
const message = deserializeMessage(JSON.stringify(parseEventJson(decode(bytes))));
|
|
33
|
+
if ("id" in message && !(Number.isSafeInteger(message.id) || typeof message.id === "string" && message.id.length <= 128)) throw Error();
|
|
34
|
+
if ("method" in message && (message.method.length > 128 || /[\x00-\x1f]/.test(message.method))) throw Error();
|
|
35
|
+
this.onmessage?.(message);
|
|
36
|
+
} catch { this.fail("RG_PROTOCOL_ERROR"); return; }
|
|
37
|
+
offset = newline + 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async send(message) {
|
|
41
|
+
if (this.closed) throw new MemoryMcpError("RG_SESSION_CLOSED");
|
|
42
|
+
if (message.error) {
|
|
43
|
+
const code = message.error.message.match(/^(?:MCP error -\d+: )?(RG_[A-Z_]+)$/)?.[1];
|
|
44
|
+
message = { jsonrpc: "2.0", id: message.id, error: { code: message.error.code, message: code ?? "RG_PROTOCOL_ERROR" } };
|
|
45
|
+
}
|
|
46
|
+
const line = serializeMessage(message);
|
|
47
|
+
if (Buffer.byteLength(line) > MEMORY_MCP_LIMITS.responseBytes) { this.fail("RG_RESPONSE_LIMIT"); throw new MemoryMcpError("RG_RESPONSE_LIMIT", true); }
|
|
48
|
+
await new Promise((resolve, reject) => {
|
|
49
|
+
try { this.output.write(line, error => error ? reject(new MemoryMcpError("RG_PROTOCOL_ERROR", true)) : resolve()); }
|
|
50
|
+
catch { reject(new MemoryMcpError("RG_PROTOCOL_ERROR", true)); }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async close() {
|
|
54
|
+
if (this.closed) return; this.closed = true; this.parts = []; this.bytes = 0;
|
|
55
|
+
this.input.off("data", this.data); this.input.off("end", this.end); this.input.off("error", this.error);
|
|
56
|
+
if (!this.input.listenerCount("data")) this.input.pause();
|
|
57
|
+
this.onclose?.(); this.hooks.onClose?.();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { isEphemeralPath } from './link-states.js';
|
|
4
|
+
|
|
5
|
+
// This file must stay free of third-party imports: it has to run exactly when they are missing.
|
|
6
|
+
const copyRoot = () => path.resolve(fileURLToPath(new URL('..', import.meta.url)));
|
|
7
|
+
|
|
8
|
+
// Loads a module of nexakit. If a third-party package is missing in a checkout, says how to install it instead
|
|
9
|
+
// of showing a stack trace. Any other failure is raised untouched, and so is a missing package under npx,
|
|
10
|
+
// where `npm ci` would be the wrong advice.
|
|
11
|
+
export async function loadWithDependencyCheck(load, { root = copyRoot(), write = text => process.stderr.write(text) } = {}) {
|
|
12
|
+
try {
|
|
13
|
+
return await load();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
const missingPackage = error?.code === 'ERR_MODULE_NOT_FOUND' && /^Cannot find package '/u.test(error.message ?? '');
|
|
16
|
+
if (!missingPackage || isEphemeralPath(root)) throw error;
|
|
17
|
+
write(`Faltan las dependencias de esta copia. Ejecuta \`npm ci\` en ${root}.\n`);
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import { getStaticTOMLValue, parseTOML } from 'toml-eslint-parser';
|
|
5
|
+
import { agentModels } from './agent-models.js';
|
|
6
|
+
import { resolveCliInvocation } from './cli-executable.js';
|
|
7
|
+
import { runRevisionProcess } from './revision-process.js';
|
|
8
|
+
import pkg from '../package.json' with { type: 'json' };
|
|
9
|
+
|
|
10
|
+
export async function inspectModels({
|
|
11
|
+
homeDirectory = os.homedir(),
|
|
12
|
+
environment = process.env,
|
|
13
|
+
codexProfile,
|
|
14
|
+
runCommand,
|
|
15
|
+
includeAntigravity = true,
|
|
16
|
+
} = {}) {
|
|
17
|
+
const codexHome = environment.CODEX_HOME ?? path.join(homeDirectory, '.codex');
|
|
18
|
+
const claudeHome = environment.CLAUDE_CONFIG_DIR ?? path.join(homeDirectory, '.claude');
|
|
19
|
+
const old = await agentModels({ codexHome, claudeHome });
|
|
20
|
+
let cache = {},
|
|
21
|
+
config = {},
|
|
22
|
+
settings = {};
|
|
23
|
+
try {
|
|
24
|
+
cache = JSON.parse(await fs.readFile(path.join(codexHome, 'models_cache.json'), 'utf8'));
|
|
25
|
+
} catch {}
|
|
26
|
+
try {
|
|
27
|
+
config = getStaticTOMLValue(parseTOML(await fs.readFile(path.join(codexHome, 'config.toml'), 'utf8')));
|
|
28
|
+
} catch {}
|
|
29
|
+
try {
|
|
30
|
+
settings = JSON.parse(await fs.readFile(path.join(claudeHome, 'settings.json'), 'utf8'));
|
|
31
|
+
} catch {}
|
|
32
|
+
const profile = codexProfile ?? config.profile;
|
|
33
|
+
const selected = profile ? config.profiles?.[profile] : null;
|
|
34
|
+
let storedCodex =
|
|
35
|
+
profile && !selected
|
|
36
|
+
? null
|
|
37
|
+
: {
|
|
38
|
+
model: selected?.model ?? config.model ?? null,
|
|
39
|
+
effort: selected?.model_reasoning_effort ?? config.model_reasoning_effort ?? null,
|
|
40
|
+
};
|
|
41
|
+
// Modern Codex profiles can also be separate files; no shell interpolation.
|
|
42
|
+
if (profile && /^[a-zA-Z0-9._-]+$/u.test(profile)) {
|
|
43
|
+
try {
|
|
44
|
+
const layer = getStaticTOMLValue(
|
|
45
|
+
parseTOML(await fs.readFile(path.join(codexHome, `${profile}.config.toml`), 'utf8')),
|
|
46
|
+
);
|
|
47
|
+
storedCodex = {
|
|
48
|
+
model: layer.model ?? config.model ?? null,
|
|
49
|
+
effort: layer.model_reasoning_effort ?? config.model_reasoning_effort ?? null,
|
|
50
|
+
};
|
|
51
|
+
} catch {}
|
|
52
|
+
}
|
|
53
|
+
let antigravity = [],
|
|
54
|
+
error = null;
|
|
55
|
+
if (includeAntigravity) {
|
|
56
|
+
try {
|
|
57
|
+
let result;
|
|
58
|
+
if (runCommand) result = await runCommand('agy', ['models']);
|
|
59
|
+
else {
|
|
60
|
+
const cli = await resolveCliInvocation({ name: 'agy', environment });
|
|
61
|
+
result = await runRevisionProcess(
|
|
62
|
+
{ executable: cli.executable, args: [...cli.argsPrefix, 'models'], env: environment },
|
|
63
|
+
{ prompt: '', timeoutMs: 20000 },
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (result.status !== 0 || result.timedOut) throw new Error('No se pudo consultar agy models.');
|
|
67
|
+
antigravity = result.stdout.split('\n').flatMap((line) => {
|
|
68
|
+
const [model, label] = line.split('\t');
|
|
69
|
+
const effort = model?.match(/-(low|medium|high|xhigh|max)$/u)?.[1];
|
|
70
|
+
return model && label && effort
|
|
71
|
+
? [{ model, description: label, efforts: [effort], defaultEffort: effort }]
|
|
72
|
+
: [];
|
|
73
|
+
});
|
|
74
|
+
} catch (e) {
|
|
75
|
+
error = e.message;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const codex = old.codex.models.map((item) => ({
|
|
79
|
+
...item,
|
|
80
|
+
defaultEffort: cache.models?.find((m) => m.slug === item.model)?.default_reasoning_level ?? null,
|
|
81
|
+
}));
|
|
82
|
+
return {
|
|
83
|
+
catalogs: { claude: old.claude.map((m) => ({ ...m, defaultEffort: 'medium' })), codex, antigravity },
|
|
84
|
+
stored: {
|
|
85
|
+
claude: {
|
|
86
|
+
model: settings.model ?? null,
|
|
87
|
+
effort: settings.modelSettings?.[settings.model]?.effortLevel ?? settings.effortLevel ?? null,
|
|
88
|
+
},
|
|
89
|
+
codex: storedCodex,
|
|
90
|
+
antigravity: null,
|
|
91
|
+
},
|
|
92
|
+
sources: {
|
|
93
|
+
claude: `lista incluida en nexakit ${pkg.version}`,
|
|
94
|
+
codex: 'models_cache.json de Codex',
|
|
95
|
+
antigravity: error ?? 'agy models; el esfuerzo forma parte del id',
|
|
96
|
+
},
|
|
97
|
+
levels: old.levels,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function validateReviewChoice(options) {
|
|
102
|
+
const data = await inspectModels({ ...options, includeAntigravity: options.client === 'antigravity' });
|
|
103
|
+
const match = data.catalogs[options.client]?.find((item) => item.model === options.model);
|
|
104
|
+
if (!match || !match.efforts.includes(options.effort))
|
|
105
|
+
throw new Error('Modelo o esfuerzo no disponible en el catálogo real; consulta nexakit modelo.');
|
|
106
|
+
}
|
|
107
|
+
export async function runModelCommand(args, { out, err }, options = {}) {
|
|
108
|
+
let level, client, profile;
|
|
109
|
+
const seen = new Set();
|
|
110
|
+
for (let i = 0; i < args.length; i++) {
|
|
111
|
+
const flag = args[i],
|
|
112
|
+
value = args[++i];
|
|
113
|
+
if (seen.has(flag) || !value) {
|
|
114
|
+
await err('Argumentos de modelo inválidos.\n');
|
|
115
|
+
return 2;
|
|
116
|
+
}
|
|
117
|
+
seen.add(flag);
|
|
118
|
+
if (flag === '--nivel') level = value;
|
|
119
|
+
else if (flag === '--ia') client = value;
|
|
120
|
+
else if (flag === '--perfil-codex') profile = value;
|
|
121
|
+
else return 2;
|
|
122
|
+
}
|
|
123
|
+
if (client && !['claude', 'codex', 'antigravity'].includes(client)) return 2;
|
|
124
|
+
const data = await inspectModels({ ...options, codexProfile: profile });
|
|
125
|
+
const row = level ? data.levels.find((x) => x.level.toLowerCase() === level.toLowerCase()) : null;
|
|
126
|
+
if (level && !row) return 2;
|
|
127
|
+
for (const ia of client ? [client] : ['claude', 'codex', 'antigravity']) {
|
|
128
|
+
await out(`${ia}: ${data.sources[ia]}\n`);
|
|
129
|
+
for (const model of data.catalogs[ia])
|
|
130
|
+
await out(
|
|
131
|
+
` ${model.model} · ${model.efforts.join(', ')} · defecto ${model.defaultEffort ?? 'no informado'}\n`,
|
|
132
|
+
);
|
|
133
|
+
const stored = data.stored[ia],
|
|
134
|
+
wanted = row?.[ia];
|
|
135
|
+
const mark =
|
|
136
|
+
!stored?.model || !stored?.effort || !wanted
|
|
137
|
+
? '?'
|
|
138
|
+
: stored.model === wanted.model && stored.effort === wanted.effort
|
|
139
|
+
? '✓'
|
|
140
|
+
: '→';
|
|
141
|
+
await out(
|
|
142
|
+
`${mark} Guardado: ${stored?.model ?? 'no comprobable'} · ${stored?.effort ?? 'no informado'}${wanted ? ` · recomendado ${wanted.model} · ${wanted.effort}` : ''}\n`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
await out('Compara lo guardado; una sesión abierta puede diferir. Compruébalo en /model.\n');
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
2
|
+
|
|
3
|
+
const SCHEMA_ID = "https://agent-toolkit.local/schemas/agent-model-preference.schema.json";
|
|
4
|
+
const DOCUMENTS = ["request", "catalog", "policy"];
|
|
5
|
+
|
|
6
|
+
// Internal extension: helpers and both schemas come from the trusted factory.
|
|
7
|
+
// This module performs no file, network, account or client operations.
|
|
8
|
+
export function createPreferenceSelector(baseSchema, schema, helpers) {
|
|
9
|
+
const {
|
|
10
|
+
hashJson, isUtcTimestamp, emptyReport, finish, semanticIssues, taskBlocks,
|
|
11
|
+
profileExclusions, matchingEvaluations, compareText, uniqueIssues,
|
|
12
|
+
hasDuplicates, REQUIRED_REQUEST_FIELDS, REQUIRED_REQUIREMENTS
|
|
13
|
+
} = helpers;
|
|
14
|
+
if (schema.$id !== SCHEMA_ID) throw new Error("Unsupported preference schema");
|
|
15
|
+
const ajv = new Ajv2020({ strict: true, allErrors: true });
|
|
16
|
+
ajv.addFormat("date-time", { type: "string", validate: isUtcTimestamp });
|
|
17
|
+
ajv.addSchema(baseSchema);
|
|
18
|
+
ajv.addSchema(schema);
|
|
19
|
+
const validators = Object.fromEntries(DOCUMENTS.map((name) => [
|
|
20
|
+
name, ajv.compile({ $ref: `${SCHEMA_ID}#/$defs/${name}` })
|
|
21
|
+
]));
|
|
22
|
+
const schemaSha256 = hashJson(schema);
|
|
23
|
+
const baseSchemaSha256 = hashJson(baseSchema);
|
|
24
|
+
const comboKey = (profileId, effort) => JSON.stringify([profileId, effort]);
|
|
25
|
+
const scopeKey = (rule) => JSON.stringify([rule.category, rule.difficulty, rule.risk]);
|
|
26
|
+
const sameScope = (rule, request) => rule.category === request.category &&
|
|
27
|
+
rule.difficulty === request.difficulty && rule.risk === request.risk;
|
|
28
|
+
|
|
29
|
+
return function selectPreference(data) {
|
|
30
|
+
const report = emptyReport(schemaSha256);
|
|
31
|
+
report.schemaVersion = "2.0.0";
|
|
32
|
+
report.selectorVersion = "2.0.0";
|
|
33
|
+
report.audit.baseSchemaSha256 = baseSchemaSha256;
|
|
34
|
+
report.effortExcluded = [];
|
|
35
|
+
report.alternatives = [];
|
|
36
|
+
for (const name of DOCUMENTS) {
|
|
37
|
+
report.audit[`${name}Sha256`] = data[name] === undefined ? null : hashJson(data[name]);
|
|
38
|
+
if (!validators[name](data[name])) report.issues.push({ code: "schema-invalid", document: name });
|
|
39
|
+
}
|
|
40
|
+
if (validators.request(data.request)) {
|
|
41
|
+
const { projectId, taskId, revision, role, mode } = data.request;
|
|
42
|
+
report.identity = { projectId, taskId, revision, role, mode };
|
|
43
|
+
}
|
|
44
|
+
if (report.issues.length) return finish(report, "invalid", "invalid-structure-or-version-mix");
|
|
45
|
+
|
|
46
|
+
const { request, catalog, policy } = data;
|
|
47
|
+
report.audit.catalog = { id: catalog.catalogId, revision: catalog.revision };
|
|
48
|
+
report.audit.policy = { id: policy.policyId, revision: policy.revision };
|
|
49
|
+
report.constraints = {
|
|
50
|
+
provider: request.provider ?? null, client: request.client ?? null,
|
|
51
|
+
mode: request.mode, authorizationContext: request.authorizationContext ?? null,
|
|
52
|
+
history: request.history ?? null, maxCorrectionRounds: policy.maxCorrectionRounds,
|
|
53
|
+
maxFutureExecutions: policy.maxFutureExecutions,
|
|
54
|
+
maxFutureDurationSeconds: policy.maxFutureDurationSeconds,
|
|
55
|
+
accessType: policy.accessType, execution: policy.execution
|
|
56
|
+
};
|
|
57
|
+
const profiles = new Map(catalog.profiles.map((entry) => [entry.profileId, entry]));
|
|
58
|
+
// Reuse v1 invariants only; this projection never selects or migrates data.
|
|
59
|
+
const invariantPolicy = {
|
|
60
|
+
...policy,
|
|
61
|
+
routes: policy.routes.map((route) => ({
|
|
62
|
+
...route,
|
|
63
|
+
priorities: [...new Set(route.families.flatMap((family) => family.profileIds))]
|
|
64
|
+
.map((profileId) => ({ profileId, rank: 0 }))
|
|
65
|
+
}))
|
|
66
|
+
};
|
|
67
|
+
const issues = semanticIssues(request, catalog, invariantPolicy, profiles);
|
|
68
|
+
const add = (code, document) => issues.push({ code, document });
|
|
69
|
+
const versions = new Set();
|
|
70
|
+
const models = new Set();
|
|
71
|
+
for (const profile of catalog.profiles) {
|
|
72
|
+
const modelKey = JSON.stringify([profile.provider, profile.client, profile.requestedModel]);
|
|
73
|
+
if (models.has(modelKey)) add("duplicate-model-identity", "catalog");
|
|
74
|
+
models.add(modelKey);
|
|
75
|
+
if (profile.versionOrdinal !== null) {
|
|
76
|
+
const key = JSON.stringify([profile.provider, profile.client, profile.familyId, profile.versionOrdinal]);
|
|
77
|
+
if (versions.has(key)) add("duplicate-version-ordinal", "catalog");
|
|
78
|
+
versions.add(key);
|
|
79
|
+
}
|
|
80
|
+
for (const evaluation of profile.evaluations) {
|
|
81
|
+
if (!supportsEffort(profile, evaluation.effort)) add("unsupported-evaluation-effort", "catalog");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
for (const route of policy.routes) {
|
|
85
|
+
if (hasDuplicates(route.families.map((family) => family.familyId))) add("duplicate-family", "policy");
|
|
86
|
+
if (hasDuplicates(route.families.map((family) => family.rank))) add("ambiguous-family-order", "policy");
|
|
87
|
+
if (hasDuplicates(route.families.flatMap((family) => family.profileIds))) add("duplicate-family-profile", "policy");
|
|
88
|
+
const ruleIds = [];
|
|
89
|
+
const combinations = new Map();
|
|
90
|
+
const effortRanks = new Map();
|
|
91
|
+
for (const family of route.families) {
|
|
92
|
+
if (hasDuplicates(family.effortRules.map(scopeKey))) add("overlapping-effort-rules", "policy");
|
|
93
|
+
for (const id of family.profileIds) {
|
|
94
|
+
const profile = profiles.get(id);
|
|
95
|
+
if (profile && profile.familyId !== family.familyId) add("family-profile-mismatch", "policy");
|
|
96
|
+
}
|
|
97
|
+
for (const rule of family.effortRules) {
|
|
98
|
+
ruleIds.push(rule.ruleId);
|
|
99
|
+
if (!route.categories.includes(rule.category)) add("rule-category-not-permitted", "policy");
|
|
100
|
+
if (hasDuplicates(rule.options.map((option) => comboKey(option.profileId, option.effort)))) {
|
|
101
|
+
add("duplicate-effort-option", "policy");
|
|
102
|
+
}
|
|
103
|
+
for (const option of rule.options) {
|
|
104
|
+
const profile = profiles.get(option.profileId);
|
|
105
|
+
if (!profile) { add("unknown-effort-profile", "policy"); continue; }
|
|
106
|
+
if (!family.profileIds.includes(option.profileId)) add("effort-profile-outside-family", "policy");
|
|
107
|
+
if (!supportsEffort(profile, option.effort)) add("unsupported-effort", "policy");
|
|
108
|
+
const key = comboKey(option.profileId, option.effort);
|
|
109
|
+
const previous = combinations.get(key);
|
|
110
|
+
if (previous && (previous.effortRank !== option.effortRank ||
|
|
111
|
+
previous.progressionRank !== option.progressionRank)) add("inconsistent-effort-order", "policy");
|
|
112
|
+
combinations.set(key, option);
|
|
113
|
+
const rankKey = JSON.stringify([option.profileId, option.effortRank]);
|
|
114
|
+
if (effortRanks.has(rankKey) && effortRanks.get(rankKey) !== key) add("ambiguous-effort-order", "policy");
|
|
115
|
+
effortRanks.set(rankKey, key);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (hasDuplicates(ruleIds)) add("duplicate-effort-rule-id", "policy");
|
|
120
|
+
for (const profileId of new Set([...combinations.values()].map((option) => option.profileId))) {
|
|
121
|
+
const ordered = [...combinations.values()].filter((option) => option.profileId === profileId)
|
|
122
|
+
.sort((a, b) => a.effortRank - b.effortRank);
|
|
123
|
+
if (ordered.some((option, index) => index > 0 && option.progressionRank < ordered[index - 1].progressionRank)) {
|
|
124
|
+
add("contradictory-quality-progression", "policy");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (request.explicitEffort !== undefined && !request.explicitProfileId) add("explicit-effort-without-profile", "request");
|
|
129
|
+
if (request.history?.previousEffort !== undefined && !request.history.previousProfileId) {
|
|
130
|
+
add("previous-effort-without-profile", "request");
|
|
131
|
+
}
|
|
132
|
+
report.issues = uniqueIssues(issues);
|
|
133
|
+
if (report.issues.length) return finish(report, "invalid", "invalid-references-or-data");
|
|
134
|
+
|
|
135
|
+
report.missing = REQUIRED_REQUEST_FIELDS.filter((key) => request[key] === undefined);
|
|
136
|
+
if (request.requirements) report.missing.push(...REQUIRED_REQUIREMENTS
|
|
137
|
+
.filter((key) => request.requirements[key] === undefined).map((key) => `requirements.${key}`));
|
|
138
|
+
if (request.escalation && request.history) {
|
|
139
|
+
if (!request.history.previousProfileId) report.missing.push("history.previousProfileId");
|
|
140
|
+
if (request.history.previousEffort === undefined) report.missing.push("history.previousEffort");
|
|
141
|
+
}
|
|
142
|
+
report.missing.sort(compareText);
|
|
143
|
+
if (report.missing.length) return finish(report, "needs-info", "missing-task-information");
|
|
144
|
+
const blocks = taskBlocks(request, policy);
|
|
145
|
+
if (blocks.length) {
|
|
146
|
+
report.reasons.push(...blocks);
|
|
147
|
+
return finish(report, "blocked");
|
|
148
|
+
}
|
|
149
|
+
const route = policy.routes.find((entry) => entry.role === request.role &&
|
|
150
|
+
entry.provider === request.provider && entry.client === request.client);
|
|
151
|
+
if (!route || !route.modes.includes(request.mode) || !route.categories.includes(request.category)) {
|
|
152
|
+
return finish(report, "blocked", "route-not-permitted");
|
|
153
|
+
}
|
|
154
|
+
let previousCombination;
|
|
155
|
+
if (request.escalation) {
|
|
156
|
+
previousCombination = route.families.flatMap((family) => family.effortRules)
|
|
157
|
+
.flatMap((rule) => rule.options).find((option) =>
|
|
158
|
+
option.profileId === request.history.previousProfileId && option.effort === request.history.previousEffort);
|
|
159
|
+
if (!previousCombination) return finish(report, "blocked", "previous-combination-not-in-route");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const availability = new Map(request.availability.map((entry) => [entry.profileId, entry]));
|
|
163
|
+
const families = new Map(route.families.map((family) => [family.familyId, family]));
|
|
164
|
+
const candidates = [];
|
|
165
|
+
for (const profile of [...catalog.profiles].sort((a, b) => compareText(a.profileId, b.profileId))) {
|
|
166
|
+
const family = families.get(profile.familyId);
|
|
167
|
+
const permitted = family?.profileIds.includes(profile.profileId);
|
|
168
|
+
const record = availability.get(profile.profileId);
|
|
169
|
+
const reasons = profileExclusions(profile, permitted ? { rank: family.rank } : undefined, record, request, policy);
|
|
170
|
+
if (!permitted) {
|
|
171
|
+
report.excluded.push({ profileId: profile.profileId, reasons });
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (family.profileIds.some((id) => profiles.get(id).versionOrdinal === null)) reasons.push("family-version-order-unknown");
|
|
175
|
+
const rule = family.effortRules.find((entry) => sameScope(entry, request));
|
|
176
|
+
if (!rule) reasons.push("no-matching-effort-rule");
|
|
177
|
+
if (reasons.length) {
|
|
178
|
+
report.excluded.push({ profileId: profile.profileId, reasons });
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
let admitted = 0;
|
|
182
|
+
for (const option of rule.options.filter((entry) => entry.profileId === profile.profileId)
|
|
183
|
+
.sort((a, b) => a.effortRank - b.effortRank)) {
|
|
184
|
+
const optionReasons = [];
|
|
185
|
+
const evaluations = matchingEvaluations(profile, request).filter((entry) => entry.effort === option.effort);
|
|
186
|
+
if (!evaluations.length) optionReasons.push("effort-scope-not-evaluated");
|
|
187
|
+
if (option.effortRank > rule.maxEffortRank) optionReasons.push("effort-limit-exceeded");
|
|
188
|
+
if (previousCombination && option.progressionRank <= previousCombination.progressionRank) {
|
|
189
|
+
optionReasons.push("not-higher-approved-progression");
|
|
190
|
+
}
|
|
191
|
+
if (optionReasons.length) report.effortExcluded.push({ profileId: profile.profileId, effort: option.effort, reasons: optionReasons });
|
|
192
|
+
else {
|
|
193
|
+
candidates.push({ profile, family, rule, option, record, evaluations });
|
|
194
|
+
admitted++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!admitted) report.excluded.push({ profileId: profile.profileId, reasons: ["no-admissible-effort"] });
|
|
198
|
+
}
|
|
199
|
+
candidates.sort((a, b) => a.family.rank - b.family.rank ||
|
|
200
|
+
b.profile.versionOrdinal - a.profile.versionOrdinal || a.option.effortRank - b.option.effortRank ||
|
|
201
|
+
compareText(a.profile.profileId, b.profile.profileId));
|
|
202
|
+
report.alternatives = candidates.map(({ profile, family, option }) => ({
|
|
203
|
+
profileId: profile.profileId, familyId: family.familyId, familyRank: family.rank,
|
|
204
|
+
versionOrdinal: profile.versionOrdinal, effort: option.effort,
|
|
205
|
+
effortRank: option.effortRank, progressionRank: option.progressionRank
|
|
206
|
+
}));
|
|
207
|
+
const chosen = request.explicitProfileId ? candidates.find((entry) =>
|
|
208
|
+
entry.profile.profileId === request.explicitProfileId &&
|
|
209
|
+
(request.explicitEffort === undefined || entry.option.effort === request.explicitEffort)) : candidates[0];
|
|
210
|
+
if (!chosen) return finish(report, "blocked", request.explicitProfileId
|
|
211
|
+
? "explicit-choice-not-admissible" : "no-admissible-combination");
|
|
212
|
+
const { profile, family, rule, option, record, evaluations } = chosen;
|
|
213
|
+
report.recommendation = {
|
|
214
|
+
profileId: profile.profileId, provider: profile.provider, client: profile.client,
|
|
215
|
+
requestedModel: profile.requestedModel, versionPolicy: profile.versionPolicy,
|
|
216
|
+
familyId: family.familyId, familyRank: family.rank,
|
|
217
|
+
familyEvidenceRefs: family.evidenceRefs,
|
|
218
|
+
versionOrdinal: profile.versionOrdinal, versionEvidenceRefs: profile.versionEvidenceRefs,
|
|
219
|
+
effort: option.effort, effortRank: option.effortRank, effortRuleId: rule.ruleId,
|
|
220
|
+
effortEvidenceRefs: [...new Set([...rule.evidenceRefs, ...option.evidenceRefs])].sort(compareText),
|
|
221
|
+
progressionRank: option.progressionRank,
|
|
222
|
+
evaluationEvidenceRefs: [...new Set(evaluations.flatMap((entry) => entry.evidenceRefs))].sort(compareText),
|
|
223
|
+
availabilityEvidence: record
|
|
224
|
+
};
|
|
225
|
+
const knownOrdinals = family.profileIds.map((id) => profiles.get(id).versionOrdinal);
|
|
226
|
+
if (profile.versionOrdinal < Math.max(...knownOrdinals)) report.reasons.push("older-than-known-version");
|
|
227
|
+
if (request.escalation) report.reasons.push("quality-escalation-with-declared-evidence");
|
|
228
|
+
return finish(report, "recommended", request.explicitProfileId
|
|
229
|
+
? "explicit-compatible-choice" : "preferred-family-latest-admissible-version-and-effort");
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function supportsEffort(profile, effort) {
|
|
234
|
+
return effort === null ? profile.effortOptions.length === 0 : profile.effortOptions.includes(effort);
|
|
235
|
+
}
|