docks-kit 0.22.28 → 0.24.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/AGENTS.md +42 -89
- package/README.md +35 -72
- package/cli/docs/command-guards.md +233 -197
- package/cli/docs/flags.md +17 -65
- package/cli/docs/install.md +2 -3
- package/cli/docs/omp-context.md +79 -7
- package/cli/docs/omp-models.md +27 -12
- package/cli/docs/overview.md +7 -18
- package/cli/docs/platforms.md +2 -2
- package/cli/docs/sync-layers.md +14 -60
- package/cli/docs/toolchain.md +12 -81
- package/cli/src/argv.ts +0 -12
- package/cli/src/argvValidate.ts +3 -54
- package/cli/src/commands/docs.ts +3 -15
- package/cli/src/commands/omp.ts +1 -1
- package/cli/src/commands/scratch.ts +1 -1
- package/cli/src/commands/sync.ts +5 -120
- package/cli/src/commands/tidy.ts +1 -1
- package/cli/src/commands/toolchain.ts +4 -12
- package/cli/src/engine-native/DESIGN.md +69 -100
- package/cli/src/engine-native/deps.ts +7 -92
- package/cli/src/engine-native/engineCtx.ts +9 -103
- package/cli/src/engine-native/exec.ts +1 -18
- package/cli/src/engine-native/index.ts +6 -8
- package/cli/src/engine-native/jq.ts +4 -37
- package/cli/src/engine-native/kitDb.ts +21 -37
- package/cli/src/engine-native/modes.ts +3 -132
- package/cli/src/engine-native/ompFastMode.ts +1 -1
- package/cli/src/engine-native/ompOverlay.ts +1 -1
- package/cli/src/engine-native/ompRemovals.ts +24 -3
- package/cli/src/engine-native/ompSession.ts +67 -0
- package/cli/src/engine-native/ompSync.ts +1 -1
- package/cli/src/engine-native/os/darwin.ts +0 -4
- package/cli/src/engine-native/os/index.ts +1 -2
- package/cli/src/engine-native/os/linux.ts +0 -3
- package/cli/src/engine-native/os/posix.ts +2 -47
- package/cli/src/engine-native/os/types.ts +1 -36
- package/cli/src/engine-native/os/windows.ts +0 -50
- package/cli/src/engine-native/parseArgs.ts +7 -180
- package/cli/src/engine-native/parseHelp.ts +4 -44
- package/cli/src/engine-native/scratch.ts +1 -1
- package/cli/src/engine-native/services.ts +1 -2
- package/cli/src/engine-native/sharedTypes.d.ts +1 -41
- package/cli/src/engine-native/syncConcurrency.ts +3 -15
- package/cli/src/engine-native/syncDispatch.ts +30 -143
- package/cli/src/engine-native/toolchain.ts +6 -45
- package/cli/src/engine.ts +0 -75
- package/cli/src/generated/sotPayload.ts +14 -43
- package/cli/src/main.ts +8 -24
- package/cli/src/payload.ts +2 -8
- package/cli/tsconfig.json +1 -3
- package/package.json +3 -5
- package/cli/docs/models.md +0 -58
- package/cli/docs/modifiers.md +0 -52
- package/cli/docs/plugins.md +0 -70
- package/cli/src/checklistPrompt.ts +0 -464
- package/cli/src/commands/harnesses.ts +0 -80
- package/cli/src/commands/model.ts +0 -68
- package/cli/src/commands/models.ts +0 -75
- package/cli/src/commands/plugins.ts +0 -35
- package/cli/src/commands/skills.ts +0 -40
- package/cli/src/commands/status.ts +0 -206
- package/cli/src/efforts.ts +0 -89
- package/cli/src/engine-native/claudeLsp.ts +0 -301
- package/cli/src/engine-native/claudeOptionalPlugins.ts +0 -126
- package/cli/src/engine-native/claudePluginPasses.ts +0 -426
- package/cli/src/engine-native/claudeRemovals.ts +0 -383
- package/cli/src/engine-native/claudeRetired.ts +0 -165
- package/cli/src/engine-native/claudeRuntime.ts +0 -157
- package/cli/src/engine-native/claudeSettings.ts +0 -201
- package/cli/src/engine-native/claudeSettingsModifiers.ts +0 -115
- package/cli/src/engine-native/claudeSync.ts +0 -312
- package/cli/src/engine-native/codexConfig.ts +0 -214
- package/cli/src/engine-native/codexHooks.ts +0 -91
- package/cli/src/engine-native/codexPaths.ts +0 -14
- package/cli/src/engine-native/codexPlugins.ts +0 -315
- package/cli/src/engine-native/codexStatus.ts +0 -25
- package/cli/src/engine-native/codexSync.ts +0 -314
- package/cli/src/engine-native/codexToml.ts +0 -303
- package/cli/src/engine-native/harnesses.ts +0 -138
- package/cli/src/engine-native/liveModels.ts +0 -264
- package/cli/src/engine-native/models.ts +0 -101
- package/cli/src/engine-native/parseModifiers.ts +0 -225
- package/cli/src/engine-native/settings.ts +0 -42
- package/cli/src/engine-native/skillsInstall.ts +0 -135
- package/cli/src/engine-native/skillsLinks.ts +0 -216
- package/cli/src/engine-native/skillsManifest.ts +0 -36
- package/cli/src/engine-native/skillsPrune.ts +0 -117
- package/cli/src/engine-native/skillsRecords.ts +0 -138
- package/cli/src/engine-native/skillsSync.ts +0 -57
- package/cli/src/engine-native/tomlLines.ts +0 -92
- package/cli/src/manifests.ts +0 -145
- package/cli/src/terminalCells.ts +0 -191
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modifier and effort mapping for the EngineNative flag layer: deploy-time
|
|
3
|
-
* modifier metadata, scalar-modifier setters, compact-window and opt-in
|
|
4
|
-
* plugin parsing, and post-parse modifier validation. Pure apart from the
|
|
5
|
-
* injected ctx seam; help output and the early-exit error come from
|
|
6
|
-
* parseHelp.ts.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { Ctx, ModifierFlag } from "./index";
|
|
10
|
-
import type { ScalarModifierFlag } from "./sharedTypes";
|
|
11
|
-
import {
|
|
12
|
-
CLAUDE_ADVISOR_STATES,
|
|
13
|
-
advisorCatalog,
|
|
14
|
-
advisorValueGrammar,
|
|
15
|
-
effortCatalog,
|
|
16
|
-
effortValueGrammar,
|
|
17
|
-
isEffortModifierValue,
|
|
18
|
-
} from "../efforts";
|
|
19
|
-
import { printModels, validateClaudeModel, validateCodexModel } from "./models";
|
|
20
|
-
import { defaultLiveInputs, resolveCatalog } from "./liveModels";
|
|
21
|
-
import { ExitError, printCatalog } from "./parseHelp";
|
|
22
|
-
|
|
23
|
-
export const KNOWN_CLAUDE_OPTIN_PLUGINS = ["supabase", "n8n"];
|
|
24
|
-
|
|
25
|
-
interface ModifierMetadata {
|
|
26
|
-
readonly target: "claude" | "codex";
|
|
27
|
-
readonly ignoredWarning: string;
|
|
28
|
-
readonly hasValue: (ctx: Ctx) => boolean;
|
|
29
|
-
readonly clear: (ctx: Ctx) => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const MODIFIER_METADATA = {
|
|
33
|
-
"--claude-model": {
|
|
34
|
-
target: "claude",
|
|
35
|
-
ignoredWarning: "--claude-model ignored: claude target not selected",
|
|
36
|
-
hasValue: (ctx) => ctx.claudeModel !== "",
|
|
37
|
-
clear: (ctx) => {
|
|
38
|
-
ctx.claudeModel = "";
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
"--claude-effort": {
|
|
42
|
-
target: "claude",
|
|
43
|
-
ignoredWarning: "--claude-effort ignored: claude target not selected",
|
|
44
|
-
hasValue: (ctx) => ctx.claudeEffort !== "",
|
|
45
|
-
clear: (ctx) => {
|
|
46
|
-
ctx.claudeEffort = "";
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
"--claude-advisor": {
|
|
50
|
-
target: "claude",
|
|
51
|
-
ignoredWarning: "--claude-advisor ignored: claude target not selected",
|
|
52
|
-
hasValue: (ctx) => ctx.claudeAdvisor !== "",
|
|
53
|
-
clear: (ctx) => {
|
|
54
|
-
ctx.claudeAdvisor = "";
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
"--claude-compact-window": {
|
|
58
|
-
target: "claude",
|
|
59
|
-
ignoredWarning: "--claude-compact-window ignored: claude target not selected",
|
|
60
|
-
hasValue: (ctx) => ctx.claudeCompactWindow !== "",
|
|
61
|
-
clear: (ctx) => {
|
|
62
|
-
ctx.claudeCompactWindow = "";
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
"--claude-permissive": {
|
|
66
|
-
target: "claude",
|
|
67
|
-
ignoredWarning: "--claude-permissive ignored: claude target not selected",
|
|
68
|
-
hasValue: (ctx) => ctx.claudePermissive,
|
|
69
|
-
clear: (ctx) => {
|
|
70
|
-
ctx.claudePermissive = false;
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
"--claude-plugin": {
|
|
74
|
-
target: "claude",
|
|
75
|
-
ignoredWarning: "--claude-plugin ignored: claude target not selected",
|
|
76
|
-
hasValue: (ctx) => ctx.claudePlugins.length > 0,
|
|
77
|
-
clear: (ctx) => {
|
|
78
|
-
ctx.claudePlugins = [];
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
"--codex-model": {
|
|
82
|
-
target: "codex",
|
|
83
|
-
ignoredWarning: "--codex-model ignored: codex target not selected",
|
|
84
|
-
hasValue: (ctx) => ctx.codexModel !== "",
|
|
85
|
-
clear: (ctx) => {
|
|
86
|
-
ctx.codexModel = "";
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
"--codex-effort": {
|
|
90
|
-
target: "codex",
|
|
91
|
-
ignoredWarning: "--codex-effort ignored: codex target not selected",
|
|
92
|
-
hasValue: (ctx) => ctx.codexEffort !== "",
|
|
93
|
-
clear: (ctx) => {
|
|
94
|
-
ctx.codexEffort = "";
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
} satisfies Record<ModifierFlag, ModifierMetadata>;
|
|
98
|
-
|
|
99
|
-
export type { ScalarModifierFlag };
|
|
100
|
-
|
|
101
|
-
const SCALAR_MODIFIER_FLAGS: Record<ScalarModifierFlag, true> = {
|
|
102
|
-
"--claude-model": true,
|
|
103
|
-
"--claude-effort": true,
|
|
104
|
-
"--claude-advisor": true,
|
|
105
|
-
"--codex-model": true,
|
|
106
|
-
"--codex-effort": true,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/** common::parse_compact_window — normalized tokens or undefined on junk. */
|
|
110
|
-
export function parseCompactWindow(v: string): string | undefined {
|
|
111
|
-
if (/[kK]$/.test(v)) {
|
|
112
|
-
const n = v.slice(0, -1);
|
|
113
|
-
if (!/^[0-9]+$/.test(n)) return undefined;
|
|
114
|
-
return String(parseInt(n, 10) * 1000);
|
|
115
|
-
}
|
|
116
|
-
return /^[0-9]+$/.test(v) ? v : undefined;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function parseClaudePlugin(name: string, err: (message: string) => void): string {
|
|
120
|
-
if (!KNOWN_CLAUDE_OPTIN_PLUGINS.includes(name)) {
|
|
121
|
-
err(`Unknown opt-in plugin '${name}'. Known: ${KNOWN_CLAUDE_OPTIN_PLUGINS.join(", ")}`);
|
|
122
|
-
throw new ExitError(2);
|
|
123
|
-
}
|
|
124
|
-
return name;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export function markModifier(ctx: Ctx, flag: ModifierFlag): void {
|
|
128
|
-
const flags = ctx.modifierFlags ?? new Set<ModifierFlag>();
|
|
129
|
-
flags.add(flag);
|
|
130
|
-
ctx.modifierFlags = flags;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function addClaudePlugin(ctx: Ctx, name: string): void {
|
|
134
|
-
if (name === "") {
|
|
135
|
-
printCatalog(
|
|
136
|
-
ctx,
|
|
137
|
-
`Available Claude optional plugins:\n${KNOWN_CLAUDE_OPTIN_PLUGINS.map((plugin) => ` ${plugin}`).join("\n")}`,
|
|
138
|
-
);
|
|
139
|
-
ctx.services.logger.err(
|
|
140
|
-
`Invalid Claude plugin '' — valid: ${KNOWN_CLAUDE_OPTIN_PLUGINS.join("|")}`,
|
|
141
|
-
);
|
|
142
|
-
throw new ExitError(2);
|
|
143
|
-
}
|
|
144
|
-
ctx.claudePlugins.push(parseClaudePlugin(name, ctx.services.logger.err));
|
|
145
|
-
markModifier(ctx, "--claude-plugin");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export function setModifier(ctx: Ctx, flag: ScalarModifierFlag, value: string): void {
|
|
149
|
-
switch (flag) {
|
|
150
|
-
case "--claude-model":
|
|
151
|
-
ctx.claudeModel = value;
|
|
152
|
-
break;
|
|
153
|
-
case "--claude-effort":
|
|
154
|
-
ctx.claudeEffort = value;
|
|
155
|
-
break;
|
|
156
|
-
case "--claude-advisor":
|
|
157
|
-
ctx.claudeAdvisor = value;
|
|
158
|
-
break;
|
|
159
|
-
case "--codex-model":
|
|
160
|
-
ctx.codexModel = value;
|
|
161
|
-
break;
|
|
162
|
-
case "--codex-effort":
|
|
163
|
-
ctx.codexEffort = value;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
markModifier(ctx, flag);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function isScalarModifierFlag(value: string): value is ScalarModifierFlag {
|
|
170
|
-
return SCALAR_MODIFIER_FLAGS[value as ScalarModifierFlag] === true;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export async function validateModifierFlags(ctx: Ctx): Promise<void> {
|
|
174
|
-
const { err, warn } = ctx.services.logger;
|
|
175
|
-
const supplied = (flag: ModifierFlag): boolean =>
|
|
176
|
-
MODIFIER_METADATA[flag].hasValue(ctx) || ctx.modifierFlags?.has(flag) === true;
|
|
177
|
-
|
|
178
|
-
for (const flag of Object.keys(MODIFIER_METADATA) as Array<ModifierFlag>) {
|
|
179
|
-
const metadata = MODIFIER_METADATA[flag];
|
|
180
|
-
const targetSelected = metadata.target === "claude" ? ctx.syncClaude : ctx.syncCodex;
|
|
181
|
-
if (!targetSelected && supplied(flag)) {
|
|
182
|
-
warn(metadata.ignoredWarning);
|
|
183
|
-
metadata.clear(ctx);
|
|
184
|
-
ctx.modifierFlags?.delete(flag);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (supplied("--claude-model")) {
|
|
189
|
-
const catalog = await resolveCatalog("claude", defaultLiveInputs(ctx.home));
|
|
190
|
-
if (!validateClaudeModel(ctx, ctx.claudeModel, catalog)) {
|
|
191
|
-
printModels(ctx, catalog);
|
|
192
|
-
err(`Invalid Claude model '${ctx.claudeModel}' — use an alias above or a full claude-* ID`);
|
|
193
|
-
throw new ExitError(2);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (supplied("--claude-effort")) {
|
|
197
|
-
if (!isEffortModifierValue("claude", ctx.claudeEffort)) {
|
|
198
|
-
printCatalog(ctx, effortCatalog("claude"));
|
|
199
|
-
err(`Invalid Claude effort '${ctx.claudeEffort}' — valid: ${effortValueGrammar("claude")}`);
|
|
200
|
-
throw new ExitError(2);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (supplied("--claude-advisor")) {
|
|
204
|
-
if (!CLAUDE_ADVISOR_STATES.some((state) => state === ctx.claudeAdvisor)) {
|
|
205
|
-
printCatalog(ctx, advisorCatalog());
|
|
206
|
-
err(`Invalid Claude advisor state '${ctx.claudeAdvisor}' — valid: ${advisorValueGrammar()}`);
|
|
207
|
-
throw new ExitError(2);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (supplied("--codex-model")) {
|
|
211
|
-
const catalog = await resolveCatalog("codex", defaultLiveInputs(ctx.home));
|
|
212
|
-
if (!validateCodexModel(ctx, ctx.codexModel, catalog)) {
|
|
213
|
-
printModels(ctx, catalog);
|
|
214
|
-
err(`Invalid Codex model '${ctx.codexModel}' — must match ^[A-Za-z0-9._-]+$`);
|
|
215
|
-
throw new ExitError(2);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (supplied("--codex-effort")) {
|
|
219
|
-
if (!isEffortModifierValue("codex", ctx.codexEffort)) {
|
|
220
|
-
printCatalog(ctx, effortCatalog("codex"));
|
|
221
|
-
err(`Invalid Codex effort '${ctx.codexEffort}' — valid: ${effortValueGrammar("codex")}`);
|
|
222
|
-
throw new ExitError(2);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `~/.claude/settings.json` merge helpers. Pure functions take the two parsed
|
|
3
|
-
* documents and return the merged document; the FS step (backup, tmp+rename,
|
|
4
|
-
* log line) lives in the sync orchestrator. jq-oracle equivalence is covered by
|
|
5
|
-
* cli/test/unit/settings.test.ts and deployed behavior by the golden suites.
|
|
6
|
-
*/
|
|
7
|
-
import { deepMerge, isObject, uniqueStrings, type Json } from "./jq";
|
|
8
|
-
|
|
9
|
-
/** `$user * $repo` — SoT keys win, permissions arrays replaced wholesale. */
|
|
10
|
-
export function reconcileSettings(repo: Json, user: Json): Json {
|
|
11
|
-
return deepMerge(user, repo);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* `($user * $repo)` + permissions.{allow,deny,ask} unioned (user + repo,
|
|
16
|
-
* `unique` — i.e. codepoint-sorted and deduplicated, matching jq).
|
|
17
|
-
*/
|
|
18
|
-
export function mergeSettings(repo: Json, user: Json): Json {
|
|
19
|
-
const candidate = deepMerge(user, repo);
|
|
20
|
-
if (!isObject(candidate)) return candidate;
|
|
21
|
-
const merged = { ...candidate };
|
|
22
|
-
const permissions = isObject(merged["permissions"]) ? merged["permissions"] : {};
|
|
23
|
-
merged["permissions"] = {
|
|
24
|
-
...permissions,
|
|
25
|
-
allow: unionPermissions(user, repo, "allow"),
|
|
26
|
-
deny: unionPermissions(user, repo, "deny"),
|
|
27
|
-
ask: unionPermissions(user, repo, "ask"),
|
|
28
|
-
};
|
|
29
|
-
return merged;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function unionPermissions(user: Json, repo: Json, key: string): Array<string> {
|
|
33
|
-
return uniqueStrings([...permissionArray(user, key), ...permissionArray(repo, key)]);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function permissionArray(doc: Json, key: string): Array<string> {
|
|
37
|
-
if (!isObject(doc)) return [];
|
|
38
|
-
const permissions = doc["permissions"];
|
|
39
|
-
if (!isObject(permissions)) return [];
|
|
40
|
-
const arr = permissions[key];
|
|
41
|
-
return Array.isArray(arr) ? arr.filter((x): x is string => typeof x === "string") : [];
|
|
42
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EngineNative universal-skill install pass (`npx skills@<pin> add`) with
|
|
3
|
-
* Claude symlink healing. Split from skillsSync.ts; the orchestration still
|
|
4
|
-
* lives there. The pass records a slug as pending before its install only
|
|
5
|
-
* when the canonical directory does not exist (`skillsRecords.ts`). After
|
|
6
|
-
* the install, it moves the slug to the owned record when its directory
|
|
7
|
-
* exists. It writes both records before the next install starts. A canonical
|
|
8
|
-
* directory that existed before is reused and never recorded.
|
|
9
|
-
*/
|
|
10
|
-
import { p, spawnProcess } from "./exec";
|
|
11
|
-
import type { Ctx } from "./index";
|
|
12
|
-
import { ExitError } from "./parseArgs";
|
|
13
|
-
import { healClaudeSymlink, isDir } from "./skillsLinks";
|
|
14
|
-
import {
|
|
15
|
-
canonicalAbsent,
|
|
16
|
-
recordPendingInstall,
|
|
17
|
-
settlePendingSlug,
|
|
18
|
-
writeSkillRecords,
|
|
19
|
-
type SkillRecords,
|
|
20
|
-
} from "./skillsRecords";
|
|
21
|
-
import { normalizeManifest, skillBase } from "./skillsManifest";
|
|
22
|
-
import { field } from "./toolchain";
|
|
23
|
-
|
|
24
|
-
export interface SkillsState {
|
|
25
|
-
present: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** skills::_skills_cli — the pinned npx package spec. */
|
|
29
|
-
function skillsCli(ctx: Ctx): string {
|
|
30
|
-
const version = field("skills-cli", "verified");
|
|
31
|
-
if (version !== "") return `skills@${version}`;
|
|
32
|
-
ctx.services.logger.err(
|
|
33
|
-
"Universal skills sync aborted because SoT/toolchain.json has no verified skills-cli pin",
|
|
34
|
-
);
|
|
35
|
-
throw new ExitError(1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function syncUniversal(
|
|
39
|
-
ctx: Ctx,
|
|
40
|
-
state: SkillsState,
|
|
41
|
-
skillsDir: string,
|
|
42
|
-
manifest: string,
|
|
43
|
-
records: SkillRecords,
|
|
44
|
-
): Promise<void> {
|
|
45
|
-
const { change, clearProgress, echo, progress, verbose, warn } = ctx.services.logger;
|
|
46
|
-
if (ctx.services.deps.probe("npx").state === "missing") {
|
|
47
|
-
ctx.services.deps.warnMissing(
|
|
48
|
-
"npx",
|
|
49
|
-
ctx.services.logger,
|
|
50
|
-
"skipping universal skills bootstrap",
|
|
51
|
-
);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let added = 0;
|
|
56
|
-
let already = 0;
|
|
57
|
-
let failed = 0;
|
|
58
|
-
let healed = 0;
|
|
59
|
-
|
|
60
|
-
for (const slug of normalizeManifest(manifest)) {
|
|
61
|
-
const base = skillBase(slug);
|
|
62
|
-
|
|
63
|
-
if (ctx.dryRun) {
|
|
64
|
-
if (isDir(p(skillsDir, base))) {
|
|
65
|
-
echo(`[dry-run] universal skill present: ${base}`);
|
|
66
|
-
healClaudeSymlink(ctx, skillsDir, base);
|
|
67
|
-
} else {
|
|
68
|
-
echo(`[dry-run] npx ${skillsCli(ctx)} add ${slug} -g -y -a claude-code codex`);
|
|
69
|
-
}
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (isDir(p(skillsDir, base))) {
|
|
74
|
-
already++;
|
|
75
|
-
if (!records.owned.has(slug) && !records.legacy.has(slug)) {
|
|
76
|
-
warn(
|
|
77
|
-
`Universal skill ${slug}: reused the existing ~/.agents/skills/${base}; the kit did not install it, so --prune keeps it`,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
if (healClaudeSymlink(ctx, skillsDir, base)) healed++;
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const cli = skillsCli(ctx);
|
|
85
|
-
const pending = canonicalAbsent(skillsDir, slug);
|
|
86
|
-
if (pending) recordPendingInstall(records, slug);
|
|
87
|
-
progress(`Installing universal skill ${slug}...`);
|
|
88
|
-
const res = await spawnProcess(
|
|
89
|
-
"npx",
|
|
90
|
-
["--yes", cli, "add", slug, "-g", "-y", "-a", "claude-code", "codex"],
|
|
91
|
-
{
|
|
92
|
-
stdio: "ignore",
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
clearProgress();
|
|
96
|
-
if (pending) {
|
|
97
|
-
// The owned record goes first, so a stop between the writes keeps the slug pending.
|
|
98
|
-
settlePendingSlug(records, skillsDir, slug);
|
|
99
|
-
writeSkillRecords(ctx, records);
|
|
100
|
-
}
|
|
101
|
-
if (res.error === undefined && res.exitCode === 0) {
|
|
102
|
-
added++;
|
|
103
|
-
if (!isDir(p(skillsDir, base))) {
|
|
104
|
-
warn(
|
|
105
|
-
`Installed skill name differs from slug ${slug}; declare it as <owner>/<repo>@<skill-name>`,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
warn(`Failed to install universal skill: ${slug}`);
|
|
110
|
-
failed++;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (ctx.dryRun) return;
|
|
115
|
-
|
|
116
|
-
state.present = added + already;
|
|
117
|
-
|
|
118
|
-
if (added > 0) {
|
|
119
|
-
change(`Universal skills synced (+${added} new, ${already} already present)`);
|
|
120
|
-
ctx.nextStepTriggers.skillsRestart = true;
|
|
121
|
-
} else {
|
|
122
|
-
verbose(`Universal skills already in sync (${already} present)`);
|
|
123
|
-
}
|
|
124
|
-
if (healed > 0) {
|
|
125
|
-
change(
|
|
126
|
-
`Claude per-tool symlinks healed (+${healed}) — canonical present, ~/.claude/skills/<name> was missing or broken`,
|
|
127
|
-
);
|
|
128
|
-
ctx.nextStepTriggers.skillsRestart = true;
|
|
129
|
-
}
|
|
130
|
-
if (failed > 0) {
|
|
131
|
-
warn(
|
|
132
|
-
`${failed} skill install(s) failed — re-run sync or install manually with: npx --yes ${skillsCli(ctx)} add <slug> -g -y -a claude-code codex`,
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EngineNative skill link mechanics: Claude per-tool symlink healing plus the
|
|
3
|
-
* directory-link-or-marked-copy fallback. Split from skillsSync.ts; the
|
|
4
|
-
* install pass (skillsInstall.ts) and the prune pass (skillsPrune.ts) share
|
|
5
|
-
* the probe and removal helpers exported here.
|
|
6
|
-
*/
|
|
7
|
-
import {
|
|
8
|
-
cpSync,
|
|
9
|
-
existsSync,
|
|
10
|
-
lstatSync,
|
|
11
|
-
mkdirSync,
|
|
12
|
-
readlinkSync,
|
|
13
|
-
realpathSync,
|
|
14
|
-
rmSync,
|
|
15
|
-
statSync,
|
|
16
|
-
symlinkSync,
|
|
17
|
-
writeFileSync,
|
|
18
|
-
} from "node:fs";
|
|
19
|
-
import { dirname, relative, resolve } from "node:path";
|
|
20
|
-
import { p } from "./exec";
|
|
21
|
-
import type { Ctx } from "./index";
|
|
22
|
-
import { hostOs, type DirectoryLinkKind } from "./os";
|
|
23
|
-
import type { EngineServices } from "./services";
|
|
24
|
-
|
|
25
|
-
export type LinkOutcome = "symlink" | "junction" | "copy" | "failed";
|
|
26
|
-
|
|
27
|
-
/** Lets heal and prune distinguish a kit-owned copy from a user's real directory. */
|
|
28
|
-
export const COPY_MARKER = ".docks-kit-copied-skill";
|
|
29
|
-
|
|
30
|
-
export function isDir(path: string): boolean {
|
|
31
|
-
try {
|
|
32
|
-
return statSync(path).isDirectory();
|
|
33
|
-
} catch {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** skills::heal_claude_symlink — true when a heal occurred. */
|
|
39
|
-
export function healClaudeSymlink(ctx: Ctx, skillsDir: string, base: string): boolean {
|
|
40
|
-
const { echo, warn } = ctx.services.logger;
|
|
41
|
-
const canonical = p(skillsDir, base);
|
|
42
|
-
const claudeSkillsDir = p(ctx.home, ".claude", "skills");
|
|
43
|
-
const claudeLink = p(claudeSkillsDir, base);
|
|
44
|
-
const relTarget = relative(dirname(claudeLink), canonical);
|
|
45
|
-
|
|
46
|
-
if (!isDir(canonical)) return false;
|
|
47
|
-
|
|
48
|
-
const linkStat = lstat(claudeLink);
|
|
49
|
-
if (linkStat?.isSymbolicLink() === true) {
|
|
50
|
-
const current = safeReadlink(claudeLink);
|
|
51
|
-
if (current === relTarget || pointsAt(claudeLink, canonical)) return false;
|
|
52
|
-
if (ctx.dryRun) {
|
|
53
|
-
echo(
|
|
54
|
-
`[dry-run] would replace stale Claude symlink: ~/.claude/skills/${base} -> ${current} (correct: ${relTarget})`,
|
|
55
|
-
);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
if (!removeLink(claudeLink)) {
|
|
59
|
-
warn(
|
|
60
|
-
`could not remove stale link ~/.claude/skills/${base} — remove it manually, then re-run sync`,
|
|
61
|
-
);
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
} else if (linkStat !== undefined) {
|
|
65
|
-
if (!isKitOwnedCopy(claudeLink)) {
|
|
66
|
-
warn(
|
|
67
|
-
`~/.claude/skills/${base} exists as a real path (not a symlink) — leaving alone; remove manually if it's stale`,
|
|
68
|
-
);
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
if (ctx.dryRun) {
|
|
72
|
-
echo(
|
|
73
|
-
`[dry-run] would replace kit-created Claude copy: ~/.claude/skills/${base} -> ${relTarget}`,
|
|
74
|
-
);
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
if (!removeKitOwnedCopy(claudeLink)) {
|
|
78
|
-
warn(
|
|
79
|
-
`could not remove kit-created copy ~/.claude/skills/${base} — remove it manually, then re-run sync`,
|
|
80
|
-
);
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
} else if (ctx.dryRun) {
|
|
84
|
-
echo(`[dry-run] would create missing Claude symlink: ~/.claude/skills/${base} -> ${relTarget}`);
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
mkdirSync(claudeSkillsDir, { recursive: true });
|
|
89
|
-
return linkOrCopyWithWarnings(relTarget, claudeLink, ctx.services) !== "failed";
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function lstat(path: string): ReturnType<typeof lstatSync> | undefined {
|
|
93
|
-
try {
|
|
94
|
-
return lstatSync(path);
|
|
95
|
-
} catch {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* A link only counts when it RESOLVES to the skill directory. Windows picks a
|
|
102
|
-
* symlink's file-or-directory type by autodetecting the target against the
|
|
103
|
-
* process working directory, not the link's own directory, so a relative
|
|
104
|
-
* target can yield a symlink that exists but resolves to nothing. Checking
|
|
105
|
-
* resolution is what makes the next mechanism in the chain reachable.
|
|
106
|
-
*/
|
|
107
|
-
function linksToDirectory(path: string): boolean {
|
|
108
|
-
if (lstat(path)?.isSymbolicLink() !== true) return false;
|
|
109
|
-
try {
|
|
110
|
-
return statSync(path).isDirectory();
|
|
111
|
-
} catch {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function isKitOwnedCopy(path: string): boolean {
|
|
117
|
-
return lstat(path)?.isDirectory() === true && existsSync(p(path, COPY_MARKER));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function removeKitOwnedCopy(path: string): boolean {
|
|
121
|
-
if (!isKitOwnedCopy(path)) return false;
|
|
122
|
-
try {
|
|
123
|
-
rmSync(path, { recursive: true, force: true });
|
|
124
|
-
return true;
|
|
125
|
-
} catch {
|
|
126
|
-
return lstat(path) === undefined;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function safeReadlink(path: string): string {
|
|
131
|
-
try {
|
|
132
|
-
return readlinkSync(path);
|
|
133
|
-
} catch {
|
|
134
|
-
return "";
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* True when `link` resolves to `target`. A junction stores an absolute target,
|
|
140
|
-
* so the link text never equals the relative form that a symlink uses.
|
|
141
|
-
*/
|
|
142
|
-
function pointsAt(link: string, target: string): boolean {
|
|
143
|
-
try {
|
|
144
|
-
return realpathSync.native(link) === realpathSync.native(target);
|
|
145
|
-
} catch {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** Remove a symlink without touching a real directory. */
|
|
151
|
-
export function removeLink(path: string): boolean {
|
|
152
|
-
try {
|
|
153
|
-
rmSync(path, { force: true });
|
|
154
|
-
return true;
|
|
155
|
-
} catch {
|
|
156
|
-
return lstat(path) === undefined;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** skills::_link_or_copy — try directory links in host order, then a marked copy. */
|
|
161
|
-
export function linkOrCopy(
|
|
162
|
-
target: string,
|
|
163
|
-
link: string,
|
|
164
|
-
kinds: ReadonlyArray<DirectoryLinkKind> = hostOs().directoryLinkKinds,
|
|
165
|
-
): LinkOutcome {
|
|
166
|
-
const resolvedLink = resolve(link);
|
|
167
|
-
const absoluteTarget = resolve(dirname(resolvedLink), target);
|
|
168
|
-
if (absoluteTarget === resolvedLink) return "symlink";
|
|
169
|
-
removeLink(link);
|
|
170
|
-
|
|
171
|
-
for (const kind of kinds) {
|
|
172
|
-
try {
|
|
173
|
-
if (kind === "symlink") {
|
|
174
|
-
symlinkSync(target, link);
|
|
175
|
-
} else {
|
|
176
|
-
symlinkSync(absoluteTarget, link, "junction");
|
|
177
|
-
}
|
|
178
|
-
if (linksToDirectory(link)) return kind;
|
|
179
|
-
} catch {
|
|
180
|
-
// The runtime decides whether each mechanism works; try the next one.
|
|
181
|
-
}
|
|
182
|
-
removeLink(link);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const copyDestinationWasAbsent = lstat(link) === undefined;
|
|
186
|
-
try {
|
|
187
|
-
cpSync(absoluteTarget, link, { recursive: true });
|
|
188
|
-
writeFileSync(p(link, COPY_MARKER), "");
|
|
189
|
-
return "copy";
|
|
190
|
-
} catch {
|
|
191
|
-
if (copyDestinationWasAbsent) {
|
|
192
|
-
try {
|
|
193
|
-
rmSync(link, { recursive: true, force: true });
|
|
194
|
-
} catch {
|
|
195
|
-
// The outcome remains failed; a later sync can retry the destination.
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return "failed";
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function linkOrCopyWithWarnings(
|
|
203
|
-
target: string,
|
|
204
|
-
link: string,
|
|
205
|
-
services: EngineServices,
|
|
206
|
-
): LinkOutcome {
|
|
207
|
-
const outcome = linkOrCopy(target, link);
|
|
208
|
-
if (outcome === "copy") {
|
|
209
|
-
services.logger.warn(
|
|
210
|
-
`created copy fallback ${link} because directory linking is unavailable — a later sync will restore a real link once linking works`,
|
|
211
|
-
);
|
|
212
|
-
} else if (outcome === "failed") {
|
|
213
|
-
services.logger.warn(`could not create symlink ${link}`);
|
|
214
|
-
}
|
|
215
|
-
return outcome;
|
|
216
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EngineNative universal-skill manifest parsing: cleaned slugs, one per line.
|
|
3
|
-
* Split from skillsSync.ts. Pure logic with no process state.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/** skills::_normalize_manifest — cleaned slugs, one per line. */
|
|
7
|
-
export function normalizeManifest(content: string): Array<string> {
|
|
8
|
-
const out: Array<string> = [];
|
|
9
|
-
for (const line of content.split("\n")) {
|
|
10
|
-
if (/^[ \t]*#/.test(line)) continue;
|
|
11
|
-
if (/^[ \t]*$/.test(line)) continue;
|
|
12
|
-
const cleaned = line.replace(/[ \t]*#.*$/, "").replace(/[ \t\r]+/g, "");
|
|
13
|
-
if (cleaned.length > 0) out.push(cleaned);
|
|
14
|
-
}
|
|
15
|
-
return out;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The directory the skills CLI installs for a manifest slug. The CLI names a
|
|
20
|
-
* skill directory after the skill. It reads `@<skill>` only in the
|
|
21
|
-
* `<owner>/<repo>@<skill>` form (skills@1.7.0 parseSource), so an `@` in a local
|
|
22
|
-
* path or URL stays part of the name. Any other slug means one skill named after
|
|
23
|
-
* its last path segment. The name goes through the CLI's `sanitizeName` rule.
|
|
24
|
-
*/
|
|
25
|
-
export function skillBase(slug: string): string {
|
|
26
|
-
const selector = /^[^/]+\/[^/@]+@(.+)$/.exec(slug)?.[1];
|
|
27
|
-
const nativeForm = !slug.includes(":") && !slug.startsWith(".") && !slug.startsWith("/");
|
|
28
|
-
const name =
|
|
29
|
-
selector !== undefined && nativeForm ? selector : slug.slice(slug.lastIndexOf("/") + 1);
|
|
30
|
-
const sanitized = name
|
|
31
|
-
.toLowerCase()
|
|
32
|
-
.replace(/[^a-z0-9._]+/g, "-")
|
|
33
|
-
.replace(/^[.-]+|[.-]+$/g, "")
|
|
34
|
-
.slice(0, 255);
|
|
35
|
-
return sanitized === "" ? "unnamed-skill" : sanitized;
|
|
36
|
-
}
|