@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
package/src/signals/state.ts
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
appendFileSync,
|
|
3
|
-
closeSync,
|
|
4
|
-
fstatSync,
|
|
5
|
-
lstatSync,
|
|
6
|
-
mkdirSync,
|
|
7
|
-
openSync,
|
|
8
|
-
readSync,
|
|
9
|
-
renameSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
writeFileSync,
|
|
12
|
-
} from 'node:fs';
|
|
13
|
-
import { randomBytes } from 'node:crypto';
|
|
14
|
-
import { dirname, join } from 'node:path';
|
|
15
|
-
import { LocalScan } from '../local/scan.ts';
|
|
16
|
-
import { EntryKinds, SignalConstants } from './constants.ts';
|
|
17
|
-
|
|
18
|
-
/** One line of the log. Only the fields of its kind are set. */
|
|
19
|
-
interface ISignalEntry {
|
|
20
|
-
kind: string;
|
|
21
|
-
/** The session and the agent inside it ('' for the main agent) the line belongs to. */
|
|
22
|
-
session: string;
|
|
23
|
-
agent: string;
|
|
24
|
-
at: number;
|
|
25
|
-
tool: string;
|
|
26
|
-
key: string;
|
|
27
|
-
isOk: boolean;
|
|
28
|
-
isProbe: boolean;
|
|
29
|
-
/** The gate commands the call ran, as short names. */
|
|
30
|
-
gates: string[];
|
|
31
|
-
isEdit: boolean;
|
|
32
|
-
/** The name of an advisory already given. */
|
|
33
|
-
name: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ISignalEvent {
|
|
37
|
-
tool: string;
|
|
38
|
-
key: string;
|
|
39
|
-
isOk: boolean;
|
|
40
|
-
at: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** What the log says about the current turn of one session. */
|
|
44
|
-
export interface ISignalState {
|
|
45
|
-
turnAt: number;
|
|
46
|
-
/** The calls of the turn, for the agent asked about. */
|
|
47
|
-
events: ISignalEvent[];
|
|
48
|
-
/** The last public-state probe of the turn, by any agent. */
|
|
49
|
-
probeAt: number;
|
|
50
|
-
/** Gates whose latest run in the turn failed, by any agent. */
|
|
51
|
-
failedGates: string[];
|
|
52
|
-
editAt: number;
|
|
53
|
-
/** When each advisory was last given, by name. */
|
|
54
|
-
notedAt: Record<string, number>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const recordOf = (opts: { value: unknown }): Record<string, unknown> =>
|
|
58
|
-
typeof opts.value === 'object' && opts.value !== null && !Array.isArray(opts.value)
|
|
59
|
-
? Object.fromEntries(Object.entries(opts.value))
|
|
60
|
-
: {};
|
|
61
|
-
|
|
62
|
-
const numberOf = (opts: { value: unknown }): number =>
|
|
63
|
-
typeof opts.value === 'number' && Number.isFinite(opts.value) ? opts.value : 0;
|
|
64
|
-
|
|
65
|
-
const stringOf = (opts: { value: unknown }): string =>
|
|
66
|
-
typeof opts.value === 'string' ? opts.value : '';
|
|
67
|
-
|
|
68
|
-
/** The log of a trusted `.agents/local/`; neither the cache folder nor the file may be a link, or not a plain file. */
|
|
69
|
-
const logFileOf = (opts: { root: string; create: boolean }): string | undefined => {
|
|
70
|
-
const local = LocalScan.localRootOf({ root: opts.root });
|
|
71
|
-
|
|
72
|
-
if (local === undefined) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const file = join(local, SignalConstants.LOG_FILE);
|
|
77
|
-
const directory = dirname(file);
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
const kind = lstatSync(directory, { throwIfNoEntry: false });
|
|
81
|
-
|
|
82
|
-
if (kind === undefined) {
|
|
83
|
-
if (!opts.create) {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
mkdirSync(directory, { recursive: true });
|
|
88
|
-
} else if (!kind.isDirectory()) {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const entry = lstatSync(file, { throwIfNoEntry: false });
|
|
93
|
-
|
|
94
|
-
return entry === undefined || entry.isFile() ? file : undefined;
|
|
95
|
-
} catch {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const entryOf = (opts: { value: unknown }): ISignalEntry | undefined => {
|
|
101
|
-
const raw = recordOf({ value: opts.value });
|
|
102
|
-
const kind = stringOf({ value: raw.kind });
|
|
103
|
-
|
|
104
|
-
if (kind !== EntryKinds.TURN && kind !== EntryKinds.CALL && kind !== EntryKinds.NOTE) {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
kind,
|
|
110
|
-
session: stringOf({ value: raw.session }),
|
|
111
|
-
agent: stringOf({ value: raw.agent }),
|
|
112
|
-
at: numberOf({ value: raw.at }),
|
|
113
|
-
tool: stringOf({ value: raw.tool }),
|
|
114
|
-
key: stringOf({ value: raw.key }),
|
|
115
|
-
isOk: raw.isOk === true,
|
|
116
|
-
isProbe: raw.isProbe === true,
|
|
117
|
-
gates: Array.isArray(raw.gates)
|
|
118
|
-
? raw.gates.filter((gate): gate is string => typeof gate === 'string')
|
|
119
|
-
: [],
|
|
120
|
-
isEdit: raw.isEdit === true,
|
|
121
|
-
name: stringOf({ value: raw.name }),
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/** The log's lines, the end only when it is large; a damaged line is skipped. */
|
|
126
|
-
const readEntries = (opts: { file: string }): ISignalEntry[] => {
|
|
127
|
-
let text = '';
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
const descriptor = openSync(opts.file, 'r');
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
const { size } = fstatSync(descriptor);
|
|
134
|
-
const length = Math.min(size, SignalConstants.READ_TAIL_BYTES);
|
|
135
|
-
const buffer = Buffer.alloc(length);
|
|
136
|
-
|
|
137
|
-
readSync(descriptor, buffer, 0, length, size - length);
|
|
138
|
-
text = buffer.toString('utf8');
|
|
139
|
-
} finally {
|
|
140
|
-
closeSync(descriptor);
|
|
141
|
-
}
|
|
142
|
-
} catch {
|
|
143
|
-
return [];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const entries: ISignalEntry[] = [];
|
|
147
|
-
|
|
148
|
-
for (const line of text.split('\n')) {
|
|
149
|
-
try {
|
|
150
|
-
const entry = entryOf({ value: JSON.parse(line) });
|
|
151
|
-
|
|
152
|
-
if (entry !== undefined) {
|
|
153
|
-
entries.push(entry);
|
|
154
|
-
}
|
|
155
|
-
} catch {
|
|
156
|
-
// A damaged or cut line: the log is advisory.
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return entries;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const EMPTY_STATE = (): ISignalState => ({
|
|
164
|
-
turnAt: 0,
|
|
165
|
-
events: [],
|
|
166
|
-
probeAt: 0,
|
|
167
|
-
failedGates: [],
|
|
168
|
-
editAt: 0,
|
|
169
|
-
notedAt: {},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
export class SignalState {
|
|
173
|
-
/** The current turn of `session`: its last prompt, then the calls since. `agent` narrows the events only. */
|
|
174
|
-
static read(opts: { root: string; session: string; agent?: string }): ISignalState {
|
|
175
|
-
const file = logFileOf({ root: opts.root, create: false });
|
|
176
|
-
|
|
177
|
-
if (file === undefined) {
|
|
178
|
-
return EMPTY_STATE();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const entries = readEntries({ file });
|
|
182
|
-
const state = EMPTY_STATE();
|
|
183
|
-
const gates = new Map<string, boolean>();
|
|
184
|
-
const mine = entries.filter(
|
|
185
|
-
(entry) => entry.kind === EntryKinds.NOTE || entry.session === opts.session,
|
|
186
|
-
);
|
|
187
|
-
const turnIndex = mine.findLastIndex((entry) => entry.kind === EntryKinds.TURN);
|
|
188
|
-
|
|
189
|
-
for (const entry of mine) {
|
|
190
|
-
if (entry.kind === EntryKinds.NOTE) {
|
|
191
|
-
state.notedAt[entry.name] = Math.max(state.notedAt[entry.name] ?? 0, entry.at);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
state.turnAt = turnIndex === -1 ? 0 : (mine[turnIndex]?.at ?? 0);
|
|
196
|
-
|
|
197
|
-
for (const entry of mine.slice(turnIndex + 1)) {
|
|
198
|
-
if (entry.kind !== EntryKinds.CALL) {
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (opts.agent === undefined || entry.agent === opts.agent) {
|
|
203
|
-
state.events.push({ tool: entry.tool, key: entry.key, isOk: entry.isOk, at: entry.at });
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (entry.isProbe) {
|
|
207
|
-
state.probeAt = Math.max(state.probeAt, entry.at);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (entry.isEdit) {
|
|
211
|
-
state.editAt = Math.max(state.editAt, entry.at);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
for (const gate of entry.gates) {
|
|
215
|
-
gates.set(gate, entry.isOk);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
state.events = state.events.slice(-SignalConstants.MAX_EVENTS);
|
|
220
|
-
state.failedGates = [...gates.entries()].filter(([, isOk]) => !isOk).map(([gate]) => gate);
|
|
221
|
-
|
|
222
|
-
return state;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/** Adds one line; appending a short line is atomic, so parallel hook processes lose nothing. */
|
|
226
|
-
static append(opts: {
|
|
227
|
-
root: string;
|
|
228
|
-
entry: Partial<ISignalEntry> & { kind: string; at: number };
|
|
229
|
-
}): void {
|
|
230
|
-
const file = logFileOf({ root: opts.root, create: true });
|
|
231
|
-
|
|
232
|
-
if (file === undefined) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
appendFileSync(file, `${JSON.stringify(opts.entry)}\n`, { mode: 0o600 });
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/** A new turn for `session`: a marker line; a log grown past its size is first cut to what still matters. */
|
|
240
|
-
static startTurn(opts: { root: string; session: string; now?: number }): void {
|
|
241
|
-
const file = logFileOf({ root: opts.root, create: true });
|
|
242
|
-
|
|
243
|
-
if (file === undefined) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const now = opts.now ?? Date.now();
|
|
248
|
-
|
|
249
|
-
if ((lstatSync(file, { throwIfNoEntry: false })?.size ?? 0) > SignalConstants.COMPACT_BYTES) {
|
|
250
|
-
const kept = readEntries({ file }).filter(
|
|
251
|
-
(entry) => entry.kind === EntryKinds.NOTE || now - entry.at < SignalConstants.DEBOUNCE_MS,
|
|
252
|
-
);
|
|
253
|
-
const partial = `${file}.${randomBytes(6).toString('hex')}.partial`;
|
|
254
|
-
|
|
255
|
-
try {
|
|
256
|
-
writeFileSync(partial, kept.map((entry) => `${JSON.stringify(entry)}\n`).join(''), {
|
|
257
|
-
mode: 0o600,
|
|
258
|
-
flag: 'wx',
|
|
259
|
-
});
|
|
260
|
-
renameSync(partial, file);
|
|
261
|
-
} finally {
|
|
262
|
-
rmSync(partial, { force: true });
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
SignalState.append({
|
|
267
|
-
root: opts.root,
|
|
268
|
-
entry: { kind: EntryKinds.TURN, session: opts.session, at: now },
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
package/src/sync/atlas-block.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { AtlasBlock } from '../agents/index.ts';
|
|
4
|
-
import type { TResolvedConfig } from '../config/index.ts';
|
|
5
|
-
import { ProjectManifest } from '../manifest/index.ts';
|
|
6
|
-
import { SyncStatuses } from './common/index.ts';
|
|
7
|
-
import type { ISyncAction } from './common/index.ts';
|
|
8
|
-
|
|
9
|
-
const NO_CHANGE = (): void => {};
|
|
10
|
-
|
|
11
|
-
export class AtlasBlockPlan {
|
|
12
|
-
/**
|
|
13
|
-
* The block's text for this project, or undefined when AGENTS.md is absent. Every project has the
|
|
14
|
-
* atlas server, and the block is what an agent that does not show the server's own text reads, so it
|
|
15
|
-
* does not wait for a per-machine MCP file to exist.
|
|
16
|
-
*/
|
|
17
|
-
static merged(opts: {
|
|
18
|
-
root: string;
|
|
19
|
-
config: TResolvedConfig;
|
|
20
|
-
}): { path: string; changed: boolean; text: string } | undefined {
|
|
21
|
-
const path = join(opts.root, 'AGENTS.md');
|
|
22
|
-
|
|
23
|
-
if (!existsSync(path)) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const block = AtlasBlock.render({
|
|
28
|
-
project: ProjectManifest.projectNameOf(opts),
|
|
29
|
-
sources: opts.config.atlas.sources.map((source) => source.name),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return { path, ...AtlasBlock.merge({ text: readFileSync(path, 'utf8'), block }) };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** The committed AGENTS.md carries the block for every agent, Claude included. */
|
|
36
|
-
static plan(opts: { root: string; config: TResolvedConfig }): ISyncAction[] {
|
|
37
|
-
const merged = AtlasBlockPlan.merged(opts);
|
|
38
|
-
|
|
39
|
-
if (merged === undefined) {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!merged.changed) {
|
|
44
|
-
return [{ path: merged.path, status: SyncStatuses.UNCHANGED, apply: NO_CHANGE }];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return [
|
|
48
|
-
{
|
|
49
|
-
path: merged.path,
|
|
50
|
-
status: SyncStatuses.REPLACED,
|
|
51
|
-
note: 'Atlas block',
|
|
52
|
-
apply: () => writeFileSync(merged.path, merged.text),
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
}
|
|
56
|
-
}
|