@venizia/vulcan 0.4.9-0 → 0.4.9-2
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/extensions/vulcan-guards.ts +48 -41
- package/base/hooks/antigravity-guards.ts +2 -2
- package/base/hooks/codex-guards.ts +15 -5
- package/base/hooks/guard-git.ts +8 -8
- package/base/hooks/guard-manifest.ts +4 -5
- package/base/hooks/guard-outside.ts +8 -8
- package/base/hooks/guard-package.ts +5 -6
- package/base/hooks/guard-remote-hosts.ts +6 -7
- package/base/hooks/guard-scripting.ts +5 -6
- package/base/hooks/guard-writes.ts +8 -9
- package/base/hooks/post-tool.ts +2 -2
- package/base/hooks/prompt-submit.ts +2 -2
- package/base/hooks/session-start.ts +3 -3
- package/base/hooks/stop.ts +2 -2
- package/base/hooks/subagent-start.ts +2 -2
- package/base/skills/docs-update/SKILL.md +4 -2
- package/base/skills/visualize-work/SKILL.md +9 -0
- package/package.json +3 -3
- package/src/agents/atlas-block.ts +43 -43
- package/src/agents/codex-hooks.ts +45 -43
- package/src/agents/detect.ts +19 -16
- package/src/agents/exclude.ts +96 -97
- package/src/agents/hooks-json.ts +38 -36
- package/src/agents/local.ts +46 -43
- package/src/agents/prompt.ts +45 -42
- package/src/agents/render.ts +201 -195
- package/src/agents/resolve.ts +133 -134
- package/src/agents/table.ts +12 -8
- package/src/commands/add.command.ts +2 -2
- package/src/commands/agents.command.ts +11 -17
- package/src/commands/clean.command.ts +6 -6
- package/src/commands/doctor.command.ts +4 -4
- package/src/commands/init.command.ts +12 -8
- package/src/commands/preset.command.ts +2 -2
- package/src/commands/profile.command.ts +42 -49
- package/src/commands/sync.command.ts +109 -111
- package/src/commands/upgrade.command.ts +80 -75
- package/src/commands/visualize.command.ts +7 -13
- package/src/commands/x.command.ts +55 -50
- package/src/common/format.ts +23 -21
- package/src/common/json.ts +8 -5
- package/src/common/layout-folder.ts +94 -91
- package/src/common/paths.ts +14 -12
- package/src/config/loader.ts +52 -49
- package/src/config/packages.ts +14 -11
- package/src/config/schema.ts +3 -3
- package/src/create/add-app.ts +519 -509
- package/src/create/add-lib.ts +237 -240
- package/src/create/bunfig.ts +26 -23
- package/src/create/checks.ts +36 -34
- package/src/create/diff.ts +21 -23
- package/src/create/dockerignore.ts +26 -24
- package/src/create/files.ts +7 -5
- package/src/create/init-monorepo.ts +75 -80
- package/src/create/lib-preset.ts +59 -63
- package/src/create/manifest-json.ts +10 -4
- package/src/create/names.ts +217 -210
- package/src/create/next.ts +26 -23
- package/src/create/plan.ts +15 -12
- package/src/create/preset-diff.ts +301 -303
- package/src/create/preset-menu.ts +38 -32
- package/src/create/preset.ts +202 -197
- package/src/create/process.ts +79 -72
- package/src/create/scratch.ts +48 -49
- package/src/create/workspace.ts +404 -396
- package/src/doctor/checks.ts +1027 -1014
- package/src/doctor/makefile.ts +17 -13
- package/src/doctor/runner.ts +88 -118
- package/src/doctor/skills.ts +97 -95
- package/src/doctor/tags.ts +42 -37
- package/src/hooks/codex-patch.ts +25 -22
- package/src/hooks/command-view.ts +44 -39
- package/src/hooks/decision.ts +37 -37
- package/src/hooks/guard-git.ts +51 -49
- package/src/hooks/guard-manifest.ts +58 -55
- package/src/hooks/guard-outside.ts +93 -91
- package/src/hooks/guard-package.ts +82 -79
- package/src/hooks/guard-scripting.ts +19 -14
- package/src/hooks/guard-writes.ts +154 -149
- package/src/hooks/owner-reply.ts +127 -127
- package/src/hooks/post-tool.ts +94 -93
- package/src/hooks/project-guards.ts +65 -62
- package/src/hooks/project-tmp.ts +27 -24
- package/src/hooks/remote-hosts.ts +153 -130
- package/src/hooks/session-digest.ts +98 -101
- package/src/hooks/shell.ts +509 -499
- package/src/hooks/subagent-card.ts +11 -7
- package/src/hooks/trusted-scripts.ts +106 -104
- package/src/init/scaffold.ts +135 -132
- package/src/local/clean.ts +38 -36
- package/src/local/format.ts +21 -17
- package/src/local/scan.ts +144 -138
- package/src/manifest/render.ts +110 -104
- package/src/owner/card.ts +51 -46
- package/src/owner/profile.ts +99 -93
- package/src/owner/reply-switch.ts +9 -6
- package/src/owner/shape.ts +71 -69
- package/src/owner/survey.ts +173 -171
- package/src/owner/view.ts +62 -59
- package/src/owner/violations.ts +119 -123
- package/src/rules/base.ts +15 -11
- package/src/rules/parser.ts +39 -32
- package/src/rules/slots.ts +8 -6
- package/src/signals/claims.ts +30 -28
- package/src/signals/classify.ts +38 -33
- package/src/signals/loop.ts +39 -37
- package/src/signals/state.ts +79 -81
- package/src/skills/frontmatter.ts +28 -28
- package/src/sync/agent-files.ts +217 -199
- package/src/sync/agent-removal.ts +56 -59
- package/src/sync/atlas-block.ts +45 -43
- package/src/sync/base-rules.ts +32 -30
- package/src/sync/claude-launch.ts +36 -34
- package/src/sync/exclude.ts +77 -69
- package/src/sync/local-choice.ts +50 -47
- package/src/sync/planner.ts +59 -61
- package/src/sync/prune.ts +52 -48
- package/src/sync/settings.ts +166 -167
- package/src/ui/capability.ts +12 -7
- package/src/ui/keyboard.ts +38 -38
- package/src/ui/prompt.ts +79 -77
- package/src/visualize/assets.ts +33 -24
- package/src/visualize/charts.ts +179 -176
- package/src/visualize/compare-css.ts +3 -2
- package/src/visualize/compare-render.ts +9 -7
- package/src/visualize/diagrams.ts +189 -174
- package/src/visualize/grid-span.ts +34 -0
- package/src/visualize/icons.ts +7 -5
- package/src/visualize/kinds-render.ts +50 -45
- package/src/visualize/kinds-validate.ts +12 -10
- package/src/visualize/labels.ts +21 -17
- package/src/visualize/layout.ts +112 -97
- package/src/visualize/page.ts +92 -104
- package/src/visualize/render.ts +143 -140
- package/src/visualize/sections.ts +395 -384
- package/src/visualize/sources.ts +2 -2
- package/src/visualize/theme.ts +12 -10
- package/src/visualize/validate.ts +13 -9
- package/src/wiki/anchors.ts +38 -36
- package/src/wiki/command.ts +4 -4
- package/src/wiki/source-links.ts +46 -44
|
@@ -2,19 +2,10 @@ import { existsSync, lstatSync, rmSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { ExitCodes } from '../common/index.ts';
|
|
4
4
|
import type { ICommandContext } from '../common/index.ts';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
linkedAt,
|
|
8
|
-
OwnerConstants,
|
|
9
|
-
profileIsIgnored,
|
|
10
|
-
readProfile,
|
|
11
|
-
renderProfile,
|
|
12
|
-
runSurvey,
|
|
13
|
-
systemLanguageOf,
|
|
14
|
-
writeProfile,
|
|
15
|
-
} from '../owner/index.ts';
|
|
5
|
+
import { ProjectNames } from '../create/names.ts';
|
|
6
|
+
import { OwnerConstants, OwnerProfile, OwnerSurvey } from '../owner/index.ts';
|
|
16
7
|
import type { ISurveyIo } from '../owner/index.ts';
|
|
17
|
-
import {
|
|
8
|
+
import { TerminalCapability, TerminalPrompt } from '../ui/index.ts';
|
|
18
9
|
|
|
19
10
|
const YES_FLAG = '--yes';
|
|
20
11
|
|
|
@@ -22,18 +13,18 @@ const YES_FLAG = '--yes';
|
|
|
22
13
|
const menuIo: ISurveyIo = {
|
|
23
14
|
// An empty entry takes the default, so only what was typed is checked.
|
|
24
15
|
text: (opts) =>
|
|
25
|
-
promptText({
|
|
16
|
+
TerminalPrompt.promptText({
|
|
26
17
|
...opts,
|
|
27
18
|
validate: (value) => (value === '' ? undefined : opts.validate?.(value)),
|
|
28
19
|
}),
|
|
29
|
-
select: (opts) => promptSelect(opts),
|
|
30
|
-
confirm: (opts) => promptConfirm(opts),
|
|
20
|
+
select: (opts) => TerminalPrompt.promptSelect(opts),
|
|
21
|
+
confirm: (opts) => TerminalPrompt.promptConfirm(opts),
|
|
31
22
|
};
|
|
32
23
|
|
|
33
24
|
/** The same questions as plain lines, for a pipe, a log or `TERM=dumb`: an empty line takes the default, the end of the input cancels. */
|
|
34
25
|
const lineIo: ISurveyIo = {
|
|
35
26
|
text: async (opts) => {
|
|
36
|
-
const answer = askWithPrompt({
|
|
27
|
+
const answer = ProjectNames.askWithPrompt({
|
|
37
28
|
question: opts.message,
|
|
38
29
|
...(opts.defaultValue === '' ? {} : { previous: opts.defaultValue }),
|
|
39
30
|
});
|
|
@@ -54,7 +45,7 @@ const lineIo: ISurveyIo = {
|
|
|
54
45
|
return value;
|
|
55
46
|
},
|
|
56
47
|
select: async (opts) => {
|
|
57
|
-
const answer = askWithPrompt({
|
|
48
|
+
const answer = ProjectNames.askWithPrompt({
|
|
58
49
|
question: `${opts.message} [${opts.choices.map((choice) => choice.value).join('/')}]`,
|
|
59
50
|
previous: opts.initial,
|
|
60
51
|
});
|
|
@@ -74,7 +65,7 @@ const lineIo: ISurveyIo = {
|
|
|
74
65
|
return lineIo.select(opts);
|
|
75
66
|
},
|
|
76
67
|
confirm: async (opts) => {
|
|
77
|
-
const answer = askWithPrompt({
|
|
68
|
+
const answer = ProjectNames.askWithPrompt({
|
|
78
69
|
question: `${opts.message} [y/n]`,
|
|
79
70
|
previous: opts.initial ? 'y' : 'n',
|
|
80
71
|
});
|
|
@@ -101,7 +92,7 @@ const lineIo: ISurveyIo = {
|
|
|
101
92
|
|
|
102
93
|
/** Runs the form and saves the profile; the exit code of the command. */
|
|
103
94
|
const fillInProfile = async (opts: { root: string }): Promise<number> => {
|
|
104
|
-
const current =
|
|
95
|
+
const current = OwnerProfile.read({ root: opts.root });
|
|
105
96
|
|
|
106
97
|
if (!current.ok) {
|
|
107
98
|
process.stderr.write(
|
|
@@ -112,7 +103,7 @@ const fillInProfile = async (opts: { root: string }): Promise<number> => {
|
|
|
112
103
|
}
|
|
113
104
|
|
|
114
105
|
// Before the questions, not after: an answer that cannot be saved is an answer typed for nothing.
|
|
115
|
-
if (!profileIsIgnored({ root: opts.root })) {
|
|
106
|
+
if (!OwnerProfile.profileIsIgnored({ root: opts.root })) {
|
|
116
107
|
process.stderr.write(
|
|
117
108
|
'vulcan profile: .gitignore does not list .agents/local/ - run vulcan sync (or add the line) first; a personal file must not be committable\n',
|
|
118
109
|
);
|
|
@@ -120,10 +111,10 @@ const fillInProfile = async (opts: { root: string }): Promise<number> => {
|
|
|
120
111
|
return ExitCodes.FAILURE;
|
|
121
112
|
}
|
|
122
113
|
|
|
123
|
-
const profile = await
|
|
124
|
-
io: menusAvailable() ? menuIo : lineIo,
|
|
114
|
+
const profile = await OwnerSurvey.run({
|
|
115
|
+
io: TerminalCapability.menusAvailable() ? menuIo : lineIo,
|
|
125
116
|
existing: current.profile,
|
|
126
|
-
systemLanguage: systemLanguageOf({ env: process.env }),
|
|
117
|
+
systemLanguage: OwnerSurvey.systemLanguageOf({ env: process.env }),
|
|
127
118
|
});
|
|
128
119
|
|
|
129
120
|
if (profile === null) {
|
|
@@ -132,7 +123,7 @@ const fillInProfile = async (opts: { root: string }): Promise<number> => {
|
|
|
132
123
|
return ExitCodes.FAILURE;
|
|
133
124
|
}
|
|
134
125
|
|
|
135
|
-
const saved =
|
|
126
|
+
const saved = OwnerProfile.write({ root: opts.root, profile });
|
|
136
127
|
|
|
137
128
|
if (!saved.ok) {
|
|
138
129
|
process.stderr.write(`vulcan profile: ${saved.error}\n`);
|
|
@@ -147,33 +138,35 @@ const fillInProfile = async (opts: { root: string }): Promise<number> => {
|
|
|
147
138
|
return ExitCodes.OK;
|
|
148
139
|
};
|
|
149
140
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
export class ProfilePrompt {
|
|
142
|
+
/**
|
|
143
|
+
* After `init`: in a terminal that can draw menus, a project with no profile is offered the form once;
|
|
144
|
+
* anywhere else (a pipe, CI) it only says how to run it. A profile that already exists is left alone.
|
|
145
|
+
*/
|
|
146
|
+
static async offer(opts: { root: string }): Promise<void> {
|
|
147
|
+
if (existsSync(join(opts.root, OwnerConstants.PROFILE_FILE))) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
158
150
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
151
|
+
if (!TerminalCapability.menusAvailable()) {
|
|
152
|
+
process.stderr.write(
|
|
153
|
+
"tell VULCAN how you like to work (language, how to address you, tone): run 'bun x --no-install vulcan profile'\n",
|
|
154
|
+
);
|
|
163
155
|
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
166
158
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
159
|
+
const now = await TerminalPrompt.promptConfirm({
|
|
160
|
+
message:
|
|
161
|
+
"Tell VULCAN how you like to work (language, how to address you, tone)? Every question can be skipped; 'vulcan profile' does it later.",
|
|
162
|
+
initial: true,
|
|
163
|
+
});
|
|
172
164
|
|
|
173
|
-
|
|
174
|
-
|
|
165
|
+
if (now === true) {
|
|
166
|
+
await fillInProfile({ root: opts.root });
|
|
167
|
+
}
|
|
175
168
|
}
|
|
176
|
-
}
|
|
169
|
+
}
|
|
177
170
|
|
|
178
171
|
/**
|
|
179
172
|
* `vulcan profile`: the form (also `edit`), `show` prints the file, `reset` removes it. The file is
|
|
@@ -197,7 +190,7 @@ export const runProfileCommand = async (opts: ICommandContext): Promise<number>
|
|
|
197
190
|
const file = join(opts.cwd, OwnerConstants.PROFILE_FILE);
|
|
198
191
|
|
|
199
192
|
if (sub === 'show') {
|
|
200
|
-
const read =
|
|
193
|
+
const read = OwnerProfile.read({ root: opts.cwd });
|
|
201
194
|
|
|
202
195
|
if (!read.ok) {
|
|
203
196
|
process.stderr.write(`vulcan profile: ${read.error}\n`);
|
|
@@ -211,14 +204,14 @@ export const runProfileCommand = async (opts: ICommandContext): Promise<number>
|
|
|
211
204
|
return ExitCodes.OK;
|
|
212
205
|
}
|
|
213
206
|
|
|
214
|
-
process.stdout.write(
|
|
207
|
+
process.stdout.write(OwnerProfile.render({ profile: read.profile }));
|
|
215
208
|
|
|
216
209
|
return ExitCodes.OK;
|
|
217
210
|
}
|
|
218
211
|
|
|
219
212
|
// The same refusal as read and write: a link at the file's place or at `.agents/local` must never
|
|
220
213
|
// turn a reset into a delete outside the project.
|
|
221
|
-
if (linkedAt({ root: opts.cwd }) !== undefined) {
|
|
214
|
+
if (OwnerProfile.linkedAt({ root: opts.cwd }) !== undefined) {
|
|
222
215
|
process.stderr.write(
|
|
223
216
|
`vulcan profile: ${OwnerConstants.PROFILE_FILE} (or .agents/local) is a symlink - remove the link yourself; nothing was deleted\n`,
|
|
224
217
|
);
|
|
@@ -4,24 +4,22 @@ import type { ICommandContext } from '../common/index.ts';
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import {
|
|
6
6
|
AgentConstants,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
AgentDetection,
|
|
8
|
+
LocalChoice,
|
|
9
|
+
AgentTable,
|
|
10
|
+
AgentsPrompt,
|
|
11
11
|
} from '../agents/index.ts';
|
|
12
|
-
import {
|
|
12
|
+
import { ConfigLoader } from '../config/index.ts';
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
planLocalWorkspace,
|
|
22
|
-
planPrune,
|
|
23
|
-
planSync,
|
|
14
|
+
AgentFiles,
|
|
15
|
+
AgentRemoval,
|
|
16
|
+
AtlasBlockPlan,
|
|
17
|
+
BaseRulesDiff,
|
|
18
|
+
ExcludePlan,
|
|
19
|
+
LocalPlan,
|
|
20
|
+
PrunePlan,
|
|
24
21
|
SyncConstants,
|
|
22
|
+
SyncPlanner,
|
|
25
23
|
SyncStatuses,
|
|
26
24
|
} from '../sync/index.ts';
|
|
27
25
|
|
|
@@ -50,117 +48,117 @@ const readAgentsFlag = (opts: { args: string[] }): string | undefined => {
|
|
|
50
48
|
return value === undefined || value.startsWith('--') ? '' : value;
|
|
51
49
|
};
|
|
52
50
|
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
export class SyncFlow {
|
|
52
|
+
static printAgentTable(): void {
|
|
53
|
+
for (const entry of AgentTable.read()) {
|
|
54
|
+
process.stdout.write(
|
|
55
|
+
`${entry.id.padEnd(15)} ${entry.name.padEnd(20)} MCP ${entry.mcp.path.padEnd(26)} skills ${entry.skills.dir}\n`,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
|
-
};
|
|
60
59
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
): Promise<number> => {
|
|
69
|
-
const flag = readAgentsFlag({ args: opts.args });
|
|
60
|
+
/**
|
|
61
|
+
* The whole sync. `cleanup` names agents whose adapters are taken back even when no stored choice
|
|
62
|
+
* says so (`vulcan agents remove`); an agent stored before and left out of a new explicit list is
|
|
63
|
+
* taken back too.
|
|
64
|
+
*/
|
|
65
|
+
static async run(opts: ICommandContext & { cleanup?: string[] }): Promise<number> {
|
|
66
|
+
const flag = readAgentsFlag({ args: opts.args });
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
if (flag === AgentConstants.LIST) {
|
|
69
|
+
SyncFlow.printAgentTable();
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
return ExitCodes.OK;
|
|
72
|
+
}
|
|
76
73
|
|
|
77
|
-
|
|
74
|
+
const loaded = await ConfigLoader.load({ root: opts.cwd });
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
if (!loaded.ok) {
|
|
77
|
+
process.stderr.write(`vulcan sync: ${loaded.error}\n`);
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
return ExitCodes.FAILURE;
|
|
80
|
+
}
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
root: opts.cwd,
|
|
87
|
-
flag,
|
|
88
|
-
configAgents: loaded.config.agents,
|
|
89
|
-
interactive: process.stdin.isTTY === true,
|
|
90
|
-
detected: detectAgents({
|
|
82
|
+
const resolved = await AgentsPrompt.resolveInTerminal({
|
|
91
83
|
root: opts.cwd,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
84
|
+
flag,
|
|
85
|
+
configAgents: loaded.config.agents,
|
|
86
|
+
interactive: process.stdin.isTTY === true,
|
|
87
|
+
detected: AgentDetection.detect({
|
|
88
|
+
root: opts.cwd,
|
|
89
|
+
home: process.env.HOME ?? homedir(),
|
|
90
|
+
path: process.env.PATH ?? '',
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (!resolved.ok) {
|
|
95
|
+
process.stderr.write(`${resolved.error}\n`);
|
|
96
|
+
|
|
97
|
+
return ExitCodes.FAILURE;
|
|
98
|
+
}
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
100
|
+
const previous = LocalChoice.read({ root: opts.cwd });
|
|
101
|
+
const dropped =
|
|
102
|
+
resolved.source === 'flag' || resolved.source === 'asked'
|
|
103
|
+
? (previous.ok ? (previous.agents ?? []) : []).filter((id) => !resolved.agents.includes(id))
|
|
104
|
+
: [];
|
|
105
|
+
const removed = [...new Set([...(opts.cleanup ?? []), ...dropped])].filter(
|
|
106
|
+
(id) => !resolved.agents.includes(id),
|
|
107
|
+
);
|
|
108
|
+
const dryRun = opts.args.includes(DRY_RUN_FLAG);
|
|
109
|
+
// Planned before anything is written: prune reads the managed record of the previous sync.
|
|
110
|
+
const pruned = opts.args.includes(PRUNE_FLAG) ? PrunePlan.plan({ root: opts.cwd }) : [];
|
|
111
|
+
// The stored choice is listed whether it was just written or only read; a machine that has not chosen stores nothing.
|
|
112
|
+
const stored =
|
|
113
|
+
resolved.writeLocal || resolved.source === 'local'
|
|
114
|
+
? [
|
|
115
|
+
LocalPlan.planChoice({ root: opts.cwd, agents: resolved.agents }),
|
|
116
|
+
...(resolved.writeLocal ? LocalPlan.planIgnore({ root: opts.cwd }) : []),
|
|
117
|
+
]
|
|
118
|
+
: [];
|
|
119
|
+
const actions = [
|
|
120
|
+
...AgentRemoval.plan({ root: opts.cwd, removed, remaining: resolved.agents }),
|
|
121
|
+
...SyncPlanner.plan({ root: opts.cwd, config: loaded.config, agents: resolved.agents }),
|
|
122
|
+
...AtlasBlockPlan.plan({ root: opts.cwd, config: loaded.config }),
|
|
123
|
+
...stored,
|
|
124
|
+
...LocalPlan.planWorkspace({ root: opts.cwd }),
|
|
125
|
+
...ExcludePlan.plan({ root: opts.cwd, agents: resolved.agents }),
|
|
126
|
+
...pruned,
|
|
127
|
+
];
|
|
128
|
+
// Read before the manifest action rewrites the hashes it compares against.
|
|
129
|
+
const changes = BaseRulesDiff.diff({ root: opts.cwd });
|
|
130
|
+
const width = dryRun ? DRY_RUN_LABEL_WIDTH : LABEL_WIDTH;
|
|
131
|
+
|
|
132
|
+
for (const action of actions) {
|
|
133
|
+
if (!dryRun) {
|
|
134
|
+
action.apply();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const note = action.note === undefined ? '' : ` (${action.note})`;
|
|
138
|
+
const label = (dryRun ? DRY_RUN_LABELS[action.status] : undefined) ?? action.status;
|
|
139
|
+
|
|
140
|
+
process.stderr.write(` ${label.padEnd(width)} ${relative(opts.cwd, action.path)}${note}\n`);
|
|
138
141
|
}
|
|
139
142
|
|
|
140
|
-
const
|
|
141
|
-
|
|
143
|
+
for (const { id, change, text } of changes) {
|
|
144
|
+
process.stderr.write(` ${change.padEnd(width)} ${[id, text].filter(Boolean).join(' ')}\n`);
|
|
145
|
+
}
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
}
|
|
147
|
+
for (const { agent, note } of AgentFiles.agentNotes({ agents: resolved.agents })) {
|
|
148
|
+
process.stderr.write(` ${'note'.padEnd(width)} ${agent}: ${note}\n`);
|
|
149
|
+
}
|
|
145
150
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
if (resolved.hint !== undefined) {
|
|
152
|
+
process.stderr.write(`${resolved.hint}\n`);
|
|
153
|
+
}
|
|
149
154
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
const settingsBroken = actions.some(
|
|
156
|
+
(action) =>
|
|
157
|
+
action.status === SyncStatuses.SKIPPED && action.path.endsWith(SyncConstants.SETTINGS_FILE),
|
|
158
|
+
);
|
|
153
159
|
|
|
154
|
-
|
|
155
|
-
process.stderr.write(`${resolved.hint}\n`);
|
|
160
|
+
return settingsBroken ? ExitCodes.FAILURE : ExitCodes.OK;
|
|
156
161
|
}
|
|
162
|
+
}
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
(action) =>
|
|
160
|
-
action.status === SyncStatuses.SKIPPED && action.path.endsWith(SyncConstants.SETTINGS_FILE),
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
return settingsBroken ? ExitCodes.FAILURE : ExitCodes.OK;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export const runSyncCommand = async (opts: ICommandContext): Promise<number> => runSyncFlow(opts);
|
|
164
|
+
export const runSyncCommand = async (opts: ICommandContext): Promise<number> => SyncFlow.run(opts);
|