@aiwg/cli 2026.10.15 → 2026.10.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/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
- package/dist/src/artifacts/citation-parser.js +7 -6
- package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
- package/dist/src/artifacts/corpus-tools/cli.js +8 -3
- package/dist/src/artifacts/corpus-tools/discovery-log.js +26 -24
- package/dist/src/artifacts/corpus-tools/expand-cli.js +3 -2
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +4 -1
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +17 -1
- package/dist/src/artifacts/corpus-tools/expand.js +16 -17
- package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
- package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
- package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +11 -3
- package/dist/src/artifacts/corpus-tools/resolve.js +42 -11
- package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
- package/dist/src/artifacts/graph-query.js +5 -3
- package/dist/src/artifacts/hybrid-query.js +11 -2
- package/dist/src/artifacts/index-refresh.js +2 -0
- package/dist/src/artifacts/query-engine-corpus.js +217 -0
- package/dist/src/artifacts/query-engine-discover-output.js +229 -0
- package/dist/src/artifacts/query-engine-discover.js +285 -0
- package/dist/src/artifacts/query-engine-entries.js +188 -0
- package/dist/src/artifacts/query-engine-index.js +249 -0
- package/dist/src/artifacts/query-engine-matching.js +143 -0
- package/dist/src/artifacts/query-engine-options.js +2 -0
- package/dist/src/artifacts/query-engine-rules.js +202 -0
- package/dist/src/artifacts/query-engine-scoring.js +436 -0
- package/dist/src/artifacts/query-engine-show-card.js +194 -0
- package/dist/src/artifacts/query-engine-show-load.js +211 -0
- package/dist/src/artifacts/query-engine-show.js +300 -0
- package/dist/src/artifacts/query-engine.js +7 -2576
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +10 -5
- package/dist/src/cli/handlers/doctor-help.js +4 -1
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/mc-agents.js +111 -0
- package/dist/src/cli/handlers/mc-args.js +54 -0
- package/dist/src/cli/handlers/mc-control.js +227 -0
- package/dist/src/cli/handlers/mc-dispatch.js +203 -0
- package/dist/src/cli/handlers/mc-help.js +171 -0
- package/dist/src/cli/handlers/mc-run.js +343 -0
- package/dist/src/cli/handlers/mc-session.js +138 -0
- package/dist/src/cli/handlers/mc-status.js +258 -0
- package/dist/src/cli/handlers/mc-summary.js +43 -0
- package/dist/src/cli/handlers/mc-types.js +3 -0
- package/dist/src/cli/handlers/mc-worker.js +205 -0
- package/dist/src/cli/handlers/mc.js +12 -1665
- package/dist/src/cli/handlers/models-refusal.js +13 -0
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +5 -3
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/remove-bundled.js +133 -0
- package/dist/src/cli/handlers/remove-options.js +31 -0
- package/dist/src/cli/handlers/remove-user.js +174 -0
- package/dist/src/cli/handlers/remove.js +201 -0
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
- package/dist/src/cli/handlers/subcommands-list.js +250 -0
- package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
- package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
- package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
- package/dist/src/cli/handlers/subcommands-services.js +66 -0
- package/dist/src/cli/handlers/subcommands-storage.js +259 -0
- package/dist/src/cli/handlers/subcommands.js +18 -1976
- package/dist/src/cli/handlers/update.js +157 -0
- package/dist/src/cli/handlers/use.js +14 -4
- package/dist/src/cli/handlers/utilities.js +3 -560
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/scope-resolver.js +1 -142
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/cli/user-scope-mirror.js +173 -0
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-host-thresholds.js +2 -0
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +21 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +24 -0
- package/dist/src/config/host-resource-report.mjs +110 -0
- package/dist/src/config/host-resource-runtime.d.mts +37 -0
- package/dist/src/config/host-resource-runtime.mjs +296 -0
- package/dist/src/config/installed-selection.js +22 -0
- package/dist/src/config/worker-invocation-marker.d.mts +1 -0
- package/dist/src/config/worker-invocation-marker.mjs +2 -0
- package/dist/src/decision/ensemble-study/artifacts.js +7 -0
- package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
- package/dist/src/decision/ensemble-study/gates.js +78 -0
- package/dist/src/decision/ensemble-study/protocol.js +18 -21
- package/dist/src/decision/ensemble-study/score.js +3 -2
- package/dist/src/decision/ensemble-study/statistics.js +7 -26
- package/dist/src/decision/heldout/access.js +74 -0
- package/dist/src/decision/heldout/calibration.js +1 -0
- package/dist/src/decision/heldout/collector.js +8 -1
- package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
- package/dist/src/decision/sensitivity/comparative.js +18 -41
- package/dist/src/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +133 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/gates/evaluate.js +2 -358
- package/dist/src/gates/heldout.js +17 -7
- package/dist/src/gates/observations.js +363 -0
- package/dist/src/gates/pack-composition.js +270 -0
- package/dist/src/gates/pack-tightening.js +197 -0
- package/dist/src/gates/pack-validation.js +262 -0
- package/dist/src/gates/registry-error.js +5 -0
- package/dist/src/gates/registry.js +13 -685
- package/dist/src/lint/check-patterns.js +163 -0
- package/dist/src/lint/checks.js +268 -0
- package/dist/src/lint/reference-resolution.js +54 -0
- package/dist/src/lint/runner.js +3 -465
- package/dist/src/mcp/helpers.mjs +11 -1
- package/dist/src/mcp/json-document.mjs +29 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -28
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/mission-protocol/worker-review-gate.js +7 -0
- package/dist/src/models/worker-plan.js +36 -5
- package/dist/src/models/wrapper-deployment.js +25 -12
- package/dist/src/models/wrapper-enforcement.js +47 -7
- package/dist/src/network-analysis/research.js +2 -1
- package/dist/src/plugin/command-ownership.js +34 -0
- package/dist/src/plugin/skill-command-frontmatter.js +197 -0
- package/dist/src/plugin/skill-command-translator.js +6 -232
- package/dist/src/policy/hitl-check.js +14 -4
- package/dist/src/policy/hitl-consume.js +54 -0
- package/dist/src/policy/hitl-receipt.js +2 -0
- package/dist/src/policy/hitl.js +11 -3
- package/dist/src/providers/context-output-ownership.js +26 -0
- package/dist/src/providers/deployment-ownership.d.mts +19 -0
- package/dist/src/providers/deployment-ownership.mjs +226 -0
- package/dist/src/providers/deployment-removal.js +200 -0
- package/dist/src/providers/provider-context-contracts.js +162 -0
- package/dist/src/providers/provider-definition-schema.js +136 -0
- package/dist/src/providers/provider-definitions.js +8 -1298
- package/dist/src/providers/provider-seeds-1.js +360 -0
- package/dist/src/providers/provider-seeds-2.js +387 -0
- package/dist/src/providers/provider-seeds-3.js +262 -0
- package/dist/src/providers/removal-transaction.js +86 -0
- package/dist/src/providers/settings-document.d.mts +3 -0
- package/dist/src/providers/settings-document.mjs +47 -0
- package/dist/src/providers/settings-removal.js +190 -0
- package/dist/src/providers/skill-ownership.d.mts +19 -2
- package/dist/src/providers/skill-ownership.mjs +12 -4
- package/dist/src/providers/transformation-receipt-integration.js +15 -271
- package/dist/src/providers/transformation-receipt-outputs.js +99 -0
- package/dist/src/providers/transformation-receipt-source.js +194 -0
- package/dist/src/research/clients/arxiv.js +4 -30
- package/dist/src/research/clients/base.js +48 -22
- package/dist/src/research/identity.js +42 -4
- package/dist/src/research/query-cli.js +3 -87
- package/dist/src/research/query-options.js +87 -0
- package/dist/src/research/reference-match.js +105 -24
- package/dist/src/research/services/acquisition.js +9 -7
- package/dist/src/research/services/citation.js +5 -2
- package/dist/src/research/types.js +2 -0
- package/dist/src/rules/activation.mjs +15 -6
- package/dist/src/rules/core-startup.mjs +2 -2
- package/dist/src/serve/mission-conductor.js +52 -4
- package/dist/src/serve/mission-summary.js +56 -0
- package/dist/src/sessions/adapters/grok-build-native.js +23 -0
- package/dist/src/sessions/adapters/grok-build.js +14 -7
- package/dist/src/sessions/workspace-discovery.js +5 -5
- package/dist/src/smiths/context-pipeline/aiwg-md.js +39 -46
- package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
- package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +10 -11
- package/dist/src/smiths/context-pipeline/managed-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
- package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
- package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
- package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
- package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
- package/dist/src/smiths/hook-bridge/index.js +9 -0
- package/package.json +13 -1
- package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +24 -675
- package/tools/agents/deploy-command-mirrors.mjs +229 -0
- package/tools/agents/deploy-options.mjs +258 -0
- package/tools/agents/deploy-support.mjs +165 -0
- package/tools/agents/providers/base-addon-discovery.mjs +139 -0
- package/tools/agents/providers/base-behaviors.mjs +168 -0
- package/tools/agents/providers/base-context.mjs +205 -0
- package/tools/agents/providers/base-contract.mjs +116 -0
- package/tools/agents/providers/base-files.mjs +252 -0
- package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
- package/tools/agents/providers/base-framework-discovery.mjs +309 -0
- package/tools/agents/providers/base-frontmatter.mjs +196 -0
- package/tools/agents/providers/base-inventory.mjs +269 -0
- package/tools/agents/providers/base-kernel-skills.mjs +354 -0
- package/tools/agents/providers/base-migrations.mjs +258 -0
- package/tools/agents/providers/base-models-platforms.mjs +273 -0
- package/tools/agents/providers/base-rule-index.mjs +450 -0
- package/tools/agents/providers/base-runtime.mjs +60 -0
- package/tools/agents/providers/base-skill-copy.mjs +273 -0
- package/tools/agents/providers/base.mjs +16 -3364
- package/tools/agents/providers/claude-post-deploy.mjs +20 -1
- package/tools/agents/providers/context-write.mjs +4 -0
- package/tools/agents/providers/hermes-startup.mjs +0 -5
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/pi.mjs +3 -1
- package/tools/agents/providers/rule-delivery-surface.mjs +359 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1144
- package/tools/agents/providers/rule-deployment-commit.mjs +148 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +461 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/agents/providers/rule-projection.mjs +3 -0
- package/tools/daemon/README.md +511 -0
- package/tools/daemon/adapters/base-adapter.mjs +84 -0
- package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
- package/tools/daemon/agent-supervisor.mjs +299 -0
- package/tools/daemon/automation-engine.mjs +310 -0
- package/tools/daemon/autonomous-engine.mjs +346 -0
- package/tools/daemon/behavior-loader.mjs +316 -0
- package/tools/daemon/behavior.mjs +174 -0
- package/tools/daemon/concierge/intent-router.mjs +401 -0
- package/tools/daemon/concierge/orchestrator.mjs +272 -0
- package/tools/daemon/concierge/response-translator.mjs +462 -0
- package/tools/daemon/config.mjs +377 -0
- package/tools/daemon/cron-scheduler.mjs +178 -0
- package/tools/daemon/daemon-main.mjs +1169 -0
- package/tools/daemon/event-router.mjs +84 -0
- package/tools/daemon/file-watcher.mjs +383 -0
- package/tools/daemon/index.mjs +1181 -0
- package/tools/daemon/init-profile.mjs +124 -0
- package/tools/daemon/ipc-client.mjs +197 -0
- package/tools/daemon/ipc-ops-handlers.mjs +236 -0
- package/tools/daemon/ipc-server.mjs +275 -0
- package/tools/daemon/maintenance-owner.mjs +79 -0
- package/tools/daemon/memory-manager.mjs +386 -0
- package/tools/daemon/message-router.mjs +194 -0
- package/tools/daemon/provider-watcher.mjs +585 -0
- package/tools/daemon/pty-adapter.mjs +420 -0
- package/tools/daemon/repl-chat.mjs +359 -0
- package/tools/daemon/resource-bounds.mjs +88 -0
- package/tools/daemon/sandbox-transport.mjs +295 -0
- package/tools/daemon/scheduled-task-runner.mjs +535 -0
- package/tools/daemon/task-store.mjs +450 -0
- package/tools/daemon/tmux-manager.mjs +324 -0
- package/tools/daemon/update-policy.mjs +517 -0
- package/tools/daemon/web-server.mjs +399 -0
- package/tools/daemon/web-ui/index.html +585 -0
- package/tools/daemon/web-ui/styles.css +156 -0
- package/tools/docker/Dockerfile.daemon +35 -0
- package/tools/docker/container-manager.mjs +291 -0
- package/tools/messaging/adapter-registry.mjs +230 -0
- package/tools/messaging/adapters/base.mjs +326 -0
- package/tools/messaging/adapters/discord.mjs +462 -0
- package/tools/messaging/adapters/slack.mjs +402 -0
- package/tools/messaging/adapters/telegram.mjs +552 -0
- package/tools/messaging/chat-handler.mjs +297 -0
- package/tools/messaging/command-router.mjs +269 -0
- package/tools/messaging/event-bus.mjs +199 -0
- package/tools/messaging/index.mjs +456 -0
- package/tools/messaging/message-formatter.mjs +320 -0
- package/tools/messaging/room-manager.mjs +277 -0
- package/tools/messaging/types.mjs +94 -0
- package/tools/providers/pi-bridge-policy.mjs +4 -0
- package/tools/ralph-external/daemon-supervisor.mjs +394 -0
- package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +7 -4
- package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
- package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
- package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
- package/tools/ralph-external/lib/worker-termination.mjs +15 -8
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
- package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
// Health diagnostics extracted from the utility handler collection.
|
|
2
|
+
import fsp from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { createScriptRunner } from './script-runner.js';
|
|
5
|
+
import { getFrameworkRoot } from '../../channel/manager.mjs';
|
|
6
|
+
import { parsePublicDoctorFlags } from './doctor-args.js';
|
|
7
|
+
import { DOCTOR_HELP } from './doctor-help.js';
|
|
8
|
+
import { checkCollisions } from '../../smiths/skillsmith/collision-detector.js';
|
|
9
|
+
import { renderUseDeploymentResult, verifyConfiguredDeployments } from '../services/deployment-verification.js';
|
|
10
|
+
function flagValue(args, flag) {
|
|
11
|
+
const index = args.indexOf(flag);
|
|
12
|
+
if (index >= 0)
|
|
13
|
+
return args[index + 1];
|
|
14
|
+
const prefix = `${flag}=`;
|
|
15
|
+
return args.find((arg) => arg.startsWith(prefix))?.slice(prefix.length);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A directory is a deployed skill only if it carries a SKILL.md manifest —
|
|
19
|
+
* the same marker `isOwnedByNamespace()` in collision-detector.ts reads for
|
|
20
|
+
* ownership. Harness container/bucket directories (e.g. Claude Code's own
|
|
21
|
+
* `.claude/skills/synced/` sync storage, which holds UUID-named dirs with
|
|
22
|
+
* `manifest.json`, not SKILL.md) have no manifest of their own and must
|
|
23
|
+
* never be reported as a colliding skill (#278).
|
|
24
|
+
*
|
|
25
|
+
* A container directory without its own SKILL.md is still descended exactly
|
|
26
|
+
* one level: a real skill nested inside it (`<container>/<skill>/SKILL.md`)
|
|
27
|
+
* is reported as `<container>/<skill>`, while the container itself never is.
|
|
28
|
+
*/
|
|
29
|
+
async function hasSkillManifest(dirPath) {
|
|
30
|
+
try {
|
|
31
|
+
await fsp.access(path.join(dirPath, 'SKILL.md'));
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function collectDeployedSkillDirNames(skillsDir) {
|
|
39
|
+
let topEntries;
|
|
40
|
+
try {
|
|
41
|
+
topEntries = await fsp.readdir(skillsDir, { withFileTypes: true });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const names = [];
|
|
47
|
+
for (const entry of topEntries) {
|
|
48
|
+
if (!entry.isDirectory())
|
|
49
|
+
continue;
|
|
50
|
+
const dirPath = path.join(skillsDir, entry.name);
|
|
51
|
+
if (await hasSkillManifest(dirPath)) {
|
|
52
|
+
names.push(entry.name);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
let nestedEntries;
|
|
56
|
+
try {
|
|
57
|
+
nestedEntries = await fsp.readdir(dirPath, { withFileTypes: true });
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
for (const nested of nestedEntries) {
|
|
63
|
+
if (!nested.isDirectory())
|
|
64
|
+
continue;
|
|
65
|
+
const nestedPath = path.join(dirPath, nested.name);
|
|
66
|
+
if (await hasSkillManifest(nestedPath)) {
|
|
67
|
+
names.push(path.join(entry.name, nested.name));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return names;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* #1156 Phase 1 — Validate the per-user registry at `~/.aiwg/installed.json`.
|
|
75
|
+
*
|
|
76
|
+
* Checks each registered framework+provider deploy:
|
|
77
|
+
* - Registry entry parses correctly
|
|
78
|
+
* - Recorded artifact entries (Cycle 3 mirrors) still exist on disk
|
|
79
|
+
* - Per-artifact-type counts match the actual entry-name list length
|
|
80
|
+
* - Pre-Cycle-3 entries (no `entries` snapshot) are surfaced as "limited
|
|
81
|
+
* drift detection" rather than failures
|
|
82
|
+
*
|
|
83
|
+
* Returns exit 1 when drift is detected, exit 0 otherwise. Output is plain
|
|
84
|
+
* text suitable for terminal consumption.
|
|
85
|
+
*/
|
|
86
|
+
async function runUserScopeDoctor(verbose) {
|
|
87
|
+
const { readUserRegistry, userRegistryPath } = await import('../../config/user-registry.js');
|
|
88
|
+
const { USER_SCOPE_PATHS } = await import('../scope-resolver.js');
|
|
89
|
+
const fsp2 = await import('node:fs/promises');
|
|
90
|
+
const path2 = await import('node:path');
|
|
91
|
+
const registry = await readUserRegistry();
|
|
92
|
+
const frameworks = Object.entries(registry.installed);
|
|
93
|
+
const lines = [];
|
|
94
|
+
lines.push('');
|
|
95
|
+
lines.push('── User-scope registry validation ──');
|
|
96
|
+
lines.push(`Registry path: ${userRegistryPath()}`);
|
|
97
|
+
lines.push('');
|
|
98
|
+
if (frameworks.length === 0) {
|
|
99
|
+
lines.push('No frameworks deployed at user scope. Run `aiwg use <fw> --scope user` to install.');
|
|
100
|
+
return { exitCode: 0, message: lines.join('\n') + '\n' };
|
|
101
|
+
}
|
|
102
|
+
let driftCount = 0;
|
|
103
|
+
let limitedCount = 0;
|
|
104
|
+
for (const [name, entry] of frameworks) {
|
|
105
|
+
lines.push(`▸ ${name} v${entry.version} [${entry.source}]`);
|
|
106
|
+
for (const [provider, providerDeployRaw] of Object.entries(entry.deployedTo)) {
|
|
107
|
+
// Cast through unknown for the optional `entries` snapshot.
|
|
108
|
+
const providerDeploy = providerDeployRaw;
|
|
109
|
+
const userPaths = USER_SCOPE_PATHS[provider];
|
|
110
|
+
if (!userPaths) {
|
|
111
|
+
lines.push(` ${provider}: ⚠ no user-scope path map registered for this provider`);
|
|
112
|
+
driftCount++;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const recorded = providerDeploy.entries;
|
|
116
|
+
if (!recorded) {
|
|
117
|
+
lines.push(` ${provider}: ⚠ pre-Cycle-3 entry — no per-artifact manifest, drift detection limited`);
|
|
118
|
+
lines.push(` counts: agents=${providerDeploy.agents} commands=${providerDeploy.commands} skills=${providerDeploy.skills} rules=${providerDeploy.rules}`);
|
|
119
|
+
limitedCount++;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
// Walk the recorded entry names and check each one exists on disk.
|
|
123
|
+
const checks = [
|
|
124
|
+
['agents', userPaths.agents, recorded.agents, providerDeploy.agents],
|
|
125
|
+
['commands', userPaths.commands, recorded.commands, providerDeploy.commands],
|
|
126
|
+
['skills', userPaths.skills, recorded.skills, providerDeploy.skills],
|
|
127
|
+
['rules', userPaths.rules, recorded.rules, providerDeploy.rules],
|
|
128
|
+
];
|
|
129
|
+
const issues = [];
|
|
130
|
+
for (const [type, dir, names, expectedCount] of checks) {
|
|
131
|
+
if (!dir || !names)
|
|
132
|
+
continue;
|
|
133
|
+
let present = 0;
|
|
134
|
+
const missing = [];
|
|
135
|
+
for (const n of names) {
|
|
136
|
+
const target = path2.join(dir, n);
|
|
137
|
+
const stat = await fsp2.stat(target).catch(() => null);
|
|
138
|
+
if (stat)
|
|
139
|
+
present++;
|
|
140
|
+
else
|
|
141
|
+
missing.push(n);
|
|
142
|
+
}
|
|
143
|
+
if (names.length !== expectedCount) {
|
|
144
|
+
issues.push(`count drift on ${type}: registry says ${expectedCount}, manifest lists ${names.length}`);
|
|
145
|
+
}
|
|
146
|
+
if (missing.length > 0) {
|
|
147
|
+
issues.push(`${type}: ${missing.length}/${names.length} entries missing from ${dir}`);
|
|
148
|
+
if (verbose) {
|
|
149
|
+
for (const m of missing)
|
|
150
|
+
issues.push(` missing: ${path2.join(dir, m)}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else if (verbose) {
|
|
154
|
+
issues.push(`${type}: ${present}/${names.length} present at ${dir}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (issues.length === 0) {
|
|
158
|
+
lines.push(` ${provider}: ✓ all recorded artifacts present`);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const hasMissing = issues.some(i => i.includes('missing') || i.includes('drift'));
|
|
162
|
+
const marker = hasMissing ? '✗' : 'ℹ';
|
|
163
|
+
lines.push(` ${provider}: ${marker}`);
|
|
164
|
+
for (const i of issues)
|
|
165
|
+
lines.push(` ${i}`);
|
|
166
|
+
if (hasMissing)
|
|
167
|
+
driftCount++;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
lines.push('');
|
|
172
|
+
lines.push('═'.repeat(60));
|
|
173
|
+
lines.push(`Frameworks: ${frameworks.length} Drift: ${driftCount} Limited (pre-Cycle-3): ${limitedCount}`);
|
|
174
|
+
if (driftCount > 0) {
|
|
175
|
+
lines.push('');
|
|
176
|
+
lines.push('Drift detected. To repair, re-run `aiwg use <framework> --scope user --provider <p>`.');
|
|
177
|
+
lines.push('To remove a stale registry entry, run `aiwg remove <framework> --scope user`.');
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
exitCode: driftCount > 0 ? 1 : 0,
|
|
181
|
+
message: lines.join('\n') + '\n',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Handler for doctor command
|
|
186
|
+
*
|
|
187
|
+
* Runs health diagnostics on the AIWG installation and workspace.
|
|
188
|
+
*
|
|
189
|
+
* Usage:
|
|
190
|
+
* aiwg doctor
|
|
191
|
+
* aiwg -doctor
|
|
192
|
+
* aiwg --doctor
|
|
193
|
+
* aiwg doctor --verbose
|
|
194
|
+
* aiwg doctor --scope user # validate ~/.aiwg/installed.json
|
|
195
|
+
*/
|
|
196
|
+
export const doctorHandler = {
|
|
197
|
+
id: 'doctor',
|
|
198
|
+
name: 'Doctor',
|
|
199
|
+
description: 'Run health diagnostics',
|
|
200
|
+
category: 'maintenance',
|
|
201
|
+
aliases: ['-doctor', '--doctor'],
|
|
202
|
+
async help() {
|
|
203
|
+
return { exitCode: 0, message: DOCTOR_HELP, rawOutput: true };
|
|
204
|
+
},
|
|
205
|
+
async execute(ctx) {
|
|
206
|
+
// Validate before any early-return mode: deployment and user-scope doctor
|
|
207
|
+
// never invoke doctor.mjs, so they must enforce the same flag contract.
|
|
208
|
+
let flags;
|
|
209
|
+
try {
|
|
210
|
+
flags = parsePublicDoctorFlags(ctx.args);
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
return { exitCode: 2, message: `${error instanceof Error ? error.message : String(error)}. See 'aiwg doctor --help'.` };
|
|
214
|
+
}
|
|
215
|
+
const { hasSwitch, values } = flags;
|
|
216
|
+
if (hasSwitch('--help') || hasSwitch('-h')) {
|
|
217
|
+
return { exitCode: 0, message: DOCTOR_HELP, rawOutput: true };
|
|
218
|
+
}
|
|
219
|
+
if (hasSwitch('--deployment')) {
|
|
220
|
+
const scopeValue = values.get('--scope');
|
|
221
|
+
if (scopeValue && scopeValue !== 'project' && scopeValue !== 'user') {
|
|
222
|
+
return { exitCode: 2, message: `Invalid deployment verification scope: ${scopeValue}` };
|
|
223
|
+
}
|
|
224
|
+
const result = await verifyConfiguredDeployments(ctx.cwd || process.cwd(), {
|
|
225
|
+
provider: values.get('--provider'),
|
|
226
|
+
bundle: values.get('--bundle'),
|
|
227
|
+
scope: scopeValue,
|
|
228
|
+
}, ctx.frameworkRoot);
|
|
229
|
+
const { rulePinState } = await import('../../rules/pin-state.js');
|
|
230
|
+
const pins = rulePinState(ctx.cwd, ctx.frameworkRoot);
|
|
231
|
+
return {
|
|
232
|
+
exitCode: result.exitCode,
|
|
233
|
+
message: hasSwitch('--json')
|
|
234
|
+
? JSON.stringify({ ...result, rule_pins: { rules: pins.rules, warnings: pins.warnings } }, null, 2)
|
|
235
|
+
: renderUseDeploymentResult(result) + '\n' + pins.rules.map(rule => `${rule.name}: pinned kernel (canonical ${rule.canonical_activation})`).concat(pins.warnings).join('\n'),
|
|
236
|
+
rawOutput: hasSwitch('--json'),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
// #1156 Phase 1 — `aiwg doctor --scope user` / `aiwg doctor --user`
|
|
240
|
+
// validates the per-user registry (~/.aiwg/installed.json) without
|
|
241
|
+
// running the project-scope diagnostics. Operators need this to verify
|
|
242
|
+
// their user-scope deployments from any cwd, including shells with no
|
|
243
|
+
// project at all.
|
|
244
|
+
const userScopeRequested = hasSwitch('--user') || values.get('--scope') === 'user';
|
|
245
|
+
if (userScopeRequested && !hasSwitch('--probe-workers')) {
|
|
246
|
+
return await runUserScopeDoctor(hasSwitch('--verbose') || hasSwitch('-v'));
|
|
247
|
+
}
|
|
248
|
+
const frameworkRoot = (hasSwitch('--decision-offload') || hasSwitch('--resources')) ? ctx.frameworkRoot : await getFrameworkRoot();
|
|
249
|
+
const runner = createScriptRunner(frameworkRoot);
|
|
250
|
+
// Run core doctor diagnostics
|
|
251
|
+
const result = await runner.run('tools/cli/doctor.mjs', ctx.args, { cwd: ctx.cwd });
|
|
252
|
+
// Machine-readable worker probes (#3066): tools/cli/doctor.mjs already
|
|
253
|
+
// printed exactly one JSON document (or a usage error) on its own
|
|
254
|
+
// stdio — every section below writes human-readable text, so returning
|
|
255
|
+
// here keeps stdout to the JSON document alone.
|
|
256
|
+
if (hasSwitch('--resources') || hasSwitch('--list-approvals') || values.get('--forget-approval') || hasSwitch('--decision-offload') || hasSwitch('--json') || hasSwitch('--qualify') || hasSwitch('--cli') || hasSwitch('--dry-run') || result.exitCode === 2)
|
|
257
|
+
return result;
|
|
258
|
+
let agentSkillsFailure = false;
|
|
259
|
+
try {
|
|
260
|
+
const { inspectGrokBuildNative } = await import('../../mcp/grok-build-config.mjs');
|
|
261
|
+
const native = await inspectGrokBuildNative({ projectDir: ctx.cwd || process.cwd() });
|
|
262
|
+
console.log(`\n── Grok Build native extensions ──\n MCP: ${native.mcp}\n Hooks: ${native.hooks}`);
|
|
263
|
+
for (const diagnostic of native.diagnostics)
|
|
264
|
+
console.log(` ⚠ ${diagnostic}`);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
console.log(`\n── Grok Build native extensions ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
268
|
+
}
|
|
269
|
+
try {
|
|
270
|
+
const projectDir = ctx.cwd || process.cwd();
|
|
271
|
+
const provider = flagValue(ctx.args, '--provider');
|
|
272
|
+
const requested = provider === 'muse' || ctx.args.includes('--all-providers');
|
|
273
|
+
const { inspectMuseNative, isMuseDeployedProject } = await import('../../mcp/muse-native-config.mjs');
|
|
274
|
+
if (requested || await isMuseDeployedProject(projectDir)) {
|
|
275
|
+
const native = await inspectMuseNative({ projectDir });
|
|
276
|
+
console.log(`\n── Muse Code native extensions ──\n CLI: ${native.cli}\n Hooks: ${native.hooks}\n MCP: ${native.mcp}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.log(`\n── Muse Code native extensions ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
const { buildAgentSkillsDoctorSection } = await import('../../skills/doctor.js');
|
|
284
|
+
const section = buildAgentSkillsDoctorSection(ctx.cwd || process.cwd());
|
|
285
|
+
console.log(section.output);
|
|
286
|
+
agentSkillsFailure = section.hasFailures;
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
console.log(`\n── Agent Skills conformance ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
290
|
+
}
|
|
291
|
+
// Surface feedback escape hatch when doctor finds issues
|
|
292
|
+
if (result.exitCode !== 0) {
|
|
293
|
+
console.log(`
|
|
294
|
+
── Recovery options ──
|
|
295
|
+
aiwg session --no-repair — launch anyway (skip auto-repair)
|
|
296
|
+
aiwg sync — sync to latest and redeploy
|
|
297
|
+
aiwg feedback --type bug — report this issue to GitHub
|
|
298
|
+
`);
|
|
299
|
+
}
|
|
300
|
+
// Append collision scan: check deployed skills dir for bad-state collisions
|
|
301
|
+
// (platform built-ins and AIWG CLI command shadows)
|
|
302
|
+
try {
|
|
303
|
+
const projectDir = ctx.cwd || process.cwd();
|
|
304
|
+
const skillsDir = path.join(projectDir, '.claude', 'skills');
|
|
305
|
+
const deployedSkillNames = await collectDeployedSkillDirNames(skillsDir);
|
|
306
|
+
if (deployedSkillNames.length > 0) {
|
|
307
|
+
const collisions = await checkCollisions({
|
|
308
|
+
platform: 'claude',
|
|
309
|
+
projectPath: projectDir,
|
|
310
|
+
skillNames: deployedSkillNames,
|
|
311
|
+
namespace: 'aiwg',
|
|
312
|
+
skillsBaseDir: skillsDir,
|
|
313
|
+
});
|
|
314
|
+
// Two distinct causes share this scan, and conflating them mislabels
|
|
315
|
+
// one as the other: an `error` is a name that shadows a Claude
|
|
316
|
+
// built-in; a `warn` is a deployed skill this namespace does not own
|
|
317
|
+
// (#2504). Report each under its own heading with its own remedy.
|
|
318
|
+
const builtinCollisions = collisions.filter(r => r.severity === 'error');
|
|
319
|
+
const unownedCollisions = collisions.filter(r => r.severity === 'warn');
|
|
320
|
+
if (builtinCollisions.length > 0 || unownedCollisions.length > 0) {
|
|
321
|
+
console.log('\n── Skill collision scan ──');
|
|
322
|
+
if (builtinCollisions.length > 0) {
|
|
323
|
+
console.log('');
|
|
324
|
+
console.log('⚠ Stale skills detected (names collide with Claude built-ins):');
|
|
325
|
+
for (const r of builtinCollisions) {
|
|
326
|
+
console.log(` ✗ ${r.skillName}: ${r.reason}`);
|
|
327
|
+
}
|
|
328
|
+
console.log('');
|
|
329
|
+
console.log(' Fix: run `aiwg use <framework>` to redeploy and auto-clean stale skill directories.');
|
|
330
|
+
}
|
|
331
|
+
if (unownedCollisions.length > 0) {
|
|
332
|
+
console.log('');
|
|
333
|
+
console.log("⚠ Deployed skills not owned by namespace 'aiwg' (a redeploy would overwrite them):");
|
|
334
|
+
for (const r of unownedCollisions) {
|
|
335
|
+
console.log(` ✗ ${r.skillName}: ${r.reason}`);
|
|
336
|
+
}
|
|
337
|
+
console.log('');
|
|
338
|
+
console.log(" Fix: if the skill is yours, move it out of the AIWG-managed skills directory");
|
|
339
|
+
console.log(" or give it its own namespace. If AIWG generated it, re-run `aiwg use` to");
|
|
340
|
+
console.log(' restore the ownership marker.');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
// Collision scan is non-fatal for doctor
|
|
347
|
+
}
|
|
348
|
+
// #1037 / #1049 — Project-local artifacts section: per-type counts,
|
|
349
|
+
// validation errors, shadows, denylist violations, drift detection,
|
|
350
|
+
// and provider deployment matrix. Replaces the older inline shadow
|
|
351
|
+
// scan with the richer section spec'd by design-doctor-log-promote.md.
|
|
352
|
+
try {
|
|
353
|
+
const projectDir = ctx.cwd || process.cwd();
|
|
354
|
+
const fr = await getFrameworkRoot();
|
|
355
|
+
const { readAiwgConfig } = await import('../../config/aiwg-config.js');
|
|
356
|
+
const config = await readAiwgConfig(projectDir);
|
|
357
|
+
const { buildProjectLocalDoctorSection } = await import('../../extensions/project-local-doctor.js');
|
|
358
|
+
const onlyProjectLocal = ctx.args.includes('--project-local');
|
|
359
|
+
const quiet = ctx.args.includes('--quiet');
|
|
360
|
+
const section = await buildProjectLocalDoctorSection({
|
|
361
|
+
projectDir, frameworkRoot: fr, config, quiet,
|
|
362
|
+
});
|
|
363
|
+
if (section.output) {
|
|
364
|
+
console.log(section.output);
|
|
365
|
+
}
|
|
366
|
+
// When --project-local is requested as the only output and the rest
|
|
367
|
+
// of doctor printed nothing project-local-specific, fold result exit
|
|
368
|
+
// into our own findings.
|
|
369
|
+
if (onlyProjectLocal && section.hasFailures) {
|
|
370
|
+
return { exitCode: 1, message: '' };
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
// Project-local section is non-fatal for doctor
|
|
375
|
+
}
|
|
376
|
+
// Web-backed resource lock/cache diagnostics (#1850). Report lock source
|
|
377
|
+
// mode, cold cache, and digest drift without requiring web mode to be in use.
|
|
378
|
+
try {
|
|
379
|
+
const { buildWebResourceDoctorSection } = await import('../../resources/doctor.js');
|
|
380
|
+
const section = buildWebResourceDoctorSection(ctx.cwd || process.cwd(), {
|
|
381
|
+
cacheRoot: process.env.AIWG_RESOURCE_CACHE_ROOT,
|
|
382
|
+
});
|
|
383
|
+
if (section.output)
|
|
384
|
+
console.log(section.output);
|
|
385
|
+
if (section.hasFailures)
|
|
386
|
+
return { exitCode: 1, message: '' };
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
console.log(`\n── Web resource cache ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
390
|
+
}
|
|
391
|
+
// Canonical workspace-context graph diagnostics (#1811). Legacy projects
|
|
392
|
+
// remain valid; drift, loops, conflicts, and possible credentials fail.
|
|
393
|
+
try {
|
|
394
|
+
const { diagnoseWorkspaceContext } = await import('../../smiths/context-pipeline/workspace-context.js');
|
|
395
|
+
const diagnostics = await diagnoseWorkspaceContext(ctx.cwd || process.cwd());
|
|
396
|
+
console.log('\n── Workspace context graph ──');
|
|
397
|
+
for (const diagnostic of diagnostics) {
|
|
398
|
+
const mark = diagnostic.severity === 'error' ? '✗' : diagnostic.severity === 'warning' ? '⚠' : '✓';
|
|
399
|
+
console.log(` ${mark} ${diagnostic.message}`);
|
|
400
|
+
}
|
|
401
|
+
if (diagnostics.some((item) => item.severity === 'error'))
|
|
402
|
+
return { exitCode: 1, message: '' };
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
console.log(`\n── Workspace context graph ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
406
|
+
}
|
|
407
|
+
return agentSkillsFailure
|
|
408
|
+
? { exitCode: 1, message: '' }
|
|
409
|
+
: result;
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
//# sourceMappingURL=utility-doctor.js.map
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* project` are mutually exclusive; default is `project`.
|
|
11
11
|
*/
|
|
12
12
|
import { resolveOmpPaths } from '../providers/omp-paths.mjs';
|
|
13
|
+
import { mirrorArtifactDir, assertGrokUserMirrorPaths } from './user-scope-mirror.js';
|
|
13
14
|
import { homedir } from 'node:os';
|
|
14
15
|
import * as path from 'node:path';
|
|
15
16
|
import { resolveHermesHome, resolveHermesHomePath } from '../providers/hermes-home.js';
|
|
@@ -373,57 +374,6 @@ export async function mirrorToUserScope(provider, projectPaths) {
|
|
|
373
374
|
]);
|
|
374
375
|
return { agents, skills, commands, rules, behaviors };
|
|
375
376
|
}
|
|
376
|
-
async function assertGrokUserMirrorPaths(projectPaths, userPaths) {
|
|
377
|
-
const fs = await import('node:fs/promises');
|
|
378
|
-
const statIfPresent = async (target) => {
|
|
379
|
-
try {
|
|
380
|
-
return await fs.lstat(target);
|
|
381
|
-
}
|
|
382
|
-
catch (error) {
|
|
383
|
-
if (error.code === 'ENOENT')
|
|
384
|
-
return null;
|
|
385
|
-
throw error;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
const checkTarget = async (target) => {
|
|
389
|
-
const stat = await statIfPresent(target);
|
|
390
|
-
if (!stat)
|
|
391
|
-
return;
|
|
392
|
-
if (stat.isSymbolicLink() || (!stat.isDirectory() && !stat.isFile())) {
|
|
393
|
-
throw new Error(`Refusing unsafe Grok Build user mirror target: ${target}`);
|
|
394
|
-
}
|
|
395
|
-
if (stat.isDirectory()) {
|
|
396
|
-
for (const name of await fs.readdir(target))
|
|
397
|
-
await checkTarget(path.join(target, name));
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
for (const [destination, sources] of [
|
|
401
|
-
[userPaths.agents, [projectPaths.agents]],
|
|
402
|
-
[userPaths.skills, [projectPaths.skills, projectPaths.kernelSkills ?? '']],
|
|
403
|
-
]) {
|
|
404
|
-
if (!destination)
|
|
405
|
-
continue;
|
|
406
|
-
const rootStat = await statIfPresent(destination);
|
|
407
|
-
if (rootStat && (rootStat.isSymbolicLink() || !rootStat.isDirectory())) {
|
|
408
|
-
throw new Error(`Refusing unsafe Grok Build user mirror root: ${destination}`);
|
|
409
|
-
}
|
|
410
|
-
for (const source of sources) {
|
|
411
|
-
if (!source)
|
|
412
|
-
continue;
|
|
413
|
-
let names;
|
|
414
|
-
try {
|
|
415
|
-
names = await fs.readdir(source);
|
|
416
|
-
}
|
|
417
|
-
catch (error) {
|
|
418
|
-
if (error.code === 'ENOENT')
|
|
419
|
-
continue;
|
|
420
|
-
throw error;
|
|
421
|
-
}
|
|
422
|
-
for (const name of names)
|
|
423
|
-
await checkTarget(path.join(destination, name));
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
377
|
/**
|
|
428
378
|
* Merge standard and kernel skill directories into one user-discoverable
|
|
429
379
|
* target. Provider deployments intentionally keep those source surfaces
|
|
@@ -444,97 +394,6 @@ export async function mirrorSkillDirsToUserScope(sourceDirs, targetDir) {
|
|
|
444
394
|
entries: [...entries],
|
|
445
395
|
};
|
|
446
396
|
}
|
|
447
|
-
/**
|
|
448
|
-
* Copy every directory or file under `src` into `dst` (creating `dst` if
|
|
449
|
-
* needed). Returns the count of top-level entries successfully copied and
|
|
450
|
-
* the entry names themselves — the names are needed by callers that record
|
|
451
|
-
* a per-framework manifest at user scope so `aiwg remove --scope user` can
|
|
452
|
-
* delete only what this deploy created.
|
|
453
|
-
*
|
|
454
|
-
* Used by the user-scope mirror to cover both directory-style artifacts
|
|
455
|
-
* (skills, agents) and file-style artifacts (commands, rules in some
|
|
456
|
-
* providers). Failures on individual entries are swallowed so a single bad
|
|
457
|
-
* entry doesn't fail the whole mirror.
|
|
458
|
-
*/
|
|
459
|
-
async function mirrorArtifactDir(src, dst, ownedThisCall = new Set()) {
|
|
460
|
-
if (!src || !dst)
|
|
461
|
-
return { count: 0, targetDir: dst, entries: [] };
|
|
462
|
-
const fs = await import('node:fs/promises');
|
|
463
|
-
let dirents;
|
|
464
|
-
try {
|
|
465
|
-
dirents = await fs.readdir(src, { withFileTypes: true });
|
|
466
|
-
}
|
|
467
|
-
catch {
|
|
468
|
-
return { count: 0, targetDir: dst, entries: [] };
|
|
469
|
-
}
|
|
470
|
-
// Some providers already deploy kernel skills to an absolute user-level
|
|
471
|
-
// path. Inventory that source for registry accounting instead of trying to
|
|
472
|
-
// recursively copy each entry onto itself.
|
|
473
|
-
if (path.resolve(src) === path.resolve(dst)) {
|
|
474
|
-
const entries = [];
|
|
475
|
-
for (const entry of dirents) {
|
|
476
|
-
if ((entry.isDirectory() || entry.isFile()) && await isAiwgManagedEntry(path.join(dst, entry.name), entry.isDirectory())) {
|
|
477
|
-
entries.push(entry.name);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return { count: entries.length, targetDir: dst, entries };
|
|
481
|
-
}
|
|
482
|
-
await fs.mkdir(dst, { recursive: true });
|
|
483
|
-
let count = 0;
|
|
484
|
-
const entries = [];
|
|
485
|
-
for (const entry of dirents) {
|
|
486
|
-
const s = path.join(src, entry.name);
|
|
487
|
-
const d = path.join(dst, entry.name);
|
|
488
|
-
try {
|
|
489
|
-
// User-scope directories are shared with operator-created artifacts.
|
|
490
|
-
// A same-named unmanaged entry belongs to the operator, even when a
|
|
491
|
-
// project has an AIWG-managed source with that name.
|
|
492
|
-
try {
|
|
493
|
-
const existing = await fs.lstat(d);
|
|
494
|
-
if (!ownedThisCall.has(entry.name) && !await isAiwgManagedEntry(d, existing.isDirectory()))
|
|
495
|
-
continue;
|
|
496
|
-
}
|
|
497
|
-
catch (error) {
|
|
498
|
-
if (error.code !== 'ENOENT')
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
if (entry.isDirectory()) {
|
|
502
|
-
await fs.cp(s, d, { recursive: true, force: true });
|
|
503
|
-
}
|
|
504
|
-
else if (entry.isFile()) {
|
|
505
|
-
await fs.copyFile(s, d);
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
continue;
|
|
509
|
-
}
|
|
510
|
-
count++;
|
|
511
|
-
entries.push(entry.name);
|
|
512
|
-
}
|
|
513
|
-
catch {
|
|
514
|
-
// ignore individual failures
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return { count, targetDir: dst, entries };
|
|
518
|
-
}
|
|
519
|
-
async function isAiwgManagedEntry(target, directory) {
|
|
520
|
-
const fs = await import('node:fs/promises');
|
|
521
|
-
if (directory) {
|
|
522
|
-
try {
|
|
523
|
-
const marker = await fs.readFile(path.join(target, '.aiwg-managed'), 'utf8');
|
|
524
|
-
if (marker.trim() === 'aiwg')
|
|
525
|
-
return true;
|
|
526
|
-
}
|
|
527
|
-
catch { /* legacy deployed skill may use an inline marker */ }
|
|
528
|
-
}
|
|
529
|
-
const markerFile = directory ? path.join(target, 'SKILL.md') : target;
|
|
530
|
-
try {
|
|
531
|
-
const text = await fs.readFile(markerFile, 'utf8');
|
|
532
|
-
return /(?:#|<!--) aiwg:managed v[^\s]+ [^\r\n]+/.test(text.slice(0, 2048));
|
|
533
|
-
}
|
|
534
|
-
catch {
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
397
|
/**
|
|
539
398
|
* #1156 Phase 1 — some app providers are exclusively user-scope. `--scope
|
|
540
399
|
* project` against them is meaningless because their paths are home-rooted;
|
|
@@ -577,7 +577,6 @@ export async function verifyProviderDeployment(options) {
|
|
|
577
577
|
const requiredContext = [
|
|
578
578
|
path.join(options.projectRoot, 'WORKSPACE.md'),
|
|
579
579
|
...(definition?.paths.contextFiles.aiwgMd === false ? [] : [path.join(options.projectRoot, 'AIWG.md')]),
|
|
580
|
-
path.join(options.projectRoot, '.aiwg', 'AIWG.md'),
|
|
581
580
|
];
|
|
582
581
|
for (const contextPath of requiredContext) {
|
|
583
582
|
if (!(await exists(contextPath))) {
|