@aiwg/cli 2026.11.0 → 2026.11.2
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-hooks/canonical/aiwg-prompt-discovery.yaml +9 -0
- package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +136 -0
- package/agentic/code/providers/flue/README.md +2 -1
- package/agentic/code/providers/model-capabilities.v1.json +27 -23
- package/agentic/code/providers/model-catalog.v1.json +3 -3
- package/dist/src/artifacts/cli.js +13 -13
- package/dist/src/artifacts/discover-cli-help.js +25 -0
- package/dist/src/artifacts/discover-facets.js +2 -0
- package/dist/src/artifacts/discover-session-facets.js +15 -0
- package/dist/src/artifacts/fortemi-core-prebuilt-freshness.js +28 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
- package/dist/src/artifacts/fortemi-core-sync.js +3 -0
- package/dist/src/artifacts/framework-capabilities.js +11 -3
- package/dist/src/artifacts/framework-source-digest.js +1 -1
- package/dist/src/artifacts/index-builder.js +12 -13
- package/dist/src/artifacts/index-dependencies.js +72 -0
- package/dist/src/artifacts/query-engine-discover-output.js +13 -5
- package/dist/src/artifacts/query-engine-discover.js +103 -28
- package/dist/src/artifacts/query-engine-entries.js +107 -10
- package/dist/src/artifacts/query-engine-installation.js +27 -0
- package/dist/src/artifacts/query-engine-options.js +14 -1
- package/dist/src/artifacts/query-engine-rules.js +1 -2
- package/dist/src/artifacts/query-engine-scoring.js +38 -32
- package/dist/src/artifacts/query-engine-show-card.js +8 -2
- package/dist/src/artifacts/query-engine-show-load.js +1 -1
- package/dist/src/artifacts/query-engine-show.js +5 -3
- package/dist/src/artifacts/query-engine-templates.js +33 -0
- package/dist/src/artifacts/query-engine-verbose.js +25 -0
- package/dist/src/artifacts/relations-builder.js +49 -4
- package/dist/src/artifacts/relations.js +26 -10
- package/dist/src/artifacts/template-references.js +42 -0
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/cli/handlers/bundle-reconciliation.js +7 -3
- package/dist/src/cli/handlers/checkpoint-handoff.js +48 -0
- package/dist/src/cli/handlers/checkpoint-record.js +20 -0
- package/dist/src/cli/handlers/checkpoint.js +176 -0
- package/dist/src/cli/handlers/decision.js +1 -1
- package/dist/src/cli/handlers/doctor-args.js +3 -1
- package/dist/src/cli/handlers/doctor-help.js +2 -1
- package/dist/src/cli/handlers/help.js +1 -0
- package/dist/src/cli/handlers/index.js +4 -2
- package/dist/src/cli/handlers/models-resource-sample.js +7 -3
- package/dist/src/cli/handlers/ralph-launcher.js +1 -1
- package/dist/src/cli/handlers/refresh-bundles.js +2 -1
- package/dist/src/cli/handlers/refresh-managed-deployment.js +196 -0
- package/dist/src/cli/handlers/refresh.js +10 -2
- package/dist/src/cli/handlers/script-runner.js +2 -1
- package/dist/src/cli/handlers/steward-signing.js +44 -0
- package/dist/src/cli/handlers/steward.js +5 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +8 -1
- package/dist/src/cli/handlers/use-provider-results.js +17 -0
- package/dist/src/cli/handlers/use.js +19 -18
- package/dist/src/cli/router.js +12 -2
- package/dist/src/cli/services/deployment-verification.js +11 -7
- package/dist/src/cli/user-scope-mirror.js +3 -1
- package/dist/src/config/aiwg-config.js +5 -1
- package/dist/src/config/cli.js +1 -0
- package/dist/src/config/delivery-validation.js +21 -0
- package/dist/src/config/host-resource-report.d.mts +1 -1
- package/dist/src/config/host-resource-report.mjs +23 -4
- package/dist/src/config/host-resource-runtime.d.mts +8 -0
- package/dist/src/config/host-resource-runtime.mjs +67 -24
- package/dist/src/config/index-graph-overrides.js +4 -0
- package/dist/src/config/worker-attribution.d.mts +7 -0
- package/dist/src/config/worker-attribution.mjs +44 -0
- package/dist/src/config/worker-write.js +4 -10
- package/dist/src/decision/ledger.js +15 -15
- package/dist/src/decision/offload.js +6 -7
- package/dist/src/delivery/git.js +62 -0
- package/dist/src/delivery/pr.js +151 -0
- package/dist/src/delivery/template-sections.js +56 -0
- package/dist/src/delivery/tracker.js +33 -0
- package/dist/src/discovery/interview.js +1 -1
- package/dist/src/extensions/claude-hooks-installer.js +62 -53
- package/dist/src/extensions/loader.js +2 -1
- package/dist/src/extensions/managed-hook-script-state.js +48 -0
- package/dist/src/extensions/muse-managed-hooks.js +49 -0
- package/dist/src/issues/cli.js +15 -3
- package/dist/src/issues/external-cli.js +79 -0
- package/dist/src/issues/live.js +26 -2
- package/dist/src/issues/local.js +5 -1
- package/dist/src/issues/tracker-policy.js +27 -0
- package/dist/src/mcp/json-document.d.mts +2 -0
- package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
- package/dist/src/models/conductor-data-policy.d.mts +3 -2
- package/dist/src/models/conductor-data-policy.mjs +94 -5
- package/dist/src/models/model-capabilities.v1.json +27 -23
- package/dist/src/models/model-catalog.v1.json +3 -3
- package/dist/src/models/provider-policy.js +8 -0
- package/dist/src/models/worker-health-readiness.js +20 -4
- package/dist/src/models/worker-health-snapshot.js +29 -0
- package/dist/src/models/worker-installation.d.mts +5 -1
- package/dist/src/models/worker-installation.mjs +11 -5
- package/dist/src/models/worker-plan.js +3 -3
- package/dist/src/models/worker-qualification-policy.js +54 -0
- package/dist/src/models/worker-selection-policy.js +2 -1
- package/dist/src/providers/deployment-lock.js +77 -0
- package/dist/src/providers/deployment-ownership.d.mts +12 -2
- package/dist/src/providers/deployment-ownership.mjs +115 -21
- package/dist/src/providers/deployment-preservation.d.mts +2 -1
- package/dist/src/providers/deployment-preservation.mjs +3 -0
- package/dist/src/providers/provider-definitions.js +4 -0
- package/dist/src/providers/skill-ownership.d.mts +1 -0
- package/dist/src/providers/transformation-receipt-integration.js +4 -2
- package/dist/src/providers/transformation-receipt.js +4 -2
- package/dist/src/serve/worker-invocation-preparation.js +3 -1
- package/dist/src/serve/worker-invocation.js +6 -2
- package/dist/src/skills/run.js +5 -0
- package/dist/src/smiths/context-pipeline/workspace-audit.js +34 -17
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +12 -6
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +44 -4
- package/dist/src/smiths/context-pipeline/workspace-document.js +5 -2
- package/dist/src/smiths/context-pipeline/workspace-migration.js +2 -1
- package/dist/src/smiths/hook-bridge/codex-translator.js +150 -92
- package/dist/src/smiths/hook-bridge/codex-trust.js +50 -0
- package/dist/src/smiths/hook-bridge/factory-hook-config.js +132 -0
- package/dist/src/smiths/hook-bridge/factory-translator.js +88 -33
- package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/index.js +3 -3
- package/dist/src/smiths/hook-bridge/loader.js +10 -2
- package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +5 -0
- package/dist/src/storage/workspace-permissions-health.js +64 -0
- package/dist/src/storage/workspace-permissions.js +51 -0
- package/package.json +9 -2
- package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
- package/tools/agents/deploy-agents.mjs +15 -0
- package/tools/agents/providers/base-contract.mjs +7 -1
- package/tools/agents/providers/base-files.mjs +2 -1
- package/tools/agents/providers/base-flat-artifacts.mjs +6 -3
- package/tools/agents/providers/base-inventory.mjs +35 -13
- package/tools/agents/providers/base-models-platforms.mjs +3 -3
- package/tools/agents/providers/base-skill-copy.mjs +2 -0
- package/tools/agents/providers/base.mjs +1 -1
- package/tools/agents/providers/bound-rules-pointer.mjs +21 -0
- package/tools/agents/providers/claude-post-deploy.mjs +9 -5
- package/tools/agents/providers/codex-post-deploy.mjs +10 -0
- package/tools/agents/providers/conductor-data-guard.mjs +35 -11
- package/tools/agents/providers/factory-hooks.mjs +43 -0
- package/tools/agents/providers/factory.mjs +4 -91
- package/tools/agents/providers/muse-hooks.mjs +6 -41
- package/tools/agents/providers/muse-prompt-discovery.mjs +18 -0
- package/tools/agents/providers/packaged-codex-agents.mjs +48 -0
- package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
- package/tools/agents/providers/rule-delivery-surface.mjs +10 -7
- package/tools/agents/providers/rule-deployment-commit.mjs +10 -0
- package/tools/agents/providers/rule-presentation.mjs +6 -5
- package/tools/agents/providers/rule-projection.mjs +10 -2
- package/tools/agents/providers/rule-startup.mjs +8 -1
- package/tools/agents/providers/stale-artifact-prune.mjs +9 -8
- package/tools/cli/decision-offload-report.mjs +7 -2
- package/tools/plugin/issue-template-copies.mjs +24 -0
- package/tools/plugin/package-plugins.mjs +11 -3
- package/tools/ralph-external/lib/factory-adapter.mjs +7 -8
- package/tools/ralph-external/lib/worker-artifacts.mjs +4 -2
- package/tools/ralph-external/lib/worker-capture.mjs +157 -0
- package/tools/ralph-external/lib/worker-final.mjs +43 -8
- package/tools/ralph-external/lib/worker-health.mjs +3 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
- package/tools/ralph-external/lib/worker-launch-cli.mjs +20 -2
- package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
- package/tools/ralph-external/lib/worker-prompt.mjs +35 -0
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
- package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +8 -0
- package/tools/ralph-external/lib/worker-termination.mjs +56 -6
- package/tools/ralph-external/process-monitor.mjs +12 -18
- package/tools/ralph-external/session-launcher.mjs +53 -36
- package/vscode-extension/schemas/aiwg.config.v1.json +15 -0
|
@@ -24,6 +24,11 @@ const VALID_EVENTS = new Set([
|
|
|
24
24
|
'SessionStart',
|
|
25
25
|
'SessionEnd',
|
|
26
26
|
'Stop',
|
|
27
|
+
'PermissionRequest',
|
|
28
|
+
'PreCompact',
|
|
29
|
+
'PostCompact',
|
|
30
|
+
'SubagentStart',
|
|
31
|
+
'SubagentStop',
|
|
27
32
|
]);
|
|
28
33
|
/**
|
|
29
34
|
* Validate and normalize a parsed HookSource. Returns null if the input
|
|
@@ -50,6 +55,7 @@ function normalize(input, filePath) {
|
|
|
50
55
|
events,
|
|
51
56
|
command: o.command,
|
|
52
57
|
args: Array.isArray(o.args) ? o.args.filter((a) => typeof a === 'string') : undefined,
|
|
58
|
+
timeout: typeof o.timeout === 'number' && Number.isFinite(o.timeout) && o.timeout > 0 ? o.timeout : undefined,
|
|
53
59
|
safetyCritical: o['safety-critical'] === true || o.safetyCritical === true,
|
|
54
60
|
degradeOn: Array.isArray(o['degrade-on'])
|
|
55
61
|
? o['degrade-on'].filter((p) => typeof p === 'string')
|
|
@@ -108,8 +114,10 @@ export async function loadHookSources(frameworkRoot) {
|
|
|
108
114
|
errors.push(error);
|
|
109
115
|
continue;
|
|
110
116
|
}
|
|
111
|
-
if (source)
|
|
112
|
-
|
|
117
|
+
if (source) {
|
|
118
|
+
const resolveRoot = (value) => value.replace(/\$AIWG_ROOT\b|\$\{AIWG_ROOT\}/g, () => frameworkRoot);
|
|
119
|
+
sources.push({ ...source, command: resolveRoot(source.command), args: source.args?.map(resolveRoot) });
|
|
120
|
+
}
|
|
113
121
|
}
|
|
114
122
|
return { sources, errors };
|
|
115
123
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Explain prompt discovery gaps where an event mapping has no context contract.
|
|
2
|
+
export const PROMPT_DISCOVERY_GAPS = {
|
|
3
|
+
hermes: 'Prompt discovery unavailable: the Hermes bridge returns an exit code without forwarding prompt JSON or injecting additionalContext.',
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=prompt-discovery-gaps.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Diagnose and explicitly repair permissions on known non-secret workspace outputs.
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, open, readdir } from 'node:fs/promises';
|
|
4
|
+
import { dirname, join, relative } from 'node:path';
|
|
5
|
+
import { projectAiwgPath } from '../config/project-artifacts.js';
|
|
6
|
+
import { sharedWorkspace, workspacePermissionsAllowed } from './workspace-permissions.js';
|
|
7
|
+
/** Only outputs with a non-secret contract are eligible; token/key stores are never traversed. */
|
|
8
|
+
export async function inspectWorkspacePermissions(projectRoot, fix = false) {
|
|
9
|
+
const root = projectAiwgPath(projectRoot);
|
|
10
|
+
const report = { findings: [], journals: [] };
|
|
11
|
+
const visit = async (file, descend = true) => {
|
|
12
|
+
let info;
|
|
13
|
+
try {
|
|
14
|
+
info = await lstat(file);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error.code === 'ENOENT')
|
|
18
|
+
return;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
if (info.isSymbolicLink() || (!info.isDirectory() && !info.isFile()))
|
|
22
|
+
return;
|
|
23
|
+
const name = relative(root, file);
|
|
24
|
+
const journal = /^decision\/(ledger|opportunities)\.jsonl$/.test(name);
|
|
25
|
+
const allowed = workspacePermissionsAllowed(file, info);
|
|
26
|
+
const shared = sharedWorkspace(dirname(file));
|
|
27
|
+
if (journal)
|
|
28
|
+
report.journals.push({ path: file, state: !allowed ? 'unsafe' : (info.mode & 0o070) ? 'shared' : 'private' });
|
|
29
|
+
const collapsed = shared !== null && info.gid === shared.gid && (info.mode & 0o070) === 0;
|
|
30
|
+
if (collapsed || (journal && !allowed)) {
|
|
31
|
+
const finding = { path: file, reason: collapsed ? 'collapsed-group-mask' : 'ledger-permissions',
|
|
32
|
+
repaired: false, repair: 'aiwg doctor --decision-offload --fix' };
|
|
33
|
+
report.findings.push(finding);
|
|
34
|
+
if (fix && (!process.getuid || info.uid === process.getuid()) && (info.isDirectory() || info.nlink === 1)) {
|
|
35
|
+
const handle = await open(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
36
|
+
try {
|
|
37
|
+
const opened = await handle.stat();
|
|
38
|
+
if (opened.ino === info.ino && opened.dev === info.dev && opened.uid === info.uid && opened.nlink === info.nlink) {
|
|
39
|
+
await handle.chmod(collapsed ? (info.mode & 0o7777) | (info.isDirectory() ? 0o070 : 0o060) : 0o600);
|
|
40
|
+
finding.repaired = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await handle.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (info.isDirectory() && descend) {
|
|
49
|
+
for (const entry of await readdir(file))
|
|
50
|
+
await visit(join(file, entry));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// The local config and firewall baseline are control-plane outputs even with an external artifact root.
|
|
54
|
+
for (const file of [join(projectRoot, '.aiwg', 'aiwg.config'), join(projectRoot, '.aiwg', 'context-memory-firewall-baseline.json'),
|
|
55
|
+
join(root, 'receipts'), join(root, 'traces', 'transcripts'), join(root, 'archive', 'decision')])
|
|
56
|
+
await visit(file);
|
|
57
|
+
for (const directory of new Set([join(projectRoot, '.aiwg'), root, join(root, 'decision')]))
|
|
58
|
+
await visit(directory, false);
|
|
59
|
+
// Do not descend into decision's credential/private stores or transient lock files.
|
|
60
|
+
for (const name of ['ledger.jsonl', 'opportunities.jsonl'])
|
|
61
|
+
await visit(join(root, 'decision', name));
|
|
62
|
+
return report;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=workspace-permissions-health.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Stat-only permission policy for non-secret files in setgid, closed-to-others workspaces.
|
|
2
|
+
import { lstatSync } from 'node:fs';
|
|
3
|
+
import { chmod, lstat } from 'node:fs/promises';
|
|
4
|
+
import { dirname, resolve } from 'node:path';
|
|
5
|
+
/** Walk existing directories only; no ACL commands, subprocesses, or cached policy. */
|
|
6
|
+
export function sharedWorkspace(directory) {
|
|
7
|
+
if (process.platform === 'win32')
|
|
8
|
+
return null;
|
|
9
|
+
let current = resolve(directory);
|
|
10
|
+
for (;;) {
|
|
11
|
+
try {
|
|
12
|
+
const info = lstatSync(current);
|
|
13
|
+
if (info.isSymbolicLink())
|
|
14
|
+
return null;
|
|
15
|
+
if (info.isDirectory() && (info.mode & 0o2000) !== 0) {
|
|
16
|
+
return (info.mode & 0o007) === 0 ? { gid: info.gid } : null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error.code !== 'ENOENT')
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
const parent = dirname(current);
|
|
24
|
+
if (parent === current)
|
|
25
|
+
return null;
|
|
26
|
+
current = parent;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Group bits leave the inherited ACL mask usable; umask/default ACL still apply.
|
|
30
|
+
export const workspaceFileMode = (file) => sharedWorkspace(dirname(file)) ? 0o660 : 0o600;
|
|
31
|
+
export const workspaceDirectoryMode = (directory) => sharedWorkspace(directory) ? 0o770 : 0o700;
|
|
32
|
+
/** Private files remain valid; shared files must match the workspace gid and exclude others. */
|
|
33
|
+
export function workspacePermissionsAllowed(file, info) {
|
|
34
|
+
if ((info.mode & 0o077) === 0)
|
|
35
|
+
return true;
|
|
36
|
+
const shared = sharedWorkspace(info.isDirectory?.() ? file : dirname(file));
|
|
37
|
+
return (info.mode & 0o007) === 0 && shared !== null && info.gid === shared.gid;
|
|
38
|
+
}
|
|
39
|
+
/** chmod after creation preserves the target mode even when umask filters temporary-file creation. */
|
|
40
|
+
export async function preserveReplacementMode(temporary, destination) {
|
|
41
|
+
try {
|
|
42
|
+
const info = await lstat(destination);
|
|
43
|
+
if (info.isFile())
|
|
44
|
+
await chmod(temporary, info.mode & 0o777);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error.code !== 'ENOENT')
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=workspace-permissions.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwg/cli",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.2",
|
|
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-hooks/canonical/aiwg-prompt-discovery.yaml",
|
|
31
|
+
"agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs",
|
|
30
32
|
"agentic/code/addons/aiwg-utils/rules/anti-laziness.md",
|
|
31
33
|
"agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md",
|
|
32
34
|
"agentic/code/addons/composition-engine/lib/runtime.mjs",
|
|
@@ -61,7 +63,10 @@
|
|
|
61
63
|
"tools/ralph-external/lib/session-environment.mjs",
|
|
62
64
|
"tools/ralph-external/lib/worker-inputs.mjs",
|
|
63
65
|
"tools/ralph-external/lib/worker-final.mjs",
|
|
66
|
+
"tools/ralph-external/lib/worker-prompt.mjs",
|
|
67
|
+
"tools/ralph-external/lib/worker-capture.mjs",
|
|
64
68
|
"tools/ralph-external/lib/worker-launch-cli.mjs",
|
|
69
|
+
"tools/ralph-external/lib/worker-run-directory-refusal.mjs",
|
|
65
70
|
"tools/ralph-external/lib/worker-isolation.mjs",
|
|
66
71
|
"tools/ralph-external/lib/worker-isolation-args.mjs",
|
|
67
72
|
"tools/ralph-external/lib/worker-unit-cleanup.mjs",
|
|
@@ -69,6 +74,7 @@
|
|
|
69
74
|
"tools/ralph-external/lib/worker-isolation-status.mjs",
|
|
70
75
|
"tools/ralph-external/lib/worker-retry-evidence.mjs",
|
|
71
76
|
"tools/ralph-external/lib/worker-termination.mjs",
|
|
77
|
+
"tools/ralph-external/lib/worker-process-identity.mjs",
|
|
72
78
|
"tools/ralph-external/lib/worker-invocation-processes.mjs",
|
|
73
79
|
"tools/ralph-external/lib/worker-invocation-ancestry.mjs",
|
|
74
80
|
"tools/ralph-external/lib/worker-context.mjs",
|
|
@@ -104,6 +110,7 @@
|
|
|
104
110
|
"tools/providers/antigravity-transport.mjs",
|
|
105
111
|
"tools/commands/deploy-prompts-codex.mjs",
|
|
106
112
|
"tools/plugin/package-plugins.mjs",
|
|
113
|
+
"tools/plugin/issue-template-copies.mjs",
|
|
107
114
|
"tools/plugin/plugin-links.mjs",
|
|
108
115
|
"tools/skills/deploy-skills-codex.mjs",
|
|
109
116
|
"tools/skills/codex-skill-transform.mjs",
|
|
@@ -141,7 +148,7 @@
|
|
|
141
148
|
"chalk": "^4.1.2",
|
|
142
149
|
"chokidar": "^4.0.3",
|
|
143
150
|
"commander": "^12.1.0",
|
|
144
|
-
"glob": "^
|
|
151
|
+
"glob": "^14.0.2",
|
|
145
152
|
"graceful-fs": "^4.2.11",
|
|
146
153
|
"js-yaml": "^4.3.0",
|
|
147
154
|
"listr2": "^8.2.5",
|
|
@@ -166,6 +166,21 @@ const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'provide
|
|
|
166
166
|
const { captureDeploymentOutputs, recordDeploymentOutputs, deploymentOutputRoots } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
167
167
|
|
|
168
168
|
export async function main(args = process.argv.slice(2), internal = {}) {
|
|
169
|
+
const cfg = parseArgs(args);
|
|
170
|
+
if (!cfg.help && !cfg.dryRun && !internal.preflightOnly && !internal.finalizeOnly
|
|
171
|
+
&& !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')]) {
|
|
172
|
+
const provider = await loadProvider(cfg.provider);
|
|
173
|
+
const shared = [...Object.values(provider.paths), provider.kernelSkillsPath].some(dir => dir && path.isAbsolute(dir))
|
|
174
|
+
|| provider.name === 'codex' || cfg.userScope || cfg.saveUser;
|
|
175
|
+
if (shared) {
|
|
176
|
+
const { withProviderDeploymentLock } = await importImpl(import.meta.url, 'providers/deployment-lock.js');
|
|
177
|
+
return withProviderDeploymentLock(() => mainUnlocked(args, internal));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return mainUnlocked(args, internal);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function mainUnlocked(args, internal) {
|
|
169
184
|
const cfg = parseArgs(args);
|
|
170
185
|
if (cfg.help) { printHelp(); return 0; }
|
|
171
186
|
const modelCatalog = loadRuntimeModelCatalog(staticModelCatalog);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Shared provider contract utilities.
|
|
2
2
|
import { path } from './base-runtime.mjs';
|
|
3
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
// ============================================================================
|
|
@@ -110,7 +111,12 @@ export function injectBoundRules(content, source, opts = {}) {
|
|
|
110
111
|
* kernel passes leave rule delivery to the final source in the invocation. */
|
|
111
112
|
export async function withRuleDeployment(opts, provider, deploy) {
|
|
112
113
|
if (opts.kernelOnly && opts.deferRuleProjection && provider.name !== 'warp'
|
|
113
|
-
&& !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')])
|
|
114
|
+
&& !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')]) {
|
|
115
|
+
const shared = [...Object.values(provider.paths), provider.kernelSkillsPath].some(dir => dir && path.isAbsolute(dir));
|
|
116
|
+
if (!shared || opts.dryRun) return deploy(opts);
|
|
117
|
+
const { withProviderDeploymentLock } = await importImpl(import.meta.url, 'providers/deployment-lock.js');
|
|
118
|
+
return withProviderDeploymentLock(() => deploy(opts));
|
|
119
|
+
}
|
|
114
120
|
const { deployWithRuleDelivery } = await import('./rule-delivery.mjs');
|
|
115
121
|
return deployWithRuleDelivery(opts, provider, deploy);
|
|
116
122
|
}
|
|
@@ -236,11 +236,12 @@ export function updateSidecarManifest(dir, deployedEntries, opts) {
|
|
|
236
236
|
const existing = readSidecarManifest(dir) || { managed: {} };
|
|
237
237
|
|
|
238
238
|
for (const entry of deployedEntries) {
|
|
239
|
-
const { filename, hash, frameworkSlug, kind, sourcePath } = entry;
|
|
239
|
+
const { filename, hash, frameworkSlug, kind, sourcePath, sourceHash } = entry;
|
|
240
240
|
const prior = existing.managed[filename];
|
|
241
241
|
const digest = `sha256:${hash}`;
|
|
242
242
|
const sidecarEntry = { ...(prior?.hash === digest ? prior : {}), hash: digest, source, version };
|
|
243
243
|
if (sourcePath) sidecarEntry.sourcePath = sourcePath;
|
|
244
|
+
if (sourceHash) sidecarEntry.sourceHash = sourceHash;
|
|
244
245
|
if (frameworkSlug) sidecarEntry.frameworkSlug = frameworkSlug;
|
|
245
246
|
// `kind` marks artifacts whose lifecycle is governed elsewhere — currently
|
|
246
247
|
// only `skill-command` wrappers, which follow their source skill (#2507).
|
|
@@ -23,6 +23,7 @@ export function deployFiles(files, destDir, opts, transformFn) {
|
|
|
23
23
|
// (#1169). Each value: { src, frameworkSlug }
|
|
24
24
|
const seen = new Map();
|
|
25
25
|
const actions = [];
|
|
26
|
+
const sourceHashes = new Map();
|
|
26
27
|
// Collision report — one entry per detected cross-framework collision
|
|
27
28
|
// (within-batch or against sidecar). Surfaced after the loop.
|
|
28
29
|
const collisions = [];
|
|
@@ -45,7 +46,9 @@ export function deployFiles(files, destDir, opts, transformFn) {
|
|
|
45
46
|
|
|
46
47
|
// Read and transform source content (needed for content-equality check
|
|
47
48
|
// and the collision-vs-duplicate distinction)
|
|
48
|
-
const
|
|
49
|
+
const rawContent = fs.readFileSync(f, 'utf8');
|
|
50
|
+
sourceHashes.set(f, `sha256:${contentHash(rawContent)}`);
|
|
51
|
+
const srcContent = injectBoundRules(rawContent, f, opts);
|
|
49
52
|
let transformedContent = transformFn ? transformFn(f, srcContent, opts) : srcContent;
|
|
50
53
|
|
|
51
54
|
// Rule triggers are index metadata, not something the reading agent needs.
|
|
@@ -185,11 +188,11 @@ export function deployFiles(files, destDir, opts, transformFn) {
|
|
|
185
188
|
if (dryRun) console.log(`[dry-run] deploy ${a.src} -> ${a.dest} (${a.reason})`);
|
|
186
189
|
else writeFile(a.dest, a.content, false);
|
|
187
190
|
if (verbose) console.log(`deployed ${path.basename(a.src)} -> ${path.relative(process.cwd(), opts.logicalOutputPath?.(a.dest) || a.dest)} (${a.reason})`);
|
|
188
|
-
deployedEntries.push({ filename: path.basename(a.dest), hash: a.hash, frameworkSlug: a.frameworkSlug, sourcePath: path.resolve(a.src) });
|
|
191
|
+
deployedEntries.push({ filename: path.basename(a.dest), hash: a.hash, sourceHash: sourceHashes.get(a.src), frameworkSlug: a.frameworkSlug, sourcePath: path.resolve(a.src) });
|
|
189
192
|
} else if (a.type === 'skip') {
|
|
190
193
|
if (verbose) console.log(`skip (${a.reason}): ${path.basename(a.dest)}`);
|
|
191
194
|
// Preserve existing sidecar entries for skipped files
|
|
192
|
-
if (a.hash) deployedEntries.push({ filename: path.basename(a.dest), hash: a.hash, frameworkSlug: a.frameworkSlug, sourcePath: path.resolve(a.src) });
|
|
195
|
+
if (a.hash) deployedEntries.push({ filename: path.basename(a.dest), hash: a.hash, sourceHash: sourceHashes.get(a.src), frameworkSlug: a.frameworkSlug, sourcePath: path.resolve(a.src) });
|
|
193
196
|
}
|
|
194
197
|
}
|
|
195
198
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Shared provider inventory utilities.
|
|
2
|
-
import { fs, path } from './base-runtime.mjs';
|
|
2
|
+
import { extractFrameworkSlug, fs, path } from './base-runtime.mjs';
|
|
3
3
|
import { collectFrameworkArtifacts } from './base-framework-discovery.mjs';
|
|
4
4
|
import { getAddonAgentFiles, getAddonCommandFiles } from './base-addon-discovery.mjs';
|
|
5
5
|
import { getAddonRuleFiles } from './base-rule-index.mjs';
|
|
@@ -40,8 +40,9 @@ export function artifactStem(name) {
|
|
|
40
40
|
* deliberate and mirrors `computeAllKernelNames` for skills: `aiwg use sdlc`
|
|
41
41
|
* must not prune a marketing agent that a prior `aiwg use all` deployed and
|
|
42
42
|
* that is still a valid AIWG artifact. Only artifacts whose source no longer
|
|
43
|
-
* exists ANYWHERE in the tree (renamed/removed) fall out of this set
|
|
44
|
-
*
|
|
43
|
+
* exists ANYWHERE in the tree (renamed/removed) fall out of this set.
|
|
44
|
+
* Receipts with bundle identity use the owner inventory instead, so an
|
|
45
|
+
* unrelated bundle's same-named artifact cannot hide a retired artifact.
|
|
45
46
|
*
|
|
46
47
|
* Anchors to the AIWG root (resolved by walking up from `srcRoot` for the
|
|
47
48
|
* `agentic/code/frameworks` + `agentic/code/addons` pair, or `AIWG_ROOT`),
|
|
@@ -57,12 +58,25 @@ export function artifactStem(name) {
|
|
|
57
58
|
* if the AIWG framework/addon tree can't be located
|
|
58
59
|
*/
|
|
59
60
|
export function computeAllArtifactBasenames(srcRoot, type) {
|
|
61
|
+
return computeArtifactInventory(srcRoot, type)?.stems ?? null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Global and per-bundle stems from the same mode-independent discovery pass. */
|
|
65
|
+
export function computeArtifactInventory(srcRoot, type) {
|
|
60
66
|
const aiwgRoot = resolveAiwgRoot(srcRoot);
|
|
61
67
|
if (!aiwgRoot) return null;
|
|
62
68
|
|
|
63
69
|
const stems = new Set();
|
|
70
|
+
const ownerStems = new Map();
|
|
64
71
|
const add = (files) => {
|
|
65
|
-
for (const f of files)
|
|
72
|
+
for (const f of files) {
|
|
73
|
+
const stem = artifactStem(path.basename(f));
|
|
74
|
+
stems.add(stem);
|
|
75
|
+
const owner = extractFrameworkSlug(f);
|
|
76
|
+
if (!owner) continue;
|
|
77
|
+
if (!ownerStems.has(owner)) ownerStems.set(owner, new Set());
|
|
78
|
+
ownerStems.get(owner).add(stem);
|
|
79
|
+
}
|
|
66
80
|
};
|
|
67
81
|
|
|
68
82
|
const frameworkArtifacts = collectFrameworkArtifacts(aiwgRoot, 'all', {
|
|
@@ -87,7 +101,7 @@ export function computeAllArtifactBasenames(srcRoot, type) {
|
|
|
87
101
|
add(getAddonRuleFiles(aiwgRoot, [], { includeExplicit: true }));
|
|
88
102
|
}
|
|
89
103
|
|
|
90
|
-
return stems;
|
|
104
|
+
return { stems, ownerStems };
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
|
|
@@ -170,21 +184,23 @@ export function computeAllSkillNames(srcRoot) {
|
|
|
170
184
|
* 1. It has an allowed deployed-artifact extension (`.md` / `.mdc` by
|
|
171
185
|
* default; callers may include `.toml`), is not `RULES-INDEX.md`,
|
|
172
186
|
* and not the sidecar manifest.
|
|
173
|
-
* 2.
|
|
187
|
+
* 2. No recorded owner still ships its stem. Receipts without bundle
|
|
188
|
+
* identity fall back to the global `desiredStems` check.
|
|
174
189
|
* 3. It carries an AIWG ownership signal — either a `.aiwg-manifest.json`
|
|
175
190
|
* sidecar entry, or an in-file `aiwg:managed` marker.
|
|
191
|
+
* 4. Its bytes match the sidecar's hash. Markers alone never permit deletion.
|
|
176
192
|
*
|
|
177
|
-
* User-authored files (no ownership signal) and
|
|
178
|
-
*
|
|
193
|
+
* User-authored files (no ownership signal) and artifacts still shipped by a
|
|
194
|
+
* recorded owner are never touched. Pruned files also have their sidecar
|
|
179
195
|
* entry dropped so the manifest stays accurate.
|
|
180
196
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
197
|
+
* Shared-path rule: retain the file if ANY recorded owner still ships the
|
|
198
|
+
* stem, including when another recorded owner has retired it. Inventory is
|
|
199
|
+
* mode-independent so sibling-framework files remain protected.
|
|
184
200
|
*
|
|
185
201
|
* @param {string} destDir absolute path to the provider artifact dir
|
|
186
202
|
* @param {Set<string>|string[]} desiredStems stems that should remain
|
|
187
|
-
* @param {object} opts `{ dryRun, verbose }`
|
|
203
|
+
* @param {object} opts `{ dryRun, verbose, ownerStems?: Map<string, Set<string>> }`
|
|
188
204
|
* @returns {string[]} removed (or would-be-removed) file paths
|
|
189
205
|
*/
|
|
190
206
|
export function pruneStaleAiwgFiles(destDir, desiredStems, opts = {}) {
|
|
@@ -224,7 +240,13 @@ export function pruneStaleAiwgFiles(destDir, desiredStems, opts = {}) {
|
|
|
224
240
|
const lower = name.toLowerCase();
|
|
225
241
|
if (!artifactExtensions.some(extension => lower.endsWith(extension))) continue;
|
|
226
242
|
|
|
227
|
-
|
|
243
|
+
const stem = artifactStem(name);
|
|
244
|
+
const record = managed[name];
|
|
245
|
+
const owners = [record?.frameworkSlug, ...(Array.isArray(record?.owners) ? record.owners : [])]
|
|
246
|
+
.filter(owner => typeof owner === 'string' && owner.length > 0);
|
|
247
|
+
// Wrappers belong to the skill inventory below, not the command inventory.
|
|
248
|
+
const ownerAware = opts.ownerStems instanceof Map && owners.length > 0 && record?.kind !== 'skill-command';
|
|
249
|
+
if (ownerAware ? owners.some(owner => opts.ownerStems.get(owner)?.has(stem)) : desired.has(stem)) continue;
|
|
228
250
|
|
|
229
251
|
// Skill-command wrappers are named after skills, not command sources, so
|
|
230
252
|
// they are absent from the command desired set by construction — pruning
|
|
@@ -42,9 +42,9 @@ export function loadModelConfig(srcRoot) {
|
|
|
42
42
|
efficiency: { model: 'claude-haiku-4-5' }
|
|
43
43
|
},
|
|
44
44
|
factory: {
|
|
45
|
-
reasoning: { model: '
|
|
46
|
-
coding: { model: '
|
|
47
|
-
efficiency: { model: '
|
|
45
|
+
reasoning: { model: 'claude-opus-5' },
|
|
46
|
+
coding: { model: 'claude-sonnet-5' },
|
|
47
|
+
efficiency: { model: 'claude-haiku-4-5-20251001' }
|
|
48
48
|
},
|
|
49
49
|
shorthand: {
|
|
50
50
|
'opus': 'claude-opus-5',
|
|
@@ -74,6 +74,7 @@ export function deploySkillDir(skillDir, destDir, opts) {
|
|
|
74
74
|
copyRecursive(srcPath, destPath);
|
|
75
75
|
} else {
|
|
76
76
|
let srcContent = fs.readFileSync(srcPath, 'utf8');
|
|
77
|
+
const sourceHash = `sha256:${contentHash(srcContent)}`;
|
|
77
78
|
|
|
78
79
|
// Inject target platform into SKILL.md — replaces [all] token with [provider-name]
|
|
79
80
|
if (entry.name === 'SKILL.md' && provider) {
|
|
@@ -93,6 +94,7 @@ export function deploySkillDir(skillDir, destDir, opts) {
|
|
|
93
94
|
const relative = path.relative(destSkillDir, destPath);
|
|
94
95
|
managed[relative] = {
|
|
95
96
|
hash: `sha256:${contentHash(srcContent)}`,
|
|
97
|
+
sourceHash,
|
|
96
98
|
source: opts.deploySource || 'bundled',
|
|
97
99
|
version: opts.deployVersion || 'unknown',
|
|
98
100
|
...(frameworkSlug ? { frameworkSlug } : {}),
|
|
@@ -5,7 +5,7 @@ export { loadModelConfig, loadRuntimeModelCatalog, parseSkillPlatforms, skillMat
|
|
|
5
5
|
export { parseFrontmatter, stringifyFrontmatter, toKebabCase, stripJsonComments, inferAgentCategory, parseTools, filterCommandsAgainstSkills } from './base-frontmatter.mjs';
|
|
6
6
|
export { deployFiles, deploySoulCompanions } from './base-flat-artifacts.mjs';
|
|
7
7
|
export { isKernelSkill, deploySkillsWithKernelRouting, computeAllKernelNames, pruneStaleAiwgSkills } from './base-kernel-skills.mjs';
|
|
8
|
-
export { artifactStem, computeAllArtifactBasenames, resolveAiwgRoot, computeAllSkillNames, pruneStaleAiwgFiles } from './base-inventory.mjs';
|
|
8
|
+
export { artifactStem, computeAllArtifactBasenames, computeArtifactInventory, resolveAiwgRoot, computeAllSkillNames, pruneStaleAiwgFiles } from './base-inventory.mjs';
|
|
9
9
|
export { deploySkillDir, initializeFrameworkWorkspace } from './base-skill-copy.mjs';
|
|
10
10
|
export { buildRemotesTopologyBlock, interpolateContextTokens, createManagedMdFromTemplate, createAgentsMdFromTemplate } from './base-context.mjs';
|
|
11
11
|
export { shouldDeployAgent, matchesGlob, filterAgentFiles, normalizeDeploymentMode, discoverFrameworks, getFrameworksForMode, collectFrameworkArtifacts } from './base-framework-discovery.mjs';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Render the final bound-rule pointer shared by deployment and size checks.
|
|
2
|
+
import { replaceBoundRulesBlock } from './base-contract.mjs';
|
|
3
|
+
|
|
4
|
+
export const boundRuleAnchor = target => `${target.type}-${target.name}`.toLowerCase().replace(/[^a-z0-9_-]/g, '-');
|
|
5
|
+
|
|
6
|
+
export function renderBoundRulesPointer(body, targets, indexRel, { fetch = '', compact = false } = {}) {
|
|
7
|
+
const clean = replaceBoundRulesBlock(body, []);
|
|
8
|
+
const pointers = [...new Set(targets.map(target => `${indexRel}#${boundRuleAnchor(target)}`))];
|
|
9
|
+
if (!pointers.length) return clean;
|
|
10
|
+
// Authored pointers already reach the same complete rule set; keep one copy.
|
|
11
|
+
const missing = pointers.filter(pointer => !clean.includes(`\`${pointer}\``));
|
|
12
|
+
const instruction = missing.length
|
|
13
|
+
? `${compact ? 'Read and follow' : 'Read and follow before governed work'}: ${missing.map(pointer => `\`${pointer}\``).join('; ')}.`
|
|
14
|
+
: 'Read and follow the bound rules listed above before governed work.';
|
|
15
|
+
return `${clean}${clean.endsWith('\n') ? '' : '\n'}\n<!-- AIWG:bound-rules:start -->\n${instruction}\n${fetch ? fetch + '\n' : ''}<!-- AIWG:bound-rules:end -->\n`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function projectCodexAgentBindings(rendered, targets) {
|
|
19
|
+
return rendered.replace(/^developer_instructions = (".*")$/m, (_, value) =>
|
|
20
|
+
`developer_instructions = ${JSON.stringify(renderBoundRulesPointer(JSON.parse(value), targets, '.codex/RULES-BOUND.md', { compact: true }))}`);
|
|
21
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { fileURLToPath } from 'node:url';
|
|
4
5
|
import { importImpl } from '../../_resolve-impl.mjs';
|
|
5
6
|
import { initializeFrameworkWorkspace, ensureDir } from './base.mjs';
|
|
6
7
|
import { deployHookFile } from './claude.mjs';
|
|
@@ -36,13 +37,16 @@ export async function postDeploy(targetDir, opts) {
|
|
|
36
37
|
|
|
37
38
|
const addonPass = /(?:agentic\/code|\.aiwg)\/(?:addons|extensions)\//.test((opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot)?.replaceAll('\\', '/') || '');
|
|
38
39
|
|
|
39
|
-
//
|
|
40
|
-
|
|
40
|
+
// Full addon passes also refresh runtime scripts, using this package's source.
|
|
41
|
+
const fullDeploy = !opts.commandsOnly && !opts.rulesOnly && (!opts.skillsOnly || opts.kernelOnly === true);
|
|
42
|
+
const hooks = fullDeploy && opts.hooks === true && opts.scope !== 'user';
|
|
43
|
+
if (opts.attribution !== false || hooks) {
|
|
41
44
|
const { installAiwgHooks } = await importImpl(import.meta.url, 'extensions/claude-hooks-installer.js');
|
|
42
45
|
const { deploymentOwner } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
43
|
-
const result = await installAiwgHooks({ frameworkSlug: deploymentOwner(opts), claimUnchangedSettings: !addonPass, projectPath: targetDir,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
const result = await installAiwgHooks({ frameworkSlug: deploymentOwner(opts), claimUnchangedSettings: !addonPass, projectPath: targetDir,
|
|
47
|
+
frameworkRoot: fileURLToPath(new URL('../../../', import.meta.url)),
|
|
48
|
+
attribution: opts.attribution !== false, hooks, dryRun: opts.dryRun });
|
|
49
|
+
if (!opts.dryRun && result) opts.writtenFiles?.push(result.settingsPath, ...result.installedScripts);
|
|
46
50
|
for (const warning of result?.warnings || []) console.warn(`Claude settings: ${warning}`);
|
|
47
51
|
}
|
|
48
52
|
await deployConductorDataGuard(targetDir, 'claude', opts);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Apply project settings and context after provider file deployment.
|
|
2
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
2
4
|
import { initializeFrameworkWorkspace } from './base.mjs';
|
|
3
5
|
import { createAgentsMd } from './codex.mjs';
|
|
4
6
|
import { deployConductorDataGuard } from './conductor-data-guard.mjs';
|
|
@@ -7,6 +9,14 @@ export async function postDeploy(targetDir, opts) {
|
|
|
7
9
|
initializeFrameworkWorkspace(targetDir, opts.mode, opts.dryRun, opts.srcRoot);
|
|
8
10
|
await deployConductorDataGuard(targetDir, 'codex', opts);
|
|
9
11
|
|
|
12
|
+
const fullDeploy = !opts.commandsOnly && !opts.rulesOnly && (!opts.skillsOnly || opts.kernelOnly === true);
|
|
13
|
+
if (fullDeploy && opts.hooks !== false && opts.scope !== 'user') {
|
|
14
|
+
const { installCodexPromptDiscovery } = await importImpl(import.meta.url, 'smiths/hook-bridge/codex-translator.js');
|
|
15
|
+
const packageRoot = fileURLToPath(new URL('../../../', import.meta.url));
|
|
16
|
+
// Runtime hooks belong to this package, even when deploying an external bundle.
|
|
17
|
+
await installCodexPromptDiscovery({ projectPath: targetDir, frameworkRoot: packageRoot, dryRun: opts.dryRun });
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
if (opts.createAgentsMd) {
|
|
11
21
|
if (opts.contextFiles !== false) createAgentsMd(targetDir, opts.srcRoot, opts.dryRun);
|
|
12
22
|
}
|
|
@@ -6,26 +6,50 @@ import { importImpl, resolveImpl } from '../../_resolve-impl.mjs';
|
|
|
6
6
|
|
|
7
7
|
const quote = value => `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
// on the framework default config (absent from the slim CLI package).
|
|
13
|
-
function declaresLocalOnlyPaths(targetDir) {
|
|
9
|
+
// Avoid the full model-config load for ordinary deploys, including slim CLI installs
|
|
10
|
+
// without framework defaults. Declared guards use the same validated loader as paths.
|
|
11
|
+
function declaresGuardPolicy(targetDir, provider) {
|
|
14
12
|
const userDir = process.env.AIWG_CONFIG || path.join(os.homedir(), '.config/aiwg');
|
|
15
13
|
return [path.join(targetDir, 'models.json'), path.join(userDir, 'models.json'), path.join(targetDir, '.aiwg/aiwg.config')]
|
|
16
|
-
.some(file => { try {
|
|
14
|
+
.some(file => { try {
|
|
15
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
16
|
+
if (source.includes('localOnlyPaths')) return true;
|
|
17
|
+
if (provider !== 'claude' || !source.includes('denyConductorWorkerExecution')) return false;
|
|
18
|
+
const value = JSON.parse(source)?.defaults?.workerSelection?.guards?.denyConductorWorkerExecution;
|
|
19
|
+
return value !== undefined && value !== false;
|
|
20
|
+
} catch (error) { return error instanceof SyntaxError; } });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Turn off a previously deployed opt-in check without removing retained read rules.
|
|
24
|
+
function disableExecutionCheck(targetDir, provider, opts) {
|
|
25
|
+
if (provider !== 'claude' || opts.dryRun) return;
|
|
26
|
+
const root = path.resolve(targetDir), hookPath = path.join(root, '.claude/hooks/aiwg-local-only.mjs');
|
|
27
|
+
if (!fs.existsSync(hookPath)) return;
|
|
28
|
+
const source = fs.readFileSync(hookPath, 'utf8');
|
|
29
|
+
const start = source.lastIndexOf(`\nrunConductorDataHook(${JSON.stringify(root)}, `);
|
|
30
|
+
if (start >= 0 && source.endsWith(', true);\n')) {
|
|
31
|
+
fs.writeFileSync(hookPath, source.slice(0, -', true);\n'.length) + ', false);\n');
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
34
|
|
|
19
35
|
export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
20
|
-
if (!
|
|
36
|
+
if (!declaresGuardPolicy(targetDir, provider)) {
|
|
37
|
+
disableExecutionCheck(targetDir, provider, opts);
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
21
40
|
// Always resolve policy through the existing loader, including inherited restrictions.
|
|
22
|
-
const { ConfigLoader } = await importImpl(import.meta.url, 'models/config-loader.js');
|
|
23
41
|
const { readAiwgConfig } = await importImpl(import.meta.url, 'config/aiwg-config.js');
|
|
42
|
+
const { ConfigLoader } = await importImpl(import.meta.url, 'models/config-loader.js');
|
|
24
43
|
const guard = await importImpl(import.meta.url, 'models/conductor-data-policy.mjs');
|
|
25
44
|
const config = await readAiwgConfig(targetDir);
|
|
26
45
|
const models = await new ConfigLoader(targetDir).load(config?.parallelism);
|
|
46
|
+
const executionGuard = provider === 'claude' && models.defaults.workerSelection?.guards?.denyConductorWorkerExecution === true;
|
|
27
47
|
const paths = guard.collectLocalOnlyPaths(models.defaults.workerSelection, config?.parallelism);
|
|
28
|
-
if (!paths.length
|
|
48
|
+
if (!paths.length && !executionGuard) {
|
|
49
|
+
disableExecutionCheck(targetDir, provider, opts);
|
|
50
|
+
return paths;
|
|
51
|
+
}
|
|
52
|
+
if (opts.dryRun) return paths;
|
|
29
53
|
const root = path.resolve(targetDir);
|
|
30
54
|
if (provider === 'claude') {
|
|
31
55
|
const settingsPath = path.join(root, '.claude/settings.json');
|
|
@@ -33,7 +57,7 @@ export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
|
33
57
|
const hookPath = path.join(root, '.claude/hooks/aiwg-local-only.mjs');
|
|
34
58
|
const hookSource = fs.readFileSync(resolveImpl(import.meta.url, 'models/conductor-data-policy.mjs'), 'utf8');
|
|
35
59
|
fs.mkdirSync(path.dirname(hookPath), { recursive: true });
|
|
36
|
-
fs.writeFileSync(hookPath, `${hookSource}\nrunConductorDataHook(${JSON.stringify(root)}, ${JSON.stringify(paths)});\n`);
|
|
60
|
+
fs.writeFileSync(hookPath, `${hookSource}\nrunConductorDataHook(${JSON.stringify(root)}, ${JSON.stringify(paths)}, ${JSON.stringify(executionGuard)});\n`);
|
|
37
61
|
settings.permissions ??= {};
|
|
38
62
|
settings.permissions.deny = [...new Set([...(settings.permissions.deny ?? []), ...paths.flatMap(file => [
|
|
39
63
|
`Read(//${path.join(root, file).slice(1)})`, `Read(//${path.join(root, file).slice(1)}/**)`,
|
|
@@ -56,6 +80,6 @@ export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
|
56
80
|
fs.mkdirSync(path.dirname(rulesPath), { recursive: true });
|
|
57
81
|
fs.writeFileSync(rulesPath, lines.join('\n') + '\n');
|
|
58
82
|
}
|
|
59
|
-
console.log(`
|
|
83
|
+
console.log(`Conductor guard (${provider}): ${paths.join(', ')}${executionGuard ? '; worker execution checks enabled' : ''}; shell coverage is limited.`);
|
|
60
84
|
return paths;
|
|
61
85
|
}
|