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,368 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
4
|
+
|
|
5
|
+
import { createPreferenceSelector } from "./model-preference.js";
|
|
6
|
+
|
|
7
|
+
const SCHEMA_ID = "https://agent-toolkit.local/schemas/agent-model-selection.schema.json";
|
|
8
|
+
const SELECTOR_VERSION = "1.0.0";
|
|
9
|
+
const DOCUMENTS = ["request", "catalog", "policy"];
|
|
10
|
+
const REQUIRED_REQUEST_FIELDS = [
|
|
11
|
+
"provider", "client", "category", "difficulty", "risk",
|
|
12
|
+
"requirements", "authorizationContext", "history", "availability"
|
|
13
|
+
];
|
|
14
|
+
const REQUIRED_REQUIREMENTS = [
|
|
15
|
+
"tools", "inputModalities", "outputFormats", "contextTokens", "riskFactors"
|
|
16
|
+
];
|
|
17
|
+
const ROLE_ACTIONS = {
|
|
18
|
+
coordinator: ["read"],
|
|
19
|
+
reviewer: ["read", "verify"],
|
|
20
|
+
tutor: ["read", "explain"],
|
|
21
|
+
proposer: ["read", "propose"],
|
|
22
|
+
executor: ["read", "apply", "verify"]
|
|
23
|
+
};
|
|
24
|
+
const CATEGORY_ACTIONS = {
|
|
25
|
+
documentation: ["read"],
|
|
26
|
+
tutoring: ["explain"],
|
|
27
|
+
proposal: ["propose"],
|
|
28
|
+
diagnostic: ["read"],
|
|
29
|
+
application: ["apply", "verify"],
|
|
30
|
+
review: ["verify"]
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Initialize with the trusted, packaged schema as JSON data. The caller loads
|
|
35
|
+
* it; neither initialization nor recommendation reads files or launches clients.
|
|
36
|
+
* Recommendations describe declared permission/evidence, never authenticate it.
|
|
37
|
+
*/
|
|
38
|
+
export function createModelSelector(schema, preferenceSchema) {
|
|
39
|
+
const schemaCopy = copyJson(schema);
|
|
40
|
+
if (schemaCopy.$id !== SCHEMA_ID) throw new Error("Unsupported selector schema");
|
|
41
|
+
const ajv = new Ajv2020({ strict: true, allErrors: true });
|
|
42
|
+
ajv.addFormat("date-time", { type: "string", validate: isUtcTimestamp });
|
|
43
|
+
ajv.addSchema(schemaCopy);
|
|
44
|
+
const validators = Object.fromEntries(DOCUMENTS.map((name) => [
|
|
45
|
+
name, ajv.compile({ $ref: `${SCHEMA_ID}#/$defs/${name}` })
|
|
46
|
+
]));
|
|
47
|
+
const schemaSha256 = hashJson(schemaCopy);
|
|
48
|
+
const selectPreference = preferenceSchema === undefined ? null : createPreferenceSelector(
|
|
49
|
+
schemaCopy, copyJson(preferenceSchema), {
|
|
50
|
+
hashJson, isUtcTimestamp, emptyReport, finish, semanticIssues,
|
|
51
|
+
taskBlocks, profileExclusions, matchingEvaluations, compareText, uniqueIssues,
|
|
52
|
+
hasDuplicates, REQUIRED_REQUEST_FIELDS, REQUIRED_REQUIREMENTS
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return function selectModel(input) {
|
|
57
|
+
let data;
|
|
58
|
+
try {
|
|
59
|
+
data = copyJson(input);
|
|
60
|
+
} catch {
|
|
61
|
+
return emptyReport(schemaSha256, "invalid", "non-json-input");
|
|
62
|
+
}
|
|
63
|
+
if (!data || Array.isArray(data) || typeof data !== "object" ||
|
|
64
|
+
Object.keys(data).some((key) => !DOCUMENTS.includes(key))) {
|
|
65
|
+
return emptyReport(schemaSha256, "invalid", "invalid-envelope");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (DOCUMENTS.some((name) => data[name]?.schemaVersion === "2.0.0")) {
|
|
69
|
+
return selectPreference ? selectPreference(data)
|
|
70
|
+
: emptyReport(schemaSha256, "invalid", "preference-schema-not-loaded");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const report = emptyReport(schemaSha256);
|
|
74
|
+
let requestValid = false;
|
|
75
|
+
for (const name of DOCUMENTS) {
|
|
76
|
+
const value = data[name];
|
|
77
|
+
report.audit[`${name}Sha256`] = value === undefined ? null : hashJson(value);
|
|
78
|
+
const valid = validators[name](value);
|
|
79
|
+
if (name === "request") requestValid = valid;
|
|
80
|
+
if (!valid) {
|
|
81
|
+
// Do not echo input values or unknown property names in validation errors.
|
|
82
|
+
report.issues.push({ code: "schema-invalid", document: name });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (requestValid) {
|
|
86
|
+
const { projectId, taskId, revision, role, mode } = data.request;
|
|
87
|
+
report.identity = { projectId, taskId, revision, role, mode };
|
|
88
|
+
}
|
|
89
|
+
if (report.issues.length) return finish(report, "invalid", "invalid-structure");
|
|
90
|
+
|
|
91
|
+
const { request, catalog, policy } = data;
|
|
92
|
+
report.audit.catalog = { id: catalog.catalogId, revision: catalog.revision };
|
|
93
|
+
report.audit.policy = { id: policy.policyId, revision: policy.revision };
|
|
94
|
+
report.constraints = {
|
|
95
|
+
provider: request.provider ?? null,
|
|
96
|
+
client: request.client ?? null,
|
|
97
|
+
mode: request.mode,
|
|
98
|
+
authorizationContext: request.authorizationContext ?? null,
|
|
99
|
+
history: request.history ?? null,
|
|
100
|
+
maxCorrectionRounds: policy.maxCorrectionRounds,
|
|
101
|
+
maxFutureExecutions: policy.maxFutureExecutions,
|
|
102
|
+
maxFutureDurationSeconds: policy.maxFutureDurationSeconds,
|
|
103
|
+
accessType: policy.accessType,
|
|
104
|
+
execution: policy.execution
|
|
105
|
+
};
|
|
106
|
+
const profiles = new Map(catalog.profiles.map((profile) => [profile.profileId, profile]));
|
|
107
|
+
report.issues = semanticIssues(request, catalog, policy, profiles);
|
|
108
|
+
if (report.issues.length) return finish(report, "invalid", "invalid-references-or-data");
|
|
109
|
+
|
|
110
|
+
report.missing = REQUIRED_REQUEST_FIELDS.filter((key) => request[key] === undefined);
|
|
111
|
+
if (request.requirements) {
|
|
112
|
+
report.missing.push(...REQUIRED_REQUIREMENTS
|
|
113
|
+
.filter((key) => request.requirements[key] === undefined)
|
|
114
|
+
.map((key) => `requirements.${key}`));
|
|
115
|
+
}
|
|
116
|
+
if (request.escalation && request.history && !request.history.previousProfileId) {
|
|
117
|
+
report.missing.push("history.previousProfileId");
|
|
118
|
+
}
|
|
119
|
+
report.missing.sort(compareText);
|
|
120
|
+
if (report.missing.length) return finish(report, "needs-info", "missing-task-information");
|
|
121
|
+
|
|
122
|
+
const blocked = taskBlocks(request, policy);
|
|
123
|
+
if (blocked.length) {
|
|
124
|
+
report.reasons.push(...blocked);
|
|
125
|
+
return finish(report, "blocked");
|
|
126
|
+
}
|
|
127
|
+
const route = policy.routes.find((entry) => entry.role === request.role &&
|
|
128
|
+
entry.provider === request.provider && entry.client === request.client);
|
|
129
|
+
if (!route || !route.modes.includes(request.mode) ||
|
|
130
|
+
!route.categories.includes(request.category)) {
|
|
131
|
+
return finish(report, "blocked", "route-not-permitted");
|
|
132
|
+
}
|
|
133
|
+
const priorities = new Map(route.priorities.map((entry) => [entry.profileId, entry]));
|
|
134
|
+
const availability = new Map(request.availability.map((entry) => [entry.profileId, entry]));
|
|
135
|
+
const previous = request.history.previousProfileId;
|
|
136
|
+
if (request.escalation && !priorities.has(previous)) {
|
|
137
|
+
return finish(report, "blocked", "previous-profile-not-in-route");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const candidates = [];
|
|
141
|
+
for (const profile of [...catalog.profiles].sort((a, b) => compareText(a.profileId, b.profileId))) {
|
|
142
|
+
const priority = priorities.get(profile.profileId);
|
|
143
|
+
const record = availability.get(profile.profileId);
|
|
144
|
+
const reasons = profileExclusions(profile, priority, record, request, policy);
|
|
145
|
+
if (request.escalation && priority && priority.rank <= priorities.get(previous).rank) {
|
|
146
|
+
reasons.push("not-higher-approved-priority");
|
|
147
|
+
}
|
|
148
|
+
if (reasons.length) {
|
|
149
|
+
report.excluded.push({ profileId: profile.profileId, reasons });
|
|
150
|
+
} else {
|
|
151
|
+
candidates.push({ profile, priority, record });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
candidates.sort((a, b) => a.priority.rank - b.priority.rank ||
|
|
155
|
+
compareText(a.profile.profileId, b.profile.profileId));
|
|
156
|
+
const chosen = request.explicitProfileId
|
|
157
|
+
? candidates.find((entry) => entry.profile.profileId === request.explicitProfileId)
|
|
158
|
+
: candidates[0];
|
|
159
|
+
if (!chosen) {
|
|
160
|
+
return finish(report, "blocked", request.explicitProfileId
|
|
161
|
+
? "explicit-choice-not-admissible" : "no-admissible-profile");
|
|
162
|
+
}
|
|
163
|
+
const { profile, priority, record } = chosen;
|
|
164
|
+
const evaluation = matchingEvaluations(profile, request);
|
|
165
|
+
report.recommendation = {
|
|
166
|
+
profileId: profile.profileId,
|
|
167
|
+
provider: profile.provider,
|
|
168
|
+
client: profile.client,
|
|
169
|
+
requestedModel: profile.requestedModel,
|
|
170
|
+
versionPolicy: profile.versionPolicy,
|
|
171
|
+
effort: priority.effort ?? null,
|
|
172
|
+
rank: priority.rank,
|
|
173
|
+
evaluationEvidenceRefs: [...new Set(evaluation.flatMap((item) => item.evidenceRefs))].sort(compareText),
|
|
174
|
+
availabilityEvidence: record
|
|
175
|
+
};
|
|
176
|
+
if (request.escalation) report.reasons.push("quality-escalation-with-declared-evidence");
|
|
177
|
+
return finish(report, "recommended", request.explicitProfileId
|
|
178
|
+
? "explicit-compatible-choice" : "lowest-admissible-priority");
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function semanticIssues(request, catalog, policy, profiles) {
|
|
183
|
+
const issues = [];
|
|
184
|
+
const add = (code, document) => issues.push({ code, document });
|
|
185
|
+
if (hasDuplicates(catalog.profiles.map((entry) => entry.profileId))) add("duplicate-profile-id", "catalog");
|
|
186
|
+
if (policy.catalogId !== catalog.catalogId || policy.catalogRevision !== catalog.revision) {
|
|
187
|
+
add("catalog-version-mismatch", "policy");
|
|
188
|
+
}
|
|
189
|
+
const now = Date.parse(request.evaluationTime);
|
|
190
|
+
for (const profile of catalog.profiles) {
|
|
191
|
+
if (Date.parse(profile.reviewedAt) > now) add("profile-reviewed-in-future", "catalog");
|
|
192
|
+
const declared = profile.declaredCapabilities;
|
|
193
|
+
const verified = profile.verifiedCapabilities;
|
|
194
|
+
if (["tools", "inputModalities", "outputFormats"].some((key) =>
|
|
195
|
+
verified[key].some((value) => !declared[key].includes(value))) ||
|
|
196
|
+
(declared.maxContextTokens !== null && verified.maxContextTokens !== null &&
|
|
197
|
+
verified.maxContextTokens > declared.maxContextTokens)) {
|
|
198
|
+
add("inconsistent-verified-capabilities", "catalog");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (hasDuplicates(policy.routes.map((entry) => JSON.stringify([entry.role, entry.provider, entry.client])))) {
|
|
202
|
+
add("duplicate-route", "policy");
|
|
203
|
+
}
|
|
204
|
+
for (const route of policy.routes) {
|
|
205
|
+
if (hasDuplicates(route.priorities.map((entry) => entry.profileId))) add("duplicate-priority", "policy");
|
|
206
|
+
for (const priority of route.priorities) {
|
|
207
|
+
const profile = profiles.get(priority.profileId);
|
|
208
|
+
if (!profile) { add("unknown-priority-profile", "policy"); continue; }
|
|
209
|
+
if (profile.provider !== route.provider || profile.client !== route.client) add("priority-client-mismatch", "policy");
|
|
210
|
+
if (priority.effort !== undefined && !profile.effortOptions.includes(priority.effort)) add("unsupported-effort", "policy");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (request.availability) {
|
|
214
|
+
if (hasDuplicates(request.availability.map((entry) => entry.profileId))) add("duplicate-availability", "request");
|
|
215
|
+
for (const item of request.availability) {
|
|
216
|
+
if (!profiles.has(item.profileId)) add("unknown-availability-profile", "request");
|
|
217
|
+
else if (!sameClient(profiles.get(item.profileId), request)) add("availability-client-mismatch", "request");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
for (const id of [request.explicitProfileId, request.history?.previousProfileId]) {
|
|
221
|
+
if (id === undefined) continue;
|
|
222
|
+
if (!profiles.has(id)) add("unknown-request-profile", "request");
|
|
223
|
+
else if (!sameClient(profiles.get(id), request)) add("request-profile-client-mismatch", "request");
|
|
224
|
+
}
|
|
225
|
+
if (request.risk === "low" && request.requirements?.riskFactors?.length) add("risk-contradiction", "request");
|
|
226
|
+
if (request.history?.previousProfileId && request.history.executionsUsed === 0) add("history-contradiction", "request");
|
|
227
|
+
if (request.mode === "autonomous" && request.history?.correctionRound > 0 && request.history.executionsUsed === 0) {
|
|
228
|
+
add("history-contradiction", "request");
|
|
229
|
+
}
|
|
230
|
+
return uniqueIssues(issues);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function taskBlocks(request, policy) {
|
|
234
|
+
const reasons = [];
|
|
235
|
+
const actions = new Set(request.authorizationContext.allowedActions);
|
|
236
|
+
if ([...ROLE_ACTIONS[request.role], ...CATEGORY_ACTIONS[request.category]]
|
|
237
|
+
.some((action) => !actions.has(action))) reasons.push("insufficient-declared-actions");
|
|
238
|
+
if ((request.role === "executor") !== (request.category === "application")) reasons.push("role-category-conflict");
|
|
239
|
+
if (request.role === "executor" && request.authorizationContext.activeWriter !== "authorized-executor") {
|
|
240
|
+
reasons.push("executor-is-not-active-writer");
|
|
241
|
+
}
|
|
242
|
+
if (request.history.executionsUsed >= policy.maxFutureExecutions) reasons.push("execution-limit-reached");
|
|
243
|
+
if (request.history.durationUsedSeconds >= policy.maxFutureDurationSeconds) reasons.push("duration-limit-reached");
|
|
244
|
+
if (request.mode === "autonomous" && request.history.correctionRound >= policy.maxCorrectionRounds) {
|
|
245
|
+
reasons.push("correction-limit-reached");
|
|
246
|
+
}
|
|
247
|
+
if (request.escalation && request.escalation.reason !== "quality") reasons.push("non-quality-failure");
|
|
248
|
+
return reasons;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function profileExclusions(profile, priority, record, request, policy) {
|
|
252
|
+
const reasons = [];
|
|
253
|
+
if (!priority || !sameClient(profile, request)) reasons.push("profile-not-permitted");
|
|
254
|
+
if (profile.status !== "approved") reasons.push("profile-not-approved");
|
|
255
|
+
if (!matchingEvaluations(profile, request).length) reasons.push("scope-not-evaluated");
|
|
256
|
+
const verified = profile.verifiedCapabilities;
|
|
257
|
+
for (const key of ["tools", "inputModalities", "outputFormats"]) {
|
|
258
|
+
if (request.requirements[key].some((value) => !verified[key].includes(value))) reasons.push(`${key}-not-verified`);
|
|
259
|
+
}
|
|
260
|
+
if (verified.maxContextTokens === null || verified.maxContextTokens < request.requirements.contextTokens) {
|
|
261
|
+
reasons.push("context-not-verified");
|
|
262
|
+
}
|
|
263
|
+
if (!record || record.status !== "available") reasons.push("availability-not-declared");
|
|
264
|
+
else {
|
|
265
|
+
const age = (Date.parse(request.evaluationTime) - Date.parse(record.checkedAt)) / 1000;
|
|
266
|
+
if (age < 0) reasons.push("availability-in-future");
|
|
267
|
+
else if (age > policy.availabilityMaxAgeSeconds) reasons.push("availability-expired");
|
|
268
|
+
}
|
|
269
|
+
return reasons;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function matchingEvaluations(profile, request) {
|
|
273
|
+
return profile.evaluations.filter((entry) => entry.role === request.role &&
|
|
274
|
+
entry.category === request.category && entry.difficulties.includes(request.difficulty) &&
|
|
275
|
+
entry.risks.includes(request.risk));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function sameClient(profile, request) {
|
|
279
|
+
return (request.provider === undefined || profile.provider === request.provider) &&
|
|
280
|
+
(request.client === undefined || profile.client === request.client);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function emptyReport(schemaSha256, state = null, reason = null) {
|
|
284
|
+
const report = {
|
|
285
|
+
schemaVersion: "1.0.0", selectorVersion: SELECTOR_VERSION, state, executed: false,
|
|
286
|
+
identity: null, recommendation: null, constraints: null,
|
|
287
|
+
observedModels: [], modelVerification: "unknown",
|
|
288
|
+
reasons: [], issues: [], missing: [], excluded: [],
|
|
289
|
+
audit: { schemaSha256, requestSha256: null, catalogSha256: null, policySha256: null, catalog: null, policy: null },
|
|
290
|
+
nextAction: null
|
|
291
|
+
};
|
|
292
|
+
return state ? finish(report, state, reason) : report;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function finish(report, state, reason) {
|
|
296
|
+
report.state = state;
|
|
297
|
+
if (reason) report.reasons.push(reason);
|
|
298
|
+
report.nextAction = {
|
|
299
|
+
recommended: "review-recommendation-and-select-manually",
|
|
300
|
+
"needs-info": "complete-listed-information",
|
|
301
|
+
blocked: "resolve-block-without-changing-permissions",
|
|
302
|
+
invalid: "correct-input-documents"
|
|
303
|
+
}[state];
|
|
304
|
+
return report;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function uniqueIssues(issues) {
|
|
308
|
+
return [...new Map(issues.map((issue) => [`${issue.document}:${issue.code}`, issue])).values()]
|
|
309
|
+
.sort((a, b) => compareText(`${a.document}:${a.code}`, `${b.document}:${b.code}`));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function hasDuplicates(values) { return new Set(values).size !== values.length; }
|
|
313
|
+
function compareText(left, right) { return left < right ? -1 : left > right ? 1 : 0; }
|
|
314
|
+
|
|
315
|
+
function isUtcTimestamp(value) {
|
|
316
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(value)) return false;
|
|
317
|
+
const time = Date.parse(value);
|
|
318
|
+
return Number.isFinite(time) && new Date(time).toISOString() === value.replace(/Z$/, ".000Z");
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function hashJson(value) {
|
|
322
|
+
return createHash("sha256").update(canonicalJson(value)).digest("hex");
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function canonicalJson(value) {
|
|
326
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
327
|
+
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
328
|
+
return `{${Object.keys(value).sort(compareText)
|
|
329
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Accept only bounded JSON data; never invoke getters or toJSON on task inputs.
|
|
333
|
+
function copyJson(value) {
|
|
334
|
+
const ancestors = new Set();
|
|
335
|
+
let nodes = 0;
|
|
336
|
+
let textUnits = 0;
|
|
337
|
+
function visit(item, depth) {
|
|
338
|
+
if (++nodes > 30000 || depth > 64) throw new Error("JSON limit");
|
|
339
|
+
if (typeof item === "string") {
|
|
340
|
+
textUnits += item.length;
|
|
341
|
+
if (textUnits > 2000000) throw new Error("JSON limit");
|
|
342
|
+
return item;
|
|
343
|
+
}
|
|
344
|
+
if (item === null || typeof item === "boolean") return item;
|
|
345
|
+
if (typeof item === "number" && Number.isFinite(item)) return item;
|
|
346
|
+
if (typeof item !== "object" || ancestors.has(item)) throw new Error("Non-JSON data");
|
|
347
|
+
const array = Array.isArray(item);
|
|
348
|
+
if (array && item.length > 256) throw new Error("JSON limit");
|
|
349
|
+
if (!array && ![Object.prototype, null].includes(Object.getPrototypeOf(item))) throw new Error("Non-JSON object");
|
|
350
|
+
if (Object.getOwnPropertySymbols(item).length) throw new Error("Non-JSON keys");
|
|
351
|
+
const keys = Object.getOwnPropertyNames(item).filter((key) => !array || key !== "length");
|
|
352
|
+
if (array && (keys.length !== item.length || keys.some((key, index) => key !== String(index)))) throw new Error("Non-JSON array");
|
|
353
|
+
if (keys.length > 30000) throw new Error("JSON limit");
|
|
354
|
+
ancestors.add(item);
|
|
355
|
+
const result = array ? [] : {};
|
|
356
|
+
for (const key of keys) {
|
|
357
|
+
if (["__proto__", "prototype", "constructor"].includes(key)) throw new Error("Unsafe JSON key");
|
|
358
|
+
const descriptor = Object.getOwnPropertyDescriptor(item, key);
|
|
359
|
+
if (!descriptor.enumerable || !("value" in descriptor)) throw new Error("Non-JSON property");
|
|
360
|
+
textUnits += key.length;
|
|
361
|
+
if (textUnits > 2000000) throw new Error("JSON limit");
|
|
362
|
+
result[key] = visit(descriptor.value, depth + 1);
|
|
363
|
+
}
|
|
364
|
+
ancestors.delete(item);
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
return visit(value, 0);
|
|
368
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include "managed-preferences.h"
|
|
3
|
+
|
|
4
|
+
#ifndef N1_SYNTHETIC_BACKEND
|
|
5
|
+
#ifdef __APPLE__
|
|
6
|
+
#include <CoreFoundation/CoreFoundation.h>
|
|
7
|
+
|
|
8
|
+
int n1_copy(const char *key, const char *application, void **value) {
|
|
9
|
+
CFStringRef k = CFStringCreateWithCString(NULL, key, kCFStringEncodingUTF8);
|
|
10
|
+
CFStringRef app = CFStringCreateWithCString(NULL, application, kCFStringEncodingUTF8);
|
|
11
|
+
if (k == NULL || app == NULL) {
|
|
12
|
+
if (k != NULL) CFRelease(k);
|
|
13
|
+
if (app != NULL) CFRelease(app);
|
|
14
|
+
*value = NULL;
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
*value = (void *)CFPreferencesCopyAppValue(k, app);
|
|
18
|
+
CFRelease(k);
|
|
19
|
+
CFRelease(app);
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
enum n1_kind n1_type(const void *value) {
|
|
24
|
+
CFTypeID type = CFGetTypeID((CFTypeRef)value);
|
|
25
|
+
if (type == CFBooleanGetTypeID()) return N1_BOOLEAN;
|
|
26
|
+
if (type == CFNumberGetTypeID()) return N1_NUMBER;
|
|
27
|
+
if (type == CFStringGetTypeID()) return N1_STRING;
|
|
28
|
+
if (type == CFArrayGetTypeID()) return N1_ARRAY;
|
|
29
|
+
if (type == CFDictionaryGetTypeID()) return N1_DICTIONARY;
|
|
30
|
+
return N1_OTHER;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void n1_release(void *value) { CFRelease((CFTypeRef)value); }
|
|
34
|
+
|
|
35
|
+
int n1_forced(const char *key, const char *application, int *forced) {
|
|
36
|
+
CFStringRef k = CFStringCreateWithCString(NULL, key, kCFStringEncodingUTF8);
|
|
37
|
+
CFStringRef app = CFStringCreateWithCString(NULL, application, kCFStringEncodingUTF8);
|
|
38
|
+
if (k == NULL || app == NULL) {
|
|
39
|
+
if (k != NULL) CFRelease(k);
|
|
40
|
+
if (app != NULL) CFRelease(app);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
*forced = CFPreferencesAppValueIsForced(k, app) ? 1 : 0;
|
|
44
|
+
CFRelease(k);
|
|
45
|
+
CFRelease(app);
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
int n1_complete(void) { return 1; }
|
|
50
|
+
#else
|
|
51
|
+
#error "Core Foundation backend requires macOS"
|
|
52
|
+
#endif
|
|
53
|
+
#define N1_SOURCE "core-foundation-claim"
|
|
54
|
+
#else
|
|
55
|
+
#define N1_SOURCE "synthetic"
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
static const char *const keys[N1_FIELD_COUNT] = {
|
|
59
|
+
"hooks", "policyHelper", "apiKeyHelper", "env", "managedMcpServers", "disableAllHooks"
|
|
60
|
+
};
|
|
61
|
+
static const char *const types[] = {
|
|
62
|
+
"not-found-by-api", "boolean", "number", "string", "array", "dictionary", "other"
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
static int failure(const char *code) {
|
|
66
|
+
/* Callers only pass internal literal codes. No values/paths/errors are printed. */
|
|
67
|
+
int written = printf("{\"schemaVersion\":\"1.0.0\",\"source\":\"%s\",\"status\":\"failed\",\"code\":\"%s\"}\n", N1_SOURCE, code);
|
|
68
|
+
if (written < 0 || fflush(stdout) != 0) return 2;
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
int main(int argc, char **argv) {
|
|
73
|
+
enum n1_kind kind[N1_FIELD_COUNT];
|
|
74
|
+
int forced[N1_FIELD_COUNT];
|
|
75
|
+
(void)argv;
|
|
76
|
+
if (argc != 1) return failure("preferences-arguments-rejected");
|
|
77
|
+
for (int i = 0; i < N1_FIELD_COUNT; i++) {
|
|
78
|
+
void *value = NULL;
|
|
79
|
+
if (!n1_copy(keys[i], N1_APPLICATION, &value)) {
|
|
80
|
+
if (value != NULL) n1_release(value);
|
|
81
|
+
return failure("preferences-backend-failed");
|
|
82
|
+
}
|
|
83
|
+
int found = value != NULL;
|
|
84
|
+
kind[i] = found ? n1_type(value) : N1_NOT_FOUND;
|
|
85
|
+
if (value != NULL) n1_release(value);
|
|
86
|
+
if (kind[i] < N1_NOT_FOUND || kind[i] > N1_OTHER || (found && kind[i] == N1_NOT_FOUND))
|
|
87
|
+
return failure("preferences-type-rejected");
|
|
88
|
+
/* Release the value before asking forced status or advancing to another key. */
|
|
89
|
+
if (!n1_forced(keys[i], N1_APPLICATION, &forced[i]) || forced[i] < 0 || forced[i] > 1)
|
|
90
|
+
return failure("preferences-backend-failed");
|
|
91
|
+
}
|
|
92
|
+
if (!n1_complete()) return failure("preferences-backend-failed");
|
|
93
|
+
if (printf("{\"schemaVersion\":\"1.0.0\",\"source\":\"%s\",\"application\":\"%s\",\"status\":\"complete\",\"fields\":[", N1_SOURCE, N1_APPLICATION) < 0) return 2;
|
|
94
|
+
for (int i = 0; i < N1_FIELD_COUNT; i++) {
|
|
95
|
+
if (printf("%s{\"name\":\"%s\",\"type\":\"%s\",\"forced\":\"%s\"}", i == 0 ? "" : ",",
|
|
96
|
+
keys[i], types[kind[i]], forced[i] ? "forced" : "not-forced") < 0) return 2;
|
|
97
|
+
}
|
|
98
|
+
if (printf("]}\n") < 0 || fflush(stdout) != 0) return 2;
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef AGENT_MANAGED_PREFERENCES_H
|
|
2
|
+
#define AGENT_MANAGED_PREFERENCES_H
|
|
3
|
+
|
|
4
|
+
/* This interface is linked at build time, never selected by argv or settings. */
|
|
5
|
+
#define N1_APPLICATION "com.anthropic.claudecode"
|
|
6
|
+
#define N1_FIELD_COUNT 6
|
|
7
|
+
enum n1_kind {
|
|
8
|
+
N1_NOT_FOUND = 0, N1_BOOLEAN, N1_NUMBER, N1_STRING,
|
|
9
|
+
N1_ARRAY, N1_DICTIONARY, N1_OTHER
|
|
10
|
+
};
|
|
11
|
+
int n1_copy(const char *key, const char *application, void **value);
|
|
12
|
+
enum n1_kind n1_type(const void *value);
|
|
13
|
+
void n1_release(void *value);
|
|
14
|
+
int n1_forced(const char *key, const char *application, int *forced);
|
|
15
|
+
int n1_complete(void);
|
|
16
|
+
|
|
17
|
+
#endif
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
// npm excludes the root lock from tarballs. prepack generates this fallback;
|
|
5
|
+
// retain the root lock in development and never mask permission or IO errors.
|
|
6
|
+
export async function resolvePackageLock(toolkitRoot, io = fs) {
|
|
7
|
+
const rootLock = path.join(toolkitRoot, 'package-lock.json');
|
|
8
|
+
try { await io.lstat(rootLock); return rootLock; }
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error.code !== 'ENOENT') throw error;
|
|
11
|
+
return path.join(toolkitRoot, 'assets', 'runtime', 'package-lock.json');
|
|
12
|
+
}
|
|
13
|
+
}
|