@aiwg/cli 2026.10.15 → 2026.10.16
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 +23 -9
- 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/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/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +3 -2
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands.js +8 -0
- 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/services/deployment-verification.js +0 -1
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +17 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +19 -0
- package/dist/src/config/host-resource-report.mjs +80 -0
- package/dist/src/config/host-resource-runtime.d.mts +34 -0
- package/dist/src/config/host-resource-runtime.mjs +293 -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/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/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +115 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/gates/heldout.js +17 -7
- 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/memory/project-registry.js +44 -4
- 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/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/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/research/clients/arxiv.js +4 -30
- package/dist/src/research/clients/base.js +48 -22
- package/dist/src/research/identity.js +34 -2
- 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 +70 -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/serve/mission-conductor.js +48 -4
- 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 +16 -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/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +9 -10
- 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/package.json +10 -1
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +10 -0
- package/tools/agents/providers/claude-post-deploy.mjs +12 -1
- package/tools/agents/providers/context-write.mjs +4 -0
- package/tools/agents/providers/pi.mjs +3 -1
- package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1144
- package/tools/agents/providers/rule-deployment-commit.mjs +144 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +452 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -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 +3 -2
- 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-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { parsePublicDoctorFlags } from './doctor-args.js';
|
|
2
1
|
/**
|
|
3
2
|
* Utility Command Handlers
|
|
4
3
|
*
|
|
@@ -11,48 +10,12 @@ import { parsePublicDoctorFlags } from './doctor-args.js';
|
|
|
11
10
|
* @issue #33, #342
|
|
12
11
|
*/
|
|
13
12
|
import fs from 'fs';
|
|
14
|
-
import fsp from 'fs/promises';
|
|
15
13
|
import path from 'path';
|
|
16
14
|
import { createScriptRunner } from './script-runner.js';
|
|
17
|
-
import { DOCTOR_HELP } from './doctor-help.js';
|
|
18
15
|
import { getFrameworkRoot } from '../../channel/manager.mjs';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
import { checkCollisions, } from '../../smiths/skillsmith/collision-detector.js';
|
|
23
|
-
import { renderUseDeploymentResult, verifyConfiguredDeployments, } from '../services/deployment-verification.js';
|
|
24
|
-
/**
|
|
25
|
-
* Maps framework registry IDs (e.g. 'sdlc-complete') to `aiwg use` names (e.g. 'sdlc').
|
|
26
|
-
*/
|
|
27
|
-
const REGISTRY_ID_TO_USE_NAME = {
|
|
28
|
-
'sdlc-complete': 'sdlc',
|
|
29
|
-
'media-marketing-kit': 'marketing',
|
|
30
|
-
'media-curator': 'media-curator',
|
|
31
|
-
'research-complete': 'research',
|
|
32
|
-
'forensics-complete': 'forensics',
|
|
33
|
-
};
|
|
34
|
-
function flagValue(args, flag) {
|
|
35
|
-
const index = args.indexOf(flag);
|
|
36
|
-
if (index >= 0)
|
|
37
|
-
return args[index + 1];
|
|
38
|
-
const prefix = `${flag}=`;
|
|
39
|
-
return args.find((arg) => arg.startsWith(prefix))?.slice(prefix.length);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Read the installed frameworks from the on-disk registry.
|
|
43
|
-
*/
|
|
44
|
-
function readFrameworkRegistry(cwd) {
|
|
45
|
-
const registryPath = projectAiwgPath(cwd, 'frameworks', 'registry.json');
|
|
46
|
-
if (!fs.existsSync(registryPath)) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
return JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
16
|
+
import { doctorHandler } from './utility-doctor.js';
|
|
17
|
+
import { updateHandler } from './update.js';
|
|
18
|
+
export { doctorHandler, updateHandler };
|
|
56
19
|
/**
|
|
57
20
|
* Handler for prefill-cards command
|
|
58
21
|
*
|
|
@@ -328,401 +291,6 @@ export const validateMetadataHandler = {
|
|
|
328
291
|
return result;
|
|
329
292
|
},
|
|
330
293
|
};
|
|
331
|
-
/**
|
|
332
|
-
* A directory is a deployed skill only if it carries a SKILL.md manifest —
|
|
333
|
-
* the same marker `isOwnedByNamespace()` in collision-detector.ts reads for
|
|
334
|
-
* ownership. Harness container/bucket directories (e.g. Claude Code's own
|
|
335
|
-
* `.claude/skills/synced/` sync storage, which holds UUID-named dirs with
|
|
336
|
-
* `manifest.json`, not SKILL.md) have no manifest of their own and must
|
|
337
|
-
* never be reported as a colliding skill (#278).
|
|
338
|
-
*
|
|
339
|
-
* A container directory without its own SKILL.md is still descended exactly
|
|
340
|
-
* one level: a real skill nested inside it (`<container>/<skill>/SKILL.md`)
|
|
341
|
-
* is reported as `<container>/<skill>`, while the container itself never is.
|
|
342
|
-
*/
|
|
343
|
-
async function hasSkillManifest(dirPath) {
|
|
344
|
-
try {
|
|
345
|
-
await fsp.access(path.join(dirPath, 'SKILL.md'));
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
catch {
|
|
349
|
-
return false;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
async function collectDeployedSkillDirNames(skillsDir) {
|
|
353
|
-
let topEntries;
|
|
354
|
-
try {
|
|
355
|
-
topEntries = await fsp.readdir(skillsDir, { withFileTypes: true });
|
|
356
|
-
}
|
|
357
|
-
catch {
|
|
358
|
-
return [];
|
|
359
|
-
}
|
|
360
|
-
const names = [];
|
|
361
|
-
for (const entry of topEntries) {
|
|
362
|
-
if (!entry.isDirectory())
|
|
363
|
-
continue;
|
|
364
|
-
const dirPath = path.join(skillsDir, entry.name);
|
|
365
|
-
if (await hasSkillManifest(dirPath)) {
|
|
366
|
-
names.push(entry.name);
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
let nestedEntries;
|
|
370
|
-
try {
|
|
371
|
-
nestedEntries = await fsp.readdir(dirPath, { withFileTypes: true });
|
|
372
|
-
}
|
|
373
|
-
catch {
|
|
374
|
-
continue;
|
|
375
|
-
}
|
|
376
|
-
for (const nested of nestedEntries) {
|
|
377
|
-
if (!nested.isDirectory())
|
|
378
|
-
continue;
|
|
379
|
-
const nestedPath = path.join(dirPath, nested.name);
|
|
380
|
-
if (await hasSkillManifest(nestedPath)) {
|
|
381
|
-
names.push(path.join(entry.name, nested.name));
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return names;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* #1156 Phase 1 — Validate the per-user registry at `~/.aiwg/installed.json`.
|
|
389
|
-
*
|
|
390
|
-
* Checks each registered framework+provider deploy:
|
|
391
|
-
* - Registry entry parses correctly
|
|
392
|
-
* - Recorded artifact entries (Cycle 3 mirrors) still exist on disk
|
|
393
|
-
* - Per-artifact-type counts match the actual entry-name list length
|
|
394
|
-
* - Pre-Cycle-3 entries (no `entries` snapshot) are surfaced as "limited
|
|
395
|
-
* drift detection" rather than failures
|
|
396
|
-
*
|
|
397
|
-
* Returns exit 1 when drift is detected, exit 0 otherwise. Output is plain
|
|
398
|
-
* text suitable for terminal consumption.
|
|
399
|
-
*/
|
|
400
|
-
async function runUserScopeDoctor(verbose) {
|
|
401
|
-
const { readUserRegistry, userRegistryPath } = await import('../../config/user-registry.js');
|
|
402
|
-
const { USER_SCOPE_PATHS } = await import('../scope-resolver.js');
|
|
403
|
-
const fsp2 = await import('node:fs/promises');
|
|
404
|
-
const path2 = await import('node:path');
|
|
405
|
-
const registry = await readUserRegistry();
|
|
406
|
-
const frameworks = Object.entries(registry.installed);
|
|
407
|
-
const lines = [];
|
|
408
|
-
lines.push('');
|
|
409
|
-
lines.push('── User-scope registry validation ──');
|
|
410
|
-
lines.push(`Registry path: ${userRegistryPath()}`);
|
|
411
|
-
lines.push('');
|
|
412
|
-
if (frameworks.length === 0) {
|
|
413
|
-
lines.push('No frameworks deployed at user scope. Run `aiwg use <fw> --scope user` to install.');
|
|
414
|
-
return { exitCode: 0, message: lines.join('\n') + '\n' };
|
|
415
|
-
}
|
|
416
|
-
let driftCount = 0;
|
|
417
|
-
let limitedCount = 0;
|
|
418
|
-
for (const [name, entry] of frameworks) {
|
|
419
|
-
lines.push(`▸ ${name} v${entry.version} [${entry.source}]`);
|
|
420
|
-
for (const [provider, providerDeployRaw] of Object.entries(entry.deployedTo)) {
|
|
421
|
-
// Cast through unknown for the optional `entries` snapshot.
|
|
422
|
-
const providerDeploy = providerDeployRaw;
|
|
423
|
-
const userPaths = USER_SCOPE_PATHS[provider];
|
|
424
|
-
if (!userPaths) {
|
|
425
|
-
lines.push(` ${provider}: ⚠ no user-scope path map registered for this provider`);
|
|
426
|
-
driftCount++;
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
429
|
-
const recorded = providerDeploy.entries;
|
|
430
|
-
if (!recorded) {
|
|
431
|
-
lines.push(` ${provider}: ⚠ pre-Cycle-3 entry — no per-artifact manifest, drift detection limited`);
|
|
432
|
-
lines.push(` counts: agents=${providerDeploy.agents} commands=${providerDeploy.commands} skills=${providerDeploy.skills} rules=${providerDeploy.rules}`);
|
|
433
|
-
limitedCount++;
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
// Walk the recorded entry names and check each one exists on disk.
|
|
437
|
-
const checks = [
|
|
438
|
-
['agents', userPaths.agents, recorded.agents, providerDeploy.agents],
|
|
439
|
-
['commands', userPaths.commands, recorded.commands, providerDeploy.commands],
|
|
440
|
-
['skills', userPaths.skills, recorded.skills, providerDeploy.skills],
|
|
441
|
-
['rules', userPaths.rules, recorded.rules, providerDeploy.rules],
|
|
442
|
-
];
|
|
443
|
-
const issues = [];
|
|
444
|
-
for (const [type, dir, names, expectedCount] of checks) {
|
|
445
|
-
if (!dir || !names)
|
|
446
|
-
continue;
|
|
447
|
-
let present = 0;
|
|
448
|
-
const missing = [];
|
|
449
|
-
for (const n of names) {
|
|
450
|
-
const target = path2.join(dir, n);
|
|
451
|
-
const stat = await fsp2.stat(target).catch(() => null);
|
|
452
|
-
if (stat)
|
|
453
|
-
present++;
|
|
454
|
-
else
|
|
455
|
-
missing.push(n);
|
|
456
|
-
}
|
|
457
|
-
if (names.length !== expectedCount) {
|
|
458
|
-
issues.push(`count drift on ${type}: registry says ${expectedCount}, manifest lists ${names.length}`);
|
|
459
|
-
}
|
|
460
|
-
if (missing.length > 0) {
|
|
461
|
-
issues.push(`${type}: ${missing.length}/${names.length} entries missing from ${dir}`);
|
|
462
|
-
if (verbose) {
|
|
463
|
-
for (const m of missing)
|
|
464
|
-
issues.push(` missing: ${path2.join(dir, m)}`);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
else if (verbose) {
|
|
468
|
-
issues.push(`${type}: ${present}/${names.length} present at ${dir}`);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (issues.length === 0) {
|
|
472
|
-
lines.push(` ${provider}: ✓ all recorded artifacts present`);
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
const hasMissing = issues.some(i => i.includes('missing') || i.includes('drift'));
|
|
476
|
-
const marker = hasMissing ? '✗' : 'ℹ';
|
|
477
|
-
lines.push(` ${provider}: ${marker}`);
|
|
478
|
-
for (const i of issues)
|
|
479
|
-
lines.push(` ${i}`);
|
|
480
|
-
if (hasMissing)
|
|
481
|
-
driftCount++;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
lines.push('');
|
|
486
|
-
lines.push('═'.repeat(60));
|
|
487
|
-
lines.push(`Frameworks: ${frameworks.length} Drift: ${driftCount} Limited (pre-Cycle-3): ${limitedCount}`);
|
|
488
|
-
if (driftCount > 0) {
|
|
489
|
-
lines.push('');
|
|
490
|
-
lines.push('Drift detected. To repair, re-run `aiwg use <framework> --scope user --provider <p>`.');
|
|
491
|
-
lines.push('To remove a stale registry entry, run `aiwg remove <framework> --scope user`.');
|
|
492
|
-
}
|
|
493
|
-
return {
|
|
494
|
-
exitCode: driftCount > 0 ? 1 : 0,
|
|
495
|
-
message: lines.join('\n') + '\n',
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Handler for doctor command
|
|
500
|
-
*
|
|
501
|
-
* Runs health diagnostics on the AIWG installation and workspace.
|
|
502
|
-
*
|
|
503
|
-
* Usage:
|
|
504
|
-
* aiwg doctor
|
|
505
|
-
* aiwg -doctor
|
|
506
|
-
* aiwg --doctor
|
|
507
|
-
* aiwg doctor --verbose
|
|
508
|
-
* aiwg doctor --scope user # validate ~/.aiwg/installed.json
|
|
509
|
-
*/
|
|
510
|
-
export const doctorHandler = {
|
|
511
|
-
id: 'doctor',
|
|
512
|
-
name: 'Doctor',
|
|
513
|
-
description: 'Run health diagnostics',
|
|
514
|
-
category: 'maintenance',
|
|
515
|
-
aliases: ['-doctor', '--doctor'],
|
|
516
|
-
async help() {
|
|
517
|
-
return { exitCode: 0, message: DOCTOR_HELP, rawOutput: true };
|
|
518
|
-
},
|
|
519
|
-
async execute(ctx) {
|
|
520
|
-
// Validate before any early-return mode: deployment and user-scope doctor
|
|
521
|
-
// never invoke doctor.mjs, so they must enforce the same flag contract.
|
|
522
|
-
let flags;
|
|
523
|
-
try {
|
|
524
|
-
flags = parsePublicDoctorFlags(ctx.args);
|
|
525
|
-
}
|
|
526
|
-
catch (error) {
|
|
527
|
-
return { exitCode: 2, message: `${error instanceof Error ? error.message : String(error)}. See 'aiwg doctor --help'.` };
|
|
528
|
-
}
|
|
529
|
-
const { hasSwitch, values } = flags;
|
|
530
|
-
if (hasSwitch('--help') || hasSwitch('-h')) {
|
|
531
|
-
return { exitCode: 0, message: DOCTOR_HELP, rawOutput: true };
|
|
532
|
-
}
|
|
533
|
-
if (hasSwitch('--deployment')) {
|
|
534
|
-
const scopeValue = values.get('--scope');
|
|
535
|
-
if (scopeValue && scopeValue !== 'project' && scopeValue !== 'user') {
|
|
536
|
-
return { exitCode: 2, message: `Invalid deployment verification scope: ${scopeValue}` };
|
|
537
|
-
}
|
|
538
|
-
const result = await verifyConfiguredDeployments(ctx.cwd || process.cwd(), {
|
|
539
|
-
provider: values.get('--provider'),
|
|
540
|
-
bundle: values.get('--bundle'),
|
|
541
|
-
scope: scopeValue,
|
|
542
|
-
}, ctx.frameworkRoot);
|
|
543
|
-
const { rulePinState } = await import('../../rules/pin-state.js');
|
|
544
|
-
const pins = rulePinState(ctx.cwd, ctx.frameworkRoot);
|
|
545
|
-
return {
|
|
546
|
-
exitCode: result.exitCode,
|
|
547
|
-
message: hasSwitch('--json')
|
|
548
|
-
? JSON.stringify({ ...result, rule_pins: { rules: pins.rules, warnings: pins.warnings } }, null, 2)
|
|
549
|
-
: renderUseDeploymentResult(result) + '\n' + pins.rules.map(rule => `${rule.name}: pinned kernel (canonical ${rule.canonical_activation})`).concat(pins.warnings).join('\n'),
|
|
550
|
-
rawOutput: hasSwitch('--json'),
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
// #1156 Phase 1 — `aiwg doctor --scope user` / `aiwg doctor --user`
|
|
554
|
-
// validates the per-user registry (~/.aiwg/installed.json) without
|
|
555
|
-
// running the project-scope diagnostics. Operators need this to verify
|
|
556
|
-
// their user-scope deployments from any cwd, including shells with no
|
|
557
|
-
// project at all.
|
|
558
|
-
const userScopeRequested = hasSwitch('--user') || values.get('--scope') === 'user';
|
|
559
|
-
if (userScopeRequested && !hasSwitch('--probe-workers')) {
|
|
560
|
-
return await runUserScopeDoctor(hasSwitch('--verbose') || hasSwitch('-v'));
|
|
561
|
-
}
|
|
562
|
-
const frameworkRoot = hasSwitch('--decision-offload') ? ctx.frameworkRoot : await getFrameworkRoot();
|
|
563
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
564
|
-
// Run core doctor diagnostics
|
|
565
|
-
const result = await runner.run('tools/cli/doctor.mjs', ctx.args, { cwd: ctx.cwd });
|
|
566
|
-
// Machine-readable worker probes (#3066): tools/cli/doctor.mjs already
|
|
567
|
-
// printed exactly one JSON document (or a usage error) on its own
|
|
568
|
-
// stdio — every section below writes human-readable text, so returning
|
|
569
|
-
// here keeps stdout to the JSON document alone.
|
|
570
|
-
if (hasSwitch('--list-approvals') || values.get('--forget-approval') || hasSwitch('--decision-offload') || hasSwitch('--json') || hasSwitch('--qualify') || hasSwitch('--cli') || hasSwitch('--dry-run') || result.exitCode === 2)
|
|
571
|
-
return result;
|
|
572
|
-
let agentSkillsFailure = false;
|
|
573
|
-
try {
|
|
574
|
-
const { inspectGrokBuildNative } = await import('../../mcp/grok-build-config.mjs');
|
|
575
|
-
const native = await inspectGrokBuildNative({ projectDir: ctx.cwd || process.cwd() });
|
|
576
|
-
console.log(`\n── Grok Build native extensions ──\n MCP: ${native.mcp}\n Hooks: ${native.hooks}`);
|
|
577
|
-
for (const diagnostic of native.diagnostics)
|
|
578
|
-
console.log(` ⚠ ${diagnostic}`);
|
|
579
|
-
}
|
|
580
|
-
catch (error) {
|
|
581
|
-
console.log(`\n── Grok Build native extensions ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
582
|
-
}
|
|
583
|
-
try {
|
|
584
|
-
const projectDir = ctx.cwd || process.cwd();
|
|
585
|
-
const provider = flagValue(ctx.args, '--provider');
|
|
586
|
-
const requested = provider === 'muse' || ctx.args.includes('--all-providers');
|
|
587
|
-
const { inspectMuseNative, isMuseDeployedProject } = await import('../../mcp/muse-native-config.mjs');
|
|
588
|
-
if (requested || await isMuseDeployedProject(projectDir)) {
|
|
589
|
-
const native = await inspectMuseNative({ projectDir });
|
|
590
|
-
console.log(`\n── Muse Code native extensions ──\n CLI: ${native.cli}\n Hooks: ${native.hooks}\n MCP: ${native.mcp}`);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
catch (error) {
|
|
594
|
-
console.log(`\n── Muse Code native extensions ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
595
|
-
}
|
|
596
|
-
try {
|
|
597
|
-
const { buildAgentSkillsDoctorSection } = await import('../../skills/doctor.js');
|
|
598
|
-
const section = buildAgentSkillsDoctorSection(ctx.cwd || process.cwd());
|
|
599
|
-
console.log(section.output);
|
|
600
|
-
agentSkillsFailure = section.hasFailures;
|
|
601
|
-
}
|
|
602
|
-
catch (error) {
|
|
603
|
-
console.log(`\n── Agent Skills conformance ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
604
|
-
}
|
|
605
|
-
// Surface feedback escape hatch when doctor finds issues
|
|
606
|
-
if (result.exitCode !== 0) {
|
|
607
|
-
console.log(`
|
|
608
|
-
── Recovery options ──
|
|
609
|
-
aiwg session --no-repair — launch anyway (skip auto-repair)
|
|
610
|
-
aiwg sync — sync to latest and redeploy
|
|
611
|
-
aiwg feedback --type bug — report this issue to GitHub
|
|
612
|
-
`);
|
|
613
|
-
}
|
|
614
|
-
// Append collision scan: check deployed skills dir for bad-state collisions
|
|
615
|
-
// (platform built-ins and AIWG CLI command shadows)
|
|
616
|
-
try {
|
|
617
|
-
const projectDir = ctx.cwd || process.cwd();
|
|
618
|
-
const skillsDir = path.join(projectDir, '.claude', 'skills');
|
|
619
|
-
const deployedSkillNames = await collectDeployedSkillDirNames(skillsDir);
|
|
620
|
-
if (deployedSkillNames.length > 0) {
|
|
621
|
-
const collisions = await checkCollisions({
|
|
622
|
-
platform: 'claude',
|
|
623
|
-
projectPath: projectDir,
|
|
624
|
-
skillNames: deployedSkillNames,
|
|
625
|
-
namespace: 'aiwg',
|
|
626
|
-
skillsBaseDir: skillsDir,
|
|
627
|
-
});
|
|
628
|
-
// Two distinct causes share this scan, and conflating them mislabels
|
|
629
|
-
// one as the other: an `error` is a name that shadows a Claude
|
|
630
|
-
// built-in; a `warn` is a deployed skill this namespace does not own
|
|
631
|
-
// (#2504). Report each under its own heading with its own remedy.
|
|
632
|
-
const builtinCollisions = collisions.filter(r => r.severity === 'error');
|
|
633
|
-
const unownedCollisions = collisions.filter(r => r.severity === 'warn');
|
|
634
|
-
if (builtinCollisions.length > 0 || unownedCollisions.length > 0) {
|
|
635
|
-
console.log('\n── Skill collision scan ──');
|
|
636
|
-
if (builtinCollisions.length > 0) {
|
|
637
|
-
console.log('');
|
|
638
|
-
console.log('⚠ Stale skills detected (names collide with Claude built-ins):');
|
|
639
|
-
for (const r of builtinCollisions) {
|
|
640
|
-
console.log(` ✗ ${r.skillName}: ${r.reason}`);
|
|
641
|
-
}
|
|
642
|
-
console.log('');
|
|
643
|
-
console.log(' Fix: run `aiwg use <framework>` to redeploy and auto-clean stale skill directories.');
|
|
644
|
-
}
|
|
645
|
-
if (unownedCollisions.length > 0) {
|
|
646
|
-
console.log('');
|
|
647
|
-
console.log("⚠ Deployed skills not owned by namespace 'aiwg' (a redeploy would overwrite them):");
|
|
648
|
-
for (const r of unownedCollisions) {
|
|
649
|
-
console.log(` ✗ ${r.skillName}: ${r.reason}`);
|
|
650
|
-
}
|
|
651
|
-
console.log('');
|
|
652
|
-
console.log(" Fix: if the skill is yours, move it out of the AIWG-managed skills directory");
|
|
653
|
-
console.log(" or give it its own namespace. If AIWG generated it, re-run `aiwg use` to");
|
|
654
|
-
console.log(' restore the ownership marker.');
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
catch {
|
|
660
|
-
// Collision scan is non-fatal for doctor
|
|
661
|
-
}
|
|
662
|
-
// #1037 / #1049 — Project-local artifacts section: per-type counts,
|
|
663
|
-
// validation errors, shadows, denylist violations, drift detection,
|
|
664
|
-
// and provider deployment matrix. Replaces the older inline shadow
|
|
665
|
-
// scan with the richer section spec'd by design-doctor-log-promote.md.
|
|
666
|
-
try {
|
|
667
|
-
const projectDir = ctx.cwd || process.cwd();
|
|
668
|
-
const fr = await getFrameworkRoot();
|
|
669
|
-
const { readAiwgConfig } = await import('../../config/aiwg-config.js');
|
|
670
|
-
const config = await readAiwgConfig(projectDir);
|
|
671
|
-
const { buildProjectLocalDoctorSection } = await import('../../extensions/project-local-doctor.js');
|
|
672
|
-
const onlyProjectLocal = ctx.args.includes('--project-local');
|
|
673
|
-
const quiet = ctx.args.includes('--quiet');
|
|
674
|
-
const section = await buildProjectLocalDoctorSection({
|
|
675
|
-
projectDir, frameworkRoot: fr, config, quiet,
|
|
676
|
-
});
|
|
677
|
-
if (section.output) {
|
|
678
|
-
console.log(section.output);
|
|
679
|
-
}
|
|
680
|
-
// When --project-local is requested as the only output and the rest
|
|
681
|
-
// of doctor printed nothing project-local-specific, fold result exit
|
|
682
|
-
// into our own findings.
|
|
683
|
-
if (onlyProjectLocal && section.hasFailures) {
|
|
684
|
-
return { exitCode: 1, message: '' };
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
catch {
|
|
688
|
-
// Project-local section is non-fatal for doctor
|
|
689
|
-
}
|
|
690
|
-
// Web-backed resource lock/cache diagnostics (#1850). Report lock source
|
|
691
|
-
// mode, cold cache, and digest drift without requiring web mode to be in use.
|
|
692
|
-
try {
|
|
693
|
-
const { buildWebResourceDoctorSection } = await import('../../resources/doctor.js');
|
|
694
|
-
const section = buildWebResourceDoctorSection(ctx.cwd || process.cwd(), {
|
|
695
|
-
cacheRoot: process.env.AIWG_RESOURCE_CACHE_ROOT,
|
|
696
|
-
});
|
|
697
|
-
if (section.output)
|
|
698
|
-
console.log(section.output);
|
|
699
|
-
if (section.hasFailures)
|
|
700
|
-
return { exitCode: 1, message: '' };
|
|
701
|
-
}
|
|
702
|
-
catch (error) {
|
|
703
|
-
console.log(`\n── Web resource cache ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
704
|
-
}
|
|
705
|
-
// Canonical workspace-context graph diagnostics (#1811). Legacy projects
|
|
706
|
-
// remain valid; drift, loops, conflicts, and possible credentials fail.
|
|
707
|
-
try {
|
|
708
|
-
const { diagnoseWorkspaceContext } = await import('../../smiths/context-pipeline/workspace-context.js');
|
|
709
|
-
const diagnostics = await diagnoseWorkspaceContext(ctx.cwd || process.cwd());
|
|
710
|
-
console.log('\n── Workspace context graph ──');
|
|
711
|
-
for (const diagnostic of diagnostics) {
|
|
712
|
-
const mark = diagnostic.severity === 'error' ? '✗' : diagnostic.severity === 'warning' ? '⚠' : '✓';
|
|
713
|
-
console.log(` ${mark} ${diagnostic.message}`);
|
|
714
|
-
}
|
|
715
|
-
if (diagnostics.some((item) => item.severity === 'error'))
|
|
716
|
-
return { exitCode: 1, message: '' };
|
|
717
|
-
}
|
|
718
|
-
catch (error) {
|
|
719
|
-
console.log(`\n── Workspace context graph ──\n ⚠ unable to audit: ${error instanceof Error ? error.message : String(error)}`);
|
|
720
|
-
}
|
|
721
|
-
return agentSkillsFailure
|
|
722
|
-
? { exitCode: 1, message: '' }
|
|
723
|
-
: result;
|
|
724
|
-
},
|
|
725
|
-
};
|
|
726
294
|
const CONTEXT_FIREWALL_HELP = `aiwg context-firewall — inspect provider context and reviewed memory
|
|
727
295
|
|
|
728
296
|
Usage:
|
|
@@ -831,131 +399,6 @@ export const contextFirewallHandler = {
|
|
|
831
399
|
return runner.run('tools/security/context-memory-firewall.mjs', forwarded, { cwd: ctx.cwd });
|
|
832
400
|
},
|
|
833
401
|
};
|
|
834
|
-
/**
|
|
835
|
-
* Handler for update command
|
|
836
|
-
*
|
|
837
|
-
* Updates AIWG and re-deploys installed frameworks/addons.
|
|
838
|
-
* - Checks for npm/git updates first
|
|
839
|
-
* - Reads .aiwg/frameworks/registry.json to detect installed items
|
|
840
|
-
* - Re-deploys only those (preserving the user's current selection)
|
|
841
|
-
* - Use --all to deploy everything (equivalent to `aiwg use all`)
|
|
842
|
-
*
|
|
843
|
-
* Usage:
|
|
844
|
-
* aiwg update # Update + re-deploy installed frameworks
|
|
845
|
-
* aiwg update --all # Update + deploy everything
|
|
846
|
-
* aiwg update --dry-run # Show what would be updated
|
|
847
|
-
* aiwg update --provider <name> # Pass through provider to deployment
|
|
848
|
-
* aiwg update --skip-check # Skip npm/git update check, only re-deploy
|
|
849
|
-
*
|
|
850
|
-
* @issue #342
|
|
851
|
-
*/
|
|
852
|
-
export const updateHandler = {
|
|
853
|
-
id: 'update',
|
|
854
|
-
name: 'Update',
|
|
855
|
-
description: 'Update AIWG and re-deploy installed frameworks',
|
|
856
|
-
category: 'maintenance',
|
|
857
|
-
aliases: ['-update', '--update', 'upgrade'],
|
|
858
|
-
async execute(ctx) {
|
|
859
|
-
const args = ctx.args;
|
|
860
|
-
const deployAll = args.includes('--all');
|
|
861
|
-
const dryRun = args.includes('--dry-run');
|
|
862
|
-
const skipCheck = args.includes('--skip-check');
|
|
863
|
-
// Extract --provider value if present
|
|
864
|
-
const providerIdx = args.findIndex(a => a === '--provider' || a === '--platform');
|
|
865
|
-
const providerArgs = providerIdx >= 0 && args[providerIdx + 1]
|
|
866
|
-
? ['--provider', args[providerIdx + 1]]
|
|
867
|
-
: [];
|
|
868
|
-
// Step 1: Check for package updates (unless --skip-check)
|
|
869
|
-
if (!skipCheck) {
|
|
870
|
-
try {
|
|
871
|
-
console.log('Updating AIWG installation...\n');
|
|
872
|
-
const update = await updateInstallation({
|
|
873
|
-
dryRun,
|
|
874
|
-
offline: args.includes('--offline'),
|
|
875
|
-
});
|
|
876
|
-
console.log(`${update.message}\n`);
|
|
877
|
-
}
|
|
878
|
-
catch (error) {
|
|
879
|
-
if (error.code === 'AIWG_INSTALLATION_DRIFT'
|
|
880
|
-
|| error.code === 'AIWG_INSTALLATION_INVALID') {
|
|
881
|
-
return { exitCode: 78, message: error instanceof Error ? error.message : String(error) };
|
|
882
|
-
}
|
|
883
|
-
console.error(`Warning: Update check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
884
|
-
console.log('Continuing with re-deployment...\n');
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
// Step 2: Determine what to re-deploy
|
|
888
|
-
if (deployAll) {
|
|
889
|
-
// --all: deploy everything (equivalent to `aiwg use all`)
|
|
890
|
-
const frameworks = ['all'];
|
|
891
|
-
if (dryRun) {
|
|
892
|
-
console.log('Dry run: Would re-deploy all frameworks and addons');
|
|
893
|
-
return { exitCode: 0 };
|
|
894
|
-
}
|
|
895
|
-
console.log('Re-deploying all frameworks and addons...\n');
|
|
896
|
-
const result = await useFrameworkHandler.execute({
|
|
897
|
-
...ctx,
|
|
898
|
-
args: [...frameworks, ...providerArgs],
|
|
899
|
-
});
|
|
900
|
-
return result;
|
|
901
|
-
}
|
|
902
|
-
// Read registry to determine installed frameworks
|
|
903
|
-
const registry = readFrameworkRegistry(ctx.cwd);
|
|
904
|
-
if (!registry || registry.frameworks.length === 0) {
|
|
905
|
-
console.log('No frameworks found in .aiwg/frameworks/registry.json');
|
|
906
|
-
console.log('');
|
|
907
|
-
console.log('To deploy a framework first, run:');
|
|
908
|
-
console.log(' aiwg use sdlc');
|
|
909
|
-
console.log(' aiwg use marketing');
|
|
910
|
-
console.log(' aiwg use all');
|
|
911
|
-
return { exitCode: 0 };
|
|
912
|
-
}
|
|
913
|
-
// Canonical framework IDs need their historical public aliases. Add-ons,
|
|
914
|
-
// extensions, and project-local bundles are already accepted by `aiwg use`,
|
|
915
|
-
// so preserve their registry IDs instead of silently skipping them.
|
|
916
|
-
const installedFrameworks = registry.frameworks.map(item => REGISTRY_ID_TO_USE_NAME[item.id] ?? item.id);
|
|
917
|
-
// Report what will be updated
|
|
918
|
-
console.log(`Installed frameworks: ${installedFrameworks.join(', ')}`);
|
|
919
|
-
console.log('');
|
|
920
|
-
if (dryRun) {
|
|
921
|
-
console.log('Dry run: Would re-deploy the following frameworks:');
|
|
922
|
-
for (const fw of installedFrameworks) {
|
|
923
|
-
console.log(` - ${fw}`);
|
|
924
|
-
}
|
|
925
|
-
return { exitCode: 0 };
|
|
926
|
-
}
|
|
927
|
-
// Step 3: Re-deploy each installed framework
|
|
928
|
-
const results = [];
|
|
929
|
-
for (const fw of installedFrameworks) {
|
|
930
|
-
console.log(`Re-deploying ${fw}...`);
|
|
931
|
-
const result = await useFrameworkHandler.execute({
|
|
932
|
-
...ctx,
|
|
933
|
-
args: [fw, ...providerArgs],
|
|
934
|
-
});
|
|
935
|
-
results.push({ framework: fw, exitCode: result.exitCode });
|
|
936
|
-
if (result.exitCode !== 0) {
|
|
937
|
-
console.error(`Warning: Failed to re-deploy ${fw}`);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
// Step 4: Report summary
|
|
941
|
-
console.log('');
|
|
942
|
-
console.log('Update Summary:');
|
|
943
|
-
const succeeded = results.filter(r => r.exitCode === 0);
|
|
944
|
-
const failed = results.filter(r => r.exitCode !== 0);
|
|
945
|
-
for (const r of results) {
|
|
946
|
-
const status = r.exitCode === 0 ? 'updated' : 'FAILED';
|
|
947
|
-
console.log(` ${r.framework}: ${status}`);
|
|
948
|
-
}
|
|
949
|
-
console.log('');
|
|
950
|
-
console.log(`Updated: ${succeeded.length}/${results.length}`);
|
|
951
|
-
return {
|
|
952
|
-
exitCode: failed.length > 0 ? 1 : 0,
|
|
953
|
-
message: failed.length > 0
|
|
954
|
-
? `Some frameworks failed to update: ${failed.map(f => f.framework).join(', ')}`
|
|
955
|
-
: `Successfully updated ${succeeded.length} framework(s)`,
|
|
956
|
-
};
|
|
957
|
-
},
|
|
958
|
-
};
|
|
959
402
|
/**
|
|
960
403
|
* All utility handlers
|
|
961
404
|
*/
|