@aiwg/cli 2026.9.20 → 2026.9.24
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/agentic/code/providers/capability-matrix.yaml +58 -6
- package/agentic/code/providers/model-capabilities.v1.json +34 -0
- package/agentic/code/providers/model-catalog.v1.json +55 -13
- package/bin/aiwg.mjs +2 -0
- package/dist/src/api/index.d.ts +1 -0
- package/dist/src/api/index.js +1 -0
- package/dist/src/artifacts/cli.js +23 -18
- package/dist/src/artifacts/enrichment/cli.js +1 -1
- package/dist/src/artifacts/fortemi-core-query-adapter.js +6 -2
- package/dist/src/artifacts/query-engine.js +14 -4
- package/dist/src/artifacts/views/cli.js +1 -1
- package/dist/src/audit/operator-decision.js +10 -0
- package/dist/src/auth/credential-store.js +127 -27
- package/dist/src/catalog/builtin-models.json +272 -40
- package/dist/src/catalog/cli.js +1 -1
- package/dist/src/catalog/cli.mjs +1 -1
- package/dist/src/cli/handlers/effect.js +872 -0
- package/dist/src/cli/handlers/help.js +2 -0
- package/dist/src/cli/handlers/index.js +4 -2
- package/dist/src/cli/handlers/models.js +41 -10
- package/dist/src/cli/handlers/ralph.js +1 -1
- package/dist/src/cli/handlers/sessions.js +113 -37
- package/dist/src/cli/handlers/subcommands.js +31 -0
- package/dist/src/cli/handlers/use.js +46 -9
- package/dist/src/cli/handlers/utilities.js +10 -0
- package/dist/src/cli/handlers/workspace.js +3 -1
- package/dist/src/cli/scope-resolver.js +112 -9
- package/dist/src/cli/services/deployment-verification.js +5 -0
- package/dist/src/config/aiwg-config.js +3 -0
- package/dist/src/decision/acceptance-rollout.js +93 -0
- package/dist/src/decision/acceptance.js +175 -0
- package/dist/src/decision/adapters/jev.js +234 -13
- package/dist/src/decision/adapters/llm-subagent.js +60 -12
- package/dist/src/decision/admission.js +550 -0
- package/dist/src/decision/batch-benchmark.js +47 -0
- package/dist/src/decision/batch-receipts/accounting.js +75 -0
- package/dist/src/decision/batch-receipts/export.js +40 -0
- package/dist/src/decision/batch-receipts/index.js +9 -0
- package/dist/src/decision/batch-receipts/protection.js +40 -0
- package/dist/src/decision/batch-receipts/receipt.js +44 -0
- package/dist/src/decision/batch-receipts/result-store.js +341 -0
- package/dist/src/decision/batch-receipts/store.js +362 -0
- package/dist/src/decision/batch-receipts/types.js +2 -0
- package/dist/src/decision/batch-receipts/validate.js +127 -0
- package/dist/src/decision/batch.js +68 -0
- package/dist/src/decision/calibration/index.js +4 -0
- package/dist/src/decision/calibration/receipts.js +130 -0
- package/dist/src/decision/calibration/registry.js +258 -0
- package/dist/src/decision/calibration/types.js +2 -0
- package/dist/src/decision/compile-cache/benchmark.js +62 -0
- package/dist/src/decision/compile-cache/compatibility.js +65 -0
- package/dist/src/decision/compile-cache/file-store.js +280 -0
- package/dist/src/decision/compile-cache/identity.js +26 -0
- package/dist/src/decision/compile-cache/index.js +9 -0
- package/dist/src/decision/compile-cache/prefix.js +21 -0
- package/dist/src/decision/compile-cache/records.js +86 -0
- package/dist/src/decision/compile-cache/runtime.js +68 -0
- package/dist/src/decision/compile-cache/store.js +108 -0
- package/dist/src/decision/compile-cache/types.js +2 -0
- package/dist/src/decision/context-plan.js +234 -0
- package/dist/src/decision/context-qualification.js +60 -0
- package/dist/src/decision/ensemble/aggregate.js +215 -0
- package/dist/src/decision/ensemble/contract.js +316 -0
- package/dist/src/decision/ensemble/drift.js +51 -0
- package/dist/src/decision/ensemble/index.js +6 -0
- package/dist/src/decision/ensemble/report.js +71 -0
- package/dist/src/decision/ensemble/types.js +2 -0
- package/dist/src/decision/evaluate.js +1024 -78
- package/dist/src/decision/file-lifecycle-store.js +168 -0
- package/dist/src/decision/graph-beam.js +40 -0
- package/dist/src/decision/graph-budget.js +110 -0
- package/dist/src/decision/graph-decision-bridge.js +93 -0
- package/dist/src/decision/graph-evidence.js +123 -0
- package/dist/src/decision/graph-flow-adapter.js +56 -0
- package/dist/src/decision/graph-flow.js +105 -0
- package/dist/src/decision/graph-parallel.js +79 -0
- package/dist/src/decision/graph-patterns.js +20 -0
- package/dist/src/decision/graph-run-store.js +66 -0
- package/dist/src/decision/graph-run.js +166 -0
- package/dist/src/decision/graph-skill-bridge.js +91 -0
- package/dist/src/decision/graph-templates.js +56 -0
- package/dist/src/decision/graph.js +115 -0
- package/dist/src/decision/index.js +35 -0
- package/dist/src/decision/job-accounting.js +93 -0
- package/dist/src/decision/job-contract.js +186 -0
- package/dist/src/decision/job-effects.js +95 -0
- package/dist/src/decision/job-evaluate.js +80 -0
- package/dist/src/decision/job-gateway.js +121 -0
- package/dist/src/decision/job-http.js +194 -0
- package/dist/src/decision/job-payload-store.js +258 -0
- package/dist/src/decision/job-poll-limiter.js +92 -0
- package/dist/src/decision/job-quota.js +158 -0
- package/dist/src/decision/job-runtime.js +240 -0
- package/dist/src/decision/job-scheduler.js +26 -0
- package/dist/src/decision/job-service.js +117 -0
- package/dist/src/decision/job-store.js +264 -0
- package/dist/src/decision/job-worker.js +141 -0
- package/dist/src/decision/lifecycle.js +148 -0
- package/dist/src/decision/patterns/artifacts.js +173 -0
- package/dist/src/decision/patterns/catalog.js +108 -0
- package/dist/src/decision/patterns/durable-review.js +237 -0
- package/dist/src/decision/patterns/index.js +8 -0
- package/dist/src/decision/patterns/playground.js +401 -0
- package/dist/src/decision/patterns/recorded.js +43 -0
- package/dist/src/decision/patterns/specs.js +174 -0
- package/dist/src/decision/patterns/types.js +2 -0
- package/dist/src/decision/portable-secrets.js +53 -0
- package/dist/src/decision/projection.js +210 -0
- package/dist/src/decision/qualification/capture.js +67 -0
- package/dist/src/decision/qualification/drift.js +68 -0
- package/dist/src/decision/qualification/gate-evidence.js +172 -0
- package/dist/src/decision/qualification/gates.js +83 -0
- package/dist/src/decision/qualification/index.js +12 -0
- package/dist/src/decision/qualification/load.js +282 -0
- package/dist/src/decision/qualification/manifest.js +37 -0
- package/dist/src/decision/qualification/privacy.js +41 -0
- package/dist/src/decision/qualification/quality.js +213 -0
- package/dist/src/decision/qualification/release.js +116 -0
- package/dist/src/decision/qualification/runner.js +408 -0
- package/dist/src/decision/qualification/types.js +2 -0
- package/dist/src/decision/receipts.js +30 -7
- package/dist/src/decision/result-cache/index.js +6 -0
- package/dist/src/decision/result-cache/integrity.js +28 -0
- package/dist/src/decision/result-cache/key.js +28 -0
- package/dist/src/decision/result-cache/service.js +92 -0
- package/dist/src/decision/result-cache/store.js +327 -0
- package/dist/src/decision/result-cache/types.js +3 -0
- package/dist/src/decision/review/authorization.js +110 -0
- package/dist/src/decision/review/effect-ledger-adapter.js +321 -0
- package/dist/src/decision/review/index.js +12 -0
- package/dist/src/decision/review/migrate.js +34 -0
- package/dist/src/decision/review/operator-audit.js +59 -0
- package/dist/src/decision/review/recovery-adapters.js +252 -0
- package/dist/src/decision/review/recovery.js +33 -0
- package/dist/src/decision/review/service.js +498 -0
- package/dist/src/decision/review/store.js +219 -0
- package/dist/src/decision/review/types.js +2 -0
- package/dist/src/decision/review/validate.js +205 -0
- package/dist/src/decision/scheduler.js +115 -0
- package/dist/src/decision/telemetry/context.js +42 -0
- package/dist/src/decision/telemetry/debug-sidecar.js +152 -0
- package/dist/src/decision/telemetry/exporter.js +77 -0
- package/dist/src/decision/telemetry/file-debug-backend.js +112 -0
- package/dist/src/decision/telemetry/index.js +13 -0
- package/dist/src/decision/telemetry/mapping.js +146 -0
- package/dist/src/decision/telemetry/metrics.js +164 -0
- package/dist/src/decision/telemetry/otlp-http.js +183 -0
- package/dist/src/decision/telemetry/redaction.js +93 -0
- package/dist/src/decision/telemetry/retention.js +109 -0
- package/dist/src/decision/telemetry/runtime.js +310 -0
- package/dist/src/decision/telemetry/trace.js +158 -0
- package/dist/src/decision/telemetry/types.js +3 -0
- package/dist/src/decision/validate.js +135 -5
- package/dist/src/effects/checkpoint-sinks.js +94 -0
- package/dist/src/effects/checkpoint.js +76 -0
- package/dist/src/effects/decision-links.js +54 -0
- package/dist/src/effects/errors.js +48 -0
- package/dist/src/effects/identity.js +178 -0
- package/dist/src/effects/index.js +25 -0
- package/dist/src/effects/keyring.js +160 -0
- package/dist/src/effects/keys.js +130 -0
- package/dist/src/effects/ledger.js +435 -0
- package/dist/src/effects/lifecycle.js +110 -0
- package/dist/src/effects/lock-recovery.js +269 -0
- package/dist/src/effects/reader.js +103 -0
- package/dist/src/effects/records.js +114 -0
- package/dist/src/effects/redaction.js +51 -0
- package/dist/src/effects/schema.js +73 -0
- package/dist/src/effects/store.js +239 -0
- package/dist/src/effects/types.js +49 -0
- package/dist/src/effects/verifiers/decision.js +168 -0
- package/dist/src/effects/verifiers/file.js +106 -0
- package/dist/src/effects/verifiers/git.js +206 -0
- package/dist/src/effects/verifiers/index.js +90 -0
- package/dist/src/effects/verifiers/registry.js +148 -0
- package/dist/src/effects/verifiers/review.js +123 -0
- package/dist/src/effects/verifiers/tracker.js +299 -0
- package/dist/src/effects/verifiers/types.js +21 -0
- package/dist/src/effects/verify.js +295 -0
- package/dist/src/evidence/bundle.js +2 -0
- package/dist/src/extensions/commands/definitions.js +28 -0
- package/dist/src/extensions/manifest.js +1 -0
- package/dist/src/marketplace/provenance.js +25 -27
- package/dist/src/mcp/cli.mjs +11 -1
- package/dist/src/mcp/grok-build-config.mjs +189 -0
- package/dist/src/mcp/registry.js +21 -1
- package/dist/src/mcp/registry.mjs +20 -1
- package/dist/src/models/grok-build-models.js +356 -0
- package/dist/src/models/index.js +1 -0
- package/dist/src/models/model-capabilities.v1.json +34 -0
- package/dist/src/models/model-catalog.v1.json +55 -13
- package/dist/src/models/model-discovery.js +41 -5
- package/dist/src/models/provider-policy.js +3 -2
- package/dist/src/plugin/skill-command-translator.js +1 -0
- package/dist/src/providers/capability-matrix.yaml +58 -6
- package/dist/src/providers/grok-build-acp.js +192 -0
- package/dist/src/providers/grok-build-dispatch.js +251 -0
- package/dist/src/providers/grok-build-headless.js +170 -0
- package/dist/src/providers/muse-paths.js +105 -0
- package/dist/src/providers/provider-definitions.js +93 -7
- package/dist/src/providers/provider-definitions.mjs +21 -1
- package/dist/src/providers/provider-inventory.js +3 -0
- package/dist/src/security/artifact-attestation.js +4 -8
- package/dist/src/security/signing.js +119 -0
- package/dist/src/sessions/adapters/grok-build.js +187 -0
- package/dist/src/sessions/adapters/muse.js +412 -0
- package/dist/src/sessions/contracts.js +1 -1
- package/dist/src/sessions/grok-build-cli.js +196 -0
- package/dist/src/sessions/index.js +3 -0
- package/dist/src/sessions/workspace-discovery.js +9 -5
- package/dist/src/skills/deployer.js +33 -5
- package/dist/src/smiths/context-pipeline/claude-hook.js +2 -0
- package/dist/src/smiths/context-pipeline/context-file-safety.js +18 -0
- package/dist/src/smiths/context-pipeline/finalization.js +1 -32
- package/dist/src/smiths/context-pipeline/generator.js +12 -0
- package/dist/src/smiths/context-pipeline/index.js +1 -1
- package/dist/src/smiths/context-pipeline/managed-hook.js +2 -0
- package/dist/src/smiths/context-pipeline/muse-bridge.js +50 -0
- package/dist/src/smiths/context-pipeline/provider-policy.js +5 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +22 -16
- package/dist/src/smiths/hook-bridge/grok-build-translator.js +64 -0
- package/dist/src/smiths/hook-bridge/index.js +3 -0
- package/dist/src/smiths/hook-bridge/shim.js +2 -0
- package/dist/src/smiths/hook-bridge/types.js +5 -0
- package/dist/src/smiths/skillsmith/collision-detector.js +1 -0
- package/dist/src/storage/protected-files.js +102 -0
- package/dist/src/tracker/forge-http.js +371 -0
- package/dist/src/tracker/project-inputs.js +41 -0
- package/package.json +2 -1
- package/schemas/decision/BatchReceipt.v1.schema.json +50 -0
- package/schemas/decision/CalibrationArtifact.v1.schema.json +76 -0
- package/schemas/decision/CalibrationCompatibility.v1.schema.json +18 -0
- package/schemas/decision/CalibrationGovernanceReceipt.v1.schema.json +44 -0
- package/schemas/decision/DecisionAdmissionEvidence.v1.schema.json +43 -0
- package/schemas/decision/DecisionBinding.schema.json +309 -0
- package/schemas/decision/DecisionBinding.v1alpha2.schema.json +369 -0
- package/schemas/decision/DecisionCacheTelemetry.v1.schema.json +20 -0
- package/schemas/decision/DecisionChampionChallenger.v1.schema.json +100 -0
- package/schemas/decision/DecisionCompileCacheEntry.v1.schema.json +35 -0
- package/schemas/decision/DecisionCompileCacheIdentity.v1.schema.json +26 -0
- package/schemas/decision/DecisionCompileCacheTombstone.v1.schema.json +31 -0
- package/schemas/decision/DecisionContextEvidence.v1.schema.json +136 -0
- package/schemas/decision/DecisionDefinition.schema.json +159 -0
- package/schemas/decision/DecisionDefinition.v1alpha2.schema.json +203 -0
- package/schemas/decision/DecisionDriftResponse.v1.schema.json +55 -0
- package/schemas/decision/DecisionEnsembleAggregate.v1.schema.json +86 -0
- package/schemas/decision/DecisionEnsembleIntegrityReport.v1.schema.json +64 -0
- package/schemas/decision/DecisionEnsemblePolicy.v1.schema.json +130 -0
- package/schemas/decision/DecisionGraph.v1.schema.json +77 -0
- package/schemas/decision/DecisionJob.v1.schema.json +71 -0
- package/schemas/decision/DecisionLifecyclePolicy.v1.schema.json +52 -0
- package/schemas/decision/DecisionProjectionPolicy.v1.schema.json +65 -0
- package/schemas/decision/DecisionProviderPrefixCompatibility.v1.schema.json +45 -0
- package/schemas/decision/DecisionProviderPrefixEvidence.v1.schema.json +17 -0
- package/schemas/decision/DecisionProviderPrefixIdentity.v1.schema.json +36 -0
- package/schemas/decision/DecisionResult.schema.json +524 -0
- package/schemas/decision/DecisionResult.v1alpha2.schema.json +619 -0
- package/schemas/decision/DecisionResultCacheEntry.v1.schema.json +53 -0
- package/schemas/decision/DecisionReview.schema.json +29 -0
- package/schemas/decision/DecisionRuleset.schema.json +313 -0
- package/schemas/decision/DecisionRuleset.v1alpha2.schema.json +313 -0
- package/schemas/decision/DecisionTelemetryTrace.v1.schema.json +95 -0
- package/schemas/decision/RulesetResult.schema.json +721 -0
- package/schemas/decision/RulesetResult.v1alpha2.schema.json +891 -0
- package/schemas/security/pr-evidence-receipt.v1.schema.json +77 -0
- package/schemas/security/threat-assessment-report.v1.schema.json +71 -1
- package/tools/agents/deploy-agents.mjs +21 -6
- package/tools/agents/providers/base.mjs +7 -4
- package/tools/agents/providers/codex.mjs +1 -1
- package/tools/agents/providers/grok-build.d.mts +7 -0
- package/tools/agents/providers/grok-build.mjs +249 -9
- package/tools/agents/providers/model-role.mjs +6 -3
- package/tools/agents/providers/muse-hooks.mjs +785 -0
- package/tools/agents/providers/muse-paths.mjs +112 -0
- package/tools/agents/providers/muse.mjs +336 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Muse Code user skill-root resolution for the file-deploy path (.mjs twin).
|
|
3
|
+
*
|
|
4
|
+
* This module mirrors `src/providers/muse-paths.ts` so the deploy-agents
|
|
5
|
+
* writer resolves the same XDG user root without importing TypeScript:
|
|
6
|
+
*
|
|
7
|
+
* - unset XDG_CONFIG_HOME → `~/.config/muse/skills` (documented default)
|
|
8
|
+
* - absolute XDG_CONFIG_HOME → `<xdg>/muse/skills`
|
|
9
|
+
* - leading `~/` → expanded against the operator home
|
|
10
|
+
* - relative values / bare `~` / NUL bytes / filesystem-root collapse
|
|
11
|
+
* → fail closed (null)
|
|
12
|
+
*
|
|
13
|
+
* Never invent `~/.muse`, `~/.config/muse` siblings outside `muse/skills`,
|
|
14
|
+
* or `~/.agents/skills` as a write target.
|
|
15
|
+
*
|
|
16
|
+
* @see docs/architecture/adr-muse-provider-target.md
|
|
17
|
+
* @issue #226 (path semantics defined by #234)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import os from 'node:os';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
|
|
23
|
+
/** Muse's documented user skills subtree below the XDG config root. */
|
|
24
|
+
export const MUSE_XDG_SKILLS_SUBDIR = path.join('muse', 'skills');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Expand a leading `~/` against the operator home directory.
|
|
28
|
+
* Bare `~` is rejected — it would invent a home skill root.
|
|
29
|
+
*/
|
|
30
|
+
function expandHomePrefix(raw, userHome = os.homedir()) {
|
|
31
|
+
if (raw === '~') return raw;
|
|
32
|
+
if (raw.startsWith('~/')) return path.join(userHome, raw.slice(2));
|
|
33
|
+
return raw;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Validate and resolve the Muse XDG user skills directory.
|
|
38
|
+
* Returns a structured result so the writer can fail closed on bad metadata.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveMuseXdgSkillsDirResult(env = process.env, userHome = os.homedir()) {
|
|
41
|
+
const raw = (env.XDG_CONFIG_HOME || '').trim();
|
|
42
|
+
if (!raw) {
|
|
43
|
+
// Documented default: ~/.config/muse/skills when XDG_CONFIG_HOME is unset.
|
|
44
|
+
return {
|
|
45
|
+
ok: true,
|
|
46
|
+
path: path.join(userHome, '.config', MUSE_XDG_SKILLS_SUBDIR),
|
|
47
|
+
source: 'default',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const expanded = expandHomePrefix(raw, userHome);
|
|
52
|
+
if (expanded === '~' || expanded.startsWith('~')) {
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
reason: 'not-absolute',
|
|
56
|
+
message:
|
|
57
|
+
`XDG_CONFIG_HOME must be an absolute path (got '${raw}'). Bare '~' is rejected so AIWG never invents a Muse home layout.`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!path.isAbsolute(expanded)) {
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
reason: 'not-absolute',
|
|
65
|
+
message:
|
|
66
|
+
`XDG_CONFIG_HOME must be an absolute path (got '${raw}'). Relative values are rejected.`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (raw.includes('\0') || expanded.includes('\0')) {
|
|
71
|
+
return {
|
|
72
|
+
ok: false,
|
|
73
|
+
reason: 'traversal',
|
|
74
|
+
message: 'XDG_CONFIG_HOME contains an invalid path character.',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Defensive: refuse a config root that collapses to the filesystem root;
|
|
79
|
+
// deploying skills to /muse/skills is never the operator's intent.
|
|
80
|
+
const normalized = path.normalize(expanded);
|
|
81
|
+
if (normalized === path.sep) {
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
reason: 'empty',
|
|
85
|
+
message: 'XDG_CONFIG_HOME resolves to the filesystem root; refuse to deploy skills there.',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
ok: true,
|
|
91
|
+
path: path.join(normalized, MUSE_XDG_SKILLS_SUBDIR),
|
|
92
|
+
source: 'env',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Absolute Muse XDG user skills dir when the metadata is sane; otherwise
|
|
98
|
+
* null (fail closed). Never invents ~/.muse.
|
|
99
|
+
*/
|
|
100
|
+
export function resolveMuseXdgSkillsDir(env = process.env, userHome = os.homedir()) {
|
|
101
|
+
const resolution = resolveMuseXdgSkillsDirResult(env, userHome);
|
|
102
|
+
return resolution.ok ? resolution.path : null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* User-facing remediation for bad Muse XDG metadata.
|
|
107
|
+
* Shared by the writer so a blocked deploy explains the fix.
|
|
108
|
+
*/
|
|
109
|
+
export function museXdgSkillsDirRemediation(env = process.env, userHome = os.homedir()) {
|
|
110
|
+
const resolution = resolveMuseXdgSkillsDirResult(env, userHome);
|
|
111
|
+
return resolution.ok ? '' : resolution.message;
|
|
112
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Muse Code provider (experimental).
|
|
3
|
+
*
|
|
4
|
+
* Muse-native skill roots (docs/architecture/adr-muse-provider-target.md):
|
|
5
|
+
* - Project scope: `<target>/.agents/skills/<id>/SKILL.md`
|
|
6
|
+
* (Muse project skills convention; kernel → `.agents/skills/`,
|
|
7
|
+
* standard tier → opt-in `.agents/.aiwg/skills/` via --copy-all).
|
|
8
|
+
* - User scope: `$XDG_CONFIG_HOME/muse/skills`
|
|
9
|
+
* (default `~/.config/muse/skills`; resolved fail-closed by
|
|
10
|
+
* muse-paths.mjs, which mirrors src/providers/muse-paths.ts).
|
|
11
|
+
*
|
|
12
|
+
* The CLI's `--scope user` mirror consumes `USER_SCOPE_PATHS.muse` for the
|
|
13
|
+
* user landing path; a direct writer call with `opts.scope === 'user'`
|
|
14
|
+
* deploys straight to the resolved XDG root.
|
|
15
|
+
*
|
|
16
|
+
* Guarantees:
|
|
17
|
+
* - Never targets `.cursor/` (any such resolution throws fail-closed).
|
|
18
|
+
* - Never invents `~/.muse`, `~/.config/muse` siblings outside
|
|
19
|
+
* `muse/skills`, or `~/.agents/skills` as a write target.
|
|
20
|
+
* - Operator-owned skills are preserved via the base.mjs managed markers
|
|
21
|
+
* (`.aiwg-managed` sidecar): only recorded AIWG entries are ever
|
|
22
|
+
* removed; unmanaged content is byte-identical across deploys.
|
|
23
|
+
* - `--dry-run` performs zero writes.
|
|
24
|
+
*
|
|
25
|
+
* The discover-first AGENTS.md bridge is written by `createAgentsMd`, rendered from
|
|
26
|
+
* `agentic/code/frameworks/sdlc-complete/templates/muse/AGENTS.md.aiwg-template`
|
|
27
|
+
* into an AIWG-managed section (operator content outside the markers is
|
|
28
|
+
* preserved). Hooks/MCP settings are handled by muse-hooks.mjs:
|
|
29
|
+
* managed project hooks merge additively into `.muse/hooks.json` (default
|
|
30
|
+
* on, `--no-hooks` opts out), and the optional MCP settings profile enriches
|
|
31
|
+
* user `mcp_servers` only with the explicit `--mcp` flag.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import fs from 'node:fs';
|
|
35
|
+
import os from 'node:os';
|
|
36
|
+
import path from 'node:path';
|
|
37
|
+
import {
|
|
38
|
+
collectFrameworkArtifacts,
|
|
39
|
+
createAgentsMdFromTemplate,
|
|
40
|
+
deploySkillsWithKernelRouting,
|
|
41
|
+
getAddonSkillDirs,
|
|
42
|
+
normalizeDeploymentMode,
|
|
43
|
+
pruneStaleAiwgSkills,
|
|
44
|
+
computeAllKernelNames,
|
|
45
|
+
resolveAiwgRoot,
|
|
46
|
+
} from './base.mjs';
|
|
47
|
+
import {
|
|
48
|
+
resolveMuseXdgSkillsDir,
|
|
49
|
+
museXdgSkillsDirRemediation,
|
|
50
|
+
} from './muse-paths.mjs';
|
|
51
|
+
import { deployMuseHooks, deployMuseMcp } from './muse-hooks.mjs';
|
|
52
|
+
|
|
53
|
+
export const name = 'muse';
|
|
54
|
+
export const aliases = []; // ADR: no aliases (no muse-spark, muse-code, spark, meta)
|
|
55
|
+
|
|
56
|
+
// Project-relative paths. Skills deploy into the Muse-native project skills
|
|
57
|
+
// root; agents/commands/rules have no file surface in this wave (indexed via
|
|
58
|
+
// aiwg discover / aiwg show). The discover-first AGENTS.md bridge renders
|
|
59
|
+
// via createAgentsMd below.
|
|
60
|
+
export const paths = {
|
|
61
|
+
agents: '',
|
|
62
|
+
commands: '',
|
|
63
|
+
skills: '.agents/skills',
|
|
64
|
+
rules: '',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Kernel skills land at the project skills root itself.
|
|
68
|
+
export const kernelSkillsPath = '.agents/skills';
|
|
69
|
+
|
|
70
|
+
// Opt-in standard-tier mirror (only with --copy-all): siblings of the
|
|
71
|
+
// project skills root, never the user XDG root and never ~/.agents/skills.
|
|
72
|
+
const STANDARD_MIRROR_SUBDIR = '.agents/.aiwg/skills';
|
|
73
|
+
|
|
74
|
+
export const support = {
|
|
75
|
+
agents: 'indexed',
|
|
76
|
+
commands: 'indexed',
|
|
77
|
+
skills: 'native',
|
|
78
|
+
rules: 'indexed',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const capabilities = {
|
|
82
|
+
skills: true,
|
|
83
|
+
rules: false,
|
|
84
|
+
aggregatedOutput: false,
|
|
85
|
+
yamlFormat: true,
|
|
86
|
+
homeDirectoryDeploy: true, // --scope user lands under the operator's XDG home
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export function mapModel(originalModel) {
|
|
90
|
+
return originalModel;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function transformAgent(_srcPath, content) {
|
|
94
|
+
return content;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function transformCommand(_srcPath, content) {
|
|
98
|
+
return content;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function deployAgents() {
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function deployCommands() {
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function deployRules() {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Fail-closed guard: Muse never deploys into a `.cursor` tree — the
|
|
115
|
+
* cursor-overload anti-pattern called out in the ADR.
|
|
116
|
+
*/
|
|
117
|
+
export function assertNotCursorTarget(dir, what) {
|
|
118
|
+
const segments = path.normalize(String(dir)).split(path.sep);
|
|
119
|
+
if (segments.includes('.cursor')) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`Refusing to deploy Muse ${what} into a .cursor path (${dir}). ` +
|
|
122
|
+
'Muse skills deploy to .agents/skills (project) or $XDG_CONFIG_HOME/muse/skills (user).',
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return dir;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Resolve the user-scope skills target for this writer. Fail closed: bad
|
|
130
|
+
* XDG metadata throws with the remediation message instead of inventing a
|
|
131
|
+
* bogus tree.
|
|
132
|
+
*/
|
|
133
|
+
export function assertMuseUserSkillsDir(env = process.env, userHome = os.homedir()) {
|
|
134
|
+
const resolved = resolveMuseXdgSkillsDir(env, userHome);
|
|
135
|
+
if (!resolved) {
|
|
136
|
+
const err = new Error(museXdgSkillsDirRemediation(env, userHome));
|
|
137
|
+
err.code = 'MUSE_XDG_UNSET';
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
return assertNotCursorTarget(resolved, 'user skills');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Deploy skills to the Muse-native roots.
|
|
145
|
+
*
|
|
146
|
+
* Kernel skills → `<target>/.agents/skills/` at project scope, or the
|
|
147
|
+
* resolved `$XDG_CONFIG_HOME/muse/skills` when `opts.scope === 'user'`.
|
|
148
|
+
* Standard tier stays index-discovered unless `--copy-all` opts in, in
|
|
149
|
+
* which case it mirrors to `<target>/.agents/.aiwg/skills/` (project scope
|
|
150
|
+
* only — never silently into the user root or `~/.agents/skills`).
|
|
151
|
+
*/
|
|
152
|
+
export function deploySkills(skillDirs, targetDir, opts = {}) {
|
|
153
|
+
const userScope = opts.scope === 'user';
|
|
154
|
+
const userRoot = userScope
|
|
155
|
+
? assertMuseUserSkillsDir(opts.env || process.env, opts.userHome || os.homedir())
|
|
156
|
+
: null;
|
|
157
|
+
|
|
158
|
+
const kernelDest = userScope ? userRoot : path.join(targetDir, kernelSkillsPath);
|
|
159
|
+
const standardDest = userScope ? null : path.join(targetDir, STANDARD_MIRROR_SUBDIR);
|
|
160
|
+
|
|
161
|
+
assertNotCursorTarget(kernelDest, 'skills');
|
|
162
|
+
if (standardDest) assertNotCursorTarget(standardDest, 'standard skills');
|
|
163
|
+
|
|
164
|
+
if (!opts.quiet) {
|
|
165
|
+
console.log(
|
|
166
|
+
`\n Muse skills root: ${kernelDest}` +
|
|
167
|
+
(userScope ? ' (user scope, from XDG_CONFIG_HOME)' : ' (project scope)') +
|
|
168
|
+
(opts.dryRun ? ' [dry-run]' : ''),
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const result = deploySkillsWithKernelRouting(skillDirs, standardDest, kernelDest, {
|
|
173
|
+
...opts,
|
|
174
|
+
provider: name,
|
|
175
|
+
copyStandardSkills: !userScope && opts.copyStandardSkills === true,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Holistic post-deploy cleanup of stale AIWG-managed kernel skills, bound
|
|
179
|
+
// by managed markers so operator-owned skills survive. computeAllKernelNames
|
|
180
|
+
// returns null when no AIWG tree is locatable — skip rather than prune on
|
|
181
|
+
// an empty desired set.
|
|
182
|
+
if (!opts.dryRun && opts.srcRoot) {
|
|
183
|
+
const kernelNames = computeAllKernelNames(opts.srcRoot);
|
|
184
|
+
if (kernelNames != null) {
|
|
185
|
+
pruneStaleAiwgSkills(kernelDest, [...kernelNames], opts);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function getFileExtension() {
|
|
193
|
+
return '.md';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Render the discover-first AGENTS.md bridge from the muse template (#227).
|
|
198
|
+
* The template section is wrapped in AIWG-managed markers; operator content
|
|
199
|
+
* outside the markers is preserved on redeploy, and the managed section is
|
|
200
|
+
* updated in place when the template changes.
|
|
201
|
+
*/
|
|
202
|
+
export function createAgentsMd(target, srcRoot, dryRun) {
|
|
203
|
+
assertSafeAgentsMd(target);
|
|
204
|
+
const aiwgRoot = resolveAiwgRoot(srcRoot) || srcRoot;
|
|
205
|
+
createAgentsMdFromTemplate(target, aiwgRoot, 'muse/AGENTS.md.aiwg-template', dryRun);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Refuse to write AGENTS.md through a symlink or onto a non-file. */
|
|
209
|
+
function assertSafeAgentsMd(target) {
|
|
210
|
+
const dest = path.join(target, 'AGENTS.md');
|
|
211
|
+
let stat;
|
|
212
|
+
try {
|
|
213
|
+
stat = fs.lstatSync(dest);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
if (error?.code === 'ENOENT') return;
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
219
|
+
throw new Error(`Refusing unsafe Muse AGENTS.md target: ${dest}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export async function postDeploy(targetDir, opts = {}) {
|
|
224
|
+
const fullDeploy = !opts.commandsOnly && !opts.skillsOnly && !opts.rulesOnly;
|
|
225
|
+
if (opts.createAgentsMd || fullDeploy) {
|
|
226
|
+
createAgentsMd(targetDir, opts.srcRoot, opts.dryRun);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// #228 — managed project hooks (.muse/hooks.json). Default on, mirroring
|
|
230
|
+
// the Claude provider's autoInstall policy; the operator opts out with
|
|
231
|
+
// --no-hooks (opts.hooks === false). Project-scoped only: at user scope
|
|
232
|
+
// there is no project hooks.json to manage.
|
|
233
|
+
if (fullDeploy && opts.hooks !== false && opts.scope !== 'user') {
|
|
234
|
+
deployMuseHooks(targetDir, opts);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// #228 — optional MCP settings profile. Explicit opt-in only (--mcp);
|
|
238
|
+
// default `aiwg use --provider muse` never touches user settings.
|
|
239
|
+
if (fullDeploy && opts.mcp === true) {
|
|
240
|
+
deployMuseMcp(opts);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!opts.quiet) {
|
|
244
|
+
const root = opts.scope === 'user'
|
|
245
|
+
? assertMuseUserSkillsDir(opts.env || process.env, opts.userHome || os.homedir())
|
|
246
|
+
: path.join(targetDir, kernelSkillsPath);
|
|
247
|
+
console.log(`\nMuse Code: skills deployed to ${root}`);
|
|
248
|
+
console.log(' Rules/agents surface through `aiwg discover` / `aiwg show`; the discover-first');
|
|
249
|
+
console.log(' AGENTS.md bridge is managed above.');
|
|
250
|
+
if (opts.hooks === false) {
|
|
251
|
+
console.log(' Hooks skipped (--no-hooks).');
|
|
252
|
+
} else if (opts.scope !== 'user') {
|
|
253
|
+
console.log(' Managed hooks merged into .muse/hooks.json (--no-hooks to skip).');
|
|
254
|
+
}
|
|
255
|
+
if (opts.mcp === true) {
|
|
256
|
+
console.log(' MCP profile merged into user settings mcp_servers (--mcp).');
|
|
257
|
+
} else {
|
|
258
|
+
console.log(' MCP profile not installed (opt in with --mcp).');
|
|
259
|
+
}
|
|
260
|
+
console.log(' Trust the workspace when prompted, then start a new Muse session to load the bridge.');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export async function deploy(opts = {}) {
|
|
265
|
+
const {
|
|
266
|
+
srcRoot,
|
|
267
|
+
target,
|
|
268
|
+
mode,
|
|
269
|
+
deploySkills: shouldDeploySkills,
|
|
270
|
+
skillsOnly,
|
|
271
|
+
commandsOnly,
|
|
272
|
+
rulesOnly,
|
|
273
|
+
} = opts;
|
|
274
|
+
|
|
275
|
+
if (!opts.quiet) {
|
|
276
|
+
console.log(`\n=== Muse Code Provider (experimental) ===`);
|
|
277
|
+
console.log(`Target: ${target}`);
|
|
278
|
+
console.log(`Mode: ${mode}`);
|
|
279
|
+
if (opts.dryRun) console.log('Dry-run: no filesystem mutations');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Fail closed when a direct caller requests user scope without usable XDG
|
|
283
|
+
// metadata — the CLI's --scope user mirror handles the normal path via
|
|
284
|
+
// USER_SCOPE_PATHS.muse.
|
|
285
|
+
if (opts.scope === 'user') {
|
|
286
|
+
assertMuseUserSkillsDir(opts.env || process.env, opts.userHome || os.homedir());
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const skillDirs = [];
|
|
290
|
+
const normalizedMode = normalizeDeploymentMode(mode);
|
|
291
|
+
|
|
292
|
+
if (['general', 'sdlc', 'both', 'all'].includes(normalizedMode)) {
|
|
293
|
+
if (shouldDeploySkills || skillsOnly) skillDirs.push(...getAddonSkillDirs(srcRoot));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const fw = collectFrameworkArtifacts(srcRoot, normalizedMode, {
|
|
297
|
+
includeAgents: false,
|
|
298
|
+
includeCommands: false,
|
|
299
|
+
includeSkills: shouldDeploySkills || skillsOnly,
|
|
300
|
+
includeRules: false,
|
|
301
|
+
});
|
|
302
|
+
skillDirs.push(...(fw.skills || []));
|
|
303
|
+
|
|
304
|
+
let count = 0;
|
|
305
|
+
if ((shouldDeploySkills || skillsOnly) && !commandsOnly && !rulesOnly) {
|
|
306
|
+
const result = deploySkills(skillDirs, target, opts);
|
|
307
|
+
count += result.kernel + result.standardCopied;
|
|
308
|
+
} else if (!opts.quiet) {
|
|
309
|
+
console.log(' No skills requested for deploy');
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
await postDeploy(target, opts);
|
|
313
|
+
return count;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export default {
|
|
317
|
+
name,
|
|
318
|
+
aliases,
|
|
319
|
+
paths,
|
|
320
|
+
kernelSkillsPath,
|
|
321
|
+
support,
|
|
322
|
+
capabilities,
|
|
323
|
+
mapModel,
|
|
324
|
+
transformAgent,
|
|
325
|
+
transformCommand,
|
|
326
|
+
deployAgents,
|
|
327
|
+
deployCommands,
|
|
328
|
+
deploySkills,
|
|
329
|
+
deployRules,
|
|
330
|
+
assertNotCursorTarget,
|
|
331
|
+
assertMuseUserSkillsDir,
|
|
332
|
+
createAgentsMd,
|
|
333
|
+
postDeploy,
|
|
334
|
+
getFileExtension,
|
|
335
|
+
deploy,
|
|
336
|
+
};
|