@venizia/vulcan 0.4.10-2 → 0.4.10-21
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/README.md +30 -23
- package/base/checks/wiki-source-links.ts +17 -1
- package/base/claude/events.json +1 -11
- package/base/claude/settings.json +5 -76
- package/base/extensions/vulcan-guards.ts +81 -18
- package/base/hooks/guard-git.ts +95 -19
- package/base/hooks/guard-outside.ts +163 -43
- package/base/hooks/guard-writes.ts +15 -36
- package/base/hooks/session-start.ts +1 -1
- package/base/make/vulcan.mk +8 -5
- package/base/packs/venizia.md +16 -0
- package/base/references/delegation-brief.md +3 -5
- package/base/references/testing.md +1 -9
- package/base/rules.md +33 -38
- package/base/skills/build-a-feature/SKILL.md +4 -4
- package/base/skills/docs-update/SKILL.md +19 -8
- package/base/skills/fix-a-bug/SKILL.md +4 -2
- package/base/skills/plan-a-change/SKILL.md +1 -1
- package/base/skills/research/SKILL.md +1 -1
- package/base/skills/retro/SKILL.md +2 -2
- package/base/skills/review-a-change/SKILL.md +1 -1
- package/base/skills/visualize-work/SKILL.md +3 -3
- package/base/skills/visualize-work/references/spec.md +6 -3
- package/base/templates/AGENTS.md +9 -7
- package/base/templates/board.html +10 -110
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +8 -31
- package/src/agents/codex-hooks.ts +1 -1
- package/src/agents/generated-block.ts +52 -0
- package/src/agents/hooks-json.ts +22 -3
- package/src/agents/index.ts +2 -0
- package/src/agents/render.ts +15 -2
- package/src/agents/resolve.ts +1 -0
- package/src/agents/rules-block.ts +92 -0
- package/src/board/command.ts +92 -30
- package/src/board/common/constants.ts +26 -0
- package/src/board/common/types.ts +10 -3
- package/src/board/fold.ts +1 -1
- package/src/board/github.ts +1 -2
- package/src/board/gitlab.ts +436 -0
- package/src/board/index.ts +1 -0
- package/src/board/logo.ts +49 -0
- package/src/board/open-file.ts +110 -0
- package/src/board/page.ts +57 -5
- package/src/board/schema.ts +4 -1
- package/src/board/server.ts +87 -3
- package/src/board/settings.ts +21 -24
- package/src/commands/changelog.command.ts +40 -0
- package/src/commands/clean.command.ts +6 -1
- package/src/commands/help.command.ts +2 -63
- package/src/commands/index.ts +6 -1
- package/src/commands/migrate.command.ts +71 -0
- package/src/commands/profile.command.ts +1 -1
- package/src/commands/runners.command.ts +43 -0
- package/src/commands/sync.command.ts +8 -4
- package/src/commands/table.ts +362 -0
- package/src/commit/check.ts +1 -0
- package/src/commit/common/constants.ts +4 -0
- package/src/commit/hook.ts +112 -8
- package/src/common/constants.ts +11 -9
- package/src/common/env-variables.ts +41 -0
- package/src/common/index.ts +1 -0
- package/src/common/layout-folder.ts +3 -4
- package/src/common/record.ts +5 -0
- package/src/config/common/constants.ts +28 -22
- package/src/config/loader.ts +22 -0
- package/src/config/schema.ts +330 -146
- package/src/create/add-app.ts +7 -2
- package/src/create/add-lib.ts +2 -4
- package/src/create/common/constants.ts +5 -3
- package/src/create/preset.ts +1 -0
- package/src/create/scratch.ts +2 -1
- package/src/doctor/checks.ts +277 -448
- package/src/doctor/common/constants.ts +27 -19
- package/src/doctor/private-values.ts +4 -1
- package/src/doctor/runner.ts +5 -12
- package/src/doctor/schema.ts +4 -0
- package/src/events/common/actor-names.ts +12 -0
- package/src/events/common/constants.ts +65 -38
- package/src/events/common/index.ts +1 -0
- package/src/events/hook.ts +5 -56
- package/src/events/text.ts +41 -6
- package/src/hooks/command-view.ts +80 -19
- package/src/hooks/common/constants.ts +26 -17
- package/src/hooks/common/types.ts +13 -24
- package/src/hooks/decision.ts +30 -12
- package/src/hooks/git-queries.ts +113 -0
- package/src/hooks/guard-git.ts +76 -24
- package/src/hooks/guard-outside.ts +334 -311
- package/src/hooks/guard-runner.ts +206 -0
- package/src/hooks/guard-writes.ts +87 -184
- package/src/hooks/hook-input.ts +57 -0
- package/src/hooks/index.ts +3 -6
- package/src/hooks/link-makers.ts +315 -0
- package/src/hooks/package-runners.ts +268 -0
- package/src/hooks/project-guards.ts +81 -44
- package/src/hooks/project-tmp.ts +39 -4
- package/src/hooks/runner-scan.ts +257 -0
- package/src/hooks/script-runners.ts +400 -0
- package/src/hooks/session-digest.ts +27 -117
- package/src/hooks/shell-folders.ts +760 -0
- package/src/hooks/shell-writes.ts +646 -0
- package/src/hooks/shell.ts +1421 -194
- package/src/hooks/subagent-card.ts +2 -2
- package/src/hooks/write-commands.ts +898 -0
- package/src/init/scaffold.ts +2 -3
- package/src/local/auto-clean.ts +2 -1
- package/src/local/browser-socket.ts +33 -0
- package/src/local/clean.ts +37 -6
- package/src/local/constants.ts +15 -1
- package/src/local/index.ts +1 -0
- package/src/local/scan.ts +41 -10
- package/src/manifest/render.ts +84 -30
- package/src/owner/constants.ts +4 -5
- package/src/owner/index.ts +0 -2
- package/src/owner/profile.ts +1 -0
- package/src/owner/schema.ts +51 -27
- package/src/owner/survey.ts +0 -3
- package/src/owner/view.ts +0 -9
- package/src/router.ts +8 -132
- package/src/rules/base.ts +12 -7
- package/src/rules/index.ts +1 -0
- package/src/rules/packs.ts +44 -0
- package/src/runners/check.ts +130 -0
- package/src/skills/frontmatter.ts +1 -0
- package/src/sync/agents-block.ts +104 -0
- package/src/sync/base-rules.ts +3 -3
- package/src/sync/claude-launch.ts +12 -12
- package/src/sync/common/constants.ts +0 -2
- package/src/sync/index.ts +1 -1
- package/src/sync/local-choice.ts +32 -3
- package/src/sync/planner.ts +2 -15
- package/src/sync/settings.ts +0 -17
- package/src/theme/index.ts +1 -0
- package/src/theme/tokens.ts +410 -0
- package/src/ui/prompt.ts +1 -0
- package/src/visualize/architecture.ts +504 -0
- package/src/visualize/assets.ts +41 -30
- package/src/visualize/compare-render.ts +22 -24
- package/src/visualize/constants.ts +27 -0
- package/src/visualize/diagrams.ts +13 -121
- package/src/visualize/kinds-render.ts +2 -2
- package/src/visualize/kinds-schema.ts +49 -0
- package/src/visualize/labels-vi.ts +25 -0
- package/src/visualize/labels.ts +2 -0
- package/src/visualize/layout.ts +415 -66
- package/src/visualize/page.ts +82 -15
- package/src/visualize/render.ts +2 -1
- package/src/visualize/schema.ts +29 -1
- package/src/visualize/sections.ts +78 -9
- package/src/visualize/theme.ts +49 -18
- package/src/wiki/anchors.ts +1 -0
- package/src/wiki/command.ts +10 -3
- package/src/wiki/source-links.ts +57 -18
- package/base/ci-global.json +0 -13
- package/base/claude/remote-hosts.json +0 -15
- package/base/hooks/guard-manifest.ts +0 -27
- package/base/hooks/guard-package.ts +0 -30
- package/base/hooks/guard-remote-hosts.ts +0 -70
- package/base/hooks/guard-scripting.ts +0 -32
- package/base/hooks/post-tool.ts +0 -37
- package/base/hooks/prompt-submit.ts +0 -54
- package/base/hooks/stop.ts +0 -40
- package/base/skills/build-a-feature/evals/evals.json +0 -29
- package/base/skills/docs-update/evals/evals.json +0 -23
- package/base/skills/docs-writing/evals/evals.json +0 -17
- package/base/skills/fix-a-bug/evals/evals.json +0 -17
- package/base/skills/knowledge-sync/SKILL.md +0 -81
- package/base/skills/knowledge-sync/knowledge-sync.workflow.js +0 -291
- package/base/skills/knowledge-sync/references/workflow.md +0 -44
- package/base/skills/plan-a-change/evals/evals.json +0 -47
- package/base/skills/report-back/evals/evals.json +0 -23
- package/base/skills/research/evals/evals.json +0 -17
- package/base/skills/retro/evals/evals.json +0 -17
- package/base/skills/review-a-change/evals/evals.json +0 -17
- package/base/skills/ship/evals/evals.json +0 -23
- package/base/skills/visualize-work/evals/evals.json +0 -17
- package/base/templates/ci/github-actions.yml +0 -75
- package/base/templates/ci/gitlab-ci.yml +0 -52
- package/base/templates/trusted-hosts.local.example +0 -11
- package/src/ci/affected.ts +0 -176
- package/src/ci/command.ts +0 -166
- package/src/ci/common/constants.ts +0 -76
- package/src/ci/common/index.ts +0 -2
- package/src/ci/common/types.ts +0 -37
- package/src/ci/git.ts +0 -72
- package/src/ci/global.ts +0 -48
- package/src/ci/graph.ts +0 -43
- package/src/ci/index.ts +0 -7
- package/src/ci/workspace.ts +0 -119
- package/src/commands/ci.command.ts +0 -4
- package/src/hooks/guard-manifest.ts +0 -109
- package/src/hooks/guard-package.ts +0 -226
- package/src/hooks/guard-scripting.ts +0 -36
- package/src/hooks/host-pattern.ts +0 -17
- package/src/hooks/owner-reply.ts +0 -162
- package/src/hooks/post-tool.ts +0 -138
- package/src/hooks/remote-hosts.ts +0 -1013
- package/src/hooks/trusted-scripts.ts +0 -212
- package/src/owner/shape.ts +0 -496
- package/src/owner/violations.ts +0 -332
- package/src/signals/claims.ts +0 -73
- package/src/signals/classify.ts +0 -137
- package/src/signals/constants.ts +0 -88
- package/src/signals/index.ts +0 -5
- package/src/signals/loop.ts +0 -48
- package/src/signals/state.ts +0 -271
- package/src/sync/atlas-block.ts +0 -56
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { PackageRunners } from './package-runners.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How a program that runs a script file reads its own options: `values` take the next word (or the rest of a
|
|
5
|
+
* cluster), `evals` take code to run instead of a file, `ends` run something that is no file (`python -m`),
|
|
6
|
+
* `files` take the script itself (`php -f`).
|
|
7
|
+
*/
|
|
8
|
+
interface IRunnerTable {
|
|
9
|
+
values: ReadonlySet<string>;
|
|
10
|
+
evals: ReadonlySet<string>;
|
|
11
|
+
ends: ReadonlySet<string>;
|
|
12
|
+
files: ReadonlySet<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A program that runs another program named by its first plain word: `npx` then `tsx x.ts`, `uv run x.py`. `values`
|
|
17
|
+
* take the next word; `ends` run no program the guard can name (`npx` with `-c`, `uv run -m`); `subcommand` is the
|
|
18
|
+
* word that must come first (`uv run`). `isPackage`: the word names a package (a scoped name after `npx`), not a file.
|
|
19
|
+
*/
|
|
20
|
+
interface ILauncherTable {
|
|
21
|
+
values: ReadonlySet<string>;
|
|
22
|
+
ends: ReadonlySet<string>;
|
|
23
|
+
subcommand?: string;
|
|
24
|
+
isPackage: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What a launcher runs: the program and its words, and whether the program is a package, not a project file. */
|
|
28
|
+
interface ILaunched {
|
|
29
|
+
name: string;
|
|
30
|
+
args: string[];
|
|
31
|
+
isPackage: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const runnerOf = (opts: {
|
|
35
|
+
values?: string[];
|
|
36
|
+
evals?: string[];
|
|
37
|
+
ends?: string[];
|
|
38
|
+
files?: string[];
|
|
39
|
+
}): IRunnerTable => ({
|
|
40
|
+
values: new Set(opts.values ?? []),
|
|
41
|
+
evals: new Set(opts.evals ?? []),
|
|
42
|
+
ends: new Set(opts.ends ?? []),
|
|
43
|
+
files: new Set(opts.files ?? []),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export class ScriptRunners {
|
|
47
|
+
static readonly PYTHON = runnerOf({
|
|
48
|
+
values: ['-W', '-X', '--check-hash-based-pycs'],
|
|
49
|
+
evals: ['-c'],
|
|
50
|
+
ends: ['-m'],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
static readonly TYPESCRIPT = runnerOf({
|
|
54
|
+
values: [
|
|
55
|
+
'-r',
|
|
56
|
+
'--require',
|
|
57
|
+
'--import',
|
|
58
|
+
'-C',
|
|
59
|
+
'--conditions',
|
|
60
|
+
'--input-type',
|
|
61
|
+
'--tsconfig',
|
|
62
|
+
'-P',
|
|
63
|
+
'--project',
|
|
64
|
+
'-O',
|
|
65
|
+
'--compiler-options',
|
|
66
|
+
'--compiler',
|
|
67
|
+
'-I',
|
|
68
|
+
'--ignore',
|
|
69
|
+
'-D',
|
|
70
|
+
'--ignore-diagnostics',
|
|
71
|
+
'--cwd',
|
|
72
|
+
'--scope-dir',
|
|
73
|
+
],
|
|
74
|
+
evals: ['-e', '--eval', '-p', '--print'],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
static readonly TABLES: Readonly<Record<string, IRunnerTable>> = {
|
|
78
|
+
tsx: ScriptRunners.TYPESCRIPT,
|
|
79
|
+
'ts-node': ScriptRunners.TYPESCRIPT,
|
|
80
|
+
node: runnerOf({
|
|
81
|
+
values: [
|
|
82
|
+
'-r',
|
|
83
|
+
'--require',
|
|
84
|
+
'--import',
|
|
85
|
+
'--loader',
|
|
86
|
+
'--experimental-loader',
|
|
87
|
+
'-C',
|
|
88
|
+
'--conditions',
|
|
89
|
+
'--env-file',
|
|
90
|
+
'--input-type',
|
|
91
|
+
'--title',
|
|
92
|
+
],
|
|
93
|
+
evals: ['-e', '--eval', '-p', '--print'],
|
|
94
|
+
}),
|
|
95
|
+
bun: runnerOf({
|
|
96
|
+
values: [
|
|
97
|
+
'--cwd',
|
|
98
|
+
'-F',
|
|
99
|
+
'--filter',
|
|
100
|
+
'--elide-lines',
|
|
101
|
+
'--shell',
|
|
102
|
+
'-r',
|
|
103
|
+
'--preload',
|
|
104
|
+
'--require',
|
|
105
|
+
'--import',
|
|
106
|
+
'--port',
|
|
107
|
+
'--conditions',
|
|
108
|
+
'--env-file',
|
|
109
|
+
'-c',
|
|
110
|
+
'--config',
|
|
111
|
+
'-d',
|
|
112
|
+
'--define',
|
|
113
|
+
'-l',
|
|
114
|
+
'--loader',
|
|
115
|
+
'--tsconfig-override',
|
|
116
|
+
'--main-fields',
|
|
117
|
+
'--extension-order',
|
|
118
|
+
'--title',
|
|
119
|
+
'--console-depth',
|
|
120
|
+
],
|
|
121
|
+
evals: ['-e', '--eval', '-p', '--print'],
|
|
122
|
+
}),
|
|
123
|
+
deno: runnerOf({
|
|
124
|
+
values: [
|
|
125
|
+
'-c',
|
|
126
|
+
'--config',
|
|
127
|
+
'--import-map',
|
|
128
|
+
'-L',
|
|
129
|
+
'--log-level',
|
|
130
|
+
'--env-file',
|
|
131
|
+
'--location',
|
|
132
|
+
'--cert',
|
|
133
|
+
],
|
|
134
|
+
}),
|
|
135
|
+
python: ScriptRunners.PYTHON,
|
|
136
|
+
python3: ScriptRunners.PYTHON,
|
|
137
|
+
ruby: runnerOf({ values: ['-r', '-I', '-C', '-E', '-F'], evals: ['-e'] }),
|
|
138
|
+
perl: runnerOf({ values: ['-I', '-M', '-m'], evals: ['-e', '-E'] }),
|
|
139
|
+
php: runnerOf({
|
|
140
|
+
values: ['-c', '-d', '-z', '-t'],
|
|
141
|
+
evals: ['-r', '-B', '-R', '-F', '-E'],
|
|
142
|
+
ends: ['-S', '-a', '-i', '-l', '-v', '-m'],
|
|
143
|
+
files: ['-f'],
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/** The `deno` subcommands that run the file named next; every other one runs no script file. */
|
|
148
|
+
static readonly DENO_RUNS = new Set(['run', 'serve']);
|
|
149
|
+
|
|
150
|
+
/** The `tsx` subcommand that runs the file named next, again on each change. */
|
|
151
|
+
static readonly TSX_RUNS = new Set(['watch']);
|
|
152
|
+
|
|
153
|
+
static readonly LAUNCHERS: Readonly<Record<string, ILauncherTable>> = {
|
|
154
|
+
uv: {
|
|
155
|
+
values: new Set([
|
|
156
|
+
'--with',
|
|
157
|
+
'--with-editable',
|
|
158
|
+
'--with-requirements',
|
|
159
|
+
'-p',
|
|
160
|
+
'--python',
|
|
161
|
+
'--package',
|
|
162
|
+
'--extra',
|
|
163
|
+
'--group',
|
|
164
|
+
'--only-group',
|
|
165
|
+
'--no-group',
|
|
166
|
+
'--env-file',
|
|
167
|
+
'--index',
|
|
168
|
+
'--index-url',
|
|
169
|
+
'--extra-index-url',
|
|
170
|
+
'-f',
|
|
171
|
+
'--find-links',
|
|
172
|
+
'--directory',
|
|
173
|
+
'--project',
|
|
174
|
+
'--config-file',
|
|
175
|
+
'--cache-dir',
|
|
176
|
+
'--color',
|
|
177
|
+
]),
|
|
178
|
+
ends: new Set(['-m', '--module']),
|
|
179
|
+
subcommand: 'run',
|
|
180
|
+
isPackage: false,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/** The Python files `uv run` hands to Python; any other word is a program it runs. */
|
|
185
|
+
static readonly PYTHON_FILE = /\.pyw?$/;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The program a launcher runs, and its words: `npx` then `tsx x.ts` runs `tsx x.ts`, `uv run x.py` runs
|
|
189
|
+
* `python x.py`. The call as given when `name` is no launcher or names no program the guard can follow.
|
|
190
|
+
*/
|
|
191
|
+
static launchedOf(opts: { name: string; args: string[] }): ILaunched {
|
|
192
|
+
const launcher = ScriptRunners.LAUNCHERS[opts.name.split('/').pop() ?? opts.name];
|
|
193
|
+
const given: ILaunched = { ...opts, isPackage: false };
|
|
194
|
+
const call = PackageRunners.find({ program: opts.name, args: opts.args });
|
|
195
|
+
|
|
196
|
+
// `npx`, `bunx` and `pnpx` run the package their first word names, read by the table the runner guard reads
|
|
197
|
+
if (
|
|
198
|
+
call !== undefined &&
|
|
199
|
+
launcher === undefined &&
|
|
200
|
+
call.leading.length === 0 &&
|
|
201
|
+
call.runner === opts.name.split('/').pop()
|
|
202
|
+
) {
|
|
203
|
+
const target = PackageRunners.targetOf({ words: call.words, runner: call.runner });
|
|
204
|
+
const isCommandString = target.flags.some((flag) => flag === '-c' || flag === '--call');
|
|
205
|
+
|
|
206
|
+
return target.name === '' || isCommandString
|
|
207
|
+
? given
|
|
208
|
+
: ScriptRunners.launchedWordOf({
|
|
209
|
+
word: target.name,
|
|
210
|
+
args: target.rest,
|
|
211
|
+
isPackage: !/^\.{0,2}\//.test(target.name),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (launcher === undefined) {
|
|
216
|
+
return given;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let isStarted = launcher.subcommand === undefined;
|
|
220
|
+
|
|
221
|
+
for (let index = 0; index < opts.args.length; index += 1) {
|
|
222
|
+
const word = opts.args[index] ?? '';
|
|
223
|
+
|
|
224
|
+
if (!word.startsWith('-')) {
|
|
225
|
+
if (isStarted) {
|
|
226
|
+
return ScriptRunners.launchedWordOf({
|
|
227
|
+
word,
|
|
228
|
+
args: opts.args.slice(index + 1),
|
|
229
|
+
isPackage: launcher.isPackage && !/^\.{0,2}\//.test(word),
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (word !== launcher.subcommand) {
|
|
234
|
+
return given;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
isStarted = true;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const option = word.startsWith('--') ? (word.split('=')[0] ?? word) : word;
|
|
242
|
+
|
|
243
|
+
if (launcher.ends.has(option)) {
|
|
244
|
+
return given;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
index += launcher.values.has(option) && !word.includes('=') ? 1 : 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return given;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
private static launchedWordOf(opts: {
|
|
254
|
+
word: string;
|
|
255
|
+
args: string[];
|
|
256
|
+
isPackage: boolean;
|
|
257
|
+
}): ILaunched {
|
|
258
|
+
const launched = ScriptRunners.PYTHON_FILE.test(opts.word)
|
|
259
|
+
? { name: 'python', args: [opts.word, ...opts.args] }
|
|
260
|
+
: { name: opts.word, args: opts.args };
|
|
261
|
+
const inner = ScriptRunners.launchedOf(launched);
|
|
262
|
+
|
|
263
|
+
return inner.name === launched.name ? { ...inner, isPackage: opts.isPackage } : inner;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** The `deno` subcommands that run no script file, so a word after them is not one. */
|
|
267
|
+
static readonly DENO_BUILT_INS = new Set([
|
|
268
|
+
'task',
|
|
269
|
+
'test',
|
|
270
|
+
'bench',
|
|
271
|
+
'check',
|
|
272
|
+
'compile',
|
|
273
|
+
'completions',
|
|
274
|
+
'coverage',
|
|
275
|
+
'doc',
|
|
276
|
+
'eval',
|
|
277
|
+
'fmt',
|
|
278
|
+
'info',
|
|
279
|
+
'init',
|
|
280
|
+
'install',
|
|
281
|
+
'uninstall',
|
|
282
|
+
'jupyter',
|
|
283
|
+
'lint',
|
|
284
|
+
'lsp',
|
|
285
|
+
'publish',
|
|
286
|
+
'repl',
|
|
287
|
+
'upgrade',
|
|
288
|
+
'vendor',
|
|
289
|
+
'add',
|
|
290
|
+
'remove',
|
|
291
|
+
'outdated',
|
|
292
|
+
'clean',
|
|
293
|
+
'x',
|
|
294
|
+
'approve-scripts',
|
|
295
|
+
'audit',
|
|
296
|
+
'bundle',
|
|
297
|
+
'deploy',
|
|
298
|
+
'help',
|
|
299
|
+
'types',
|
|
300
|
+
]);
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* The option of `program` that `word` is, read the way the runner reads it: a long option with or without
|
|
304
|
+
* `=value`, or a cluster of short ones (`-uc`) ending at its first letter that takes a value.
|
|
305
|
+
*/
|
|
306
|
+
static optionOf(opts: { table: IRunnerTable; word: string }): {
|
|
307
|
+
option: string;
|
|
308
|
+
value: string | undefined;
|
|
309
|
+
} {
|
|
310
|
+
const { table, word } = opts;
|
|
311
|
+
|
|
312
|
+
if (word.startsWith('--')) {
|
|
313
|
+
const at = word.indexOf('=');
|
|
314
|
+
|
|
315
|
+
return at > 0
|
|
316
|
+
? { option: word.slice(0, at), value: word.slice(at + 1) }
|
|
317
|
+
: { option: word, value: undefined };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
for (let at = 1; at < word.length; at += 1) {
|
|
321
|
+
const option = `-${word[at] ?? ''}`;
|
|
322
|
+
const isKnown = [table.values, table.evals, table.ends, table.files].some((set) =>
|
|
323
|
+
set.has(option),
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
if (isKnown) {
|
|
327
|
+
const rest = word.slice(at + 1);
|
|
328
|
+
|
|
329
|
+
return { option, value: rest === '' ? undefined : rest };
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return { option: word, value: undefined };
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* The script word `program` runs, from its words; `undefined` for none (the code of an eval option, a
|
|
338
|
+
* module, a server, only options).
|
|
339
|
+
*/
|
|
340
|
+
static callOf(opts: { program: string; args: string[] }): { script?: string } {
|
|
341
|
+
const table = ScriptRunners.TABLES[opts.program];
|
|
342
|
+
|
|
343
|
+
if (table === undefined) {
|
|
344
|
+
return {};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const { args } = opts;
|
|
348
|
+
|
|
349
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
350
|
+
const word = args[index] ?? '';
|
|
351
|
+
|
|
352
|
+
if (word === '--') {
|
|
353
|
+
return { script: args[index + 1] };
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (!word.startsWith('-') || word === '-') {
|
|
357
|
+
return ScriptRunners.positionalOf({ program: opts.program, args: args.slice(index) });
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const { option, value } = ScriptRunners.optionOf({ table, word });
|
|
361
|
+
const takes = [table.values, table.evals, table.files].some((set) => set.has(option));
|
|
362
|
+
const given = value ?? (takes ? args[index + 1] : undefined);
|
|
363
|
+
|
|
364
|
+
index += takes && value === undefined ? 1 : 0;
|
|
365
|
+
|
|
366
|
+
// `python -c` and `ruby -e` run the code, and the words after it are its arguments.
|
|
367
|
+
if ((table.evals.has(option) && given !== undefined) || table.ends.has(option)) {
|
|
368
|
+
return {};
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (table.files.has(option)) {
|
|
372
|
+
return { script: given };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return {};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The script word among the positional words: `deno run x` and `deno x`, `tsx watch x` and `tsx x`, any
|
|
381
|
+
* other runner's first word.
|
|
382
|
+
*/
|
|
383
|
+
private static positionalOf(opts: { program: string; args: string[] }): { script?: string } {
|
|
384
|
+
const [first, ...rest] = opts.args;
|
|
385
|
+
|
|
386
|
+
if (opts.program === 'tsx' && first !== undefined && ScriptRunners.TSX_RUNS.has(first)) {
|
|
387
|
+
return ScriptRunners.callOf({ program: 'tsx', args: rest });
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (opts.program !== 'deno' || first === undefined) {
|
|
391
|
+
return { script: first };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (ScriptRunners.DENO_RUNS.has(first)) {
|
|
395
|
+
return ScriptRunners.callOf({ program: 'deno', args: rest });
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return first === 'eval' || ScriptRunners.DENO_BUILT_INS.has(first) ? {} : { script: first };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
@@ -1,146 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { basename, join } from 'node:path';
|
|
3
|
-
import { BASE_DIRECTORY, ProjectLayout } from '../common/index.ts';
|
|
4
|
-
import { ConfigConstants, ConfigLoader } from '../config/index.ts';
|
|
1
|
+
import { ConfigLoader } from '../config/index.ts';
|
|
5
2
|
import { OWNER_SCHEMA, OwnerCard, OwnerProfile, OwnerView, ReplySwitch } from '../owner/index.ts';
|
|
6
|
-
import { RuleConstants, RuleParser, RuleSlots } from '../rules/index.ts';
|
|
7
3
|
import { ClaudeLaunch } from '../sync/claude-launch.ts';
|
|
8
|
-
import { ProjectTmp } from './project-tmp.ts';
|
|
9
|
-
|
|
10
|
-
/** A project row whose first cell lists IDs - `| V-W-02, V-W-03 |` - elaborates those base rules. */
|
|
11
|
-
const ID_LIST_ROW =
|
|
12
|
-
/^\|\s*(?:\*\*)?(?:[A-Z]+-)?[A-Z]-\d{2}(?:\*\*)?(?:\s*,\s*(?:\*\*)?(?:[A-Z]+-)?[A-Z]-\d{2}(?:\*\*)?)+\s*\|/;
|
|
13
|
-
|
|
14
|
-
/** The project's own picture of itself, printed verbatim at session start. */
|
|
15
|
-
const MINIMAP = /<!-- minimap-shape:start -->\n([\s\S]*?)\n?<!-- minimap-shape:end -->/;
|
|
16
|
-
|
|
17
|
-
const TABLE_HEADER = ['| ID | Rule | Enforced by |', '|----|------|-------------|'];
|
|
18
|
-
|
|
19
|
-
/** Each listed ID's row, plain or bold (`| **W-00** |`), quoted from its rule file so it cannot drift. */
|
|
20
|
-
const selectRows = (opts: { rows: string[]; ids: string[] }): string[] =>
|
|
21
|
-
opts.ids
|
|
22
|
-
.map((id) => opts.rows.find((row) => RuleParser.parseIds({ markdown: row })[0] === id))
|
|
23
|
-
.filter((row): row is string => row !== undefined);
|
|
24
|
-
|
|
25
|
-
const readText = (opts: { file: string }): string =>
|
|
26
|
-
existsSync(opts.file) ? readFileSync(opts.file, 'utf8') : '';
|
|
27
|
-
|
|
28
|
-
/** The Atlas block: only for a project whose `.mcp.json` runs the atlas server. */
|
|
29
|
-
const buildAtlasBlock = (opts: {
|
|
30
|
-
projectRoot: string;
|
|
31
|
-
project: string;
|
|
32
|
-
sources: string[];
|
|
33
|
-
}): string[] => {
|
|
34
|
-
if (!/\batlas\b/.test(readText({ file: join(opts.projectRoot, '.mcp.json') }))) {
|
|
35
|
-
return [];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return [
|
|
39
|
-
'## Atlas',
|
|
40
|
-
'',
|
|
41
|
-
`The \`atlas\` MCP server holds the real code and docs of: ${[`${opts.project} (this repository)`, ...opts.sources].join(', ')}.`,
|
|
42
|
-
'Look facts up there before you answer or write from memory: `symbol` for an export you import, `search` for how something works, `version` or `changes` for a release (V-P-07).',
|
|
43
|
-
'',
|
|
44
|
-
];
|
|
45
|
-
};
|
|
46
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Builds the digest printed at session start by the session-start hook: what only this session knows - a config
|
|
7
|
+
* problem, a launch warning, how to answer this owner. The rules themselves are the block of AGENTS.md
|
|
8
|
+
* (`RulesBlock`), which every agent reads, Claude Code through CLAUDE.md.
|
|
9
|
+
*/
|
|
47
10
|
export class SessionDigest {
|
|
48
|
-
/**
|
|
11
|
+
/** Claude Code gives the model a hook's output whole up to 10,000 bytes, beyond that a file and its first 2 KB; the digest stays within the 2 KB. */
|
|
12
|
+
static readonly MAX_BYTES = 2048;
|
|
13
|
+
|
|
49
14
|
static async build(opts: {
|
|
50
15
|
projectRoot: string;
|
|
51
16
|
/** The environment of the session; `VULCAN_OWNER_REPLY=off` leaves out the owner's shape and profile cards. */
|
|
52
17
|
env?: Record<string, string | undefined>;
|
|
53
18
|
}): Promise<string> {
|
|
54
|
-
const baseRows = RuleParser.extractRows({
|
|
55
|
-
markdown: readText({ file: join(BASE_DIRECTORY, 'rules.md') }),
|
|
56
|
-
});
|
|
57
|
-
const projectText = readText({ file: join(opts.projectRoot, '.agents', 'rules.md') });
|
|
58
|
-
const projectRows = projectText
|
|
59
|
-
.split('\n')
|
|
60
|
-
.filter(
|
|
61
|
-
(line) => RuleParser.extractRows({ markdown: line }).length > 0 || ID_LIST_ROW.test(line),
|
|
62
|
-
);
|
|
63
|
-
const minimap = MINIMAP.exec(projectText)?.[1].trim();
|
|
64
19
|
const loaded = await ConfigLoader.load({ root: opts.projectRoot });
|
|
65
|
-
const
|
|
66
|
-
const oftenDropped = loaded.ok
|
|
67
|
-
? loaded.config.digest.oftenDropped
|
|
68
|
-
: ConfigConstants.DEFAULT_OFTEN_DROPPED;
|
|
69
|
-
|
|
70
|
-
const slotRows = Object.entries(RuleSlots.read()).map(([id, slot]) => {
|
|
71
|
-
const choice = choices[id];
|
|
72
|
-
|
|
73
|
-
if (choice === undefined) {
|
|
74
|
-
return `| ${id} | this project: **not chosen** - run \`${ProjectLayout.VULCAN_COMMAND} doctor\` |`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return `| ${id} | this project: \`${choice}\` - ${slot.options[choice]?.text ?? `unknown option - run \`${ProjectLayout.VULCAN_COMMAND} doctor\``} |`;
|
|
78
|
-
});
|
|
79
|
-
|
|
20
|
+
const configNote = ConfigLoader.unreadableNote({ loaded });
|
|
80
21
|
const launchWarning = ClaudeLaunch.missWarning({
|
|
81
22
|
root: opts.projectRoot,
|
|
82
23
|
env: opts.env ?? process.env,
|
|
83
24
|
});
|
|
84
|
-
|
|
85
25
|
const lines = [
|
|
86
|
-
'# VULCAN
|
|
26
|
+
'# VULCAN session',
|
|
87
27
|
'',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
project: loaded.ok
|
|
94
|
-
? (loaded.config.name ?? basename(opts.projectRoot))
|
|
95
|
-
: basename(opts.projectRoot),
|
|
96
|
-
sources: loaded.ok ? loaded.config.atlas.sources.map((source) => source.name) : [],
|
|
97
|
-
}),
|
|
98
|
-
'## Write boundaries',
|
|
99
|
-
'',
|
|
100
|
-
...TABLE_HEADER,
|
|
101
|
-
...baseRows.filter((row) => row.startsWith(`| ${RuleConstants.BASE_NAMESPACE}W-`)),
|
|
102
|
-
'',
|
|
103
|
-
'## Temporary files',
|
|
104
|
-
'',
|
|
105
|
-
`Scratch and temporary files go in \`${ProjectTmp.projectOf({ root: opts.projectRoot })}\`, never /tmp (V-B-08). The scratchpad folder your tool offers is under /tmp too: do not use it, this rule wins over the tool's line. In Claude Code every Bash command already runs with \`TMPDIR\` set to it; in any other agent run \`export TMPDIR=${ProjectTmp.projectOf({ root: opts.projectRoot })}\` first. Remove what you made when the task ends.`,
|
|
106
|
-
'',
|
|
107
|
-
"## This project's slot choices",
|
|
108
|
-
'',
|
|
109
|
-
...slotRows,
|
|
28
|
+
'The rules are in AGENTS.md ("Rules that must not be skipped"); the full text is `node_modules/@venizia/vulcan/base/rules.md` and `.agents/rules.md`.',
|
|
29
|
+
...(configNote === undefined
|
|
30
|
+
? []
|
|
31
|
+
: ['', '## Config problem', '', `This session: ${configNote}.`]),
|
|
32
|
+
...(launchWarning === undefined ? [] : ['', '## Launch warning', '', launchWarning]),
|
|
110
33
|
];
|
|
111
34
|
|
|
112
|
-
const profile = OwnerProfile.read({ root: opts.projectRoot });
|
|
113
|
-
const view = OwnerView.resolve({
|
|
114
|
-
owner: loaded.ok ? loaded.config.owner : OWNER_SCHEMA.parse(undefined),
|
|
115
|
-
profile: profile.ok ? profile.profile : undefined,
|
|
116
|
-
});
|
|
117
|
-
const profileCard = OwnerCard.renderProfile({ view });
|
|
118
|
-
|
|
119
35
|
// A session whose reader is an agent: the owner's shape and the person's profile are not its business.
|
|
120
36
|
if (!ReplySwitch.isOwnerOff({ env: opts.env ?? process.env })) {
|
|
121
|
-
|
|
37
|
+
const profile = OwnerProfile.read({ root: opts.projectRoot });
|
|
38
|
+
const view = OwnerView.resolve({
|
|
39
|
+
owner: loaded.ok ? loaded.config.owner : OWNER_SCHEMA.parse(undefined),
|
|
40
|
+
profile: profile.ok ? profile.profile : undefined,
|
|
41
|
+
});
|
|
42
|
+
const shape = OwnerCard.renderShape({ view });
|
|
43
|
+
const profileCard = OwnerCard.renderProfile({ view });
|
|
44
|
+
|
|
45
|
+
if (shape.length > 0) {
|
|
46
|
+
lines.push('', ...shape);
|
|
47
|
+
}
|
|
122
48
|
|
|
123
49
|
if (profileCard.length > 0) {
|
|
124
50
|
lines.push('', ...profileCard);
|
|
125
51
|
}
|
|
126
52
|
}
|
|
127
53
|
|
|
128
|
-
if (projectRows.length > 0) {
|
|
129
|
-
lines.push('', "## This project's own rules", '', ...TABLE_HEADER, ...projectRows);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (minimap !== undefined && minimap.length > 0) {
|
|
133
|
-
lines.push('', "## This project's minimap", '', minimap);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
lines.push(
|
|
137
|
-
'',
|
|
138
|
-
'## The rules sessions drop most',
|
|
139
|
-
'',
|
|
140
|
-
...TABLE_HEADER,
|
|
141
|
-
...selectRows({ rows: [...baseRows, ...projectRows], ids: oftenDropped }),
|
|
142
|
-
);
|
|
143
|
-
|
|
144
54
|
return `${lines.join('\n')}\n`;
|
|
145
55
|
}
|
|
146
56
|
}
|