@venizia/vulcan 0.4.9-3 → 0.4.9-5
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/ci-global.json +13 -0
- package/base/claude/commit-attribution.json +7 -0
- package/base/claude/events.json +60 -0
- package/base/commit-agents.json +41 -0
- package/base/hooks/event.ts +37 -0
- package/base/rules.md +1 -1
- package/base/templates/ci/github-actions.yml +75 -0
- package/base/templates/ci/gitlab-ci.yml +52 -0
- package/package.json +3 -3
- package/src/ci/affected.ts +176 -0
- package/src/ci/command.ts +166 -0
- package/src/ci/common/constants.ts +76 -0
- package/src/ci/common/index.ts +2 -0
- package/src/ci/common/types.ts +37 -0
- package/src/ci/git.ts +72 -0
- package/src/ci/global.ts +48 -0
- package/src/ci/graph.ts +43 -0
- package/src/ci/index.ts +7 -0
- package/src/ci/workspace.ts +119 -0
- package/src/commands/ci.command.ts +4 -0
- package/src/commands/clean.command.ts +3 -5
- package/src/commands/commit-check.command.ts +5 -0
- package/src/commands/event.command.ts +5 -0
- package/src/commands/help.command.ts +14 -2
- package/src/commands/index.ts +28 -27
- package/src/commands/sync.command.ts +2 -0
- package/src/commit/agents.ts +32 -0
- package/src/commit/check.ts +160 -0
- package/src/commit/common/constants.ts +28 -0
- package/src/commit/common/index.ts +2 -0
- package/src/commit/common/types.ts +57 -0
- package/src/commit/hook.ts +187 -0
- package/src/commit/index.ts +8 -0
- package/src/commit/message.ts +74 -0
- package/src/commit/policy.ts +110 -0
- package/src/commit/signature.ts +94 -0
- package/src/commit/subject.ts +40 -0
- package/src/common/constants.ts +13 -0
- package/src/config/common/constants.ts +1 -0
- package/src/config/schema.ts +102 -0
- package/src/doctor/checks.ts +129 -7
- package/src/doctor/common/constants.ts +2 -0
- package/src/doctor/runner.ts +3 -0
- package/src/events/actor.ts +116 -0
- package/src/events/command.ts +191 -0
- package/src/events/common/constants.ts +118 -0
- package/src/events/common/index.ts +2 -0
- package/src/events/common/types.ts +39 -0
- package/src/events/flow.ts +92 -0
- package/src/events/hook.ts +163 -0
- package/src/events/index.ts +8 -0
- package/src/events/log.ts +162 -0
- package/src/events/settings.ts +80 -0
- package/src/events/text.ts +49 -0
- package/src/local/constants.ts +36 -1
- package/src/local/scan.ts +256 -27
- package/src/manifest/render.ts +42 -0
- package/src/router.ts +47 -7
- package/src/sync/common/constants.ts +3 -0
- package/src/sync/local-choice.ts +3 -3
- package/src/sync/planner.ts +20 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export class CiSubcommands {
|
|
2
|
+
static readonly AFFECTED = 'affected';
|
|
3
|
+
static readonly TEMPLATE = 'template';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class CiFlags {
|
|
7
|
+
static readonly BASE = '--base';
|
|
8
|
+
static readonly HEAD = '--head';
|
|
9
|
+
static readonly CHECK = '--check';
|
|
10
|
+
static readonly JSON = '--json';
|
|
11
|
+
static readonly NAMES = '--names';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The checks a package can have: each is the name of a `package.json` script, the standard names of an app. */
|
|
15
|
+
export class CiChecks {
|
|
16
|
+
static readonly TYPECHECK = 'typecheck';
|
|
17
|
+
static readonly LINT = 'lint';
|
|
18
|
+
static readonly TEST = 'test';
|
|
19
|
+
static readonly COMPILE = 'compile';
|
|
20
|
+
|
|
21
|
+
static readonly SCHEME_SET = new Set<string>([
|
|
22
|
+
this.TYPECHECK,
|
|
23
|
+
this.LINT,
|
|
24
|
+
this.TEST,
|
|
25
|
+
this.COMPILE,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
static isValid(value: string): boolean {
|
|
29
|
+
return this.SCHEME_SET.has(value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Why a package is on the list. */
|
|
34
|
+
export class AffectedReasons {
|
|
35
|
+
/** One of its files changed. */
|
|
36
|
+
static readonly CHANGED = 'changed';
|
|
37
|
+
/** A package it depends on is affected. */
|
|
38
|
+
static readonly DEPENDENT = 'dependent';
|
|
39
|
+
/** A file every package depends on changed, so all are on the list. */
|
|
40
|
+
static readonly GLOBAL = 'global';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The CI systems that have a template. */
|
|
44
|
+
export class CiTemplates {
|
|
45
|
+
static readonly GITHUB = 'github';
|
|
46
|
+
static readonly GITLAB = 'gitlab';
|
|
47
|
+
|
|
48
|
+
static readonly FILES: Record<string, string> = {
|
|
49
|
+
[this.GITHUB]: 'github-actions.yml',
|
|
50
|
+
[this.GITLAB]: 'gitlab-ci.yml',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
static readonly SCHEME_SET = new Set<string>([this.GITHUB, this.GITLAB]);
|
|
54
|
+
|
|
55
|
+
static isValid(value: string): boolean {
|
|
56
|
+
return this.SCHEME_SET.has(value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class CiConstants {
|
|
61
|
+
static readonly ROOT_MANIFEST = 'package.json';
|
|
62
|
+
static readonly MANIFEST_FILE = '.agents/vulcan.manifest.json';
|
|
63
|
+
/** The shipped list of files every package depends on, in the package's `base/`. */
|
|
64
|
+
static readonly GLOBAL_FILE = 'ci-global.json';
|
|
65
|
+
static readonly TEMPLATE_FOLDER = 'templates/ci';
|
|
66
|
+
/** What a CI system passes as the base of a push that has no parent: nothing to compare with. */
|
|
67
|
+
static readonly EMPTY_BASE = /^0{40}(?:0{24})?$/;
|
|
68
|
+
static readonly DEPENDENCY_FIELDS = [
|
|
69
|
+
'dependencies',
|
|
70
|
+
'devDependencies',
|
|
71
|
+
'peerDependencies',
|
|
72
|
+
'optionalDependencies',
|
|
73
|
+
];
|
|
74
|
+
static readonly GIT_TIMEOUT_MS = 30_000;
|
|
75
|
+
static readonly GIT_MAX_BUFFER = 256 * 1024 * 1024;
|
|
76
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TConstValue } from '../../common/index.ts';
|
|
2
|
+
import type { AffectedReasons, CiChecks } from './constants.ts';
|
|
3
|
+
|
|
4
|
+
export type TCiCheck = TConstValue<typeof CiChecks>;
|
|
5
|
+
export type TAffectedReason = TConstValue<typeof AffectedReasons>;
|
|
6
|
+
|
|
7
|
+
/** A package of the workspace, as its `package.json` says. */
|
|
8
|
+
export interface IWorkspacePackage {
|
|
9
|
+
name: string;
|
|
10
|
+
/** Relative to the root, with `/`. */
|
|
11
|
+
dir: string;
|
|
12
|
+
scripts: Record<string, string>;
|
|
13
|
+
/** Every dependency of every field: the name and the spec it is declared with. */
|
|
14
|
+
dependencies: IDependency[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IDependency {
|
|
18
|
+
name: string;
|
|
19
|
+
spec: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface IAffectedPackage {
|
|
23
|
+
name: string;
|
|
24
|
+
dir: string;
|
|
25
|
+
reason: TAffectedReason;
|
|
26
|
+
/** The checks the package has: the check name to the script that runs it. */
|
|
27
|
+
checks: Partial<Record<TCiCheck, string>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IAffectedResult {
|
|
31
|
+
base: string;
|
|
32
|
+
head: string;
|
|
33
|
+
/** Whether every package is on the list, and the file or the fact that made it so. */
|
|
34
|
+
all: boolean;
|
|
35
|
+
allBecause?: string;
|
|
36
|
+
packages: IAffectedPackage[];
|
|
37
|
+
}
|
package/src/ci/git.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { CiConstants } from './common/index.ts';
|
|
3
|
+
|
|
4
|
+
type TGitResult = { ok: true; stdout: string } | { ok: false; error: string };
|
|
5
|
+
|
|
6
|
+
/** The few read-only git questions the command asks. */
|
|
7
|
+
export class CiGit {
|
|
8
|
+
static run(opts: { root: string; args: string[] }): TGitResult {
|
|
9
|
+
const result = spawnSync('git', opts.args, {
|
|
10
|
+
cwd: opts.root,
|
|
11
|
+
encoding: 'utf8',
|
|
12
|
+
timeout: CiConstants.GIT_TIMEOUT_MS,
|
|
13
|
+
maxBuffer: CiConstants.GIT_MAX_BUFFER,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (result.error !== undefined) {
|
|
17
|
+
return { ok: false, error: `git could not run: ${result.error.message}` };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return result.status === 0
|
|
21
|
+
? { ok: true, stdout: result.stdout }
|
|
22
|
+
: { ok: false, error: result.stderr.trim() || `git ${opts.args[0]} exited ${result.status}` };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The commit a revision names, or the reason it names none. */
|
|
26
|
+
static resolve(opts: { root: string; ref: string }): TGitResult {
|
|
27
|
+
const result = CiGit.run({
|
|
28
|
+
root: opts.root,
|
|
29
|
+
args: ['rev-parse', '--verify', '--quiet', '--end-of-options', `${opts.ref}^{commit}`],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return result.ok
|
|
33
|
+
? { ok: true, stdout: result.stdout.trim() }
|
|
34
|
+
: {
|
|
35
|
+
ok: false,
|
|
36
|
+
error: `${opts.ref} is not a commit here (a shallow clone has only the recent ones: fetch-depth 0 in GitHub Actions, GIT_DEPTH 0 in GitLab CI)`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The files that differ between the merge base of two commits and the second one, deletions and both sides of a rename included. */
|
|
41
|
+
static changedFiles(opts: {
|
|
42
|
+
root: string;
|
|
43
|
+
base: string;
|
|
44
|
+
head: string;
|
|
45
|
+
}): { ok: true; files: string[]; mergeBase: string } | { ok: false; error: string } {
|
|
46
|
+
const mergeBase = CiGit.run({ root: opts.root, args: ['merge-base', opts.base, opts.head] });
|
|
47
|
+
|
|
48
|
+
if (!mergeBase.ok) {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
error: `${opts.base} and ${opts.head} share no history here (a shallow clone cuts it: fetch-depth 0 in GitHub Actions, GIT_DEPTH 0 in GitLab CI)`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const point = mergeBase.stdout.trim();
|
|
56
|
+
const diff = CiGit.run({
|
|
57
|
+
root: opts.root,
|
|
58
|
+
args: ['diff', '--name-only', '--no-renames', '-z', point, opts.head],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return diff.ok
|
|
62
|
+
? { ok: true, files: diff.stdout.split('\0').filter((file) => file !== ''), mergeBase: point }
|
|
63
|
+
: { ok: false, error: diff.error };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The text of a file at a commit, or `undefined` when the commit has no such file. */
|
|
67
|
+
static show(opts: { root: string; commit: string; path: string }): string | undefined {
|
|
68
|
+
const result = CiGit.run({ root: opts.root, args: ['show', `${opts.commit}:${opts.path}`] });
|
|
69
|
+
|
|
70
|
+
return result.ok ? result.stdout : undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/ci/global.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { BASE_DIRECTORY } from '../common/paths.ts';
|
|
4
|
+
import { RecordValue } from '../common/record.ts';
|
|
5
|
+
import { CiConstants } from './common/index.ts';
|
|
6
|
+
|
|
7
|
+
/** The files every package depends on: when one changes, all of them are affected. */
|
|
8
|
+
export class CiGlobal {
|
|
9
|
+
/** The shipped list (data, `base/ci-global.json`) and the project's own from the manifest. */
|
|
10
|
+
static read(opts: { root: string }): string[] {
|
|
11
|
+
return [...CiGlobal.shipped(), ...CiGlobal.project({ root: opts.root })];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The first file of `files` that matches one of `globs` (root-relative, dotfiles included). */
|
|
15
|
+
static firstHit(opts: { files: string[]; globs: string[] }): string | undefined {
|
|
16
|
+
const matchers = opts.globs.map((glob) => new Bun.Glob(glob));
|
|
17
|
+
|
|
18
|
+
return opts.files.find((file) => matchers.some((matcher) => matcher.match(file)));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private static shipped(): string[] {
|
|
22
|
+
const list: unknown = JSON.parse(
|
|
23
|
+
readFileSync(join(BASE_DIRECTORY, CiConstants.GLOBAL_FILE), 'utf8'),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return RecordValue.isRecord(list) ? CiGlobal.stringsOf({ value: list.files }) : [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private static project(opts: { root: string }): string[] {
|
|
30
|
+
try {
|
|
31
|
+
const manifest: unknown = JSON.parse(
|
|
32
|
+
readFileSync(join(opts.root, CiConstants.MANIFEST_FILE), 'utf8'),
|
|
33
|
+
);
|
|
34
|
+
const ci = RecordValue.isRecord(manifest) ? manifest.ci : undefined;
|
|
35
|
+
const affected = RecordValue.isRecord(ci) ? ci.affected : undefined;
|
|
36
|
+
|
|
37
|
+
return RecordValue.isRecord(affected) ? CiGlobal.stringsOf({ value: affected.global }) : [];
|
|
38
|
+
} catch {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static stringsOf(opts: { value: unknown }): string[] {
|
|
44
|
+
return Array.isArray(opts.value)
|
|
45
|
+
? opts.value.filter((entry): entry is string => typeof entry === 'string' && entry !== '')
|
|
46
|
+
: [];
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/ci/graph.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AffectedReasons } from './common/index.ts';
|
|
2
|
+
import type { IWorkspacePackage, TAffectedReason } from './common/index.ts';
|
|
3
|
+
|
|
4
|
+
/** Who depends on whom, inside the workspace. */
|
|
5
|
+
export class CiGraph {
|
|
6
|
+
/**
|
|
7
|
+
* `seeds` and every package that depends on one, directly or through others, each with the reason it is
|
|
8
|
+
* on the list: a seed keeps its own, the others are `dependent`. A dependency on a workspace package
|
|
9
|
+
* counts whatever its spec is (`workspace:*`, a range, `catalog:`), which can only add a package, never
|
|
10
|
+
* lose one. Cycles end.
|
|
11
|
+
*/
|
|
12
|
+
static closure(opts: {
|
|
13
|
+
packages: IWorkspacePackage[];
|
|
14
|
+
seeds: Map<string, TAffectedReason>;
|
|
15
|
+
}): Map<string, TAffectedReason> {
|
|
16
|
+
const names = new Set(opts.packages.map((entry) => entry.name));
|
|
17
|
+
const dependents = new Map<string, string[]>();
|
|
18
|
+
|
|
19
|
+
for (const entry of opts.packages) {
|
|
20
|
+
for (const dependency of entry.dependencies) {
|
|
21
|
+
if (names.has(dependency.name) && dependency.name !== entry.name) {
|
|
22
|
+
dependents.set(dependency.name, [...(dependents.get(dependency.name) ?? []), entry.name]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const reached = new Map<string, TAffectedReason>(opts.seeds);
|
|
28
|
+
const queue = [...opts.seeds.keys()];
|
|
29
|
+
|
|
30
|
+
while (queue.length > 0) {
|
|
31
|
+
const name = queue.shift() ?? '';
|
|
32
|
+
|
|
33
|
+
for (const dependent of dependents.get(name) ?? []) {
|
|
34
|
+
if (!reached.has(dependent)) {
|
|
35
|
+
reached.set(dependent, AffectedReasons.DEPENDENT);
|
|
36
|
+
queue.push(dependent);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return reached;
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/ci/index.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { RecordValue } from '../common/record.ts';
|
|
4
|
+
import { CiConstants } from './common/index.ts';
|
|
5
|
+
import type { IDependency, IWorkspacePackage } from './common/index.ts';
|
|
6
|
+
|
|
7
|
+
type TWorkspaceRead = { ok: true; packages: IWorkspacePackage[] } | { ok: false; error: string };
|
|
8
|
+
|
|
9
|
+
/** The packages of the workspace: the folders the root `package.json` lists in `workspaces`. */
|
|
10
|
+
export class CiWorkspace {
|
|
11
|
+
/**
|
|
12
|
+
* Every folder with a `package.json` that the `workspaces` globs match (an array, or an object with
|
|
13
|
+
* `packages`; a `!` glob removes), with a name, sorted by folder. `node_modules` is never searched.
|
|
14
|
+
*/
|
|
15
|
+
static read(opts: { root: string }): TWorkspaceRead {
|
|
16
|
+
const file = join(opts.root, CiConstants.ROOT_MANIFEST);
|
|
17
|
+
|
|
18
|
+
if (!existsSync(file)) {
|
|
19
|
+
return { ok: false, error: `no ${CiConstants.ROOT_MANIFEST} in ${opts.root}` };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let manifest: unknown;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
manifest = JSON.parse(readFileSync(file, 'utf8'));
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return {
|
|
28
|
+
ok: false,
|
|
29
|
+
error: `${CiConstants.ROOT_MANIFEST} is not JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const globs = RecordValue.isRecord(manifest)
|
|
34
|
+
? CiWorkspace.globsOf({ value: manifest.workspaces })
|
|
35
|
+
: [];
|
|
36
|
+
|
|
37
|
+
if (globs.length === 0) {
|
|
38
|
+
return { ok: false, error: `${CiConstants.ROOT_MANIFEST} lists no workspaces` };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const include = globs.filter((glob) => !glob.startsWith('!'));
|
|
42
|
+
// `!apps/old/**` leaves out the folder itself too, which the glob alone does not match.
|
|
43
|
+
const exclude = globs
|
|
44
|
+
.filter((glob) => glob.startsWith('!'))
|
|
45
|
+
.flatMap((glob) => [glob.slice(1), glob.slice(1).replace(/\/\*\*$/, '')])
|
|
46
|
+
.map((pattern) => new Bun.Glob(pattern));
|
|
47
|
+
const dirs = new Set<string>();
|
|
48
|
+
|
|
49
|
+
for (const glob of include) {
|
|
50
|
+
const scan = new Bun.Glob(`${glob.replace(/\/+$/, '')}/${CiConstants.ROOT_MANIFEST}`);
|
|
51
|
+
|
|
52
|
+
for (const match of scan.scanSync({ cwd: opts.root, onlyFiles: true })) {
|
|
53
|
+
const dir = dirname(match).split('\\').join('/');
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
!dir.split('/').includes('node_modules') &&
|
|
57
|
+
!exclude.some((pattern) => pattern.match(dir))
|
|
58
|
+
) {
|
|
59
|
+
dirs.add(dir);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const packages = [...dirs]
|
|
65
|
+
.sort()
|
|
66
|
+
.flatMap((dir) => CiWorkspace.packageAt({ root: opts.root, dir }) ?? []);
|
|
67
|
+
|
|
68
|
+
return { ok: true, packages };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private static globsOf(opts: { value: unknown }): string[] {
|
|
72
|
+
const list = Array.isArray(opts.value)
|
|
73
|
+
? opts.value
|
|
74
|
+
: RecordValue.isRecord(opts.value) && Array.isArray(opts.value.packages)
|
|
75
|
+
? opts.value.packages
|
|
76
|
+
: [];
|
|
77
|
+
|
|
78
|
+
return list.filter((entry): entry is string => typeof entry === 'string' && entry !== '');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private static packageAt(opts: { root: string; dir: string }): IWorkspacePackage | undefined {
|
|
82
|
+
let manifest: unknown;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
manifest = JSON.parse(
|
|
86
|
+
readFileSync(join(opts.root, opts.dir, CiConstants.ROOT_MANIFEST), 'utf8'),
|
|
87
|
+
);
|
|
88
|
+
} catch {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (
|
|
93
|
+
!RecordValue.isRecord(manifest) ||
|
|
94
|
+
typeof manifest.name !== 'string' ||
|
|
95
|
+
manifest.name === ''
|
|
96
|
+
) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const scripts = RecordValue.isRecord(manifest.scripts)
|
|
101
|
+
? Object.fromEntries(
|
|
102
|
+
Object.entries(manifest.scripts).filter(
|
|
103
|
+
(entry): entry is [string, string] => typeof entry[1] === 'string',
|
|
104
|
+
),
|
|
105
|
+
)
|
|
106
|
+
: {};
|
|
107
|
+
const dependencies: IDependency[] = CiConstants.DEPENDENCY_FIELDS.flatMap((field) => {
|
|
108
|
+
const block = manifest[field];
|
|
109
|
+
|
|
110
|
+
return RecordValue.isRecord(block)
|
|
111
|
+
? Object.entries(block)
|
|
112
|
+
.filter((entry): entry is [string, string] => typeof entry[1] === 'string')
|
|
113
|
+
.map(([name, spec]) => ({ name, spec }))
|
|
114
|
+
: [];
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return { name: manifest.name, dir: opts.dir, scripts, dependencies };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -10,7 +10,7 @@ const lineOf = (opts: { entry: ILocalEntry }): string => {
|
|
|
10
10
|
const { entry } = opts;
|
|
11
11
|
const note = entry.note === '' ? (entry.state === 'stale' ? 'stale' : '') : entry.note;
|
|
12
12
|
|
|
13
|
-
return ` ${entry.
|
|
13
|
+
return ` ${entry.where} ${LocalFormat.formatBytes({ bytes: entry.bytes })} ${LocalFormat.formatAge({ ageMs: entry.ageMs })}${note === '' ? '' : ` ${note}`}`;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -45,7 +45,7 @@ export const runCleanCommand = async (opts: ICommandContext): Promise<number> =>
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
for (const entry of plan.keep) {
|
|
48
|
-
process.stderr.write(` kept ${entry.
|
|
48
|
+
process.stderr.write(` kept ${entry.where} ${entry.note}\n`);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (!yes) {
|
|
@@ -59,9 +59,7 @@ export const runCleanCommand = async (opts: ICommandContext): Promise<number> =>
|
|
|
59
59
|
const result = LocalClean.run({ root: opts.cwd, plan });
|
|
60
60
|
|
|
61
61
|
for (const failure of result.failed) {
|
|
62
|
-
process.stderr.write(
|
|
63
|
-
` failed ${failure.entry.scope}/${failure.entry.name}: ${failure.error}\n`,
|
|
64
|
-
);
|
|
62
|
+
process.stderr.write(` failed ${failure.entry.where}: ${failure.error}\n`);
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
process.stderr.write(
|
|
@@ -27,6 +27,18 @@ Usage: bun x vulcan <command>
|
|
|
27
27
|
agents [list|add <ids>|remove <ids>|setup] [--dry-run]
|
|
28
28
|
See, add, remove or re-choose the coding agents you use on this machine
|
|
29
29
|
doctor Check the project follows VULCAN; exit 1 on any violation
|
|
30
|
+
commit-check <message-file> | --range <revs> | --text <message>
|
|
31
|
+
Check a commit message against the commit.message checks of the config (an
|
|
32
|
+
agent in a trailer or a "generated with" line, the project's subject shape);
|
|
33
|
+
sync installs it as the commit-msg hook; exit 1 on a problem, 2 on bad input
|
|
34
|
+
ci affected --base <ref> [--head <ref>] [--check <check>] [--json | --names] | template <github|gitlab>
|
|
35
|
+
List the workspace packages a change touches (changed ones and what
|
|
36
|
+
depends on them) with the checks each has; template prints a CI file that
|
|
37
|
+
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>]
|
|
39
|
+
Write a line to the agent event log (.agents/local/events/<day>.jsonl) or
|
|
40
|
+
read it; with events.log on, sync installs the Claude Code hooks that
|
|
41
|
+
write it; exit 2 on bad input
|
|
30
42
|
visualize <spec.json> [--out <name>] | --schema
|
|
31
43
|
Make one small static HTML page (a flow, a status, a before and after) from
|
|
32
44
|
a JSON spec, in .agents/local/prototypes/; --schema prints the spec's schema
|
|
@@ -34,10 +46,10 @@ Usage: bun x vulcan <command>
|
|
|
34
46
|
Tell VULCAN how you like to work (reply language, how to address you,
|
|
35
47
|
tone, habits) in .agents/local/profile.json; no argument runs the form,
|
|
36
48
|
show prints it, reset deletes it
|
|
37
|
-
clean [--tmp|--worktrees|--clones|--cache|--all] [--reports|--prototypes|--profile] [--yes]
|
|
49
|
+
clean [--tmp|--worktrees|--clones|--cache|--all] [--reports|--prototypes|--events|--release-candidates|--profile] [--yes]
|
|
38
50
|
List what an agent left under .agents/local/ (a dry run) and, with
|
|
39
51
|
--yes, remove it; --tmp is the default, --worktrees takes merged or
|
|
40
|
-
gone branches only, --all never touches reports, prototypes or the profile
|
|
52
|
+
gone branches only, --all never touches reports, prototypes, events, release candidates or the profile
|
|
41
53
|
upgrade [--stable | --nightly] [<version|tag>]
|
|
42
54
|
Bump the pinned @venizia/vulcan, then sync; --stable (default)
|
|
43
55
|
takes the latest tag, --nightly the newest of latest and next
|
package/src/commands/index.ts
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { VulcanCommands } from '../common/index.ts';
|
|
2
2
|
import type { TCommandHandler } from '../common/index.ts';
|
|
3
|
-
import { runAddCommand } from './add.command.ts';
|
|
4
|
-
import { runAgentsCommand } from './agents.command.ts';
|
|
5
|
-
import { runCleanCommand } from './clean.command.ts';
|
|
6
|
-
import { runDoctorCommand } from './doctor.command.ts';
|
|
7
|
-
import { runHelpCommand, runVersionCommand } from './help.command.ts';
|
|
8
|
-
import { runInitCommand } from './init.command.ts';
|
|
9
|
-
import { runPresetCommand } from './preset.command.ts';
|
|
10
|
-
import { runProfileCommand } from './profile.command.ts';
|
|
11
|
-
import { runSyncCommand } from './sync.command.ts';
|
|
12
|
-
import { runUpgradeCommand } from './upgrade.command.ts';
|
|
13
|
-
import { runVisualizeCommand } from './visualize.command.ts';
|
|
14
|
-
import { runXCommand } from './x.command.ts';
|
|
15
3
|
|
|
16
|
-
/**
|
|
17
|
-
export const
|
|
18
|
-
[VulcanCommands.ADD]: runAddCommand,
|
|
19
|
-
[VulcanCommands.AGENTS]:
|
|
20
|
-
|
|
21
|
-
[VulcanCommands.
|
|
22
|
-
[VulcanCommands.
|
|
23
|
-
|
|
24
|
-
[VulcanCommands.
|
|
25
|
-
|
|
26
|
-
[VulcanCommands.
|
|
27
|
-
|
|
28
|
-
[VulcanCommands.
|
|
29
|
-
|
|
30
|
-
[VulcanCommands.
|
|
4
|
+
/** Each command is loaded when it runs: `commit-check` is called by a git hook and must not load the commands that need atlas. */
|
|
5
|
+
export const COMMAND_LOADERS: Record<string, () => Promise<TCommandHandler>> = {
|
|
6
|
+
[VulcanCommands.ADD]: () => import('./add.command.ts').then((module) => module.runAddCommand),
|
|
7
|
+
[VulcanCommands.AGENTS]: () =>
|
|
8
|
+
import('./agents.command.ts').then((module) => module.runAgentsCommand),
|
|
9
|
+
[VulcanCommands.CI]: () => import('./ci.command.ts').then((module) => module.runCiCommand),
|
|
10
|
+
[VulcanCommands.CLEAN]: () =>
|
|
11
|
+
import('./clean.command.ts').then((module) => module.runCleanCommand),
|
|
12
|
+
[VulcanCommands.COMMIT_CHECK]: () =>
|
|
13
|
+
import('./commit-check.command.ts').then((module) => module.runCommitCheckCommand),
|
|
14
|
+
[VulcanCommands.DOCTOR]: () =>
|
|
15
|
+
import('./doctor.command.ts').then((module) => module.runDoctorCommand),
|
|
16
|
+
[VulcanCommands.EVENT]: () =>
|
|
17
|
+
import('./event.command.ts').then((module) => module.runEventCommand),
|
|
18
|
+
[VulcanCommands.HELP]: () => import('./help.command.ts').then((module) => module.runHelpCommand),
|
|
19
|
+
[VulcanCommands.INIT]: () => import('./init.command.ts').then((module) => module.runInitCommand),
|
|
20
|
+
[VulcanCommands.PRESET]: () =>
|
|
21
|
+
import('./preset.command.ts').then((module) => module.runPresetCommand),
|
|
22
|
+
[VulcanCommands.PROFILE]: () =>
|
|
23
|
+
import('./profile.command.ts').then((module) => module.runProfileCommand),
|
|
24
|
+
[VulcanCommands.SYNC]: () => import('./sync.command.ts').then((module) => module.runSyncCommand),
|
|
25
|
+
[VulcanCommands.UPGRADE]: () =>
|
|
26
|
+
import('./upgrade.command.ts').then((module) => module.runUpgradeCommand),
|
|
27
|
+
[VulcanCommands.VERSION]: () =>
|
|
28
|
+
import('./help.command.ts').then((module) => module.runVersionCommand),
|
|
29
|
+
[VulcanCommands.VISUALIZE]: () =>
|
|
30
|
+
import('./visualize.command.ts').then((module) => module.runVisualizeCommand),
|
|
31
|
+
[VulcanCommands.X]: () => import('./x.command.ts').then((module) => module.runXCommand),
|
|
31
32
|
};
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
SyncPlanner,
|
|
22
22
|
SyncStatuses,
|
|
23
23
|
} from '../sync/index.ts';
|
|
24
|
+
import { CommitHookPlan } from '../commit/index.ts';
|
|
24
25
|
|
|
25
26
|
const DRY_RUN_FLAG = '--dry-run';
|
|
26
27
|
const LABEL_WIDTH = 9;
|
|
@@ -119,6 +120,7 @@ export class SyncFlow {
|
|
|
119
120
|
...stored,
|
|
120
121
|
...LocalPlan.planWorkspace({ root: opts.cwd }),
|
|
121
122
|
...ExcludePlan.plan({ root: opts.cwd, agents: resolved.agents }),
|
|
123
|
+
...CommitHookPlan.plan({ root: opts.cwd, config: loaded.config }),
|
|
122
124
|
];
|
|
123
125
|
// Read before the manifest action rewrites the hashes it compares against.
|
|
124
126
|
const changes = BaseRulesDiff.diff({ root: opts.cwd });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { BASE_DIRECTORY } from '../common/index.ts';
|
|
5
|
+
import type { ICommitAgents } from './common/index.ts';
|
|
6
|
+
|
|
7
|
+
const AGENTS_SCHEMA = z.strictObject({
|
|
8
|
+
products: z.array(z.string().min(1)).min(1),
|
|
9
|
+
mentions: z.array(z.string().min(1)).min(1),
|
|
10
|
+
addressNames: z.array(z.string().min(1)),
|
|
11
|
+
addressDomains: z.array(z.string().min(1)),
|
|
12
|
+
noreplyDomains: z.array(z.string().min(1)),
|
|
13
|
+
generatedPhrases: z.array(z.string().min(1)).min(1),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
let cached: z.output<typeof AGENTS_SCHEMA> | undefined;
|
|
17
|
+
|
|
18
|
+
export class CommitAgents {
|
|
19
|
+
/** `extra` joins both `products` and `mentions`. A broken table throws. */
|
|
20
|
+
static read(opts: { extra: string[]; allow?: string[] }): ICommitAgents {
|
|
21
|
+
cached ??= AGENTS_SCHEMA.parse(
|
|
22
|
+
JSON.parse(readFileSync(join(BASE_DIRECTORY, 'commit-agents.json'), 'utf8')),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
...cached,
|
|
27
|
+
products: [...new Set([...cached.products, ...opts.extra])],
|
|
28
|
+
mentions: [...new Set([...cached.mentions, ...opts.extra])],
|
|
29
|
+
allow: opts.allow ?? [],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|