@aiwg/cli 2026.11.2 → 2026.11.4
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 +3 -2
- package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +12 -9
- package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +2 -0
- package/agentic/code/addons/composition-engine/lib/runtime.mjs +5 -26
- package/agentic/code/addons/composition-engine/schemas/flow-graph.schema.json +22 -0
- package/agentic/code/providers/capability-matrix.yaml +17 -20
- package/agentic/code/providers/model-capabilities.v1.json +17 -16
- package/dist/src/a2a/hitl-authorization.js +46 -0
- package/dist/src/a2a/hitl-driver.js +5 -5
- package/dist/src/artifacts/browser-export.js +2 -0
- package/dist/src/artifacts/framework-source-digest.js +1 -1
- package/dist/src/artifacts/index-builder.js +5 -25
- package/dist/src/artifacts/index-capability.js +24 -0
- package/dist/src/artifacts/query-engine-discover-output.js +8 -3
- package/dist/src/artifacts/query-engine-rules.js +27 -9
- package/dist/src/artifacts/query-engine-scoring.js +5 -5
- package/dist/src/artifacts/query-engine-show-card.js +5 -1
- package/dist/src/artifacts/query-engine-show-load.js +1 -1
- package/dist/src/artifacts/query-engine-show.js +3 -3
- package/dist/src/artifacts/query-engine-templates.js +10 -4
- package/dist/src/artifacts/query-engine-verbose.js +18 -4
- package/dist/src/artifacts/relations-builder.js +1 -0
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/cli/handlers/checkpoint-handoff.js +2 -1
- package/dist/src/cli/handlers/dataset.js +17 -0
- package/dist/src/cli/handlers/guided-setup.js +3 -1
- package/dist/src/cli/handlers/refresh-managed-deployment.js +17 -5
- package/dist/src/cli/handlers/rules.js +1 -1
- package/dist/src/cli/handlers/sessions.js +1 -1
- package/dist/src/cli/handlers/steward.js +1 -1
- package/dist/src/cli/handlers/use.js +18 -5
- package/dist/src/cli/handlers/utility-doctor.js +5 -2
- package/dist/src/cli/handlers/workspace.js +1 -1
- package/dist/src/cli/services/deployment-probe-scope.js +40 -0
- package/dist/src/cli/services/deployment-verification.js +5 -6
- package/dist/src/config/aiwg-config.js +6 -0
- package/dist/src/config/authorization-cli.js +61 -3
- package/dist/src/config/cli-help.js +1 -1
- package/dist/src/config/cli.js +4 -2
- package/dist/src/config/decision-config.js +2 -1
- package/dist/src/config/host-resource-runtime.mjs +1 -1
- package/dist/src/config/jev-credential-reference.js +56 -0
- package/dist/src/config/user-config.js +13 -19
- package/dist/src/config/user-registry.js +9 -1
- package/dist/src/config/worker-owner-lock.js +90 -10
- package/dist/src/decision/ask.js +3 -2
- package/dist/src/decision/graph-flow-adapter.js +1 -1
- package/dist/src/decision/jev-credentials.js +22 -0
- package/dist/src/decision/offload.js +1 -1
- package/dist/src/decision/openbao-kv-resolver.mjs +96 -0
- package/dist/src/decision/openbao-runtime.js +101 -0
- package/dist/src/effects/authorization-grant.js +50 -0
- package/dist/src/effects/authorization-store.js +130 -0
- package/dist/src/effects/index.js +2 -0
- package/dist/src/effects/ledger.js +1 -0
- package/dist/src/effects/lifecycle.js +1 -1
- package/dist/src/effects/reader.js +4 -0
- package/dist/src/effects/records.js +4 -0
- package/dist/src/effects/schema.js +2 -0
- package/dist/src/extensions/claude-hooks-installer.js +7 -7
- package/dist/src/extensions/muse-managed-hooks.js +11 -0
- package/dist/src/extensions/user-hook-diagnostics.js +32 -0
- package/dist/src/extensions/verified-hook-command.js +32 -0
- package/dist/src/lint/rule-conflicts.js +52 -0
- package/dist/src/lint/runner.js +3 -0
- package/dist/src/mcp/cli.mjs +3 -1
- package/dist/src/mcp/elicitation.mjs +30 -0
- package/dist/src/mcp/grok-build-config.mjs +1 -1
- package/dist/src/mcp/muse-native-config.mjs +1 -0
- package/dist/src/mcp/server.mjs +2 -0
- package/dist/src/mcp/tools/authorization.mjs +78 -0
- package/dist/src/models/model-capabilities.v1.json +17 -16
- package/dist/src/policy/authorization-capture.js +64 -0
- package/dist/src/policy/authorization-operations.js +108 -0
- package/dist/src/policy/hitl-check.js +3 -2
- package/dist/src/policy/hitl-consume.js +14 -0
- package/dist/src/policy/hitl-durable-store.js +60 -0
- package/dist/src/policy/hitl-durable.js +60 -0
- package/dist/src/policy/hitl-receipt.js +5 -0
- package/dist/src/policy/hitl.js +44 -6
- package/dist/src/process/bounded-child-process.mjs +49 -39
- package/dist/src/providers/capability-matrix.yaml +17 -20
- package/dist/src/providers/deployment-ownership.d.mts +1 -0
- package/dist/src/providers/deployment-ownership.mjs +21 -2
- package/dist/src/providers/grok-build-headless.js +170 -77
- package/dist/src/providers/grok-build-inspect.js +1 -0
- package/dist/src/providers/grok-build-paths.js +2 -0
- package/dist/src/providers/muse-paths.js +4 -2
- package/dist/src/providers/provider-context-contracts.js +12 -4
- package/dist/src/providers/provider-definition-schema.js +6 -0
- package/dist/src/providers/provider-seeds-1.js +3 -3
- package/dist/src/providers/provider-seeds-2.js +6 -4
- package/dist/src/providers/provider-seeds-3.js +6 -6
- package/dist/src/rules/activation.d.mts +2 -0
- package/dist/src/rules/activation.mjs +16 -7
- package/dist/src/rules/inline-budget.d.mts +2 -1
- package/dist/src/rules/inline-budget.mjs +4 -2
- package/dist/src/rules/inventory.js +3 -0
- package/dist/src/rules/precedence.d.mts +6 -0
- package/dist/src/rules/precedence.mjs +49 -0
- package/dist/src/rules/project-precedence.js +73 -0
- package/dist/src/rules/rule-frontmatter.schema.json +15 -0
- package/dist/src/serve/a2a-terminal-observer.js +12 -3
- package/dist/src/serve/mission-hitl.js +20 -1
- package/dist/src/sessions/adapters/grok-build-fallback.js +33 -0
- package/dist/src/sessions/adapters/grok-build-native-records.js +64 -0
- package/dist/src/sessions/adapters/grok-build-native.js +92 -100
- package/dist/src/sessions/adapters/grok-build.js +65 -24
- package/dist/src/sessions/grok-build-cli-output.js +113 -0
- package/dist/src/sessions/grok-build-cli.js +4 -28
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +4 -3
- package/dist/src/smiths/context-pipeline/finalization.js +5 -0
- package/dist/src/smiths/context-pipeline/generator.js +1 -1
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +20 -17
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +6 -1
- package/dist/src/smiths/context-pipeline/workspace-document.js +6 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +2 -12
- package/dist/src/smiths/hook-bridge/codex-translator.js +11 -14
- package/dist/src/smiths/hook-bridge/codex-trust.js +7 -2
- package/dist/src/smiths/hook-bridge/copilot-translator.js +2 -1
- package/dist/src/smiths/hook-bridge/factory-trust.js +56 -0
- package/dist/src/smiths/hook-bridge/grok-build-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/hermes-prompt-discovery.js +78 -0
- package/dist/src/smiths/hook-bridge/hermes-translator.js +5 -3
- package/dist/src/smiths/hook-bridge/index.js +3 -1
- package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +3 -2
- package/package.json +7 -1
- package/tools/agents/deploy-agents.mjs +5 -6
- package/tools/agents/deploy-options.mjs +1 -0
- package/tools/agents/providers/base-frontmatter.mjs +3 -2
- package/tools/agents/providers/claude-post-deploy.mjs +1 -1
- package/tools/agents/providers/codex-post-deploy.mjs +1 -1
- package/tools/agents/providers/generic.mjs +66 -0
- package/tools/agents/providers/grok-build.mjs +3 -1
- package/tools/agents/providers/muse-hooks.mjs +13 -11
- package/tools/agents/providers/muse-prompt-discovery.mjs +5 -1
- package/tools/agents/providers/muse.mjs +2 -1
- package/tools/agents/providers/openclaw.mjs +2 -1
- package/tools/agents/providers/rule-deployment-prepare.mjs +5 -3
- package/tools/agents/providers/rule-deployment-state.mjs +14 -6
- package/tools/agents/providers/rule-startup.mjs +11 -10
- package/tools/agents/providers/staged-directory-reference.mjs +14 -0
- package/tools/agents/providers/user-hooks.mjs +26 -0
- package/tools/cli/authorization-health.mjs +20 -0
- package/tools/cli/decision-offload-report.mjs +2 -0
- package/tools/cli/workspace-status.mjs +7 -0
- package/tools/commands/deploy-prompts-codex.mjs +15 -1
- package/tools/plugin/package-plugins.mjs +6 -1
- package/tools/ralph-external/lib/claude-adapter.mjs +2 -2
- package/vscode-extension/schemas/aiwg.config.v1.json +20 -0
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
// Resolve governing rules and shape bound-rule checks and summaries.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { parseRuleFrontmatter } from '../rules/activation.mjs';
|
|
4
|
+
import { resolveRulePrecedence } from '../rules/precedence.mjs';
|
|
5
|
+
import { loadRulePinConfigs } from '../rules/pins.mjs';
|
|
6
|
+
import { ruleOrderingAliases } from '../rules/project-precedence.js';
|
|
2
7
|
import { minimatch } from 'minimatch';
|
|
3
8
|
import * as path from 'node:path';
|
|
4
9
|
import { inferRuleActivation } from '../rules/activation.mjs';
|
|
@@ -36,7 +41,7 @@ export function relationshipRules(entries, target, relations) {
|
|
|
36
41
|
const asMetadata = (id) => {
|
|
37
42
|
const rule = relations.index.rules[id];
|
|
38
43
|
return { path: rule.path, type: rule.type, name: rule.name, activation: rule.activation ?? undefined,
|
|
39
|
-
bound_to: rule.bound_to, ruleSummary: rule.summary, ruleEnforcement: rule.enforcement ?? undefined, rulePaths: rule.paths, triggers: rule.triggers };
|
|
44
|
+
bound_to: rule.bound_to, ruleSummary: rule.summary, ruleEnforcement: rule.enforcement ?? undefined, rulePrecedence: rule.precedence, ruleOverridable: rule.overridable, rulePaths: rule.paths, triggers: rule.triggers };
|
|
40
45
|
};
|
|
41
46
|
const key = `${target.type}:${discoveryIdForEntry(target)}`;
|
|
42
47
|
const shipped = Object.hasOwn(relations.index.targets, key)
|
|
@@ -49,7 +54,7 @@ export function relationshipRules(entries, target, relations) {
|
|
|
49
54
|
export const RULE_CHECK_OBLIGATION = 'Before governed work, fetch and follow every required rule below; a discovery summary is not the full rule.';
|
|
50
55
|
export function relationMetadata(relations) {
|
|
51
56
|
return Object.values(relations.index.rules).map(rule => ({ path: rule.path, type: rule.type, name: rule.name,
|
|
52
|
-
activation: rule.activation ?? undefined, ruleSummary: rule.summary, ruleEnforcement: rule.enforcement ?? undefined,
|
|
57
|
+
activation: rule.activation ?? undefined, ruleSummary: rule.summary, ruleEnforcement: rule.enforcement ?? undefined, rulePrecedence: rule.precedence, ruleOverridable: rule.overridable,
|
|
53
58
|
bound_to: rule.bound_to, rulePaths: rule.paths, triggers: rule.triggers }));
|
|
54
59
|
}
|
|
55
60
|
/** Post-ranking enrichment: relationship lookup never loads the full metadata index. */
|
|
@@ -108,8 +113,9 @@ export function compoundGoverningRules(entries, target, relations, phrase = '',
|
|
|
108
113
|
}
|
|
109
114
|
return [...found.values()].sort((a, b) => (a.rule.name ?? a.rule.path).localeCompare(b.rule.name ?? b.rule.path) || a.rule.path.localeCompare(b.rule.path));
|
|
110
115
|
}
|
|
111
|
-
export function boundRuleDescriptor(rule) {
|
|
116
|
+
export function boundRuleDescriptor(rule, ordering) {
|
|
112
117
|
return { name: rule.name ?? path.basename(rule.path, '.md'), activation: rule.activation ?? null, enforcement: rule.ruleEnforcement ?? null,
|
|
118
|
+
precedence: rule.rulePrecedence ?? 'medium', overridable: rule.ruleOverridable ?? true, precedence_source: 'rule', project_context: false, ...ordering,
|
|
113
119
|
summary: (rule.ruleSummary ?? '').replace(/\s+/g, ' ').trim(), show_command: `aiwg show ${rule.type} ${rule.name ?? path.basename(rule.path, '.md')} --body` };
|
|
114
120
|
}
|
|
115
121
|
/** Counts unique attached contracts; every emitted check is required irrespective of severity. */
|
|
@@ -123,10 +129,10 @@ export function governingRuleStats(governing) {
|
|
|
123
129
|
}
|
|
124
130
|
return stats;
|
|
125
131
|
}
|
|
126
|
-
export function governingRuleFields(governing) {
|
|
132
|
+
export function governingRuleFields(governing, ordering) {
|
|
127
133
|
if (!governing.length)
|
|
128
134
|
return {};
|
|
129
|
-
return { bound_rules: governing.map(({ rule }) => boundRuleDescriptor(rule)), rule_stats: governingRuleStats(governing),
|
|
135
|
+
return { bound_rules: governing.map(({ rule }) => boundRuleDescriptor(rule, ordering?.(rule))), rule_stats: governingRuleStats(governing),
|
|
130
136
|
required_rule_checks: governing.map(({ rule, applicability }) => ({ rule_id: discoveryIdForEntry(rule),
|
|
131
137
|
applicability, fetch_command: `aiwg show ${rule.type} ${discoveryIdForEntry(rule)} --body` })), rule_check_obligation: RULE_CHECK_OBLIGATION };
|
|
132
138
|
}
|
|
@@ -149,11 +155,11 @@ export function relationshipRuleStats(entries, target, relations) {
|
|
|
149
155
|
}
|
|
150
156
|
return stats;
|
|
151
157
|
}
|
|
152
|
-
export async function showBindings(entries, target, content, params, read, relations) {
|
|
158
|
+
export async function showBindings(entries, target, content, params, read, relations, ordering) {
|
|
153
159
|
const governing = compoundGoverningRules(entries, target, relations, '', false, false);
|
|
154
160
|
const rules = governing.map(item => item.rule);
|
|
155
161
|
const boundRules = await Promise.all(rules.map(async (rule) => ({
|
|
156
|
-
...boundRuleDescriptor(rule),
|
|
162
|
+
...boundRuleDescriptor(rule, ordering?.(rule)),
|
|
157
163
|
...((params.boundRuleBodies || params.withRuleBodies) ? { content: await read(rule) } : {}),
|
|
158
164
|
})));
|
|
159
165
|
// Parse the selected rule for reverse lookup, including corpus-only rules.
|
|
@@ -182,7 +188,7 @@ export async function showBindings(entries, target, content, params, read, relat
|
|
|
182
188
|
if (boundRules.length) {
|
|
183
189
|
// Cards already print these stats in the header; body/section output has no header.
|
|
184
190
|
const stats = params.body || params.sections?.length ? `${statsText(governingRuleStats(governing))}\n\n` : '';
|
|
185
|
-
text += `\n## Bound rules\n\n${RULE_CHECK_OBLIGATION}\n\n${stats}` + boundRules.map(rule => `- **${rule.name}** [${rule.activation ?? 'unknown'} / ${rule.enforcement ?? 'unknown'}]: ${rule.summary} (\`${rule.show_command}\`)`
|
|
191
|
+
text += `\n## Bound rules\n\n${RULE_CHECK_OBLIGATION}\n\n${stats}` + boundRules.map(rule => `- **${rule.name}** [${rule.activation ?? 'unknown'} / ${rule.enforcement ?? 'unknown'}; precedence ${rule.precedence}; overridable ${rule.overridable}; source ${rule.precedence_source}]: ${rule.summary} (\`${rule.show_command}\`)`
|
|
186
192
|
+ ('content' in rule ? `\n\n${rule.content}` : '')).join('\n') + '\n';
|
|
187
193
|
}
|
|
188
194
|
if (Object.keys(boundTo).length) {
|
|
@@ -192,10 +198,22 @@ export async function showBindings(entries, target, content, params, read, relat
|
|
|
192
198
|
if (boundTargets.size)
|
|
193
199
|
text += '\nResolved targets: ' + [...boundTargets.values()].map(target => `${target.type} ${target.name ?? target.id}`).join(', ') + '\n';
|
|
194
200
|
return { fields: {
|
|
195
|
-
...governingRuleFields(governing),
|
|
201
|
+
...governingRuleFields(governing, ordering),
|
|
196
202
|
...(['rule', 'behavior'].includes(target.type) ? { bound_to: boundTo, bound_targets: [...boundTargets.values()] } : {}),
|
|
197
203
|
...(boundRules.length ? { bound_rules: boundRules } : {}),
|
|
198
204
|
...(Object.keys(boundTo).length ? { bound_to: boundTo } : {}),
|
|
199
205
|
}, text };
|
|
200
206
|
}
|
|
207
|
+
/** Cards use canonical source when available, so a stale index cannot weaken a rule. */
|
|
208
|
+
export function ruleOrderingFields(cwd, root, entry, file) {
|
|
209
|
+
if (!['rule', 'behavior'].includes(entry.type))
|
|
210
|
+
return {};
|
|
211
|
+
let ordering = { precedence: entry.rulePrecedence, overridable: entry.ruleOverridable };
|
|
212
|
+
if (file && fs.existsSync(file)) {
|
|
213
|
+
const parsed = parseRuleFrontmatter(fs.readFileSync(file, 'utf8'));
|
|
214
|
+
// Discovery preserves legacy binding syntax; ordering itself is validated below.
|
|
215
|
+
ordering = parsed.data && typeof parsed.data === 'object' ? parsed.data : {};
|
|
216
|
+
}
|
|
217
|
+
return resolveRulePrecedence({ ...ordering, name: entry.name, id: discoveryIdForEntry(entry) }, loadRulePinConfigs(cwd), ruleOrderingAliases(file ?? path.resolve(root, entry.path), root, cwd));
|
|
218
|
+
}
|
|
201
219
|
//# sourceMappingURL=query-engine-rules.js.map
|
|
@@ -226,16 +226,16 @@ export function scoreEntryDetailed(entry, text, opts = {}) {
|
|
|
226
226
|
});
|
|
227
227
|
return finish(1.001, 1.001);
|
|
228
228
|
}
|
|
229
|
-
if (nearNameMatch(text, entry.name)) {
|
|
229
|
+
if (nearNameMatch(text, entry.name) || verbose?.names(entry.name)) {
|
|
230
230
|
matches.push({
|
|
231
231
|
field: 'name',
|
|
232
|
-
match: 'near-name',
|
|
232
|
+
match: verbose?.names(entry.name) ? 'contained-phrase' : 'near-name',
|
|
233
233
|
value: entry.name,
|
|
234
234
|
contribution: 0.951,
|
|
235
|
-
matched_tokens: tokens,
|
|
236
|
-
query_token_coverage: 1,
|
|
235
|
+
matched_tokens: verbose?.names(entry.name) ? tokenize(entry.name) : tokens,
|
|
236
|
+
query_token_coverage: verbose?.names(entry.name) ? tokenize(entry.name).length / tokens.length : 1,
|
|
237
237
|
});
|
|
238
|
-
return finish(0.951);
|
|
238
|
+
return finish(0.951, verbose?.names(entry.name) ? 0.951 : undefined);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
// Searchable text — joined once so per-token includes() is cheap
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { resolveRulePrecedence } from '../rules/precedence.mjs';
|
|
2
|
+
import { loadRulePinConfigs } from '../rules/pins.mjs';
|
|
3
|
+
import { ruleOrderingAliases } from '../rules/project-precedence.js';
|
|
1
4
|
// Render show metadata cards, sections, and companion resources.
|
|
2
5
|
import * as fs from 'node:fs';
|
|
3
6
|
import * as path from 'node:path';
|
|
@@ -146,6 +149,7 @@ export async function emitShowCard(cwd, aiwgRoot, entry, filePath, source, param
|
|
|
146
149
|
title: entry.title, path: filePath, description: String(data.description ?? data.summary ?? flow?.description ?? entry.capability ?? entry.ruleSummary ?? entry.summary ?? ''),
|
|
147
150
|
capability: owner ? { kind, name: owner[2] } : null, installed, kernel: entry.kernel ?? false,
|
|
148
151
|
...(['rule', 'behavior'].includes(entry.type) ? {
|
|
152
|
+
...resolveRulePrecedence({ ...data, name: entry.name, id: discoveryIdForEntry(entry) }, loadRulePinConfigs(cwd), ruleOrderingAliases(filePath, aiwgRoot ?? cwd, cwd)),
|
|
149
153
|
activation: localPin ? 'kernel' : entry.activation ?? data.activation ?? null, enforcement: data.enforcement ?? entry.ruleEnforcement ?? null,
|
|
150
154
|
bound_to: data.bound_to ?? entry.bound_to ?? {},
|
|
151
155
|
} : {}),
|
|
@@ -190,7 +194,7 @@ export async function emitShowCard(cwd, aiwgRoot, entry, filePath, source, param
|
|
|
190
194
|
if (pinNote)
|
|
191
195
|
lines.push(pinNote);
|
|
192
196
|
if ('activation' in card)
|
|
193
|
-
lines.push(`Activation: ${card.activation} | enforcement: ${card.enforcement}`, `Bound targets: ${JSON.stringify(card.bound_to)}`);
|
|
197
|
+
lines.push(`Activation: ${card.activation} | enforcement: ${card.enforcement}`, `Precedence: ${card.precedence} | overridable: ${card.overridable} | source: ${card.precedence_source} | project context: ${card.project_context}`, `Bound targets: ${JSON.stringify(card.bound_to)}`);
|
|
194
198
|
lines.push(...templateRelationLines(extra));
|
|
195
199
|
lines.push(contentNotice, bindings.text || RULE_CHECK_OBLIGATION, '\n## Outline', ...card.outline.map(section => `- ${section.heading} (${section.bytes} bytes, ${section.lines} lines)`), '\n## Resources', ...resources.map(resource => `- ${resource.path} (${resource.bytes} bytes)`), '\n## Drill in', ...Object.values(card.drill_in).flat().map(command => `- ${command}`));
|
|
196
200
|
if (card.resource)
|
|
@@ -13,7 +13,7 @@ export function resolveMetadataPath(cwd, aiwgRoot, entry) {
|
|
|
13
13
|
if (path.isAbsolute(entry.path))
|
|
14
14
|
return entry.path;
|
|
15
15
|
const normalizedPath = normalizeIndexedPath(entry.path);
|
|
16
|
-
if (aiwgRoot && normalizedPath.startsWith('agentic/code/')) {
|
|
16
|
+
if (aiwgRoot && (entry.indexScope === 'packaged' || normalizedPath.startsWith('agentic/code/'))) {
|
|
17
17
|
return path.join(aiwgRoot, normalizedPath);
|
|
18
18
|
}
|
|
19
19
|
if (entry.indexScope === 'user' && normalizedPath.startsWith('~/.aiwg/')) {
|
|
@@ -5,7 +5,7 @@ import { isArtifactInstalled } from './query-engine-installation.js';
|
|
|
5
5
|
import { findCorpusArtifact } from './query-engine-corpus.js';
|
|
6
6
|
import { buildRunHint, DEFAULT_ARTIFACT_SEARCH_BACKEND, discoveryIdForEntry, normalizeIndexedPath, } from './query-engine-entries.js';
|
|
7
7
|
import { findShowMatches } from './query-engine-matching.js';
|
|
8
|
-
import { showBindings } from './query-engine-rules.js';
|
|
8
|
+
import { showBindings, ruleOrderingFields } from './query-engine-rules.js';
|
|
9
9
|
import { emitShowCard } from './query-engine-show-card.js';
|
|
10
10
|
import { templateRelationFields } from './query-engine-templates.js';
|
|
11
11
|
import { fortemiRecordForEntry, loadShowEntries, resolveMetadataPath } from './query-engine-show-load.js';
|
|
@@ -67,7 +67,7 @@ export async function showArtifact(cwd, params) {
|
|
|
67
67
|
? `Run \`aiwg use ${corpusMatch.bundleId}\` to install this ${corpusMatch.bundleKind} into the workspace.`
|
|
68
68
|
: 'Run `aiwg index build --graph framework` to refresh the artifact index.';
|
|
69
69
|
const fallbackEntry = { path: path.relative(aiwgRoot, corpusMatch.path), type: corpusMatch.type, name: needle, title: needle };
|
|
70
|
-
const bindings = await showBindings(entries, fallbackEntry, content, params, rule => fs.readFile(resolveMetadataPath(cwd, aiwgRoot, rule), 'utf8'), relations);
|
|
70
|
+
const bindings = await showBindings(entries, fallbackEntry, content, params, rule => fs.readFile(resolveMetadataPath(cwd, aiwgRoot, rule), 'utf8'), relations, rule => ruleOrderingFields(cwd, aiwgRoot ?? cwd, rule, resolveMetadataPath(cwd, aiwgRoot, rule)));
|
|
71
71
|
await emitShowCard(cwd, aiwgRoot, fallbackEntry, corpusMatch.path, content, params, bindings, { uninstalled: !installed, installed, hint: installHint,
|
|
72
72
|
...(localPin ? { local_pin: localPin } : {}), ...templateRelationFields(fallbackEntry, relations) }, true);
|
|
73
73
|
return;
|
|
@@ -169,7 +169,7 @@ export async function showArtifact(cwd, params) {
|
|
|
169
169
|
webReleaseOptions: params.webReleaseOptions, offline: params.offline,
|
|
170
170
|
});
|
|
171
171
|
return resolved.bytes.toString('utf8');
|
|
172
|
-
}, relations);
|
|
172
|
+
}, relations, rule => ruleOrderingFields(cwd, aiwgRoot ?? cwd, rule, resourceSource === 'local' ? resolvePath(rule) : undefined));
|
|
173
173
|
const providerModels = resourceSource === 'local' ? await loadProviderModelMetadata(cwd, aiwgRoot) : null;
|
|
174
174
|
await emitShowCard(cwd, aiwgRoot, entry, filePath, content, params, bindings, {
|
|
175
175
|
...templateRelationFields(entry, relations),
|
|
@@ -25,9 +25,15 @@ export function templateRelationFields(entry, reader, limit = Infinity, includeP
|
|
|
25
25
|
}) };
|
|
26
26
|
}
|
|
27
27
|
export function templateRelationLines(fields) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
// Cards also carry strings such as run_hint and hint; only relations are lists.
|
|
29
|
+
return ['templates', 'used_by'].flatMap(key => {
|
|
30
|
+
const items = fields[key];
|
|
31
|
+
if (!Array.isArray(items) || !items.length)
|
|
32
|
+
return [];
|
|
33
|
+
return [
|
|
34
|
+
`\n## ${key === 'templates' ? 'Templates' : 'Used by'}`,
|
|
35
|
+
...items.map(item => `- ${item.name} (${item.type}): ${item.title} — \`${item.show_command}\``),
|
|
36
|
+
];
|
|
37
|
+
});
|
|
32
38
|
}
|
|
33
39
|
//# sourceMappingURL=query-engine-templates.js.map
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
// Calibrate verbose-query evidence around the leading intent and weighted token coverage.
|
|
2
|
+
function namedSubject(text, tokenize) {
|
|
3
|
+
// A command/skill named in the request is more specific than authoring vocabulary.
|
|
4
|
+
// Limit this to the leading clause so examples and trailing context cannot redirect it.
|
|
5
|
+
const leading = text.split(/[.!?;:\n]/, 1)[0];
|
|
6
|
+
const explicit = leading.match(/\b(?:command|skill)\s+(?:called|named)\s+[`"']?([a-z][a-z0-9]*(?:[-_][a-z0-9]+)*)\b/i);
|
|
7
|
+
const before = leading.match(/\b([a-z][a-z0-9]*(?:[-_][a-z0-9]+)*)[`"']?\s+(?:command|skill)\b/i);
|
|
8
|
+
const after = leading.match(/\b(?:command|skill)\s+(?:called\s+|named\s+)?[`"']?([a-z][a-z0-9]*(?:[-_][a-z0-9]+)*)\b/i);
|
|
9
|
+
return [explicit?.[1], before?.[1], after?.[1]].find(value => value && tokenize(value).length)
|
|
10
|
+
?.toLowerCase().replace(/[-_]+/g, ' ');
|
|
11
|
+
}
|
|
2
12
|
export function verboseQueryProfile(text, tokens, tokenize) {
|
|
3
|
-
|
|
4
|
-
|
|
13
|
+
const subject = namedSubject(text, tokenize);
|
|
14
|
+
const subjectTokens = new Set(subject ? tokenize(subject) : []);
|
|
15
|
+
const named = subjectTokens.size > 0;
|
|
16
|
+
// Short capability phrases retain their established lexical scores unless they name a subject.
|
|
17
|
+
if (tokens.length <= 8 && !named)
|
|
5
18
|
return undefined;
|
|
6
19
|
const prose = text.replace(/(`+)[\s\S]*?\1/g, ' ');
|
|
7
20
|
const proseTokens = new Set(tokenize(prose));
|
|
8
|
-
const leading = new Set(tokenize(prose.split(/[.!?;:\n]/, 1)[0]).slice(0, 8));
|
|
9
|
-
const contextCount = tokens.filter(token => proseTokens.has(token) && !leading.has(token)).length;
|
|
21
|
+
const leading = named ? subjectTokens : new Set(tokenize(prose.split(/[.!?;:\n]/, 1)[0]).slice(0, 8));
|
|
22
|
+
const contextCount = tokens.filter(token => (named || proseTokens.has(token)) && !leading.has(token)).length;
|
|
10
23
|
// Context gets at most a quarter of the leading clause's total weight.
|
|
11
24
|
// Code-only words carry still less signal, but remain discoverable.
|
|
12
25
|
const contextWeight = Math.min(0.25, Math.max(1, leading.size) / (4 * Math.max(1, contextCount)));
|
|
@@ -15,6 +28,7 @@ export function verboseQueryProfile(text, tokens, tokenize) {
|
|
|
15
28
|
const mass = (hits) => hits.reduce((sum, token) => sum + (weights.get(token) ?? 0), 0);
|
|
16
29
|
const total = mass(tokens);
|
|
17
30
|
return {
|
|
31
|
+
names: (name) => named && name.toLowerCase().replace(/[-_\s]+/g, ' ').trim() === subject,
|
|
18
32
|
weight: (hits) => mass(hits) / Math.max(1, hits.length),
|
|
19
33
|
coverage: (matches) => {
|
|
20
34
|
const hits = [...new Set(matches.flatMap(match => match.matched_tokens ?? tokens))];
|
|
@@ -68,6 +68,7 @@ export function buildRelations(entries) {
|
|
|
68
68
|
index.rules[id] = {
|
|
69
69
|
name: rule.name ?? slug(rule), path: rule.path, type: rule.type,
|
|
70
70
|
activation: rule.activation ?? null, enforcement: rule.ruleEnforcement ?? null,
|
|
71
|
+
precedence: rule.rulePrecedence ?? 'medium', overridable: rule.ruleOverridable ?? true,
|
|
71
72
|
summary: rule.ruleSummary ?? '', capability: capability?.id ?? null,
|
|
72
73
|
...(rule.rulePaths ? { paths: rule.rulePaths } : {}),
|
|
73
74
|
...(rule.triggers?.length ? { triggers: rule.triggers } : {}),
|
|
@@ -110,7 +110,7 @@ export const INDEX_VERSION = '1.0.0';
|
|
|
110
110
|
* making the serialized index schema incompatible; a mismatch simply forces a
|
|
111
111
|
* one-time content re-extraction during the next incremental build.
|
|
112
112
|
*/
|
|
113
|
-
export const INDEX_EXTRACTOR_VERSION = '2026.11.
|
|
113
|
+
export const INDEX_EXTRACTOR_VERSION = '2026.11.09.1';
|
|
114
114
|
/**
|
|
115
115
|
* Built-in graph definitions
|
|
116
116
|
*/
|
|
@@ -26,7 +26,8 @@ export async function writeCheckpointHandoff(frameworkRoot, checkpointsDir, reco
|
|
|
26
26
|
links: record.artifacts.length ? record.artifacts.map(path => `- ${path}`).join('\n')
|
|
27
27
|
: '- [TODO: Link relevant artifacts and references.]',
|
|
28
28
|
};
|
|
29
|
-
const
|
|
29
|
+
const body = template.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '');
|
|
30
|
+
const handoff = body.replace(/\{\{(\w+)\}\}/g, (match, key) => fields[key] ?? match);
|
|
30
31
|
const prompt = [
|
|
31
32
|
`Continue checkpoint ${record.id}${record.name ? ` (${record.name})` : ''} in ${record.cwd}.`,
|
|
32
33
|
'Read WORKSPACE.md and AIWG.md if present, then read the handoff:',
|
|
@@ -73,6 +73,22 @@ export async function executeDatasetCommand(ctx, providedService) {
|
|
|
73
73
|
exitCode: 1,
|
|
74
74
|
message: `Unknown dataset action '${action ?? ""}'.`,
|
|
75
75
|
};
|
|
76
|
+
if (action === "status" && !ids[0])
|
|
77
|
+
return {
|
|
78
|
+
exitCode: 1,
|
|
79
|
+
rawOutput: true,
|
|
80
|
+
message: presentDatasetResult({
|
|
81
|
+
schema: "aiwg.dataset-orchestration/v1",
|
|
82
|
+
action,
|
|
83
|
+
ok: false,
|
|
84
|
+
diagnostics: [{
|
|
85
|
+
code: "DATASET_ARGUMENT_REQUIRED",
|
|
86
|
+
message: "Missing required run ID. Usage: aiwg dataset status <run-id>",
|
|
87
|
+
boundary: "input",
|
|
88
|
+
retryable: false,
|
|
89
|
+
}],
|
|
90
|
+
}, ctx.args.includes("--json")),
|
|
91
|
+
};
|
|
76
92
|
const s = providedService ?? service(ctx);
|
|
77
93
|
let result;
|
|
78
94
|
switch (action) {
|
|
@@ -155,6 +171,7 @@ export const datasetHandler = {
|
|
|
155
171
|
"source/plan: --file <json>",
|
|
156
172
|
"preview: <source-id> [--count N] [--offline]",
|
|
157
173
|
"ingest: <plan-id> --digest <sha256> --idempotency-key <key> [--approve id,id]",
|
|
174
|
+
"status <run-id>: Inspect one run by its required ID.",
|
|
158
175
|
"All actions: --json for the canonical aiwg.dataset-orchestration/v1 envelope.",
|
|
159
176
|
].join("\n"),
|
|
160
177
|
};
|
|
@@ -74,7 +74,9 @@ export function parseGuidedSetupFlags(args, command) {
|
|
|
74
74
|
throw new Error('--workspace, --monorepo, --package and --scan-roots are available on setup.');
|
|
75
75
|
}
|
|
76
76
|
// The strict helpers honor the bare -- terminator, including malformed later occurrences.
|
|
77
|
-
|
|
77
|
+
// Init opts into planning only through its documented selectors; Jev options are answers.
|
|
78
|
+
const enabled = command === 'init' ? ['--scope', '--intent', '--credential'].some(name => value(name) !== undefined)
|
|
79
|
+
: NEW_FLAGS.some(name => value(name) !== undefined) || tokenStdin || verify || remove;
|
|
78
80
|
return { jev: jev ?? (remove ? 'decline' : undefined) ?? (tokenStdin || region || endpoint || verify ? 'enable' : undefined), jevOptions, scope, intent, monorepo, packageRoot, workspaces: workspaces.length ? workspaces : undefined,
|
|
79
81
|
scanRoots: scanRoots.length ? scanRoots : undefined, credentials, enabled };
|
|
80
82
|
}
|
|
@@ -4,7 +4,8 @@ import path from 'node:path';
|
|
|
4
4
|
import { isDeepStrictEqual } from 'node:util';
|
|
5
5
|
import { lt, valid } from 'semver';
|
|
6
6
|
import { managedClaudeHooks } from '../../extensions/claude-hooks-installer.js';
|
|
7
|
-
import {
|
|
7
|
+
import { verifiedHookCommand } from '../../extensions/verified-hook-command.js';
|
|
8
|
+
import { managedMuseHooks } from '../../extensions/muse-managed-hooks.js';
|
|
8
9
|
import { managedHookScriptState } from '../../extensions/managed-hook-script-state.js';
|
|
9
10
|
import { managedFactoryHooks } from '../../smiths/hook-bridge/factory-translator.js';
|
|
10
11
|
import { readFactoryDocument } from '../../smiths/hook-bridge/factory-hook-config.js';
|
|
@@ -41,7 +42,7 @@ function groups(doc, event) {
|
|
|
41
42
|
return Array.isArray(hooks?.[event]) ? hooks[event] : [];
|
|
42
43
|
}
|
|
43
44
|
async function staleHooks(projectRoot, frameworkRoot, provider) {
|
|
44
|
-
if (!['claude', 'muse', 'factory'].includes(provider))
|
|
45
|
+
if (!['claude', 'muse', 'factory', 'codex'].includes(provider))
|
|
45
46
|
return [];
|
|
46
47
|
const file = provider === 'claude' ? '.claude/settings.json' : `.${provider}/hooks.json`;
|
|
47
48
|
let doc;
|
|
@@ -53,7 +54,18 @@ async function staleHooks(projectRoot, frameworkRoot, provider) {
|
|
|
53
54
|
return [{ name: `${provider} managed hooks`, file, reason: 'unreadable' }];
|
|
54
55
|
}
|
|
55
56
|
const stale = [];
|
|
56
|
-
if (provider === '
|
|
57
|
+
if (provider === 'codex') {
|
|
58
|
+
const { sources } = await loadHookSources(frameworkRoot);
|
|
59
|
+
const source = sources.find(hook => hook.id === 'aiwg-prompt-discovery');
|
|
60
|
+
if (!source?.args?.[0])
|
|
61
|
+
return [];
|
|
62
|
+
const expected = verifiedHookCommand(projectRoot, '.codex/hooks/aiwg-prompt-discovery.cjs', await fs.readFile(source.args[0]));
|
|
63
|
+
const candidates = groups(doc, 'UserPromptSubmit').flatMap(group => group.hooks || [])
|
|
64
|
+
.filter(hook => hook._aiwg_id === source.id);
|
|
65
|
+
if (!candidates.some(hook => hook.command === expected && hook.statusMessage === 'AIWG prompt discovery'))
|
|
66
|
+
stale.push({ name: `UserPromptSubmit → ${source.id}`, file, reason: candidates.length ? 'outdated' : 'missing' });
|
|
67
|
+
}
|
|
68
|
+
else if (provider === 'factory') {
|
|
57
69
|
for (const hook of managedFactoryHooks()) {
|
|
58
70
|
const candidates = groups(doc, hook.event).flatMap(group => Array.isArray(group?.hooks) ? group.hooks : [])
|
|
59
71
|
.filter(entry => entry && (entry._aiwg_id === hook.id || entry.command === hook.command));
|
|
@@ -74,7 +86,7 @@ async function staleHooks(projectRoot, frameworkRoot, provider) {
|
|
|
74
86
|
return [];
|
|
75
87
|
throw error;
|
|
76
88
|
}
|
|
77
|
-
for (const hook of managedClaudeHooks(sourceFiles)) {
|
|
89
|
+
for (const hook of managedClaudeHooks(sourceFiles, projectRoot, source)) {
|
|
78
90
|
const candidates = groups(doc, hook.event).flatMap(group => Array.isArray(group?.hooks) ? group.hooks : [])
|
|
79
91
|
.filter(entry => entry && (entry._aiwg_id === hook.hookId ||
|
|
80
92
|
(typeof entry.command === 'string' && entry.command.includes(hook.script))));
|
|
@@ -93,7 +105,7 @@ async function staleHooks(projectRoot, frameworkRoot, provider) {
|
|
|
93
105
|
recorded = sidecar.hooks;
|
|
94
106
|
}
|
|
95
107
|
catch { /* The live document still proves canonical registrations without a sidecar. */ }
|
|
96
|
-
for (const hook of
|
|
108
|
+
for (const hook of managedMuseHooks(projectRoot, await fs.readFile(path.join(frameworkRoot, 'agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs')))) {
|
|
97
109
|
const deployed = groups(doc, hook.event);
|
|
98
110
|
if (deployed.some(group => isDeepStrictEqual(group, hook.group)))
|
|
99
111
|
continue;
|
|
@@ -77,7 +77,7 @@ export const rulesHandler = {
|
|
|
77
77
|
const { ruleInventory } = await import('../../rules/inventory.js');
|
|
78
78
|
const report = await ruleInventory(ctx.cwd, ctx.frameworkRoot, { scope: scope, capability: list('--capability'), activation, enforcement: tier, provider: values.get('--provider'), bodies: flags.has('--bodies') });
|
|
79
79
|
return { exitCode: 0, rawOutput: true, message: json ? JSON.stringify(report, null, 2) :
|
|
80
|
-
[`Scope: ${report.scope} (${report.scope_description})`, 'Per-rule delivery and session loading: unknown.', ...report.rules.map(rule => `${rule.capability}/${rule.name} [${rule.effective_activation ?? 'unconfigured'}, ${rule.enforcement ?? 'unknown'}]: ${rule.summary ?? '(no summary)'}; ${rule.fetch_command ?? 'fetch ID unknown'}${rule.content ? `\n${rule.content}` : ''}`), ...report.warnings, ...(!report.rules.length ? ['No matching rules.'] : [])].join('\n') };
|
|
80
|
+
[`Scope: ${report.scope} (${report.scope_description})`, 'Per-rule delivery and session loading: unknown.', ...report.rules.map(rule => `${rule.capability}/${rule.name} [${rule.effective_activation ?? 'unconfigured'}, ${rule.enforcement ?? 'unknown'}; precedence: ${rule.precedence}; overridable: ${rule.overridable}; source: ${rule.precedence_source}; project context: ${rule.project_context}]: ${rule.summary ?? '(no summary)'}; ${rule.fetch_command ?? 'fetch ID unknown'}${rule.content ? `\n${rule.content}` : ''}`), ...report.warnings, ...(!report.rules.length ? ['No matching rules.'] : [])].join('\n') };
|
|
81
81
|
}
|
|
82
82
|
if (values.has('--scope') || values.has('--activation') || values.has('--provider') || flags.has('--bodies'))
|
|
83
83
|
throw new Error('Inventory filters are only valid for rules inventory');
|
|
@@ -916,7 +916,7 @@ async function importSource(ctx, args) {
|
|
|
916
916
|
: isGrokbot
|
|
917
917
|
? new GrokbotSessionAdapter(limits)
|
|
918
918
|
: isGrokBuild
|
|
919
|
-
? new GrokBuildSessionAdapter(limits)
|
|
919
|
+
? new GrokBuildSessionAdapter(limits, undefined, { cwd: ctx.cwd, binary: args.values.get('--grok-bin') })
|
|
920
920
|
: isMuse
|
|
921
921
|
? new MuseSessionAdapter(limits)
|
|
922
922
|
: isPi
|
|
@@ -111,7 +111,7 @@ async function handleSteward(args, ctx) {
|
|
|
111
111
|
aiwg steward models --route --capability-type <agent|skill|rule|workflow>
|
|
112
112
|
--capability <id> --assignment <text> [--provider <name>] [--json]
|
|
113
113
|
Emit a capability-bound wrapper launch envelope
|
|
114
|
-
aiwg steward authorization
|
|
114
|
+
aiwg steward authorization HITL policy and grants: inspect/validate/preview/enable/revoke/list/show/search/explain/verify
|
|
115
115
|
aiwg steward permissions audit Find normalized-model errors and legacy grants
|
|
116
116
|
aiwg steward permissions migrate --dry-run Preview legacy permission normalization
|
|
117
117
|
aiwg steward permissions migrate --apply Back up and atomically normalize config
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ContextWriteJournal } from '../../smiths/context-pipeline/context-file-safety.js';
|
|
2
2
|
import { trackTemporaryDirectory } from '../../utils/temporary-directory.js';
|
|
3
3
|
import { codexHookTrustNextStep, readCodexHookTrust } from '../../smiths/hook-bridge/codex-trust.js';
|
|
4
|
+
import { factoryHookTrustNextStep, readFactoryHookTrust } from '../../smiths/hook-bridge/factory-trust.js';
|
|
4
5
|
/**
|
|
5
6
|
* Use Command Handler
|
|
6
7
|
*
|
|
@@ -1413,6 +1414,9 @@ export function validateUseOptions(args, preparedCapabilities = new Set()) {
|
|
|
1413
1414
|
if (USE_FLAGS_WITH_VALUES.has(arg)) {
|
|
1414
1415
|
if (!args[i + 1] || args[i + 1].startsWith('-'))
|
|
1415
1416
|
return `Missing value for option '${arg}'. See aiwg use --help.`;
|
|
1417
|
+
if ((arg === '--provider' || arg === '--platform') && args[i + 1].includes(',')) {
|
|
1418
|
+
return `Option '${arg}' accepts one provider. Use --providers for a comma-separated list. See aiwg use --help.`;
|
|
1419
|
+
}
|
|
1416
1420
|
i++;
|
|
1417
1421
|
}
|
|
1418
1422
|
else if (arg.startsWith('-') && !USE_BOOLEAN_FLAGS.has(arg)) {
|
|
@@ -1856,7 +1860,7 @@ function removeGlobalBootstrapFlags(args) {
|
|
|
1856
1860
|
const valueFlags = new Set(['--provider', '--platform', '--providers', '--scope', '--target', '--prefix']);
|
|
1857
1861
|
const booleanFlags = new Set([
|
|
1858
1862
|
'--global', '--user', '--ci-hooks-enabled', '--no-project-local',
|
|
1859
|
-
'--no-context-files', '--no-
|
|
1863
|
+
'--no-context-files', '--no-workspace-signals',
|
|
1860
1864
|
]);
|
|
1861
1865
|
for (let i = 0; i < args.length; i += 1) {
|
|
1862
1866
|
const arg = args[i];
|
|
@@ -2593,6 +2597,12 @@ export class UseHandler {
|
|
|
2593
2597
|
result.findings.push({
|
|
2594
2598
|
id: 'codex-prompt-discovery-trust', provider: 'codex', severity: 'info', message: codexTrustStep,
|
|
2595
2599
|
});
|
|
2600
|
+
const factoryTrustStep = !dryRun && result.exitCode === 0 && requestedScope === 'project' && providers.includes('factory')
|
|
2601
|
+
? factoryHookTrustNextStep(await readFactoryHookTrust(projectDir)) : '';
|
|
2602
|
+
if (factoryTrustStep)
|
|
2603
|
+
result.findings.push({
|
|
2604
|
+
id: 'factory-hook-trust', provider: 'factory', severity: 'info', message: factoryTrustStep,
|
|
2605
|
+
});
|
|
2596
2606
|
if (json) {
|
|
2597
2607
|
return { exitCode: result.exitCode, message: JSON.stringify(result, null, 2), rawOutput: true };
|
|
2598
2608
|
}
|
|
@@ -2617,7 +2627,7 @@ export class UseHandler {
|
|
|
2617
2627
|
});
|
|
2618
2628
|
return {
|
|
2619
2629
|
exitCode: result.exitCode,
|
|
2620
|
-
message: [coreResult.message, rendered, ...(previewActions ? [...previewActions].sort() : []), codexTrustStep].filter(Boolean).join('\n'),
|
|
2630
|
+
message: [coreResult.message, rendered, ...(previewActions ? [...previewActions].sort() : []), codexTrustStep, factoryTrustStep].filter(Boolean).join('\n'),
|
|
2621
2631
|
};
|
|
2622
2632
|
}
|
|
2623
2633
|
async executeCore(ctx, resolvedProviders) {
|
|
@@ -2713,7 +2723,6 @@ export class UseHandler {
|
|
|
2713
2723
|
'--target', stageRoot,
|
|
2714
2724
|
...(externalBundle ? [] : ['--no-project-local']),
|
|
2715
2725
|
'--no-context-files',
|
|
2716
|
-
'--no-hooks',
|
|
2717
2726
|
'--no-workspace-signals',
|
|
2718
2727
|
];
|
|
2719
2728
|
const result = await this.execute({ ...ctx, cwd: stageRoot, args: innerArgs });
|
|
@@ -2765,10 +2774,14 @@ export class UseHandler {
|
|
|
2765
2774
|
: null;
|
|
2766
2775
|
const projectDir = getProjectDir(ctx, remainingArgs);
|
|
2767
2776
|
let config = await readAiwgConfig(projectDir);
|
|
2768
|
-
|
|
2777
|
+
// Validate the entire selection before auto-init can persist provider IDs (#3958).
|
|
2778
|
+
{
|
|
2769
2779
|
for (const requested of configuredGlobalProviders(remainingArgs, config)) {
|
|
2770
2780
|
const resolved = await resolveProjectLocalProviderAdapter(projectDir, requested);
|
|
2771
|
-
|
|
2781
|
+
const provider = normalizeProviderDefinitionId(resolved.provider);
|
|
2782
|
+
if (!provider)
|
|
2783
|
+
return { exitCode: 1, message: unsupportedProviderMessage(requested) ?? `Unknown provider: ${requested}` };
|
|
2784
|
+
if (detectScope(remainingArgs) === 'project' && remainingArgs.includes('--scope') && provider === 'hermes') {
|
|
2772
2785
|
return { exitCode: 1, message: "Hermes does not support --scope project: it discovers skills only under HERMES_HOME/skills (default ~/.hermes/skills). Use --scope user or an isolated HERMES_HOME profile shared with Hermes." };
|
|
2773
2786
|
}
|
|
2774
2787
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Health diagnostics extracted from the utility handler collection.
|
|
2
2
|
import fsp from 'fs/promises';
|
|
3
|
+
import { diagnoseUserHookCommands } from '../../extensions/user-hook-diagnostics.js';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import { createScriptRunner } from './script-runner.js';
|
|
5
6
|
import { getFrameworkRoot } from '../../channel/manager.mjs';
|
|
@@ -95,11 +96,13 @@ async function runUserScopeDoctor(verbose) {
|
|
|
95
96
|
lines.push('── User-scope registry validation ──');
|
|
96
97
|
lines.push(`Registry path: ${userRegistryPath()}`);
|
|
97
98
|
lines.push('');
|
|
99
|
+
const hookWarnings = await diagnoseUserHookCommands();
|
|
100
|
+
lines.push(...hookWarnings.map(warning => `⚠ ${warning.message}`));
|
|
98
101
|
if (frameworks.length === 0) {
|
|
99
102
|
lines.push('No frameworks deployed at user scope. Run `aiwg use <fw> --scope user` to install.');
|
|
100
|
-
return { exitCode: 0, message: lines.join('\n') + '\n' };
|
|
103
|
+
return { exitCode: hookWarnings.length ? 1 : 0, message: lines.join('\n') + '\n' };
|
|
101
104
|
}
|
|
102
|
-
let driftCount =
|
|
105
|
+
let driftCount = hookWarnings.length;
|
|
103
106
|
let limitedCount = 0;
|
|
104
107
|
for (const [name, entry] of frameworks) {
|
|
105
108
|
lines.push(`▸ ${name} v${entry.version} [${entry.source}]`);
|
|
@@ -50,7 +50,7 @@ export const statusHandler = {
|
|
|
50
50
|
async execute(ctx) {
|
|
51
51
|
if (ctx.args.includes('--probe')) {
|
|
52
52
|
const projectRoot = statusProjectRoot(ctx.args, ctx.cwd ?? process.cwd());
|
|
53
|
-
const scope = detectScope(ctx.args);
|
|
53
|
+
const scope = ctx.args.includes('--scope') ? detectScope(ctx.args) : undefined;
|
|
54
54
|
const probe = await buildDeploymentStatusProbe(projectRoot, ctx.frameworkRoot, {
|
|
55
55
|
scope,
|
|
56
56
|
provider: statusFlagValue(ctx.args, '--provider'),
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Select registry authority for an unqualified deployment probe.
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { readAiwgConfig } from '../../config/aiwg-config.js';
|
|
6
|
+
import { inspectUserRegistry } from '../../config/user-registry.js';
|
|
7
|
+
export async function deploymentProbeScope(projectRoot, explicitScope) {
|
|
8
|
+
if (explicitScope)
|
|
9
|
+
return explicitScope;
|
|
10
|
+
// A global (user-scope) install lives in the home directory. Other projects keep project
|
|
11
|
+
// scope unless --scope user is passed, so a project without its own deployment is not
|
|
12
|
+
// reported as a broken user deployment.
|
|
13
|
+
const real = (dir) => { try {
|
|
14
|
+
return realpathSync(dir);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return path.resolve(dir);
|
|
18
|
+
} };
|
|
19
|
+
if (real(projectRoot) !== real(os.homedir()))
|
|
20
|
+
return 'project';
|
|
21
|
+
const config = await readAiwgConfig(projectRoot);
|
|
22
|
+
if (Object.values(config?.installed ?? {}).some(entry => Object.keys(entry.deployedTo ?? {}).length > 0)) {
|
|
23
|
+
return 'project';
|
|
24
|
+
}
|
|
25
|
+
const user = await inspectUserRegistry();
|
|
26
|
+
return Object.values(user.registry.installed).some(entry => Object.keys(entry?.deployedTo ?? {}).length > 0)
|
|
27
|
+
? 'user' : 'project';
|
|
28
|
+
}
|
|
29
|
+
export function deploymentProbeNextCommand(result, engaged, notConfigured) {
|
|
30
|
+
if (engaged)
|
|
31
|
+
return null;
|
|
32
|
+
if (notConfigured)
|
|
33
|
+
return 'aiwg wizard --dry-run';
|
|
34
|
+
const blocking = result.findings.filter(item => item.severity === 'blocking');
|
|
35
|
+
if (result.scope === 'user' && blocking.length > 0 && blocking.every(item => item.id.startsWith('context-'))) {
|
|
36
|
+
return result.providers.map(item => `aiwg regenerate --provider ${item.provider}`).join(' && ');
|
|
37
|
+
}
|
|
38
|
+
return `aiwg doctor --deployment${result.scope === 'user' ? ' --scope user' : ''}`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=deployment-probe-scope.js.map
|
|
@@ -14,6 +14,7 @@ import { runGrokInspect } from '../../providers/grok-build-inspect.js';
|
|
|
14
14
|
import { diagnoseIntegratedProviderTransformationReceipt } from '../../providers/transformation-receipt-integration.js';
|
|
15
15
|
import { diagnoseWorkspaceContext, providerContextContract, } from '../../smiths/context-pipeline/workspace-context.js';
|
|
16
16
|
import { USER_SCOPE_PATHS } from '../scope-resolver.js';
|
|
17
|
+
import { deploymentProbeNextCommand, deploymentProbeScope } from './deployment-probe-scope.js';
|
|
17
18
|
const RESTART_NOTICES = {
|
|
18
19
|
flue: { policy: 'restart-required',
|
|
19
20
|
action: 'Restart the Flue app before checking deployed context and skills.',
|
|
@@ -350,9 +351,6 @@ async function collectRegistryFindings(options, provider, actualCounts) {
|
|
|
350
351
|
if (recordedTotal > 0 && actualTotal === 0) {
|
|
351
352
|
findings.push(finding(provider, `registry-artifacts-missing:${bundle}`, 'blocking', `Installed state records artifacts for '${bundle}', but no managed artifacts were found for ${provider}.`, `Re-run aiwg use ${bundle} --provider ${provider} to repair the managed deployment.`, { bundle, recordedTotal, actualTotal }));
|
|
352
353
|
}
|
|
353
|
-
if (useUserRegistry && !projectRecord) {
|
|
354
|
-
findings.push(finding(provider, `project-registry-missing:${bundle}`, 'advisory', `Project registry does not describe the additive user-scope deployment for '${bundle}'.`, 'Run aiwg status --probe --json from the originating project to inspect both registries.'));
|
|
355
|
-
}
|
|
356
354
|
}
|
|
357
355
|
return findings;
|
|
358
356
|
}
|
|
@@ -594,7 +592,7 @@ export async function verifyProviderDeployment(options) {
|
|
|
594
592
|
}
|
|
595
593
|
const diagnostics = await diagnoseWorkspaceContext(options.projectRoot);
|
|
596
594
|
for (const diagnostic of diagnostics) {
|
|
597
|
-
if (
|
|
595
|
+
if (['codex-prompt-discovery-trust', 'factory-hook-trust'].includes(diagnostic.code))
|
|
598
596
|
continue; // Doctor advisory; use appends its short next step.
|
|
599
597
|
if (diagnostic.severity === 'info')
|
|
600
598
|
continue;
|
|
@@ -781,7 +779,8 @@ function probeInstallationIdentity() {
|
|
|
781
779
|
}
|
|
782
780
|
}
|
|
783
781
|
export async function buildDeploymentStatusProbe(projectRoot, frameworkRoot = process.env.AIWG_ROOT || projectRoot, filters = {}) {
|
|
784
|
-
const
|
|
782
|
+
const scope = await deploymentProbeScope(projectRoot, filters.scope);
|
|
783
|
+
const result = await verifyConfiguredDeployments(projectRoot, { ...filters, scope }, frameworkRoot);
|
|
785
784
|
const notConfigured = result.requestedBundles.length === 0
|
|
786
785
|
&& result.findings.length > 0
|
|
787
786
|
&& result.findings.every((item) => item.id === 'deployment-not-configured');
|
|
@@ -813,7 +812,7 @@ export async function buildDeploymentStatusProbe(projectRoot, frameworkRoot = pr
|
|
|
813
812
|
? 'Choose a provider and bundle to configure AIWG for this project.'
|
|
814
813
|
: 'Repair the blocking deployment findings, then run this probe again.',
|
|
815
814
|
command: 'aiwg status --probe --json',
|
|
816
|
-
next_command: engaged
|
|
815
|
+
next_command: deploymentProbeNextCommand(result, engaged, notConfigured),
|
|
817
816
|
},
|
|
818
817
|
provider_deployments: result.providers,
|
|
819
818
|
deployment_verification: result,
|