@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,477 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical WORKSPACE.md context graph and provider adapter generator.
|
|
3
|
+
*
|
|
4
|
+
* WORKSPACE.md owns provider-neutral project/operator context; AIWG.md owns
|
|
5
|
+
* generated discovery detail; provider startup files are minimal adapters.
|
|
6
|
+
*
|
|
7
|
+
* This file contains the public generator API. Callers are expected to have already
|
|
8
|
+
* deployed artifacts and to pass pre-aggregated `AgentsMdSection[]` describing what
|
|
9
|
+
* was deployed. The generator does not walk the filesystem to discover artifacts;
|
|
10
|
+
* that's the caller's responsibility (per ADR-1 §7 generator-runs-after-deploy
|
|
11
|
+
* invariant — the caller knows what landed).
|
|
12
|
+
*/
|
|
13
|
+
import { promises as fs } from 'node:fs';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import { sanitizeDescription, sanitizeTags } from './sanitizer.js';
|
|
16
|
+
import { checkPathAllowed } from './allowlist.js';
|
|
17
|
+
import { generateAiwgMd } from './aiwg-md.js';
|
|
18
|
+
import { injectSpilloverBlock } from './overflow.js';
|
|
19
|
+
import { writeNormalizedAiwgMd } from './finalization.js';
|
|
20
|
+
import { shouldEmitAgentsMd, shouldEmitAiwgMd, shouldEmitClaudeMdHook } from './provider-policy.js';
|
|
21
|
+
import { ensureClaudeMdHook } from './claude-hook.js';
|
|
22
|
+
import { ensureManagedHook } from './managed-hook.js';
|
|
23
|
+
import { buildProviderBootstrapBlock, ensureWorkspaceContext, registerProviderContext, } from './workspace-context.js';
|
|
24
|
+
const SECTION_TITLES = {
|
|
25
|
+
agents: 'Agents',
|
|
26
|
+
rules: 'Rules',
|
|
27
|
+
skills: 'Skills',
|
|
28
|
+
behaviors: 'Behaviors',
|
|
29
|
+
};
|
|
30
|
+
const AIWG_SIGNATURE_COMMENT = '<!-- aiwg-managed -->';
|
|
31
|
+
/**
|
|
32
|
+
* Build the loud warning emitted when a pre-existing, non-AIWG-managed twin or
|
|
33
|
+
* bridge file is left untouched (#1579). The terse legacy notice ("exists and
|
|
34
|
+
* is not AIWG-managed; not overwritten") buried the real consequence: the stale
|
|
35
|
+
* file keeps loading and its Discover-First Protocol never reaches the agent,
|
|
36
|
+
* so the agent fabricates CLI commands (the #1522 / #1411 failure mode).
|
|
37
|
+
*
|
|
38
|
+
* This message names that consequence and the exact remediation, and is
|
|
39
|
+
* prefixed `WARNING:` so the CLI consumers (`aiwg use`, `aiwg regenerate`)
|
|
40
|
+
* render it prominently rather than dimmed.
|
|
41
|
+
*/
|
|
42
|
+
function nonManagedTwinWarning(fileName, remediation) {
|
|
43
|
+
return (`WARNING: ${fileName} exists and is not AIWG-managed — left untouched. ` +
|
|
44
|
+
`The stale file keeps loading instead of the lean managed bridge, so the ` +
|
|
45
|
+
`Discover-First Protocol never reaches the agent and it may fabricate CLI ` +
|
|
46
|
+
`commands. Run \`${remediation}\` to back up and replace it.`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Render a single link-index entry as markdown.
|
|
50
|
+
*
|
|
51
|
+
* Returns null if the entry is rejected by sanitizer or allowlist; the caller can
|
|
52
|
+
* accumulate warnings about dropped entries.
|
|
53
|
+
*/
|
|
54
|
+
export function renderEntry(entry) {
|
|
55
|
+
const desc = sanitizeDescription(entry.description);
|
|
56
|
+
if (!desc.ok) {
|
|
57
|
+
return {
|
|
58
|
+
markdown: null,
|
|
59
|
+
warning: `dropped entry '${entry.id}': description rejected (${desc.rejectedFor})`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const allowed = checkPathAllowed(entry.path);
|
|
63
|
+
if (!allowed.ok) {
|
|
64
|
+
return {
|
|
65
|
+
markdown: null,
|
|
66
|
+
warning: `dropped entry '${entry.id}': path rejected (${allowed.rejectedFor})`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
let suffix = '';
|
|
70
|
+
if (entry.safetyCritical) {
|
|
71
|
+
suffix = entry.shadowedBy
|
|
72
|
+
? ` *(SAFETY-CRITICAL, SHADOWED → ${entry.shadowedBy})*`
|
|
73
|
+
: ' *(SAFETY-CRITICAL)*';
|
|
74
|
+
}
|
|
75
|
+
const tagPart = entry.tags && entry.tags.length > 0
|
|
76
|
+
? `\n - Tags: ${sanitizeTags(entry.tags).kept.join(', ')}`
|
|
77
|
+
: '';
|
|
78
|
+
const userScopeMarker = allowed.isUserScope
|
|
79
|
+
? '\n <!-- user-scope; loader may not auto-resolve -->'
|
|
80
|
+
: '';
|
|
81
|
+
const markdown = `- **${entry.id}**${suffix} — ${desc.value}\n - Path: \`${entry.path}\`${tagPart}${userScopeMarker}`;
|
|
82
|
+
return { markdown, warning: '' };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Render one section (e.g. ## Agents) of an AGENTS.md.
|
|
86
|
+
*/
|
|
87
|
+
export function renderSection(section) {
|
|
88
|
+
const title = SECTION_TITLES[section.type];
|
|
89
|
+
const warnings = [];
|
|
90
|
+
const lines = [];
|
|
91
|
+
for (const entry of section.entries) {
|
|
92
|
+
const { markdown, warning } = renderEntry(entry);
|
|
93
|
+
if (markdown) {
|
|
94
|
+
lines.push(markdown);
|
|
95
|
+
}
|
|
96
|
+
else if (warning) {
|
|
97
|
+
warnings.push(warning);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (lines.length === 0) {
|
|
101
|
+
// Empty sections are omitted per ADR-1 §1
|
|
102
|
+
return { markdown: '', warnings };
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
markdown: `## ${title}\n\n${lines.join('\n\n')}\n`,
|
|
106
|
+
warnings,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Build the full AGENTS.md content (in-memory; does not write).
|
|
111
|
+
*
|
|
112
|
+
* Per operator direction (#1239): AGENTS.md is a thin pointer to AIWG.md at
|
|
113
|
+
* project root. AIWG.md mirrors CLAUDE.md (ADR-1 §0.5) and contains the full
|
|
114
|
+
* framework guidance — including the kernel-skill discovery pattern
|
|
115
|
+
* (`aiwg discover` / `aiwg show`). Inlining a full link-index here pushed the
|
|
116
|
+
* file past Codex's 32KB cap on real deploys, triggered auto-split, and ran
|
|
117
|
+
* every artifact description through the sanitizer (rejecting any with
|
|
118
|
+
* backticks). The thin-pointer body sidesteps all of that: zero warnings on
|
|
119
|
+
* any provider, regardless of how many artifacts are deployed.
|
|
120
|
+
*
|
|
121
|
+
* `opts.sections` is accepted for backwards compatibility with callers that
|
|
122
|
+
* still aggregate a link-index (no internal use). `splitOccurred` is always
|
|
123
|
+
* false; `spilloverContent` is always empty. The `partitionForOverflow` /
|
|
124
|
+
* spillover utilities remain exported for any external consumer.
|
|
125
|
+
*/
|
|
126
|
+
export async function buildAgentsMd(opts) {
|
|
127
|
+
const warnings = [];
|
|
128
|
+
const parts = [];
|
|
129
|
+
parts.push('# AGENTS.md');
|
|
130
|
+
parts.push(`${AIWG_SIGNATURE_COMMENT}`);
|
|
131
|
+
parts.push('<!-- Generated by AIWG. Edit AGENTS.override.md for operator additions. -->');
|
|
132
|
+
parts.push('');
|
|
133
|
+
parts.push(buildProviderBootstrapBlock(opts.provider));
|
|
134
|
+
parts.push('');
|
|
135
|
+
parts.push('## Framework Context');
|
|
136
|
+
parts.push('');
|
|
137
|
+
parts.push('See [AIWG.md](./AIWG.md) for the full AIWG framework context');
|
|
138
|
+
parts.push('(active frameworks, addons, agents, behaviors, rules).');
|
|
139
|
+
parts.push('Tracker and delivery source of truth: [.aiwg/aiwg.config](./.aiwg/aiwg.config).');
|
|
140
|
+
parts.push('');
|
|
141
|
+
parts.push('Deployed artifacts live under your provider\'s native directory');
|
|
142
|
+
parts.push('(for example `.codex/agents/`, `.warp/agents/`, `.github/agents/`).');
|
|
143
|
+
parts.push('Use `aiwg discover "<intent>"` and `aiwg show <type> <name>` to browse');
|
|
144
|
+
parts.push('skills, agents, rules, and commands across the installation.');
|
|
145
|
+
parts.push('');
|
|
146
|
+
if (opts.projectContext && opts.projectContext.trim().length > 0) {
|
|
147
|
+
warnings.push('projectContext is no longer inlined in provider startup files; place it in the protected WORKSPACE.md operator section.');
|
|
148
|
+
}
|
|
149
|
+
parts.push('---');
|
|
150
|
+
parts.push('');
|
|
151
|
+
parts.push('*See `AGENTS.override.md` for operator-authored additions.*');
|
|
152
|
+
parts.push('');
|
|
153
|
+
return { content: parts.join('\n'), warnings, spilloverContent: '', splitOccurred: false };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Detect whether a pre-existing file at `filePath` carries the AIWG signature.
|
|
157
|
+
*
|
|
158
|
+
* Returns `true` if the file is missing or is AIWG-managed (safe to overwrite).
|
|
159
|
+
* Returns `false` if the file exists and does not carry the signature comment
|
|
160
|
+
* (operator-claimed).
|
|
161
|
+
*/
|
|
162
|
+
export async function isOverwriteSafe(filePath) {
|
|
163
|
+
try {
|
|
164
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
165
|
+
// First 4 lines: canonical signature lookup.
|
|
166
|
+
const head = content.split('\n').slice(0, 4).join('\n');
|
|
167
|
+
if (head.includes(AIWG_SIGNATURE_COMMENT))
|
|
168
|
+
return true;
|
|
169
|
+
if (/Generated by\s+(AIWG|aiwg)/i.test(head))
|
|
170
|
+
return true;
|
|
171
|
+
// Backwards-compatibility scan: pre-ADR-1 emitters wrote AGENTS.md /
|
|
172
|
+
// WARP.md / .hermes.md without the canonical signature. Those files
|
|
173
|
+
// typically include AIWG-specific markers somewhere in the first ~50
|
|
174
|
+
// lines. Detect them so existing repos upgrade cleanly without
|
|
175
|
+
// requiring --force.
|
|
176
|
+
const headExtended = content.split('\n').slice(0, 50).join('\n');
|
|
177
|
+
const legacyMarkers = [
|
|
178
|
+
/AIWG\s+SDLC\s+(Framework|framework)/i,
|
|
179
|
+
/AIWG\s+(auto-updated|managed)/i,
|
|
180
|
+
/AIWG\s+Integration/i,
|
|
181
|
+
/<!--\s*AIWG\s+/i,
|
|
182
|
+
/aiwg\s+use\s+sdlc/i,
|
|
183
|
+
];
|
|
184
|
+
return legacyMarkers.some((re) => re.test(headExtended));
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
if (err.code === 'ENOENT') {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
throw err;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Atomically write a file via tmpfile + rename.
|
|
195
|
+
*
|
|
196
|
+
* Per ADR-4 §4 atomic write requirement; on failure no partial state is persisted.
|
|
197
|
+
*/
|
|
198
|
+
async function atomicWrite(filePath, content) {
|
|
199
|
+
const dir = path.dirname(filePath);
|
|
200
|
+
const tmp = path.join(dir, `.${path.basename(filePath)}.tmp.${process.pid}`);
|
|
201
|
+
await fs.mkdir(dir, { recursive: true });
|
|
202
|
+
await fs.writeFile(tmp, content, 'utf8');
|
|
203
|
+
try {
|
|
204
|
+
await fs.rename(tmp, filePath);
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
// Best-effort cleanup of tmpfile on rename failure.
|
|
208
|
+
await fs.unlink(tmp).catch(() => undefined);
|
|
209
|
+
throw err;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Per-provider twin-file names for AGENTS.md emission per ADR-1 §4.
|
|
214
|
+
*
|
|
215
|
+
* Hermes scans `.hermes.md` first (priority 1) and falls back to AGENTS.md.
|
|
216
|
+
* Warp prefers AGENTS.md but tooling expects `WARP.md` to exist. Both are
|
|
217
|
+
* written with the same content as AGENTS.md, except Hermes — see
|
|
218
|
+
* `applyTwinSuffix` below for the Hermes-specific MCP guidance suffix
|
|
219
|
+
* (#1242).
|
|
220
|
+
*/
|
|
221
|
+
const TWIN_FILES_BY_PROVIDER = {
|
|
222
|
+
copilot: ['.github/copilot-instructions.md'],
|
|
223
|
+
hermes: ['.hermes.md'],
|
|
224
|
+
warp: ['WARP.md'],
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Hermes-specific suffix appended to `.hermes.md` (#1242).
|
|
228
|
+
*
|
|
229
|
+
* The cross-platform AGENTS.md thin pointer (#1239) says *"See [AIWG.md] for
|
|
230
|
+
* the full AIWG framework context."* From inside a Hermes turn that link is
|
|
231
|
+
* a dead end — Hermes auto-loads AGENTS.md and CLAUDE.md but not AIWG.md.
|
|
232
|
+
* The twin file gets a Hermes-correct alternative path so a model running
|
|
233
|
+
* inside Hermes knows to call `artifact-read` over MCP rather than chase the
|
|
234
|
+
* AIWG.md link.
|
|
235
|
+
*
|
|
236
|
+
* Suffix is ~390 chars (~95 tokens) — keeps the .hermes.md twin total under
|
|
237
|
+
* Hermes's <1,000-char turn-budget target on top of the 579-byte primary.
|
|
238
|
+
*/
|
|
239
|
+
const HERMES_TWIN_SUFFIX = [
|
|
240
|
+
'',
|
|
241
|
+
'## For Hermes Sessions',
|
|
242
|
+
'',
|
|
243
|
+
'Hermes does not auto-load AIWG.md. Browse AIWG capabilities with:',
|
|
244
|
+
'',
|
|
245
|
+
'- `artifact-read AIWG.md` through AIWG MCP.',
|
|
246
|
+
'- `aiwg discover "<intent>"` and `aiwg show <type> <name>`.',
|
|
247
|
+
'- `delegate_task` through the AIWG-orchestrate skill.',
|
|
248
|
+
'',
|
|
249
|
+
].join('\n');
|
|
250
|
+
/**
|
|
251
|
+
* Apply provider-specific transformations to twin-file content.
|
|
252
|
+
*
|
|
253
|
+
* Currently used only for Hermes (#1242). Extend by adding more
|
|
254
|
+
* provider-keyed branches as new twin formats need divergence.
|
|
255
|
+
*/
|
|
256
|
+
function applyTwinSuffix(provider, baseContent) {
|
|
257
|
+
if (provider === 'hermes') {
|
|
258
|
+
return `${baseContent}${HERMES_TWIN_SUFFIX}`;
|
|
259
|
+
}
|
|
260
|
+
return baseContent;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Write per-provider twin files (.hermes.md, WARP.md). Twin content is the
|
|
264
|
+
* AGENTS.md body plus any provider-specific suffix from `applyTwinSuffix`.
|
|
265
|
+
* Operator-claimed twin files are not overwritten unless --force is set,
|
|
266
|
+
* matching the AGENTS.md guard.
|
|
267
|
+
*/
|
|
268
|
+
async function writeTwinFiles(provider, projectPath, agentsMdContent, opts, result) {
|
|
269
|
+
const twinNames = TWIN_FILES_BY_PROVIDER[provider];
|
|
270
|
+
if (!twinNames || twinNames.length === 0)
|
|
271
|
+
return;
|
|
272
|
+
const twinContent = applyTwinSuffix(provider, agentsMdContent);
|
|
273
|
+
for (const twinName of twinNames) {
|
|
274
|
+
const twinPath = path.join(projectPath, twinName);
|
|
275
|
+
if (opts.detectExistingFiles && !opts.force) {
|
|
276
|
+
const safe = await isOverwriteSafe(twinPath);
|
|
277
|
+
if (!safe) {
|
|
278
|
+
// #1579: don't skip an operator-owned twin — additively install the
|
|
279
|
+
// canonical graph hook so discover-first isn't buried (preserve content).
|
|
280
|
+
const hook = await ensureManagedHook(twinPath, { provider });
|
|
281
|
+
result.warnings.push(hook.action === 'unchanged'
|
|
282
|
+
? `${twinName} is operator-owned and already loads WORKSPACE.md then AIWG.md — left as-is.`
|
|
283
|
+
: `${twinName} is operator-owned; ${hook.action} the WORKSPACE.md → AIWG.md hook additively (existing content preserved). Pass --force to replace the whole file.`);
|
|
284
|
+
result.twinPaths.push(twinPath);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else if (opts.force) {
|
|
289
|
+
try {
|
|
290
|
+
const original = await fs.readFile(twinPath, 'utf8');
|
|
291
|
+
if (!original.includes(AIWG_SIGNATURE_COMMENT) && !/Generated by\s+(AIWG|aiwg)/i.test(original.split('\n').slice(0, 4).join('\n'))) {
|
|
292
|
+
const backupPath = `${twinPath}.bak.${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
293
|
+
await fs.writeFile(backupPath, original, 'utf8');
|
|
294
|
+
result.backupPaths.push(backupPath);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
if (err.code !== 'ENOENT')
|
|
299
|
+
throw err;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
await atomicWrite(twinPath, twinContent);
|
|
303
|
+
result.twinPaths.push(twinPath);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Inject a spillover block into AGENTS.override.md, preserving operator-authored
|
|
308
|
+
* content outside the block. Per ADR-1 §5: shared file partitioning with the
|
|
309
|
+
* `<!-- spillover-from-AGENTS.md:START/END -->` markers. Generator only writes
|
|
310
|
+
* inside that block.
|
|
311
|
+
*/
|
|
312
|
+
async function writeSpilloverBlock(projectPath, spilloverMarkdown, result) {
|
|
313
|
+
const overridePath = path.join(projectPath, 'AGENTS.override.md');
|
|
314
|
+
let existing = '';
|
|
315
|
+
try {
|
|
316
|
+
existing = await fs.readFile(overridePath, 'utf8');
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
if (err.code !== 'ENOENT') {
|
|
320
|
+
throw err;
|
|
321
|
+
}
|
|
322
|
+
// Create AGENTS.override.md with a header explaining the partition.
|
|
323
|
+
existing = [
|
|
324
|
+
'# AGENTS.override.md',
|
|
325
|
+
'',
|
|
326
|
+
'<!-- Operator-authored additions go here. The block below is AIWG-managed spillover; -->',
|
|
327
|
+
'<!-- do not edit between the spillover markers. Content outside is preserved across runs. -->',
|
|
328
|
+
'',
|
|
329
|
+
].join('\n');
|
|
330
|
+
}
|
|
331
|
+
const updated = injectSpilloverBlock(existing, spilloverMarkdown);
|
|
332
|
+
await atomicWrite(overridePath, updated);
|
|
333
|
+
result.warnings.push(`spillover written to AGENTS.override.md (${Buffer.byteLength(spilloverMarkdown, 'utf8')}b)`);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Generate the canonical graph and provider startup adapters.
|
|
337
|
+
*
|
|
338
|
+
* Skeleton implementation: emits AGENTS.md with link-index sections; AIWG.md
|
|
339
|
+
* generation is wired in commit 3 alongside the first issue closure (#1104).
|
|
340
|
+
* For now AIWG.md emission delegates to a copy of CLAUDE.md when the source
|
|
341
|
+
* is present; otherwise it is skipped with a warning.
|
|
342
|
+
*/
|
|
343
|
+
export async function generate(opts) {
|
|
344
|
+
const result = {
|
|
345
|
+
workspaceMdPath: '',
|
|
346
|
+
aiwgMdPath: '',
|
|
347
|
+
normalizedAiwgMdPath: '',
|
|
348
|
+
agentsMdPath: '',
|
|
349
|
+
twinPaths: [],
|
|
350
|
+
contextRegistrationPaths: [],
|
|
351
|
+
backupPaths: [],
|
|
352
|
+
agentsMdBytes: 0,
|
|
353
|
+
warnings: [],
|
|
354
|
+
};
|
|
355
|
+
if (!opts.skip?.workspaceMd) {
|
|
356
|
+
const workspace = await ensureWorkspaceContext(opts.projectPath);
|
|
357
|
+
result.workspaceMdAction = workspace.action;
|
|
358
|
+
result.warnings.push(...workspace.warnings);
|
|
359
|
+
if (workspace.action !== 'preserved')
|
|
360
|
+
result.workspaceMdPath = workspace.path;
|
|
361
|
+
if (workspace.backupPath)
|
|
362
|
+
result.backupPaths.push(workspace.backupPath);
|
|
363
|
+
}
|
|
364
|
+
const normalizedAiwgPath = await writeNormalizedAiwgMd(opts.projectPath);
|
|
365
|
+
result.normalizedAiwgMdPath = normalizedAiwgPath;
|
|
366
|
+
// AGENTS.md emission is gated on the provider's link-mechanism: codex/copilot/
|
|
367
|
+
// cursor/windsurf/hermes/warp/factory/opencode use AGENTS.md as their bridge
|
|
368
|
+
// to AIWG.md. Claude uses CLAUDE.md hook instead (#1437); openclaw is
|
|
369
|
+
// home-dir-only and 'generic' has no provider-local footprint.
|
|
370
|
+
if (!opts.skip?.agentsMd && shouldEmitAgentsMd(opts.provider)) {
|
|
371
|
+
const agentsMdPath = path.join(opts.projectPath, 'AGENTS.md');
|
|
372
|
+
let canWrite = true;
|
|
373
|
+
if (opts.detectExistingFiles && !opts.force) {
|
|
374
|
+
canWrite = await isOverwriteSafe(agentsMdPath);
|
|
375
|
+
}
|
|
376
|
+
else if (opts.force) {
|
|
377
|
+
// Backup before overwrite per ADR-1 §5 R1 mitigation.
|
|
378
|
+
try {
|
|
379
|
+
const original = await fs.readFile(agentsMdPath, 'utf8');
|
|
380
|
+
if (!original.includes(AIWG_SIGNATURE_COMMENT)) {
|
|
381
|
+
const backupPath = `${agentsMdPath}.bak.${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
382
|
+
await fs.writeFile(backupPath, original, 'utf8');
|
|
383
|
+
result.backupPaths.push(backupPath);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
catch (err) {
|
|
387
|
+
if (err.code !== 'ENOENT') {
|
|
388
|
+
throw err;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// Build the managed AGENTS.md content in-memory regardless — used for the full
|
|
393
|
+
// write, and as the twin content downstream.
|
|
394
|
+
const built = await buildAgentsMd(opts);
|
|
395
|
+
if (canWrite) {
|
|
396
|
+
await atomicWrite(agentsMdPath, built.content);
|
|
397
|
+
result.agentsMdPath = agentsMdPath;
|
|
398
|
+
result.agentsMdBytes = Buffer.byteLength(built.content, 'utf8');
|
|
399
|
+
result.warnings.push(...built.warnings);
|
|
400
|
+
if (built.splitOccurred) {
|
|
401
|
+
await writeSpilloverBlock(opts.projectPath, built.spilloverContent, result);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
// #1597: AGENTS.md is operator-owned — don't skip it. Additively install the
|
|
406
|
+
// canonical graph hook (preserve operator content; no --force needed) so Codex/
|
|
407
|
+
// fallback consumers load the generated AIWG.md.
|
|
408
|
+
const hook = await ensureManagedHook(agentsMdPath, { provider: opts.provider });
|
|
409
|
+
result.agentsMdPath = agentsMdPath;
|
|
410
|
+
result.warnings.push(hook.action === 'unchanged'
|
|
411
|
+
? `AGENTS.md is operator-owned and already loads WORKSPACE.md then AIWG.md — left as-is.`
|
|
412
|
+
: `AGENTS.md is operator-owned; ${hook.action} the WORKSPACE.md → AIWG.md hook additively (existing content preserved). Pass --force to replace the whole file.`);
|
|
413
|
+
}
|
|
414
|
+
// Per-provider twin emission per ADR-1 §4 (Hermes .hermes.md, Warp WARP.md);
|
|
415
|
+
// each twin is guarded individually (managed → full write, operator-owned →
|
|
416
|
+
// additive hook), so this runs whether or not AGENTS.md itself was rewritten.
|
|
417
|
+
await writeTwinFiles(opts.provider, opts.projectPath, built.content, opts, result);
|
|
418
|
+
}
|
|
419
|
+
if (!opts.skip?.aiwgMd && shouldEmitAiwgMd(opts.provider)) {
|
|
420
|
+
const aiwgMdPath = path.join(opts.projectPath, 'AIWG.md');
|
|
421
|
+
let canWrite = true;
|
|
422
|
+
if (opts.detectExistingFiles && !opts.force) {
|
|
423
|
+
canWrite = await isOverwriteSafe(aiwgMdPath);
|
|
424
|
+
if (!canWrite) {
|
|
425
|
+
result.warnings.push(nonManagedTwinWarning('AIWG.md', 'aiwg regenerate --force'));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
else if (opts.force) {
|
|
429
|
+
// Backup before overwrite per ADR-1 §5 R1 mitigation.
|
|
430
|
+
try {
|
|
431
|
+
const original = await fs.readFile(aiwgMdPath, 'utf8');
|
|
432
|
+
if (!original.includes(AIWG_SIGNATURE_COMMENT)) {
|
|
433
|
+
const backupPath = `${aiwgMdPath}.bak.${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
434
|
+
await fs.writeFile(backupPath, original, 'utf8');
|
|
435
|
+
result.backupPaths.push(backupPath);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
if (err.code !== 'ENOENT') {
|
|
440
|
+
throw err;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (canWrite) {
|
|
445
|
+
const content = await generateAiwgMd(opts.projectPath);
|
|
446
|
+
await atomicWrite(aiwgMdPath, content);
|
|
447
|
+
result.aiwgMdPath = aiwgMdPath;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// CLAUDE.md hook emission for the claude provider (#1437). Mirrors how
|
|
451
|
+
// AGENTS.md is the bridge for other providers — CLAUDE.md gets a managed
|
|
452
|
+
// marker block with an `@AIWG.md` include. Operator content outside the
|
|
453
|
+
// block is preserved.
|
|
454
|
+
if (shouldEmitClaudeMdHook(opts.provider)) {
|
|
455
|
+
const hookResult = await ensureClaudeMdHook(opts.projectPath, {
|
|
456
|
+
force: opts.force,
|
|
457
|
+
detectExistingFiles: opts.detectExistingFiles,
|
|
458
|
+
});
|
|
459
|
+
result.claudeMdHookPath = hookResult.claudeMdPath;
|
|
460
|
+
result.claudeMdHookAction = hookResult.action;
|
|
461
|
+
if (hookResult.backupPath) {
|
|
462
|
+
result.backupPaths.push(hookResult.backupPath);
|
|
463
|
+
}
|
|
464
|
+
result.warnings.push(...hookResult.warnings);
|
|
465
|
+
}
|
|
466
|
+
if (!opts.skip?.workspaceMd) {
|
|
467
|
+
const registration = await registerProviderContext(opts.provider, opts.projectPath);
|
|
468
|
+
if (registration) {
|
|
469
|
+
if (registration.changed)
|
|
470
|
+
result.contextRegistrationPaths.push(registration.path);
|
|
471
|
+
if (registration.warning)
|
|
472
|
+
result.warnings.push(registration.warning);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context-pipeline — canonical workspace graph and provider adapter generator.
|
|
3
|
+
*
|
|
4
|
+
* Implements the cross-platform context delivery pipeline defined in
|
|
5
|
+
* `.aiwg/architecture/adr-workspace-context-graph.md`. Emits a project graph:
|
|
6
|
+
*
|
|
7
|
+
* - WORKSPACE.md — protected provider-neutral project/operator context
|
|
8
|
+
* - AIWG.md — generated framework/discovery context
|
|
9
|
+
* - provider startup files — minimal WORKSPACE.md then AIWG.md adapters
|
|
10
|
+
*
|
|
11
|
+
* Distinct from `agentsmith/`, which creates subagent personas. The two modules
|
|
12
|
+
* answer different questions: agentsmith asks "what should this agent persona look
|
|
13
|
+
* like?"; context-pipeline asks "what files are deployed and how should the
|
|
14
|
+
* provider's loader find them?".
|
|
15
|
+
*
|
|
16
|
+
* @module smiths/context-pipeline
|
|
17
|
+
*/
|
|
18
|
+
export * from './types.js';
|
|
19
|
+
export * from './workspace-context.js';
|
|
20
|
+
export * from './legacy-inject.js';
|
|
21
|
+
export { generate, buildAgentsMd, renderEntry, renderSection, isOverwriteSafe, } from './generator.js';
|
|
22
|
+
export { sanitizeDescription, sanitizeTag, sanitizeTags } from './sanitizer.js';
|
|
23
|
+
export { checkPathAllowed } from './allowlist.js';
|
|
24
|
+
export { discoverDeployedArtifacts, discoverSection, } from './discovery.js';
|
|
25
|
+
export { AGENTS_MD_PROVIDERS, shouldEmitContextFiles, shouldEmitAiwgMd, shouldEmitAgentsMd, shouldEmitClaudeMdHook, } from './provider-policy.js';
|
|
26
|
+
export { generateAiwgMd } from './aiwg-md.js';
|
|
27
|
+
export { CLAUDE_HOOK_START, CLAUDE_HOOK_END, buildClaudeHookBlock, ensureClaudeMdHook, } from './claude-hook.js';
|
|
28
|
+
export { FINALIZATION_START, FINALIZATION_END, buildContextFinalizationBlock, buildNormalizedAiwgMd, replaceOrAppendFinalizationBlock, writeNormalizedAiwgMd, } from './finalization.js';
|
|
29
|
+
export { SOFT_WARN_BYTES, HARD_ERROR_BYTES, SPILLOVER_START, SPILLOVER_END, partitionForOverflow, injectSpilloverBlock, extractNonSpillover, SafetyCriticalOverflowError, } from './overflow.js';
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getProviderDefinition } from '../../providers/provider-definitions.js';
|
|
4
|
+
export const LEGACY_INJECT_START = '<!-- BEGIN AIWG -->';
|
|
5
|
+
export const LEGACY_INJECT_END = '<!-- END AIWG -->';
|
|
6
|
+
const MANAGED_BLOCKS = [
|
|
7
|
+
['<!-- AIWG:context-hook:start -->', '<!-- AIWG:context-hook:end -->'],
|
|
8
|
+
['<!-- AIWG:claude-md-hook:start -->', '<!-- AIWG:claude-md-hook:end -->'],
|
|
9
|
+
['<!-- AIWG:provider-bootstrap:start -->', '<!-- AIWG:provider-bootstrap:end -->'],
|
|
10
|
+
];
|
|
11
|
+
function legacyBlock(content) {
|
|
12
|
+
return [
|
|
13
|
+
LEGACY_INJECT_START,
|
|
14
|
+
'<!-- Legacy compatibility mode. Regenerate with `aiwg regenerate --full-inject`. -->',
|
|
15
|
+
'',
|
|
16
|
+
content.trim(),
|
|
17
|
+
'',
|
|
18
|
+
LEGACY_INJECT_END,
|
|
19
|
+
].join('\n');
|
|
20
|
+
}
|
|
21
|
+
function replaceMarked(content, start, end, replacement) {
|
|
22
|
+
const first = content.indexOf(start);
|
|
23
|
+
const last = content.indexOf(end);
|
|
24
|
+
if (first < 0 && last < 0)
|
|
25
|
+
return null;
|
|
26
|
+
if (first < 0 || last < first)
|
|
27
|
+
throw new Error(`Malformed managed context block: ${start} / ${end}`);
|
|
28
|
+
return content.slice(0, first) + replacement + content.slice(last + end.length);
|
|
29
|
+
}
|
|
30
|
+
function withoutCanonicalBlocks(content) {
|
|
31
|
+
let output = content;
|
|
32
|
+
for (const [start, end] of MANAGED_BLOCKS) {
|
|
33
|
+
const replaced = replaceMarked(output, start, end, '');
|
|
34
|
+
if (replaced !== null)
|
|
35
|
+
output = replaced;
|
|
36
|
+
}
|
|
37
|
+
return output.trim();
|
|
38
|
+
}
|
|
39
|
+
function renderLegacyTarget(existing, frameworkContent) {
|
|
40
|
+
const block = legacyBlock(frameworkContent);
|
|
41
|
+
if (existing === null)
|
|
42
|
+
return `${block}\n`;
|
|
43
|
+
const replaced = replaceMarked(existing, LEGACY_INJECT_START, LEGACY_INJECT_END, block);
|
|
44
|
+
if (replaced !== null)
|
|
45
|
+
return `${replaced.trim()}\n`;
|
|
46
|
+
if (existing.includes('<!-- aiwg-managed -->'))
|
|
47
|
+
return `${block}\n`;
|
|
48
|
+
const operator = withoutCanonicalBlocks(existing);
|
|
49
|
+
return `${operator ? `${operator}\n\n` : ''}${block}\n`;
|
|
50
|
+
}
|
|
51
|
+
async function readOptional(file) {
|
|
52
|
+
try {
|
|
53
|
+
return await fs.readFile(file, 'utf8');
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error.code === 'ENOENT')
|
|
57
|
+
return null;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function atomicWrite(file, content) {
|
|
62
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
63
|
+
const temporary = path.join(path.dirname(file), `.${path.basename(file)}.tmp.${process.pid}`);
|
|
64
|
+
await fs.writeFile(temporary, content, 'utf8');
|
|
65
|
+
try {
|
|
66
|
+
await fs.rename(temporary, file);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
await fs.rm(temporary, { force: true });
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export async function injectLegacyContext(provider, projectPath, frameworkContent, options = {}) {
|
|
74
|
+
const definition = getProviderDefinition(provider);
|
|
75
|
+
const targets = definition?.context.bootstrapTargets ?? [];
|
|
76
|
+
if (targets.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
targets: [], backups: [], changed: [], dryRun: Boolean(options.dryRun),
|
|
79
|
+
warnings: [`Provider ${provider} has no project-local startup target for legacy injection.`],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const backups = [];
|
|
83
|
+
const changed = [];
|
|
84
|
+
for (const relative of targets) {
|
|
85
|
+
const target = path.join(projectPath, relative);
|
|
86
|
+
const existing = await readOptional(target);
|
|
87
|
+
const output = renderLegacyTarget(existing, frameworkContent);
|
|
88
|
+
if (existing === output)
|
|
89
|
+
continue;
|
|
90
|
+
changed.push(target);
|
|
91
|
+
if (options.dryRun)
|
|
92
|
+
continue;
|
|
93
|
+
if (existing !== null) {
|
|
94
|
+
const backup = `${target}.bak.${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
95
|
+
await fs.mkdir(path.dirname(backup), { recursive: true });
|
|
96
|
+
await fs.writeFile(backup, existing, 'utf8');
|
|
97
|
+
backups.push(backup);
|
|
98
|
+
}
|
|
99
|
+
await atomicWrite(target, output);
|
|
100
|
+
}
|
|
101
|
+
return { targets: targets.map(target => path.join(projectPath, target)), backups, changed, dryRun: Boolean(options.dryRun), warnings: [] };
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=legacy-inject.js.map
|