@aiwg/cli 2026.10.14 → 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/addons/aiwg-utils/rules/anti-laziness.core.md +13 -0
- package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +118 -0
- 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 +37 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +27 -25
- package/dist/src/artifacts/corpus-tools/expand-cli.js +90 -0
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +41 -0
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +56 -0
- package/dist/src/artifacts/corpus-tools/expand.js +124 -0
- 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 +99 -0
- package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +119 -0
- 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 +45 -0
- package/dist/src/cli/handlers/doctor-help.js +8 -3
- 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 -586
- 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-context.js +33 -4
- 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 +9 -2
- 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/features/catalog.js +1 -1
- package/dist/src/gates/evaluate.js +2 -2
- package/dist/src/gates/heldout.js +52 -0
- package/dist/src/gates/index.js +2 -1
- 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-installation-store.mjs +228 -0
- package/dist/src/models/worker-installation.mjs +7 -162
- 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 +14 -34
- package/dist/src/research/clients/base.js +53 -26
- package/dist/src/research/clients/crossref.js +9 -1
- package/dist/src/research/clients/semantic-scholar.js +73 -44
- package/dist/src/research/identity.js +117 -0
- package/dist/src/research/index.js +1 -0
- 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 +135 -0
- 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/core-startup.d.mts +2 -0
- package/dist/src/rules/core-startup.mjs +31 -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/agents-md.js +34 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +19 -46
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
- 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 +49 -114
- package/dist/src/smiths/context-pipeline/managed-hook.js +11 -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 +13 -2
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +12 -123
- package/tools/agents/providers/antigravity.mjs +1 -1
- package/tools/agents/providers/claude-post-deploy.mjs +12 -1
- package/tools/agents/providers/context-write.mjs +16 -0
- package/tools/agents/providers/grok-build.mjs +8 -5
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
- package/tools/agents/providers/hermes-startup.mjs +209 -0
- package/tools/agents/providers/hermes.mjs +9 -359
- package/tools/agents/providers/model-wrapper.mjs +5 -1
- package/tools/agents/providers/muse.mjs +3 -3
- package/tools/agents/providers/pi.mjs +4 -2
- package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1346
- 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/agents/providers/rule-presentation.mjs +13 -4
- package/tools/agents/providers/rule-projection.mjs +119 -0
- package/tools/agents/providers/rule-startup.mjs +70 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
- package/tools/agents/providers/warp.mjs +2 -2
- package/tools/agents/providers/windsurf.mjs +11 -57
- 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/plugin/plugin-links.mjs +3 -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
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Stage, apply and roll back transactional workspace adoption.
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { readAiwgConfig } from '../../config/aiwg-config.js';
|
|
5
|
+
import { projectAiwgPath, projectControlPath } from '../../config/project-artifacts.js';
|
|
6
|
+
import { getProviderDefinition } from '../../providers/provider-definitions.js';
|
|
7
|
+
import { buildAiwgMdContent } from './aiwg-md.js';
|
|
8
|
+
import { writeContextFileSync } from './context-file-safety.js';
|
|
9
|
+
import { readAiwgOperatorNotes } from './finalization.js';
|
|
10
|
+
import { auditWorkspaceContext } from './workspace-audit.js';
|
|
11
|
+
import { buildProviderBootstrapFile } from './workspace-bootstrap.js';
|
|
12
|
+
import { atomicWrite, PROJECT_CONTEXT_PLACEHOLDER, PROVIDER_BOOTSTRAP_END, PROVIDER_BOOTSTRAP_START, readOptional, resolveProjectRelative, sha256, WORKSPACE_SIGNATURE, } from './workspace-context-shared.js';
|
|
13
|
+
import { buildWorkspaceDocument, residentMemoryForRegeneration } from './workspace-document.js';
|
|
14
|
+
import { extractExistingProjectContext, mergeProjectExtraction } from './workspace-extraction.js';
|
|
15
|
+
export function projectOutputPath(projectPath, absPath) {
|
|
16
|
+
return path.relative(projectPath, absPath).replace(/\\/g, '/');
|
|
17
|
+
}
|
|
18
|
+
export const LEGACY_PROJECT_CONTEXT_PLACEHOLDER = [
|
|
19
|
+
'## Project Context',
|
|
20
|
+
'',
|
|
21
|
+
'Add provider-neutral project conventions and links here.',
|
|
22
|
+
].join('\n');
|
|
23
|
+
/**
|
|
24
|
+
* Operator content for the WORKSPACE.md operator block after migration.
|
|
25
|
+
*
|
|
26
|
+
* Existing WORKSPACE.md operator content is kept verbatim; the operator body
|
|
27
|
+
* of each provider startup file is appended once, verbatim, under an
|
|
28
|
+
* attributed heading. Tables, procedures, and code blocks survive intact —
|
|
29
|
+
* the earlier line-flattened directive list lost exactly the runbook content
|
|
30
|
+
* operators keep in CLAUDE.md (#2558). Re-running the migration is a no-op:
|
|
31
|
+
* a body that already appears in the block is not appended again.
|
|
32
|
+
*/
|
|
33
|
+
export function neutralMigrationContent(audit) {
|
|
34
|
+
const workspace = audit.sources.find((source) => source.path === 'WORKSPACE.md');
|
|
35
|
+
let base = workspace?.operatorContent.trim() ?? '';
|
|
36
|
+
if (base === PROJECT_CONTEXT_PLACEHOLDER || base === LEGACY_PROJECT_CONTEXT_PLACEHOLDER)
|
|
37
|
+
base = '';
|
|
38
|
+
const sections = [];
|
|
39
|
+
let accumulated = base;
|
|
40
|
+
for (const source of audit.sources) {
|
|
41
|
+
if (source.path === 'WORKSPACE.md' || !audit.plan.neutralSources.includes(source.path))
|
|
42
|
+
continue;
|
|
43
|
+
const body = source.operatorContent.trim();
|
|
44
|
+
if (!body || accumulated.includes(body))
|
|
45
|
+
continue;
|
|
46
|
+
sections.push([
|
|
47
|
+
`### Migrated from ${source.path}`,
|
|
48
|
+
'',
|
|
49
|
+
`Source attribution: migrated from \`${source.path}\`; checksum \`${source.checksum}\`.`,
|
|
50
|
+
'',
|
|
51
|
+
body,
|
|
52
|
+
].join('\n'));
|
|
53
|
+
accumulated = `${accumulated}\n${body}`;
|
|
54
|
+
}
|
|
55
|
+
const parts = [base || '## Project Context', ...sections];
|
|
56
|
+
if (!base && sections.length === 0) {
|
|
57
|
+
parts.push('Add project conventions, local hook/context pointers, and links to deeper project documents here.');
|
|
58
|
+
}
|
|
59
|
+
return parts.join('\n\n').trim();
|
|
60
|
+
}
|
|
61
|
+
export async function configuredProviders(projectPath) {
|
|
62
|
+
try {
|
|
63
|
+
const config = await readAiwgConfig(projectPath);
|
|
64
|
+
if (config)
|
|
65
|
+
return config.providers.filter((provider) => typeof provider === 'string');
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Audit/migration reports malformed provider config through the normal CLI path.
|
|
69
|
+
}
|
|
70
|
+
return ['claude'];
|
|
71
|
+
}
|
|
72
|
+
export async function stageMigrationWrites(projectPath, audit, options = {}) {
|
|
73
|
+
const writes = new Map();
|
|
74
|
+
const providerFiles = [...new Set(audit.sources.filter((source) => source.path.replace(/\\/g, '/').includes('/context/providers/')).map((source) => source.path))].sort();
|
|
75
|
+
let workspaceOperatorContent = neutralMigrationContent(audit);
|
|
76
|
+
if (options.extractProject) {
|
|
77
|
+
const extracted = await extractExistingProjectContext(projectPath);
|
|
78
|
+
workspaceOperatorContent = mergeProjectExtraction(workspaceOperatorContent, extracted.content);
|
|
79
|
+
}
|
|
80
|
+
writes.set('WORKSPACE.md', buildWorkspaceDocument(projectPath, workspaceOperatorContent, providerFiles, await residentMemoryForRegeneration(projectPath)));
|
|
81
|
+
const providers = await configuredProviders(projectPath);
|
|
82
|
+
const targetProviders = new Map();
|
|
83
|
+
for (const provider of providers) {
|
|
84
|
+
const definition = getProviderDefinition(provider);
|
|
85
|
+
if (!definition)
|
|
86
|
+
continue;
|
|
87
|
+
for (const target of definition.context.bootstrapTargets) {
|
|
88
|
+
const values = targetProviders.get(target) ?? [];
|
|
89
|
+
values.push(provider);
|
|
90
|
+
targetProviders.set(target, values);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const [target, targetProviderIds] of targetProviders) {
|
|
94
|
+
// Shared AGENTS.md is deliberately provider-neutral prose so sequential
|
|
95
|
+
// multi-provider deployment cannot make the last provider win.
|
|
96
|
+
const provider = targetProviderIds.length === 1 ? targetProviderIds[0] : 'generic';
|
|
97
|
+
const content = provider === 'generic'
|
|
98
|
+
? [
|
|
99
|
+
'# Provider workspace bootstrap', WORKSPACE_SIGNATURE,
|
|
100
|
+
'<!-- Generated by AIWG. Project/operator context belongs in WORKSPACE.md. -->', '',
|
|
101
|
+
PROVIDER_BOOTSTRAP_START, '',
|
|
102
|
+
'Read and follow [WORKSPACE.md](./WORKSPACE.md) first.',
|
|
103
|
+
'Then read [AIWG.md](./AIWG.md) for AIWG discovery and framework routing.',
|
|
104
|
+
'These are explicit reading instructions; a plain Markdown link is not claimed to auto-load.', '',
|
|
105
|
+
PROVIDER_BOOTSTRAP_END, '',
|
|
106
|
+
].join('\n')
|
|
107
|
+
: buildProviderBootstrapFile(provider);
|
|
108
|
+
writes.set(target, content);
|
|
109
|
+
}
|
|
110
|
+
// Any detected operator-owned root startup file participates in the explicit
|
|
111
|
+
// adoption even when that provider is not currently enabled. Its authored
|
|
112
|
+
// content is already staged in an attributed provider file above; replacing
|
|
113
|
+
// the active root with a bootstrap completes the move and prevents two
|
|
114
|
+
// divergent sources of truth.
|
|
115
|
+
for (const source of audit.sources.filter((item) => audit.plan.providerSources.includes(item.path))) {
|
|
116
|
+
if (source.scope === 'root' && source.provider && source.path !== 'AIWG.md' && !targetProviders.has(source.path)) {
|
|
117
|
+
writes.set(source.path, buildProviderBootstrapFile(source.provider));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const activeCodexOverride = audit.sources.find((source) => source.path === 'AGENTS.override.md' && source.operatorContent.trim());
|
|
121
|
+
if (providers.includes('codex') && activeCodexOverride) {
|
|
122
|
+
writes.set('AGENTS.override.md', buildProviderBootstrapFile('codex'));
|
|
123
|
+
}
|
|
124
|
+
for (const provider of providers) {
|
|
125
|
+
const contract = getProviderDefinition(provider)?.context;
|
|
126
|
+
if (!contract?.configRegistration)
|
|
127
|
+
continue;
|
|
128
|
+
const configPath = contract.configRegistration.file;
|
|
129
|
+
const existing = await readOptional(path.join(projectPath, configPath));
|
|
130
|
+
let config = {};
|
|
131
|
+
if (existing !== null)
|
|
132
|
+
config = JSON.parse(existing);
|
|
133
|
+
const key = contract.configRegistration.key;
|
|
134
|
+
const current = Array.isArray(config[key]) ? config[key].filter((item) => typeof item === 'string') : [];
|
|
135
|
+
config[key] = [...new Set([...current, 'WORKSPACE.md', 'AIWG.md'])];
|
|
136
|
+
if (!('$schema' in config) && path.basename(configPath) === 'opencode.json')
|
|
137
|
+
config = { $schema: 'https://opencode.ai/config.json', ...config };
|
|
138
|
+
writes.set(configPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
139
|
+
}
|
|
140
|
+
if (options.includeGeneratedContext) {
|
|
141
|
+
const normalizedPath = projectOutputPath(projectPath, projectControlPath(projectPath, 'AIWG.md'));
|
|
142
|
+
const { existing, notes } = await readAiwgOperatorNotes(projectPath);
|
|
143
|
+
if (existing !== null && existing !== notes)
|
|
144
|
+
writes.set(normalizedPath, notes);
|
|
145
|
+
const stagedClaude = writes.has('CLAUDE.md')
|
|
146
|
+
? writes.get('CLAUDE.md')
|
|
147
|
+
: await readOptional(path.join(projectPath, 'CLAUDE.md'));
|
|
148
|
+
writes.set('AIWG.md', await buildAiwgMdContent(projectPath, stagedClaude));
|
|
149
|
+
}
|
|
150
|
+
return writes;
|
|
151
|
+
}
|
|
152
|
+
export function safePreimageName(relativePath) {
|
|
153
|
+
return `${sha256(relativePath).slice(0, 16)}-${path.basename(relativePath)}`;
|
|
154
|
+
}
|
|
155
|
+
export async function migrateWorkspaceContext(projectPath, options = {}) {
|
|
156
|
+
const audit = await auditWorkspaceContext(projectPath);
|
|
157
|
+
const sensitiveFindingCount = audit.sensitiveFindings.length;
|
|
158
|
+
if (sensitiveFindingCount > 0) {
|
|
159
|
+
throw new Error(`Migration refused: ${sensitiveFindingCount} possible secret/credential value(s) found. Remove them before migration.`);
|
|
160
|
+
}
|
|
161
|
+
if (audit.conflicts.length > 0 && !options.allowConflicts) {
|
|
162
|
+
throw new Error(`Migration refused: ${audit.conflicts.length} ambiguous directive conflict(s). Review the deterministic audit or pass --allow-conflicts to preserve each source separately.`);
|
|
163
|
+
}
|
|
164
|
+
const writes = await stageMigrationWrites(projectPath, audit, {
|
|
165
|
+
extractProject: options.extractProject,
|
|
166
|
+
includeGeneratedContext: options.includeGeneratedContext,
|
|
167
|
+
});
|
|
168
|
+
const changedEntries = [];
|
|
169
|
+
for (const [relativePath, content] of writes) {
|
|
170
|
+
if (await readOptional(path.join(projectPath, relativePath)) !== content)
|
|
171
|
+
changedEntries.push([relativePath, content]);
|
|
172
|
+
}
|
|
173
|
+
if (options.dryRun || !options.apply) {
|
|
174
|
+
return { audit, dryRun: true, changed: changedEntries.length > 0, written: changedEntries.map(([relative]) => relative), backups: [] };
|
|
175
|
+
}
|
|
176
|
+
if (changedEntries.length === 0)
|
|
177
|
+
return { audit, dryRun: false, changed: false, written: [], backups: [] };
|
|
178
|
+
const createdAt = new Date().toISOString();
|
|
179
|
+
const id = `${createdAt.replace(/[:.]/g, '-')}-${sha256(JSON.stringify(audit.plan)).slice(0, 8)}`;
|
|
180
|
+
const transactionDir = projectAiwgPath(projectPath, 'context-migrations', id);
|
|
181
|
+
const preimageDir = path.join(transactionDir, 'preimages');
|
|
182
|
+
await fs.mkdir(preimageDir, { recursive: true });
|
|
183
|
+
const manifest = { version: 1, id, createdAt, projectPath, status: 'prepared', files: [] };
|
|
184
|
+
const backups = [];
|
|
185
|
+
for (const [relativePath, content] of changedEntries) {
|
|
186
|
+
const target = path.join(projectPath, relativePath);
|
|
187
|
+
const existing = await readOptional(target);
|
|
188
|
+
let preimage = null;
|
|
189
|
+
if (existing !== null) {
|
|
190
|
+
preimage = path.relative(projectPath, path.join(preimageDir, safePreimageName(relativePath))).replace(/\\/g, '/');
|
|
191
|
+
writeContextFileSync(path.join(projectPath, preimage), existing, 'utf8');
|
|
192
|
+
backups.push(preimage);
|
|
193
|
+
}
|
|
194
|
+
manifest.files.push({ path: relativePath, existed: existing !== null, preimage, outputChecksum: sha256(content) });
|
|
195
|
+
}
|
|
196
|
+
const manifestPath = path.join(transactionDir, 'manifest.json');
|
|
197
|
+
await atomicWrite(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
198
|
+
try {
|
|
199
|
+
for (const [relativePath, content] of changedEntries.sort(([left], [right]) => left.localeCompare(right))) {
|
|
200
|
+
await atomicWrite(path.join(projectPath, relativePath), content);
|
|
201
|
+
}
|
|
202
|
+
manifest.status = 'applied';
|
|
203
|
+
await atomicWrite(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
await restoreMigrationManifest(projectPath, manifest);
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
return { audit, dryRun: false, changed: true, transactionId: id, written: changedEntries.map(([relative]) => relative).sort(), backups };
|
|
210
|
+
}
|
|
211
|
+
export async function restoreMigrationManifest(projectPath, manifest) {
|
|
212
|
+
for (const file of [...manifest.files].reverse()) {
|
|
213
|
+
const target = resolveProjectRelative(projectPath, file.path);
|
|
214
|
+
if (file.existed && file.preimage) {
|
|
215
|
+
const preimage = await fs.readFile(resolveProjectRelative(projectPath, file.preimage), 'utf8');
|
|
216
|
+
await atomicWrite(target, preimage);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
await fs.rm(target, { force: true });
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export async function rollbackWorkspaceContext(projectPath, requestedId) {
|
|
224
|
+
const root = projectAiwgPath(projectPath, 'context-migrations');
|
|
225
|
+
let ids;
|
|
226
|
+
try {
|
|
227
|
+
ids = (await fs.readdir(root)).sort().reverse();
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
throw new Error('No workspace-context migration transactions found.');
|
|
231
|
+
}
|
|
232
|
+
const id = requestedId ?? ids[0];
|
|
233
|
+
if (!id || id.includes('/') || id.includes('\\'))
|
|
234
|
+
throw new Error('Invalid workspace-context migration id.');
|
|
235
|
+
const manifestPath = path.join(root, id, 'manifest.json');
|
|
236
|
+
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
|
|
237
|
+
if (manifest.status === 'rolled-back')
|
|
238
|
+
return { id, restored: [] };
|
|
239
|
+
for (const file of manifest.files) {
|
|
240
|
+
const current = await readOptional(resolveProjectRelative(projectPath, file.path));
|
|
241
|
+
if (current === null || sha256(current) !== file.outputChecksum) {
|
|
242
|
+
throw new Error(`Rollback refused: ${file.path} changed after migration. Preserve or reconcile that work before restoring transaction ${id}.`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
await restoreMigrationManifest(projectPath, manifest);
|
|
246
|
+
manifest.status = 'rolled-back';
|
|
247
|
+
await atomicWrite(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
248
|
+
return { id, restored: manifest.files.map((file) => file.path) };
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=workspace-migration.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwg/cli",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.16",
|
|
4
4
|
"description": "Lightweight AIWG CLI for signed, versioned web-backed resources.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"THIRD_PARTY_NOTICES.md",
|
|
28
28
|
"bin/",
|
|
29
29
|
"agentic/code/providers/",
|
|
30
|
+
"agentic/code/addons/aiwg-utils/rules/anti-laziness.md",
|
|
31
|
+
"agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md",
|
|
30
32
|
"agentic/code/addons/composition-engine/lib/runtime.mjs",
|
|
31
33
|
"agentic/code/addons/composition-engine/lib/validator.mjs",
|
|
32
34
|
"agentic/code/addons/composition-engine/schemas/flow-graph.schema.json",
|
|
@@ -44,6 +46,13 @@
|
|
|
44
46
|
"dist/src/resources/web-release.d.ts",
|
|
45
47
|
"dist/src/dataset/**/*.d.ts",
|
|
46
48
|
"tools/_resolve-impl.mjs",
|
|
49
|
+
"tools/providers/pi-bridge-policy.mjs",
|
|
50
|
+
"tools/daemon/",
|
|
51
|
+
"tools/docker/container-manager.mjs",
|
|
52
|
+
"tools/docker/Dockerfile.daemon",
|
|
53
|
+
"tools/messaging/",
|
|
54
|
+
"tools/ralph-external/daemon-supervisor.mjs",
|
|
55
|
+
"tools/ralph-external/lib/behavior-registry.mjs",
|
|
47
56
|
"tools/warp/warp-content.mjs",
|
|
48
57
|
"tools/cli/decision-offload-report.mjs",
|
|
49
58
|
"tools/cli/workspace-status.mjs",
|
|
@@ -54,6 +63,8 @@
|
|
|
54
63
|
"tools/ralph-external/lib/worker-final.mjs",
|
|
55
64
|
"tools/ralph-external/lib/worker-launch-cli.mjs",
|
|
56
65
|
"tools/ralph-external/lib/worker-isolation.mjs",
|
|
66
|
+
"tools/ralph-external/lib/worker-isolation-args.mjs",
|
|
67
|
+
"tools/ralph-external/lib/worker-unit-cleanup.mjs",
|
|
57
68
|
"tools/ralph-external/lib/worker-native-sandbox.mjs",
|
|
58
69
|
"tools/ralph-external/lib/worker-isolation-status.mjs",
|
|
59
70
|
"tools/ralph-external/lib/worker-retry-evidence.mjs",
|
|
@@ -137,7 +148,7 @@
|
|
|
137
148
|
"zod": "^4.6.6"
|
|
138
149
|
},
|
|
139
150
|
"optionalDependencies": {
|
|
140
|
-
"@hono/node-server": "2.
|
|
151
|
+
"@hono/node-server": "2.1.5",
|
|
141
152
|
"@sigstore/bundle": "4.0.0",
|
|
142
153
|
"@sigstore/protobuf-specs": "0.5.0",
|
|
143
154
|
"@sigstore/verify": "3.1.1",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://aiwg.io/schemas/decision/D29Study.v10.schema.json",
|
|
4
|
+
"title": "D29 signed first-access record",
|
|
5
|
+
"description": "Signed v2 first-access variant; unsigned v1 remains historical and cannot authorize evaluation.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"schemaVersion",
|
|
10
|
+
"runId",
|
|
11
|
+
"analysisDigest",
|
|
12
|
+
"frozenBundleDigest",
|
|
13
|
+
"anchoredAt",
|
|
14
|
+
"firstTestAccessAt",
|
|
15
|
+
"reference",
|
|
16
|
+
"signature"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"schemaVersion": {
|
|
20
|
+
"const": "decision-d29-access/v2"
|
|
21
|
+
},
|
|
22
|
+
"runId": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"minLength": 1
|
|
25
|
+
},
|
|
26
|
+
"analysisDigest": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^sha256:[a-f0-9]{64}$"
|
|
29
|
+
},
|
|
30
|
+
"frozenBundleDigest": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"pattern": "^sha256:[a-f0-9]{64}$"
|
|
33
|
+
},
|
|
34
|
+
"anchoredAt": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"format": "date-time"
|
|
37
|
+
},
|
|
38
|
+
"firstTestAccessAt": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"format": "date-time"
|
|
41
|
+
},
|
|
42
|
+
"reference": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"minLength": 1
|
|
45
|
+
},
|
|
46
|
+
"signature": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"additionalProperties": false,
|
|
49
|
+
"required": [
|
|
50
|
+
"keyid",
|
|
51
|
+
"sig"
|
|
52
|
+
],
|
|
53
|
+
"properties": {
|
|
54
|
+
"keyid": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"pattern": "^sha256:[a-f0-9]{64}$"
|
|
57
|
+
},
|
|
58
|
+
"sig": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"minLength": 1
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -85,8 +85,6 @@ import {
|
|
|
85
85
|
addManagedMarker,
|
|
86
86
|
collectBehaviorDirs,
|
|
87
87
|
collectFrameworkArtifacts,
|
|
88
|
-
computeAllArtifactBasenames,
|
|
89
|
-
computeAllSkillNames,
|
|
90
88
|
contentHash,
|
|
91
89
|
deployEmulatedBehaviors,
|
|
92
90
|
getAddonSkillDirs,
|
|
@@ -95,7 +93,6 @@ import {
|
|
|
95
93
|
loadRuntimeModelCatalog,
|
|
96
94
|
migrateCommandsDirectory,
|
|
97
95
|
parseFrontmatter,
|
|
98
|
-
pruneStaleAiwgFiles,
|
|
99
96
|
resolveAiwgRoot,
|
|
100
97
|
updateSidecarManifest,
|
|
101
98
|
} from './providers/base.mjs';
|
|
@@ -345,126 +342,8 @@ function mirrorSkillsAsCommands(provider, target, srcRoot, opts) {
|
|
|
345
342
|
}
|
|
346
343
|
|
|
347
344
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
// ============================================================================
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* After a deploy, prune AIWG-managed flat artifacts (agents/commands/rules)
|
|
354
|
-
* whose source no longer ships them — mirroring the skills holistic prune.
|
|
355
|
-
*
|
|
356
|
-
* Safety boundaries:
|
|
357
|
-
* - Runs ONLY for AIWG framework/addon deploys (default source = AIWG root,
|
|
358
|
-
* or `--source` under `<aiwgRoot>/agentic/code`). Project-local bundle
|
|
359
|
-
* deploys (`--source <bundle>`) are skipped so a bundle's just-deployed
|
|
360
|
-
* artifacts are never mistaken for stale framework files.
|
|
361
|
-
* - `pruneStaleAiwgFiles` itself only removes files carrying an AIWG
|
|
362
|
-
* ownership signal (sidecar entry or `aiwg:managed` marker) AND whose
|
|
363
|
-
* stem is absent from the global, mode-independent source set, so
|
|
364
|
-
* user-authored files and sibling-framework artifacts always survive.
|
|
365
|
-
* - Aggregate-file paths (e.g. `AGENTS.md`) and unset paths are skipped.
|
|
366
|
-
*
|
|
367
|
-
* @param {object} provider loaded provider module
|
|
368
|
-
* @param {string} target deploy target dir
|
|
369
|
-
* @param {string} srcRoot effective deploy source
|
|
370
|
-
* @param {object} opts deploy opts (dryRun/verbose/quiet + deploy flags)
|
|
371
|
-
* @param {string|null} explicitSource the raw `--source` value (null when unset)
|
|
372
|
-
*/
|
|
373
|
-
/** Bundles whose deploy is itself the kernel-only bulk install. */
|
|
374
|
-
const BULK_INSTALL_BUNDLES = new Set(['all']);
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* True when the kernel-only bulk install is the only thing this project has
|
|
378
|
-
* deployed, so clearing leftover flat artifacts is a migration and not a
|
|
379
|
-
* deletion of another bundle's surface (#2508).
|
|
380
|
-
*
|
|
381
|
-
* A project with no readable `.aiwg/aiwg.config` has no recorded owner, so the
|
|
382
|
-
* pre-#152 migration cleanup still applies.
|
|
383
|
-
*/
|
|
384
|
-
export function bulkInstallOwnsFlatArtifacts(target) {
|
|
385
|
-
let installed;
|
|
386
|
-
try {
|
|
387
|
-
const raw = realFs.readFileSync(path.join(target, '.aiwg', 'aiwg.config'), 'utf8');
|
|
388
|
-
installed = JSON.parse(raw)?.installed;
|
|
389
|
-
} catch {
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
if (!installed || typeof installed !== 'object') return true;
|
|
393
|
-
return !Object.keys(installed).some(name => !BULK_INSTALL_BUNDLES.has(name));
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explicitSource) {
|
|
397
|
-
if (opts.skillsOnly && !opts.kernelOnly) return; // skills run their own prune in the provider
|
|
398
|
-
|
|
399
|
-
const aiwgRoot = resolveAiwgRoot(srcRoot);
|
|
400
|
-
if (!aiwgRoot) return; // no AIWG tree → bundle/standalone deploy; never prune
|
|
401
|
-
|
|
402
|
-
// Gate: only framework/addon deploys are eligible. A default deploy (no
|
|
403
|
-
// --source) sources from the AIWG root. An explicit --source is eligible
|
|
404
|
-
// only when it lives under <aiwgRoot>/agentic/code (bundled fw/addon).
|
|
405
|
-
if (explicitSource) {
|
|
406
|
-
const codeRoot = path.join(aiwgRoot, 'agentic', 'code');
|
|
407
|
-
const rel = path.relative(codeRoot, path.resolve(explicitSource));
|
|
408
|
-
const underCode = !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
409
|
-
if (!underCode) return; // project-local bundle / external source → skip
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (opts.kernelOnly) {
|
|
413
|
-
// Kernel-only delivers skills and rules. The empty desired set below
|
|
414
|
-
// applies only to bulk agents/commands left by
|
|
415
|
-
// the pre-#152 bulk default, when the bulk install is the only thing this
|
|
416
|
-
// project ever deployed.
|
|
417
|
-
//
|
|
418
|
-
// #2508: applying it unconditionally deleted every artifact a sibling
|
|
419
|
-
// bundle owned — `aiwg use sdlc` followed by `aiwg use all` took
|
|
420
|
-
// .claude/agents from 139 to 0. When another bundle is installed, it owns
|
|
421
|
-
// this surface deliberately and the migration assumption does not hold.
|
|
422
|
-
if (!bulkInstallOwnsFlatArtifacts(target)) {
|
|
423
|
-
if (opts.verbose) {
|
|
424
|
-
console.log('skip kernel-only flat prune: another installed bundle owns agents/commands/rules');
|
|
425
|
-
}
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
for (const type of ['agents', 'commands']) {
|
|
429
|
-
const relPath = provider.paths?.[type];
|
|
430
|
-
if (!relPath || relPath.endsWith('.md')) continue;
|
|
431
|
-
const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
|
|
432
|
-
pruneStaleAiwgFiles(destDir, new Set(), {
|
|
433
|
-
dryRun: opts.dryRun,
|
|
434
|
-
verbose: opts.verbose,
|
|
435
|
-
artifactExtensions: ['.md', '.mdc', '.toml'],
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
const typesThisRun = [];
|
|
442
|
-
if (!opts.commandsOnly && !opts.rulesOnly) typesThisRun.push('agents');
|
|
443
|
-
if (opts.deployCommands || opts.commandsOnly) typesThisRun.push('commands');
|
|
444
|
-
if (opts.deployRules || opts.rulesOnly) typesThisRun.push('rules');
|
|
445
|
-
|
|
446
|
-
for (const type of typesThisRun) {
|
|
447
|
-
const relPath = provider.paths?.[type];
|
|
448
|
-
if (!relPath) continue; // type not file-deployed by provider
|
|
449
|
-
if (relPath.endsWith('.md')) continue; // aggregate file (e.g. AGENTS.md)
|
|
450
|
-
|
|
451
|
-
const desired = computeAllArtifactBasenames(srcRoot, type);
|
|
452
|
-
if (!desired) continue; // no global desired set → skip
|
|
453
|
-
|
|
454
|
-
const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
|
|
455
|
-
const removed = pruneStaleAiwgFiles(destDir, desired, {
|
|
456
|
-
dryRun: opts.dryRun,
|
|
457
|
-
verbose: opts.verbose,
|
|
458
|
-
// Retire wrappers whose source skill no longer ships (#2511). Only the
|
|
459
|
-
// command directory holds them; the kernel-only branch returns earlier,
|
|
460
|
-
// so a bulk install still cannot touch wrappers it did not write.
|
|
461
|
-
skillCommandStems: type === 'commands' ? computeAllSkillNames(srcRoot) : null,
|
|
462
|
-
});
|
|
463
|
-
if (removed.length > 0 && !opts.quiet) {
|
|
464
|
-
console.log(` Pruned: ${removed.length} stale AIWG ${type} file${removed.length === 1 ? '' : 's'}`);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
345
|
+
export { bulkInstallOwnsFlatArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
346
|
+
import { pruneStaleAiwgArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
468
347
|
|
|
469
348
|
// ============================================================================
|
|
470
349
|
// Argument Parsing
|
|
@@ -578,6 +457,7 @@ export function parseArgs(args = process.argv.slice(2)) {
|
|
|
578
457
|
// managed-hooks opt-out (default on, mirroring the Claude autoInstall policy).
|
|
579
458
|
else if (a === '--mcp') cfg.mcp = true;
|
|
580
459
|
else if (a === '--no-hooks') cfg.hooks = false;
|
|
460
|
+
else if (a === '--no-attribution') cfg.attribution = false;
|
|
581
461
|
else if (a === '--no-context-files') cfg.contextFiles = false;
|
|
582
462
|
else if (a === '--deploy-source' && args[i + 1]) cfg.deploySource = String(args[++i]);
|
|
583
463
|
else if (a === '--listing-budget') cfg.listingBudget = true;
|
|
@@ -627,6 +507,7 @@ Options:
|
|
|
627
507
|
mcp_servers; default off)
|
|
628
508
|
--no-hooks Muse provider: skip managed project hooks
|
|
629
509
|
(.muse/hooks.json; installed by default)
|
|
510
|
+
--no-attribution Claude provider: leave attribution settings untouched
|
|
630
511
|
--as-agents-md Aggregate to single AGENTS.md (Codex)
|
|
631
512
|
--create-agents-md Create/update AGENTS.md template
|
|
632
513
|
--no-context-files Preserve WORKSPACE.md, AIWG.md and AGENTS.md (including managed blocks)
|
|
@@ -1083,6 +964,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
1083
964
|
// #228: Muse provider hooks/MCP profile surface.
|
|
1084
965
|
mcp: cfg.mcp === true,
|
|
1085
966
|
hooks: cfg.hooks !== false,
|
|
967
|
+
attribution: cfg.attribution !== false,
|
|
1086
968
|
listingBudget: cfg.listingBudget === true,
|
|
1087
969
|
deployVersion: resolveDeployVersion(resolveAiwgRoot(srcRoot) || srcRoot, cfg.deployVersion),
|
|
1088
970
|
deploySource: cfg.deploySource || 'bundled',
|
|
@@ -1135,6 +1017,13 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
1135
1017
|
}
|
|
1136
1018
|
if (preparationActive) return;
|
|
1137
1019
|
|
|
1020
|
+
// User settings are outside staging: write only after a real promotion.
|
|
1021
|
+
if (provider.name === 'claude' && cfg.userScope && !cfg.dryRun && cfg.attribution !== false) {
|
|
1022
|
+
const { installAiwgHooks } = await importImpl(import.meta.url, 'extensions/claude-hooks-installer.js');
|
|
1023
|
+
const result = await installAiwgHooks({ projectPath: os.homedir(), frameworkRoot: srcRoot, hooks: false });
|
|
1024
|
+
for (const warning of result?.warnings || []) console.warn(`Claude settings: ${warning}`);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1138
1027
|
const mirroredCommandCount = mirrorSkillsAsCommands(provider, cfg.target, srcRoot, opts);
|
|
1139
1028
|
if (mirroredCommandCount > 0 && !cfg.quiet) {
|
|
1140
1029
|
console.log(` Mirrored: ${mirroredCommandCount} skill command wrapper${mirroredCommandCount === 1 ? '' : 's'}`);
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from './base.mjs';
|
|
19
19
|
export const name = 'antigravity';
|
|
20
20
|
export const aliases = ['agy'];
|
|
21
|
-
export const paths = { agents: '.agents/agents', commands: '', skills: '.agents/skills', rules: '' };
|
|
21
|
+
export const paths = { agents: '.agents/agents', commands: '', skills: '.agents/skills', rules: '.antigravity/rules' };
|
|
22
22
|
export const kernelSkillsPath = '.agents/skills';
|
|
23
23
|
export const support = { agents: 'degraded', commands: 'indexed', skills: 'native', rules: 'context' };
|
|
24
24
|
export const capabilities = {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// Apply project settings and context after provider file deployment.
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
4
5
|
import { initializeFrameworkWorkspace, ensureDir } from './base.mjs';
|
|
5
6
|
import { deployHookFile } from './claude.mjs';
|
|
6
7
|
import { deployConductorDataGuard } from './conductor-data-guard.mjs';
|
|
7
8
|
|
|
8
9
|
export async function postDeploy(targetDir, opts) {
|
|
9
10
|
initializeFrameworkWorkspace(targetDir, opts.mode, opts.dryRun, opts.srcRoot);
|
|
10
|
-
|
|
11
|
+
// Validate the data policy before publishing any settings; merge before its writes.
|
|
12
|
+
await deployConductorDataGuard(targetDir, 'claude', { ...opts, dryRun: true });
|
|
11
13
|
|
|
12
14
|
// Claude-specific post-deployment (settings.json, etc.)
|
|
13
15
|
const claudeDir = path.join(targetDir, '.claude');
|
|
@@ -28,6 +30,15 @@ export async function postDeploy(targetDir, opts) {
|
|
|
28
30
|
console.log('Created .claude/settings.json');
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
// Reuse the settings owner's backup/atomic merge, independently of hooks.
|
|
34
|
+
if (opts.attribution !== false) {
|
|
35
|
+
const { installAiwgHooks } = await importImpl(import.meta.url, 'extensions/claude-hooks-installer.js');
|
|
36
|
+
const result = await installAiwgHooks({ projectPath: targetDir, frameworkRoot: opts.srcRoot || targetDir,
|
|
37
|
+
hooks: false, dryRun: opts.dryRun });
|
|
38
|
+
for (const warning of result?.warnings || []) console.warn(`Claude settings: ${warning}`);
|
|
39
|
+
}
|
|
40
|
+
await deployConductorDataGuard(targetDir, 'claude', opts);
|
|
41
|
+
|
|
31
42
|
// Hook file architecture: write AIWG.md and wire @AIWG.md into CLAUDE.md
|
|
32
43
|
if (opts.srcRoot && opts.contextFiles !== false) {
|
|
33
44
|
deployHookFile(targetDir, opts);
|
|
@@ -14,8 +14,10 @@ export const CONTEXT_STAGE_ENV = 'AIWG_CONTEXT_STAGE_LOG';
|
|
|
14
14
|
|
|
15
15
|
let loadError = null;
|
|
16
16
|
let writer = null;
|
|
17
|
+
let ownership = null;
|
|
17
18
|
try {
|
|
18
19
|
writer = await importImpl(import.meta.url, 'smiths/context-pipeline/context-file-safety.js');
|
|
20
|
+
ownership = await importImpl(import.meta.url, 'smiths/context-pipeline/bridge-ownership.js');
|
|
19
21
|
} catch (error) {
|
|
20
22
|
loadError = error;
|
|
21
23
|
}
|
|
@@ -26,3 +28,17 @@ export function writeContextFileSync(file, content, encoding) {
|
|
|
26
28
|
}
|
|
27
29
|
return writer.writeContextFileSync(file, content, encoding);
|
|
28
30
|
}
|
|
31
|
+
|
|
32
|
+
export function normalizeRuleStartup(content, bootstrap, agentsHeader) {
|
|
33
|
+
if (!ownership) throw new Error('Startup ownership layer is unavailable', { cause: loadError });
|
|
34
|
+
return ownership.normalizeRuleStartup(content, bootstrap, agentsHeader);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function retireLegacyBridge(content) {
|
|
38
|
+
if (!ownership) throw new Error('Startup ownership layer is unavailable', { cause: loadError });
|
|
39
|
+
return ownership.retireLegacyBridge(content);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Generated context outputs and the optional notes input share staging/rollback ownership.
|
|
43
|
+
export const GENERATED_CONTEXT_NAMES = ['AGENTS.md', 'AIWG.md', 'WORKSPACE.md', 'CLAUDE.md', 'WARP.md', '.hermes.md'];
|
|
44
|
+
export const OPERATOR_CONTEXT_NAMES = ['.aiwg/AIWG.md'];
|
|
@@ -6,7 +6,7 @@ import { withModelWrapper } from './model-wrapper.mjs';
|
|
|
6
6
|
*
|
|
7
7
|
* Native agent compilation is deliberately limited to the three AIWG model
|
|
8
8
|
* workers until the wider corpus has a qualified Grok tool mapping (#2577).
|
|
9
|
-
* Rules
|
|
9
|
+
* Rules are written to .grok/rules and loaded by Grok alongside AGENTS.md.
|
|
10
10
|
*
|
|
11
11
|
* @issue #2575
|
|
12
12
|
*/
|
|
@@ -36,7 +36,7 @@ export const aliases = [];
|
|
|
36
36
|
export const paths = {
|
|
37
37
|
agents: '.grok/agents',
|
|
38
38
|
skills: '.grok/skills',
|
|
39
|
-
rules: '',
|
|
39
|
+
rules: '.grok/rules',
|
|
40
40
|
hooks: '.grok/hooks',
|
|
41
41
|
config: '.grok/config.toml',
|
|
42
42
|
};
|
|
@@ -48,12 +48,15 @@ export const support = {
|
|
|
48
48
|
agents: 'native',
|
|
49
49
|
commands: 'indexed', // discoverable through the AIWG index; no native command writer
|
|
50
50
|
skills: 'native',
|
|
51
|
-
|
|
51
|
+
// CONTEXT_CONTRACTS: https://docs.x.ai/build/features/project-rules
|
|
52
|
+
// .grok/rules/*.md loads hierarchically on every task; no frontmatter marker
|
|
53
|
+
// is required for always-on rules (unlike Windsurf's trigger field).
|
|
54
|
+
rules: 'native', // always-on Markdown rules discovered root-to-cwd by Grok Build
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
export const capabilities = {
|
|
55
58
|
skills: true,
|
|
56
|
-
rules:
|
|
59
|
+
rules: true, // Native Markdown; path activation uses the index
|
|
57
60
|
yamlFormat: false,
|
|
58
61
|
aggregatedOutput: false,
|
|
59
62
|
homeDirectoryDeploy: true,
|
|
@@ -347,7 +350,7 @@ export async function postDeploy(target, opts = {}) {
|
|
|
347
350
|
console.log(
|
|
348
351
|
`Grok Build (experimental): kernel skills → ${kernelSkillsPath}; ` +
|
|
349
352
|
`standard skills index-driven (opt-in mirror → ${standardSkillsPath} with --copy-all); ` +
|
|
350
|
-
`model-worker agents → ${paths.agents}; rules
|
|
353
|
+
`model-worker agents → ${paths.agents}; rules → ${paths.rules}; user home → ${home || '(unresolved GROK_HOME)'}. ` +
|
|
351
354
|
'Distinct from grokbot.',
|
|
352
355
|
);
|
|
353
356
|
}
|