@venizia/vulcan 0.3.13 → 0.4.1
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/base/claude/remote-hosts.json +1 -1
- package/base/claude/settings.json +75 -3
- package/base/hooks/guard-git.ts +55 -0
- package/base/hooks/guard-manifest.ts +1 -1
- package/base/hooks/guard-outside.ts +66 -0
- package/base/hooks/guard-package.ts +3 -2
- package/base/hooks/guard-remote-hosts.ts +3 -2
- package/base/hooks/guard-writes.ts +1 -1
- package/base/hooks/post-tool.ts +36 -0
- package/base/hooks/prompt-submit.ts +52 -0
- package/base/hooks/stop.ts +38 -0
- package/base/hooks/subagent-start.ts +18 -0
- package/base/references/delegation-brief.md +63 -0
- package/base/references/design-pass.md +39 -0
- package/base/references/evidence.md +36 -0
- package/base/references/phase-boundaries.md +20 -0
- package/base/references/testing.md +89 -0
- package/base/rules.md +11 -2
- package/base/skills/build-a-feature/SKILL.md +49 -23
- package/base/skills/docs-update/SKILL.md +12 -1
- package/base/skills/docs-writing/SKILL.md +2 -2
- package/base/skills/docs-writing/references/agent-documents.md +53 -0
- package/base/skills/fix-a-bug/SKILL.md +84 -0
- package/base/skills/fix-a-bug/evals/evals.json +17 -0
- package/base/skills/knowledge-sync/SKILL.md +4 -1
- package/base/skills/knowledge-sync/knowledge-sync.workflow.js +10 -10
- package/base/skills/plan-a-change/SKILL.md +95 -0
- package/base/skills/plan-a-change/evals/evals.json +23 -0
- package/base/skills/plan-a-change/references/spec-card.md +39 -0
- package/base/skills/report-back/SKILL.md +112 -0
- package/base/skills/report-back/evals/evals.json +23 -0
- package/base/skills/research/SKILL.md +64 -0
- package/base/skills/research/evals/evals.json +17 -0
- package/base/skills/retro/SKILL.md +69 -0
- package/base/skills/retro/evals/evals.json +17 -0
- package/base/skills/review-a-change/SKILL.md +90 -0
- package/base/skills/review-a-change/evals/evals.json +17 -0
- package/base/skills/ship/SKILL.md +82 -0
- package/base/skills/ship/evals/evals.json +23 -0
- package/base/skills/visualize-work/SKILL.md +87 -0
- package/base/skills/visualize-work/evals/evals.json +17 -0
- package/base/skills/visualize-work/references/spec.md +65 -0
- package/package.json +4 -4
- package/src/agents/common/schema.ts +2 -2
- package/src/agents/detect.ts +5 -5
- package/src/agents/exclude.ts +3 -3
- package/src/agents/local.ts +1 -1
- package/src/agents/prompt.ts +2 -2
- package/src/agents/render.ts +2 -2
- package/src/agents/resolve.ts +6 -6
- package/src/agents/table.ts +1 -1
- package/src/commands/agents.command.ts +4 -4
- package/src/commands/clean.command.ts +72 -0
- package/src/commands/help.command.ts +11 -0
- package/src/commands/index.ts +6 -0
- package/src/commands/init.command.ts +4 -1
- package/src/commands/profile.command.ts +255 -0
- package/src/commands/sync.command.ts +6 -4
- package/src/commands/upgrade.command.ts +1 -1
- package/src/commands/visualize.command.ts +107 -0
- package/src/common/constants.ts +23 -0
- package/src/config/common/constants.ts +2 -0
- package/src/config/loader.ts +4 -4
- package/src/config/packages.ts +1 -1
- package/src/config/schema.ts +16 -5
- package/src/create/add-app.ts +15 -15
- package/src/create/add-lib.ts +7 -7
- package/src/create/bunfig.ts +1 -1
- package/src/create/dockerignore.ts +4 -4
- package/src/create/init-monorepo.ts +3 -1
- package/src/create/lib-preset.ts +1 -1
- package/src/create/names.ts +7 -6
- package/src/create/next.ts +4 -4
- package/src/create/preset-menu.ts +4 -4
- package/src/create/preset.ts +3 -3
- package/src/create/scratch.ts +27 -6
- package/src/create/workspace.ts +11 -11
- package/src/doctor/checks.ts +231 -45
- package/src/doctor/common/constants.ts +4 -0
- package/src/doctor/makefile.ts +3 -3
- package/src/doctor/runner.ts +16 -1
- package/src/doctor/skills.ts +8 -8
- package/src/doctor/tags.ts +5 -5
- package/src/hooks/common/constants.ts +29 -0
- package/src/hooks/common/types.ts +20 -0
- package/src/hooks/decision.ts +15 -0
- package/src/hooks/guard-git.ts +288 -0
- package/src/hooks/guard-manifest.ts +1 -1
- package/src/hooks/guard-outside.ts +399 -0
- package/src/hooks/guard-package.ts +4 -4
- package/src/hooks/guard-writes.ts +5 -5
- package/src/hooks/index.ts +6 -0
- package/src/hooks/owner-reply.ts +148 -0
- package/src/hooks/post-tool.ts +137 -0
- package/src/hooks/remote-hosts.ts +25 -23
- package/src/hooks/session-digest.ts +24 -4
- package/src/hooks/shell.ts +325 -0
- package/src/hooks/subagent-card.ts +32 -0
- package/src/init/scaffold.ts +6 -6
- package/src/local/clean.ts +88 -0
- package/src/local/constants.ts +50 -0
- package/src/local/format.ts +25 -0
- package/src/local/index.ts +4 -0
- package/src/local/scan.ts +368 -0
- package/src/manifest/render.ts +1 -1
- package/src/owner/card.ts +85 -0
- package/src/owner/constants.ts +105 -0
- package/src/owner/index.ts +8 -0
- package/src/owner/profile.ts +123 -0
- package/src/owner/schema.ts +147 -0
- package/src/owner/shape.ts +380 -0
- package/src/owner/survey.ts +289 -0
- package/src/owner/view.ts +76 -0
- package/src/owner/violations.ts +202 -0
- package/src/router.ts +18 -1
- package/src/rules/base.ts +1 -1
- package/src/rules/parser.ts +5 -5
- package/src/signals/claims.ts +71 -0
- package/src/signals/classify.ts +132 -0
- package/src/signals/constants.ts +88 -0
- package/src/signals/index.ts +5 -0
- package/src/signals/loop.ts +46 -0
- package/src/signals/state.ts +276 -0
- package/src/sync/agent-files.ts +4 -4
- package/src/sync/agent-removal.ts +6 -6
- package/src/sync/atlas-block.ts +1 -1
- package/src/sync/base-rules.ts +1 -1
- package/src/sync/exclude.ts +9 -9
- package/src/sync/local-choice.ts +35 -5
- package/src/sync/planner.ts +16 -16
- package/src/sync/prune.ts +3 -3
- package/src/sync/settings.ts +15 -15
- package/src/ui/prompt.ts +3 -3
- package/src/visualize/assets.ts +80 -0
- package/src/visualize/constants.ts +126 -0
- package/src/visualize/index.ts +6 -0
- package/src/visualize/layout.ts +107 -0
- package/src/visualize/page.ts +211 -0
- package/src/visualize/render.ts +161 -0
- package/src/visualize/schema.ts +178 -0
- package/src/visualize/validate.ts +127 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendSignal,
|
|
3
|
+
callKeyOf,
|
|
4
|
+
EntryKinds,
|
|
5
|
+
gatesOf,
|
|
6
|
+
isPublicProbe,
|
|
7
|
+
loopOf,
|
|
8
|
+
readSignals,
|
|
9
|
+
SignalConstants,
|
|
10
|
+
watchedFileOf,
|
|
11
|
+
WatchedKinds,
|
|
12
|
+
} from '../signals/index.ts';
|
|
13
|
+
import type { ISignalState } from '../signals/index.ts';
|
|
14
|
+
|
|
15
|
+
const FILE_TOOLS = new Set(['Write', 'Edit', 'MultiEdit', 'NotebookEdit']);
|
|
16
|
+
const FAILURE_EVENT = 'PostToolUseFailure';
|
|
17
|
+
|
|
18
|
+
const recordOf = (opts: { value: unknown }): Record<string, unknown> =>
|
|
19
|
+
typeof opts.value === 'object' && opts.value !== null && !Array.isArray(opts.value)
|
|
20
|
+
? Object.fromEntries(Object.entries(opts.value))
|
|
21
|
+
: {};
|
|
22
|
+
|
|
23
|
+
const stringOf = (opts: { value: unknown }): string =>
|
|
24
|
+
typeof opts.value === 'string' ? opts.value : '';
|
|
25
|
+
|
|
26
|
+
/** Whether the tool reported a failure in its own result: an exit code, an error flag, an interruption. */
|
|
27
|
+
const reportsFailure = (opts: { response: Record<string, unknown> }): boolean => {
|
|
28
|
+
const { response } = opts;
|
|
29
|
+
const code = response['exitCode'] ?? response['exit_code'];
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
(typeof code === 'number' && code !== 0) ||
|
|
33
|
+
response['is_error'] === true ||
|
|
34
|
+
response['isError'] === true ||
|
|
35
|
+
response['interrupted'] === true
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* What the model is told after a tool call, and the line it adds to the turn's notes: whether the turn
|
|
41
|
+
* asked public state, which gate commands ran and passed or failed, the calls themselves, so a loop shows.
|
|
42
|
+
* It speaks only to say that the agent seems stuck, or that a skill or rules file was just changed; it
|
|
43
|
+
* never blocks. Notes are kept per session, and a loop per agent. Input it cannot read gives no answer.
|
|
44
|
+
*/
|
|
45
|
+
export const buildPostToolOutput = (opts: {
|
|
46
|
+
projectRoot: string;
|
|
47
|
+
input: unknown;
|
|
48
|
+
now?: number;
|
|
49
|
+
}): Record<string, unknown> | undefined => {
|
|
50
|
+
const input = recordOf({ value: opts.input });
|
|
51
|
+
const tool = stringOf({ value: input['tool_name'] });
|
|
52
|
+
|
|
53
|
+
if (tool === '') {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const now = opts.now ?? Date.now();
|
|
58
|
+
const session = stringOf({ value: input['session_id'] });
|
|
59
|
+
const agent = stringOf({ value: input['agent_id'] });
|
|
60
|
+
const toolInput = recordOf({ value: input['tool_input'] });
|
|
61
|
+
const event = input['hook_event_name'] === FAILURE_EVENT ? FAILURE_EVENT : 'PostToolUse';
|
|
62
|
+
const isOk =
|
|
63
|
+
event !== FAILURE_EVENT &&
|
|
64
|
+
!reportsFailure({ response: recordOf({ value: input['tool_response'] }) });
|
|
65
|
+
const command = stringOf({ value: toolInput['command'] });
|
|
66
|
+
// A command sent to the background has not finished: its result is not known here.
|
|
67
|
+
const isBackground = toolInput['run_in_background'] === true;
|
|
68
|
+
const path = stringOf({ value: toolInput['file_path'] });
|
|
69
|
+
const gates = tool === 'Bash' && !isBackground ? gatesOf({ command }) : [];
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
appendSignal({
|
|
73
|
+
root: opts.projectRoot,
|
|
74
|
+
entry: {
|
|
75
|
+
kind: EntryKinds.CALL,
|
|
76
|
+
session,
|
|
77
|
+
agent,
|
|
78
|
+
at: now,
|
|
79
|
+
tool,
|
|
80
|
+
key: callKeyOf({ tool, input: toolInput }),
|
|
81
|
+
isOk,
|
|
82
|
+
isProbe: tool === 'Bash' && isOk && isPublicProbe({ command }),
|
|
83
|
+
gates,
|
|
84
|
+
isEdit: FILE_TOOLS.has(tool) && isOk,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
} catch {
|
|
88
|
+
// The notes are advisory: a failed write costs a hint, never the call.
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const state: ISignalState = readSignals({ root: opts.projectRoot, session, agent });
|
|
92
|
+
const lines: string[] = [];
|
|
93
|
+
const say = (name: string, line: string): void => {
|
|
94
|
+
const last = state.notedAt[name];
|
|
95
|
+
|
|
96
|
+
if (last !== undefined && now - last < SignalConstants.DEBOUNCE_MS) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
lines.push(line);
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
appendSignal({ root: opts.projectRoot, entry: { kind: EntryKinds.NOTE, at: now, name } });
|
|
104
|
+
} catch {
|
|
105
|
+
// Without the note the advisory may repeat; nothing worse.
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
if (FILE_TOOLS.has(tool) && isOk) {
|
|
110
|
+
const watched = watchedFileOf({ path });
|
|
111
|
+
|
|
112
|
+
if (watched?.kind === WatchedKinds.SKILL) {
|
|
113
|
+
say(
|
|
114
|
+
`skill:${watched.name}`,
|
|
115
|
+
`You changed the skill ${watched.name}. Before you rely on it, run its evals (evals/evals.json) and read the transcripts: a skill change that no eval saw is a guess.`,
|
|
116
|
+
);
|
|
117
|
+
} else if (watched?.kind === WatchedKinds.RULES) {
|
|
118
|
+
say(
|
|
119
|
+
`rules:${watched.name}`,
|
|
120
|
+
'You changed a rules file. A rule needs an observed failure and a named enforcement, and a mechanical check where one is possible (the retro skill states the admission bar).',
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const loop = loopOf({ events: state.events });
|
|
126
|
+
|
|
127
|
+
if (loop !== undefined) {
|
|
128
|
+
say(
|
|
129
|
+
`loop:${agent}`,
|
|
130
|
+
`Loop check: ${loop}. Stop repeating it: read the error, change the approach (the fix-a-bug skill builds the loop first), or ask the owner.`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return lines.length === 0
|
|
135
|
+
? undefined
|
|
136
|
+
: { hookSpecificOutput: { hookEventName: event, additionalContext: lines.join(' ') } };
|
|
137
|
+
};
|
|
@@ -55,7 +55,7 @@ const normalizeVariable = (opts: { host: string }): string =>
|
|
|
55
55
|
export const matchesHost = (opts: { host: string; entries: string[] }): boolean => {
|
|
56
56
|
const host = normalizeVariable({ host: opts.host.toLowerCase() });
|
|
57
57
|
|
|
58
|
-
return opts.entries.some(entry => {
|
|
58
|
+
return opts.entries.some((entry) => {
|
|
59
59
|
const wanted = normalizeVariable({ host: entry.toLowerCase() });
|
|
60
60
|
|
|
61
61
|
if (!wanted.includes(WILDCARD)) {
|
|
@@ -71,7 +71,7 @@ export const matchesHost = (opts: { host: string; entries: string[] }): boolean
|
|
|
71
71
|
|
|
72
72
|
const pattern = wanted
|
|
73
73
|
.split(WILDCARD)
|
|
74
|
-
.map(part => part.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&'))
|
|
74
|
+
.map((part) => part.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&'))
|
|
75
75
|
.join('[a-z0-9._-]*');
|
|
76
76
|
|
|
77
77
|
return new RegExp(`^${pattern}$`).test(host);
|
|
@@ -82,8 +82,8 @@ export const matchesHost = (opts: { host: string; entries: string[] }): boolean
|
|
|
82
82
|
export const parseTrustedList = (opts: { text: string }): string[] =>
|
|
83
83
|
opts.text
|
|
84
84
|
.split('\n')
|
|
85
|
-
.map(line => line.replace(/#.*$/, '').trim())
|
|
86
|
-
.filter(line => line !== '');
|
|
85
|
+
.map((line) => line.replace(/#.*$/, '').trim())
|
|
86
|
+
.filter((line) => line !== '');
|
|
87
87
|
|
|
88
88
|
// --- reading a command ---
|
|
89
89
|
|
|
@@ -342,7 +342,7 @@ const optionEffect = (opts: { letter: string; value: string }): IOptionEffect =>
|
|
|
342
342
|
const { letter, value } = opts;
|
|
343
343
|
|
|
344
344
|
if (letter === 'J') {
|
|
345
|
-
return { hosts: value.split(',').map(jump => hostOf({ value: jump.replace(/:\d+$/, '') })) };
|
|
345
|
+
return { hosts: value.split(',').map((jump) => hostOf({ value: jump.replace(/:\d+$/, '') })) };
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
if (letter === 'F' || letter === 'S') {
|
|
@@ -365,7 +365,9 @@ const optionEffect = (opts: { letter: string; value: string }): IOptionEffect =>
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
if (key.toLowerCase() === 'proxyjump' && setting.toLowerCase() !== 'none') {
|
|
368
|
-
return {
|
|
368
|
+
return {
|
|
369
|
+
hosts: setting.split(',').map((jump) => hostOf({ value: jump.replace(/:\d+$/, '') })),
|
|
370
|
+
};
|
|
369
371
|
}
|
|
370
372
|
|
|
371
373
|
return { hosts: key.toLowerCase() === 'hostname' ? [hostOf({ value: setting })] : [] };
|
|
@@ -442,7 +444,7 @@ const analyzeSsh = (opts: { program: string; words: string[] }): IFinding => {
|
|
|
442
444
|
return unreadable({ why: `${opts.program} names no destination` });
|
|
443
445
|
}
|
|
444
446
|
|
|
445
|
-
hosts.push(...positionals.map(positional => hostOf({ value: positional })));
|
|
447
|
+
hosts.push(...positionals.map((positional) => hostOf({ value: positional })));
|
|
446
448
|
|
|
447
449
|
return {
|
|
448
450
|
hosts,
|
|
@@ -538,11 +540,11 @@ const analyzeCopy = (opts: { program: string; words: string[] }): IFinding => {
|
|
|
538
540
|
positionals.push(word);
|
|
539
541
|
}
|
|
540
542
|
|
|
541
|
-
const specs = positionals.map(positional => copySpecHost({ word: positional }));
|
|
543
|
+
const specs = positionals.map((positional) => copySpecHost({ word: positional }));
|
|
542
544
|
|
|
543
|
-
hosts.push(...specs.flatMap(spec => (spec === undefined ? [] : [spec])));
|
|
545
|
+
hosts.push(...specs.flatMap((spec) => (spec === undefined ? [] : [spec])));
|
|
544
546
|
|
|
545
|
-
const safe = flags.every(flag => (scp ? SCP_SAFE_FLAGS : RSYNC_SAFE_FLAGS).test(flag));
|
|
547
|
+
const safe = flags.every((flag) => (scp ? SCP_SAFE_FLAGS : RSYNC_SAFE_FLAGS).test(flag));
|
|
546
548
|
const [source = '', target = ''] = positionals;
|
|
547
549
|
|
|
548
550
|
return {
|
|
@@ -563,7 +565,7 @@ const analyzeCopy = (opts: { program: string; words: string[] }): IFinding => {
|
|
|
563
565
|
const optionValues = (opts: { words: string[]; names: string[] }): string[] =>
|
|
564
566
|
opts.words.flatMap((word, index) => {
|
|
565
567
|
const name = opts.names.find(
|
|
566
|
-
candidate => word === candidate || word.startsWith(`${candidate}=`),
|
|
568
|
+
(candidate) => word === candidate || word.startsWith(`${candidate}=`),
|
|
567
569
|
);
|
|
568
570
|
|
|
569
571
|
if (name === undefined) {
|
|
@@ -574,7 +576,7 @@ const optionValues = (opts: { words: string[]; names: string[] }): string[] =>
|
|
|
574
576
|
});
|
|
575
577
|
|
|
576
578
|
const analyzeKubernetes = (opts: { program: string; words: string[] }): IFinding => {
|
|
577
|
-
if (opts.words.some(word => word === '--kubeconfig' || word.startsWith('--kubeconfig='))) {
|
|
579
|
+
if (opts.words.some((word) => word === '--kubeconfig' || word.startsWith('--kubeconfig='))) {
|
|
578
580
|
return unreadable({ why: '--kubeconfig points at contexts this guard cannot read' });
|
|
579
581
|
}
|
|
580
582
|
|
|
@@ -587,7 +589,7 @@ const analyzeKubernetes = (opts: { program: string; words: string[] }): IFinding
|
|
|
587
589
|
};
|
|
588
590
|
}
|
|
589
591
|
|
|
590
|
-
const hosts = targets.map(target =>
|
|
592
|
+
const hosts = targets.map((target) =>
|
|
591
593
|
target.includes('://') ? new URL(target).hostname : target.toLowerCase(),
|
|
592
594
|
);
|
|
593
595
|
const contexts = optionValues({ words: opts.words, names: ['--context'] });
|
|
@@ -612,7 +614,7 @@ const analyzeKubernetes = (opts: { program: string; words: string[] }): IFinding
|
|
|
612
614
|
contexts.length === 1 &&
|
|
613
615
|
targets.length === 1 &&
|
|
614
616
|
KUBECTL_READ_VERBS.has(verb) &&
|
|
615
|
-
rest.every(word => KUBECTL_SAFE_WORD.test(word)),
|
|
617
|
+
rest.every((word) => KUBECTL_SAFE_WORD.test(word)),
|
|
616
618
|
redirect: false,
|
|
617
619
|
};
|
|
618
620
|
};
|
|
@@ -643,7 +645,7 @@ const analyzeNetwork = (opts: { words: string[] }): IFinding => {
|
|
|
643
645
|
|
|
644
646
|
/** `curl`, `wget`, `http`: a URL or bare address names a host; only a listed one matters. */
|
|
645
647
|
const analyzeHttp = (opts: { words: string[] }): IFinding => {
|
|
646
|
-
const hosts = opts.words.slice(1).flatMap(word => {
|
|
648
|
+
const hosts = opts.words.slice(1).flatMap((word) => {
|
|
647
649
|
const candidate = /\s/.test(word) ? /[a-z][a-z0-9+.-]*:\/\/\S*/i.exec(word)?.[0] : word;
|
|
648
650
|
|
|
649
651
|
if (candidate === undefined || (candidate.startsWith('-') && !candidate.includes('://'))) {
|
|
@@ -754,7 +756,7 @@ const analyzeWords = (opts: {
|
|
|
754
756
|
return opts.depth > MAXIMUM_DEPTH ? [unreadable({ why: 'the command nests too deeply' })] : [];
|
|
755
757
|
}
|
|
756
758
|
|
|
757
|
-
if (program === 'command' && words.some(word => word === '-v' || word === '-V')) {
|
|
759
|
+
if (program === 'command' && words.some((word) => word === '-v' || word === '-V')) {
|
|
758
760
|
return [];
|
|
759
761
|
}
|
|
760
762
|
|
|
@@ -789,14 +791,14 @@ const analyzeWords = (opts: {
|
|
|
789
791
|
}
|
|
790
792
|
|
|
791
793
|
if (program === 'find') {
|
|
792
|
-
const start = words.findIndex(word => ['-exec', '-execdir', '-ok', '-okdir'].includes(word));
|
|
794
|
+
const start = words.findIndex((word) => ['-exec', '-execdir', '-ok', '-okdir'].includes(word));
|
|
793
795
|
|
|
794
796
|
if (start === -1) {
|
|
795
797
|
return [];
|
|
796
798
|
}
|
|
797
799
|
|
|
798
800
|
const tail = words.slice(start + 1);
|
|
799
|
-
const end = tail.findIndex(word => word === ';' || word === '+');
|
|
801
|
+
const end = tail.findIndex((word) => word === ';' || word === '+');
|
|
800
802
|
|
|
801
803
|
return analyzeWords({
|
|
802
804
|
words: end === -1 ? tail : tail.slice(0, end),
|
|
@@ -820,7 +822,7 @@ const analyzeWords = (opts: {
|
|
|
820
822
|
? []
|
|
821
823
|
: opts
|
|
822
824
|
.recurse({ command: finding.remote.join(' '), depth: opts.depth + 1 })
|
|
823
|
-
.filter(inner => inner.ambient !== true);
|
|
825
|
+
.filter((inner) => inner.ambient !== true);
|
|
824
826
|
|
|
825
827
|
return [finding, ...nested];
|
|
826
828
|
}
|
|
@@ -843,7 +845,7 @@ const analyzeWords = (opts: {
|
|
|
843
845
|
};
|
|
844
846
|
|
|
845
847
|
const analyzeCommand = (opts: { command: string; depth: number }): IFinding[] =>
|
|
846
|
-
tokenize({ command: opts.command }).flatMap(segment => {
|
|
848
|
+
tokenize({ command: opts.command }).flatMap((segment) => {
|
|
847
849
|
const findings = analyzeWords({
|
|
848
850
|
words: segment.words,
|
|
849
851
|
depth: opts.depth,
|
|
@@ -913,10 +915,10 @@ export const inspectRemoteCommand = (opts: {
|
|
|
913
915
|
}
|
|
914
916
|
}
|
|
915
917
|
|
|
916
|
-
const devices = [...command.matchAll(DEVICE_HOST)].map(match =>
|
|
918
|
+
const devices = [...command.matchAll(DEVICE_HOST)].map((match) =>
|
|
917
919
|
hostOf({ value: match[1] ?? '' }),
|
|
918
920
|
);
|
|
919
|
-
const urls = [...command.matchAll(URL_HOST)].map(match => hostOf({ value: match[1] ?? '' }));
|
|
921
|
+
const urls = [...command.matchAll(URL_HOST)].map((match) => hostOf({ value: match[1] ?? '' }));
|
|
920
922
|
|
|
921
923
|
for (const host of [...devices, ...urls]) {
|
|
922
924
|
if (!matchesHost({ host, entries: policy.trusted })) {
|
|
@@ -939,7 +941,7 @@ export const buildRemoteDecision = (opts: { hits: IWriteHit[] }) => ({
|
|
|
939
941
|
permissionDecision: HookConstants.GUARD_DECISION,
|
|
940
942
|
permissionDecisionReason: [
|
|
941
943
|
'This command may reach a remote host the project has not listed:',
|
|
942
|
-
...opts.hits.map(hit => ` - ${hit.message}`),
|
|
944
|
+
...opts.hits.map((hit) => ` - ${hit.message}`),
|
|
943
945
|
'',
|
|
944
946
|
'Read on the host, never edit, restart or copy onto it. Produce the command and hand it over.',
|
|
945
947
|
].join('\n'),
|
|
@@ -2,6 +2,13 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { basename, join } from 'node:path';
|
|
3
3
|
import { BASE_DIRECTORY, ProjectLayout } from '../common/index.ts';
|
|
4
4
|
import { ConfigConstants, loadConfig } from '../config/index.ts';
|
|
5
|
+
import {
|
|
6
|
+
OWNER_SCHEMA,
|
|
7
|
+
readProfile,
|
|
8
|
+
renderOwnerShapeCard,
|
|
9
|
+
renderProfileCard,
|
|
10
|
+
resolveOwnerView,
|
|
11
|
+
} from '../owner/index.ts';
|
|
5
12
|
import { extractRuleRows, parseRuleIds, readSlots, RuleConstants } from '../rules/index.ts';
|
|
6
13
|
|
|
7
14
|
/** A project row whose first cell lists IDs - `| V-W-02, V-W-03 |` - elaborates those base rules. */
|
|
@@ -16,7 +23,7 @@ const TABLE_HEADER = ['| ID | Rule | Enforced by |', '|----|------|-------------
|
|
|
16
23
|
/** Each listed ID's row, plain or bold (`| **W-00** |`), quoted from its rule file so it cannot drift. */
|
|
17
24
|
const selectRows = (opts: { rows: string[]; ids: string[] }): string[] =>
|
|
18
25
|
opts.ids
|
|
19
|
-
.map(id => opts.rows.find(row => parseRuleIds({ markdown: row })[0] === id))
|
|
26
|
+
.map((id) => opts.rows.find((row) => parseRuleIds({ markdown: row })[0] === id))
|
|
20
27
|
.filter((row): row is string => row !== undefined);
|
|
21
28
|
|
|
22
29
|
const readText = (opts: { file: string }): string =>
|
|
@@ -49,7 +56,7 @@ export const buildSessionDigest = async (opts: { projectRoot: string }): Promise
|
|
|
49
56
|
const projectText = readText({ file: join(opts.projectRoot, '.agents', 'rules.md') });
|
|
50
57
|
const projectRows = projectText
|
|
51
58
|
.split('\n')
|
|
52
|
-
.filter(line => extractRuleRows({ markdown: line }).length > 0 || ID_LIST_ROW.test(line));
|
|
59
|
+
.filter((line) => extractRuleRows({ markdown: line }).length > 0 || ID_LIST_ROW.test(line));
|
|
53
60
|
const minimap = MINIMAP.exec(projectText)?.[1].trim();
|
|
54
61
|
const loaded = await loadConfig({ root: opts.projectRoot });
|
|
55
62
|
const choices = loaded.ok ? loaded.config.rules : {};
|
|
@@ -77,18 +84,31 @@ export const buildSessionDigest = async (opts: { projectRoot: string }): Promise
|
|
|
77
84
|
project: loaded.ok
|
|
78
85
|
? (loaded.config.name ?? basename(opts.projectRoot))
|
|
79
86
|
: basename(opts.projectRoot),
|
|
80
|
-
sources: loaded.ok ? loaded.config.atlas.sources.map(source => source.name) : [],
|
|
87
|
+
sources: loaded.ok ? loaded.config.atlas.sources.map((source) => source.name) : [],
|
|
81
88
|
}),
|
|
82
89
|
'## Write boundaries',
|
|
83
90
|
'',
|
|
84
91
|
...TABLE_HEADER,
|
|
85
|
-
...baseRows.filter(row => row.startsWith(`| ${RuleConstants.BASE_NAMESPACE}W-`)),
|
|
92
|
+
...baseRows.filter((row) => row.startsWith(`| ${RuleConstants.BASE_NAMESPACE}W-`)),
|
|
86
93
|
'',
|
|
87
94
|
"## This project's slot choices",
|
|
88
95
|
'',
|
|
89
96
|
...slotRows,
|
|
90
97
|
];
|
|
91
98
|
|
|
99
|
+
const profile = readProfile({ root: opts.projectRoot });
|
|
100
|
+
const view = resolveOwnerView({
|
|
101
|
+
owner: loaded.ok ? loaded.config.owner : OWNER_SCHEMA.parse(undefined),
|
|
102
|
+
profile: profile.ok ? profile.profile : undefined,
|
|
103
|
+
});
|
|
104
|
+
const profileCard = renderProfileCard({ view });
|
|
105
|
+
|
|
106
|
+
lines.push('', ...renderOwnerShapeCard({ view }));
|
|
107
|
+
|
|
108
|
+
if (profileCard.length > 0) {
|
|
109
|
+
lines.push('', ...profileCard);
|
|
110
|
+
}
|
|
111
|
+
|
|
92
112
|
if (projectRows.length > 0) {
|
|
93
113
|
lines.push('', "## This project's own rules", '', ...TABLE_HEADER, ...projectRows);
|
|
94
114
|
}
|