@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.
Files changed (141) hide show
  1. package/base/extensions/vulcan-guards.ts +48 -41
  2. package/base/hooks/antigravity-guards.ts +2 -2
  3. package/base/hooks/codex-guards.ts +15 -5
  4. package/base/hooks/guard-git.ts +8 -8
  5. package/base/hooks/guard-manifest.ts +4 -5
  6. package/base/hooks/guard-outside.ts +8 -8
  7. package/base/hooks/guard-package.ts +5 -6
  8. package/base/hooks/guard-remote-hosts.ts +6 -7
  9. package/base/hooks/guard-scripting.ts +5 -6
  10. package/base/hooks/guard-writes.ts +8 -9
  11. package/base/hooks/post-tool.ts +2 -2
  12. package/base/hooks/prompt-submit.ts +2 -2
  13. package/base/hooks/session-start.ts +3 -3
  14. package/base/hooks/stop.ts +2 -2
  15. package/base/hooks/subagent-start.ts +2 -2
  16. package/base/skills/docs-update/SKILL.md +4 -2
  17. package/base/skills/visualize-work/SKILL.md +9 -0
  18. package/package.json +3 -3
  19. package/src/agents/atlas-block.ts +43 -43
  20. package/src/agents/codex-hooks.ts +45 -43
  21. package/src/agents/detect.ts +19 -16
  22. package/src/agents/exclude.ts +96 -97
  23. package/src/agents/hooks-json.ts +38 -36
  24. package/src/agents/local.ts +46 -43
  25. package/src/agents/prompt.ts +45 -42
  26. package/src/agents/render.ts +201 -195
  27. package/src/agents/resolve.ts +133 -134
  28. package/src/agents/table.ts +12 -8
  29. package/src/commands/add.command.ts +2 -2
  30. package/src/commands/agents.command.ts +11 -17
  31. package/src/commands/clean.command.ts +6 -6
  32. package/src/commands/doctor.command.ts +4 -4
  33. package/src/commands/init.command.ts +12 -8
  34. package/src/commands/preset.command.ts +2 -2
  35. package/src/commands/profile.command.ts +42 -49
  36. package/src/commands/sync.command.ts +109 -111
  37. package/src/commands/upgrade.command.ts +80 -75
  38. package/src/commands/visualize.command.ts +7 -13
  39. package/src/commands/x.command.ts +55 -50
  40. package/src/common/format.ts +23 -21
  41. package/src/common/json.ts +8 -5
  42. package/src/common/layout-folder.ts +94 -91
  43. package/src/common/paths.ts +14 -12
  44. package/src/config/loader.ts +52 -49
  45. package/src/config/packages.ts +14 -11
  46. package/src/config/schema.ts +3 -3
  47. package/src/create/add-app.ts +519 -509
  48. package/src/create/add-lib.ts +237 -240
  49. package/src/create/bunfig.ts +26 -23
  50. package/src/create/checks.ts +36 -34
  51. package/src/create/diff.ts +21 -23
  52. package/src/create/dockerignore.ts +26 -24
  53. package/src/create/files.ts +7 -5
  54. package/src/create/init-monorepo.ts +75 -80
  55. package/src/create/lib-preset.ts +59 -63
  56. package/src/create/manifest-json.ts +10 -4
  57. package/src/create/names.ts +217 -210
  58. package/src/create/next.ts +26 -23
  59. package/src/create/plan.ts +15 -12
  60. package/src/create/preset-diff.ts +301 -303
  61. package/src/create/preset-menu.ts +38 -32
  62. package/src/create/preset.ts +202 -197
  63. package/src/create/process.ts +79 -72
  64. package/src/create/scratch.ts +48 -49
  65. package/src/create/workspace.ts +404 -396
  66. package/src/doctor/checks.ts +1027 -1014
  67. package/src/doctor/makefile.ts +17 -13
  68. package/src/doctor/runner.ts +88 -118
  69. package/src/doctor/skills.ts +97 -95
  70. package/src/doctor/tags.ts +42 -37
  71. package/src/hooks/codex-patch.ts +25 -22
  72. package/src/hooks/command-view.ts +44 -39
  73. package/src/hooks/decision.ts +37 -37
  74. package/src/hooks/guard-git.ts +51 -49
  75. package/src/hooks/guard-manifest.ts +58 -55
  76. package/src/hooks/guard-outside.ts +93 -91
  77. package/src/hooks/guard-package.ts +82 -79
  78. package/src/hooks/guard-scripting.ts +19 -14
  79. package/src/hooks/guard-writes.ts +154 -149
  80. package/src/hooks/owner-reply.ts +127 -127
  81. package/src/hooks/post-tool.ts +94 -93
  82. package/src/hooks/project-guards.ts +65 -62
  83. package/src/hooks/project-tmp.ts +27 -24
  84. package/src/hooks/remote-hosts.ts +153 -130
  85. package/src/hooks/session-digest.ts +98 -101
  86. package/src/hooks/shell.ts +509 -499
  87. package/src/hooks/subagent-card.ts +11 -7
  88. package/src/hooks/trusted-scripts.ts +106 -104
  89. package/src/init/scaffold.ts +135 -132
  90. package/src/local/clean.ts +38 -36
  91. package/src/local/format.ts +21 -17
  92. package/src/local/scan.ts +144 -138
  93. package/src/manifest/render.ts +110 -104
  94. package/src/owner/card.ts +51 -46
  95. package/src/owner/profile.ts +99 -93
  96. package/src/owner/reply-switch.ts +9 -6
  97. package/src/owner/shape.ts +71 -69
  98. package/src/owner/survey.ts +173 -171
  99. package/src/owner/view.ts +62 -59
  100. package/src/owner/violations.ts +119 -123
  101. package/src/rules/base.ts +15 -11
  102. package/src/rules/parser.ts +39 -32
  103. package/src/rules/slots.ts +8 -6
  104. package/src/signals/claims.ts +30 -28
  105. package/src/signals/classify.ts +38 -33
  106. package/src/signals/loop.ts +39 -37
  107. package/src/signals/state.ts +79 -81
  108. package/src/skills/frontmatter.ts +28 -28
  109. package/src/sync/agent-files.ts +217 -199
  110. package/src/sync/agent-removal.ts +56 -59
  111. package/src/sync/atlas-block.ts +45 -43
  112. package/src/sync/base-rules.ts +32 -30
  113. package/src/sync/claude-launch.ts +36 -34
  114. package/src/sync/exclude.ts +77 -69
  115. package/src/sync/local-choice.ts +50 -47
  116. package/src/sync/planner.ts +59 -61
  117. package/src/sync/prune.ts +52 -48
  118. package/src/sync/settings.ts +166 -167
  119. package/src/ui/capability.ts +12 -7
  120. package/src/ui/keyboard.ts +38 -38
  121. package/src/ui/prompt.ts +79 -77
  122. package/src/visualize/assets.ts +33 -24
  123. package/src/visualize/charts.ts +179 -176
  124. package/src/visualize/compare-css.ts +3 -2
  125. package/src/visualize/compare-render.ts +9 -7
  126. package/src/visualize/diagrams.ts +189 -174
  127. package/src/visualize/grid-span.ts +34 -0
  128. package/src/visualize/icons.ts +7 -5
  129. package/src/visualize/kinds-render.ts +50 -45
  130. package/src/visualize/kinds-validate.ts +12 -10
  131. package/src/visualize/labels.ts +21 -17
  132. package/src/visualize/layout.ts +112 -97
  133. package/src/visualize/page.ts +92 -104
  134. package/src/visualize/render.ts +143 -140
  135. package/src/visualize/sections.ts +395 -384
  136. package/src/visualize/sources.ts +2 -2
  137. package/src/visualize/theme.ts +12 -10
  138. package/src/visualize/validate.ts +13 -9
  139. package/src/wiki/anchors.ts +38 -36
  140. package/src/wiki/command.ts +4 -4
  141. 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 { askWithPrompt } from '../create/names.ts';
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 { menusAvailable, promptConfirm, promptSelect, promptText } from '../ui/index.ts';
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 = readProfile({ root: opts.root });
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 runSurvey({
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 = writeProfile({ root: opts.root, profile });
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
- * After `init`: in a terminal that can draw menus, a project with no profile is offered the form once;
152
- * anywhere else (a pipe, CI) it only says how to run it. A profile that already exists is left alone.
153
- */
154
- export const offerProfile = async (opts: { root: string }): Promise<void> => {
155
- if (existsSync(join(opts.root, OwnerConstants.PROFILE_FILE))) {
156
- return;
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
- if (!menusAvailable()) {
160
- process.stderr.write(
161
- "tell VULCAN how you like to work (language, how to address you, tone): run 'bun x --no-install vulcan profile'\n",
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
- return;
165
- }
156
+ return;
157
+ }
166
158
 
167
- const now = await promptConfirm({
168
- message:
169
- "Tell VULCAN how you like to work (language, how to address you, tone)? Every question can be skipped; 'vulcan profile' does it later.",
170
- initial: true,
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
- if (now === true) {
174
- await fillInProfile({ root: opts.root });
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 = readProfile({ root: opts.cwd });
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(renderProfile({ profile: read.profile }));
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
- detectAgents,
8
- readLocalChoice,
9
- readAgentTable,
10
- resolveAgentsInTerminal,
7
+ AgentDetection,
8
+ LocalChoice,
9
+ AgentTable,
10
+ AgentsPrompt,
11
11
  } from '../agents/index.ts';
12
- import { loadConfig } from '../config/index.ts';
12
+ import { ConfigLoader } from '../config/index.ts';
13
13
  import {
14
- agentNotes,
15
- diffBaseRules,
16
- planAgentRemoval,
17
- planAtlasBlock,
18
- planExclude,
19
- planLocalChoice,
20
- planLocalIgnore,
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 const printAgentTable = (): void => {
54
- for (const entry of readAgentTable()) {
55
- process.stdout.write(
56
- `${entry.id.padEnd(15)} ${entry.name.padEnd(20)} MCP ${entry.mcp.path.padEnd(26)} skills ${entry.skills.dir}\n`,
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
- * The whole sync. `cleanup` names agents whose adapters are taken back even when no stored choice
63
- * says so (`vulcan agents remove`); an agent stored before and left out of a new explicit list is
64
- * taken back too.
65
- */
66
- export const runSyncFlow = async (
67
- opts: ICommandContext & { cleanup?: string[] },
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
- if (flag === AgentConstants.LIST) {
72
- printAgentTable();
68
+ if (flag === AgentConstants.LIST) {
69
+ SyncFlow.printAgentTable();
73
70
 
74
- return ExitCodes.OK;
75
- }
71
+ return ExitCodes.OK;
72
+ }
76
73
 
77
- const loaded = await loadConfig({ root: opts.cwd });
74
+ const loaded = await ConfigLoader.load({ root: opts.cwd });
78
75
 
79
- if (!loaded.ok) {
80
- process.stderr.write(`vulcan sync: ${loaded.error}\n`);
76
+ if (!loaded.ok) {
77
+ process.stderr.write(`vulcan sync: ${loaded.error}\n`);
81
78
 
82
- return ExitCodes.FAILURE;
83
- }
79
+ return ExitCodes.FAILURE;
80
+ }
84
81
 
85
- const resolved = await resolveAgentsInTerminal({
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
- home: process.env.HOME ?? homedir(),
93
- path: process.env.PATH ?? '',
94
- }),
95
- });
96
-
97
- if (!resolved.ok) {
98
- process.stderr.write(`${resolved.error}\n`);
99
-
100
- return ExitCodes.FAILURE;
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
- const previous = readLocalChoice({ root: opts.cwd });
104
- const dropped =
105
- resolved.source === 'flag' || resolved.source === 'asked'
106
- ? (previous.ok ? (previous.agents ?? []) : []).filter((id) => !resolved.agents.includes(id))
107
- : [];
108
- const removed = [...new Set([...(opts.cleanup ?? []), ...dropped])].filter(
109
- (id) => !resolved.agents.includes(id),
110
- );
111
- const dryRun = opts.args.includes(DRY_RUN_FLAG);
112
- // Planned before anything is written: prune reads the managed record of the previous sync.
113
- const pruned = opts.args.includes(PRUNE_FLAG) ? planPrune({ root: opts.cwd }) : [];
114
- // The stored choice is listed whether it was just written or only read; a machine that has not chosen stores nothing.
115
- const stored =
116
- resolved.writeLocal || resolved.source === 'local'
117
- ? [
118
- planLocalChoice({ root: opts.cwd, agents: resolved.agents }),
119
- ...(resolved.writeLocal ? planLocalIgnore({ root: opts.cwd }) : []),
120
- ]
121
- : [];
122
- const actions = [
123
- ...planAgentRemoval({ root: opts.cwd, removed, remaining: resolved.agents }),
124
- ...planSync({ root: opts.cwd, config: loaded.config, agents: resolved.agents }),
125
- ...planAtlasBlock({ root: opts.cwd, config: loaded.config }),
126
- ...stored,
127
- ...planLocalWorkspace({ root: opts.cwd }),
128
- ...planExclude({ root: opts.cwd, agents: resolved.agents }),
129
- ...pruned,
130
- ];
131
- // Read before the manifest action rewrites the hashes it compares against.
132
- const changes = diffBaseRules({ root: opts.cwd });
133
- const width = dryRun ? DRY_RUN_LABEL_WIDTH : LABEL_WIDTH;
134
-
135
- for (const action of actions) {
136
- if (!dryRun) {
137
- action.apply();
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 note = action.note === undefined ? '' : ` (${action.note})`;
141
- const label = (dryRun ? DRY_RUN_LABELS[action.status] : undefined) ?? action.status;
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
- process.stderr.write(` ${label.padEnd(width)} ${relative(opts.cwd, action.path)}${note}\n`);
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
- for (const { id, change, text } of changes) {
147
- process.stderr.write(` ${change.padEnd(width)} ${[id, text].filter(Boolean).join(' ')}\n`);
148
- }
151
+ if (resolved.hint !== undefined) {
152
+ process.stderr.write(`${resolved.hint}\n`);
153
+ }
149
154
 
150
- for (const { agent, note } of agentNotes({ agents: resolved.agents })) {
151
- process.stderr.write(` ${'note'.padEnd(width)} ${agent}: ${note}\n`);
152
- }
155
+ const settingsBroken = actions.some(
156
+ (action) =>
157
+ action.status === SyncStatuses.SKIPPED && action.path.endsWith(SyncConstants.SETTINGS_FILE),
158
+ );
153
159
 
154
- if (resolved.hint !== undefined) {
155
- process.stderr.write(`${resolved.hint}\n`);
160
+ return settingsBroken ? ExitCodes.FAILURE : ExitCodes.OK;
156
161
  }
162
+ }
157
163
 
158
- const settingsBroken = actions.some(
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);