@aiwg/cli 2026.10.1 → 2026.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/agentic/code/providers/capability-matrix.yaml +270 -0
- package/agentic/code/providers/model-capabilities.v1.json +3183 -24
- package/bin/aiwg.mjs +135 -47
- package/dist/src/a2a/codecs.js +9 -0
- package/dist/src/agents/grounding/knowledge-base.js +54 -6
- package/dist/src/artifacts/browser-export.js +6 -0
- package/dist/src/artifacts/checksum-manifest.js +1 -0
- package/dist/src/artifacts/citation-parser.js +173 -92
- package/dist/src/artifacts/citation-table-schema.js +59 -0
- package/dist/src/artifacts/cli.js +57 -18
- package/dist/src/artifacts/corpus-tools/snapshot.js +1 -1
- package/dist/src/artifacts/corpus-tools/vision-extract.js +107 -15
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -1
- package/dist/src/artifacts/corpus-views/renderers.js +3 -3
- package/dist/src/artifacts/discovery-eval.js +6 -4
- package/dist/src/artifacts/fortemi-core-query-adapter.js +36 -3
- package/dist/src/artifacts/fortemi-core-sync.js +166 -40
- package/dist/src/artifacts/framework-capabilities.js +171 -0
- package/dist/src/artifacts/framework-index-paths.js +73 -0
- package/dist/src/artifacts/framework-source-digest.js +75 -0
- package/dist/src/artifacts/index-builder.js +285 -131
- package/dist/src/artifacts/index-files.js +132 -18
- package/dist/src/artifacts/index-preparation.js +65 -0
- package/dist/src/artifacts/index-refresh.js +576 -0
- package/dist/src/artifacts/index-worker.mjs +9 -0
- package/dist/src/artifacts/prebuilt-build-lock.js +47 -4
- package/dist/src/artifacts/prebuilt-deployment.js +46 -0
- package/dist/src/artifacts/prebuilt-relations.js +80 -0
- package/dist/src/artifacts/query-engine.js +410 -88
- package/dist/src/artifacts/relations-builder.js +168 -0
- package/dist/src/artifacts/relations.js +148 -0
- package/dist/src/artifacts/repair.js +9 -4
- package/dist/src/artifacts/stats.js +5 -2
- package/dist/src/artifacts/types.js +30 -10
- package/dist/src/artifacts/watcher.js +1 -1
- package/dist/src/auth/credential-store.js +2 -1
- package/dist/src/catalog/cli.d.mts +5 -0
- package/dist/src/channel/manager.d.mts +20 -0
- package/dist/src/channel/manager.mjs +78 -12
- package/dist/src/cli/child-process-result.js +40 -0
- package/dist/src/cli/command-log.js +2 -3
- package/dist/src/cli/env.js +38 -16
- package/dist/src/cli/flag-parsing.js +236 -0
- package/dist/src/cli/handlers/artifacts.js +3 -0
- package/dist/src/cli/handlers/auth.js +3 -0
- package/dist/src/cli/handlers/decision.js +218 -5
- package/dist/src/cli/handlers/diagnose.js +13 -5
- package/dist/src/cli/handlers/effect.js +4 -2
- package/dist/src/cli/handlers/evidence.js +3 -0
- package/dist/src/cli/handlers/feedback.js +14 -5
- package/dist/src/cli/handlers/help.js +1 -0
- package/dist/src/cli/handlers/index.js +3 -1
- package/dist/src/cli/handlers/init.js +248 -30
- package/dist/src/cli/handlers/lint.js +5 -0
- package/dist/src/cli/handlers/mc.js +23 -0
- package/dist/src/cli/handlers/models.js +169 -10
- package/dist/src/cli/handlers/ralph-launcher.js +2 -0
- package/dist/src/cli/handlers/ralph.js +3 -0
- package/dist/src/cli/handlers/refresh.js +28 -0
- package/dist/src/cli/handlers/regenerate.js +14 -0
- package/dist/src/cli/handlers/resource-versions.js +3 -0
- package/dist/src/cli/handlers/rules.js +195 -0
- package/dist/src/cli/handlers/run.js +4 -0
- package/dist/src/cli/handlers/runtime-info.js +25 -11
- package/dist/src/cli/handlers/script-runner.js +19 -8
- package/dist/src/cli/handlers/session.js +406 -62
- package/dist/src/cli/handlers/sessions.js +243 -76
- package/dist/src/cli/handlers/setup-manifest.js +474 -79
- package/dist/src/cli/handlers/setup.js +180 -39
- package/dist/src/cli/handlers/steward.js +11 -0
- package/dist/src/cli/handlers/subcommands.js +60 -3
- package/dist/src/cli/handlers/team.js +18 -8
- package/dist/src/cli/handlers/uhp.js +3 -0
- package/dist/src/cli/handlers/use.js +307 -55
- package/dist/src/cli/handlers/utilities.js +125 -26
- package/dist/src/cli/handlers/version.js +8 -0
- package/dist/src/cli/prompt-utils.js +72 -0
- package/dist/src/cli/provider-resolution.js +11 -0
- package/dist/src/cli/router.js +15 -1
- package/dist/src/cli/services/deployment-verification.js +19 -9
- package/dist/src/cli/services/provider-prepare-coordinator.js +24 -0
- package/dist/src/cli/skill-usage.js +2 -3
- package/dist/src/config/aiwg-config.js +349 -35
- package/dist/src/config/cli.js +256 -23
- package/dist/src/config/decision-config.js +106 -0
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +8 -0
- package/dist/src/config/dispatch-thresholds-runtime.mjs +38 -0
- package/dist/src/config/gitignore.js +50 -0
- package/dist/src/config/index-graph-overrides.js +36 -0
- package/dist/src/config/project-artifacts-health.d.mts +37 -0
- package/dist/src/config/project-artifacts-health.mjs +14 -3
- package/dist/src/config/project-artifacts-runtime.d.mts +16 -0
- package/dist/src/config/user-config-dir.d.mts +9 -0
- package/dist/src/config/user-config.js +38 -11
- package/dist/src/config/user-registry.js +23 -15
- package/dist/src/config/user-state.js +7 -0
- package/dist/src/decision/adapters/jev.js +75 -27
- package/dist/src/decision/ask.js +203 -43
- package/dist/src/decision/context-live-qualification.js +2 -2
- package/dist/src/decision/driver.js +14 -7
- package/dist/src/decision/ensemble/aggregate.js +23 -10
- package/dist/src/decision/ensemble-study/multifact-study.js +6 -2
- package/dist/src/decision/entry.js +25 -6
- package/dist/src/decision/graph-live-qualification.js +1 -1
- package/dist/src/decision/graph-run.js +9 -0
- package/dist/src/decision/heldout/collector.js +15 -14
- package/dist/src/decision/heldout/contract.js +30 -7
- package/dist/src/decision/index.js +1 -0
- package/dist/src/decision/interop.js +60 -8
- package/dist/src/decision/jev-credentials.js +15 -1
- package/dist/src/decision/ledger.js +942 -0
- package/dist/src/decision/offload-activation.js +137 -0
- package/dist/src/decision/offload.js +550 -0
- package/dist/src/decision/qualification/load.js +4 -6
- package/dist/src/decision/savings.js +28 -0
- package/dist/src/decision/validate.js +6 -3
- package/dist/src/effects/dispatch-verifier.js +252 -0
- package/dist/src/effects/index.js +1 -0
- package/dist/src/effects/types.js +5 -1
- package/dist/src/effects/verifiers/git.js +2 -1
- package/dist/src/effects/verifiers/tracker.js +26 -14
- package/dist/src/extensions/commands/definitions.js +19 -0
- package/dist/src/extensions/project-local-remove.js +36 -1
- package/dist/src/features/installer.js +2 -2
- package/dist/src/flow/graph-metadata.js +5 -0
- package/dist/src/gates/providers/loader.js +64 -18
- package/dist/src/installation/manager-command.d.mts +18 -0
- package/dist/src/installation/manager-command.mjs +15 -3
- package/dist/src/installation/manager.d.mts +49 -0
- package/dist/src/installation/manager.mjs +95 -5
- package/dist/src/issues/cli.js +4 -4
- package/dist/src/issues/local.js +24 -5
- package/dist/src/jobs/runner.js +1 -1
- package/dist/src/lint/cli.js +27 -1
- package/dist/src/lint/loader.js +2 -1
- package/dist/src/lint/reporters.js +25 -1
- package/dist/src/lint/rule-activation.js +43 -0
- package/dist/src/lint/runner.js +137 -62
- package/dist/src/mcp/adapters/codex-runtime.js +366 -56
- package/dist/src/mcp/claude-install.d.mts +4 -0
- package/dist/src/mcp/claude-install.mjs +41 -0
- package/dist/src/mcp/cli.d.mts +1 -0
- package/dist/src/mcp/cli.mjs +620 -85
- package/dist/src/mcp/config-file.d.mts +28 -0
- package/dist/src/mcp/config-file.mjs +279 -0
- package/dist/src/mcp/config-layers.d.mts +36 -0
- package/dist/src/mcp/config-layers.mjs +348 -0
- package/dist/src/mcp/credentials.d.mts +51 -0
- package/dist/src/mcp/credentials.mjs +484 -0
- package/dist/src/mcp/grok-build-config.d.mts +6 -0
- package/dist/src/mcp/grok-build-config.mjs +17 -27
- package/dist/src/mcp/helpers.mjs +109 -4
- package/dist/src/mcp/muse-native-config.d.mts +13 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -0
- package/dist/src/mcp/omp-config.d.mts +4 -0
- package/dist/src/mcp/omp-config.mjs +50 -29
- package/dist/src/mcp/profiles.js +97 -23
- package/dist/src/mcp/profiles.mjs +99 -27
- package/dist/src/mcp/registry.js +248 -131
- package/dist/src/mcp/registry.mjs +169 -100
- package/dist/src/mcp/server-config.d.mts +3 -0
- package/dist/src/mcp/server-config.mjs +89 -0
- package/dist/src/mcp/server.mjs +127 -82
- package/dist/src/mcp/test-simple.mjs +2 -1
- package/dist/src/mcp/toml-editor.d.mts +4 -0
- package/dist/src/mcp/toml-string.d.mts +1 -0
- package/dist/src/mcp/toml-string.mjs +9 -0
- package/dist/src/mcp/toml-strip-mcp.d.mts +1 -0
- package/dist/src/mcp/toml-strip-mcp.mjs +135 -0
- package/dist/src/mcp/tool-filters.d.mts +46 -0
- package/dist/src/mcp/tool-filters.mjs +357 -0
- package/dist/src/mcp/tools/agentic-sandbox.mjs +3 -1
- package/dist/src/mcp/tools/decision.mjs +22 -3
- package/dist/src/mcp/tools/discovery.mjs +62 -55
- package/dist/src/mcp/tools/orchestration.mjs +50 -2
- package/dist/src/mcp/tools/subsystems.mjs +39 -8
- package/dist/src/mcp/tools/worker-invoke.mjs +2856 -0
- package/dist/src/mcp/tools/worker-shell-control.mjs +289 -0
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +79 -0
- package/dist/src/memory/project-registry.js +2 -2
- package/dist/src/mission-protocol/codecs.js +647 -1
- package/dist/src/mission-protocol/types.js +110 -0
- package/dist/src/mission-protocol/worker-status.js +2 -0
- package/dist/src/models/config-loader.js +76 -14
- package/dist/src/models/grok-build-models.js +93 -41
- package/dist/src/models/model-capabilities.v1.json +3183 -24
- package/dist/src/models/model-discovery.js +931 -67
- package/dist/src/models/provider-policy.js +719 -11
- package/dist/src/models/qualification-digest.d.mts +2 -0
- package/dist/src/models/qualification-digest.mjs +17 -0
- package/dist/src/models/resolver.js +261 -0
- package/dist/src/models/worker-direct-readiness.js +550 -0
- package/dist/src/models/worker-dispatch-offer.js +169 -0
- package/dist/src/models/worker-health-readiness.js +144 -0
- package/dist/src/models/worker-installation.d.mts +39 -0
- package/dist/src/models/worker-installation.mjs +986 -0
- package/dist/src/models/wrapper-route.js +18 -0
- package/dist/src/ops/registry.js +9 -14
- package/dist/src/plugins/standalone-packager.js +4 -3
- package/dist/src/process/bounded-child-process.d.mts +84 -0
- package/dist/src/process/bounded-child-process.mjs +430 -0
- package/dist/src/process/cli-command.d.mts +16 -0
- package/dist/src/process/cli-command.mjs +75 -0
- package/dist/src/process/signal-child.d.mts +6 -0
- package/dist/src/process/signal-child.mjs +7 -0
- package/dist/src/providers/capability-matrix.js +8 -0
- package/dist/src/providers/capability-matrix.yaml +270 -0
- package/dist/src/providers/deployed-skill-roots.js +20 -0
- package/dist/src/providers/grok-build-acp.js +3 -2
- package/dist/src/providers/grok-build-headless.js +53 -23
- package/dist/src/providers/grok-build-inspect.js +1 -0
- package/dist/src/providers/omp-agent.d.mts +8 -0
- package/dist/src/providers/omp-diagnostics.d.mts +1 -0
- package/dist/src/providers/omp-paths.d.mts +13 -0
- package/dist/src/providers/provider-definitions.js +9 -1
- package/dist/src/providers/provider-definitions.mjs +9 -2
- package/dist/src/providers/skill-ownership.d.mts +9 -0
- package/dist/src/providers/skill-ownership.mjs +88 -0
- package/dist/src/rules/activation.d.mts +21 -0
- package/dist/src/rules/activation.mjs +62 -0
- package/dist/src/rules/inline-budget.d.mts +26 -0
- package/dist/src/rules/inline-budget.mjs +66 -0
- package/dist/src/rules/inventory.js +129 -0
- package/dist/src/rules/pin-state.js +73 -0
- package/dist/src/rules/pins.d.mts +14 -0
- package/dist/src/rules/pins.mjs +112 -0
- package/dist/src/rules/rule-frontmatter.schema.json +197 -0
- package/dist/src/serve/executor-registry.js +16 -24
- package/dist/src/serve/fleet-mission-conductor.js +9 -0
- package/dist/src/serve/mission-conductor.js +47 -12
- package/dist/src/serve/shared-host-scheduler.js +2 -0
- package/dist/src/serve/worker-invocation.js +558 -0
- package/dist/src/serve/worker-stdin-frame.d.mts +10 -0
- package/dist/src/serve/worker-stdin-frame.mjs +107 -0
- package/dist/src/sessions/adapter-registry.js +49 -0
- package/dist/src/sessions/adapters/claude.js +39 -54
- package/dist/src/sessions/adapters/codex.js +82 -67
- package/dist/src/sessions/adapters/copilot.js +4 -4
- package/dist/src/sessions/adapters/cursor.js +40 -57
- package/dist/src/sessions/adapters/deepseek-harness.js +15 -12
- package/dist/src/sessions/adapters/factory.js +31 -27
- package/dist/src/sessions/adapters/generic.js +43 -9
- package/dist/src/sessions/adapters/grok-build.js +11 -11
- package/dist/src/sessions/adapters/grokbot-locator.js +111 -0
- package/dist/src/sessions/adapters/grokbot.js +434 -24
- package/dist/src/sessions/adapters/hermes.js +27 -29
- package/dist/src/sessions/adapters/muse-workspace-scan.js +128 -0
- package/dist/src/sessions/adapters/muse.js +200 -104
- package/dist/src/sessions/adapters/omp.js +28 -14
- package/dist/src/sessions/adapters/openclaw.js +89 -79
- package/dist/src/sessions/adapters/opencode.js +27 -24
- package/dist/src/sessions/adapters/openhuman.js +18 -60
- package/dist/src/sessions/adapters/pi.js +30 -14
- package/dist/src/sessions/adapters/warp.js +3 -3
- package/dist/src/sessions/adapters/windsurf.js +19 -48
- package/dist/src/sessions/batch-contracts.js +25 -5
- package/dist/src/sessions/batch-import.js +72 -51
- package/dist/src/sessions/candidates.js +47 -11
- package/dist/src/sessions/contracts.js +75 -2
- package/dist/src/sessions/coverage-preflight.js +134 -0
- package/dist/src/sessions/discovery.js +3 -0
- package/dist/src/sessions/export-plan.js +4 -3
- package/dist/src/sessions/grok-build-cli.js +67 -5
- package/dist/src/sessions/import-exclusions.js +72 -0
- package/dist/src/sessions/import-lease.js +34 -18
- package/dist/src/sessions/import-limits.js +37 -0
- package/dist/src/sessions/importer.js +84 -46
- package/dist/src/sessions/index.js +2 -0
- package/dist/src/sessions/lifecycle.js +45 -0
- package/dist/src/sessions/policy.js +133 -25
- package/dist/src/sessions/readers.js +106 -53
- package/dist/src/sessions/refresh.js +106 -0
- package/dist/src/sessions/repository.js +199 -63
- package/dist/src/sessions/workspace-discovery.js +315 -88
- package/dist/src/sessions/workspace-matching.js +107 -0
- package/dist/src/skills/adapters/clawhub.js +10 -8
- package/dist/src/skills/adapters/openclaw.js +10 -7
- package/dist/src/skills/importer.js +1 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +11 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +3 -26
- package/dist/src/smiths/context-pipeline/finalization.js +6 -5
- package/dist/src/smiths/context-pipeline/generator.js +21 -4
- package/dist/src/smiths/context-pipeline/parallelism-section.js +195 -14
- package/dist/src/smiths/context-pipeline/workspace-context.js +116 -9
- package/dist/src/smiths/hook-bridge/codex-translator.js +6 -5
- package/dist/src/smiths/mcpsmith/example.js +1 -1
- package/dist/src/smiths/mcpsmith/generator.js +1 -1
- package/dist/src/smiths/toolsmith/runtime-discovery.d.mts +10 -0
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +85 -31
- package/dist/src/storage/backends/fs.js +18 -76
- package/dist/src/storage/backends/logseq.js +68 -7
- package/dist/src/storage/backends/obsidian.js +1 -0
- package/dist/src/storage/fortemi-qualification-receipt.js +2 -2
- package/dist/src/testing/generators/test-code-generator.js +57 -30
- package/dist/src/tracker/forge-http.js +2 -1
- package/dist/src/uhp/client.js +11 -1
- package/dist/src/uhp/mission.js +5 -0
- package/dist/src/update/checker.d.mts +2 -0
- package/dist/src/update/checker.mjs +5 -5
- package/dist/src/update/notifier.mjs +54 -2
- package/dist/src/update/service.d.mts +22 -0
- package/dist/src/utils/contained-filesystem.d.mts +37 -0
- package/dist/src/utils/contained-filesystem.mjs +683 -0
- package/dist/src/utils/temporary-directory.js +36 -0
- package/dist/src/writing/example-generator.js +1 -1
- package/dist/src/writing/fidelity.js +18 -1
- package/package.json +32 -2
- package/schemas/mission-v1.schema.json +2429 -0
- package/schemas/models/model-catalog.v1.schema.json +301 -0
- package/schemas/models/model-config-compatibility.v1.schema.json +281 -0
- package/schemas/models/model-policy.v1.schema.json +14 -0
- package/schemas/models/provider-model-capabilities.v1.schema.json +1072 -0
- package/tools/_resolve-impl.mjs +39 -2
- package/tools/agents/deploy-agents.mjs +64 -23
- package/tools/agents/providers/base.mjs +153 -166
- package/tools/agents/providers/claude.mjs +8 -24
- package/tools/agents/providers/codex.mjs +18 -11
- package/tools/agents/providers/cursor.mjs +19 -18
- package/tools/agents/providers/grok-build.mjs +3 -1
- package/tools/agents/providers/grokbot.mjs +11 -12
- package/tools/agents/providers/hermes.mjs +62 -49
- package/tools/agents/providers/omp.mjs +5 -2
- package/tools/agents/providers/openclaw-translator.mjs +19 -5
- package/tools/agents/providers/openclaw.mjs +9 -4
- package/tools/agents/providers/pi.mjs +5 -0
- package/tools/agents/providers/provider-prepare-channel.mjs +5 -0
- package/tools/agents/providers/provider-prepare-coordinator.mjs +247 -0
- package/tools/agents/providers/provider-prepare-worker.mjs +84 -0
- package/tools/agents/providers/rule-delivery.mjs +1270 -0
- package/tools/agents/providers/warp.mjs +20 -26
- package/tools/cli/decision-offload-report.mjs +40 -0
- package/tools/cli/workspace-status.mjs +862 -0
- package/tools/plugin/package-plugins.mjs +186 -8
- package/tools/plugin/plugin-links.mjs +114 -0
- package/tools/providers/antigravity-transport.mjs +3 -1
- package/tools/providers/deepseek-harness-transport.mjs +360 -0
- package/tools/providers/omp-transport.mjs +194 -0
- package/tools/ralph-external/lib/claude-adapter.mjs +389 -0
- package/tools/ralph-external/lib/codex-adapter.mjs +432 -0
- package/tools/ralph-external/lib/consecutive-failure-circuit-breaker.mjs +1748 -0
- package/tools/ralph-external/lib/deepseek-harness-adapter.mjs +397 -0
- package/tools/ralph-external/lib/factory-adapter.mjs +503 -0
- package/tools/ralph-external/lib/launcher-recovery-evidence.mjs +55 -0
- package/tools/ralph-external/lib/muse-adapter.mjs +364 -0
- package/tools/ralph-external/lib/omp-adapter.mjs +315 -0
- package/tools/ralph-external/lib/opencode-adapter.mjs +575 -0
- package/tools/ralph-external/lib/openhuman-adapter.mjs +75 -0
- package/tools/ralph-external/lib/pi-adapter.mjs +329 -0
- package/tools/ralph-external/lib/provider-adapter.mjs +748 -0
- package/tools/ralph-external/lib/recovery-probe.mjs +72 -0
- package/tools/ralph-external/lib/session-environment.mjs +28 -0
- package/tools/ralph-external/lib/systemd-client.mjs +49 -0
- package/tools/ralph-external/lib/worker-health.mjs +439 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +717 -0
- package/tools/ralph-external/lib/worker-overflow.mjs +50 -0
- package/tools/ralph-external/process-monitor.mjs +1017 -0
- package/tools/ralph-external/session-launcher.mjs +5057 -0
- package/tools/scripts/resource-preflight.mjs +541 -0
- package/tools/skills/deploy-skills-codex.mjs +2 -1
- package/vscode-extension/schemas/aiwg.config.v1.json +2916 -0
|
@@ -27,6 +27,8 @@ try { const gfs = _require('graceful-fs'); gfs.gracefulify(realFs); fs = realFs;
|
|
|
27
27
|
import path from 'path';
|
|
28
28
|
import { spawn } from 'child_process';
|
|
29
29
|
import {
|
|
30
|
+
withRuleDeployment,
|
|
31
|
+
parseRuleActivation,
|
|
30
32
|
ensureDir,
|
|
31
33
|
listMdFiles,
|
|
32
34
|
listMdFilesRecursive,
|
|
@@ -117,25 +119,20 @@ export function transformCommand(srcPath, content, opts) {
|
|
|
117
119
|
return content;
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
/**
|
|
121
|
-
* Transform rule content for Cursor — inject MDC frontmatter with the
|
|
122
|
-
* activation mode mapping per ADR-2 (rule activation mode schema).
|
|
123
|
-
*
|
|
124
|
-
* Reads the source rule's `activation:` field (or defaults to alwaysApply
|
|
125
|
-
* per ADR-2 §2 default-preservation) and emits the corresponding MDC
|
|
126
|
-
* frontmatter fields:
|
|
127
|
-
* - alwaysApply (true): activation === 'alwaysApply' (default)
|
|
128
|
-
* - alwaysApply (false), no globs: activation === 'auto'
|
|
129
|
-
* - globs: activation === 'glob' + globs: '<pattern>'
|
|
130
|
-
* - alwaysApply (false), description: activation === 'manual'
|
|
131
|
-
*
|
|
132
|
-
* Per ADR-2 §5: until the live-Cursor smoke test gate is in CI, all rules
|
|
133
|
-
* deploy with alwaysApply: true regardless of source `activation` value
|
|
134
|
-
* (with a deploy-time warning when the source declared a non-alwaysApply
|
|
135
|
-
* mode). The deploy-time warning is emitted by the deployer, not this
|
|
136
|
-
* transform.
|
|
137
|
-
*/
|
|
122
|
+
/** Compile the shared five-mode activation contract to native MDC. */
|
|
138
123
|
export function transformRule(srcPath, content, opts) {
|
|
124
|
+
const parsed = parseRuleActivation(content);
|
|
125
|
+
if (!parsed.valid) throw new Error(`${srcPath}: ${parsed.diagnostics.map(d => d.message).join('; ')}`);
|
|
126
|
+
if (parsed.rule.tagged) {
|
|
127
|
+
const rule = parsed.rule;
|
|
128
|
+
// Bound/on-demand rules have no auto-selection description or glob hint.
|
|
129
|
+
const fields = rule.activation === 'paths'
|
|
130
|
+
? `globs: ${JSON.stringify(rule.paths)}\nalwaysApply: false`
|
|
131
|
+
: rule.activation === 'summary'
|
|
132
|
+
? `description: ${JSON.stringify(rule.summary)}\nalwaysApply: false`
|
|
133
|
+
: `alwaysApply: ${rule.activation === 'kernel'}`;
|
|
134
|
+
return `---\n${fields}\n---\n${parsed.body}`;
|
|
135
|
+
}
|
|
139
136
|
// Detect proper YAML frontmatter — must close within the first 30 lines.
|
|
140
137
|
// Files with `---` horizontal rules deeper in markdown content (like
|
|
141
138
|
// RULES-INDEX.md) can have multiple `---` lines without being frontmatter;
|
|
@@ -451,6 +448,10 @@ export function getFileExtension(type) {
|
|
|
451
448
|
* Orchestrates deployment of agents, commands, skills, and rules
|
|
452
449
|
*/
|
|
453
450
|
export async function deploy(opts) {
|
|
451
|
+
return withRuleDeployment(opts, { name, paths, kernelSkillsPath, transformRule }, deploySelected);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async function deploySelected(opts) {
|
|
454
455
|
const {
|
|
455
456
|
srcRoot,
|
|
456
457
|
target,
|
|
@@ -216,7 +216,9 @@ function regularFiles(dir, prefix = '') {
|
|
|
216
216
|
function matchesSkillSource(source, target) {
|
|
217
217
|
try {
|
|
218
218
|
const expected = regularFiles(source);
|
|
219
|
-
|
|
219
|
+
// The marker and the per-skill ownership receipt are AIWG bookkeeping,
|
|
220
|
+
// not skill content, so neither makes a deployed skill look modified.
|
|
221
|
+
const actual = regularFiles(target).filter(name => name !== '.aiwg-managed' && name !== '.aiwg-manifest.json');
|
|
220
222
|
if (JSON.stringify(expected) !== JSON.stringify(actual)) return false;
|
|
221
223
|
return expected.every(relative => {
|
|
222
224
|
if (relative.endsWith(path.sep)) return true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Grok Bot provider (
|
|
2
|
+
* Grok Bot provider (stable).
|
|
3
3
|
*
|
|
4
4
|
* Discover-first project bridge + fail-closed user skill root.
|
|
5
5
|
* Never targets `.cursor/**` or invents `~/.grokbot`.
|
|
@@ -127,21 +127,18 @@ export function deployRules() {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* Deploy skills only
|
|
130
|
+
* Deploy skills only at user scope with AIWG_GROKBOT_SKILLS_DIR configured.
|
|
131
131
|
* Kernel → configured root; standard → index/discovery unless --copy-all
|
|
132
132
|
* (then `<root>/.aiwg/skills`).
|
|
133
133
|
*/
|
|
134
134
|
export function deploySkills(skillDirs, targetDir, opts = {}) {
|
|
135
|
-
|
|
136
|
-
if (!root) {
|
|
135
|
+
if (opts.userScope !== true && opts.scope !== 'user') {
|
|
137
136
|
if (!opts.quiet) {
|
|
138
|
-
console.log(
|
|
139
|
-
`\n Grok Bot: skipping native skill copy (${SKILLS_DIR_ENV} unset). ` +
|
|
140
|
-
'Skills remain available via aiwg discover / aiwg show.',
|
|
141
|
-
);
|
|
137
|
+
console.log('\n Grok Bot: project bridge only; native skills require --scope user.');
|
|
142
138
|
}
|
|
143
139
|
return 0;
|
|
144
140
|
}
|
|
141
|
+
const root = assertUserScopeConfigured(opts);
|
|
145
142
|
|
|
146
143
|
if (root.includes(`${path.sep}.cursor${path.sep}`) || root.endsWith(`${path.sep}.cursor`) || root.includes('/.cursor/') || root.endsWith('/.cursor')) {
|
|
147
144
|
throw new Error(
|
|
@@ -178,14 +175,14 @@ export async function postDeploy(targetDir, opts = {}) {
|
|
|
178
175
|
}
|
|
179
176
|
if (!opts.quiet) {
|
|
180
177
|
const root = resolveGrokbotSkillsDir(opts.env || process.env);
|
|
181
|
-
if (root) {
|
|
178
|
+
if (root && (opts.userScope === true || opts.scope === 'user')) {
|
|
182
179
|
console.log(
|
|
183
180
|
'Grok Bot: after deploy, start a new agent chat or re-read skills. ' +
|
|
184
181
|
'Live refresh is not claimed until product behavior is verified.',
|
|
185
182
|
);
|
|
186
183
|
} else {
|
|
187
184
|
console.log(
|
|
188
|
-
`Grok Bot: project bridge only.
|
|
185
|
+
`Grok Bot: project bridge only. Use --scope user with ${SKILLS_DIR_ENV} for native skills.`,
|
|
189
186
|
);
|
|
190
187
|
}
|
|
191
188
|
}
|
|
@@ -197,7 +194,7 @@ export function getFileExtension() {
|
|
|
197
194
|
|
|
198
195
|
/**
|
|
199
196
|
* Assert user-scope is allowed. Called when the orchestrator is mirroring
|
|
200
|
-
* to user scope or when opts.scope === 'user'.
|
|
197
|
+
* to user scope or when opts.userScope === true / opts.scope === 'user'.
|
|
201
198
|
*/
|
|
202
199
|
export function assertUserScopeConfigured(opts = {}) {
|
|
203
200
|
const root = resolveGrokbotSkillsDir(opts.env || process.env);
|
|
@@ -227,7 +224,9 @@ export async function deploy(opts = {}) {
|
|
|
227
224
|
console.log(`Mode: ${mode}`);
|
|
228
225
|
const root = resolveGrokbotSkillsDir(opts.env || process.env);
|
|
229
226
|
console.log(
|
|
230
|
-
|
|
227
|
+
(opts.userScope === true || scope === 'user')
|
|
228
|
+
? `User skills root: ${root || `(unset — set ${SKILLS_DIR_ENV})`}`
|
|
229
|
+
: 'Skills: project bridge only (no native skill writes)',
|
|
231
230
|
);
|
|
232
231
|
if (opts.dryRun) console.log('Dry-run: no filesystem mutations');
|
|
233
232
|
}
|
|
@@ -24,9 +24,9 @@ import path from 'path';
|
|
|
24
24
|
import os from 'os';
|
|
25
25
|
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
|
26
26
|
import {
|
|
27
|
+
withRuleDeployment,
|
|
27
28
|
ensureDir,
|
|
28
29
|
listMdFiles,
|
|
29
|
-
listSkillDirs,
|
|
30
30
|
deploySkillDir,
|
|
31
31
|
deploySkillsWithKernelRouting,
|
|
32
32
|
isKernelSkill,
|
|
@@ -193,8 +193,8 @@ export function mapModel(shorthand, modelCfg, modelsConfig) {
|
|
|
193
193
|
/**
|
|
194
194
|
* Generate a lean AGENTS.md for Hermes
|
|
195
195
|
*
|
|
196
|
-
* Hermes
|
|
197
|
-
*
|
|
196
|
+
* Hermes reaches AGENTS.md through its startup pointer on every task. Reserve
|
|
197
|
+
* the 19,000-character budget for CRITICAL kernel bodies and the kernel index.
|
|
198
198
|
* See: docs/integrations/hermes-quickstart.md (Part 3)
|
|
199
199
|
*/
|
|
200
200
|
// Hermes context cap is 20K chars (head-tail truncated above). Hard limit
|
|
@@ -202,6 +202,23 @@ export function mapModel(shorthand, modelCfg, modelsConfig) {
|
|
|
202
202
|
const HERMES_AGENTS_MD_HARD_CAP = 19_000;
|
|
203
203
|
const HERMES_AGENTS_MD_SOFT_WARN = 15_000;
|
|
204
204
|
|
|
205
|
+
/** Never truncate CRITICAL bodies. Report each contribution before promotion. */
|
|
206
|
+
export function assertContextBudget(content, name = 'AGENTS.md', rules = []) {
|
|
207
|
+
if (content.length <= HERMES_AGENTS_MD_HARD_CAP) return;
|
|
208
|
+
const critical = rules.filter(rule => rule.tagged && rule.activation === 'kernel'
|
|
209
|
+
&& String(rule.enforcement || '').trim().toLowerCase() === 'critical');
|
|
210
|
+
const sizes = critical.map(rule => ({ name: rule.name,
|
|
211
|
+
chars: `## Rule: ${rule.name}\n\n${rule.body.trim()}`.length }));
|
|
212
|
+
const total = sizes.reduce((sum, rule) => sum + rule.chars, 0) + Math.max(0, sizes.length - 1) * 2;
|
|
213
|
+
throw new Error(
|
|
214
|
+
`Hermes ${name} (${content.length} chars) exceeds hard cap of ${HERMES_AGENTS_MD_HARD_CAP}. ` +
|
|
215
|
+
`Hermes truncates above 20K. ` +
|
|
216
|
+
(total > HERMES_AGENTS_MD_HARD_CAP ? 'CRITICAL kernel set alone exceeds the cap. ' : 'Assembled context exceeds the cap; review wrappers and operator additions. ') +
|
|
217
|
+
`CRITICAL kernel total: ${total} chars (bodies and rule headings).\n` +
|
|
218
|
+
sizes.map(rule => ` ${rule.name}: ${rule.chars} chars`).join('\n')
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
205
222
|
/**
|
|
206
223
|
* Top-7 CRITICAL rule directives, inlined into AGENTS.md for guaranteed
|
|
207
224
|
* priming on every Hermes turn (#1318 / S7; skill-discovery added #1347).
|
|
@@ -298,41 +315,32 @@ surface as provider-agnostic tools when configured.
|
|
|
298
315
|
**Artifacts** (project-required, .aiwg/ directory):
|
|
299
316
|
- \`mcp_aiwg_artifact_read\` / \`mcp_aiwg_artifact_write\``;
|
|
300
317
|
|
|
318
|
+
function mergeHermesContext(file, generated, kind) {
|
|
319
|
+
let existing = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
|
|
320
|
+
existing = existing.replace(/\n?<!-- AIWG:rule-startup:start -->[\s\S]*?<!-- AIWG:rule-startup:end -->\n?/g, '');
|
|
321
|
+
const start = `<!-- AIWG:hermes-${kind}:start -->`;
|
|
322
|
+
const end = `<!-- AIWG:hermes-${kind}:end -->`;
|
|
323
|
+
const managed = `${start}\n${generated}\n${end}`;
|
|
324
|
+
if (existing.includes(start)) return existing.slice(0, existing.indexOf(start)) + managed + existing.slice(existing.indexOf(end) + end.length);
|
|
325
|
+
if (kind === 'context' && existing.startsWith('# AIWG Integration') && existing.includes(HERMES_AGENTS_MD_FOOTER)) {
|
|
326
|
+
existing = existing.slice(existing.indexOf(HERMES_AGENTS_MD_FOOTER) + HERMES_AGENTS_MD_FOOTER.length);
|
|
327
|
+
} else if (kind === 'routing' && existing.includes(generated)) {
|
|
328
|
+
existing = existing.replace(generated, '');
|
|
329
|
+
}
|
|
330
|
+
return existing ? `${existing.trimEnd()}\n\n${managed}\n` : `<!-- aiwg-managed -->\n${managed}\n`;
|
|
331
|
+
}
|
|
332
|
+
|
|
301
333
|
export function generateAgentsMd(agentCount, skillCount, targetDir, opts) {
|
|
302
334
|
const { dryRun } = opts;
|
|
303
335
|
|
|
336
|
+
// Startup is reserved for rule contracts. Workflow routing, artifact catalogs,
|
|
337
|
+
// and the optional MCP tool inventory duplicate discover/show and consume
|
|
338
|
+
// Hermes's finite per-turn context before the kernel is appended.
|
|
304
339
|
const header = `# AIWG Integration
|
|
305
340
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
Use \`aiwg discover\` and \`aiwg show <type> <name>\` for the on-demand catalog.
|
|
310
|
-
The MCP sidecar (\`aiwg mcp serve\`) is optional.
|
|
311
|
-
|
|
312
|
-
## Route to AIWG When
|
|
313
|
-
|
|
314
|
-
- Structured artifacts needed (requirements, architecture, test plans, risk registers)
|
|
315
|
-
- Multi-step workflows with phase gates or checkpoints
|
|
316
|
-
- Template-driven output that persists across sessions
|
|
317
|
-
|
|
318
|
-
Handle in Hermes directly: one-off questions, short tasks, conversation.
|
|
319
|
-
|
|
320
|
-
## Memory Boundary
|
|
321
|
-
|
|
322
|
-
When AIWG returns an artifact: store path + one-sentence summary in MEMORY.md.
|
|
323
|
-
Do NOT copy artifact body text into memory. Reference, don't replicate.
|
|
324
|
-
|
|
325
|
-
Use \`delegate_task(goal="...", context="...")\` for AIWG workflows.
|
|
326
|
-
Child agents automatically exclude context files and memory.
|
|
327
|
-
|
|
328
|
-
## Artifact Store (.aiwg/)
|
|
329
|
-
|
|
330
|
-
Fetch on demand via \`mcp_aiwg_artifact_read\`:
|
|
331
|
-
- \`requirements/\` — use cases, user stories
|
|
332
|
-
- \`architecture/\` — SAD, ADRs
|
|
333
|
-
- \`planning/\` — phase plans
|
|
334
|
-
- \`testing/\` — test strategy
|
|
335
|
-
- \`security/\` — threat models
|
|
341
|
+
Skills: \`$HERMES_HOME/skills/\` (kernel), \`$HERMES_HOME/skills/.aiwg/\` (standard).
|
|
342
|
+
Find: \`aiwg discover "rule <topic>" --type rule\`. Fetch: \`aiwg show rule <name>\`.
|
|
343
|
+
MCP is optional; \`mcp_aiwg_rule_show\` exposes the same rule catalog.
|
|
336
344
|
`;
|
|
337
345
|
|
|
338
346
|
// On-demand tier (#1675): the MEDIUM/LOW rules not inlined above. Hermes has
|
|
@@ -340,18 +348,15 @@ Fetch on demand via \`mcp_aiwg_artifact_read\`:
|
|
|
340
348
|
const onDemandSection = opts.srcRoot
|
|
341
349
|
? renderOnDemandRuleSection(listOnDemandRuleFiles(opts.srcRoot))
|
|
342
350
|
: '';
|
|
343
|
-
const
|
|
351
|
+
const migrated = new Set((opts.ruleDelivery?.rules || []).filter(rule => rule.tagged).map(rule => rule.name));
|
|
352
|
+
const directives = CRITICAL_RULE_DIRECTIVES.split(/(?=^### Rule: )/m).filter(section => section.startsWith('### Rule: ') && !migrated.has(section.match(/^### Rule: ([^ \n]+)/)?.[1])).join('');
|
|
353
|
+
const sections = [header, directives];
|
|
344
354
|
if (onDemandSection) sections.push(onDemandSection);
|
|
345
|
-
|
|
346
|
-
const output = sections.join('\n\n');
|
|
355
|
+
// The optional tool inventory is available on demand through the CLI.
|
|
347
356
|
const destPath = path.join(targetDir, 'AGENTS.md');
|
|
357
|
+
const output = mergeHermesContext(destPath, sections.join('\n\n'), 'context');
|
|
348
358
|
|
|
349
|
-
|
|
350
|
-
throw new Error(
|
|
351
|
-
`Hermes AGENTS.md (${output.length} chars) exceeds hard cap of ${HERMES_AGENTS_MD_HARD_CAP}. ` +
|
|
352
|
-
`Hermes truncates above 20K. Trim the priming block or split rule bodies further.`
|
|
353
|
-
);
|
|
354
|
-
}
|
|
359
|
+
assertContextBudget(output, 'AGENTS.md', opts.ruleDelivery?.rules);
|
|
355
360
|
|
|
356
361
|
if (dryRun) {
|
|
357
362
|
console.log(`[dry-run] Would write AGENTS.md (${output.length} chars, ${Math.round(output.length / 4)} tokens estimated)`);
|
|
@@ -398,7 +403,7 @@ when the full AIWG project context is needed.
|
|
|
398
403
|
if (dryRun) {
|
|
399
404
|
console.log(`[dry-run] Would write .hermes.md (${body.length} chars)`);
|
|
400
405
|
} else {
|
|
401
|
-
fs.writeFileSync(destPath, body, 'utf8');
|
|
406
|
+
fs.writeFileSync(destPath, mergeHermesContext(destPath, body, 'routing'), 'utf8');
|
|
402
407
|
console.log(` Created .hermes.md (${body.length} chars)`);
|
|
403
408
|
}
|
|
404
409
|
return 1;
|
|
@@ -418,7 +423,7 @@ when the full AIWG project context is needed.
|
|
|
418
423
|
*/
|
|
419
424
|
export function deploySkills(skillDirs, opts) {
|
|
420
425
|
const standardDestDir = paths.skills;
|
|
421
|
-
const kernelDestDir = kernelSkillsPath;
|
|
426
|
+
const kernelDestDir = opts.kernelSkillsPath || kernelSkillsPath;
|
|
422
427
|
|
|
423
428
|
if (!opts.dryRun) {
|
|
424
429
|
console.log(` Deploying ${skillDirs.length} skills (kernel + standard split)...`);
|
|
@@ -432,6 +437,10 @@ export function deploySkills(skillDirs, opts) {
|
|
|
432
437
|
// ============================================================================
|
|
433
438
|
|
|
434
439
|
export async function deploy(opts) {
|
|
440
|
+
return withRuleDeployment(opts, { name, paths, kernelSkillsPath, assertContextBudget }, deploySelected);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async function deploySelected(opts) {
|
|
435
444
|
const {
|
|
436
445
|
srcRoot,
|
|
437
446
|
target,
|
|
@@ -466,7 +475,7 @@ export async function deploy(opts) {
|
|
|
466
475
|
if ((shouldDeploySkills || skillsOnly) && !opts.commandsOnly && !opts.rulesOnly) {
|
|
467
476
|
const allSkillDirs = [];
|
|
468
477
|
|
|
469
|
-
// Addon skills (
|
|
478
|
+
// Addon skills, including a direct addon source (#2873, #3035).
|
|
470
479
|
allSkillDirs.push(...getAddonSkillDirs(srcRoot));
|
|
471
480
|
|
|
472
481
|
// Framework skills
|
|
@@ -510,7 +519,7 @@ export async function deploy(opts) {
|
|
|
510
519
|
const kernelNames = computeAllKernelNames(srcRoot);
|
|
511
520
|
if (kernelNames != null) {
|
|
512
521
|
const desiredKernel = [...kernelNames, 'aiwg-orchestrate'];
|
|
513
|
-
pruneStaleAiwgSkills(kernelSkillsPath, desiredKernel, opts);
|
|
522
|
+
pruneStaleAiwgSkills(opts.kernelSkillsPath || kernelSkillsPath, desiredKernel, opts);
|
|
514
523
|
|
|
515
524
|
// Register kernel skills in Hermes's bundled manifest so the Curator
|
|
516
525
|
// (v0.12.0+, 7-day archival cycle) does not archive them. Standard
|
|
@@ -604,7 +613,7 @@ export async function deploy(opts) {
|
|
|
604
613
|
*/
|
|
605
614
|
export function updateBundledManifest(kernelSkillNames, opts) {
|
|
606
615
|
const { dryRun, quiet } = opts;
|
|
607
|
-
const manifestPath = path.join(kernelSkillsPath, '.bundled_manifest');
|
|
616
|
+
const manifestPath = path.join(opts.kernelSkillsPath || kernelSkillsPath, '.bundled_manifest');
|
|
608
617
|
const aiwgTag = 'aiwg-managed';
|
|
609
618
|
|
|
610
619
|
// Read existing manifest (if any) and split into "ours" vs "theirs"
|
|
@@ -665,7 +674,11 @@ export function updateBundledManifest(kernelSkillNames, opts) {
|
|
|
665
674
|
*/
|
|
666
675
|
export function migrateLegacySkillPath(opts) {
|
|
667
676
|
const { dryRun, quiet } = opts;
|
|
668
|
-
|
|
677
|
+
// Resolve through the same HERMES_HOME contract as every other path in
|
|
678
|
+
// this provider (env var first, platform default otherwise): with
|
|
679
|
+
// HERMES_HOME set, the legacy tree lives under that root — never under
|
|
680
|
+
// the process home directory.
|
|
681
|
+
const legacyPath = opts.hermesLegacySkills || path.join(getHermesHome(), '.aiwg', 'skills');
|
|
669
682
|
const newPath = paths.skills;
|
|
670
683
|
|
|
671
684
|
let legacyExists = false;
|
|
@@ -751,7 +764,7 @@ function deployAiwgOrchestrateSkill(srcRoot, opts) {
|
|
|
751
764
|
return;
|
|
752
765
|
}
|
|
753
766
|
|
|
754
|
-
const destDir = path.join(kernelSkillsPath, 'aiwg-orchestrate');
|
|
767
|
+
const destDir = path.join(opts.kernelSkillsPath || kernelSkillsPath, 'aiwg-orchestrate');
|
|
755
768
|
const destPath = path.join(destDir, 'SKILL.md');
|
|
756
769
|
|
|
757
770
|
if (fs.existsSync(destPath)) {
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import YAML from 'yaml';
|
|
6
|
-
import {
|
|
6
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
7
7
|
import { collectFrameworkArtifacts, getAddonFiles, isKernelSkill, listMdFiles, listSkillDirs, normalizeDeploymentMode, resolveAiwgRoot } from './base.mjs';
|
|
8
8
|
export const name = 'omp';
|
|
9
9
|
export const aliases = ['oh-my-pi'];
|
|
@@ -18,7 +18,10 @@ function parse(content) {
|
|
|
18
18
|
}
|
|
19
19
|
const render = (metadata, body) => `---\n${YAML.stringify(metadata)}---\n\n${body.trim()}\n`;
|
|
20
20
|
function diagnostic(opts, message) { opts.diagnostics?.push(message); if (!opts.quiet) console.warn(`OMP: ${message}`); }
|
|
21
|
-
|
|
21
|
+
// Resolved through the shared resolver: an installed package ships these
|
|
22
|
+
// modules under dist/src, not src, so a literal path into src fails there.
|
|
23
|
+
const { resolveOmpPaths } = await importImpl(import.meta.url, 'providers/omp-paths.mjs');
|
|
24
|
+
const { transformAgent, mapModel } = await importImpl(import.meta.url, 'providers/omp-agent.mjs');
|
|
22
25
|
export { transformAgent, mapModel };
|
|
23
26
|
const array = value => Array.isArray(value) ? value : typeof value === 'string' ? value.split(',').map(s => s.trim()).filter(Boolean) : [];
|
|
24
27
|
export function transformCommand(src, content, opts = {}) {
|
|
@@ -120,6 +120,20 @@ function parseBehaviorFrontmatter(content) {
|
|
|
120
120
|
return frontmatter;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/** Encode a complete YAML double-quoted scalar. */
|
|
124
|
+
function yamlString(value) {
|
|
125
|
+
return JSON.stringify(value)
|
|
126
|
+
.replace(/\u0085/g, '\\u0085')
|
|
127
|
+
.replace(/\u2028/g, '\\u2028')
|
|
128
|
+
.replace(/\u2029/g, '\\u2029');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Keep metadata within a single line or block comment. */
|
|
132
|
+
function escapeComment(value) {
|
|
133
|
+
return String(value).replace(/\*\//g, '* /')
|
|
134
|
+
.replace(/[\r\n\u2028\u2029]/g, (char) => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
135
|
+
}
|
|
136
|
+
|
|
123
137
|
/**
|
|
124
138
|
* Render the HOOK.md content for OpenClaw's hook loader.
|
|
125
139
|
*
|
|
@@ -133,15 +147,15 @@ function parseBehaviorFrontmatter(content) {
|
|
|
133
147
|
export function renderHookMd(behavior) {
|
|
134
148
|
const events = Object.keys(behavior.hooks || {});
|
|
135
149
|
const eventsList = events.length > 0
|
|
136
|
-
? events.map((e) => ` - ${e}`).join('\n')
|
|
150
|
+
? events.map((e) => ` - ${yamlString(e)}`).join('\n')
|
|
137
151
|
: ' []';
|
|
138
152
|
|
|
139
|
-
const description = (behavior.description || '').
|
|
153
|
+
const description = yamlString((behavior.description || '').slice(0, 200));
|
|
140
154
|
|
|
141
155
|
return [
|
|
142
156
|
'---',
|
|
143
|
-
`name: ${behavior.name}`,
|
|
144
|
-
`description:
|
|
157
|
+
`name: ${yamlString(behavior.name)}`,
|
|
158
|
+
`description: ${description}`,
|
|
145
159
|
'events:',
|
|
146
160
|
eventsList,
|
|
147
161
|
'handler: ./handler.js',
|
|
@@ -193,7 +207,7 @@ export function renderHandlerJs(behavior, scriptsRelDir = './scripts') {
|
|
|
193
207
|
|
|
194
208
|
return `#!/usr/bin/env node
|
|
195
209
|
// Generated by AIWG (PUW-008/PUW-009). Do not edit; regenerated on \`aiwg use\`.
|
|
196
|
-
// Handler for OpenClaw hook \`${behavior.name}\`. Dispatches to scripts in
|
|
210
|
+
// Handler for OpenClaw hook \`${escapeComment(behavior.name)}\`. Dispatches to scripts in
|
|
197
211
|
// ./scripts/ based on the event delivered by OpenClaw's hook loader.
|
|
198
212
|
//
|
|
199
213
|
// Stdin contract (AIWG canonical, per ADR-3 §3):
|
|
@@ -26,6 +26,7 @@ try { const gfs = _require('graceful-fs'); gfs.gracefulify(realFs); fs = realFs;
|
|
|
26
26
|
import path from 'path';
|
|
27
27
|
import os from 'os';
|
|
28
28
|
import {
|
|
29
|
+
withRuleDeployment,
|
|
29
30
|
ensureDir,
|
|
30
31
|
listMdFiles,
|
|
31
32
|
listMdFilesRecursive,
|
|
@@ -191,7 +192,7 @@ function deploySkills(skillDirs, opts) {
|
|
|
191
192
|
// Standard: ~/.openclaw/.aiwg/skills/ (no extra aiwg/ — the .aiwg/ segment IS the namespace)
|
|
192
193
|
const standardDestDir = paths.skills;
|
|
193
194
|
// Kernel: ~/.openclaw/skills/aiwg/ (preserves legacy 2-level namespacing)
|
|
194
|
-
const kernelDestDir = path.join(kernelSkillsPath, 'aiwg');
|
|
195
|
+
const kernelDestDir = path.join(opts.kernelSkillsPath || kernelSkillsPath, 'aiwg');
|
|
195
196
|
|
|
196
197
|
deploySkillsWithKernelRouting(skillDirs, standardDestDir, kernelDestDir, opts);
|
|
197
198
|
|
|
@@ -396,6 +397,10 @@ export function getFileExtension(type) {
|
|
|
396
397
|
// ============================================================================
|
|
397
398
|
|
|
398
399
|
export async function deploy(opts) {
|
|
400
|
+
return withRuleDeployment(opts, { name, paths, kernelSkillsPath, resolveOpenClawWorkspace }, deploySelected);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
async function deploySelected(opts) {
|
|
399
404
|
const {
|
|
400
405
|
srcRoot,
|
|
401
406
|
mode,
|
|
@@ -485,9 +490,9 @@ export async function deploy(opts) {
|
|
|
485
490
|
// (`aiwg use` invokes deploy-agents.mjs once per framework + addon
|
|
486
491
|
// batch).
|
|
487
492
|
{
|
|
488
|
-
const _kernelDestDir = path.isAbsolute(kernelSkillsPath)
|
|
493
|
+
const _kernelDestDir = opts.kernelSkillsPath || (path.isAbsolute(kernelSkillsPath)
|
|
489
494
|
? kernelSkillsPath
|
|
490
|
-
: path.join(target, kernelSkillsPath);
|
|
495
|
+
: path.join(target, kernelSkillsPath));
|
|
491
496
|
pruneStaleAiwgSkills(_kernelDestDir, computeAllKernelNames(srcRoot), opts);
|
|
492
497
|
}
|
|
493
498
|
}
|
|
@@ -549,7 +554,7 @@ export async function deploy(opts) {
|
|
|
549
554
|
srcRoot, 'agentic', 'code', 'frameworks', 'sdlc-complete', 'templates', 'openclaw', 'AGENTS.md.aiwg-template',
|
|
550
555
|
);
|
|
551
556
|
if (fs.existsSync(templatePath)) {
|
|
552
|
-
const workspace = resolveOpenClawWorkspace();
|
|
557
|
+
const workspace = opts.activeWorkspace || resolveOpenClawWorkspace();
|
|
553
558
|
ensureDir(workspace, dryRun);
|
|
554
559
|
if (verbose || !opts.quiet) {
|
|
555
560
|
console.log(`\nBridging AIWG context into ${path.join(workspace, 'AGENTS.md')} + SOUL.md (#1562/#1572)...`);
|
|
@@ -11,6 +11,7 @@ import path from 'path';
|
|
|
11
11
|
import fs from 'fs';
|
|
12
12
|
import {
|
|
13
13
|
collectFrameworkArtifacts,
|
|
14
|
+
withRuleDeployment,
|
|
14
15
|
createAgentsMdFromTemplate,
|
|
15
16
|
deployFiles,
|
|
16
17
|
deploySkillsWithKernelRouting,
|
|
@@ -139,6 +140,10 @@ export function getFileExtension() {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
export async function deploy(opts) {
|
|
143
|
+
return withRuleDeployment(opts, { name, paths, kernelSkillsPath }, deploySelected);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function deploySelected(opts) {
|
|
142
147
|
const normalizedMode = normalizeDeploymentMode(opts.mode);
|
|
143
148
|
const agentFiles = [];
|
|
144
149
|
const commandFiles = [];
|