@aiwg/cli 2026.10.12 → 2026.10.15
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 +44 -1
- package/dist/src/artifacts/corpus-tools/cli.js +32 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +1 -1
- package/dist/src/artifacts/corpus-tools/expand-cli.js +89 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +38 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +40 -0
- package/dist/src/artifacts/corpus-tools/expand.js +125 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +91 -0
- package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +105 -0
- package/dist/src/cli/handlers/doctor-args.js +40 -0
- package/dist/src/cli/handlers/doctor-help.js +4 -2
- package/dist/src/cli/handlers/use-bundle-counts.js +32 -6
- package/dist/src/cli/handlers/use-skill-assets.js +207 -0
- package/dist/src/cli/handlers/use.js +30 -193
- package/dist/src/cli/handlers/utilities.js +5 -31
- package/dist/src/config/authorization-cli.js +11 -3
- package/dist/src/config/worker-context.js +33 -4
- package/dist/src/decision/context-pruning-common.js +41 -0
- package/dist/src/decision/context-pruning-evaluation.js +366 -0
- package/dist/src/decision/context-pruning-pilot.js +431 -0
- package/dist/src/decision/context-pruning-types.js +19 -0
- package/dist/src/decision/context-pruning.js +5 -847
- package/dist/src/decision/ensemble/contract.js +4 -24
- package/dist/src/decision/heldout/collector.js +1 -1
- package/dist/src/decision/qualification/release.js +5 -62
- package/dist/src/extensions/manifest.js +8 -1
- package/dist/src/extensions/project-local-doctor.js +78 -2
- package/dist/src/extensions/validation.js +10 -11
- package/dist/src/features/catalog.js +1 -1
- package/dist/src/gates/evaluate.js +5 -15
- package/dist/src/gates/heldout.js +42 -0
- package/dist/src/gates/index.js +2 -1
- package/dist/src/gates/upstream-ceiling.js +111 -0
- package/dist/src/models/provider-models.js +5 -8
- package/dist/src/models/worker-installation-store.mjs +228 -0
- package/dist/src/models/worker-installation.mjs +7 -162
- package/dist/src/models/wrapper-definitions.js +14 -0
- package/dist/src/models/wrapper-deployment.js +48 -25
- package/dist/src/models/wrapper-enforcement.js +72 -0
- package/dist/src/policy/hitl-check.js +80 -0
- package/dist/src/providers/provider-definitions.js +10 -10
- package/dist/src/research/clients/arxiv.js +10 -4
- package/dist/src/research/clients/base.js +5 -4
- 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 +85 -0
- package/dist/src/research/index.js +1 -0
- package/dist/src/research/reference-match.js +89 -0
- package/dist/src/rules/activation.d.mts +2 -0
- package/dist/src/rules/activation.mjs +23 -0
- package/dist/src/rules/core-startup.d.mts +2 -0
- package/dist/src/rules/core-startup.mjs +31 -0
- package/dist/src/skills/adapters/local.js +32 -9
- package/dist/src/skills/agent-skills.js +2 -0
- package/dist/src/skills/cli-display.js +33 -0
- package/dist/src/skills/cli.js +2 -26
- package/dist/src/skills/collision-discovery.js +84 -0
- package/dist/src/skills/deployer.js +20 -75
- package/dist/src/skills/deployment-ownership.js +74 -0
- package/dist/src/skills/doctor.js +2 -2
- package/dist/src/skills/importer.js +4 -26
- package/dist/src/skills/registry.js +22 -7
- package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +3 -0
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
- package/dist/src/smiths/context-pipeline/generator.js +40 -104
- package/dist/src/smiths/context-pipeline/managed-hook.js +10 -0
- package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -3
- package/package.json +6 -2
- package/tools/agents/deploy-agents.mjs +2 -123
- package/tools/agents/providers/antigravity.mjs +4 -6
- package/tools/agents/providers/base.mjs +3 -3
- package/tools/agents/providers/claude.mjs +3 -5
- package/tools/agents/providers/codex.mjs +3 -5
- package/tools/agents/providers/context-write.mjs +12 -0
- package/tools/agents/providers/copilot.mjs +3 -5
- package/tools/agents/providers/cursor.mjs +3 -5
- package/tools/agents/providers/factory.mjs +3 -5
- package/tools/agents/providers/grok-build.mjs +17 -12
- 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 +90 -0
- package/tools/agents/providers/muse.mjs +3 -3
- package/tools/agents/providers/omp.mjs +3 -1
- package/tools/agents/providers/openclaw.mjs +3 -5
- package/tools/agents/providers/opencode.mjs +3 -5
- package/tools/agents/providers/pi.mjs +1 -1
- package/tools/agents/providers/provider-paths-staging.mjs +9 -0
- package/tools/agents/providers/rule-delivery.mjs +26 -228
- 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 +5 -7
- package/tools/agents/providers/windsurf.mjs +14 -62
- package/tools/plugin/package-plugins.mjs +2 -2
- package/tools/plugin/plugin-links.mjs +3 -0
- package/tools/skills/codex-skill-transform.mjs +232 -0
- package/tools/skills/deploy-skills-codex.mjs +8 -249
- package/tools/warp/warp-content.mjs +548 -0
|
@@ -16,8 +16,8 @@ import { existsSync, rmSync, rmdirSync } from 'fs';
|
|
|
16
16
|
import path from 'path';
|
|
17
17
|
import os from 'os';
|
|
18
18
|
import { pathToFileURL } from 'node:url';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { randomUUID } from 'node:crypto';
|
|
20
|
+
import { sameSkillOwner } from '../../providers/skill-ownership.mjs';
|
|
21
21
|
import { resolveOmpPaths } from '../../providers/omp-paths.mjs';
|
|
22
22
|
import YAML from 'yaml';
|
|
23
23
|
import { createScriptRunner } from './script-runner.js';
|
|
@@ -65,6 +65,7 @@ const PREPARABLE_BUILTIN_PROVIDERS = new Set(['claude', 'codex', 'cursor', 'herm
|
|
|
65
65
|
import { generate as generateContextFiles, discoverDeployedArtifacts, } from '../../smiths/context-pipeline/index.js';
|
|
66
66
|
import { verifyModelWrapperDeployment } from '../../models/wrapper-deployment.js';
|
|
67
67
|
import { countDeployedBundleFiles, countDeployedBundleRules } from './use-bundle-counts.js';
|
|
68
|
+
import { reconcileDeployedSkillAssets } from './use-skill-assets.js';
|
|
68
69
|
import { aggregateUseDeploymentResult, buildDryRunUseResult, renderUseDeploymentResult, verifyProviderDeployment, } from '../services/deployment-verification.js';
|
|
69
70
|
import { finalizeProviderTransformationReceipt, providerReceiptHasLocalSources, sourceVerificationsFromSignedWebRelease, } from '../../providers/transformation-receipt-integration.js';
|
|
70
71
|
import { loadResourceTrustRootFile, resolveWebRelease, } from '../../resources/web-release.js';
|
|
@@ -1090,197 +1091,9 @@ async function countBundleDeployedArtifacts(bundlePath, target, provider) {
|
|
|
1090
1091
|
agents: await countDeployedBundleFiles(bundlePath, 'agents', target, paths.agents, ['.md', '.toml']),
|
|
1091
1092
|
commands: await countDeployedBundleFiles(bundlePath, 'commands', target, paths.commands, ['.md']),
|
|
1092
1093
|
skills: await countDeployedBundleSkills(bundlePath, target, provider),
|
|
1093
|
-
rules: await countDeployedBundleRules(bundlePath, target, paths.rules),
|
|
1094
|
+
rules: await countDeployedBundleRules(bundlePath, target, paths.rules, provider),
|
|
1094
1095
|
};
|
|
1095
1096
|
}
|
|
1096
|
-
const SKILL_SUPPORT_REFERENCE = /(?:^|[\s`('"\[])((?:templates|references|scripts|assets)\/[A-Za-z0-9._@/+\-]+)(?=$|[\s`)'"\],:;])/gm;
|
|
1097
|
-
/** Copy one support file, preserving its executable bit. */
|
|
1098
|
-
async function copySkillSupportFile(source, destination, skillDir) {
|
|
1099
|
-
await fs.mkdir(path.dirname(destination), { recursive: true });
|
|
1100
|
-
await fs.copyFile(source, destination);
|
|
1101
|
-
await fs.chmod(destination, (await fs.stat(source)).mode & 0o777);
|
|
1102
|
-
// Extend the shared copier's receipt for bundle-root assets too. Adapters
|
|
1103
|
-
// without that receipt keep their own ownership and cleanup contract.
|
|
1104
|
-
if (!skillDir)
|
|
1105
|
-
return;
|
|
1106
|
-
const manifestPath = path.join(skillDir, '.aiwg-manifest.json');
|
|
1107
|
-
let manifest;
|
|
1108
|
-
try {
|
|
1109
|
-
manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
|
|
1110
|
-
}
|
|
1111
|
-
catch {
|
|
1112
|
-
return;
|
|
1113
|
-
}
|
|
1114
|
-
if (!manifest.skillSource || !manifest.managed?.['SKILL.md'])
|
|
1115
|
-
return;
|
|
1116
|
-
manifest.managed[path.relative(skillDir, destination)] = {
|
|
1117
|
-
...manifest.managed['SKILL.md'],
|
|
1118
|
-
hash: `sha256:${createHash('sha256').update(await fs.readFile(destination)).digest('hex')}`,
|
|
1119
|
-
};
|
|
1120
|
-
await fs.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* Materialize a directory-valued support-asset reference (#2503).
|
|
1124
|
-
*
|
|
1125
|
-
* Applies the same rules the single-file path applies, per entry: symlinks are
|
|
1126
|
-
* refused rather than followed (a link inside a bundle can point anywhere), and
|
|
1127
|
-
* file modes are preserved so script packs stay executable. Empty directories
|
|
1128
|
-
* are still created — a reference to an empty pack is odd but not an error.
|
|
1129
|
-
*/
|
|
1130
|
-
async function copySkillSupportTree(source, destination, sourceSkillMd, reference, deployFile, skillDir) {
|
|
1131
|
-
await fs.mkdir(destination, { recursive: true });
|
|
1132
|
-
const label = reference.replace(/\/+$/, '');
|
|
1133
|
-
const entries = await fs.readdir(source, { withFileTypes: true });
|
|
1134
|
-
for (const entry of entries) {
|
|
1135
|
-
const from = path.join(source, entry.name);
|
|
1136
|
-
const to = path.join(destination, entry.name);
|
|
1137
|
-
if (entry.isSymbolicLink()) {
|
|
1138
|
-
throw new Error(`unsafe skill support asset '${label}/${entry.name}' referenced by ${sourceSkillMd}: symbolic links are not deployed`);
|
|
1139
|
-
}
|
|
1140
|
-
if (entry.isDirectory()) {
|
|
1141
|
-
await copySkillSupportTree(from, to, sourceSkillMd, `${label}/${entry.name}`, deployFile, skillDir);
|
|
1142
|
-
continue;
|
|
1143
|
-
}
|
|
1144
|
-
if (!entry.isFile())
|
|
1145
|
-
continue;
|
|
1146
|
-
if (deployFile) {
|
|
1147
|
-
deployFile(from, to);
|
|
1148
|
-
continue;
|
|
1149
|
-
}
|
|
1150
|
-
await copySkillSupportFile(from, to, skillDir);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
/**
|
|
1154
|
-
* Skill-relative support files may live beside the skill or at the bundle root
|
|
1155
|
-
* (plugin payloads commonly share report templates). Materialize
|
|
1156
|
-
* only paths explicitly named by SKILL.md, and fail closed on missing or
|
|
1157
|
-
* unsafe sources so a deployed instruction can never point at absent assets.
|
|
1158
|
-
*/
|
|
1159
|
-
async function reconcileDeployedSkillAssets(bundlePath, target, provider, options = {}) {
|
|
1160
|
-
const strictReferences = options.strictReferences ?? true;
|
|
1161
|
-
const skillsRoot = path.join(bundlePath, 'skills');
|
|
1162
|
-
let skillDirs;
|
|
1163
|
-
try {
|
|
1164
|
-
skillDirs = (await fs.readdir(skillsRoot, { withFileTypes: true }))
|
|
1165
|
-
.filter(entry => entry.isDirectory())
|
|
1166
|
-
.map(entry => entry.name);
|
|
1167
|
-
}
|
|
1168
|
-
catch {
|
|
1169
|
-
return;
|
|
1170
|
-
}
|
|
1171
|
-
const deployRoots = provider === 'omp' && options.scope === 'user'
|
|
1172
|
-
? [path.join(resolveOmpPaths({ cwd: target }).agentDir, 'skills')]
|
|
1173
|
-
: deployedSkillRoots(target, provider);
|
|
1174
|
-
for (const skillName of skillDirs) {
|
|
1175
|
-
const sourceSkillDir = path.join(skillsRoot, skillName);
|
|
1176
|
-
const sourceSkillMd = path.join(sourceSkillDir, 'SKILL.md');
|
|
1177
|
-
let content;
|
|
1178
|
-
try {
|
|
1179
|
-
content = await fs.readFile(sourceSkillMd, 'utf8');
|
|
1180
|
-
}
|
|
1181
|
-
catch {
|
|
1182
|
-
continue;
|
|
1183
|
-
}
|
|
1184
|
-
// Check each deployed tier independently: a foreign mirror must not block
|
|
1185
|
-
// support assets for a tier already owned by this source.
|
|
1186
|
-
const ownedRoots = [];
|
|
1187
|
-
for (const root of deployRoots) {
|
|
1188
|
-
const skillDir = path.join(root, skillName);
|
|
1189
|
-
try {
|
|
1190
|
-
const manifestPath = path.join(skillDir, '.aiwg-manifest.json');
|
|
1191
|
-
const receipt = JSON.parse(await fs.readFile(manifestPath, 'utf8'));
|
|
1192
|
-
if (!canDeploySkill(receipt, sourceSkillDir, options))
|
|
1193
|
-
continue;
|
|
1194
|
-
if (!sameSkillOwner(receipt, sourceSkillDir)) {
|
|
1195
|
-
receipt.skillSource = path.resolve(sourceSkillDir);
|
|
1196
|
-
const slug = extractFrameworkSlug(sourceSkillMd);
|
|
1197
|
-
for (const record of Object.values(receipt.managed ?? {})) {
|
|
1198
|
-
if (slug)
|
|
1199
|
-
record.frameworkSlug = slug;
|
|
1200
|
-
else
|
|
1201
|
-
delete record.frameworkSlug;
|
|
1202
|
-
}
|
|
1203
|
-
await fs.writeFile(manifestPath, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
catch { /* adapters without shared ownership receipts keep their own contract */ }
|
|
1207
|
-
if (await fileExists(path.join(skillDir, 'SKILL.md')))
|
|
1208
|
-
ownedRoots.push(root);
|
|
1209
|
-
}
|
|
1210
|
-
if (ownedRoots.length === 0)
|
|
1211
|
-
continue;
|
|
1212
|
-
if (options.skipUndeployed && !(await Promise.all(ownedRoots.map(root => fileExists(path.join(root, skillName, 'SKILL.md'))))).some(Boolean))
|
|
1213
|
-
continue;
|
|
1214
|
-
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)?.[1] ?? '';
|
|
1215
|
-
const declaredEntrypoint = frontmatter
|
|
1216
|
-
.match(/^[ \t]+entrypoint:\s*["']?([^"'\s]+)["']?\s*$/m)?.[1];
|
|
1217
|
-
const declaredEntrypoints = new Set(declaredEntrypoint ? [declaredEntrypoint] : []);
|
|
1218
|
-
const references = [...new Set([
|
|
1219
|
-
...content.matchAll(SKILL_SUPPORT_REFERENCE),
|
|
1220
|
-
].map(match => match[1]).concat([...declaredEntrypoints]))];
|
|
1221
|
-
for (const relative of references) {
|
|
1222
|
-
const normalized = path.posix.normalize(relative);
|
|
1223
|
-
if (normalized !== relative || normalized.startsWith('../') || path.isAbsolute(normalized)) {
|
|
1224
|
-
throw new Error(`unsafe skill support reference '${relative}' in ${sourceSkillMd}`);
|
|
1225
|
-
}
|
|
1226
|
-
const candidates = [path.join(sourceSkillDir, normalized), path.join(bundlePath, normalized)];
|
|
1227
|
-
let source;
|
|
1228
|
-
let sourceIsDirectory = false;
|
|
1229
|
-
for (const candidate of candidates) {
|
|
1230
|
-
try {
|
|
1231
|
-
const stat = await fs.lstat(candidate);
|
|
1232
|
-
if (stat.isSymbolicLink())
|
|
1233
|
-
continue;
|
|
1234
|
-
// A reference may name a whole support directory (a templates pack,
|
|
1235
|
-
// a references folder). Rejecting those as "missing" aborted the
|
|
1236
|
-
// bundle deploy over a path that was present all along (#2503).
|
|
1237
|
-
if (stat.isFile() || stat.isDirectory()) {
|
|
1238
|
-
source = candidate;
|
|
1239
|
-
sourceIsDirectory = stat.isDirectory();
|
|
1240
|
-
break;
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
catch { /* try bundle-root fallback */ }
|
|
1244
|
-
}
|
|
1245
|
-
if (!source) {
|
|
1246
|
-
if (strictReferences || declaredEntrypoints.has(relative)) {
|
|
1247
|
-
throw new Error(`missing skill support asset '${relative}' referenced by ${sourceSkillMd}`);
|
|
1248
|
-
}
|
|
1249
|
-
continue;
|
|
1250
|
-
}
|
|
1251
|
-
if (sourceIsDirectory && declaredEntrypoints.has(relative)) {
|
|
1252
|
-
throw new Error(`skill entrypoint '${relative}' in ${sourceSkillMd} resolves to a directory; an entrypoint must be a file`);
|
|
1253
|
-
}
|
|
1254
|
-
let deployedSkillRoot;
|
|
1255
|
-
for (const root of ownedRoots) {
|
|
1256
|
-
// The deployer may select the bulk or kernel tier; use the tier that
|
|
1257
|
-
// actually contains this skill's transformed SKILL.md.
|
|
1258
|
-
if (await fileExists(path.join(root, skillName, 'SKILL.md'))) {
|
|
1259
|
-
deployedSkillRoot = root;
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
if (!deployedSkillRoot)
|
|
1264
|
-
throw new Error(`deployed skill '${skillName}' not found while reconciling support assets`);
|
|
1265
|
-
const destination = path.join(deployedSkillRoot, skillName, ...normalized.split('/'));
|
|
1266
|
-
const deployFile = provider === 'omp'
|
|
1267
|
-
? await (async () => {
|
|
1268
|
-
const adapter = await import(pathToFileURL(path.join(await getFrameworkRoot(), 'tools/agents/providers/omp.mjs')).href);
|
|
1269
|
-
return (from, to) => adapter.deploySkillSupportAsset(from, to, { quiet: true });
|
|
1270
|
-
})()
|
|
1271
|
-
: null;
|
|
1272
|
-
if (sourceIsDirectory) {
|
|
1273
|
-
await copySkillSupportTree(source, destination, sourceSkillMd, relative, deployFile, path.join(deployedSkillRoot, skillName));
|
|
1274
|
-
continue;
|
|
1275
|
-
}
|
|
1276
|
-
if (deployFile) {
|
|
1277
|
-
deployFile(source, destination);
|
|
1278
|
-
continue;
|
|
1279
|
-
}
|
|
1280
|
-
await copySkillSupportFile(source, destination, path.join(deployedSkillRoot, skillName));
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
1097
|
/**
|
|
1285
1098
|
* Managed-marker version for a project-local bundle's deployed artifacts (#2502).
|
|
1286
1099
|
*
|
|
@@ -1300,6 +1113,20 @@ function projectLocalDeployVersion(bundle) {
|
|
|
1300
1113
|
*
|
|
1301
1114
|
* @implements #1035
|
|
1302
1115
|
*/
|
|
1116
|
+
/**
|
|
1117
|
+
* First non-blank line of a captured deploy failure, so non-verbose `aiwg
|
|
1118
|
+
* use` output names the actual validation reason (#3728).
|
|
1119
|
+
*/
|
|
1120
|
+
function firstFailureLine(message) {
|
|
1121
|
+
if (!message)
|
|
1122
|
+
return '';
|
|
1123
|
+
for (const line of message.split(/\r?\n/)) {
|
|
1124
|
+
const trimmed = line.trim();
|
|
1125
|
+
if (trimmed)
|
|
1126
|
+
return trimmed;
|
|
1127
|
+
}
|
|
1128
|
+
return '';
|
|
1129
|
+
}
|
|
1303
1130
|
async function deployOneProjectLocalBundle(opts) {
|
|
1304
1131
|
const { bundle, ctx, frameworkRoot, provider, target, dryRun, verbose, quiet, modelArgs } = opts;
|
|
1305
1132
|
const sourceCounts = await countBundleSourceArtifacts(bundle.artifactPath);
|
|
@@ -1321,6 +1148,7 @@ async function deployOneProjectLocalBundle(opts) {
|
|
|
1321
1148
|
return { exitCode: 1, counts: sourceCounts };
|
|
1322
1149
|
}
|
|
1323
1150
|
let exitCode = 0;
|
|
1151
|
+
let deployFailureMessage = '';
|
|
1324
1152
|
if (artifactTotal > 0) {
|
|
1325
1153
|
const runner = createUseScriptRunner(frameworkRoot);
|
|
1326
1154
|
const args = [
|
|
@@ -1375,6 +1203,10 @@ async function deployOneProjectLocalBundle(opts) {
|
|
|
1375
1203
|
env: { AIWG_ROOT: frameworkRoot },
|
|
1376
1204
|
});
|
|
1377
1205
|
exitCode = result.exitCode;
|
|
1206
|
+
// In non-verbose mode the deployer's stderr is captured, not inherited —
|
|
1207
|
+
// keep the reason so the caller can print it instead of a bare exit code
|
|
1208
|
+
// (#3728).
|
|
1209
|
+
deployFailureMessage = result.message ?? '';
|
|
1378
1210
|
if (exitCode === 0 && !dryRun) {
|
|
1379
1211
|
try {
|
|
1380
1212
|
await reconcileDeployedSkillAssets(bundle.artifactPath, target, provider, { force: ctx.args.includes('--force') });
|
|
@@ -1404,7 +1236,7 @@ async function deployOneProjectLocalBundle(opts) {
|
|
|
1404
1236
|
? await countBundleDeployedArtifacts(bundle.artifactPath, target, provider)
|
|
1405
1237
|
: sourceCounts;
|
|
1406
1238
|
void ctx;
|
|
1407
|
-
return { exitCode, counts };
|
|
1239
|
+
return exitCode === 0 ? { exitCode, counts } : { exitCode, counts, message: deployFailureMessage };
|
|
1408
1240
|
}
|
|
1409
1241
|
/**
|
|
1410
1242
|
* Discover and deploy artifact-bearing project-local bundles from
|
|
@@ -1500,7 +1332,10 @@ async function deployProjectLocalBundles(opts) {
|
|
|
1500
1332
|
});
|
|
1501
1333
|
if (result.exitCode !== 0) {
|
|
1502
1334
|
failed++;
|
|
1503
|
-
|
|
1335
|
+
// Surface the deployer's reason (e.g. the rule frontmatter file,
|
|
1336
|
+
// field and limit) even in non-verbose output (#3728).
|
|
1337
|
+
const reason = firstFailureLine(result.message);
|
|
1338
|
+
ui.warn(`Failed to deploy project-local bundle '${bundle.id}' (exit ${result.exitCode})${reason ? `: ${reason}` : ''}`);
|
|
1504
1339
|
if (!dryRun) {
|
|
1505
1340
|
await appendProjectLocalActivity({
|
|
1506
1341
|
event: 'deploy-failed',
|
|
@@ -1741,6 +1576,8 @@ const OPENHUMAN_DEFAULT_HARNESS_PROFILE = {
|
|
|
1741
1576
|
tokenjuiceCompression: 'auto',
|
|
1742
1577
|
};
|
|
1743
1578
|
const OPENHUMAN_HARNESS_PROFILES = {
|
|
1579
|
+
'aiwg-model-explorer': { modelHint: 'efficiency', sandboxMode: 'read_only', maxTurnOutputTokens: 1000 },
|
|
1580
|
+
'aiwg-model-verifier': { modelHint: 'coding', sandboxMode: 'read_only', maxTurnOutputTokens: 1000 },
|
|
1744
1581
|
'aiwg-model-reasoning-worker': {
|
|
1745
1582
|
modelHint: 'reasoning',
|
|
1746
1583
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parsePublicDoctorFlags } from './doctor-args.js';
|
|
1
2
|
/**
|
|
2
3
|
* Utility Command Handlers
|
|
3
4
|
*
|
|
@@ -18,7 +19,6 @@ import { getFrameworkRoot } from '../../channel/manager.mjs';
|
|
|
18
19
|
import { updateInstallation } from '../../update/service.mjs';
|
|
19
20
|
import { useHandler as useFrameworkHandler } from './use.js';
|
|
20
21
|
import { projectAiwgPath } from '../../config/project-artifacts.js';
|
|
21
|
-
import { argsTerminatorIndex, hasPositionalOrSwitch, requireFlagValue, valueTokenIndexes } from '../flag-parsing.js';
|
|
22
22
|
import { checkCollisions, } from '../../smiths/skillsmith/collision-detector.js';
|
|
23
23
|
import { renderUseDeploymentResult, verifyConfiguredDeployments, } from '../services/deployment-verification.js';
|
|
24
24
|
/**
|
|
@@ -519,40 +519,14 @@ export const doctorHandler = {
|
|
|
519
519
|
async execute(ctx) {
|
|
520
520
|
// Validate before any early-return mode: deployment and user-scope doctor
|
|
521
521
|
// never invoke doctor.mjs, so they must enforce the same flag contract.
|
|
522
|
-
|
|
523
|
-
const knownFlags = new Set([
|
|
524
|
-
...valueFlags, '--all-providers', '--probe-workers', '--qualify', '--yes', '--dry-run', '--no-budget-check', '--strict-context', '--json',
|
|
525
|
-
'--decision-offload', '--deployment', '--user', '--verbose', '-v', '--project-local', '--quiet', '--help', '-h',
|
|
526
|
-
]);
|
|
527
|
-
const hasSwitch = (name) => hasPositionalOrSwitch(ctx.args, name, valueFlags);
|
|
528
|
-
const values = new Map();
|
|
522
|
+
let flags;
|
|
529
523
|
try {
|
|
530
|
-
|
|
531
|
-
values.set(flag, requireFlagValue(ctx.args, { rejectEmpty: true, precedence: 'last' }, flag));
|
|
532
|
-
}
|
|
533
|
-
const consumed = valueTokenIndexes(ctx.args, valueFlags);
|
|
534
|
-
for (let i = 0; i < argsTerminatorIndex(ctx.args); i += 1) {
|
|
535
|
-
const token = ctx.args[i];
|
|
536
|
-
if (consumed.has(i) || !token.startsWith('-'))
|
|
537
|
-
continue;
|
|
538
|
-
const name = token.split('=')[0];
|
|
539
|
-
if (!knownFlags.has(name) || (token.includes('=') && !valueFlags.includes(name))) {
|
|
540
|
-
throw new Error(`Unknown flag: ${name}`);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (hasSwitch('--decision-offload') && (hasSwitch('--probe-workers') || hasSwitch('--deployment') || hasSwitch('--user') || values.get('--scope') !== undefined)) {
|
|
544
|
-
throw new Error('--decision-offload is a separate offline mode; do not combine it with worker, deployment or user-scope checks');
|
|
545
|
-
}
|
|
546
|
-
if (['--qualify', '--cli', '--yes', '--dry-run'].some(flag => hasSwitch(flag) || values.get(flag)) && !hasSwitch('--probe-workers')) {
|
|
547
|
-
throw new Error('--qualify, --cli, --yes and --dry-run require --probe-workers');
|
|
548
|
-
}
|
|
549
|
-
if (hasSwitch('--json') && !hasSwitch('--probe-workers') && !hasSwitch('--deployment') && !hasSwitch('--decision-offload')) {
|
|
550
|
-
throw new Error('--json requires --probe-workers or --deployment or --decision-offload');
|
|
551
|
-
}
|
|
524
|
+
flags = parsePublicDoctorFlags(ctx.args);
|
|
552
525
|
}
|
|
553
526
|
catch (error) {
|
|
554
527
|
return { exitCode: 2, message: `${error instanceof Error ? error.message : String(error)}. See 'aiwg doctor --help'.` };
|
|
555
528
|
}
|
|
529
|
+
const { hasSwitch, values } = flags;
|
|
556
530
|
if (hasSwitch('--help') || hasSwitch('-h')) {
|
|
557
531
|
return { exitCode: 0, message: DOCTOR_HELP, rawOutput: true };
|
|
558
532
|
}
|
|
@@ -593,7 +567,7 @@ export const doctorHandler = {
|
|
|
593
567
|
// printed exactly one JSON document (or a usage error) on its own
|
|
594
568
|
// stdio — every section below writes human-readable text, so returning
|
|
595
569
|
// here keeps stdout to the JSON document alone.
|
|
596
|
-
if (hasSwitch('--decision-offload') || hasSwitch('--json') || hasSwitch('--qualify') || hasSwitch('--cli') || hasSwitch('--dry-run') || result.exitCode === 2)
|
|
570
|
+
if (hasSwitch('--list-approvals') || values.get('--forget-approval') || hasSwitch('--decision-offload') || hasSwitch('--json') || hasSwitch('--qualify') || hasSwitch('--cli') || hasSwitch('--dry-run') || result.exitCode === 2)
|
|
597
571
|
return result;
|
|
598
572
|
let agentSkillsFailure = false;
|
|
599
573
|
try {
|
|
@@ -6,14 +6,18 @@ import { getProjectDir, readAiwgConfig, writeAiwgConfig } from './aiwg-config.js
|
|
|
6
6
|
import { ensureAuthorization, loadHitlLayers } from '../policy/hitl-config.js';
|
|
7
7
|
import { resolveHitlAuthorization } from '../policy/hitl.js';
|
|
8
8
|
import { validateHitlPolicy } from '../policy/hitl-validation.js';
|
|
9
|
+
import { checkHitlAuthorization } from '../policy/hitl-check.js';
|
|
9
10
|
export const authorizationUsage = `aiwg config authorization (also aiwg steward authorization)
|
|
10
11
|
inspect | validate [--target DIRECTORY]
|
|
11
12
|
preview --action-file FILE [--target DIRECTORY]
|
|
13
|
+
check --action-file FILE [--target DIRECTORY]
|
|
12
14
|
enable --policy-file FILE [--target DIRECTORY]
|
|
13
15
|
revoke [--profile NAME] [--target DIRECTORY]
|
|
14
16
|
receipt --action-file FILE [--target DIRECTORY]
|
|
15
17
|
Preview is read-only. Receipt writes the decision to the existing signed effect ledger;
|
|
16
|
-
it does not perform the proposed action.
|
|
18
|
+
it does not perform the proposed action. Check writes a verified receipt before returning
|
|
19
|
+
auto-authorized; failures escalate. Action files must be host-classified descriptors,
|
|
20
|
+
never issue/model output. Action files cannot supply session authorization. Platform prompts remain authoritative.`;
|
|
17
21
|
const usageError = (message) => new AiwgError({ code: 'ERR_AUTHORIZATION_USAGE', message, exitCode: EXIT_CODES.USAGE });
|
|
18
22
|
async function jsonFile(file) {
|
|
19
23
|
try {
|
|
@@ -31,7 +35,7 @@ export async function authorizationCli(args, cwd = process.cwd()) {
|
|
|
31
35
|
const [operation, ...rest] = args;
|
|
32
36
|
const flags = {};
|
|
33
37
|
const allowed = ['--target', ...(operation === 'enable' ? ['--policy-file'] : []),
|
|
34
|
-
...(['preview', 'receipt'].includes(operation) ? ['--action-file'] : []), ...(operation === 'revoke' ? ['--profile'] : [])];
|
|
38
|
+
...(['preview', 'receipt', 'check'].includes(operation) ? ['--action-file'] : []), ...(operation === 'revoke' ? ['--profile'] : [])];
|
|
35
39
|
for (let i = 0; i < rest.length; i += 2) {
|
|
36
40
|
if (!allowed.includes(rest[i]) || !rest[i + 1] || rest[i + 1].startsWith('--') || flags[rest[i]])
|
|
37
41
|
throw usageError('Invalid authorization option');
|
|
@@ -43,10 +47,14 @@ export async function authorizationCli(args, cwd = process.cwd()) {
|
|
|
43
47
|
console.log(JSON.stringify(operation === 'inspect' ? loaded : { valid: true, layers: loaded.layers.length }, null, 2));
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
46
|
-
if (operation === 'preview' || operation === 'receipt') {
|
|
50
|
+
if (operation === 'preview' || operation === 'receipt' || operation === 'check') {
|
|
47
51
|
if (!flags['--action-file'])
|
|
48
52
|
throw usageError('--action-file is required');
|
|
49
53
|
const action = await jsonFile(resolve(cwd, flags['--action-file']));
|
|
54
|
+
if (operation === 'check') {
|
|
55
|
+
console.log(JSON.stringify(await checkHitlAuthorization(target, action), null, 2));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
50
58
|
const loaded = await loadHitlLayers(target);
|
|
51
59
|
const context = { now: new Date().toISOString(), layers: loaded.layers };
|
|
52
60
|
if (operation === 'preview')
|
|
@@ -125,8 +125,35 @@ export function resolveWorkerContextProvidersFromConfig(config) {
|
|
|
125
125
|
}
|
|
126
126
|
return { providers, skipped };
|
|
127
127
|
}
|
|
128
|
-
/**
|
|
129
|
-
|
|
128
|
+
/** Complete managed sections are required; a bootstrap marker alone is insufficient. */
|
|
129
|
+
function ruleSection(content, owner) {
|
|
130
|
+
return content.match(new RegExp(`<!--\\s*AIWG:${owner}:start\\s*-->([\\s\\S]*?)<!--\\s*AIWG:${owner}:end\\s*-->`))?.[1].trim() ?? '';
|
|
131
|
+
}
|
|
132
|
+
function readNonempty(file) {
|
|
133
|
+
try {
|
|
134
|
+
return readFileSync(file, 'utf8').trim();
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return '';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function hasRuleBootstrap(content, workdir, provider, rulesDir) {
|
|
141
|
+
// Older complete inline deployments remain usable during migration.
|
|
142
|
+
if (ruleSection(content, 'rule-startup'))
|
|
143
|
+
return true;
|
|
144
|
+
const hook = ruleSection(content, `rule-hook-${provider}`);
|
|
145
|
+
if (!ruleSection(content, 'rule-core') || !rulesDir)
|
|
146
|
+
return false;
|
|
147
|
+
const entry = path.join(rulesDir, 'RULES-INDEX.md');
|
|
148
|
+
if (!hook.includes(`\`${entry.replaceAll('\\', '/')}\``))
|
|
149
|
+
return false;
|
|
150
|
+
const indexFile = path.resolve(workdir, entry);
|
|
151
|
+
const index = readNonempty(indexFile);
|
|
152
|
+
if (!index)
|
|
153
|
+
return false;
|
|
154
|
+
return [...index.matchAll(/\]\(\.\/([^)]*\.md)\)/g)]
|
|
155
|
+
.every(match => Boolean(readNonempty(path.resolve(path.dirname(indexFile), match[1]))));
|
|
156
|
+
}
|
|
130
157
|
/**
|
|
131
158
|
* Check that a worker workdir already carries one provider's bootstrap:
|
|
132
159
|
* the kernel artifact dirs (`use all` writes kernel skills, rules,
|
|
@@ -157,8 +184,10 @@ export function workerContextBootstrapStatus({ workdir, provider }) {
|
|
|
157
184
|
catch {
|
|
158
185
|
entries = null;
|
|
159
186
|
}
|
|
160
|
-
if (!entries || entries.length === 0
|
|
187
|
+
if (!entries || entries.length === 0 || (dir === paths?.rules &&
|
|
188
|
+
!entries.some(name => /\.(md|mdc)$/.test(name) && readNonempty(path.join(absolute, name))))) {
|
|
161
189
|
missing.push(`provider dir '${dir}'`);
|
|
190
|
+
}
|
|
162
191
|
}
|
|
163
192
|
if ((definition.context?.bootstrapTargets ?? []).includes('AGENTS.md')) {
|
|
164
193
|
let content = null;
|
|
@@ -168,7 +197,7 @@ export function workerContextBootstrapStatus({ workdir, provider }) {
|
|
|
168
197
|
catch {
|
|
169
198
|
content = null;
|
|
170
199
|
}
|
|
171
|
-
if (!content || !
|
|
200
|
+
if (!content || !hasRuleBootstrap(content, workdir, definition.id, paths?.rules ?? null)) {
|
|
172
201
|
missing.push('AGENTS.md rule sections');
|
|
173
202
|
}
|
|
174
203
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Context pruning digests and shared validation errors.
|
|
2
|
+
import { sha256 } from './compile-cache/identity.js';
|
|
3
|
+
export class ContextPruningError extends Error {
|
|
4
|
+
reason;
|
|
5
|
+
constructor(message, reason) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
this.name = 'ContextPruningError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const SHA = /^sha256:[0-9a-f]{64}$/;
|
|
12
|
+
export function contextPruningDigest(value) {
|
|
13
|
+
return sha256(value);
|
|
14
|
+
}
|
|
15
|
+
/** Order-independent digest of the frozen evaluation pairs: sorted (pairId, slice) tuples. */
|
|
16
|
+
export function contextPruningPairSetDigest(pairs) {
|
|
17
|
+
const tuples = pairs.map(pair => [pair.pairId, pair.slice])
|
|
18
|
+
.sort(([a, sa], [b, sb]) => a < b ? -1 : a > b ? 1 : sa < sb ? -1 : sa > sb ? 1 : 0);
|
|
19
|
+
return contextPruningDigest({ schemaVersion: 'decision-context-pruning-pair-set/v1', pairs: tuples });
|
|
20
|
+
}
|
|
21
|
+
/** Identity of one pilot run over an ordered candidate set, optionally tied to an evaluation pair. */
|
|
22
|
+
export function contextPruningRunId(pairId, candidates) {
|
|
23
|
+
return contextPruningDigest({
|
|
24
|
+
schemaVersion: 'decision-context-pruning-run-id/v1',
|
|
25
|
+
pairId,
|
|
26
|
+
candidates: candidates.map(candidate => contextPruningDigest(candidate)),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Order-independent digest of a receipt set, for anchoring the evaluated receipts separately from the report. */
|
|
30
|
+
export function contextPruningReceiptSetDigest(receipts) {
|
|
31
|
+
return contextPruningDigest({
|
|
32
|
+
schemaVersion: 'decision-context-pruning-receipt-set/v1',
|
|
33
|
+
receipts: receipts.map(receipt => receipt.receiptDigest).sort(),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function requirePlain(value, label) {
|
|
37
|
+
if (!value || typeof value !== 'object' || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
|
|
38
|
+
throw new ContextPruningError(`${label} must be a plain object`, 'schema');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=context-pruning-common.js.map
|