@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,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Research-corpus markdown-view renderers (#1490).
|
|
3
|
+
*
|
|
4
|
+
* TypeScript port of build.py's 12 renderers. Output is byte-identical to the
|
|
5
|
+
* Python source (modulo the volatile `Generated:` line). Trailing-newline and
|
|
6
|
+
* `.rstrip()` behavior is preserved per-renderer because the golden fixtures
|
|
7
|
+
* diff exactly.
|
|
8
|
+
*
|
|
9
|
+
* @source historical: corpus-index-build/build.py
|
|
10
|
+
*/
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import { PIPELINE_STAGES, SIZE_TIERS } from './taxonomies.js';
|
|
13
|
+
import { compareRefId, refSortKey, normalizeAuthor, loadProfileSlugs } from './ref-parser.js';
|
|
14
|
+
import { computeStaleness } from './corpus-config.js';
|
|
15
|
+
function header(title, ctx, count) {
|
|
16
|
+
return [
|
|
17
|
+
`# ${title}`,
|
|
18
|
+
'',
|
|
19
|
+
`Generated: ${ctx.generated}`,
|
|
20
|
+
`Sources: ${count} references`,
|
|
21
|
+
`Source-Checksum: sha256:${ctx.checksum}`,
|
|
22
|
+
'',
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
function refLink(r) {
|
|
26
|
+
return `**${r.refId}** — ${r.title}`;
|
|
27
|
+
}
|
|
28
|
+
/** Stable multi-key sort. Each key fn returns a comparable (number or string); arrays compared element-wise. */
|
|
29
|
+
function sortByKeys(arr, keyFn) {
|
|
30
|
+
return [...arr].sort((a, b) => {
|
|
31
|
+
const ka = keyFn(a), kb = keyFn(b);
|
|
32
|
+
for (let i = 0; i < ka.length; i++) {
|
|
33
|
+
const x = ka[i], y = kb[i];
|
|
34
|
+
if (x < y)
|
|
35
|
+
return -1;
|
|
36
|
+
if (x > y)
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
return 0;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function bySortedRefs(records) {
|
|
43
|
+
return [...records].sort((a, b) => compareRefId(a.refId, b.refId));
|
|
44
|
+
}
|
|
45
|
+
function renderGrouped(title, ctx, groups, trailingLabel = 'Uncategorized') {
|
|
46
|
+
const lines = header(title, ctx, ctx.records.length);
|
|
47
|
+
const names = sortByKeys([...groups.keys()], (n) => [n === trailingLabel, -groups.get(n).length, n.toLowerCase()]);
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
const items = bySortedRefs(groups.get(name));
|
|
50
|
+
lines.push(`## ${name} (${items.length} papers)`, '');
|
|
51
|
+
for (const r of items)
|
|
52
|
+
lines.push(`- ${refLink(r)}`);
|
|
53
|
+
lines.push('');
|
|
54
|
+
}
|
|
55
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
56
|
+
}
|
|
57
|
+
function groupBy(records, keyFn) {
|
|
58
|
+
const groups = new Map();
|
|
59
|
+
for (const r of records) {
|
|
60
|
+
for (const key of keyFn(r)) {
|
|
61
|
+
if (!groups.has(key))
|
|
62
|
+
groups.set(key, []);
|
|
63
|
+
groups.get(key).push(r);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return groups;
|
|
67
|
+
}
|
|
68
|
+
function renderByYear(ctx) {
|
|
69
|
+
const groups = groupBy(ctx.records, (r) => [r.year ? String(r.year) : 'Year Unknown']);
|
|
70
|
+
const lines = header('Index: Papers by Year', ctx, ctx.records.length);
|
|
71
|
+
const years = sortByKeys([...groups.keys()], (y) => [y === 'Year Unknown' ? -1 : -parseInt(y, 10), y]);
|
|
72
|
+
for (const year of years) {
|
|
73
|
+
const items = bySortedRefs(groups.get(year));
|
|
74
|
+
lines.push(`## ${year} (${items.length} papers)`, '');
|
|
75
|
+
for (const r of items)
|
|
76
|
+
lines.push(`- ${refLink(r)}`);
|
|
77
|
+
lines.push('');
|
|
78
|
+
}
|
|
79
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
80
|
+
}
|
|
81
|
+
function renderAuthors(ctx) {
|
|
82
|
+
const groups = groupBy(ctx.records, (r) => (r.authors.length ? r.authors : ['(no authors listed)']).map(normalizeAuthor));
|
|
83
|
+
const lines = header('Index: Papers by Author', ctx, ctx.records.length);
|
|
84
|
+
lines.push('Sorted alphabetically by normalized author name.', '');
|
|
85
|
+
for (const author of [...groups.keys()].sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : a.toLowerCase() > b.toLowerCase() ? 1 : 0))) {
|
|
86
|
+
const items = bySortedRefs(groups.get(author));
|
|
87
|
+
if (items.length === 1) {
|
|
88
|
+
lines.push(`- **${author}** — ${items[0].refId}: ${items[0].title}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
lines.push(`- **${author}** (${items.length} papers)`);
|
|
92
|
+
for (const r of items)
|
|
93
|
+
lines.push(` - ${r.refId}: ${r.title}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
97
|
+
}
|
|
98
|
+
function authorSlug(author) {
|
|
99
|
+
return author.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').replace(/- /g, '-');
|
|
100
|
+
}
|
|
101
|
+
function renderEntityAuthors(ctx) {
|
|
102
|
+
const profiles = loadProfileSlugs(ctx.corpusRoot);
|
|
103
|
+
const counts = groupBy(ctx.records, (r) => (r.authors.length ? r.authors : ['(no authors listed)']).map(normalizeAuthor));
|
|
104
|
+
const lines = header('Authors Index (Enriched)', ctx, ctx.records.length);
|
|
105
|
+
lines.push('| Author | Papers | Top Hub Authored | Profile | REFs |', '|---|---:|---|---|---|');
|
|
106
|
+
const entries = sortByKeys([...counts.entries()], ([author, items]) => [-items.length, author.toLowerCase()]);
|
|
107
|
+
for (const [author, items] of entries) {
|
|
108
|
+
const refs = [...new Set(items.map((r) => r.refId))].sort(compareRefId);
|
|
109
|
+
const top = items.reduce((best, r) => (best === null || r.incoming.size > best.incoming.size ? r : best), null);
|
|
110
|
+
const slug = authorSlug(author);
|
|
111
|
+
const profile = profiles.has(slug) ? `[PROF-P-${slug}](../documentation/profiles/people/PROF-P-${slug}.md)` : '-';
|
|
112
|
+
const refsCol = `${refs.slice(0, 12).join(', ')}${refs.length > 12 ? '...' : ''}`;
|
|
113
|
+
lines.push(`| ${author} | ${refs.length} | ${top ? top.refId : '-'} (${top ? top.incoming.size : 0}) | ${profile} | ${refsCol} |`);
|
|
114
|
+
}
|
|
115
|
+
return lines.join('\n') + '\n';
|
|
116
|
+
}
|
|
117
|
+
/** Stable count of values, preserving first-seen order (mirrors Counter.most_common tie behavior). */
|
|
118
|
+
function topCounted(values, n) {
|
|
119
|
+
const counts = new Map();
|
|
120
|
+
for (const v of values)
|
|
121
|
+
counts.set(v, (counts.get(v) ?? 0) + 1);
|
|
122
|
+
return sortByKeys([...counts.keys()], (k) => [-counts.get(k)]).slice(0, n);
|
|
123
|
+
}
|
|
124
|
+
function renderOrgs(ctx) {
|
|
125
|
+
const groups = new Map();
|
|
126
|
+
const orgAuthors = new Map();
|
|
127
|
+
for (const r of ctx.records) {
|
|
128
|
+
const org = r.primaryAffiliation || '(no affiliation listed)';
|
|
129
|
+
if (!groups.has(org)) {
|
|
130
|
+
groups.set(org, []);
|
|
131
|
+
orgAuthors.set(org, []);
|
|
132
|
+
}
|
|
133
|
+
groups.get(org).push(r);
|
|
134
|
+
for (const a of r.authors.slice(0, 3))
|
|
135
|
+
orgAuthors.get(org).push(normalizeAuthor(a));
|
|
136
|
+
}
|
|
137
|
+
const lines = header('Affiliations Index', ctx, ctx.records.length);
|
|
138
|
+
lines.push('| Affiliation | Papers | Top Authors | REFs |', '|---|---:|---|---|');
|
|
139
|
+
const entries = sortByKeys([...groups.entries()], ([org, items]) => [-items.length, org.toLowerCase()]);
|
|
140
|
+
for (const [org, items] of entries) {
|
|
141
|
+
const refs = [...new Set(items.map((r) => r.refId))].sort(compareRefId);
|
|
142
|
+
const topAuthors = topCounted(orgAuthors.get(org), 3).join(', ') || '-';
|
|
143
|
+
const refsCol = `${refs.slice(0, 12).join(', ')}${refs.length > 12 ? '...' : ''}`;
|
|
144
|
+
lines.push(`| ${org} | ${refs.length} | ${topAuthors} | ${refsCol} |`);
|
|
145
|
+
}
|
|
146
|
+
return lines.join('\n') + '\n';
|
|
147
|
+
}
|
|
148
|
+
function renderBridges(ctx) {
|
|
149
|
+
const authorOrgs = new Map();
|
|
150
|
+
const authorRefs = new Map();
|
|
151
|
+
for (const r of ctx.records) {
|
|
152
|
+
for (const a of r.authors) {
|
|
153
|
+
const norm = normalizeAuthor(a);
|
|
154
|
+
if (!authorOrgs.has(norm)) {
|
|
155
|
+
authorOrgs.set(norm, new Set());
|
|
156
|
+
authorRefs.set(norm, new Set());
|
|
157
|
+
}
|
|
158
|
+
if (r.primaryAffiliation)
|
|
159
|
+
authorOrgs.get(norm).add(r.primaryAffiliation);
|
|
160
|
+
authorRefs.get(norm).add(r.refId);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const lines = header('Bridge Authors', ctx, ctx.records.length);
|
|
164
|
+
lines.push('Authors whose corpus papers span two or more distinct affiliations.', '', '| Author | Affiliations | Papers | REFs |', '|---|---:|---:|---|');
|
|
165
|
+
const rows = [...authorOrgs.entries()].filter(([, orgs]) => orgs.size >= 2).map(([a, orgs]) => ({ a, orgs, refs: authorRefs.get(a) }));
|
|
166
|
+
const sorted = sortByKeys(rows, (row) => [-row.orgs.size, -row.refs.size, row.a.toLowerCase()]);
|
|
167
|
+
for (const { a, orgs, refs } of sorted) {
|
|
168
|
+
const sortedRefs = [...refs].sort(compareRefId);
|
|
169
|
+
const refsCol = `${sortedRefs.slice(0, 12).join(', ')}${sortedRefs.length > 12 ? '...' : ''}`;
|
|
170
|
+
lines.push(`| ${a} | ${orgs.size} | ${refs.size} | ${refsCol} |`);
|
|
171
|
+
}
|
|
172
|
+
return lines.join('\n') + '\n';
|
|
173
|
+
}
|
|
174
|
+
function renderUnprofiledHubs(ctx) {
|
|
175
|
+
const profileSlugs = loadProfileSlugs(ctx.corpusRoot);
|
|
176
|
+
const lines = header('Unprofiled Top Hubs', ctx, ctx.records.length);
|
|
177
|
+
lines.push('Top in-degree REFs whose primary author does not appear to have a PROF-P profile.', '', '| REF | In-deg | Primary Author | Title |', '|---|---:|---|---|');
|
|
178
|
+
const sorted = sortByKeys(ctx.records, (r) => [-r.incoming.size, ...refSortKey(r.refId)]);
|
|
179
|
+
let emitted = 0;
|
|
180
|
+
for (const r of sorted) {
|
|
181
|
+
if (!r.authors.length)
|
|
182
|
+
continue;
|
|
183
|
+
const author = normalizeAuthor(r.authors[0]);
|
|
184
|
+
const slug = author.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
185
|
+
if (profileSlugs.has(slug))
|
|
186
|
+
continue;
|
|
187
|
+
lines.push(`| ${r.refId} | ${r.incoming.size} | ${author} | ${r.title.slice(0, 80)} |`);
|
|
188
|
+
if (++emitted >= 50)
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
return lines.join('\n') + '\n';
|
|
192
|
+
}
|
|
193
|
+
function renderCitationNetwork(ctx) {
|
|
194
|
+
const nodes = ctx.records.length;
|
|
195
|
+
const edges = ctx.records.reduce((sum, r) => sum + r.outgoing.size, 0);
|
|
196
|
+
const lines = header('Citation Network', ctx, nodes);
|
|
197
|
+
const density = nodes > 1 ? edges / (nodes * (nodes - 1)) : 0;
|
|
198
|
+
lines.push(`Nodes: ${nodes} | Edges: ${edges} | Density: ${density.toFixed(4)}`, '', '## Top Hubs', '', '| REF | Title | In | Out | Total |', '|---|---|---:|---:|---:|');
|
|
199
|
+
const hubs = sortByKeys(ctx.records, (r) => [-(r.incoming.size + r.outgoing.size), ...refSortKey(r.refId)]).slice(0, 25);
|
|
200
|
+
for (const r of hubs) {
|
|
201
|
+
lines.push(`| ${r.refId} | ${r.title.slice(0, 80)} | ${r.incoming.size} | ${r.outgoing.size} | ${r.incoming.size + r.outgoing.size} |`);
|
|
202
|
+
}
|
|
203
|
+
const isolated = ctx.records.filter((r) => !r.incoming.size && !r.outgoing.size);
|
|
204
|
+
lines.push('', `## Isolated Nodes (${isolated.length})`, '', '| REF | Title |', '|---|---|');
|
|
205
|
+
for (const r of bySortedRefs(isolated).slice(0, 200)) {
|
|
206
|
+
lines.push(`| ${r.refId} | ${r.title.slice(0, 100)} |`);
|
|
207
|
+
}
|
|
208
|
+
return lines.join('\n') + '\n';
|
|
209
|
+
}
|
|
210
|
+
function renderModelSize(ctx) {
|
|
211
|
+
const groups = groupBy(ctx.records, (r) => [r.sizeTier || 'Not Applicable / No Extractable Size']);
|
|
212
|
+
const lines = header('Index: Papers by Model Size', ctx, ctx.records.length);
|
|
213
|
+
const tierOrder = [...SIZE_TIERS.map((t) => t[0]), 'Not Applicable / No Extractable Size'];
|
|
214
|
+
for (const tier of tierOrder) {
|
|
215
|
+
const items = groups.get(tier);
|
|
216
|
+
if (!items)
|
|
217
|
+
continue;
|
|
218
|
+
lines.push(`## ${tier} (${items.length} papers)`, '');
|
|
219
|
+
const sorted = sortByKeys(items, (r) => [-(r.paramsM ?? 0), ...refSortKey(r.refId)]);
|
|
220
|
+
for (const r of sorted) {
|
|
221
|
+
const size = r.paramsM && r.paramsM >= 1000 ? ` [${(r.paramsM / 1000).toFixed(1)}B]` : r.paramsM ? ` [${Math.round(r.paramsM)}M]` : '';
|
|
222
|
+
lines.push(`- **${r.refId}**${size} — ${r.title}`);
|
|
223
|
+
}
|
|
224
|
+
lines.push('');
|
|
225
|
+
}
|
|
226
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
227
|
+
}
|
|
228
|
+
function renderPipeline(ctx) {
|
|
229
|
+
const available = new Set(ctx.records.map((r) => r.refId));
|
|
230
|
+
const lines = header('Index: Training Pipeline Reading Order', ctx, ctx.records.length);
|
|
231
|
+
lines.push('Stages move from data preparation through training, alignment, deployment, and monitoring.', '');
|
|
232
|
+
for (const [title, blurb, refs] of PIPELINE_STAGES) {
|
|
233
|
+
lines.push(`## ${title}`, '', `_${blurb}_`, '');
|
|
234
|
+
for (const ref of refs) {
|
|
235
|
+
lines.push(`- **${ref}${available.has(ref) ? '' : ' (not in corpus)'}**`);
|
|
236
|
+
}
|
|
237
|
+
lines.push('');
|
|
238
|
+
}
|
|
239
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
240
|
+
}
|
|
241
|
+
// ── Radar / discovery / funder views (#1492) ──────────────────────────────
|
|
242
|
+
// Cadence → window math lives in corpus-config.ts (the one staleness helper, #1498/#1502).
|
|
243
|
+
/** GRADE display order; unknown grades fall after, 'Ungraded' last. */
|
|
244
|
+
const GRADE_ORDER = ['A', 'A-', 'B', 'B-', 'C', 'C-', 'D'];
|
|
245
|
+
/** Papers grouped by current GRADE (radar `grade-current`); no-radar → Ungraded. (#1492) */
|
|
246
|
+
function renderByGrade(ctx) {
|
|
247
|
+
const groups = groupBy(ctx.records, (r) => [r.radar?.gradeCurrent || 'Ungraded']);
|
|
248
|
+
const lines = header('Index: Papers by GRADE', ctx, ctx.records.length);
|
|
249
|
+
const names = [...groups.keys()].sort((a, b) => {
|
|
250
|
+
if (a === 'Ungraded')
|
|
251
|
+
return 1;
|
|
252
|
+
if (b === 'Ungraded')
|
|
253
|
+
return -1;
|
|
254
|
+
const ia = GRADE_ORDER.indexOf(a);
|
|
255
|
+
const ib = GRADE_ORDER.indexOf(b);
|
|
256
|
+
const ra = ia === -1 ? GRADE_ORDER.length : ia;
|
|
257
|
+
const rb = ib === -1 ? GRADE_ORDER.length : ib;
|
|
258
|
+
return ra !== rb ? ra - rb : a < b ? -1 : a > b ? 1 : 0;
|
|
259
|
+
});
|
|
260
|
+
for (const name of names) {
|
|
261
|
+
const items = bySortedRefs(groups.get(name));
|
|
262
|
+
lines.push(`## ${name} (${items.length} papers)`, '');
|
|
263
|
+
for (const r of items)
|
|
264
|
+
lines.push(`- ${refLink(r)}`);
|
|
265
|
+
lines.push('');
|
|
266
|
+
}
|
|
267
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
268
|
+
}
|
|
269
|
+
/** Radar-tracked papers ranked by overdue-ness (cadence window vs last-refreshed). (#1492) */
|
|
270
|
+
function renderStaleQueue(ctx) {
|
|
271
|
+
const today = new Date(`${ctx.generated.slice(0, 10)}T00:00:00Z`);
|
|
272
|
+
const rows = [];
|
|
273
|
+
for (const r of ctx.records) {
|
|
274
|
+
const rad = r.radar;
|
|
275
|
+
if (!rad || !rad.refreshCadence || !rad.lastRefreshed)
|
|
276
|
+
continue;
|
|
277
|
+
const { overdueDays } = computeStaleness(rad.refreshCadence, rad.lastRefreshed, today);
|
|
278
|
+
if (overdueDays === null)
|
|
279
|
+
continue; // on-demand / unknown cadence / unparseable date → not queued
|
|
280
|
+
rows.push({ r, cadence: rad.refreshCadence, last: rad.lastRefreshed, overdue: overdueDays });
|
|
281
|
+
}
|
|
282
|
+
const sorted = sortByKeys(rows, (row) => [-row.overdue, ...refSortKey(row.r.refId)]);
|
|
283
|
+
const staleCount = sorted.filter((x) => x.overdue > 0).length;
|
|
284
|
+
const lines = header('Index: Radar Stale-Refresh Queue', ctx, ctx.records.length);
|
|
285
|
+
lines.push(`Overdue = days since last refresh minus the cadence window. ${staleCount} of ${rows.length} radar-tracked papers are overdue.`, '', '| REF | Title | GRADE | Cadence | Last Refreshed | Overdue (days) | Stale |', '|---|---|---|---|---|---:|---|');
|
|
286
|
+
for (const { r, cadence, last, overdue } of sorted) {
|
|
287
|
+
lines.push(`| ${r.refId} | ${r.title.slice(0, 70)} | ${r.radar.gradeCurrent ?? '—'} | ${cadence} | ${last} | ${overdue} | ${overdue > 0 ? 'yes' : 'no'} |`);
|
|
288
|
+
}
|
|
289
|
+
return lines.join('\n') + '\n';
|
|
290
|
+
}
|
|
291
|
+
/** Supported renderer names — `name` in the index.graphs.indices.manifest selects one of these. */
|
|
292
|
+
/**
|
|
293
|
+
* Cross-project impact (#1495): refs ranked by how many downstream projects
|
|
294
|
+
* cite them (from the "Referenced By" table). Surfaces what's load-bearing
|
|
295
|
+
* across the org.
|
|
296
|
+
*/
|
|
297
|
+
function renderProjectImpact(ctx) {
|
|
298
|
+
const ranked = ctx.records
|
|
299
|
+
.filter((r) => r.referencedByProjects.length > 0)
|
|
300
|
+
.sort((a, b) => b.referencedByProjects.length - a.referencedByProjects.length || compareRefId(a.refId, b.refId));
|
|
301
|
+
const lines = header('Index: Cross-Project Impact', ctx, ranked.length);
|
|
302
|
+
lines.push('Refs ranked by number of consuming projects (downstream "Referenced By").', '');
|
|
303
|
+
lines.push('| Rank | REF | Projects | Consuming projects |', '|---|---|---:|---|');
|
|
304
|
+
ranked.forEach((r, i) => {
|
|
305
|
+
lines.push(`| ${i + 1} | ${refLink(r)} | ${r.referencedByProjects.length} | ${r.referencedByProjects.join(', ')} |`);
|
|
306
|
+
});
|
|
307
|
+
return lines.join('\n').replace(/\s+$/, '') + '\n';
|
|
308
|
+
}
|
|
309
|
+
export const SUPPORTED_VIEWS = [
|
|
310
|
+
'by-year', 'by-topic', 'authors', 'by-venue', 'by-method', 'by-model-size',
|
|
311
|
+
'training-pipeline', 'citation-network', 'by-author', 'by-org', 'by-bridge', 'unprofiled-hubs',
|
|
312
|
+
// radar / discovery / funder views (#1492)
|
|
313
|
+
'by-grade', 'radar-stale-queue', 'by-trajectory', 'by-source', 'by-curator', 'by-funder',
|
|
314
|
+
// source-type view (#1509)
|
|
315
|
+
'by-source-type',
|
|
316
|
+
// cross-project views (#1495)
|
|
317
|
+
'by-project', 'project-impact',
|
|
318
|
+
];
|
|
319
|
+
/** Render one named view. Throws on an unsupported name (mirrors build.py build_graph). */
|
|
320
|
+
export function renderView(name, ctx) {
|
|
321
|
+
switch (name) {
|
|
322
|
+
case 'by-year': return renderByYear(ctx);
|
|
323
|
+
case 'by-topic': return renderGrouped('Index: Papers by Topic', ctx, groupBy(ctx.records, (r) => r.topics));
|
|
324
|
+
case 'authors': return renderAuthors(ctx);
|
|
325
|
+
case 'by-venue': return renderGrouped('Index: Papers by Venue', ctx, groupBy(ctx.records, (r) => [r.venue || 'Unmatched']));
|
|
326
|
+
case 'by-method': return renderGrouped('Index: Papers by Method', ctx, groupBy(ctx.records, (r) => r.methods));
|
|
327
|
+
case 'by-model-size': return renderModelSize(ctx);
|
|
328
|
+
case 'training-pipeline': return renderPipeline(ctx);
|
|
329
|
+
case 'citation-network': return renderCitationNetwork(ctx);
|
|
330
|
+
case 'by-author': return renderEntityAuthors(ctx);
|
|
331
|
+
case 'by-org': return renderOrgs(ctx);
|
|
332
|
+
case 'by-bridge': return renderBridges(ctx);
|
|
333
|
+
case 'unprofiled-hubs': return renderUnprofiledHubs(ctx);
|
|
334
|
+
// Radar / discovery / funder views (#1492)
|
|
335
|
+
case 'by-grade': return renderByGrade(ctx);
|
|
336
|
+
case 'radar-stale-queue': return renderStaleQueue(ctx);
|
|
337
|
+
case 'by-trajectory': return renderGrouped('Index: Papers by GRADE Trajectory', ctx, groupBy(ctx.records, (r) => [r.radar?.gradeTrajectory || 'unknown']), 'unknown');
|
|
338
|
+
case 'by-source': return renderGrouped('Index: Papers by Discovery Surface', ctx, groupBy(ctx.records, (r) => [r.discovery?.surface || 'unknown-surface']), 'unknown-surface');
|
|
339
|
+
case 'by-curator': return renderGrouped('Index: Papers by Curator', ctx, groupBy(ctx.records, (r) => [r.discovery?.curatorId || 'no-curator']), 'no-curator');
|
|
340
|
+
case 'by-funder': return renderGrouped('Index: Papers by Funder', ctx, groupBy(ctx.records, (r) => (r.funders.length ? r.funders.map((f) => f.id) : ['unfunded'])), 'unfunded');
|
|
341
|
+
// Source-type view (#1509) — groups refs by the canonical source type the registry normalizes to.
|
|
342
|
+
case 'by-source-type': return renderGrouped('Index: Sources by Type', ctx, groupBy(ctx.records, (r) => [r.sourceType || 'other']), 'other');
|
|
343
|
+
// Cross-project views (#1495) — consuming-project grouping + impact ranking.
|
|
344
|
+
case 'by-project': return renderGrouped('Index: Refs by Consuming Project', ctx, groupBy(ctx.records, (r) => (r.referencedByProjects.length ? r.referencedByProjects : ['(no consuming project)'])), '(no consuming project)');
|
|
345
|
+
case 'project-impact': return renderProjectImpact(ctx);
|
|
346
|
+
default: throw new Error(`unsupported graph: ${name}`);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
/** Default output path for a view: entry.output or indices/<name>.md. */
|
|
350
|
+
export function outputForView(name, output) {
|
|
351
|
+
return output ? output : path.join('indices', `${name}.md`);
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=renderers.js.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Corpus-view classifier taxonomies (#1490).
|
|
3
|
+
*
|
|
4
|
+
* Verbatim TypeScript port of the regex pattern tables from the retired
|
|
5
|
+
* research-complete `corpus-index-build/build.py`. Pattern order is
|
|
6
|
+
* load-bearing: `classifyFirst` returns the FIRST matching label, so reordering
|
|
7
|
+
* changes classification. All patterns are matched case-insensitively (the
|
|
8
|
+
* Python source compiled with `re.I`).
|
|
9
|
+
*
|
|
10
|
+
* @source historical: agentic/code/frameworks/research-complete/skills/corpus-index-build/build.py
|
|
11
|
+
*/
|
|
12
|
+
const ci = (src) => new RegExp(src, 'i');
|
|
13
|
+
/** Single-label topic classifier (first match wins). */
|
|
14
|
+
export const TOPIC_PATTERNS = [
|
|
15
|
+
['Reinforcement Learning & RLHF', ci('\\b(rlhf|reinforcement learning|rlvr|reward model|ppo|dpo|grpo)\\b')],
|
|
16
|
+
['Mechanistic Interpretability', ci('\\b(mechanistic interpret|circuit|feature attribution|sparse autoencoder|activation steering|probing)\\b')],
|
|
17
|
+
['AI Safety & Alignment', ci('\\b(alignment|misalign|sycophan|deception|jailbreak|red team|safety|constitutional ai)\\b')],
|
|
18
|
+
['Agentic Workflows & Multi-Agent', ci('\\b(agentic|multi-agent|multi[- ]agent|tool use|orchestrat|autogen|agent loop)\\b')],
|
|
19
|
+
['Retrieval & RAG', ci('\\b(rag|retrieval[- ]augmented|dense retriev|reranker|bm25|colbert|hybrid retriev)\\b')],
|
|
20
|
+
['Embeddings & Vector Search', ci('\\b(embedding|sentence-bert|hnsw|ann |vector search|matryoshka)\\b')],
|
|
21
|
+
['Reasoning & Chain-of-Thought', ci('\\b(chain[- ]of[- ]thought|reasoning|self-refine|self-consist|cot prompt|thought)\\b')],
|
|
22
|
+
['Code Generation & Software Engineering', ci('\\b(code generation|code llama|humaneval|mbpp|swe-bench|copilot|coding assistant)\\b')],
|
|
23
|
+
['Fine-Tuning & PEFT', ci('\\b(lora|peft|fine[- ]tun|adapter|qlora|instruction tun)\\b')],
|
|
24
|
+
['Pretraining & Scaling Laws', ci('\\b(scaling laws|chinchilla|pretrain|compute[- ]optimal|emergent abilit)\\b')],
|
|
25
|
+
['Quantization & Compression', ci('\\b(quantization|pruning|gptq|awq|distillation|compression)\\b')],
|
|
26
|
+
['Inference & Serving Systems', ci('\\b(vllm|tensorrt|inference serv|kv cache|continuous batch|paged attention|serving)\\b')],
|
|
27
|
+
['Memory & Context', ci('\\b(long context|context window|memory augment|stateful|kv-cache memory)\\b')],
|
|
28
|
+
['Robotics & Embodied AI', ci('\\b(robot|embodied|manipulation|locomotion|vla |vision[- ]language[- ]action)\\b')],
|
|
29
|
+
['Multimodal', ci('\\b(multimodal|vision[- ]language|vlm|clip|image[- ]text)\\b')],
|
|
30
|
+
['Benchmarks & Evaluation', ci('\\b(benchmark|evaluat|helm|big-bench|mt-bench|leaderboard)\\b')],
|
|
31
|
+
['Knowledge Graphs & Symbolic', ci('\\b(knowledge graph|symbolic|ontolog|rdf|sparql)\\b')],
|
|
32
|
+
['Streaming & Event-Driven Systems', ci('\\b(kafka|redis stream|nats|event[- ]driven|cdc|change data capt|stream process)\\b')],
|
|
33
|
+
['Distributed Systems', ci('\\b(distributed system|consensus|raft|paxos|sharding|replicat)\\b')],
|
|
34
|
+
['Cryptography & Security', ci('\\b(cryptograph|threshold signature|frost|schnorr|hkdf|argon2|tpm|hsm|secure enclave)\\b')],
|
|
35
|
+
['Blockchain', ci('\\b(blockchain|proof of stake|ethereum|validator)\\b')],
|
|
36
|
+
['HCI & Developer Experience', ci('\\b(developer productiv|hci|cognitive load|user study|ux research|developer experience)\\b')],
|
|
37
|
+
['Theory of Mind & Social Reasoning', ci('\\b(theory of mind|tom |social reason|persuas|emotion)\\b')],
|
|
38
|
+
['Cognitive Science & Psychology', ci("\\b(cognitive scien|psycholog|metacognit|miller'?s law)\\b")],
|
|
39
|
+
['LLM Foundations & Surveys', ci('\\b(survey|foundation model|large language model|transformer architecture)\\b')],
|
|
40
|
+
['LLM Evaluation & Benchmarks', ci('\\b(llm|language model|gpt|claude|gemini|llama|mistral)\\b')],
|
|
41
|
+
];
|
|
42
|
+
/** Multi-label method classifier (all matches). */
|
|
43
|
+
export const METHOD_PATTERNS = [
|
|
44
|
+
['Quantization', ci('\\b(quantiz|gptq|awq|int4|int8|bf16|fp4|fp8|bitnet|smoothquant)\\b')],
|
|
45
|
+
['Pruning & Sparsity', ci('\\b(prun|sparsit|sparse model|magnitude prun|wanda|sparsegpt)\\b')],
|
|
46
|
+
['Distillation', ci('\\b(distill|distilbert|teacher[- ]student|knowledge distill)\\b')],
|
|
47
|
+
['PEFT / LoRA / Adapters', ci('\\b(lora|qlora|peft|adapter[- ]based|prefix tun|prompt tun|p-?tuning)\\b')],
|
|
48
|
+
['Fine-Tuning (Full)', ci('\\b(full fine[- ]tun|sft|supervised fine[- ]tun|instruction tun)\\b')],
|
|
49
|
+
['RLHF / DPO / RL-from-Feedback', ci('\\b(rlhf|dpo|ppo|grpo|reward model|kto|ipo|orpo|reinforcement learning from human)\\b')],
|
|
50
|
+
['RLVR / Verifiable Rewards', ci('\\b(rlvr|verifiable reward|rule[- ]based reward|self[- ]reward)\\b')],
|
|
51
|
+
['Alignment & Constitutional', ci('\\b(constitutional ai|alignment|rule[- ]based ai feedback|rlaif)\\b')],
|
|
52
|
+
['Chain-of-Thought / Reasoning', ci('\\b(chain[- ]of[- ]thought|cot prompt|self[- ]refine|self[- ]consist|tree of thoughts|react)\\b')],
|
|
53
|
+
['Self-Play / Self-Improvement', ci('\\b(self[- ]play|self[- ]improv|bootstrap|star algorithm|rstar)\\b')],
|
|
54
|
+
['Mixture of Experts', ci('\\b(mixture of experts|\\bmoe\\b|gshard|switch transformer|expert routing)\\b')],
|
|
55
|
+
['Retrieval-Augmented Generation', ci('\\b(retrieval[- ]augmented|\\brag\\b|fid |dense retriev|colbert)\\b')],
|
|
56
|
+
['Embedding & Vector Search', ci('\\b(embedding|sentence-bert|hnsw|matryoshka|vector index)\\b')],
|
|
57
|
+
['Attention Variants & Long Context', ci('\\b(flash attention|sliding window attention|sparse attention|paged attention|ring attention|alibi|rotary embedding|rope)\\b')],
|
|
58
|
+
['KV Cache & Inference Optimization', ci('\\b(kv[- ]cache|kv cache|continuous batching|paged attention|prefill|decode optimization|speculative decoding)\\b')],
|
|
59
|
+
['Serving & Batching Systems', ci('\\b(vllm|tensorrt|continuous batch|dynamic batch|inference serv|throughput optimization)\\b')],
|
|
60
|
+
['Pretraining & Scaling Laws', ci('\\b(scaling laws|chinchilla|compute[- ]optimal|pretrain|data mixing)\\b')],
|
|
61
|
+
['Data Curation & Synthesis', ci('\\b(data curation|data synthesis|synthetic data|deduplication|semdedup|dataset distill)\\b')],
|
|
62
|
+
['Evaluation & Benchmarking', ci('\\b(benchmark|evaluat|helm|big[- ]bench|mt[- ]bench|leaderboard|holistic evaluation)\\b')],
|
|
63
|
+
['Mechanistic Interpretability', ci('\\b(mechanistic interpret|circuit analysis|sparse autoencoder|\\bsae\\b|feature attribution|probing classifier|activation steering)\\b')],
|
|
64
|
+
['Agentic Orchestration & Tool Use', ci('\\b(agentic|multi[- ]agent|tool use|tool[- ]calling|autogen|orchestrat|agent loop|react)\\b')],
|
|
65
|
+
['Robotics / Embodied Learning', ci('\\b(robot|embodied|manipulation|locomotion|vla |vision[- ]language[- ]action|sim[- ]to[- ]real)\\b')],
|
|
66
|
+
['Multimodal / Vision-Language', ci('\\b(multimodal|vision[- ]language|\\bvlm\\b|clip|image[- ]text|visual instruction)\\b')],
|
|
67
|
+
['Diffusion / Generative Models', ci('\\b(diffusion model|ddpm|score[- ]based|latent diffusion|flow matching|stable diffusion)\\b')],
|
|
68
|
+
['Reinforcement Learning (Foundations)', ci('\\b(reinforcement learning|markov decision|q[- ]learning|actor[- ]critic|trpo|policy gradient)\\b')],
|
|
69
|
+
['Distributed Training & Parallelism', ci('\\b(zero|fsdp|tensor parallel|pipeline parallel|data parallel|megatron|deepspeed)\\b')],
|
|
70
|
+
];
|
|
71
|
+
/** Single-label venue classifier (first match wins). */
|
|
72
|
+
export const VENUE_PATTERNS = [
|
|
73
|
+
['NeurIPS', ci('\\b(neurips|nips)\\b')], ['ICML', ci('\\bicml\\b')], ['ICLR', ci('\\biclr\\b')],
|
|
74
|
+
['ACL', ci('\\b(acl |annual meeting of the association for computational linguistics)\\b')],
|
|
75
|
+
['EMNLP', ci('\\bemnlp\\b')], ['NAACL', ci('\\bnaacl\\b')], ['CVPR', ci('\\bcvpr\\b')],
|
|
76
|
+
['ICCV', ci('\\biccv\\b')], ['ECCV', ci('\\beccv\\b')], ['AAAI', ci('\\baaai\\b')],
|
|
77
|
+
['IJCAI', ci('\\bijcai\\b')], ['KDD', ci('\\b(kdd |sigkdd)\\b')], ['SIGIR', ci('\\bsigir\\b')],
|
|
78
|
+
['WWW', ci('\\b(www conference|the web conference)\\b')], ['RSS', ci('\\b(rss |robotics: science and systems)\\b')],
|
|
79
|
+
['CoRL', ci('\\bcorl\\b')], ['ICRA', ci('\\bicra\\b')], ['IROS', ci('\\biros\\b')],
|
|
80
|
+
['OSDI', ci('\\bosdi\\b')], ['SOSP', ci('\\bsosp\\b')], ['NSDI', ci('\\bnsdi\\b')],
|
|
81
|
+
['USENIX ATC', ci('\\busenix atc\\b')], ['USENIX Security', ci('\\busenix security\\b')],
|
|
82
|
+
['IEEE S&P / Oakland', ci('\\b(ieee s&p|ieee symposium on security|oakland)\\b')],
|
|
83
|
+
['CCS', ci("\\b(acm ccs|ccs '?\\d)\\b")], ['CHI', ci("\\b(chi conference|chi '?\\d)\\b")],
|
|
84
|
+
['UIST', ci('\\buist\\b')], ['VLDB', ci('\\bvldb\\b')], ['SIGMOD', ci('\\bsigmod\\b')],
|
|
85
|
+
['FAccT', ci('\\bfacct\\b')], ['TMLR', ci('\\btmlr\\b')], ['JMLR', ci('\\bjmlr\\b')],
|
|
86
|
+
['Nature', ci('\\b(nature\\b(?! communications)|nature\\.)')], ['Science', ci('\\bscience\\b(?! advances)')],
|
|
87
|
+
['PNAS', ci('\\bpnas\\b')], ['RFC (IETF)', ci('\\brfc \\d+\\b')], ['arXiv', ci('\\b(arxiv|preprint)\\b')],
|
|
88
|
+
['Anthropic Research', ci('\\b(anthropic\\.com|anthropic research|transformer circuits)\\b')],
|
|
89
|
+
['OpenAI Research', ci('\\bopenai\\.com\\b')], ['DeepMind / Google Research', ci('\\b(deepmind|google research|research\\.google)\\b')],
|
|
90
|
+
['Meta AI / FAIR', ci('\\b(meta ai|fair |facebook ai research)\\b')], ['Microsoft Research', ci('\\bmicrosoft research\\b')],
|
|
91
|
+
['GitHub / Documentation', ci('\\b(github\\.com|github pages|readthedocs|docs\\.\\w+)\\b')],
|
|
92
|
+
['Blog / Web Article', ci('\\b(blog|medium\\.com|substack|dev\\.to)\\b')], ['Wikipedia', ci('\\bwikipedia\\b')],
|
|
93
|
+
];
|
|
94
|
+
/** Size extraction patterns: [pattern, multiplier-to-millions]. Matched globally, case-insensitive. */
|
|
95
|
+
export const SIZE_PATTERNS = [
|
|
96
|
+
[/(\d+\.\d+|\d{1,4})\s*B\b(?:\s*parameters|\s*params|\s*model)?/gi, 1000],
|
|
97
|
+
[/(\d{1,4})\s*M\b(?:\s*parameters|\s*params|\s*model)?/gi, 1],
|
|
98
|
+
];
|
|
99
|
+
export const SIZE_TIERS = [
|
|
100
|
+
['<1B parameters', 0, 999],
|
|
101
|
+
['1-10B parameters', 1000, 9999],
|
|
102
|
+
['10-100B parameters', 10000, 99999],
|
|
103
|
+
['100B-1T parameters', 100000, 999999],
|
|
104
|
+
['1T+ parameters', 1000000, 10 ** 12],
|
|
105
|
+
];
|
|
106
|
+
export const PIPELINE_STAGES = [
|
|
107
|
+
['1. Data Curation & Preparation', 'Assembling, cleaning, and deduplicating pretraining and finetuning data.', ['REF-421', 'REF-460', 'REF-468', 'REF-471', 'REF-442']],
|
|
108
|
+
['2. Tokenization & Architecture Foundations', 'Tokenizer choice, architecture variants, and positional encodings.', ['REF-389', 'REF-500']],
|
|
109
|
+
['3. Pretraining at Scale', 'Compute-optimal recipes, scaling laws, and large-scale optimization.', ['REF-052', 'REF-054', 'REF-389', 'REF-437', 'REF-460']],
|
|
110
|
+
['4. Mixture-of-Experts & Sparse Architectures', 'Sparsely activated models as a parallel pretraining strategy.', ['REF-007']],
|
|
111
|
+
['5. Instruction Tuning & SFT', 'Supervised fine-tuning on instructions to convert base models into assistants.', ['REF-055', 'REF-435', 'REF-470']],
|
|
112
|
+
['6. RLHF, DPO, and Preference Optimization', 'Aligning models with human and AI feedback.', ['REF-025', 'REF-055', 'REF-449']],
|
|
113
|
+
['7. RLVR & Reasoning RL', 'Verifiable-reward RL for reasoning, math, and code.', ['REF-819', 'REF-957', 'REF-457']],
|
|
114
|
+
['8. PEFT / LoRA / Adapter-Based Adaptation', 'Parameter-efficient fine-tuning when full SFT is impractical.', ['REF-049']],
|
|
115
|
+
['9. Quantization, Pruning & Compression', 'Shrinking trained models for inference deployment.', ['REF-051']],
|
|
116
|
+
['10. Inference Serving & Optimization', 'Productionizing trained models: batching, KV cache, throughput.', ['REF-101', 'REF-102', 'REF-312', 'REF-313']],
|
|
117
|
+
['11. Evaluation, Safety & Continuous Monitoring', 'Holistic evaluation, red-teaming, and live monitoring.', ['REF-063', 'REF-064', 'REF-189', 'REF-191', 'REF-481']],
|
|
118
|
+
];
|
|
119
|
+
/** Return the first matching label, or null. Mirrors build.py `classify_first`. */
|
|
120
|
+
export function classifyFirst(text, patterns) {
|
|
121
|
+
for (const [label, pattern] of patterns) {
|
|
122
|
+
if (pattern.test(text))
|
|
123
|
+
return label;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/** Return all matching labels in table order. Mirrors build.py `classify_many`. */
|
|
128
|
+
export function classifyMany(text, patterns) {
|
|
129
|
+
return patterns.filter(([, pattern]) => pattern.test(text)).map(([label]) => label);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=taxonomies.js.map
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Dependency Graph
|
|
3
|
+
*
|
|
4
|
+
* Traverses the artifact dependency graph built from @-mention relationships.
|
|
5
|
+
* Shows upstream (what this depends on) and downstream (what depends on this).
|
|
6
|
+
*
|
|
7
|
+
* @implements #417
|
|
8
|
+
* @source @src/artifacts/types.ts
|
|
9
|
+
* @tests @test/unit/artifacts/dep-graph.test.ts
|
|
10
|
+
*/
|
|
11
|
+
import { normalizeEdges } from './types.js';
|
|
12
|
+
import { loadDependencyGraph, loadGraphIndexFile } from './index-reader.js';
|
|
13
|
+
import { buildFortemiCoreDependencyGraph } from './fortemi-core-query-adapter.js';
|
|
14
|
+
/**
|
|
15
|
+
* Traverse the dependency graph in one direction
|
|
16
|
+
*
|
|
17
|
+
* @param edgeType - Optional filter: only follow edges of this type
|
|
18
|
+
*/
|
|
19
|
+
function traverse(graph, startPath, direction, maxDepth, visited = new Set(), currentDepth = 0, edgeType) {
|
|
20
|
+
if (currentDepth >= maxDepth)
|
|
21
|
+
return [];
|
|
22
|
+
const node = graph[startPath];
|
|
23
|
+
if (!node)
|
|
24
|
+
return [];
|
|
25
|
+
const rawEdges = direction === 'upstream' ? node.upstream : node.downstream;
|
|
26
|
+
// Normalize for backward compat (old indexes may have string arrays)
|
|
27
|
+
const edges = normalizeEdges(rawEdges);
|
|
28
|
+
// Filter by edge type if specified
|
|
29
|
+
const filtered = edgeType ? edges.filter(e => e.type === edgeType) : edges;
|
|
30
|
+
const results = [];
|
|
31
|
+
for (const edge of filtered) {
|
|
32
|
+
if (visited.has(edge.path))
|
|
33
|
+
continue; // Cycle detection
|
|
34
|
+
visited.add(edge.path);
|
|
35
|
+
const children = traverse(graph, edge.path, direction, maxDepth, visited, currentDepth + 1, edgeType);
|
|
36
|
+
results.push({ path: edge.path, depth: currentDepth + 1, children });
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Format tree output for human readability
|
|
42
|
+
*/
|
|
43
|
+
function formatTree(results, prefix = '') {
|
|
44
|
+
let output = '';
|
|
45
|
+
for (let i = 0; i < results.length; i++) {
|
|
46
|
+
const isLast = i === results.length - 1;
|
|
47
|
+
const connector = isLast ? '└── ' : '├── ';
|
|
48
|
+
const childPrefix = isLast ? ' ' : '│ ';
|
|
49
|
+
output += `${prefix}${connector}${results[i].path}\n`;
|
|
50
|
+
if (results[i].children.length > 0) {
|
|
51
|
+
output += formatTree(results[i].children, prefix + childPrefix);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Flatten traversal results into a unique path list
|
|
58
|
+
*/
|
|
59
|
+
function flattenResults(results) {
|
|
60
|
+
const paths = [];
|
|
61
|
+
for (const r of results) {
|
|
62
|
+
paths.push(r.path);
|
|
63
|
+
paths.push(...flattenResults(r.children));
|
|
64
|
+
}
|
|
65
|
+
return [...new Set(paths)];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Show dependencies for an artifact
|
|
69
|
+
*/
|
|
70
|
+
export async function showDeps(cwd, artifactPath, options = {}) {
|
|
71
|
+
const { direction = 'both', depth = 3, json = false, graph: graphType, edgeType, backend = 'fortemi-core' } = options;
|
|
72
|
+
let depGraph = null;
|
|
73
|
+
if (backend === 'fortemi-core') {
|
|
74
|
+
const loaded = buildFortemiCoreDependencyGraph(cwd, graphType ?? 'project');
|
|
75
|
+
if (!loaded.graph) {
|
|
76
|
+
if (json) {
|
|
77
|
+
console.log(JSON.stringify({ error: 'fortemi-core-index-unavailable', hint: loaded.reason }, null, 2));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
console.error('Error: Fortemi Core static index is unavailable.');
|
|
81
|
+
console.log(loaded.reason ??
|
|
82
|
+
"Run 'aiwg index sync' first, or pass '--backend local' to use the legacy local index.");
|
|
83
|
+
}
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
depGraph = loaded.graph;
|
|
87
|
+
}
|
|
88
|
+
else if (graphType) {
|
|
89
|
+
depGraph = loadGraphIndexFile(cwd, 'dependencies.json', graphType);
|
|
90
|
+
if (!depGraph) {
|
|
91
|
+
console.error(`Error: No artifact index found for graph '${graphType}'.`);
|
|
92
|
+
console.log("Run 'aiwg index build' first to create the index.");
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Merge dependency graphs from project-local graphs
|
|
98
|
+
const graphTypes = ['project', 'codebase'];
|
|
99
|
+
const merged = {};
|
|
100
|
+
for (const g of graphTypes) {
|
|
101
|
+
const partial = loadGraphIndexFile(cwd, 'dependencies.json', g);
|
|
102
|
+
if (partial)
|
|
103
|
+
Object.assign(merged, partial);
|
|
104
|
+
}
|
|
105
|
+
if (Object.keys(merged).length > 0) {
|
|
106
|
+
depGraph = merged;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// Legacy fallback
|
|
110
|
+
depGraph = loadDependencyGraph(cwd);
|
|
111
|
+
if (!depGraph) {
|
|
112
|
+
console.error('Error: No artifact index found.');
|
|
113
|
+
console.log("Run 'aiwg index build' first to create the index.");
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!depGraph[artifactPath]) {
|
|
119
|
+
console.error(`Error: '${artifactPath}' not found in the dependency index.`);
|
|
120
|
+
console.log('Check the path or run `aiwg index build` to refresh.');
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
const showUpstream = direction === 'upstream' || direction === 'both';
|
|
124
|
+
const showDownstream = direction === 'downstream' || direction === 'both';
|
|
125
|
+
const upstreamResults = showUpstream
|
|
126
|
+
? traverse(depGraph, artifactPath, 'upstream', depth, new Set([artifactPath]), 0, edgeType)
|
|
127
|
+
: [];
|
|
128
|
+
const downstreamResults = showDownstream
|
|
129
|
+
? traverse(depGraph, artifactPath, 'downstream', depth, new Set([artifactPath]), 0, edgeType)
|
|
130
|
+
: [];
|
|
131
|
+
if (json) {
|
|
132
|
+
console.log(JSON.stringify({
|
|
133
|
+
artifact: artifactPath,
|
|
134
|
+
backend,
|
|
135
|
+
direction,
|
|
136
|
+
depth,
|
|
137
|
+
upstream: flattenResults(upstreamResults),
|
|
138
|
+
downstream: flattenResults(downstreamResults),
|
|
139
|
+
upstreamCount: flattenResults(upstreamResults).length,
|
|
140
|
+
downstreamCount: flattenResults(downstreamResults).length,
|
|
141
|
+
}, null, 2));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.log(`Dependencies for ${artifactPath}:`);
|
|
145
|
+
console.log('');
|
|
146
|
+
if (showUpstream) {
|
|
147
|
+
console.log(' UPSTREAM (this artifact depends on):');
|
|
148
|
+
if (upstreamResults.length === 0) {
|
|
149
|
+
console.log(' (none)');
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const tree = formatTree(upstreamResults, ' ');
|
|
153
|
+
process.stdout.write(tree);
|
|
154
|
+
}
|
|
155
|
+
console.log('');
|
|
156
|
+
}
|
|
157
|
+
if (showDownstream) {
|
|
158
|
+
console.log(' DOWNSTREAM (depends on this artifact):');
|
|
159
|
+
if (downstreamResults.length === 0) {
|
|
160
|
+
console.log(' (none)');
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const tree = formatTree(downstreamResults, ' ');
|
|
164
|
+
process.stdout.write(tree);
|
|
165
|
+
}
|
|
166
|
+
console.log('');
|
|
167
|
+
}
|
|
168
|
+
const upCount = flattenResults(upstreamResults).length;
|
|
169
|
+
const downCount = flattenResults(downstreamResults).length;
|
|
170
|
+
console.log(` Upstream: ${upCount} | Downstream: ${downCount} | Total: ${upCount + downCount}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=dep-graph.js.map
|