@aiwg/cli 0.0.0-bootstrap.0 → 2026.7.18
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/LICENSE +21 -0
- package/README.md +22 -1
- package/bin/aiwg.mjs +349 -0
- package/dist/src/a2a/agent-card.js +145 -0
- package/dist/src/a2a/client.js +411 -0
- package/dist/src/a2a/hitl-cli.js +171 -0
- package/dist/src/a2a/hitl-driver.js +370 -0
- package/dist/src/a2a/hitl.js +181 -0
- package/dist/src/a2a/http.js +193 -0
- package/dist/src/a2a/jcs.js +128 -0
- package/dist/src/a2a/jws.js +187 -0
- package/dist/src/a2a/types.js +24 -0
- package/dist/src/a2a/webhook.js +240 -0
- package/dist/src/activity-log/cli.js +348 -0
- package/dist/src/activity-log/parser.js +81 -0
- package/dist/src/activity-log/types.js +50 -0
- package/dist/src/agents/agent-deployer.js +367 -0
- package/dist/src/agents/agent-packager.js +271 -0
- package/dist/src/agents/agent-validator.js +271 -0
- package/dist/src/agents/grounding/knowledge-base.js +161 -0
- package/dist/src/agents/grounding/types.js +12 -0
- package/dist/src/agents/index.js +10 -0
- package/dist/src/agents/packaged-agent-inventory.js +75 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/api/index.d.ts +10 -0
- package/dist/src/api/index.js +10 -0
- package/dist/src/artifacts/address-parser.js +73 -0
- package/dist/src/artifacts/audit/cli.js +183 -0
- package/dist/src/artifacts/audit/drift.js +122 -0
- package/dist/src/artifacts/audit/types.js +12 -0
- package/dist/src/artifacts/backends/graphology-backend.js +160 -0
- package/dist/src/artifacts/backends/json-backend.js +129 -0
- package/dist/src/artifacts/backends/sqlite-backend.js +199 -0
- package/dist/src/artifacts/browser-export.js +622 -0
- package/dist/src/artifacts/capability-resolver.js +94 -0
- package/dist/src/artifacts/checksum-manifest.js +91 -0
- package/dist/src/artifacts/citation-parser.js +162 -0
- package/dist/src/artifacts/cli.js +1486 -0
- package/dist/src/artifacts/corpus-tools/citation-densify.js +311 -0
- package/dist/src/artifacts/corpus-tools/cli.js +393 -0
- package/dist/src/artifacts/corpus-tools/corpus-graph.js +225 -0
- package/dist/src/artifacts/corpus-tools/curator.js +186 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +70 -0
- package/dist/src/artifacts/corpus-tools/funder-network.js +141 -0
- package/dist/src/artifacts/corpus-tools/induction-audit.js +233 -0
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +202 -0
- package/dist/src/artifacts/corpus-tools/profile-communities.js +166 -0
- package/dist/src/artifacts/corpus-tools/profile-edges.js +72 -0
- package/dist/src/artifacts/corpus-tools/profile-embed.js +113 -0
- package/dist/src/artifacts/corpus-tools/profile-generate-fm.js +167 -0
- package/dist/src/artifacts/corpus-tools/profile-generate.js +181 -0
- package/dist/src/artifacts/corpus-tools/profile-metrics.js +98 -0
- package/dist/src/artifacts/corpus-tools/profile-status.js +86 -0
- package/dist/src/artifacts/corpus-tools/profile-temporal.js +139 -0
- package/dist/src/artifacts/corpus-tools/radar-init.js +93 -0
- package/dist/src/artifacts/corpus-tools/radar-report.js +118 -0
- package/dist/src/artifacts/corpus-tools/radar-shared.js +189 -0
- package/dist/src/artifacts/corpus-tools/radar-status.js +68 -0
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +233 -0
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +277 -0
- package/dist/src/artifacts/corpus-tools/snapshot.js +591 -0
- package/dist/src/artifacts/corpus-tools/source-types.js +164 -0
- package/dist/src/artifacts/corpus-tools/vision-extract.js +243 -0
- package/dist/src/artifacts/corpus-views/build.js +126 -0
- package/dist/src/artifacts/corpus-views/corpus-config.js +124 -0
- package/dist/src/artifacts/corpus-views/ref-parser.js +437 -0
- package/dist/src/artifacts/corpus-views/renderers.js +353 -0
- package/dist/src/artifacts/corpus-views/taxonomies.js +131 -0
- package/dist/src/artifacts/dep-graph.js +173 -0
- package/dist/src/artifacts/discover-facets.js +375 -0
- package/dist/src/artifacts/embedding-index.js +354 -0
- package/dist/src/artifacts/enrichment/cli.js +240 -0
- package/dist/src/artifacts/enrichment/prompt.js +47 -0
- package/dist/src/artifacts/enrichment/store.js +90 -0
- package/dist/src/artifacts/enrichment/types.js +12 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +475 -0
- package/dist/src/artifacts/fortemi-core-sync.js +251 -0
- package/dist/src/artifacts/fortemi-shard-export.js +44 -0
- package/dist/src/artifacts/fulltext.js +108 -0
- package/dist/src/artifacts/graph-backend.js +51 -0
- package/dist/src/artifacts/graph-query.js +247 -0
- package/dist/src/artifacts/hybrid-query.js +225 -0
- package/dist/src/artifacts/index-builder.js +1089 -0
- package/dist/src/artifacts/index-reader.js +112 -0
- package/dist/src/artifacts/index-status.js +193 -0
- package/dist/src/artifacts/legacy-index-migration.js +169 -0
- package/dist/src/artifacts/move.js +154 -0
- package/dist/src/artifacts/operational-state.js +239 -0
- package/dist/src/artifacts/prebuilt-build-lock.js +49 -0
- package/dist/src/artifacts/query-engine.js +1955 -0
- package/dist/src/artifacts/source-graph.js +529 -0
- package/dist/src/artifacts/stats.js +169 -0
- package/dist/src/artifacts/types.js +606 -0
- package/dist/src/artifacts/views/cli.js +293 -0
- package/dist/src/artifacts/views/definition.js +170 -0
- package/dist/src/artifacts/views/store.js +149 -0
- package/dist/src/artifacts/views/types.js +8 -0
- package/dist/src/artifacts/watcher.js +255 -0
- package/dist/src/catalog/builtin-models.json +636 -0
- package/dist/src/catalog/cli.js +228 -0
- package/dist/src/catalog/cli.mjs +289 -0
- package/dist/src/catalog/index.js +15 -0
- package/dist/src/catalog/loader.js +217 -0
- package/dist/src/catalog/loader.mjs +251 -0
- package/dist/src/catalog/sources.json +41 -0
- package/dist/src/catalog/types.js +8 -0
- package/dist/src/channel/manager.mjs +504 -0
- package/dist/src/cli/agent-spawn.js +178 -0
- package/dist/src/cli/cli-extension-loader.js +245 -0
- package/dist/src/cli/command-log.js +275 -0
- package/dist/src/cli/config-loader.js +232 -0
- package/dist/src/cli/env.js +82 -0
- package/dist/src/cli/errors.js +150 -0
- package/dist/src/cli/find-package-root.js +40 -0
- package/dist/src/cli/git-hooks.js +250 -0
- package/dist/src/cli/handlers/agentcard.js +206 -0
- package/dist/src/cli/handlers/artifacts.js +76 -0
- package/dist/src/cli/handlers/best-practices-audit.js +280 -0
- package/dist/src/cli/handlers/cockpit.js +137 -0
- package/dist/src/cli/handlers/command-log.js +37 -0
- package/dist/src/cli/handlers/daemon.js +59 -0
- package/dist/src/cli/handlers/diagnose.js +300 -0
- package/dist/src/cli/handlers/execution-mode.js +105 -0
- package/dist/src/cli/handlers/feedback.js +341 -0
- package/dist/src/cli/handlers/help.js +147 -0
- package/dist/src/cli/handlers/index.js +302 -0
- package/dist/src/cli/handlers/init.js +179 -0
- package/dist/src/cli/handlers/install.js +129 -0
- package/dist/src/cli/handlers/issues.js +46 -0
- package/dist/src/cli/handlers/lint.js +42 -0
- package/dist/src/cli/handlers/local-executor.js +315 -0
- package/dist/src/cli/handlers/marketplace.js +168 -0
- package/dist/src/cli/handlers/mc.js +1010 -0
- package/dist/src/cli/handlers/models.js +352 -0
- package/dist/src/cli/handlers/packages.js +155 -0
- package/dist/src/cli/handlers/ralph-launcher.js +717 -0
- package/dist/src/cli/handlers/ralph.js +575 -0
- package/dist/src/cli/handlers/refresh.js +432 -0
- package/dist/src/cli/handlers/regenerate.js +336 -0
- package/dist/src/cli/handlers/repo-access.js +109 -0
- package/dist/src/cli/handlers/run.js +165 -0
- package/dist/src/cli/handlers/runtime-info.js +301 -0
- package/dist/src/cli/handlers/sandbox.js +197 -0
- package/dist/src/cli/handlers/scaffolding.js +149 -0
- package/dist/src/cli/handlers/script-runner.js +121 -0
- package/dist/src/cli/handlers/sdlc-accelerate.js +148 -0
- package/dist/src/cli/handlers/serve.js +1835 -0
- package/dist/src/cli/handlers/session.js +348 -0
- package/dist/src/cli/handlers/setup.js +440 -0
- package/dist/src/cli/handlers/skill-lint.js +367 -0
- package/dist/src/cli/handlers/skill-usage.js +74 -0
- package/dist/src/cli/handlers/steward.js +567 -0
- package/dist/src/cli/handlers/subcommands.js +1702 -0
- package/dist/src/cli/handlers/team.js +337 -0
- package/dist/src/cli/handlers/types.js +11 -0
- package/dist/src/cli/handlers/use.js +2772 -0
- package/dist/src/cli/handlers/utilities.js +703 -0
- package/dist/src/cli/handlers/version.js +134 -0
- package/dist/src/cli/handlers/workspace-context.js +93 -0
- package/dist/src/cli/handlers/workspace.js +126 -0
- package/dist/src/cli/help-generator.js +178 -0
- package/dist/src/cli/hooks/builtin/activity-log-hook.js +126 -0
- package/dist/src/cli/hooks/executor.js +96 -0
- package/dist/src/cli/hooks/index.js +15 -0
- package/dist/src/cli/hooks/registry.js +143 -0
- package/dist/src/cli/hooks/types.js +13 -0
- package/dist/src/cli/log.js +492 -0
- package/dist/src/cli/project-isolation/detect.js +70 -0
- package/dist/src/cli/project-isolation/index.js +7 -0
- package/dist/src/cli/project-isolation/signals.js +17 -0
- package/dist/src/cli/project-isolation/warning.js +102 -0
- package/dist/src/cli/prompt-utils.js +155 -0
- package/dist/src/cli/provider-deployment-plan.js +126 -0
- package/dist/src/cli/provider-resolution.js +119 -0
- package/dist/src/cli/router.js +305 -0
- package/dist/src/cli/scope-resolver.js +392 -0
- package/dist/src/cli/skill-usage.js +616 -0
- package/dist/src/cli/ui.js +224 -0
- package/dist/src/cli/watch-service.js +203 -0
- package/dist/src/cli/workflow-orchestrator.js +478 -0
- package/dist/src/cli/workspace-signals.js +321 -0
- package/dist/src/community/footer.js +14 -0
- package/dist/src/community/links.js +123 -0
- package/dist/src/community/milestones.js +46 -0
- package/dist/src/community/nudge-policy.js +93 -0
- package/dist/src/config/aiwg-config.js +883 -0
- package/dist/src/config/cli.js +703 -0
- package/dist/src/config/gitignore.js +156 -0
- package/dist/src/config/project-artifacts.js +76 -0
- package/dist/src/config/user-config.js +428 -0
- package/dist/src/config/user-registry.js +127 -0
- package/dist/src/config/workspace.js +276 -0
- package/dist/src/contributors/detect.js +39 -0
- package/dist/src/contributors/discover.js +172 -0
- package/dist/src/contributors/heuristic.js +186 -0
- package/dist/src/contributors/index.js +11 -0
- package/dist/src/contributors/types.js +13 -0
- package/dist/src/contributors/validation.js +116 -0
- package/dist/src/data/community.schema.json +43 -0
- package/dist/src/data/community.yaml +16 -0
- package/dist/src/extensions/capability-index.js +270 -0
- package/dist/src/extensions/claude-hooks-installer.js +268 -0
- package/dist/src/extensions/commands/definitions.js +3485 -0
- package/dist/src/extensions/deployment-registration.js +463 -0
- package/dist/src/extensions/index.js +22 -0
- package/dist/src/extensions/loader.js +132 -0
- package/dist/src/extensions/managed-marker.js +100 -0
- package/dist/src/extensions/manifest.js +196 -0
- package/dist/src/extensions/project-local-activity.js +114 -0
- package/dist/src/extensions/project-local-discovery.js +261 -0
- package/dist/src/extensions/project-local-doctor.js +281 -0
- package/dist/src/extensions/project-local-gitignore.js +176 -0
- package/dist/src/extensions/project-local-paths.js +121 -0
- package/dist/src/extensions/project-local-promote.js +218 -0
- package/dist/src/extensions/project-local-remove.js +373 -0
- package/dist/src/extensions/project-local-scaffold.js +252 -0
- package/dist/src/extensions/project-quickref.js +291 -0
- package/dist/src/extensions/registry.js +368 -0
- package/dist/src/extensions/shadow-resolver.js +271 -0
- package/dist/src/extensions/types.js +86 -0
- package/dist/src/extensions/upstream-registry.js +195 -0
- package/dist/src/extensions/validation.js +631 -0
- package/dist/src/features/catalog.js +88 -0
- package/dist/src/features/cli.js +197 -0
- package/dist/src/features/installer.js +57 -0
- package/dist/src/features/paths.js +14 -0
- package/dist/src/features/runtime.js +21 -0
- package/dist/src/features/status.js +134 -0
- package/dist/src/hooks/laziness-detection.js +532 -0
- package/dist/src/intake/git-history-analyzer.js +486 -0
- package/dist/src/intake/index.js +9 -0
- package/dist/src/issues/cli.js +327 -0
- package/dist/src/issues/index.js +5 -0
- package/dist/src/issues/live.js +154 -0
- package/dist/src/issues/local.js +666 -0
- package/dist/src/issues/sync.js +143 -0
- package/dist/src/issues/types.js +2 -0
- package/dist/src/issues/workflows.js +164 -0
- package/dist/src/kb/cli.js +173 -0
- package/dist/src/lint/cli.js +171 -0
- package/dist/src/lint/loader.js +225 -0
- package/dist/src/lint/reporters.js +141 -0
- package/dist/src/lint/runner.js +364 -0
- package/dist/src/lint/types.js +10 -0
- package/dist/src/marketplace/cache.js +110 -0
- package/dist/src/marketplace/identifier.js +63 -0
- package/dist/src/marketplace/registry.js +36 -0
- package/dist/src/marketplace/sources/clawhub.js +53 -0
- package/dist/src/marketplace/sources/git.js +45 -0
- package/dist/src/marketplace/types.js +9 -0
- package/dist/src/mcp/adapters/codex-runtime.js +224 -0
- package/dist/src/mcp/cli.mjs +1197 -0
- package/dist/src/mcp/elicitation.mjs +149 -0
- package/dist/src/mcp/helpers.mjs +287 -0
- package/dist/src/mcp/index.mjs +11 -0
- package/dist/src/mcp/profiles.js +263 -0
- package/dist/src/mcp/profiles.mjs +360 -0
- package/dist/src/mcp/registry.js +376 -0
- package/dist/src/mcp/registry.mjs +387 -0
- package/dist/src/mcp/server.mjs +633 -0
- package/dist/src/mcp/test-simple.mjs +271 -0
- package/dist/src/mcp/tools/command-run.mjs +101 -0
- package/dist/src/mcp/tools/discovery.mjs +291 -0
- package/dist/src/mcp/tools/interaction.mjs +87 -0
- package/dist/src/mcp/tools/orchestration.mjs +320 -0
- package/dist/src/mcp/tools/subsystems.mjs +640 -0
- package/dist/src/memory/cli.js +166 -0
- package/dist/src/memory/project-registry.js +282 -0
- package/dist/src/metrics/artifact-metrics.js +184 -0
- package/dist/src/metrics/context-budget.js +174 -0
- package/dist/src/metrics/token-counter.js +133 -0
- package/dist/src/models/config-loader.js +228 -0
- package/dist/src/models/index.js +22 -0
- package/dist/src/models/model-capabilities.v1.json +120 -0
- package/dist/src/models/model-catalog.v1.json +96 -0
- package/dist/src/models/model-discovery.js +521 -0
- package/dist/src/models/provider-models.js +73 -0
- package/dist/src/models/provider-policy.js +273 -0
- package/dist/src/models/resolver.js +245 -0
- package/dist/src/models/router.js +70 -0
- package/dist/src/models/types.js +8 -0
- package/dist/src/models/wrapper-deployment.js +178 -0
- package/dist/src/models/wrapper-route.js +54 -0
- package/dist/src/ops/cli.js +268 -0
- package/dist/src/ops/registry.js +623 -0
- package/dist/src/packages/adapters/clawhub.js +113 -0
- package/dist/src/packages/adapters/git.js +153 -0
- package/dist/src/packages/adapters/gitea.js +93 -0
- package/dist/src/packages/adapters/github.js +69 -0
- package/dist/src/packages/adapters/local-cache.js +89 -0
- package/dist/src/packages/package-registry.js +143 -0
- package/dist/src/packages/registry.js +238 -0
- package/dist/src/packages/types.js +11 -0
- package/dist/src/plugin/cross-framework-ops.js +475 -0
- package/dist/src/plugin/framework-config-loader.js +235 -0
- package/dist/src/plugin/framework-detector.js +186 -0
- package/dist/src/plugin/framework-isolator.js +341 -0
- package/dist/src/plugin/framework-migration.js +371 -0
- package/dist/src/plugin/metadata-validator.js +906 -0
- package/dist/src/plugin/plugin-installer.js +436 -0
- package/dist/src/plugin/plugin-status.js +369 -0
- package/dist/src/plugin/plugin-uninstaller.js +473 -0
- package/dist/src/plugin/registry-validator.js +344 -0
- package/dist/src/plugin/skill-command-translator.js +415 -0
- package/dist/src/plugin/workspace-creator.js +189 -0
- package/dist/src/plugin/workspace-migrator.js +821 -0
- package/dist/src/policy/authorization.js +390 -0
- package/dist/src/policy/repo-access.js +215 -0
- package/dist/src/provenance/cli.js +16 -0
- package/dist/src/providers/capability-matrix.js +300 -0
- package/dist/src/providers/capability-matrix.yaml +514 -0
- package/dist/src/providers/provider-definitions.js +977 -0
- package/dist/src/providers/provider-definitions.mjs +159 -0
- package/dist/src/providers/provider-inventory.js +169 -0
- package/dist/src/quality/feedback-ab.js +174 -0
- package/dist/src/quality/feedback-collector.js +176 -0
- package/dist/src/quality/feedback-tracker.js +123 -0
- package/dist/src/quality/patterns/adr.json +24 -0
- package/dist/src/quality/patterns/sad.json +24 -0
- package/dist/src/quality/patterns/test-plan.json +24 -0
- package/dist/src/quality/patterns/use-case.json +24 -0
- package/dist/src/quality/scoring.js +157 -0
- package/dist/src/reflections/cli.js +15 -0
- package/dist/src/release/plan.js +139 -0
- package/dist/src/research/cache/manager.js +227 -0
- package/dist/src/research/clients/arxiv.js +156 -0
- package/dist/src/research/clients/base.js +197 -0
- package/dist/src/research/clients/crossref.js +112 -0
- package/dist/src/research/clients/semantic-scholar.js +126 -0
- package/dist/src/research/clients/unpaywall.js +87 -0
- package/dist/src/research/index.js +14 -0
- package/dist/src/research/query-cli.js +336 -0
- package/dist/src/research/services/acquisition.js +313 -0
- package/dist/src/research/services/archival.js +225 -0
- package/dist/src/research/services/citation.js +279 -0
- package/dist/src/research/services/discovery.js +243 -0
- package/dist/src/research/services/documentation.js +269 -0
- package/dist/src/research/services/index.js +14 -0
- package/dist/src/research/services/provenance.js +279 -0
- package/dist/src/research/services/quality.js +370 -0
- package/dist/src/research/services/types.js +7 -0
- package/dist/src/research/storage-cli.js +20 -0
- package/dist/src/research/types.js +47 -0
- package/dist/src/resources/index.d.ts +2 -0
- package/dist/src/resources/index.js +2 -0
- package/dist/src/resources/web-release.d.ts +89 -0
- package/dist/src/resources/web-release.js +886 -0
- package/dist/src/rlm/cache/cli.js +162 -0
- package/dist/src/rlm/cache/hash.js +35 -0
- package/dist/src/rlm/cache/store.js +170 -0
- package/dist/src/rlm/cache/types.js +8 -0
- package/dist/src/rlm/cli.js +650 -0
- package/dist/src/serve/a2a-terminal-observer.js +120 -0
- package/dist/src/serve/agent-router.js +205 -0
- package/dist/src/serve/dispatch-router.js +171 -0
- package/dist/src/serve/executor-registry.js +715 -0
- package/dist/src/serve/mission-conductor.js +177 -0
- package/dist/src/serve/orchestrator-adapter.js +113 -0
- package/dist/src/serve/orchestrator-override.js +94 -0
- package/dist/src/serve/orchestrator-pty.js +133 -0
- package/dist/src/serve/pty-bridge.js +799 -0
- package/dist/src/serve/sandbox-registry.js +832 -0
- package/dist/src/serve/screen-reader.js +228 -0
- package/dist/src/serve/stack-adapters.js +68 -0
- package/dist/src/serve/telemetry.js +143 -0
- package/dist/src/skills/adapters/clawhub.js +250 -0
- package/dist/src/skills/adapters/local.js +335 -0
- package/dist/src/skills/adapters/openclaw.js +316 -0
- package/dist/src/skills/cli.js +334 -0
- package/dist/src/skills/registry.js +117 -0
- package/dist/src/skills/run.js +259 -0
- package/dist/src/skills/runtime.js +94 -0
- package/dist/src/skills/types.js +10 -0
- package/dist/src/smiths/agentsmith/demo.js +116 -0
- package/dist/src/smiths/agentsmith/examples.js +300 -0
- package/dist/src/smiths/agentsmith/generator.js +503 -0
- package/dist/src/smiths/agentsmith/index.js +11 -0
- package/dist/src/smiths/agentsmith/types.js +8 -0
- package/dist/src/smiths/commandsmith/example.js +220 -0
- package/dist/src/smiths/commandsmith/generator.js +288 -0
- package/dist/src/smiths/commandsmith/index.js +41 -0
- package/dist/src/smiths/commandsmith/templates.js +296 -0
- package/dist/src/smiths/commandsmith/types.js +7 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +104 -0
- package/dist/src/smiths/context-pipeline/allowlist.js +195 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +127 -0
- package/dist/src/smiths/context-pipeline/discovery.js +187 -0
- package/dist/src/smiths/context-pipeline/external-links-section.js +49 -0
- package/dist/src/smiths/context-pipeline/finalization.js +147 -0
- package/dist/src/smiths/context-pipeline/generator.js +477 -0
- package/dist/src/smiths/context-pipeline/index.js +30 -0
- package/dist/src/smiths/context-pipeline/legacy-inject.js +103 -0
- package/dist/src/smiths/context-pipeline/managed-hook.js +95 -0
- package/dist/src/smiths/context-pipeline/overflow.js +212 -0
- package/dist/src/smiths/context-pipeline/parallelism-section.js +94 -0
- package/dist/src/smiths/context-pipeline/provider-policy.js +64 -0
- package/dist/src/smiths/context-pipeline/sanitizer.js +93 -0
- package/dist/src/smiths/context-pipeline/types.js +23 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +988 -0
- package/dist/src/smiths/hook-bridge/codex-translator.js +129 -0
- package/dist/src/smiths/hook-bridge/copilot-translator.js +64 -0
- package/dist/src/smiths/hook-bridge/factory-translator.js +43 -0
- package/dist/src/smiths/hook-bridge/hermes-translator.js +88 -0
- package/dist/src/smiths/hook-bridge/index.js +79 -0
- package/dist/src/smiths/hook-bridge/loader.js +116 -0
- package/dist/src/smiths/hook-bridge/shim.js +89 -0
- package/dist/src/smiths/hook-bridge/types.js +31 -0
- package/dist/src/smiths/index.js +39 -0
- package/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +390 -0
- package/dist/src/smiths/mcpsmith/example.js +119 -0
- package/dist/src/smiths/mcpsmith/generator.js +236 -0
- package/dist/src/smiths/mcpsmith/index.js +17 -0
- package/dist/src/smiths/mcpsmith/types.js +10 -0
- package/dist/src/smiths/platform-paths.js +101 -0
- package/dist/src/smiths/skillsmith/codex-sidecar.js +85 -0
- package/dist/src/smiths/skillsmith/collision-detector.js +249 -0
- package/dist/src/smiths/skillsmith/demo.js +83 -0
- package/dist/src/smiths/skillsmith/examples.js +161 -0
- package/dist/src/smiths/skillsmith/generator.js +316 -0
- package/dist/src/smiths/skillsmith/index.js +12 -0
- package/dist/src/smiths/skillsmith/namespace-adapter.js +180 -0
- package/dist/src/smiths/skillsmith/platform-resolver.js +157 -0
- package/dist/src/smiths/skillsmith/types.js +9 -0
- package/dist/src/smiths/toolsmith/index.js +10 -0
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +710 -0
- package/dist/src/smiths/toolsmith/types.js +8 -0
- package/dist/src/storage/backends/fortemi.js +227 -0
- package/dist/src/storage/backends/fs.js +134 -0
- package/dist/src/storage/backends/logseq.js +309 -0
- package/dist/src/storage/backends/obsidian.js +233 -0
- package/dist/src/storage/cli.js +468 -0
- package/dist/src/storage/config.js +272 -0
- package/dist/src/storage/index.js +108 -0
- package/dist/src/storage/subsystem-cli.js +201 -0
- package/dist/src/storage/types.js +33 -0
- package/dist/src/testing/corpus/corpus-builder.js +383 -0
- package/dist/src/testing/corpus/ground-truth-manager.js +460 -0
- package/dist/src/testing/corpus/index.js +10 -0
- package/dist/src/testing/fixtures/index.js +9 -0
- package/dist/src/testing/fixtures/test-data-factory.js +472 -0
- package/dist/src/testing/generators/index.js +11 -0
- package/dist/src/testing/generators/test-case-generator.js +393 -0
- package/dist/src/testing/generators/test-code-generator.js +384 -0
- package/dist/src/testing/generators/use-case-parser.js +325 -0
- package/dist/src/testing/index.js +11 -0
- package/dist/src/tracker/capability-protocol.js +118 -0
- package/dist/src/update/checker.mjs +396 -0
- package/dist/src/update/notifier.mjs +235 -0
- package/dist/src/writing/content-diversifier.js +804 -0
- package/dist/src/writing/example-generator.js +959 -0
- package/dist/src/writing/example-templates.js +99 -0
- package/dist/src/writing/pattern-library.js +486 -0
- package/dist/src/writing/patterns/banned-phrases.json +4413 -0
- package/dist/src/writing/patterns/formulaic-structures.json +1300 -0
- package/dist/src/writing/patterns/generic-adjectives.json +1510 -0
- package/dist/src/writing/patterns/hedging-language.json +2096 -0
- package/dist/src/writing/patterns/transition-words.json +1285 -0
- package/dist/src/writing/patterns/weak-verbs.json +1112 -0
- package/dist/src/writing/prompt-optimizer.js +660 -0
- package/dist/src/writing/prompt-templates.js +583 -0
- package/dist/src/writing/scoring-config-loader.js +168 -0
- package/dist/src/writing/validation-engine.js +595 -0
- package/dist/src/writing/validation-rules.js +380 -0
- package/dist/src/writing/voice-analyzer.js +439 -0
- package/dist/src/writing/voice-calibration.js +661 -0
- package/dist/src/writing/voice-profiles.json +588 -0
- package/package.json +65 -9
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Budget — configurable context/generation token split
|
|
3
|
+
*
|
|
4
|
+
* Manages token budgets for context windows with a default 70/30 split
|
|
5
|
+
* (70% context, 30% generation). Supports priority scoring based on
|
|
6
|
+
* recency, similarity, and @-mention presence.
|
|
7
|
+
*
|
|
8
|
+
* @module metrics/context-budget
|
|
9
|
+
* @issue #144
|
|
10
|
+
*/
|
|
11
|
+
import { promises as fs } from 'fs';
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import { estimateTokens } from './token-counter.js';
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Constants
|
|
16
|
+
// ============================================================================
|
|
17
|
+
const DEFAULT_CONFIG = {
|
|
18
|
+
totalTokens: 200000,
|
|
19
|
+
contextFraction: 0.70,
|
|
20
|
+
generationFraction: 0.30,
|
|
21
|
+
warningThreshold: 0.85,
|
|
22
|
+
hardLimitThreshold: 0.95,
|
|
23
|
+
};
|
|
24
|
+
const CONFIG_PATH = '.aiwg/config/context-budget.json';
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// ContextBudgetManager
|
|
27
|
+
// ============================================================================
|
|
28
|
+
export class ContextBudgetManager {
|
|
29
|
+
config;
|
|
30
|
+
items;
|
|
31
|
+
projectPath;
|
|
32
|
+
constructor(projectPath, config) {
|
|
33
|
+
this.projectPath = projectPath;
|
|
34
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
35
|
+
this.items = [];
|
|
36
|
+
// Validate fractions sum to 1
|
|
37
|
+
const total = this.config.contextFraction + this.config.generationFraction;
|
|
38
|
+
if (Math.abs(total - 1.0) > 0.001) {
|
|
39
|
+
throw new Error(`Context and generation fractions must sum to 1.0, got ${total}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get contextBudget() {
|
|
43
|
+
return Math.floor(this.config.totalTokens * this.config.contextFraction);
|
|
44
|
+
}
|
|
45
|
+
get generationBudget() {
|
|
46
|
+
return Math.floor(this.config.totalTokens * this.config.generationFraction);
|
|
47
|
+
}
|
|
48
|
+
addItem(id, content, sourceType, similarity) {
|
|
49
|
+
const tokens = estimateTokens(content);
|
|
50
|
+
const priority = calculatePriority(sourceType, similarity);
|
|
51
|
+
const item = {
|
|
52
|
+
id,
|
|
53
|
+
content,
|
|
54
|
+
tokens,
|
|
55
|
+
priority,
|
|
56
|
+
source: {
|
|
57
|
+
type: sourceType,
|
|
58
|
+
addedAt: new Date().toISOString(),
|
|
59
|
+
similarity,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
this.items.push(item);
|
|
63
|
+
return item;
|
|
64
|
+
}
|
|
65
|
+
removeItem(id) {
|
|
66
|
+
const index = this.items.findIndex((item) => item.id === id);
|
|
67
|
+
if (index === -1)
|
|
68
|
+
return false;
|
|
69
|
+
this.items.splice(index, 1);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
getStatus() {
|
|
73
|
+
const contextUsed = this.items.reduce((sum, item) => sum + item.tokens, 0);
|
|
74
|
+
const contextBudget = this.contextBudget;
|
|
75
|
+
const usageFraction = contextBudget > 0 ? contextUsed / contextBudget : 0;
|
|
76
|
+
let level;
|
|
77
|
+
if (usageFraction > 1.0) {
|
|
78
|
+
level = 'exceeded';
|
|
79
|
+
}
|
|
80
|
+
else if (usageFraction >= this.config.hardLimitThreshold) {
|
|
81
|
+
level = 'critical';
|
|
82
|
+
}
|
|
83
|
+
else if (usageFraction >= this.config.warningThreshold) {
|
|
84
|
+
level = 'warning';
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
level = 'ok';
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
contextBudget,
|
|
91
|
+
generationBudget: this.generationBudget,
|
|
92
|
+
contextUsed,
|
|
93
|
+
contextRemaining: Math.max(0, contextBudget - contextUsed),
|
|
94
|
+
usageFraction: Math.round(usageFraction * 10000) / 10000,
|
|
95
|
+
level,
|
|
96
|
+
itemCount: this.items.length,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
wouldExceed(content) {
|
|
100
|
+
const tokens = estimateTokens(content);
|
|
101
|
+
const status = this.getStatus();
|
|
102
|
+
return (status.contextUsed + tokens) > this.contextBudget;
|
|
103
|
+
}
|
|
104
|
+
degrade() {
|
|
105
|
+
const targetTokens = Math.floor(this.contextBudget * this.config.warningThreshold);
|
|
106
|
+
const sorted = [...this.items].sort((a, b) => a.priority - b.priority);
|
|
107
|
+
let currentTokens = this.items.reduce((sum, item) => sum + item.tokens, 0);
|
|
108
|
+
const dropped = [];
|
|
109
|
+
const droppedIds = new Set();
|
|
110
|
+
for (const item of sorted) {
|
|
111
|
+
if (currentTokens <= targetTokens)
|
|
112
|
+
break;
|
|
113
|
+
if (item.source.type === 'system')
|
|
114
|
+
continue;
|
|
115
|
+
dropped.push(item);
|
|
116
|
+
droppedIds.add(item.id);
|
|
117
|
+
currentTokens -= item.tokens;
|
|
118
|
+
}
|
|
119
|
+
this.items = this.items.filter((item) => !droppedIds.has(item.id));
|
|
120
|
+
const tokensFreed = dropped.reduce((sum, item) => sum + item.tokens, 0);
|
|
121
|
+
return {
|
|
122
|
+
kept: [...this.items],
|
|
123
|
+
dropped,
|
|
124
|
+
tokensFreed,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
getItems() {
|
|
128
|
+
return [...this.items].sort((a, b) => b.priority - a.priority);
|
|
129
|
+
}
|
|
130
|
+
async loadConfig() {
|
|
131
|
+
try {
|
|
132
|
+
const configPath = path.join(this.projectPath, CONFIG_PATH);
|
|
133
|
+
const content = await fs.readFile(configPath, 'utf-8');
|
|
134
|
+
const loaded = JSON.parse(content);
|
|
135
|
+
this.config = { ...DEFAULT_CONFIG, ...loaded };
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Use defaults
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async saveConfig() {
|
|
142
|
+
const configPath = path.join(this.projectPath, CONFIG_PATH);
|
|
143
|
+
await fs.mkdir(path.dirname(configPath), { recursive: true });
|
|
144
|
+
await fs.writeFile(configPath, JSON.stringify(this.config, null, 2), 'utf-8');
|
|
145
|
+
}
|
|
146
|
+
getConfig() {
|
|
147
|
+
return { ...this.config };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// ============================================================================
|
|
151
|
+
// Priority Scoring
|
|
152
|
+
// ============================================================================
|
|
153
|
+
export function calculatePriority(sourceType, similarity) {
|
|
154
|
+
let base;
|
|
155
|
+
switch (sourceType) {
|
|
156
|
+
case 'system':
|
|
157
|
+
base = 1.0;
|
|
158
|
+
break;
|
|
159
|
+
case 'at-mention':
|
|
160
|
+
base = 0.9;
|
|
161
|
+
break;
|
|
162
|
+
case 'user':
|
|
163
|
+
base = 0.7;
|
|
164
|
+
break;
|
|
165
|
+
case 'auto':
|
|
166
|
+
base = 0.5;
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
base = 0.3;
|
|
170
|
+
}
|
|
171
|
+
const similarityBonus = similarity ? similarity * 0.1 : 0;
|
|
172
|
+
return Math.min(1.0, base + similarityBonus);
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=context-budget.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Counter — character-based token estimation
|
|
3
|
+
*
|
|
4
|
+
* Provides lightweight token estimation using the 4 chars per token
|
|
5
|
+
* heuristic, non-blank line counting, and tokens/line ratio calculation.
|
|
6
|
+
* Benchmark target: 124 tokens/line (MetaGPT, REF-013).
|
|
7
|
+
*
|
|
8
|
+
* @module metrics/token-counter
|
|
9
|
+
* @issue #173
|
|
10
|
+
* @schema @agentic/code/frameworks/sdlc-complete/schemas/flows/token-efficiency.yaml
|
|
11
|
+
*/
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Constants
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/** Average characters per token (GPT/Claude heuristic) */
|
|
16
|
+
export const CHARS_PER_TOKEN = 4;
|
|
17
|
+
/** MetaGPT benchmark: 124 tokens per line (REF-013) */
|
|
18
|
+
export const BENCHMARK_TOKENS_PER_LINE = 124;
|
|
19
|
+
/** Typical LLM baseline: ~200 tokens per line */
|
|
20
|
+
export const BASELINE_TOKENS_PER_LINE = 200;
|
|
21
|
+
/** Green threshold: at or below benchmark */
|
|
22
|
+
export const GREEN_MAX_TOKENS_PER_LINE = 124;
|
|
23
|
+
/** Yellow threshold: between benchmark and 150 */
|
|
24
|
+
export const YELLOW_MAX_TOKENS_PER_LINE = 150;
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Core Functions
|
|
27
|
+
// ============================================================================
|
|
28
|
+
/**
|
|
29
|
+
* Estimate token count from text content using character-based heuristic.
|
|
30
|
+
*
|
|
31
|
+
* @param content - Text content to estimate tokens for
|
|
32
|
+
* @returns Estimated token count
|
|
33
|
+
*/
|
|
34
|
+
export function estimateTokens(content) {
|
|
35
|
+
if (!content)
|
|
36
|
+
return 0;
|
|
37
|
+
return Math.ceil(content.length / CHARS_PER_TOKEN);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Count non-blank lines in content.
|
|
41
|
+
*
|
|
42
|
+
* @param content - Text content
|
|
43
|
+
* @returns Number of non-blank lines
|
|
44
|
+
*/
|
|
45
|
+
export function countNonBlankLines(content) {
|
|
46
|
+
if (!content)
|
|
47
|
+
return 0;
|
|
48
|
+
const lines = content.split('\n');
|
|
49
|
+
return lines.filter((line) => line.trim().length > 0).length;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Count total lines in content.
|
|
53
|
+
*
|
|
54
|
+
* @param content - Text content
|
|
55
|
+
* @returns Total line count
|
|
56
|
+
*/
|
|
57
|
+
export function countTotalLines(content) {
|
|
58
|
+
if (!content)
|
|
59
|
+
return 0;
|
|
60
|
+
return content.split('\n').length;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Perform full token count analysis on content.
|
|
64
|
+
*
|
|
65
|
+
* @param content - Text content to analyze
|
|
66
|
+
* @returns Token count with line metrics
|
|
67
|
+
*/
|
|
68
|
+
export function countTokens(content) {
|
|
69
|
+
const tokens = estimateTokens(content);
|
|
70
|
+
const nonBlankLines = countNonBlankLines(content);
|
|
71
|
+
const totalLines = countTotalLines(content);
|
|
72
|
+
const tokensPerLine = nonBlankLines > 0 ? tokens / nonBlankLines : 0;
|
|
73
|
+
return {
|
|
74
|
+
tokens,
|
|
75
|
+
characters: content ? content.length : 0,
|
|
76
|
+
nonBlankLines,
|
|
77
|
+
totalLines,
|
|
78
|
+
tokensPerLine: Math.round(tokensPerLine * 100) / 100,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// Threshold Evaluation
|
|
83
|
+
// ============================================================================
|
|
84
|
+
/**
|
|
85
|
+
* Determine threshold status for a tokens/line ratio.
|
|
86
|
+
*
|
|
87
|
+
* @param tokensPerLine - Tokens per non-blank line ratio
|
|
88
|
+
* @returns Threshold status with level, message, and action
|
|
89
|
+
*/
|
|
90
|
+
export function evaluateThreshold(tokensPerLine) {
|
|
91
|
+
if (tokensPerLine <= GREEN_MAX_TOKENS_PER_LINE) {
|
|
92
|
+
return {
|
|
93
|
+
level: 'green',
|
|
94
|
+
message: 'Meeting benchmark',
|
|
95
|
+
action: 'none',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (tokensPerLine <= YELLOW_MAX_TOKENS_PER_LINE) {
|
|
99
|
+
return {
|
|
100
|
+
level: 'yellow',
|
|
101
|
+
message: 'Review for optimization',
|
|
102
|
+
action: 'flag_for_review',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
level: 'red',
|
|
107
|
+
message: 'Requires optimization',
|
|
108
|
+
action: 'generate_recommendations',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Analyze token efficiency with full benchmark comparison.
|
|
113
|
+
*
|
|
114
|
+
* @param content - Text content to analyze
|
|
115
|
+
* @returns Full efficiency result with threshold and benchmark comparison
|
|
116
|
+
*/
|
|
117
|
+
export function analyzeTokenEfficiency(content) {
|
|
118
|
+
const count = countTokens(content);
|
|
119
|
+
const threshold = evaluateThreshold(count.tokensPerLine);
|
|
120
|
+
const vsBenchmark = count.tokensPerLine > 0
|
|
121
|
+
? Math.round(((count.tokensPerLine - BENCHMARK_TOKENS_PER_LINE) / BENCHMARK_TOKENS_PER_LINE) * 10000) / 100
|
|
122
|
+
: 0;
|
|
123
|
+
const vsBaseline = count.tokensPerLine > 0
|
|
124
|
+
? Math.round(((count.tokensPerLine - BASELINE_TOKENS_PER_LINE) / BASELINE_TOKENS_PER_LINE) * 10000) / 100
|
|
125
|
+
: 0;
|
|
126
|
+
return {
|
|
127
|
+
...count,
|
|
128
|
+
threshold,
|
|
129
|
+
vsBenchmark,
|
|
130
|
+
vsBaseline,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=token-counter.js.map
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Configuration Loader
|
|
3
|
+
* Loads and merges model configurations from multiple sources with proper precedence
|
|
4
|
+
*
|
|
5
|
+
* @implements @.aiwg/architecture/ADR-015-enhanced-model-selection.md
|
|
6
|
+
* @architecture @.aiwg/architecture/enhanced-model-selection-design.md
|
|
7
|
+
*/
|
|
8
|
+
import { readFile } from 'fs/promises';
|
|
9
|
+
import { resolve } from 'path';
|
|
10
|
+
import { homedir } from 'os';
|
|
11
|
+
import { existsSync } from 'fs';
|
|
12
|
+
import { validateUserProjectModelConfig } from './provider-policy.js';
|
|
13
|
+
/**
|
|
14
|
+
* Loads and merges model configurations
|
|
15
|
+
*/
|
|
16
|
+
export class ConfigLoader {
|
|
17
|
+
cache = null;
|
|
18
|
+
locations;
|
|
19
|
+
constructor(projectPath) {
|
|
20
|
+
const aiwgHome = process.env.AIWG_HOME || resolve(homedir(), '.local/share/ai-writing-guide');
|
|
21
|
+
const userConfigDir = process.env.AIWG_CONFIG || resolve(homedir(), '.config/aiwg');
|
|
22
|
+
this.locations = {
|
|
23
|
+
aiwgDefault: resolve(aiwgHome, 'agentic/code/frameworks/sdlc-complete/config/models-v2.json'),
|
|
24
|
+
userConfig: resolve(userConfigDir, 'models.json'),
|
|
25
|
+
projectConfig: resolve(projectPath || process.cwd(), 'models.json'),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load and merge all configurations
|
|
30
|
+
* Precedence: project > user > AIWG default
|
|
31
|
+
*/
|
|
32
|
+
async load() {
|
|
33
|
+
if (this.cache) {
|
|
34
|
+
return this.cache;
|
|
35
|
+
}
|
|
36
|
+
// Load all configs
|
|
37
|
+
const aiwgDefault = await this.loadAiwgDefault();
|
|
38
|
+
const userConfig = await this.loadUserConfig();
|
|
39
|
+
const projectConfig = await this.loadProjectConfig();
|
|
40
|
+
// Merge with precedence
|
|
41
|
+
const merged = this.merge(aiwgDefault, userConfig, projectConfig);
|
|
42
|
+
this.cache = merged;
|
|
43
|
+
return merged;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load AIWG default configuration
|
|
47
|
+
*/
|
|
48
|
+
async loadAiwgDefault() {
|
|
49
|
+
try {
|
|
50
|
+
const content = await readFile(this.locations.aiwgDefault, 'utf-8');
|
|
51
|
+
const config = JSON.parse(content);
|
|
52
|
+
// Validate it's v2 schema
|
|
53
|
+
if (!config.version || !config.tiers || !config.providers) {
|
|
54
|
+
throw new Error('Invalid AIWG default config: missing required v2 fields');
|
|
55
|
+
}
|
|
56
|
+
return config;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new Error(`Failed to load AIWG default config: ${error}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Load user configuration (optional)
|
|
64
|
+
*/
|
|
65
|
+
async loadUserConfig() {
|
|
66
|
+
if (!existsSync(this.locations.userConfig)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const content = await readFile(this.locations.userConfig, 'utf-8');
|
|
71
|
+
const parsed = JSON.parse(content);
|
|
72
|
+
const validation = validateUserProjectModelConfig(parsed);
|
|
73
|
+
if (!validation.valid) {
|
|
74
|
+
throw new Error(validation.diagnostics.map(item => `${item.code}: ${item.message}`).join('; '));
|
|
75
|
+
}
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
throw new Error(`Invalid user model config ${this.locations.userConfig}: ${error}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Load project configuration (optional)
|
|
84
|
+
*/
|
|
85
|
+
async loadProjectConfig() {
|
|
86
|
+
if (!existsSync(this.locations.projectConfig)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const content = await readFile(this.locations.projectConfig, 'utf-8');
|
|
91
|
+
const parsed = JSON.parse(content);
|
|
92
|
+
const validation = validateUserProjectModelConfig(parsed);
|
|
93
|
+
if (!validation.valid) {
|
|
94
|
+
throw new Error(validation.diagnostics.map(item => `${item.code}: ${item.message}`).join('; '));
|
|
95
|
+
}
|
|
96
|
+
return parsed;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Error(`Invalid project model config ${this.locations.projectConfig}: ${error}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Merge configurations with proper precedence
|
|
104
|
+
*/
|
|
105
|
+
merge(aiwgDefault, userConfig, projectConfig) {
|
|
106
|
+
// Start with AIWG defaults
|
|
107
|
+
const merged = {
|
|
108
|
+
defaults: { ...aiwgDefault.defaults },
|
|
109
|
+
tiers: { ...aiwgDefault.tiers },
|
|
110
|
+
providers: this.deepCloneProviders(aiwgDefault.providers),
|
|
111
|
+
agentRoleAssignments: { ...(aiwgDefault.agentRoleAssignments || {}) },
|
|
112
|
+
shorthand: { ...(aiwgDefault.shorthand || {}) },
|
|
113
|
+
agentOverrides: {},
|
|
114
|
+
};
|
|
115
|
+
// Apply user config
|
|
116
|
+
if (userConfig) {
|
|
117
|
+
if (userConfig.defaults) {
|
|
118
|
+
merged.defaults = { ...merged.defaults, ...userConfig.defaults };
|
|
119
|
+
}
|
|
120
|
+
if (userConfig.customTiers) {
|
|
121
|
+
merged.tiers = { ...merged.tiers, ...userConfig.customTiers };
|
|
122
|
+
}
|
|
123
|
+
if (userConfig.agentOverrides) {
|
|
124
|
+
merged.agentOverrides = { ...userConfig.agentOverrides };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Apply project config (highest precedence)
|
|
128
|
+
if (projectConfig) {
|
|
129
|
+
if (projectConfig.defaults) {
|
|
130
|
+
merged.defaults = { ...merged.defaults, ...projectConfig.defaults };
|
|
131
|
+
}
|
|
132
|
+
if (projectConfig.customTiers) {
|
|
133
|
+
merged.tiers = { ...merged.tiers, ...projectConfig.customTiers };
|
|
134
|
+
}
|
|
135
|
+
if (projectConfig.agentOverrides) {
|
|
136
|
+
merged.agentOverrides = { ...merged.agentOverrides, ...projectConfig.agentOverrides };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return merged;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Deep clone providers to avoid mutation
|
|
143
|
+
*/
|
|
144
|
+
deepCloneProviders(providers) {
|
|
145
|
+
const cloned = {};
|
|
146
|
+
for (const [name, provider] of Object.entries(providers)) {
|
|
147
|
+
cloned[name] = {
|
|
148
|
+
...provider,
|
|
149
|
+
models: provider.models
|
|
150
|
+
? {
|
|
151
|
+
reasoning: provider.models.reasoning ? { ...provider.models.reasoning } : undefined,
|
|
152
|
+
coding: provider.models.coding ? { ...provider.models.coding } : undefined,
|
|
153
|
+
efficiency: provider.models.efficiency ? { ...provider.models.efficiency } : undefined,
|
|
154
|
+
}
|
|
155
|
+
: undefined,
|
|
156
|
+
tierOverrides: provider.tierOverrides ? { ...provider.tierOverrides } : undefined,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return cloned;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Load v1 config for backwards compatibility
|
|
163
|
+
*/
|
|
164
|
+
async loadV1Config(path) {
|
|
165
|
+
if (!existsSync(path)) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const content = await readFile(path, 'utf-8');
|
|
170
|
+
const config = JSON.parse(content);
|
|
171
|
+
// Simple heuristic: v1 has provider keys with role objects
|
|
172
|
+
// v2 has version, tiers, providers structure
|
|
173
|
+
if ('version' in config && 'tiers' in config) {
|
|
174
|
+
return null; // This is v2
|
|
175
|
+
}
|
|
176
|
+
return config;
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Convert v1 config to v2 compatible structure
|
|
184
|
+
*/
|
|
185
|
+
convertV1ToV2(_v1Config) {
|
|
186
|
+
const agentOverrides = {};
|
|
187
|
+
// V1 doesn't have agent overrides, so we just create empty structure
|
|
188
|
+
// The actual v1 role mappings will be used as defaults in the resolver
|
|
189
|
+
// _v1Config preserved for future v1 field migration
|
|
190
|
+
return {
|
|
191
|
+
agentOverrides,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Resolve provider inheritance
|
|
196
|
+
*/
|
|
197
|
+
resolveProviderInheritance(provider, providers) {
|
|
198
|
+
if (!provider.inherits) {
|
|
199
|
+
return provider;
|
|
200
|
+
}
|
|
201
|
+
const parent = providers[provider.inherits];
|
|
202
|
+
if (!parent) {
|
|
203
|
+
throw new Error(`Provider ${provider.inherits} not found for inheritance`);
|
|
204
|
+
}
|
|
205
|
+
// Recursively resolve parent
|
|
206
|
+
const resolvedParent = this.resolveProviderInheritance(parent, providers);
|
|
207
|
+
// Merge parent into child (child overrides parent)
|
|
208
|
+
return {
|
|
209
|
+
...resolvedParent,
|
|
210
|
+
...provider,
|
|
211
|
+
models: provider.models || resolvedParent.models,
|
|
212
|
+
tierOverrides: provider.tierOverrides || resolvedParent.tierOverrides,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Clear cache (useful for testing)
|
|
217
|
+
*/
|
|
218
|
+
clearCache() {
|
|
219
|
+
this.cache = null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get configuration file locations
|
|
223
|
+
*/
|
|
224
|
+
getLocations() {
|
|
225
|
+
return { ...this.locations };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=config-loader.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Model Selection System - Public API
|
|
3
|
+
*
|
|
4
|
+
* Provides tier-based model selection with:
|
|
5
|
+
* - Quality tiers (economy, standard, premium, max-quality)
|
|
6
|
+
* - Provider abstraction (claude, openai, factory, etc.)
|
|
7
|
+
* - Hierarchical configuration (default < user < project < agent)
|
|
8
|
+
* - Backwards compatibility with v1 configs
|
|
9
|
+
*
|
|
10
|
+
* @implements @.aiwg/architecture/ADR-015-enhanced-model-selection.md
|
|
11
|
+
* @architecture @.aiwg/architecture/enhanced-model-selection-design.md
|
|
12
|
+
*
|
|
13
|
+
* @module models
|
|
14
|
+
*/
|
|
15
|
+
// Export ConfigLoader
|
|
16
|
+
export { ConfigLoader } from './config-loader.js';
|
|
17
|
+
// Export ModelResolver
|
|
18
|
+
export { ModelResolver } from './resolver.js';
|
|
19
|
+
// Export provider-neutral runtime tier routing primitive
|
|
20
|
+
export { routeModelTier } from './router.js';
|
|
21
|
+
export { compileModelPolicy, loadProviderModelCapabilities, loadProviderModelCatalog, renderCodexAgentToml, resetModelPolicyCachesForTests, validateCanonicalModelPolicy, validateUserProjectModelConfig, } from './provider-policy.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../schemas/models/provider-model-capabilities.v1.schema.json",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"verifiedAt": "2026-07-20",
|
|
5
|
+
"providers": {
|
|
6
|
+
"claude": {
|
|
7
|
+
"agent": "native", "skill": "native", "globalChild": "inherited",
|
|
8
|
+
"identifierSyntax": "Claude alias or accepted Anthropic model ID",
|
|
9
|
+
"effortValues": ["low", "medium", "high"],
|
|
10
|
+
"inheritance": "Omitted agent or skill fields inherit the invoking session",
|
|
11
|
+
"invalidPinFallback": "Provider validation/error; never assume fallback",
|
|
12
|
+
"configTarget": ".claude/agents/*.md and skill SKILL.md frontmatter",
|
|
13
|
+
"artifactFormat": "YAML frontmatter plus Markdown",
|
|
14
|
+
"verification": "Inspect deployed frontmatter and bounded invocation metadata",
|
|
15
|
+
"sourceUrl": "https://code.claude.com/docs/en/sub-agents", "verifiedAt": "2026-07-20"
|
|
16
|
+
},
|
|
17
|
+
"codex": {
|
|
18
|
+
"agent": "native", "skill": "unsupported", "globalChild": "inherited",
|
|
19
|
+
"identifierSyntax": "Codex model slug accepted by config.toml",
|
|
20
|
+
"effortValues": ["minimal", "low", "medium", "high", "xhigh"],
|
|
21
|
+
"inheritance": "Omitted model and model_reasoning_effort inherit the parent session",
|
|
22
|
+
"invalidPinFallback": "Strict config or runtime validation; never assume fallback",
|
|
23
|
+
"configTarget": ".codex/agents/*.toml",
|
|
24
|
+
"artifactFormat": "Standalone TOML custom-agent configuration",
|
|
25
|
+
"verification": "Parse TOML and load in Codex custom-agent registry",
|
|
26
|
+
"sourceUrl": "https://learn.chatgpt.com/docs/agent-configuration/subagents", "verifiedAt": "2026-07-20"
|
|
27
|
+
},
|
|
28
|
+
"copilot": {
|
|
29
|
+
"agent": "native", "skill": "unsupported", "globalChild": "inherited",
|
|
30
|
+
"identifierSyntax": "Current Copilot custom-agent model identifier",
|
|
31
|
+
"inheritance": "Omitted model uses session or Auto selection",
|
|
32
|
+
"invalidPinFallback": "Plan/admin/catalog dependent; report unresolved",
|
|
33
|
+
"configTarget": ".github/agents/*.agent.md",
|
|
34
|
+
"artifactFormat": "YAML frontmatter plus Markdown",
|
|
35
|
+
"verification": "Schema fixture and entitled Copilot invocation",
|
|
36
|
+
"sourceUrl": "https://docs.github.com/en/copilot/reference/custom-agents-configuration", "verifiedAt": "2026-07-20"
|
|
37
|
+
},
|
|
38
|
+
"cursor": {
|
|
39
|
+
"agent": "native", "skill": "unsupported", "globalChild": "inherited",
|
|
40
|
+
"identifierSyntax": "Cursor-supported exact model ID",
|
|
41
|
+
"inheritance": "Omitted model inherits parent selection",
|
|
42
|
+
"invalidPinFallback": "Plan/admin fallback may apply; record observed result",
|
|
43
|
+
"configTarget": ".cursor/agents/*.md",
|
|
44
|
+
"artifactFormat": "YAML frontmatter plus Markdown",
|
|
45
|
+
"verification": "Schema fixture and entitled Cursor invocation",
|
|
46
|
+
"sourceUrl": "https://cursor.com/docs/subagents", "verifiedAt": "2026-07-20"
|
|
47
|
+
},
|
|
48
|
+
"factory": {
|
|
49
|
+
"agent": "native", "skill": "informational", "globalChild": "native",
|
|
50
|
+
"identifierSyntax": "Factory model ID or Light/Medium/Heavy complexity",
|
|
51
|
+
"effortValues": ["low", "medium", "high"],
|
|
52
|
+
"inheritance": "Droid may inherit org/session model policy",
|
|
53
|
+
"invalidPinFallback": "Organization policy may substitute; record observed result",
|
|
54
|
+
"configTarget": ".factory/droids/*.md and Factory settings",
|
|
55
|
+
"artifactFormat": "YAML frontmatter plus Markdown",
|
|
56
|
+
"verification": "Fixture validation and Factory CLI model report",
|
|
57
|
+
"sourceUrl": "https://docs.factory.ai/cli/configuration/custom-droids", "verifiedAt": "2026-07-20"
|
|
58
|
+
},
|
|
59
|
+
"opencode": {
|
|
60
|
+
"agent": "native", "skill": "unsupported", "globalChild": "inherited",
|
|
61
|
+
"identifierSyntax": "provider/model-id",
|
|
62
|
+
"inheritance": "Omitted agent model inherits global primary model",
|
|
63
|
+
"invalidPinFallback": "Installed provider catalog determines error/fallback",
|
|
64
|
+
"configTarget": ".opencode/agent/*.md",
|
|
65
|
+
"artifactFormat": "YAML frontmatter plus Markdown",
|
|
66
|
+
"verification": "Inspect artifact and OpenCode model registry",
|
|
67
|
+
"sourceUrl": "https://opencode.ai/docs/agents", "verifiedAt": "2026-07-20"
|
|
68
|
+
},
|
|
69
|
+
"warp": {
|
|
70
|
+
"agent": "global-only", "skill": "unsupported", "globalChild": "native",
|
|
71
|
+
"identifierSyntax": "Warp saved-profile or run model identifier",
|
|
72
|
+
"inheritance": "All delegated work uses run/profile selection",
|
|
73
|
+
"invalidPinFallback": "Profile availability dependent",
|
|
74
|
+
"configTarget": "Warp agent profile or run configuration",
|
|
75
|
+
"artifactFormat": "Saved profile / run control plane",
|
|
76
|
+
"verification": "Inspect active profile and run metadata",
|
|
77
|
+
"sourceUrl": "https://docs.warp.dev/agent-platform/capabilities/agent-profiles-permissions", "verifiedAt": "2026-07-20"
|
|
78
|
+
},
|
|
79
|
+
"windsurf": {
|
|
80
|
+
"agent": "unsupported", "skill": "unsupported", "globalChild": "inherited",
|
|
81
|
+
"identifierSyntax": "UI-selected provider model",
|
|
82
|
+
"inheritance": "Child behavior follows the main UI session",
|
|
83
|
+
"invalidPinFallback": "No portable custom-child selector",
|
|
84
|
+
"configTarget": "No supported portable artifact field",
|
|
85
|
+
"artifactFormat": "Informational policy only",
|
|
86
|
+
"verification": "Assert unsupported fields are omitted",
|
|
87
|
+
"sourceUrl": "https://docs.devin.ai/desktop/cascade/skills", "verifiedAt": "2026-07-20"
|
|
88
|
+
},
|
|
89
|
+
"openclaw": {
|
|
90
|
+
"agent": "native", "skill": "unsupported", "globalChild": "native",
|
|
91
|
+
"identifierSyntax": "Configured provider/model identifier",
|
|
92
|
+
"inheritance": "Per-agent or per-spawn override falls back to global subagent model",
|
|
93
|
+
"invalidPinFallback": "Provider/account fallback must be observed",
|
|
94
|
+
"configTarget": "OpenClaw subagent configuration",
|
|
95
|
+
"artifactFormat": "JSON/JSONC runtime configuration",
|
|
96
|
+
"verification": "Inspect resolved subagent metadata",
|
|
97
|
+
"sourceUrl": "https://docs.openclaw.ai/tools/subagents", "verifiedAt": "2026-07-20"
|
|
98
|
+
},
|
|
99
|
+
"hermes": {
|
|
100
|
+
"agent": "global-only", "skill": "unsupported", "globalChild": "native",
|
|
101
|
+
"identifierSyntax": "Hermes delegation provider and model",
|
|
102
|
+
"inheritance": "All delegated workers share one configured model",
|
|
103
|
+
"invalidPinFallback": "Provider resolution is global; report actual model",
|
|
104
|
+
"configTarget": "Hermes delegation configuration",
|
|
105
|
+
"artifactFormat": "Global CLI/config setting",
|
|
106
|
+
"verification": "Inspect Hermes delegation configuration",
|
|
107
|
+
"sourceUrl": "https://hermes-agent.nousresearch.com/docs/user-guide/features/delegation", "verifiedAt": "2026-07-20"
|
|
108
|
+
},
|
|
109
|
+
"openhuman": {
|
|
110
|
+
"agent": "compiled", "skill": "unsupported", "globalChild": "inherited",
|
|
111
|
+
"identifierSyntax": "Inherit, Exact(model), or semantic Hint",
|
|
112
|
+
"inheritance": "Inherit delegates selection to router/provider defaults",
|
|
113
|
+
"invalidPinFallback": "Exact pins validate; semantic hints route dynamically",
|
|
114
|
+
"configTarget": "OpenHuman agent TOML",
|
|
115
|
+
"artifactFormat": "Standalone TOML agent definition",
|
|
116
|
+
"verification": "Parse against OpenHuman definition schema",
|
|
117
|
+
"sourceUrl": "https://github.com/tinyhumansai/openhuman/blob/main/src/openhuman/agent/harness/definition.rs", "verifiedAt": "2026-07-20"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|