@venizia/vulcan 0.4.9-5 → 0.4.9
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/hooks/auto-clean.ts +22 -0
- package/base/hooks/session-start.ts +12 -0
- package/base/skills/retro/SKILL.md +2 -2
- package/base/templates/board.html +4697 -0
- package/package.json +3 -3
- package/src/board/command.ts +200 -0
- package/src/board/common/constants.ts +122 -0
- package/src/board/common/index.ts +2 -0
- package/src/board/common/types.ts +86 -0
- package/src/board/fold.ts +428 -0
- package/src/board/github.ts +255 -0
- package/src/board/index.ts +6 -0
- package/src/board/page.ts +26 -0
- package/src/board/settings.ts +106 -0
- package/src/commands/board.command.ts +5 -0
- package/src/commands/help.command.ts +5 -1
- package/src/commands/index.ts +2 -0
- package/src/common/constants.ts +1 -0
- package/src/config/schema.ts +59 -0
- package/src/doctor/checks.ts +29 -0
- package/src/doctor/common/constants.ts +1 -0
- package/src/doctor/runner.ts +1 -0
- package/src/events/command.ts +21 -2
- package/src/events/common/constants.ts +31 -0
- package/src/events/common/types.ts +15 -1
- package/src/events/index.ts +1 -0
- package/src/events/log.ts +7 -3
- package/src/events/retention.ts +172 -0
- package/src/events/settings.ts +12 -0
- package/src/local/auto-clean-run.ts +99 -0
- package/src/local/auto-clean.ts +147 -0
- package/src/local/clean.ts +33 -1
- package/src/local/constants.ts +1 -0
- package/src/local/index.ts +1 -0
- package/src/local/scan.ts +43 -6
- package/src/manifest/render.ts +36 -2
- package/src/router.ts +8 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { BASE_DIRECTORY } from '../common/paths.ts';
|
|
4
|
+
import { BoardConstants } from './common/index.ts';
|
|
5
|
+
import type { IBoardData } from './common/index.ts';
|
|
6
|
+
|
|
7
|
+
/** The board as one HTML file: the page of `base/templates/board.html` with the data inside it. */
|
|
8
|
+
export class BoardPage {
|
|
9
|
+
/**
|
|
10
|
+
* The page with `data` embedded as JSON in a `script` of type `application/json`. `<` and the two line separators
|
|
11
|
+
* are escaped, so no text in the data can close the script or break it. Nothing is fetched when the page opens.
|
|
12
|
+
*/
|
|
13
|
+
static render(opts: { data: IBoardData; template?: string }): string {
|
|
14
|
+
const template =
|
|
15
|
+
opts.template ?? readFileSync(join(BASE_DIRECTORY, BoardConstants.TEMPLATE), 'utf8');
|
|
16
|
+
const json = JSON.stringify(opts.data)
|
|
17
|
+
.replaceAll('<', '\\u003c')
|
|
18
|
+
.replaceAll('
', '\\u2028')
|
|
19
|
+
.replaceAll('
', '\\u2029');
|
|
20
|
+
|
|
21
|
+
return template.replace(
|
|
22
|
+
BoardConstants.DATA_MARKER,
|
|
23
|
+
() => `<script type="application/json" id="board-data">${json}</script>`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { RecordValue } from '../common/record.ts';
|
|
5
|
+
import { BoardConstants, BoardShapes } from './common/index.ts';
|
|
6
|
+
|
|
7
|
+
export interface IBoardSettings {
|
|
8
|
+
title: string;
|
|
9
|
+
owner: string;
|
|
10
|
+
logo?: string;
|
|
11
|
+
key: string;
|
|
12
|
+
shapes: Record<string, string>;
|
|
13
|
+
/** Why a setting was not used, for the note the command prints. */
|
|
14
|
+
notes: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** What the project calls things on the board page: its manifest block, with the fallbacks that keep VULCAN neutral. */
|
|
18
|
+
export class BoardSettings {
|
|
19
|
+
/**
|
|
20
|
+
* The names for the page. The owner is `board.owner`, else `gitUser` (`git config user.name`), else `Owner`; the
|
|
21
|
+
* title is `board.title`, else the project name and "Board"; the logo is `board.logo`, an SVG in the project, as a
|
|
22
|
+
* `data:` URL, and none when it is not set, is missing, is too large or is not an SVG. Nothing here is a default of
|
|
23
|
+
* any one organisation.
|
|
24
|
+
*/
|
|
25
|
+
static resolve(opts: {
|
|
26
|
+
manifest: unknown;
|
|
27
|
+
gitUser: string | undefined;
|
|
28
|
+
readLogo: (path: string) => string | undefined;
|
|
29
|
+
}): IBoardSettings {
|
|
30
|
+
const manifest = RecordValue.isRecord(opts.manifest) ? opts.manifest : {};
|
|
31
|
+
const block = RecordValue.isRecord(manifest.board) ? manifest.board : {};
|
|
32
|
+
const name =
|
|
33
|
+
typeof manifest.name === 'string' && manifest.name !== '' ? manifest.name : 'Project';
|
|
34
|
+
const text = (value: unknown): string | undefined =>
|
|
35
|
+
typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
36
|
+
const notes: string[] = [];
|
|
37
|
+
const logoPath = text(block.logo);
|
|
38
|
+
const logo = logoPath === undefined ? undefined : opts.readLogo(logoPath);
|
|
39
|
+
|
|
40
|
+
if (logoPath !== undefined && logo === undefined) {
|
|
41
|
+
notes.push(`board.logo ${logoPath} is missing, over 100 KB or not an SVG: no logo`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
title: text(block.title) ?? `${name} Board`,
|
|
46
|
+
owner: text(block.owner) ?? text(opts.gitUser) ?? BoardConstants.DEFAULT_OWNER,
|
|
47
|
+
...(logo === undefined ? {} : { logo }),
|
|
48
|
+
key:
|
|
49
|
+
name
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
52
|
+
.replace(/^-|-$/g, '') || 'project',
|
|
53
|
+
shapes: RecordValue.isRecord(block.agents)
|
|
54
|
+
? Object.fromEntries(
|
|
55
|
+
Object.entries(block.agents).filter(
|
|
56
|
+
(entry): entry is [string, string] =>
|
|
57
|
+
typeof entry[1] === 'string' && BoardShapes.isValid(entry[1]),
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
: {},
|
|
61
|
+
notes,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `resolve` for the project at `root`: its manifest, `git config user.name`, and the logo file. */
|
|
66
|
+
static read(opts: { root: string }): IBoardSettings {
|
|
67
|
+
let manifest: unknown;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
manifest = JSON.parse(readFileSync(join(opts.root, BoardConstants.MANIFEST_FILE), 'utf8'));
|
|
71
|
+
} catch {
|
|
72
|
+
manifest = {};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const git = spawnSync('git', ['config', 'user.name'], {
|
|
76
|
+
cwd: opts.root,
|
|
77
|
+
encoding: 'utf8',
|
|
78
|
+
timeout: 5000,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return BoardSettings.resolve({
|
|
82
|
+
manifest,
|
|
83
|
+
gitUser: git.status === 0 ? git.stdout.trim() : undefined,
|
|
84
|
+
readLogo: (path) => BoardSettings.logoOf({ root: opts.root, path }),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The SVG at `path` in the project as a `data:` URL; a picture in an `img` runs no script, whatever the file holds. */
|
|
89
|
+
private static logoOf(opts: { root: string; path: string }): string | undefined {
|
|
90
|
+
const file = join(opts.root, opts.path);
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
if (!existsSync(file) || statSync(file).size > BoardConstants.LOGO_MAX_BYTES) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const svg = readFileSync(file);
|
|
98
|
+
|
|
99
|
+
return /<svg[\s>]/i.test(svg.toString('utf8', 0, 2000))
|
|
100
|
+
? `data:image/svg+xml;base64,${svg.toString('base64')}`
|
|
101
|
+
: undefined;
|
|
102
|
+
} catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -31,11 +31,15 @@ Usage: bun x vulcan <command>
|
|
|
31
31
|
Check a commit message against the commit.message checks of the config (an
|
|
32
32
|
agent in a trailer or a "generated with" line, the project's subject shape);
|
|
33
33
|
sync installs it as the commit-msg hook; exit 1 on a problem, 2 on bad input
|
|
34
|
+
board [--out <file>] [--open] [--since <date>] [--dir <events folder>] [--repo owner/name]... [--no-github]
|
|
35
|
+
Fold the event log (and GitHub pull requests, checks and reviews when gh
|
|
36
|
+
can read them) into flows and write one HTML file, by default
|
|
37
|
+
.agents/local/reports/board.html; read-only; exit 2 on bad input
|
|
34
38
|
ci affected --base <ref> [--head <ref>] [--check <check>] [--json | --names] | template <github|gitlab>
|
|
35
39
|
List the workspace packages a change touches (changed ones and what
|
|
36
40
|
depends on them) with the checks each has; template prints a CI file that
|
|
37
41
|
runs exactly those; exit 2 on bad input
|
|
38
|
-
event add --kind <k> --summary <text> [--flow F-n] [--ref <r>] | tail [--since <time>] [--json] [--dir <folder>]
|
|
42
|
+
event add --kind <k> --summary <text> [--flow F-n] [--ref <r>] [--status approve|park|reject] | tail [--since <time>] [--json] [--dir <folder>]
|
|
39
43
|
Write a line to the agent event log (.agents/local/events/<day>.jsonl) or
|
|
40
44
|
read it; with events.log on, sync installs the Claude Code hooks that
|
|
41
45
|
write it; exit 2 on bad input
|
package/src/commands/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export const COMMAND_LOADERS: Record<string, () => Promise<TCommandHandler>> = {
|
|
|
6
6
|
[VulcanCommands.ADD]: () => import('./add.command.ts').then((module) => module.runAddCommand),
|
|
7
7
|
[VulcanCommands.AGENTS]: () =>
|
|
8
8
|
import('./agents.command.ts').then((module) => module.runAgentsCommand),
|
|
9
|
+
[VulcanCommands.BOARD]: () =>
|
|
10
|
+
import('./board.command.ts').then((module) => module.runBoardCommand),
|
|
9
11
|
[VulcanCommands.CI]: () => import('./ci.command.ts').then((module) => module.runCiCommand),
|
|
10
12
|
[VulcanCommands.CLEAN]: () =>
|
|
11
13
|
import('./clean.command.ts').then((module) => module.runCleanCommand),
|
package/src/common/constants.ts
CHANGED
|
@@ -11,6 +11,7 @@ export class VulcanCommands {
|
|
|
11
11
|
static readonly VISUALIZE = 'visualize';
|
|
12
12
|
static readonly COMMIT_CHECK = 'commit-check';
|
|
13
13
|
static readonly CI = 'ci';
|
|
14
|
+
static readonly BOARD = 'board';
|
|
14
15
|
static readonly EVENT = 'event';
|
|
15
16
|
static readonly X = 'x';
|
|
16
17
|
static readonly HELP = 'help';
|
package/src/config/schema.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { OWNER_SCHEMA } from '../owner/schema.ts';
|
|
|
5
5
|
import { AgentSignaturePolicies } from '../commit/common/index.ts';
|
|
6
6
|
import type { TAgentSignaturePolicy } from '../commit/common/index.ts';
|
|
7
7
|
import { SubjectShape } from '../commit/subject.ts';
|
|
8
|
+
import { BoardShapes } from '../board/common/constants.ts';
|
|
9
|
+
import { EventRetention } from '../events/retention.ts';
|
|
8
10
|
import { EventSettings } from '../events/settings.ts';
|
|
9
11
|
import {
|
|
10
12
|
CodingAgents,
|
|
@@ -369,6 +371,40 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
|
|
|
369
371
|
.optional(),
|
|
370
372
|
})
|
|
371
373
|
.optional(),
|
|
374
|
+
/**
|
|
375
|
+
* What `vulcan board` calls things. `owner` is who an ask waits on (default: `git config user.name`),
|
|
376
|
+
* `title` the name on the page (default: the project name and "Board"), `logo` a path inside the project to an
|
|
377
|
+
* SVG put on the page (default: none), `agents` an agent name to a face (`bun`, `flame`, `ember`, `rock`,
|
|
378
|
+
* `banana`; any other agent has `bun`). Written to the manifest only when something is set.
|
|
379
|
+
*/
|
|
380
|
+
board: z
|
|
381
|
+
.strictObject({
|
|
382
|
+
owner: z.string().min(1).optional(),
|
|
383
|
+
title: z.string().min(1).optional(),
|
|
384
|
+
logo: z
|
|
385
|
+
.string()
|
|
386
|
+
.min(1)
|
|
387
|
+
.refine(
|
|
388
|
+
(value) =>
|
|
389
|
+
value.toLowerCase().endsWith('.svg') &&
|
|
390
|
+
!value.startsWith('/') &&
|
|
391
|
+
!value.split('/').includes('..'),
|
|
392
|
+
{
|
|
393
|
+
message:
|
|
394
|
+
'a path inside the project to an .svg file, with no leading / and no .. segment',
|
|
395
|
+
},
|
|
396
|
+
)
|
|
397
|
+
.optional(),
|
|
398
|
+
agents: z
|
|
399
|
+
.record(
|
|
400
|
+
z.string().min(1),
|
|
401
|
+
z.custom<string>((value) => typeof value === 'string' && BoardShapes.isValid(value), {
|
|
402
|
+
message: `one of ${[...BoardShapes.SCHEME_SET].join(', ')}`,
|
|
403
|
+
}),
|
|
404
|
+
)
|
|
405
|
+
.default({}),
|
|
406
|
+
})
|
|
407
|
+
.default({ agents: {} }),
|
|
372
408
|
/** Team-shared Claude settings (permissions, env, enabledPlugins...), merged by sync over personal keys. */
|
|
373
409
|
claude: z
|
|
374
410
|
.strictObject({ settings: z.record(z.string(), z.unknown()).default({}) })
|
|
@@ -507,8 +543,31 @@ export const VULCAN_CONFIG_SCHEMA = z.strictObject({
|
|
|
507
543
|
}
|
|
508
544
|
})
|
|
509
545
|
.optional(),
|
|
546
|
+
/**
|
|
547
|
+
* How much of the log is kept, as whole day files removed oldest first (today's never): `maxSize` for the
|
|
548
|
+
* folder (`50MB`, `200MB`, `1GB`), `maxFiles` for the day files, `maxAgeDays` for their age. The defaults,
|
|
549
|
+
* when `log` is on, are 50MB, 30 files and 30 days.
|
|
550
|
+
*/
|
|
551
|
+
maxSize: z
|
|
552
|
+
.string()
|
|
553
|
+
.refine((value) => EventRetention.parseSize({ text: value }) !== undefined, {
|
|
554
|
+
message: 'a size such as 50MB, 200MB or 1GB',
|
|
555
|
+
})
|
|
556
|
+
.optional(),
|
|
557
|
+
maxFiles: z.number().int().min(1).optional(),
|
|
558
|
+
maxAgeDays: z.number().int().min(1).optional(),
|
|
510
559
|
})
|
|
511
560
|
.default({ log: false }),
|
|
561
|
+
/**
|
|
562
|
+
* What `vulcan` keeps tidy in `.agents/local/` by itself. `autoClean` (default true) lets the session-start hook, at
|
|
563
|
+
* most once a day, remove the safe part: stale `tmp/`, browser leftovers older than an hour, event files past their
|
|
564
|
+
* limits, and release candidates whose version is tagged. It never removes a worktree or a clone.
|
|
565
|
+
*/
|
|
566
|
+
local: z
|
|
567
|
+
.strictObject({
|
|
568
|
+
autoClean: z.boolean().default(true),
|
|
569
|
+
})
|
|
570
|
+
.default({ autoClean: true }),
|
|
512
571
|
});
|
|
513
572
|
|
|
514
573
|
export type VulcanConfig = z.input<typeof VULCAN_CONFIG_SCHEMA>;
|
package/src/doctor/checks.ts
CHANGED
|
@@ -20,6 +20,9 @@ import { BaseRules, RuleParser, RuleSlots } from '../rules/index.ts';
|
|
|
20
20
|
import { ManifestConstants, ProjectManifest } from '../manifest/index.ts';
|
|
21
21
|
import { AgentScopes, AgentSelection, AgentTable, LocalChoice } from '../agents/index.ts';
|
|
22
22
|
import { CommitHook, CommitHookStates } from '../commit/index.ts';
|
|
23
|
+
import { EventConstants } from '../events/common/index.ts';
|
|
24
|
+
import { EventRetention } from '../events/retention.ts';
|
|
25
|
+
import { EventSettings } from '../events/settings.ts';
|
|
23
26
|
import { AgentFiles, AtlasBlockPlan, LocalPlan, SyncPlanner, SyncStatuses } from '../sync/index.ts';
|
|
24
27
|
import { LocalConstants, LocalFormat, LocalScan, LocalStates } from '../local/index.ts';
|
|
25
28
|
import {
|
|
@@ -774,6 +777,32 @@ export class ProjectContract {
|
|
|
774
777
|
];
|
|
775
778
|
}
|
|
776
779
|
|
|
780
|
+
/**
|
|
781
|
+
* Today's file of the event log alone is bigger than `events.maxSize`. The retention never truncates a file and never
|
|
782
|
+
* removes today's, so nothing else will shrink it: the project raises the limit or writes fewer lines. A warning.
|
|
783
|
+
*/
|
|
784
|
+
static checkEventsSize(opts: ICheckContext): IViolation[] {
|
|
785
|
+
const settings = { ...opts.config.events };
|
|
786
|
+
|
|
787
|
+
if (!EventRetention.isActive({ settings })) {
|
|
788
|
+
return [];
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
const dir = EventSettings.dirOf({ root: opts.root, settings });
|
|
792
|
+
const limits = EventRetention.limitsOf({ settings });
|
|
793
|
+
const plan = EventRetention.plan({ dir, limits, now: Date.now() });
|
|
794
|
+
|
|
795
|
+
return plan.todayOver
|
|
796
|
+
? [
|
|
797
|
+
createViolation({
|
|
798
|
+
check: DoctorChecks.EVENTS_SIZE,
|
|
799
|
+
file: opts.configFile,
|
|
800
|
+
message: `today's event file in ${dir} is ${LocalFormat.formatBytes({ bytes: plan.todayBytes })}, over events.maxSize (${settings.maxSize ?? EventConstants.DEFAULT_MAX_SIZE}); nothing is truncated and today's file is never removed - raise maxSize or write fewer events`,
|
|
801
|
+
}),
|
|
802
|
+
]
|
|
803
|
+
: [];
|
|
804
|
+
}
|
|
805
|
+
|
|
777
806
|
/**
|
|
778
807
|
* The atlas server is registered the one way every project does: the root `.mcp.json` (a per-machine
|
|
779
808
|
* file `sync` writes for the agents that read it) holds an `atlas` entry that runs the project's own
|
|
@@ -22,6 +22,7 @@ export class DoctorChecks {
|
|
|
22
22
|
static readonly GUARDS = 'guards';
|
|
23
23
|
static readonly COMMIT_HOOK = 'commit-hook';
|
|
24
24
|
static readonly EVENTS_DIR = 'events-dir';
|
|
25
|
+
static readonly EVENTS_SIZE = 'events-size';
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
/** The `package.json` scripts every app carries, and the names the standard retired. */
|
package/src/doctor/runner.ts
CHANGED
|
@@ -93,6 +93,7 @@ export class DoctorRunner {
|
|
|
93
93
|
...ProjectContract.checkMcpAtlas(context),
|
|
94
94
|
...ProjectContract.checkCommitHook(context),
|
|
95
95
|
...ProjectContract.checkEventsDir(context),
|
|
96
|
+
...ProjectContract.checkEventsSize(context),
|
|
96
97
|
...ProjectContract.checkDockerignore(context),
|
|
97
98
|
...ProjectContract.checkSkillTriggers(context),
|
|
98
99
|
...ProjectContract.checkFormat(context),
|
package/src/events/command.ts
CHANGED
|
@@ -7,15 +7,16 @@ import {
|
|
|
7
7
|
EventFlags,
|
|
8
8
|
EventKinds,
|
|
9
9
|
EventSources,
|
|
10
|
+
EventStatuses,
|
|
10
11
|
EventSubcommands,
|
|
11
12
|
} from './common/index.ts';
|
|
12
|
-
import type { IEvent, TEventKind } from './common/index.ts';
|
|
13
|
+
import type { IEvent, TEventKind, TEventStatus } from './common/index.ts';
|
|
13
14
|
import { EventActor } from './actor.ts';
|
|
14
15
|
import { EventFlow } from './flow.ts';
|
|
15
16
|
import { EventLog } from './log.ts';
|
|
16
17
|
import { EventSettings } from './settings.ts';
|
|
17
18
|
|
|
18
|
-
const USAGE = `usage: vulcan event add ${EventFlags.KIND} <kind> ${EventFlags.SUMMARY} <text> [${EventFlags.FLOW} F-n] [${EventFlags.REF} <ref>] [${EventFlags.ACTOR} <name>] [${EventFlags.DIR} <folder>]
|
|
19
|
+
const USAGE = `usage: vulcan event add ${EventFlags.KIND} <kind> ${EventFlags.SUMMARY} <text> [${EventFlags.FLOW} F-n] [${EventFlags.REF} <ref>] [${EventFlags.STATUS} <${[...EventStatuses.SCHEME_SET].join('|')}>] [${EventFlags.ACTOR} <name>] [${EventFlags.DIR} <folder>]
|
|
19
20
|
vulcan event tail [${EventFlags.SINCE} <time>] [${EventFlags.JSON}] [${EventFlags.DIR} <folder>]
|
|
20
21
|
kinds: ${[...EventKinds.SCHEME_SET].join(', ')}`;
|
|
21
22
|
|
|
@@ -105,6 +106,23 @@ export class EventCommand {
|
|
|
105
106
|
return ExitCodes.USAGE;
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
const status = values[EventFlags.STATUS];
|
|
110
|
+
|
|
111
|
+
// A decision says which way it went; no other line has a status.
|
|
112
|
+
if (
|
|
113
|
+
kind === EventKinds.DECISION
|
|
114
|
+
? status === undefined || !EventStatuses.isValid(status)
|
|
115
|
+
: status !== undefined
|
|
116
|
+
) {
|
|
117
|
+
process.stderr.write(
|
|
118
|
+
kind === EventKinds.DECISION
|
|
119
|
+
? `event: a decision needs ${EventFlags.STATUS} <${[...EventStatuses.SCHEME_SET].join('|')}>\n`
|
|
120
|
+
: `event: ${EventFlags.STATUS} belongs to a decision only\n`,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
return ExitCodes.USAGE;
|
|
124
|
+
}
|
|
125
|
+
|
|
108
126
|
const flowId = flow ?? EventFlow.fromBranch({ cwd: opts.cwd });
|
|
109
127
|
const actor =
|
|
110
128
|
values[EventFlags.ACTOR] === undefined
|
|
@@ -120,6 +138,7 @@ export class EventCommand {
|
|
|
120
138
|
source: EventSources.CLI,
|
|
121
139
|
...(flowId === undefined ? {} : { flowId }),
|
|
122
140
|
...(values[EventFlags.REF] === undefined ? {} : { ref: values[EventFlags.REF] }),
|
|
141
|
+
...(status === undefined ? {} : { status: status as TEventStatus }),
|
|
123
142
|
});
|
|
124
143
|
|
|
125
144
|
try {
|
|
@@ -8,6 +8,8 @@ export class EventKinds {
|
|
|
8
8
|
static readonly SUBAGENT_STOP = 'subagent-stop';
|
|
9
9
|
static readonly COMMIT = 'commit';
|
|
10
10
|
static readonly PR = 'pr';
|
|
11
|
+
/** The owner's answer to a flow, written by whoever relays it; its `status` says which. */
|
|
12
|
+
static readonly DECISION = 'decision';
|
|
11
13
|
|
|
12
14
|
static readonly SCHEME_SET = new Set<string>([
|
|
13
15
|
this.SESSION_START,
|
|
@@ -18,6 +20,7 @@ export class EventKinds {
|
|
|
18
20
|
this.SUBAGENT_STOP,
|
|
19
21
|
this.COMMIT,
|
|
20
22
|
this.PR,
|
|
23
|
+
this.DECISION,
|
|
21
24
|
]);
|
|
22
25
|
|
|
23
26
|
static isValid(value: string): boolean {
|
|
@@ -25,6 +28,19 @@ export class EventKinds {
|
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
/** What a `decision` line says: the owner approved, parked or rejected the flow. */
|
|
32
|
+
export class EventStatuses {
|
|
33
|
+
static readonly APPROVE = 'approve';
|
|
34
|
+
static readonly PARK = 'park';
|
|
35
|
+
static readonly REJECT = 'reject';
|
|
36
|
+
|
|
37
|
+
static readonly SCHEME_SET = new Set<string>([this.APPROVE, this.PARK, this.REJECT]);
|
|
38
|
+
|
|
39
|
+
static isValid(value: string): boolean {
|
|
40
|
+
return this.SCHEME_SET.has(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
28
44
|
/** Who wrote the line: the hook installed for Claude Code, or `vulcan event add`. */
|
|
29
45
|
export class EventSources {
|
|
30
46
|
static readonly CLAUDE_HOOK = 'claude-hook';
|
|
@@ -41,6 +57,7 @@ export class EventFlags {
|
|
|
41
57
|
static readonly SUMMARY = '--summary';
|
|
42
58
|
static readonly FLOW = '--flow';
|
|
43
59
|
static readonly REF = '--ref';
|
|
60
|
+
static readonly STATUS = '--status';
|
|
44
61
|
static readonly ACTOR = '--actor';
|
|
45
62
|
static readonly DIR = '--dir';
|
|
46
63
|
static readonly SINCE = '--since';
|
|
@@ -64,7 +81,21 @@ export class ClaudeHookEvents {
|
|
|
64
81
|
]);
|
|
65
82
|
}
|
|
66
83
|
|
|
84
|
+
/** The size units of `events.maxSize`: a number and one of these, such as `50MB`. */
|
|
85
|
+
export class EventSizeUnits {
|
|
86
|
+
static readonly BYTES: Record<string, number> = {
|
|
87
|
+
KB: 1024,
|
|
88
|
+
MB: 1024 * 1024,
|
|
89
|
+
GB: 1024 * 1024 * 1024,
|
|
90
|
+
};
|
|
91
|
+
static readonly PATTERN = /^(\d+(?:\.\d+)?)\s?(KB|MB|GB)$/i;
|
|
92
|
+
}
|
|
93
|
+
|
|
67
94
|
export class EventConstants {
|
|
95
|
+
/** What the log keeps when `events.log` is on and the project sets no limit. */
|
|
96
|
+
static readonly DEFAULT_MAX_SIZE = '50MB';
|
|
97
|
+
static readonly DEFAULT_MAX_FILES = 30;
|
|
98
|
+
static readonly DEFAULT_MAX_AGE_DAYS = 30;
|
|
68
99
|
/** Relative to the project root; the default place of the log. */
|
|
69
100
|
static readonly DEFAULT_DIRECTORY = '.agents/local/events';
|
|
70
101
|
static readonly MANIFEST_FILE = '.agents/vulcan.manifest.json';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { TConstValue } from '../../common/index.ts';
|
|
2
|
-
import type { EventKinds } from './constants.ts';
|
|
2
|
+
import type { EventKinds, EventStatuses } from './constants.ts';
|
|
3
3
|
|
|
4
4
|
export type TEventKind = TConstValue<typeof EventKinds>;
|
|
5
|
+
export type TEventStatus = TConstValue<typeof EventStatuses>;
|
|
5
6
|
|
|
6
7
|
/** One line of the log. Field order is the order on disk. */
|
|
7
8
|
export interface IEvent {
|
|
@@ -12,13 +13,26 @@ export interface IEvent {
|
|
|
12
13
|
actor: string;
|
|
13
14
|
kind: TEventKind;
|
|
14
15
|
summary: string;
|
|
16
|
+
/** Only a `decision` has one. */
|
|
17
|
+
status?: TEventStatus;
|
|
15
18
|
ref?: string;
|
|
16
19
|
source: string;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
/** The manifest's `events` block, as `vulcan sync` writes it. */
|
|
23
|
+
/** How much of the log is kept: whole day files are removed, oldest first, past any of these. */
|
|
24
|
+
export interface IEventLimits {
|
|
25
|
+
maxBytes: number;
|
|
26
|
+
maxFiles: number;
|
|
27
|
+
maxAgeDays: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
export interface IEventSettings {
|
|
21
31
|
log: boolean;
|
|
32
|
+
/** The limits the manifest sets; a missing one takes its default when the log is on. */
|
|
33
|
+
maxSize?: string;
|
|
34
|
+
maxFiles?: number;
|
|
35
|
+
maxAgeDays?: number;
|
|
22
36
|
/** An absolute folder; the log goes here instead of `.agents/local/events` of the project. */
|
|
23
37
|
dir?: string;
|
|
24
38
|
}
|
package/src/events/index.ts
CHANGED
package/src/events/log.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { RecordValue } from '../common/record.ts';
|
|
4
|
-
import { EventConstants, EventKinds } from './common/index.ts';
|
|
5
|
-
import type { IEvent, IEventRead, TEventKind } from './common/index.ts';
|
|
4
|
+
import { EventConstants, EventKinds, EventStatuses } from './common/index.ts';
|
|
5
|
+
import type { IEvent, IEventRead, TEventKind, TEventStatus } from './common/index.ts';
|
|
6
6
|
import { EventText } from './text.ts';
|
|
7
7
|
|
|
8
8
|
const DAY_FILE = /^(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
@@ -38,6 +38,7 @@ export class EventLog {
|
|
|
38
38
|
source: string;
|
|
39
39
|
flowId?: string;
|
|
40
40
|
ref?: string;
|
|
41
|
+
status?: TEventStatus;
|
|
41
42
|
now?: number;
|
|
42
43
|
}): IEvent {
|
|
43
44
|
const now = opts.now ?? Date.now();
|
|
@@ -53,6 +54,7 @@ export class EventLog {
|
|
|
53
54
|
actor: opts.actor,
|
|
54
55
|
kind: opts.kind,
|
|
55
56
|
summary: EventText.oneLine({ text: opts.summary, max: EventConstants.SUMMARY_MAX }),
|
|
57
|
+
...(opts.status === undefined ? {} : { status: opts.status }),
|
|
56
58
|
...(ref === '' ? {} : { ref }),
|
|
57
59
|
source: opts.source,
|
|
58
60
|
};
|
|
@@ -128,7 +130,7 @@ export class EventLog {
|
|
|
128
130
|
return undefined;
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
const { id, ts, flowId, actor, kind, summary, ref, source } = value;
|
|
133
|
+
const { id, ts, flowId, actor, kind, summary, status, ref, source } = value;
|
|
132
134
|
|
|
133
135
|
if (
|
|
134
136
|
typeof id !== 'string' ||
|
|
@@ -140,6 +142,7 @@ export class EventLog {
|
|
|
140
142
|
typeof summary !== 'string' ||
|
|
141
143
|
typeof source !== 'string' ||
|
|
142
144
|
(flowId !== undefined && typeof flowId !== 'string') ||
|
|
145
|
+
(status !== undefined && (typeof status !== 'string' || !EventStatuses.isValid(status))) ||
|
|
143
146
|
(ref !== undefined && typeof ref !== 'string')
|
|
144
147
|
) {
|
|
145
148
|
return undefined;
|
|
@@ -155,6 +158,7 @@ export class EventLog {
|
|
|
155
158
|
actor: clean(actor),
|
|
156
159
|
kind: kind as TEventKind,
|
|
157
160
|
summary: clean(summary),
|
|
161
|
+
...(status === undefined ? {} : { status: status as TEventStatus }),
|
|
158
162
|
...(ref === undefined ? {} : { ref: clean(ref) }),
|
|
159
163
|
source: clean(source),
|
|
160
164
|
};
|