@venizia/vulcan 0.4.8-0 → 0.4.9-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/hooks/antigravity-guards.ts +2 -1
- package/base/hooks/codex-guards.ts +2 -1
- package/base/hooks/guard-manifest.ts +2 -1
- package/base/hooks/guard-package.ts +2 -1
- package/base/hooks/guard-remote-hosts.ts +9 -3
- package/base/hooks/guard-scripting.ts +2 -1
- package/base/hooks/guard-writes.ts +14 -4
- package/base/hooks/post-tool.ts +2 -1
- package/base/hooks/prompt-submit.ts +2 -1
- package/base/hooks/session-start.ts +3 -1
- package/base/hooks/stop.ts +2 -1
- package/base/make/vulcan.mk +1 -4
- package/base/skills/build-a-feature/SKILL.md +1 -1
- package/base/skills/docs-update/SKILL.md +11 -5
- package/base/skills/docs-update/evals/evals.json +1 -1
- package/base/skills/docs-writing/SKILL.md +1 -1
- package/base/skills/plan-a-change/references/spec-card.md +1 -1
- package/base/skills/ship/SKILL.md +1 -1
- package/base/skills/visualize-work/SKILL.md +20 -6
- package/base/skills/visualize-work/references/spec.md +16 -5
- package/package.json +5 -6
- package/src/agents/codex-hooks.ts +11 -10
- package/src/agents/common/types.ts +1 -1
- package/src/agents/exclude.ts +1 -1
- package/src/agents/hooks-json.ts +4 -8
- package/src/agents/prompt.ts +2 -2
- package/src/agents/render.ts +8 -12
- package/src/cli.ts +3 -1
- package/src/commands/doctor.command.ts +3 -1
- package/src/commands/help.command.ts +11 -9
- package/src/commands/init.command.ts +3 -1
- package/src/commands/profile.command.ts +1 -1
- package/src/commands/upgrade.command.ts +5 -3
- package/src/commands/visualize.command.ts +23 -2
- package/src/common/index.ts +2 -0
- package/src/common/layout-folder.ts +2 -20
- package/src/common/record.ts +7 -0
- package/src/common/text.ts +7 -0
- package/src/config/common/constants.ts +13 -1
- package/src/config/common/types.ts +8 -1
- package/src/config/loader.ts +4 -2
- package/src/config/packages.ts +4 -1
- package/src/config/schema.ts +51 -4
- package/src/create/add-app.ts +170 -69
- package/src/create/add-lib.ts +41 -31
- package/src/create/common/constants.ts +1 -0
- package/src/create/common/failure.ts +10 -0
- package/src/create/common/index.ts +2 -0
- package/src/create/common/preset-path.ts +11 -0
- package/src/create/common/types.ts +7 -2
- package/src/create/init-monorepo.ts +5 -2
- package/src/create/lib-preset.ts +22 -17
- package/src/create/names.ts +1 -1
- package/src/create/next.ts +1 -1
- package/src/create/preset-diff.ts +232 -55
- package/src/create/preset-menu.ts +3 -3
- package/src/create/preset.ts +18 -10
- package/src/create/process.ts +4 -2
- package/src/create/scratch.ts +3 -1
- package/src/create/workspace.ts +37 -20
- package/src/doctor/checks.ts +74 -16
- package/src/doctor/runner.ts +2 -0
- package/src/doctor/tags.ts +2 -4
- package/src/hooks/codex-patch.ts +2 -2
- package/src/hooks/common/constants.ts +0 -3
- package/src/hooks/common/types.ts +15 -1
- package/src/hooks/decision.ts +1 -5
- package/src/hooks/guard-git.ts +1 -1
- package/src/hooks/guard-outside.ts +28 -9
- package/src/hooks/guard-package.ts +13 -7
- package/src/hooks/guard-scripting.ts +1 -1
- package/src/hooks/guard-writes.ts +73 -20
- package/src/hooks/owner-reply.ts +1 -1
- package/src/hooks/project-guards.ts +39 -4
- package/src/hooks/remote-hosts.ts +5 -20
- package/src/hooks/session-digest.ts +7 -0
- package/src/hooks/shell.ts +13 -4
- package/src/hooks/trusted-scripts.ts +80 -4
- package/src/init/common/types.ts +1 -1
- package/src/init/scaffold.ts +2 -2
- package/src/local/clean.ts +1 -1
- package/src/local/scan.ts +2 -2
- package/src/manifest/render.ts +20 -11
- package/src/owner/profile.ts +1 -3
- package/src/owner/shape.ts +1 -1
- package/src/owner/survey.ts +27 -18
- package/src/router.ts +4 -1
- package/src/rules/common/types.ts +1 -1
- package/src/signals/state.ts +1 -4
- package/src/sync/agent-removal.ts +7 -10
- package/src/sync/claude-launch.ts +36 -1
- package/src/sync/common/constants.ts +4 -0
- package/src/sync/common/index.ts +1 -0
- package/src/sync/common/symlink.ts +9 -0
- package/src/sync/common/types.ts +2 -2
- package/src/sync/planner.ts +10 -12
- package/src/sync/settings.ts +1 -1
- package/src/ui/keyboard.ts +3 -1
- package/src/ui/prompt.ts +4 -2
- package/src/visualize/assets.ts +370 -195
- package/src/visualize/charts.ts +11 -2
- package/src/visualize/compare-css.ts +30 -0
- package/src/visualize/compare-render.ts +194 -0
- package/src/visualize/compare-schema.ts +81 -0
- package/src/visualize/compare-validate.ts +126 -0
- package/src/visualize/constants.ts +29 -3
- package/src/visualize/diagrams.ts +1 -1
- package/src/visualize/gate.ts +136 -0
- package/src/visualize/icons.ts +5 -2
- package/src/visualize/index.ts +2 -0
- package/src/visualize/kinds-css.ts +54 -0
- package/src/visualize/kinds-render.ts +693 -0
- package/src/visualize/kinds-schema.ts +148 -0
- package/src/visualize/kinds-validate.ts +184 -0
- package/src/visualize/labels-vi.ts +109 -0
- package/src/visualize/labels.ts +49 -0
- package/src/visualize/layout.ts +10 -5
- package/src/visualize/page.ts +99 -61
- package/src/visualize/render.ts +48 -7
- package/src/visualize/schema.ts +21 -1
- package/src/visualize/sections.ts +115 -34
- package/src/visualize/sources.ts +270 -0
- package/src/visualize/theme.ts +472 -0
- package/src/visualize/validate.ts +6 -0
- package/src/wiki/anchors.ts +1 -1
- package/src/wiki/source-links.ts +3 -5
package/src/owner/survey.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { OWNER_LABEL_SET, PROFILE_SCHEMA } from './schema.ts';
|
|
|
3
3
|
import { isEnglishLanguage } from './view.ts';
|
|
4
4
|
import type { TOwnerLabelSet, TProfile } from './schema.ts';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface ISurveyChoice {
|
|
7
7
|
value: string;
|
|
8
8
|
label: string;
|
|
9
9
|
}
|
|
@@ -49,7 +49,7 @@ const codeTasteProblem = (value: string): string | undefined =>
|
|
|
49
49
|
value.length > 1000 ? 'at most 1000 characters' : undefined;
|
|
50
50
|
|
|
51
51
|
/** A single dash clears an optional value that an earlier run set: an empty answer keeps it. */
|
|
52
|
-
|
|
52
|
+
const CLEAR_ANSWER = '-';
|
|
53
53
|
|
|
54
54
|
const languageProblem = (value: string): string | undefined =>
|
|
55
55
|
OwnerConstants.LANGUAGE_PATTERN.test(value) ? undefined : 'a language code such as en or pt-BR';
|
|
@@ -169,69 +169,78 @@ export const runSurvey = async (opts: {
|
|
|
169
169
|
existing?.address.you ?? '',
|
|
170
170
|
optionalLabelProblem,
|
|
171
171
|
);
|
|
172
|
-
|
|
172
|
+
// Each question is asked only when the one before it was answered.
|
|
173
|
+
const askingSelf =
|
|
173
174
|
you === null
|
|
174
175
|
? null
|
|
175
|
-
:
|
|
176
|
+
: optional(
|
|
176
177
|
'How should I refer to myself? (leave empty for neutral)',
|
|
177
178
|
existing?.address.self ?? '',
|
|
178
179
|
optionalLabelProblem,
|
|
179
180
|
);
|
|
180
|
-
const
|
|
181
|
+
const self = await askingSelf;
|
|
182
|
+
const askingFormality =
|
|
181
183
|
self === null
|
|
182
184
|
? null
|
|
183
|
-
:
|
|
185
|
+
: io.select({
|
|
184
186
|
message: 'How formal should I be?',
|
|
185
187
|
choices: choicesOf({ set: OwnerFormalities.SCHEME_SET }),
|
|
186
188
|
initial: existing?.address.formality ?? OwnerFormalities.NEUTRAL,
|
|
187
189
|
});
|
|
188
|
-
const
|
|
190
|
+
const formality = await askingFormality;
|
|
191
|
+
const askingTone =
|
|
189
192
|
formality === null
|
|
190
193
|
? null
|
|
191
|
-
:
|
|
194
|
+
: io.select({
|
|
192
195
|
message: 'Tone',
|
|
193
196
|
choices: choicesOf({ set: OwnerTones.SCHEME_SET }),
|
|
194
197
|
initial: existing?.tone ?? OwnerTones.NEUTRAL,
|
|
195
198
|
});
|
|
196
|
-
const
|
|
199
|
+
const tone = await askingTone;
|
|
200
|
+
const askingReportDetail =
|
|
197
201
|
tone === null
|
|
198
202
|
? null
|
|
199
|
-
:
|
|
203
|
+
: io.select({
|
|
200
204
|
message: 'Reports: headline only, or headline plus tables?',
|
|
201
205
|
choices: choicesOf({ set: OwnerDetails.SCHEME_SET }),
|
|
202
206
|
initial: existing?.reportDetail ?? OwnerDetails.TABLES,
|
|
203
207
|
});
|
|
204
|
-
const
|
|
208
|
+
const reportDetail = await askingReportDetail;
|
|
209
|
+
const askingAsk =
|
|
205
210
|
reportDetail === null
|
|
206
211
|
? null
|
|
207
|
-
:
|
|
212
|
+
: io.confirm({
|
|
208
213
|
message:
|
|
209
214
|
'For a choice that can be undone, ask you first? (no: state a default and continue)',
|
|
210
215
|
initial: existing?.habits.askBeforeReversible ?? false,
|
|
211
216
|
});
|
|
212
|
-
const
|
|
217
|
+
const ask = await askingAsk;
|
|
218
|
+
const askingCommits =
|
|
213
219
|
ask === null
|
|
214
220
|
? null
|
|
215
|
-
:
|
|
221
|
+
: io.confirm({
|
|
216
222
|
message: 'Propose commits when a piece of work is done?',
|
|
217
223
|
initial: existing?.habits.proposeCommits ?? false,
|
|
218
224
|
});
|
|
219
|
-
const
|
|
225
|
+
const commits = await askingCommits;
|
|
226
|
+
const askingAbout =
|
|
220
227
|
commits === null
|
|
221
228
|
? null
|
|
222
|
-
:
|
|
229
|
+
: optional(
|
|
223
230
|
'Anything about how you like to work, or to be worked with? (your own words, optional)',
|
|
224
231
|
existing?.about ?? '',
|
|
225
232
|
aboutProblem,
|
|
226
233
|
);
|
|
227
|
-
const
|
|
234
|
+
const about = await askingAbout;
|
|
235
|
+
const askingCodeTaste =
|
|
228
236
|
about === null
|
|
229
237
|
? null
|
|
230
|
-
:
|
|
238
|
+
: optional(
|
|
231
239
|
'Taste in code that no formatter or lint rule already enforces? (optional)',
|
|
232
240
|
existing?.codeTaste ?? '',
|
|
233
241
|
codeTasteProblem,
|
|
234
242
|
);
|
|
243
|
+
const codeTaste = await askingCodeTaste;
|
|
235
244
|
|
|
236
245
|
if (
|
|
237
246
|
[you, self, formality, tone, reportDetail, ask, commits, about, codeTaste].some(
|
package/src/router.ts
CHANGED
|
@@ -41,6 +41,7 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
|
|
|
41
41
|
CreateFlags.APP,
|
|
42
42
|
CreateFlags.API,
|
|
43
43
|
CreateFlags.LIB,
|
|
44
|
+
CreateFlags.SHARED,
|
|
44
45
|
CreateFlags.DIR,
|
|
45
46
|
CreateFlags.SCOPE,
|
|
46
47
|
],
|
|
@@ -152,7 +153,9 @@ export const runVulcan = async (opts: { argv: string[]; cwd: string }): Promise<
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
try {
|
|
155
|
-
|
|
156
|
+
const exitCode = await handler({ args, cwd: opts.cwd });
|
|
157
|
+
|
|
158
|
+
return exitCode;
|
|
156
159
|
} catch (error) {
|
|
157
160
|
// The refusal is already printed; every `finally` between the menu and here has run.
|
|
158
161
|
if (error instanceof PipedInputRefusal) {
|
package/src/signals/state.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { localRootOf } from '../local/scan.ts';
|
|
|
16
16
|
import { EntryKinds, SignalConstants } from './constants.ts';
|
|
17
17
|
|
|
18
18
|
/** One line of the log. Only the fields of its kind are set. */
|
|
19
|
-
|
|
19
|
+
interface ISignalEntry {
|
|
20
20
|
kind: string;
|
|
21
21
|
/** The session and the agent inside it ('' for the main agent) the line belongs to. */
|
|
22
22
|
session: string;
|
|
@@ -54,9 +54,6 @@ export interface ISignalState {
|
|
|
54
54
|
notedAt: Record<string, number>;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export const isRecord = (opts: { value: unknown }): opts is { value: Record<string, unknown> } =>
|
|
58
|
-
typeof opts.value === 'object' && opts.value !== null && !Array.isArray(opts.value);
|
|
59
|
-
|
|
60
57
|
const recordOf = (opts: { value: unknown }): Record<string, unknown> =>
|
|
61
58
|
typeof opts.value === 'object' && opts.value !== null && !Array.isArray(opts.value)
|
|
62
59
|
? Object.fromEntries(Object.entries(opts.value))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
existsSync,
|
|
3
|
-
lstatSync,
|
|
4
3
|
readdirSync,
|
|
5
4
|
readFileSync,
|
|
6
5
|
readlinkSync,
|
|
@@ -24,18 +23,14 @@ import {
|
|
|
24
23
|
import type { TAgentEntry } from '../agents/index.ts';
|
|
25
24
|
import { isTracked } from './agent-files.ts';
|
|
26
25
|
import { BASE_DIRECTORY, stableBaseDirectoryOf } from '../common/index.ts';
|
|
27
|
-
import { SyncConstants, SyncStatuses } from './common/index.ts';
|
|
26
|
+
import { SyncConstants, SyncLinks, SyncStatuses } from './common/index.ts';
|
|
28
27
|
import type { ISyncAction, TSettings } from './common/index.ts';
|
|
29
28
|
import { isSettingsObject, removeManagedSettings } from './settings.ts';
|
|
30
29
|
|
|
31
30
|
const NO_CHANGE = (): void => {};
|
|
32
|
-
const CLAUDE_SKILLS = join(SyncConstants.CLAUDE_DIRECTORY, SyncConstants.SKILLS_DIRECTORY);
|
|
33
31
|
/** Parents sync may delete once empty: its own agent folders, never `.agents` or the project. */
|
|
34
32
|
const OWN_FOLDERS = new Set(['.cursor', '.codex', '.pi', '.omp', '.vscode', '.claude']);
|
|
35
33
|
|
|
36
|
-
const isSymlink = (opts: { path: string }): boolean =>
|
|
37
|
-
lstatSync(opts.path, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;
|
|
38
|
-
|
|
39
34
|
const removeIfEmpty = (opts: { path: string }): void => {
|
|
40
35
|
try {
|
|
41
36
|
if (existsSync(opts.path) && readdirSync(opts.path).length === 0) {
|
|
@@ -58,7 +53,7 @@ const readJsonObject = (opts: { path: string }): TSettings | undefined => {
|
|
|
58
53
|
|
|
59
54
|
/** A skill link sync made: a symlink into the shipped skills, stable or in the package, or into `.agents/skills`. */
|
|
60
55
|
const isSkillLink = (opts: { root: string; path: string }): boolean => {
|
|
61
|
-
if (!isSymlink({ path: opts.path })) {
|
|
56
|
+
if (!SyncLinks.isSymlink({ path: opts.path })) {
|
|
62
57
|
return false;
|
|
63
58
|
}
|
|
64
59
|
|
|
@@ -299,7 +294,7 @@ const planMcpRemoval = (opts: { root: string; entry: TAgentEntry }): ISyncAction
|
|
|
299
294
|
const planSkillLinkRemoval = (opts: { root: string; directory: string }): ISyncAction[] => {
|
|
300
295
|
const target = join(opts.root, opts.directory);
|
|
301
296
|
|
|
302
|
-
if (!existsSync(target) || isSymlink({ path: target })) {
|
|
297
|
+
if (!existsSync(target) || SyncLinks.isSymlink({ path: target })) {
|
|
303
298
|
return [];
|
|
304
299
|
}
|
|
305
300
|
|
|
@@ -356,7 +351,9 @@ const planClaudeRemoval = (opts: { root: string }): ISyncAction[] => {
|
|
|
356
351
|
actions.push(removeFile({ path: managedPath }));
|
|
357
352
|
}
|
|
358
353
|
|
|
359
|
-
actions.push(
|
|
354
|
+
actions.push(
|
|
355
|
+
...planSkillLinkRemoval({ root: opts.root, directory: SyncConstants.CLAUDE_SKILLS }),
|
|
356
|
+
);
|
|
360
357
|
|
|
361
358
|
return actions;
|
|
362
359
|
};
|
|
@@ -397,7 +394,7 @@ export const planAgentRemoval = (opts: {
|
|
|
397
394
|
}
|
|
398
395
|
|
|
399
396
|
if (
|
|
400
|
-
entry.skills.dir !== CLAUDE_SKILLS &&
|
|
397
|
+
entry.skills.dir !== SyncConstants.CLAUDE_SKILLS &&
|
|
401
398
|
!kept.has(entry.skills.dir) &&
|
|
402
399
|
!cleaned.has(entry.skills.dir)
|
|
403
400
|
) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
2
|
+
import { dirname, isAbsolute, join, relative } from 'node:path';
|
|
3
3
|
import { ProjectLayout } from '../common/index.ts';
|
|
4
4
|
import { projectTmpOf } from '../hooks/project-tmp.ts';
|
|
5
5
|
import { SyncStatuses } from './common/index.ts';
|
|
@@ -46,3 +46,38 @@ export const planClaudeLaunch = (opts: { root: string }): ISyncAction[] => {
|
|
|
46
46
|
},
|
|
47
47
|
];
|
|
48
48
|
};
|
|
49
|
+
|
|
50
|
+
export class ClaudeLaunch {
|
|
51
|
+
/** The one line that starts Claude Code in this project; the docs and the warning print this string. */
|
|
52
|
+
static readonly COMMAND = `claude --settings ${CLAUDE_LAUNCH_FILE}`;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* What to tell the owner when a Claude Code session runs without the launch file: `CLAUDE_CODE_TMPDIR` is unset
|
|
56
|
+
* or points outside the project, so Claude Code's own scratchpad and task output land outside it and writes
|
|
57
|
+
* there need approval. Undefined for any other agent, for a project without the file, and for a session
|
|
58
|
+
* that already uses a folder inside the project.
|
|
59
|
+
*/
|
|
60
|
+
static missWarning(opts: {
|
|
61
|
+
root: string;
|
|
62
|
+
env: Record<string, string | undefined>;
|
|
63
|
+
}): string | undefined {
|
|
64
|
+
if (
|
|
65
|
+
opts.env.CLAUDE_PROJECT_DIR === undefined ||
|
|
66
|
+
!existsSync(join(opts.root, CLAUDE_LAUNCH_FILE))
|
|
67
|
+
) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const folder = opts.env.CLAUDE_CODE_TMPDIR;
|
|
72
|
+
const fromRoot =
|
|
73
|
+
folder === undefined || folder === '' ? undefined : relative(opts.root, folder);
|
|
74
|
+
|
|
75
|
+
if (fromRoot !== undefined && !isAbsolute(fromRoot) && !fromRoot.startsWith('..')) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return `Claude Code was started without the project's launch file: CLAUDE_CODE_TMPDIR is ${
|
|
80
|
+
fromRoot === undefined ? 'not set' : `${folder}, outside the project`
|
|
81
|
+
}, so its scratchpad and task output are written outside the project and the owner will be asked to approve each write there. Say so in your first reply. To fix it, quit and start Claude Code with: ${ClaudeLaunch.COMMAND}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
1
3
|
export class SyncStatuses {
|
|
2
4
|
static readonly CREATED = 'created';
|
|
3
5
|
static readonly REPLACED = 'replaced';
|
|
@@ -31,6 +33,8 @@ export class SyncConstants {
|
|
|
31
33
|
/** What sync applied last time, so a later sync can take back what the project no longer asks for. */
|
|
32
34
|
static readonly MANAGED_FILE = 'vulcan-managed.json';
|
|
33
35
|
static readonly SKILLS_DIRECTORY = 'skills';
|
|
36
|
+
/** The Claude skills folder, relative to the project root. */
|
|
37
|
+
static readonly CLAUDE_SKILLS = join(this.CLAUDE_DIRECTORY, this.SKILLS_DIRECTORY);
|
|
34
38
|
static readonly SKILL_FILE = 'SKILL.md';
|
|
35
39
|
/** The settings key of hook entries: sync takes a managed hook back by its command, not its whole entry. */
|
|
36
40
|
static readonly HOOKS_KEY = 'hooks';
|
package/src/sync/common/index.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { lstatSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
/** Reading a path without following it: the link itself is what sync keeps or replaces. */
|
|
4
|
+
export class SyncLinks {
|
|
5
|
+
/** Whether `path` is a symlink, a dangling one included; a missing path is not. */
|
|
6
|
+
static isSymlink(opts: { path: string }): boolean {
|
|
7
|
+
return lstatSync(opts.path, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/src/sync/common/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TConstValue } from '../../common/index.ts';
|
|
2
2
|
import type { BaseRuleChanges, SyncStatuses } from './constants.ts';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type TSyncStatus = TConstValue<typeof SyncStatuses>;
|
|
5
5
|
|
|
6
6
|
export type TSettings = Record<string, unknown>;
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ export interface ISyncAction {
|
|
|
13
13
|
apply: () => void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
type TBaseRuleChange = TConstValue<typeof BaseRuleChanges>;
|
|
17
17
|
|
|
18
18
|
/** One base rule that moved since the last sync; `text` is its new text, or `(retired)` when the base retired it. */
|
|
19
19
|
export interface IBaseRuleChange {
|
package/src/sync/planner.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
existsSync,
|
|
3
|
-
lstatSync,
|
|
4
3
|
mkdirSync,
|
|
5
4
|
readdirSync,
|
|
6
5
|
readFileSync,
|
|
@@ -17,7 +16,7 @@ import type { TResolvedConfig } from '../config/index.ts';
|
|
|
17
16
|
import { ManifestConstants, renderManifest } from '../manifest/index.ts';
|
|
18
17
|
import { readSlots } from '../rules/index.ts';
|
|
19
18
|
import { planAgentFiles } from './agent-files.ts';
|
|
20
|
-
import { SyncConstants, SyncStatuses } from './common/index.ts';
|
|
19
|
+
import { SyncConstants, SyncLinks, SyncStatuses } from './common/index.ts';
|
|
21
20
|
import type { ISyncAction, TSettings } from './common/index.ts';
|
|
22
21
|
import {
|
|
23
22
|
buildProjectHookSettings,
|
|
@@ -29,15 +28,12 @@ import {
|
|
|
29
28
|
|
|
30
29
|
const NO_CHANGE = (): void => {};
|
|
31
30
|
|
|
32
|
-
const isSymlink = (opts: { path: string }): boolean =>
|
|
33
|
-
lstatSync(opts.path, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;
|
|
34
|
-
|
|
35
31
|
/** `CLAUDE.md` holds only `@AGENTS.md`: an old symlink or bun init's template is replaced, a hand-written file is left alone. */
|
|
36
32
|
const planClaudeImport = (opts: { root: string }): ISyncAction => {
|
|
37
33
|
const path = join(opts.root, SyncConstants.CLAUDE_TOOL_FILE);
|
|
38
34
|
const write = (): void => writeFileSync(path, `${SyncConstants.CLAUDE_IMPORT_LINE}\n`);
|
|
39
35
|
|
|
40
|
-
if (isSymlink({ path })) {
|
|
36
|
+
if (SyncLinks.isSymlink({ path })) {
|
|
41
37
|
return {
|
|
42
38
|
path,
|
|
43
39
|
status: SyncStatuses.REPLACED,
|
|
@@ -194,7 +190,7 @@ const planSkillLinks = (opts: {
|
|
|
194
190
|
const target = join(opts.root, opts.directory);
|
|
195
191
|
|
|
196
192
|
// A symlinked skills directory points outside the project: writing links through it would land them there.
|
|
197
|
-
if (isSymlink({ path: target })) {
|
|
193
|
+
if (SyncLinks.isSymlink({ path: target })) {
|
|
198
194
|
return [
|
|
199
195
|
{
|
|
200
196
|
path: target,
|
|
@@ -234,7 +230,7 @@ const planSkillLinks = (opts: {
|
|
|
234
230
|
symlinkSync(resolve(source), path);
|
|
235
231
|
};
|
|
236
232
|
|
|
237
|
-
if (isSymlink({ path })) {
|
|
233
|
+
if (SyncLinks.isSymlink({ path })) {
|
|
238
234
|
return readlinkSync(path) === resolve(source)
|
|
239
235
|
? { path, status: SyncStatuses.UNCHANGED, apply: NO_CHANGE }
|
|
240
236
|
: {
|
|
@@ -266,7 +262,7 @@ const planSkillLinks = (opts: {
|
|
|
266
262
|
const stale = (existsSync(target) ? readdirSync(target) : [])
|
|
267
263
|
.filter((name) => !linked.has(name))
|
|
268
264
|
.map((name) => join(target, name))
|
|
269
|
-
.filter((path) => isSymlink({ path }) && !existsSync(path))
|
|
265
|
+
.filter((path) => SyncLinks.isSymlink({ path }) && !existsSync(path))
|
|
270
266
|
.map((path) => ({ path, destination: readlinkSync(path) }))
|
|
271
267
|
.filter(
|
|
272
268
|
({ destination }) =>
|
|
@@ -303,8 +299,6 @@ export const planManifest = (opts: { root: string; config: TResolvedConfig }): I
|
|
|
303
299
|
: { path, status: SyncStatuses.REPLACED, apply: write };
|
|
304
300
|
};
|
|
305
301
|
|
|
306
|
-
const CLAUDE_SKILLS = join(SyncConstants.CLAUDE_DIRECTORY, SyncConstants.SKILLS_DIRECTORY);
|
|
307
|
-
|
|
308
302
|
/** The skills folders of the chosen agents, each once, in table order: agents that read one folder share its links. */
|
|
309
303
|
const skillDirectoriesOf = (opts: { agents: string[] }): string[] => [
|
|
310
304
|
...new Set(
|
|
@@ -325,7 +319,11 @@ export const planSync = (opts: {
|
|
|
325
319
|
? [planClaudeImport({ root: opts.root }), planSettings(opts)]
|
|
326
320
|
: []),
|
|
327
321
|
...skillDirectoriesOf({ agents: opts.agents }).flatMap((directory) =>
|
|
328
|
-
planSkillLinks({
|
|
322
|
+
planSkillLinks({
|
|
323
|
+
root: opts.root,
|
|
324
|
+
directory,
|
|
325
|
+
withProject: directory === SyncConstants.CLAUDE_SKILLS,
|
|
326
|
+
}),
|
|
329
327
|
),
|
|
330
328
|
...planAgentFiles({ root: opts.root, agents: opts.agents }),
|
|
331
329
|
planManifest(opts),
|
package/src/sync/settings.ts
CHANGED
|
@@ -78,7 +78,7 @@ const toHookEntry = (opts: {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/** Every hook command in one event's entries; anything that is not an entry or a command is skipped. */
|
|
81
|
-
|
|
81
|
+
const extractEntryCommands = (opts: { entries: unknown }): string[] =>
|
|
82
82
|
Array.isArray(opts.entries)
|
|
83
83
|
? opts.entries.flatMap((entry) =>
|
|
84
84
|
(toHookEntry({ entry })?.hooks ?? []).flatMap((hook) => toHookCommand({ hook }) ?? []),
|
package/src/ui/keyboard.ts
CHANGED
|
@@ -41,7 +41,9 @@ export const guardAgainstPipedLines = async <TResult>(
|
|
|
41
41
|
process.stdin.on('data', refuse);
|
|
42
42
|
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
const outcome = await Promise.race([run(), refused]);
|
|
45
|
+
|
|
46
|
+
return outcome;
|
|
45
47
|
} finally {
|
|
46
48
|
process.stdin.off('data', refuse);
|
|
47
49
|
}
|
package/src/ui/prompt.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { confirm, isCancel, multiselect, note, select, text } from '@clack/promp
|
|
|
2
2
|
import { guardAgainstPipedLines } from './keyboard.ts';
|
|
3
3
|
|
|
4
4
|
/** One line of a menu: what it is called, and a short note beside it. */
|
|
5
|
-
|
|
5
|
+
interface IChoice {
|
|
6
6
|
value: string;
|
|
7
7
|
label: string;
|
|
8
8
|
hint?: string;
|
|
@@ -90,5 +90,7 @@ export const promptConfirm = async (opts: {
|
|
|
90
90
|
export const promptPlan = async (opts: { title: string; lines: string[] }): Promise<boolean> => {
|
|
91
91
|
note(opts.lines.join('\n'), opts.title);
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
const confirmed = await promptConfirm({ message: 'Write these files?' });
|
|
94
|
+
|
|
95
|
+
return confirmed === true;
|
|
94
96
|
};
|