@aiwg/cli 0.0.0-bootstrap.0 → 2026.7.17
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/README.md +21 -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 +1462 -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 +882 -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 +64 -9
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic enrichment sidecar store.
|
|
3
|
+
*
|
|
4
|
+
* Storage:
|
|
5
|
+
* .aiwg/index/semantic/<sanitized-id>.json
|
|
6
|
+
*
|
|
7
|
+
* Sanitization: replace `/` with `__` and any non-[a-zA-Z0-9._-] with `_`.
|
|
8
|
+
* Preserves `.md`, `.ts`, etc. extensions readably while keeping filesystem-safe.
|
|
9
|
+
*
|
|
10
|
+
* @implements #1204
|
|
11
|
+
*/
|
|
12
|
+
import { createHash, } from 'node:crypto';
|
|
13
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync, } from 'node:fs';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
const SEMANTIC_ROOT_DEFAULT = '.aiwg/index/semantic';
|
|
16
|
+
export function resolveSemanticRoot(cwd = process.cwd()) {
|
|
17
|
+
return join(cwd, SEMANTIC_ROOT_DEFAULT);
|
|
18
|
+
}
|
|
19
|
+
export function sanitizeId(id) {
|
|
20
|
+
return id.replace(/\//g, '__').replace(/[^a-zA-Z0-9._\-]/g, '_');
|
|
21
|
+
}
|
|
22
|
+
function entryPath(root, id) {
|
|
23
|
+
return join(root, `${sanitizeId(id)}.json`);
|
|
24
|
+
}
|
|
25
|
+
export function has(root, id) {
|
|
26
|
+
return existsSync(entryPath(root, id));
|
|
27
|
+
}
|
|
28
|
+
export function get(root, id) {
|
|
29
|
+
const file = entryPath(root, id);
|
|
30
|
+
if (!existsSync(file))
|
|
31
|
+
throw new Error(`No enrichment for: ${id}`);
|
|
32
|
+
return JSON.parse(readFileSync(file, 'utf-8'));
|
|
33
|
+
}
|
|
34
|
+
export function put(root, id, fields) {
|
|
35
|
+
mkdirSync(root, { recursive: true });
|
|
36
|
+
const file = entryPath(root, id);
|
|
37
|
+
writeFileSync(file, JSON.stringify(fields, null, 2), 'utf-8');
|
|
38
|
+
return file;
|
|
39
|
+
}
|
|
40
|
+
export function remove(root, id) {
|
|
41
|
+
const file = entryPath(root, id);
|
|
42
|
+
if (!existsSync(file))
|
|
43
|
+
return false;
|
|
44
|
+
rmSync(file);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/** Drop ALL enrichment data — implements `aiwg index enrich --reset`. */
|
|
48
|
+
export function reset(root) {
|
|
49
|
+
if (!existsSync(root))
|
|
50
|
+
return { removed: 0 };
|
|
51
|
+
const before = readdirSync(root).filter((f) => f.endsWith('.json'));
|
|
52
|
+
rmSync(root, { recursive: true, force: true });
|
|
53
|
+
return { removed: before.length };
|
|
54
|
+
}
|
|
55
|
+
/** Compute the content hash that would be stored as `enrichedHash`. */
|
|
56
|
+
export function computeContentHash(content) {
|
|
57
|
+
return createHash('sha256').update(content).digest('hex');
|
|
58
|
+
}
|
|
59
|
+
/** List all enrichment entries with staleness flag (caller supplies current hashes). */
|
|
60
|
+
export function list(root, currentHashes, now = new Date()) {
|
|
61
|
+
if (!existsSync(root))
|
|
62
|
+
return [];
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const file of readdirSync(root)) {
|
|
65
|
+
if (!file.endsWith('.json'))
|
|
66
|
+
continue;
|
|
67
|
+
let fields;
|
|
68
|
+
try {
|
|
69
|
+
fields = JSON.parse(readFileSync(join(root, file), 'utf-8'));
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const id = file.replace(/\.json$/, '').replace(/__/g, '/');
|
|
75
|
+
const ageDays = Math.max(0, Math.floor((now.getTime() - new Date(fields.enrichedAt).getTime()) / 86_400_000));
|
|
76
|
+
const currentHash = currentHashes[id];
|
|
77
|
+
const isStale = currentHash !== undefined && currentHash !== fields.enrichedHash;
|
|
78
|
+
out.push({
|
|
79
|
+
artifactId: id,
|
|
80
|
+
enrichedAt: fields.enrichedAt,
|
|
81
|
+
enrichedHash: fields.enrichedHash,
|
|
82
|
+
symbolCount: fields.declaredSymbols.length,
|
|
83
|
+
citationCount: fields.citations.length,
|
|
84
|
+
ageDays,
|
|
85
|
+
isStale,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return out.sort((a, b) => a.artifactId.localeCompare(b.artifactId));
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic enrichment — type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Stored as sidecar files at `.aiwg/index/semantic/<sanitized-id>.json`
|
|
5
|
+
* so the existing index schema is not mutated. Surfaces additively from
|
|
6
|
+
* `aiwg index query` when enrichment is present.
|
|
7
|
+
*
|
|
8
|
+
* @implements #1204
|
|
9
|
+
* @see .aiwg/architecture/adr-rlm-index-features-impl-plan.md
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { bm25Rank } from "./fulltext.js";
|
|
4
|
+
import { getFortemiCorePrebuiltStatus, getFortemiCoreSyncStatus } from "./fortemi-core-sync.js";
|
|
5
|
+
import { operationalStateQueryProjection, } from "./operational-state.js";
|
|
6
|
+
function tokenize(text) {
|
|
7
|
+
return text
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.split(/[^a-z0-9-]+/)
|
|
10
|
+
.map((term) => term.trim())
|
|
11
|
+
.filter((term) => term.length > 2);
|
|
12
|
+
}
|
|
13
|
+
function includesAny(text, terms) {
|
|
14
|
+
const lower = text.toLowerCase();
|
|
15
|
+
let matches = 0;
|
|
16
|
+
for (const term of terms) {
|
|
17
|
+
if (lower.includes(term))
|
|
18
|
+
matches++;
|
|
19
|
+
}
|
|
20
|
+
return matches;
|
|
21
|
+
}
|
|
22
|
+
function scoreStaticRecord(record, terms) {
|
|
23
|
+
const fields = [
|
|
24
|
+
{ name: "title", text: record.title, weight: 3 },
|
|
25
|
+
{ name: "name", text: record.name ?? record.search?.name ?? "", weight: 3 },
|
|
26
|
+
{
|
|
27
|
+
name: "summary",
|
|
28
|
+
text: record.summary ?? record.search?.summary ?? "",
|
|
29
|
+
weight: 2,
|
|
30
|
+
},
|
|
31
|
+
{ name: "capability", text: record.search?.capability ?? "", weight: 2 },
|
|
32
|
+
{
|
|
33
|
+
name: "triggers",
|
|
34
|
+
text: (record.search?.triggers ?? []).join(" "),
|
|
35
|
+
weight: 2,
|
|
36
|
+
},
|
|
37
|
+
{ name: "tags", text: record.tags.join(" "), weight: 2 },
|
|
38
|
+
{ name: "body", text: record.search?.body ?? record.text, weight: 1 },
|
|
39
|
+
{
|
|
40
|
+
name: "chunks",
|
|
41
|
+
text: (record.chunks ?? []).map((chunk) => chunk.text).join(" "),
|
|
42
|
+
weight: 1,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
let score = 0;
|
|
46
|
+
const matched = [];
|
|
47
|
+
for (const field of fields) {
|
|
48
|
+
const matches = includesAny(field.text, terms);
|
|
49
|
+
if (matches > 0) {
|
|
50
|
+
score += (matches / terms.length) * field.weight;
|
|
51
|
+
matched.push(field.name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { score, matched };
|
|
55
|
+
}
|
|
56
|
+
function recordToStaticResult(record, score, matched) {
|
|
57
|
+
return {
|
|
58
|
+
path: record.source.path,
|
|
59
|
+
type: artifactTypeFromRecord(record),
|
|
60
|
+
title: record.title,
|
|
61
|
+
summary: record.summary ?? record.search?.summary,
|
|
62
|
+
score: Math.round(score * 1000) / 1000,
|
|
63
|
+
matched,
|
|
64
|
+
...(record.operational_state
|
|
65
|
+
? { operational_state: operationalStateQueryProjection(record.operational_state) }
|
|
66
|
+
: {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function recordBody(record) {
|
|
70
|
+
const chunks = (record.chunks ?? []).map((chunk) => chunk.text).join("\n");
|
|
71
|
+
return [
|
|
72
|
+
record.search?.body,
|
|
73
|
+
record.text,
|
|
74
|
+
chunks,
|
|
75
|
+
record.summary,
|
|
76
|
+
record.search?.summary,
|
|
77
|
+
]
|
|
78
|
+
.filter((part) => Boolean(part))
|
|
79
|
+
.join("\n");
|
|
80
|
+
}
|
|
81
|
+
function matchesPath(recordPath, pattern) {
|
|
82
|
+
if (pattern.includes("*")) {
|
|
83
|
+
const doubleStarPlaceholder = "__AIWG_DOUBLE_STAR__";
|
|
84
|
+
const regex = new RegExp(`^${pattern
|
|
85
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
86
|
+
.replace(/\*\*/g, doubleStarPlaceholder)
|
|
87
|
+
.replace(/\*/g, "[^/]*")
|
|
88
|
+
.replace(new RegExp(doubleStarPlaceholder, "g"), ".*")}$`);
|
|
89
|
+
return regex.test(recordPath);
|
|
90
|
+
}
|
|
91
|
+
return recordPath.includes(pattern);
|
|
92
|
+
}
|
|
93
|
+
function readVerifiedRegularFile(pathname, expectedSize, expectedSha256, label) {
|
|
94
|
+
if (!Number.isSafeInteger(expectedSize) || expectedSize < 0) {
|
|
95
|
+
throw new Error(`${label} has an invalid signed size`);
|
|
96
|
+
}
|
|
97
|
+
const pathStat = fs.lstatSync(pathname);
|
|
98
|
+
if (pathStat.isSymbolicLink() || !pathStat.isFile()) {
|
|
99
|
+
throw new Error(`${label} must be a regular file and may not be a symlink`);
|
|
100
|
+
}
|
|
101
|
+
if (pathStat.size !== expectedSize) {
|
|
102
|
+
throw new Error(`${label} size does not match the signed release descriptor`);
|
|
103
|
+
}
|
|
104
|
+
const noFollow = typeof fs.constants.O_NOFOLLOW === "number"
|
|
105
|
+
? fs.constants.O_NOFOLLOW
|
|
106
|
+
: 0;
|
|
107
|
+
const fd = fs.openSync(pathname, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK | noFollow);
|
|
108
|
+
try {
|
|
109
|
+
const openedStat = fs.fstatSync(fd);
|
|
110
|
+
if (!openedStat.isFile() || openedStat.size !== expectedSize) {
|
|
111
|
+
throw new Error(`${label} changed before it could be read safely`);
|
|
112
|
+
}
|
|
113
|
+
const bytes = Buffer.alloc(expectedSize + 1);
|
|
114
|
+
let offset = 0;
|
|
115
|
+
while (offset < bytes.length) {
|
|
116
|
+
const count = fs.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
117
|
+
if (count === 0)
|
|
118
|
+
break;
|
|
119
|
+
offset += count;
|
|
120
|
+
}
|
|
121
|
+
if (offset !== expectedSize) {
|
|
122
|
+
throw new Error(`${label} changed size while being read`);
|
|
123
|
+
}
|
|
124
|
+
const verified = bytes.subarray(0, expectedSize);
|
|
125
|
+
const digest = createHash("sha256").update(verified).digest("hex");
|
|
126
|
+
if (digest !== expectedSha256) {
|
|
127
|
+
throw new Error(`${label} does not match the signed release descriptor`);
|
|
128
|
+
}
|
|
129
|
+
return verified;
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
fs.closeSync(fd);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function loadFortemiCoreExport(cwd, graph = "project", sourcePaths) {
|
|
136
|
+
if (sourcePaths) {
|
|
137
|
+
try {
|
|
138
|
+
const manifestBytes = readVerifiedRegularFile(sourcePaths.manifestPath, sourcePaths.manifestSize, sourcePaths.manifestSha256, "Verified Fortemi Core manifest");
|
|
139
|
+
const exportBytes = readVerifiedRegularFile(sourcePaths.exportPath, sourcePaths.exportSize, sourcePaths.exportSha256, "Verified Fortemi Core export");
|
|
140
|
+
const manifestSha256 = createHash("sha256").update(manifestBytes).digest("hex");
|
|
141
|
+
const exportSha256 = createHash("sha256").update(exportBytes).digest("hex");
|
|
142
|
+
if (manifestSha256 !== sourcePaths.manifestSha256 ||
|
|
143
|
+
exportSha256 !== sourcePaths.exportSha256) {
|
|
144
|
+
return { reason: "Verified Fortemi Core source bytes do not match the signed release descriptor." };
|
|
145
|
+
}
|
|
146
|
+
const manifest = JSON.parse(manifestBytes.toString("utf-8"));
|
|
147
|
+
const exported = JSON.parse(exportBytes.toString("utf-8"));
|
|
148
|
+
if (manifest.schema_version !== "aiwg.fortemi.prebuilt.v1" ||
|
|
149
|
+
manifest.backend !== "fortemi-core" ||
|
|
150
|
+
manifest.graph !== graph ||
|
|
151
|
+
manifest.export_path !== "aiwg-fortemi-index-v2.json" ||
|
|
152
|
+
manifest.export_schema_version !== "aiwg.fortemi.index.export.v2") {
|
|
153
|
+
return { reason: "Verified Fortemi Core source manifest is incompatible with the requested graph." };
|
|
154
|
+
}
|
|
155
|
+
if (manifest.export_checksum !== exportSha256 ||
|
|
156
|
+
exported.schema_version !== "aiwg.fortemi.index.export.v2" ||
|
|
157
|
+
exported.source?.graph !== graph ||
|
|
158
|
+
!Array.isArray(exported.items) ||
|
|
159
|
+
manifest.item_count !== exported.items.length) {
|
|
160
|
+
return { reason: "Verified Fortemi Core source export does not match its manifest." };
|
|
161
|
+
}
|
|
162
|
+
return { exported };
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
return {
|
|
166
|
+
reason: `Verified Fortemi Core source could not be read: ${err instanceof Error ? err.message : String(err)}`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
let status = getFortemiCoreSyncStatus(cwd, graph);
|
|
171
|
+
if ((!status.optedIn || !status.built || status.stale) && graph === "framework") {
|
|
172
|
+
const prebuilt = getFortemiCorePrebuiltStatus(graph);
|
|
173
|
+
if (prebuilt.optedIn && prebuilt.built && !prebuilt.stale) {
|
|
174
|
+
status = prebuilt;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!status.optedIn) {
|
|
178
|
+
return {
|
|
179
|
+
reason: `Fortemi Core static index is not materialized for graph '${graph}'. Run 'aiwg index sync${graph === "project" ? "" : ` --graph ${graph}`}' first, or pass '--backend local' to use the legacy local index.`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (!status.built || status.stale) {
|
|
183
|
+
return {
|
|
184
|
+
reason: `${status.reason ??
|
|
185
|
+
`Fortemi Core static index for graph '${graph}' is stale or incomplete`}. Re-run 'aiwg index sync' or pass '--backend local' to use the legacy local index.`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const exported = JSON.parse(fs.readFileSync(status.exportPath, "utf-8"));
|
|
190
|
+
if (exported.schema_version !== "aiwg.fortemi.index.export.v2") {
|
|
191
|
+
return {
|
|
192
|
+
reason: `Fortemi Core static index has schema '${exported.schema_version}', expected 'aiwg.fortemi.index.export.v2'. Re-run 'aiwg index sync'.`,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return { exported };
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
return {
|
|
199
|
+
reason: `Fortemi Core static index could not be read: ${err instanceof Error ? err.message : String(err)}`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function artifactTypeFromRecord(record) {
|
|
204
|
+
if (record.search?.type)
|
|
205
|
+
return record.search.type;
|
|
206
|
+
if (record.type.startsWith("aiwg."))
|
|
207
|
+
return record.type.slice("aiwg.".length);
|
|
208
|
+
return record.type;
|
|
209
|
+
}
|
|
210
|
+
function entryFromRecord(record) {
|
|
211
|
+
const indexedFrontmatter = record.search?.frontmatter ?? {};
|
|
212
|
+
const indexedSearchTerms = indexedFrontmatter.aiwg_search_terms;
|
|
213
|
+
return {
|
|
214
|
+
path: record.source.path,
|
|
215
|
+
type: artifactTypeFromRecord(record),
|
|
216
|
+
kind: typeof indexedFrontmatter.aiwg_kind === "string"
|
|
217
|
+
? indexedFrontmatter.aiwg_kind
|
|
218
|
+
: undefined,
|
|
219
|
+
sourceType: typeof indexedFrontmatter.aiwg_source_type === "string"
|
|
220
|
+
? indexedFrontmatter.aiwg_source_type
|
|
221
|
+
: undefined,
|
|
222
|
+
phase: record.search?.phase ?? record.facets.phase?.[0] ?? "",
|
|
223
|
+
title: record.title,
|
|
224
|
+
name: record.name ?? record.search?.name,
|
|
225
|
+
tags: record.tags,
|
|
226
|
+
created: record.source.updated_at ?? record.updated_at,
|
|
227
|
+
updated: record.updated_at,
|
|
228
|
+
checksum: record.source.checksum ?? "",
|
|
229
|
+
summary: record.summary ?? record.search?.summary ?? record.text,
|
|
230
|
+
dependencies: record.relationships
|
|
231
|
+
.filter((relationship) => relationship.direction === "upstream")
|
|
232
|
+
.map((relationship) => relationship.target_path ??
|
|
233
|
+
relationship.source_path ??
|
|
234
|
+
relationship.target_id),
|
|
235
|
+
dependents: record.relationships
|
|
236
|
+
.filter((relationship) => relationship.direction === "downstream")
|
|
237
|
+
.map((relationship) => relationship.target_path ??
|
|
238
|
+
relationship.source_path ??
|
|
239
|
+
relationship.target_id),
|
|
240
|
+
triggers: record.search?.triggers,
|
|
241
|
+
capability: record.search?.capability,
|
|
242
|
+
searchTerms: Array.isArray(indexedSearchTerms)
|
|
243
|
+
? indexedSearchTerms.filter((term) => typeof term === "string")
|
|
244
|
+
: undefined,
|
|
245
|
+
kernel: typeof record.search?.frontmatter?.kernel === "boolean"
|
|
246
|
+
? record.search.frontmatter.kernel
|
|
247
|
+
: undefined,
|
|
248
|
+
operationalState: record.operational_state,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
export function loadFortemiCoreMetadataEntries(cwd, graph = "project", sourcePaths) {
|
|
252
|
+
const loaded = loadFortemiCoreExport(cwd, graph, sourcePaths);
|
|
253
|
+
if (!loaded.exported)
|
|
254
|
+
return { entries: [], reason: loaded.reason };
|
|
255
|
+
return { entries: loaded.exported.items.map(entryFromRecord) };
|
|
256
|
+
}
|
|
257
|
+
export async function queryFortemiCoreAiwgDiscovery(cwd, options) {
|
|
258
|
+
const loaded = loadFortemiCoreExport(cwd, options.graph ?? "framework", options.sourcePaths);
|
|
259
|
+
if (!loaded.exported) {
|
|
260
|
+
return {
|
|
261
|
+
results: [],
|
|
262
|
+
reason: loaded.reason ?? "Fortemi Core static index is unavailable.",
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const typeSet = options.types && options.types.length > 0
|
|
266
|
+
? new Set(options.types)
|
|
267
|
+
: null;
|
|
268
|
+
const dedicatedRecordTypes = new Set([
|
|
269
|
+
"skill", "agent", "command", "rule", "behavior", "flow", "workflow",
|
|
270
|
+
]);
|
|
271
|
+
const fortemiTypes = options.types
|
|
272
|
+
? [...new Set(options.types.map((type) => dedicatedRecordTypes.has(type) ? `aiwg.${type === "workflow" ? "flow" : type}` : "aiwg.artifact"))]
|
|
273
|
+
: undefined;
|
|
274
|
+
const requestedLimit = options.limit ?? 10;
|
|
275
|
+
const includesGenericRecordType = fortemiTypes?.includes("aiwg.artifact") ?? false;
|
|
276
|
+
const { queryAiwgFortemiIndex } = await import("@fortemi/core/aiwg-index");
|
|
277
|
+
const queried = queryAiwgFortemiIndex(loaded.exported, options.text, {
|
|
278
|
+
// `template`, `runbook`, and `hook` are intentionally represented by the
|
|
279
|
+
// server-owned generic aiwg.artifact record type. Overfetch before the
|
|
280
|
+
// exact artifact-type post-filter so unrelated generic artifacts cannot
|
|
281
|
+
// crowd the requested operational type out of the candidate window.
|
|
282
|
+
limit: includesGenericRecordType ? loaded.exported.items.length : requestedLimit,
|
|
283
|
+
rank: true,
|
|
284
|
+
includeMatches: false,
|
|
285
|
+
searchProfile: "aiwg-discovery",
|
|
286
|
+
...(fortemiTypes && fortemiTypes.length > 0 ? { types: fortemiTypes } : {}),
|
|
287
|
+
});
|
|
288
|
+
const rankedItems = queried.rankedItems ??
|
|
289
|
+
queried.items.map((item, index) => ({
|
|
290
|
+
item,
|
|
291
|
+
rank: queried.items.length - index,
|
|
292
|
+
}));
|
|
293
|
+
const maxRank = Math.max(1, ...rankedItems.map((result) => typeof result.rank === "number" ? result.rank : 0));
|
|
294
|
+
const results = rankedItems
|
|
295
|
+
.map((result, index) => {
|
|
296
|
+
const entry = entryFromRecord(result.item);
|
|
297
|
+
return {
|
|
298
|
+
entry,
|
|
299
|
+
score: typeof result.rank === "number"
|
|
300
|
+
? result.rank / maxRank
|
|
301
|
+
: (rankedItems.length - index) / rankedItems.length,
|
|
302
|
+
};
|
|
303
|
+
})
|
|
304
|
+
.filter((result) => !typeSet || typeSet.has(result.entry.type))
|
|
305
|
+
.slice(0, requestedLimit);
|
|
306
|
+
return { results };
|
|
307
|
+
}
|
|
308
|
+
export function buildFortemiCoreArtifactIndex(cwd, graph = "project") {
|
|
309
|
+
const loaded = loadFortemiCoreExport(cwd, graph);
|
|
310
|
+
if (!loaded.exported)
|
|
311
|
+
return null;
|
|
312
|
+
const entries = loaded.exported.items.map(entryFromRecord);
|
|
313
|
+
return {
|
|
314
|
+
version: "fortemi-core-v2",
|
|
315
|
+
builtAt: new Date(0).toISOString(),
|
|
316
|
+
buildTimeMs: 0,
|
|
317
|
+
entries: Object.fromEntries(entries.map((entry) => [entry.path, entry])),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
export function buildFortemiCoreDependencyGraph(cwd, graph = "project") {
|
|
321
|
+
const loaded = loadFortemiCoreExport(cwd, graph);
|
|
322
|
+
if (!loaded.exported)
|
|
323
|
+
return { reason: loaded.reason };
|
|
324
|
+
const dependencyGraph = {};
|
|
325
|
+
for (const record of loaded.exported.items) {
|
|
326
|
+
const sourcePath = record.source.path;
|
|
327
|
+
dependencyGraph[sourcePath] ??= { upstream: [], downstream: [] };
|
|
328
|
+
for (const relationship of record.relationships) {
|
|
329
|
+
const targetPath = relationship.target_path ??
|
|
330
|
+
relationship.source_path ??
|
|
331
|
+
relationship.target_id;
|
|
332
|
+
if (!targetPath || relationship.direction === "related")
|
|
333
|
+
continue;
|
|
334
|
+
const direction = relationship.direction ?? "upstream";
|
|
335
|
+
dependencyGraph[sourcePath][direction].push({
|
|
336
|
+
path: targetPath,
|
|
337
|
+
type: relationship.type,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return { graph: dependencyGraph };
|
|
342
|
+
}
|
|
343
|
+
export function queryFortemiCoreStaticSemanticIndex(cwd, options) {
|
|
344
|
+
const loaded = loadFortemiCoreExport(cwd, options.graph ?? "project");
|
|
345
|
+
if (!loaded.exported)
|
|
346
|
+
return {
|
|
347
|
+
results: [],
|
|
348
|
+
reason: loaded.reason ?? "Fortemi Core static index is unavailable.",
|
|
349
|
+
};
|
|
350
|
+
const terms = tokenize(options.text);
|
|
351
|
+
if (terms.length === 0)
|
|
352
|
+
return { results: [] };
|
|
353
|
+
const results = loaded.exported.items
|
|
354
|
+
.map((record) => {
|
|
355
|
+
const scored = scoreStaticRecord(record, terms);
|
|
356
|
+
return { record, ...scored };
|
|
357
|
+
})
|
|
358
|
+
.filter((result) => result.score > 0)
|
|
359
|
+
.sort((a, b) => b.score - a.score ||
|
|
360
|
+
a.record.source.path.localeCompare(b.record.source.path))
|
|
361
|
+
.slice(0, options.limit ?? 10)
|
|
362
|
+
.map((result) => recordToStaticResult(result.record, result.score, result.matched));
|
|
363
|
+
return { results };
|
|
364
|
+
}
|
|
365
|
+
export function queryFortemiCoreStaticFulltextIndex(cwd, options) {
|
|
366
|
+
const loaded = loadFortemiCoreExport(cwd, options.graph ?? "project");
|
|
367
|
+
if (!loaded.exported)
|
|
368
|
+
return {
|
|
369
|
+
results: [],
|
|
370
|
+
reason: loaded.reason ?? "Fortemi Core static index is unavailable.",
|
|
371
|
+
};
|
|
372
|
+
const recordsByPath = new Map();
|
|
373
|
+
const docs = [];
|
|
374
|
+
const tags = new Set((options.tags ?? []).map((tag) => tag.toLowerCase()));
|
|
375
|
+
for (const record of loaded.exported.items) {
|
|
376
|
+
if (options.path && !matchesPath(record.source.path, options.path))
|
|
377
|
+
continue;
|
|
378
|
+
if (options.type && artifactTypeFromRecord(record) !== options.type)
|
|
379
|
+
continue;
|
|
380
|
+
if (options.phase && record.search?.phase !== options.phase)
|
|
381
|
+
continue;
|
|
382
|
+
if (tags.size > 0) {
|
|
383
|
+
const recordTags = new Set(record.tags.map((tag) => tag.toLowerCase()));
|
|
384
|
+
let hasAllTags = true;
|
|
385
|
+
for (const tag of tags) {
|
|
386
|
+
if (!recordTags.has(tag)) {
|
|
387
|
+
hasAllTags = false;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (!hasAllTags)
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
const body = recordBody(record);
|
|
395
|
+
if (!body.trim())
|
|
396
|
+
continue;
|
|
397
|
+
recordsByPath.set(record.source.path, record);
|
|
398
|
+
docs.push({ id: record.source.path, text: body });
|
|
399
|
+
}
|
|
400
|
+
const hits = bm25Rank(docs, options.text);
|
|
401
|
+
return {
|
|
402
|
+
results: hits.slice(0, options.limit ?? 20).map((hit) => {
|
|
403
|
+
const record = recordsByPath.get(hit.id);
|
|
404
|
+
return {
|
|
405
|
+
path: record.source.path,
|
|
406
|
+
type: artifactTypeFromRecord(record),
|
|
407
|
+
phase: record.search?.phase ?? record.facets.phase?.[0] ?? "",
|
|
408
|
+
tags: record.tags,
|
|
409
|
+
title: record.title,
|
|
410
|
+
summary: record.summary ?? record.search?.summary ?? record.text,
|
|
411
|
+
score: Math.round(hit.score * 1000) / 1000,
|
|
412
|
+
matched: hit.matchedTerms,
|
|
413
|
+
...(record.operational_state
|
|
414
|
+
? { operational_state: operationalStateQueryProjection(record.operational_state) }
|
|
415
|
+
: {}),
|
|
416
|
+
};
|
|
417
|
+
}),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
export function queryFortemiCoreStaticHybridIndex(cwd, options) {
|
|
421
|
+
const loaded = loadFortemiCoreExport(cwd, options.graph ?? "project");
|
|
422
|
+
if (!loaded.exported)
|
|
423
|
+
return {
|
|
424
|
+
results: [],
|
|
425
|
+
reason: loaded.reason ?? "Fortemi Core static index is unavailable.",
|
|
426
|
+
};
|
|
427
|
+
const terms = tokenize(options.text);
|
|
428
|
+
const tags = new Set((options.tags ?? []).map((tag) => tag.toLowerCase()));
|
|
429
|
+
const results = loaded.exported.items
|
|
430
|
+
.filter((record) => {
|
|
431
|
+
if (options.path && !matchesPath(record.source.path, options.path))
|
|
432
|
+
return false;
|
|
433
|
+
if (options.type && artifactTypeFromRecord(record) !== options.type)
|
|
434
|
+
return false;
|
|
435
|
+
if (options.phase && record.search?.phase !== options.phase)
|
|
436
|
+
return false;
|
|
437
|
+
if (tags.size > 0) {
|
|
438
|
+
const recordTags = new Set(record.tags.map((tag) => tag.toLowerCase()));
|
|
439
|
+
for (const tag of tags) {
|
|
440
|
+
if (!recordTags.has(tag))
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return true;
|
|
445
|
+
})
|
|
446
|
+
.map((record) => {
|
|
447
|
+
const scored = scoreStaticRecord(record, terms);
|
|
448
|
+
let score = scored.score;
|
|
449
|
+
const matched = [...scored.matched];
|
|
450
|
+
if (options.path) {
|
|
451
|
+
score += 1;
|
|
452
|
+
matched.push("path");
|
|
453
|
+
}
|
|
454
|
+
if (options.type) {
|
|
455
|
+
score += 0.5;
|
|
456
|
+
matched.push("type");
|
|
457
|
+
}
|
|
458
|
+
if (options.phase) {
|
|
459
|
+
score += 0.5;
|
|
460
|
+
matched.push("phase");
|
|
461
|
+
}
|
|
462
|
+
if (tags.size > 0) {
|
|
463
|
+
score += tags.size * 0.5;
|
|
464
|
+
matched.push("tags");
|
|
465
|
+
}
|
|
466
|
+
return { record, score, matched };
|
|
467
|
+
})
|
|
468
|
+
.filter((result) => result.score > 0)
|
|
469
|
+
.sort((a, b) => b.score - a.score ||
|
|
470
|
+
a.record.source.path.localeCompare(b.record.source.path))
|
|
471
|
+
.slice(0, options.limit ?? 10)
|
|
472
|
+
.map((result) => recordToStaticResult(result.record, result.score, result.matched));
|
|
473
|
+
return { results };
|
|
474
|
+
}
|
|
475
|
+
//# sourceMappingURL=fortemi-core-query-adapter.js.map
|