@aiwg/cli 2026.11.3 → 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 +15 -18
- 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/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 +1 -2
- 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 +4 -5
- 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/host-resource-runtime.mjs +1 -1
- package/dist/src/config/user-registry.js +9 -1
- package/dist/src/config/worker-owner-lock.js +90 -10
- package/dist/src/decision/graph-flow-adapter.js +1 -1
- 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/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 +15 -18
- 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 +2 -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/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/workspace-status.mjs +7 -0
- package/tools/commands/deploy-prompts-codex.mjs +15 -1
- package/vscode-extension/schemas/aiwg.config.v1.json +20 -0
|
@@ -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:',
|
|
@@ -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
|
|
@@ -1860,7 +1860,7 @@ function removeGlobalBootstrapFlags(args) {
|
|
|
1860
1860
|
const valueFlags = new Set(['--provider', '--platform', '--providers', '--scope', '--target', '--prefix']);
|
|
1861
1861
|
const booleanFlags = new Set([
|
|
1862
1862
|
'--global', '--user', '--ci-hooks-enabled', '--no-project-local',
|
|
1863
|
-
'--no-context-files', '--no-
|
|
1863
|
+
'--no-context-files', '--no-workspace-signals',
|
|
1864
1864
|
]);
|
|
1865
1865
|
for (let i = 0; i < args.length; i += 1) {
|
|
1866
1866
|
const arg = args[i];
|
|
@@ -2723,7 +2723,6 @@ export class UseHandler {
|
|
|
2723
2723
|
'--target', stageRoot,
|
|
2724
2724
|
...(externalBundle ? [] : ['--no-project-local']),
|
|
2725
2725
|
'--no-context-files',
|
|
2726
|
-
'--no-hooks',
|
|
2727
2726
|
'--no-workspace-signals',
|
|
2728
2727
|
];
|
|
2729
2728
|
const result = await this.execute({ ...ctx, cwd: stageRoot, args: innerArgs });
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -993,12 +993,15 @@ export async function readAiwgConfigCandidate(projectDir) {
|
|
|
993
993
|
if (authorizationErrors.length > 0) {
|
|
994
994
|
throw new Error(`Invalid .aiwg/aiwg.config:\n${authorizationErrors.map(item => item.message).join('\n')}`);
|
|
995
995
|
}
|
|
996
|
+
// Lazy: rule precedence loads the rule schema, which config readers should not pay for.
|
|
997
|
+
const { validateProjectRulePrecedence } = await import('../rules/project-precedence.js');
|
|
996
998
|
const threatAssessmentErrors = [
|
|
997
999
|
...validateThreatAssessmentConfig(parsed.security?.threatAssessment),
|
|
998
1000
|
...validateProjectConfig(parsed.project),
|
|
999
1001
|
...validateDeliverySettings(parsed),
|
|
1000
1002
|
...validateParallelismConfig(parsed.parallelism),
|
|
1001
1003
|
...validateDecisionConfig(parsed.decision),
|
|
1004
|
+
...validateProjectRulePrecedence(projectDir, parsed),
|
|
1002
1005
|
...validateRulePinCapabilities(parsed.rules, installedRuleCapabilities(loadRulePinConfigs(projectDir, parsed)), loadRulePinConfigs(projectDir, parsed).user.rules?.pin_groups),
|
|
1003
1006
|
];
|
|
1004
1007
|
if (threatAssessmentErrors.length > 0) {
|
|
@@ -1083,12 +1086,15 @@ async function writeAiwgConfigUnlocked(projectDir, config) {
|
|
|
1083
1086
|
config = { ...config, rules: { ...config.rules, pin_groups: pinGroups, always_load: selectors } };
|
|
1084
1087
|
console.warn(`Uninstalled ${removed.join(', ')}: their rules leave the effective pinned set; retired project capability selectors/groups. User pins remain visible as inactive warnings.`);
|
|
1085
1088
|
}
|
|
1089
|
+
// Lazy: rule precedence loads the rule schema, which config readers should not pay for.
|
|
1090
|
+
const { validateProjectRulePrecedence } = await import('../rules/project-precedence.js');
|
|
1086
1091
|
const threatAssessmentErrors = [
|
|
1087
1092
|
...validateThreatAssessmentConfig(config.security?.threatAssessment),
|
|
1088
1093
|
...validateProjectConfig(config.project),
|
|
1089
1094
|
...validateDeliverySettings(config),
|
|
1090
1095
|
...validateParallelismConfig(config.parallelism),
|
|
1091
1096
|
...validateDecisionConfig(config.decision),
|
|
1097
|
+
...validateProjectRulePrecedence(projectDir, config),
|
|
1092
1098
|
...validateRulePinCapabilities(config.rules, installedRuleCapabilities(loadRulePinConfigs(projectDir, config)), loadRulePinConfigs(projectDir, config).user.rules?.pin_groups),
|
|
1093
1099
|
];
|
|
1094
1100
|
if (threatAssessmentErrors.length > 0) {
|
|
@@ -7,6 +7,7 @@ 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
9
|
import { checkHitlAuthorization } from '../policy/hitl-check.js';
|
|
10
|
+
import { listAuthorizationGrants, showAuthorizationGrant, searchAuthorizationGrants, explainAuthorization, revokeAuthorizationGrant } from '../policy/authorization-operations.js';
|
|
10
11
|
export const authorizationUsage = `aiwg config authorization (also aiwg steward authorization)
|
|
11
12
|
inspect | validate [--target DIRECTORY]
|
|
12
13
|
preview --action-file FILE [--target DIRECTORY]
|
|
@@ -14,10 +15,22 @@ export const authorizationUsage = `aiwg config authorization (also aiwg steward
|
|
|
14
15
|
enable --policy-file FILE [--target DIRECTORY]
|
|
15
16
|
revoke [--profile NAME] [--target DIRECTORY]
|
|
16
17
|
receipt --action-file FILE [--target DIRECTORY]
|
|
18
|
+
list [--active|--expired|--revoked] [--target DIRECTORY]
|
|
19
|
+
show <grantId> | search "<text>" [--target DIRECTORY]
|
|
20
|
+
explain --action-file FILE [--target DIRECTORY]
|
|
21
|
+
revoke <grantId> [--target DIRECTORY]
|
|
22
|
+
verify [--target DIRECTORY]
|
|
23
|
+
All operations accept --json; operator lookup output is JSON by default.
|
|
24
|
+
Search ranks up to 20 matches by token/field overlap, then grant/effect ID.
|
|
25
|
+
Explain is read-only: no receipts, uses, or index repairs.
|
|
26
|
+
Verify checks signed grant records and rebuilds/diffs their private descriptor index;
|
|
27
|
+
integrity failures exit 6. Missing indexes are rebuilt from verified records.
|
|
17
28
|
Preview is read-only. Receipt writes the decision to the existing signed effect ledger;
|
|
18
29
|
it does not perform the proposed action. Check writes a verified receipt before returning
|
|
19
30
|
auto-authorized; failures escalate. Action files must be host-classified descriptors,
|
|
20
|
-
never issue/model output.
|
|
31
|
+
never issue/model output. Check looks up verified durable grants before asking and
|
|
32
|
+
reports the nearest grant's differing fields when scope does not match.
|
|
33
|
+
Action files cannot supply session authorization. Platform prompts remain authoritative.`;
|
|
21
34
|
const usageError = (message) => new AiwgError({ code: 'ERR_AUTHORIZATION_USAGE', message, exitCode: EXIT_CODES.USAGE });
|
|
22
35
|
async function jsonFile(file) {
|
|
23
36
|
try {
|
|
@@ -33,16 +46,61 @@ export async function authorizationCli(args, cwd = process.cwd()) {
|
|
|
33
46
|
return;
|
|
34
47
|
}
|
|
35
48
|
const [operation, ...rest] = args;
|
|
49
|
+
let operand;
|
|
50
|
+
if (['show', 'search', 'revoke'].includes(operation) && rest[0] && !rest[0].startsWith('--'))
|
|
51
|
+
operand = rest.shift();
|
|
36
52
|
const flags = {};
|
|
37
53
|
const allowed = ['--target', ...(operation === 'enable' ? ['--policy-file'] : []),
|
|
38
|
-
...(['preview', 'receipt', 'check'].includes(operation) ? ['--action-file'] : []),
|
|
54
|
+
...(['preview', 'receipt', 'check', 'explain'].includes(operation) ? ['--action-file'] : []),
|
|
39
55
|
...(operation === 'check' ? ['--receipt-file', '--effect-id'] : []), ...(operation === 'revoke' ? ['--profile'] : [])];
|
|
40
|
-
for (let i = 0; i < rest.length; i
|
|
56
|
+
for (let i = 0; i < rest.length; i++) {
|
|
57
|
+
if (['--json', ...(operation === 'list' ? ['--active', '--expired', '--revoked'] : [])].includes(rest[i])) {
|
|
58
|
+
if (flags[rest[i]])
|
|
59
|
+
throw usageError('Invalid authorization option');
|
|
60
|
+
flags[rest[i]] = 'true';
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
41
63
|
if (!allowed.includes(rest[i]) || !rest[i + 1] || rest[i + 1].startsWith('--') || flags[rest[i]])
|
|
42
64
|
throw usageError('Invalid authorization option');
|
|
43
65
|
flags[rest[i]] = rest[i + 1];
|
|
66
|
+
i++;
|
|
44
67
|
}
|
|
45
68
|
const target = resolve(getProjectDir({ cwd }, rest));
|
|
69
|
+
if (['list', 'show', 'search', 'explain'].includes(operation) || (operation === 'revoke' && operand)) {
|
|
70
|
+
let result;
|
|
71
|
+
if (operation === 'list') {
|
|
72
|
+
const selected = ['active', 'expired', 'revoked'].filter(s => flags[`--${s}`]);
|
|
73
|
+
if (selected.length > 1)
|
|
74
|
+
throw usageError('Choose one grant status filter');
|
|
75
|
+
result = await listAuthorizationGrants(target, selected[0]);
|
|
76
|
+
}
|
|
77
|
+
else if (operation === 'explain') {
|
|
78
|
+
if (!flags['--action-file'])
|
|
79
|
+
throw usageError('--action-file is required');
|
|
80
|
+
result = await explainAuthorization(target, await jsonFile(resolve(cwd, flags['--action-file'])));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
if (!operand)
|
|
84
|
+
throw usageError('A grant ID or search text is required');
|
|
85
|
+
if (operation === 'revoke' && flags['--profile'])
|
|
86
|
+
throw usageError('Grant ID and --profile cannot be combined');
|
|
87
|
+
result = operation === 'show' ? await showAuthorizationGrant(target, operand)
|
|
88
|
+
: operation === 'search' ? await searchAuthorizationGrants(target, operand) : await revokeAuthorizationGrant(target, operand);
|
|
89
|
+
}
|
|
90
|
+
console.log(JSON.stringify(result, null, 2));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (operation === 'verify') {
|
|
94
|
+
const { effectSession } = await import('../effects/host.js');
|
|
95
|
+
const { openEffectLedger } = await import('../effects/ledger.js');
|
|
96
|
+
const { verifyAuthorizationGrants } = await import('../effects/authorization-store.js');
|
|
97
|
+
const session = await effectSession(target, 'custom');
|
|
98
|
+
const result = await verifyAuthorizationGrants(openEffectLedger({ projectDir: target, scope: session.scope, writer: 'cli' }));
|
|
99
|
+
console.log(JSON.stringify(result, null, 2));
|
|
100
|
+
if (!result.ok)
|
|
101
|
+
throw new AiwgError({ code: 'ERR_AUTHORIZATION_INTEGRITY', message: 'Authorization ledger verification failed', exitCode: result.exitCode });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
46
104
|
if (operation === 'inspect' || operation === 'validate') {
|
|
47
105
|
const loaded = await loadHitlLayers(target);
|
|
48
106
|
console.log(JSON.stringify(operation === 'inspect' ? loaded : { valid: true, layers: loaded.layers.length }, null, 2));
|
|
@@ -17,7 +17,7 @@ Subcommands:
|
|
|
17
17
|
path Print config directory path
|
|
18
18
|
edit Open config in $EDITOR/$VISUAL (requires a terminal)
|
|
19
19
|
edit --print-path Print the config file path instead of opening an editor
|
|
20
|
-
authorization Inspect/validate/preview/enable/revoke bounded HITL policy
|
|
20
|
+
authorization Inspect/validate/preview/enable/revoke bounded HITL policy; list/show/search/explain/verify grants
|
|
21
21
|
gitignore Show/check/fix .gitignore AIWG entries
|
|
22
22
|
|
|
23
23
|
Reviewed worker policy pair (project scope, no prompts):
|
package/dist/src/config/cli.js
CHANGED
|
@@ -501,7 +501,8 @@ async function handleValidate(config, args) {
|
|
|
501
501
|
try {
|
|
502
502
|
const { loadRulePinConfigs, installedRuleCapabilities, validateRulePinCapabilities } = await import('../rules/pins.mjs');
|
|
503
503
|
const configs = loadRulePinConfigs(process.cwd(), undefined, config.getPath());
|
|
504
|
-
|
|
504
|
+
const { validateProjectRulePrecedence } = await import('../rules/project-precedence.js');
|
|
505
|
+
for (const message of [...validateRulePinCapabilities(configs.user.rules, installedRuleCapabilities(configs), configs.project.rules?.pin_groups), ...validateProjectRulePrecedence(process.cwd(), configs.user, 'user', config.getPath())]) {
|
|
505
506
|
issues.push({ file: 'aiwg.config', severity: 'error', message });
|
|
506
507
|
}
|
|
507
508
|
}
|
|
@@ -919,7 +920,8 @@ export async function setRuleConfigKey(cwd, source, key, raw, userConfigDir) {
|
|
|
919
920
|
value = raw;
|
|
920
921
|
}
|
|
921
922
|
setDottedPath(configs.user, key, value);
|
|
922
|
-
const
|
|
923
|
+
const { validateProjectRulePrecedence } = await import('../rules/project-precedence.js');
|
|
924
|
+
const errors = [...validateRulePinCapabilities(configs.user.rules, installedRuleCapabilities(configs), configs.project.rules?.pin_groups), ...validateProjectRulePrecedence(cwd, configs.user, 'user', userConfigDir)];
|
|
923
925
|
if (errors.length)
|
|
924
926
|
throw new Error(errors.join('\n'));
|
|
925
927
|
const file = rulePinConfigPath(cwd, 'user', userConfigDir);
|
|
@@ -58,7 +58,7 @@ function listWorkerUnits({ spawn = spawnSync } = {}) {
|
|
|
58
58
|
try {
|
|
59
59
|
const result = spawn('systemctl', ['--user', 'list-units', '--type=service',
|
|
60
60
|
'--state=running,activating', '--no-legend', '--plain', 'aiwg-worker-*'],
|
|
61
|
-
{ encoding: 'utf8', timeout: 1000 });
|
|
61
|
+
{ encoding: 'utf8', timeout: 1000, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
62
62
|
if (result.error || result.status !== 0) return undefined;
|
|
63
63
|
return [...new Set(String(result.stdout ?? '').split('\n')
|
|
64
64
|
.map(line => /^(aiwg-worker-[^\s]+\.service)\s/.exec(line.trim())?.[1]).filter(Boolean))];
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* --scope user` works from any cwd.
|
|
13
13
|
*/
|
|
14
14
|
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
15
|
-
import { dirname } from 'node:path';
|
|
15
|
+
import { dirname, resolve } from 'node:path';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
16
17
|
import { userScopeConfigPath } from '../cli/scope-resolver.js';
|
|
17
18
|
/**
|
|
18
19
|
* Path to ~/.aiwg/installed.json. Distinct from `userScopeConfigPath()`
|
|
@@ -76,6 +77,13 @@ export async function inspectUserRegistry() {
|
|
|
76
77
|
export async function readUserRegistry() {
|
|
77
78
|
return (await inspectUserRegistry()).registry;
|
|
78
79
|
}
|
|
80
|
+
/** User receipts can describe project-relative provider trees only at HOME. */
|
|
81
|
+
export async function homeDeploymentReceipts(projectRoot) {
|
|
82
|
+
if (resolve(projectRoot) !== resolve(homedir()))
|
|
83
|
+
return [];
|
|
84
|
+
const registry = await readUserRegistry();
|
|
85
|
+
return Object.entries(registry.installed).map(([name, entry]) => [`user:${name}`, entry]);
|
|
86
|
+
}
|
|
79
87
|
/**
|
|
80
88
|
* Persist the user registry. Creates the parent directory if missing.
|
|
81
89
|
*/
|