@oisincoveney/pipeline 3.16.0 → 3.17.1

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.
@@ -36,6 +36,7 @@ function mokaCommonSubmitOptions(input) {
36
36
  return {
37
37
  brokerAuth: resolveMokaBrokerAuth(input.globalConfig),
38
38
  config: input.config,
39
+ dbAuth: momokaya?.submit.dbAuth,
39
40
  delivery: { pullRequest: input.flags.openPr === true },
40
41
  eventUrl: input.eventUrl,
41
42
  eventAuthSecretKey: momokaya?.submit.eventAuthSecretKey,
@@ -80,8 +80,6 @@ declare const DEFAULT_OPENCODE_ECOSYSTEM_MANIFEST: {
80
80
  default_stack: true;
81
81
  id: string;
82
82
  name: string;
83
- role: string;
84
- source: string;
85
83
  package?: string | undefined;
86
84
  plugin?: {
87
85
  kind: "local";
@@ -91,6 +89,8 @@ declare const DEFAULT_OPENCODE_ECOSYSTEM_MANIFEST: {
91
89
  kind: "npm";
92
90
  package: string;
93
91
  } | undefined;
92
+ role: string;
93
+ source: string;
94
94
  }[];
95
95
  generated_by: "@oisincoveney/pipeline";
96
96
  host_capabilities: {
@@ -108,9 +108,9 @@ declare const DEFAULT_OPENCODE_ECOSYSTEM_MANIFEST: {
108
108
  credentials: string[];
109
109
  id: string;
110
110
  locality: string;
111
+ name?: string | undefined;
111
112
  required: boolean;
112
113
  role: string;
113
- name?: string | undefined;
114
114
  }[];
115
115
  official_dependencies: {
116
116
  dependency_scope: string;
@@ -121,9 +121,9 @@ declare const DEFAULT_OPENCODE_ECOSYSTEM_MANIFEST: {
121
121
  }[];
122
122
  prompts: {
123
123
  id: string;
124
- used_by: string[];
125
124
  path?: string | undefined;
126
125
  source?: string | undefined;
126
+ used_by: string[];
127
127
  }[];
128
128
  runtime: {
129
129
  compatibility_runners: string[];
@@ -133,9 +133,9 @@ declare const DEFAULT_OPENCODE_ECOSYSTEM_MANIFEST: {
133
133
  };
134
134
  skills: {
135
135
  id: string;
136
- used_by: string[];
137
136
  path?: string | undefined;
138
137
  source?: string | undefined;
138
+ used_by: string[];
139
139
  }[];
140
140
  sources: {
141
141
  label: string;
@@ -92,10 +92,10 @@ declare const workflowNodeBaseSchema: z.ZodObject<{
92
92
  models: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
93
  needs: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
94
  reasoning_effort: z.ZodOptional<z.ZodEnum<{
95
- none: "none";
95
+ high: "high";
96
96
  low: "low";
97
97
  medium: "medium";
98
- high: "high";
98
+ none: "none";
99
99
  xhigh: "xhigh";
100
100
  }>>;
101
101
  retries: z.ZodOptional<z.ZodObject<{
@@ -176,8 +176,8 @@ declare const configSchema: z.ZodObject<{
176
176
  "workspace-write": "workspace-write";
177
177
  }>>;
178
178
  network: z.ZodOptional<z.ZodEnum<{
179
- inherit: "inherit";
180
179
  disabled: "disabled";
180
+ inherit: "inherit";
181
181
  }>>;
182
182
  }, z.core.$strict>>;
183
183
  returns: z.ZodOptional<z.ZodObject<{
@@ -251,12 +251,12 @@ declare const configSchema: z.ZodObject<{
251
251
  }, z.core.$strict>>>;
252
252
  default_profile: z.ZodOptional<z.ZodString>;
253
253
  host_scope: z.ZodDefault<z.ZodEnum<{
254
- project: "project";
255
254
  global: "global";
255
+ project: "project";
256
256
  }>>;
257
257
  mode: z.ZodEnum<{
258
- local: "local";
259
258
  hosted: "hosted";
259
+ local: "local";
260
260
  }>;
261
261
  provider: z.ZodLiteral<"toolhive">;
262
262
  authorization_env: z.ZodDefault<z.ZodString>;
@@ -294,16 +294,16 @@ declare const configSchema: z.ZodObject<{
294
294
  model: z.ZodOptional<z.ZodString>;
295
295
  network: z.ZodOptional<z.ZodObject<{
296
296
  mode: z.ZodEnum<{
297
- inherit: "inherit";
298
297
  disabled: "disabled";
298
+ inherit: "inherit";
299
299
  }>;
300
300
  }, z.core.$strict>>;
301
301
  output: z.ZodOptional<z.ZodObject<{
302
302
  format: z.ZodEnum<{
303
- json_schema: "json_schema";
304
- text: "text";
305
303
  json: "json";
304
+ json_schema: "json_schema";
306
305
  jsonl: "jsonl";
306
+ text: "text";
307
307
  }>;
308
308
  repair: z.ZodOptional<z.ZodObject<{
309
309
  enabled: z.ZodOptional<z.ZodBoolean>;
@@ -313,10 +313,10 @@ declare const configSchema: z.ZodObject<{
313
313
  schema_path: z.ZodOptional<z.ZodString>;
314
314
  }, z.core.$strict>>;
315
315
  reasoning_effort: z.ZodOptional<z.ZodEnum<{
316
- none: "none";
316
+ high: "high";
317
317
  low: "low";
318
318
  medium: "medium";
319
- high: "high";
319
+ none: "none";
320
320
  xhigh: "xhigh";
321
321
  }>>;
322
322
  rules: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -328,13 +328,13 @@ declare const configSchema: z.ZodObject<{
328
328
  skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
329
329
  timeout_ms: z.ZodOptional<z.ZodNumber>;
330
330
  tools: z.ZodOptional<z.ZodArray<z.ZodEnum<{
331
- task: "task";
332
- read: "read";
333
- list: "list";
334
- grep: "grep";
335
- glob: "glob";
336
331
  bash: "bash";
337
332
  edit: "edit";
333
+ glob: "glob";
334
+ grep: "grep";
335
+ list: "list";
336
+ read: "read";
337
+ task: "task";
338
338
  write: "write";
339
339
  }>>>;
340
340
  }, z.core.$strict>>>;
@@ -361,8 +361,8 @@ declare const configSchema: z.ZodObject<{
361
361
  rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
362
362
  path: z.ZodString;
363
363
  source_root: z.ZodDefault<z.ZodEnum<{
364
- project: "project";
365
364
  package: "package";
365
+ project: "project";
366
366
  }>>;
367
367
  }, z.core.$strict>>>;
368
368
  runners: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -375,25 +375,25 @@ declare const configSchema: z.ZodObject<{
375
375
  mcp_servers: z.ZodOptional<z.ZodBoolean>;
376
376
  native_subagents: z.ZodOptional<z.ZodBoolean>;
377
377
  network: z.ZodOptional<z.ZodArray<z.ZodEnum<{
378
- inherit: "inherit";
379
378
  disabled: "disabled";
379
+ inherit: "inherit";
380
380
  }>>>;
381
381
  output_formats: z.ZodOptional<z.ZodArray<z.ZodEnum<{
382
- json_schema: "json_schema";
383
- text: "text";
384
382
  json: "json";
383
+ json_schema: "json_schema";
385
384
  jsonl: "jsonl";
385
+ text: "text";
386
386
  }>>>;
387
387
  rules: z.ZodOptional<z.ZodBoolean>;
388
388
  skills: z.ZodOptional<z.ZodBoolean>;
389
389
  tools: z.ZodOptional<z.ZodArray<z.ZodEnum<{
390
- task: "task";
391
- read: "read";
392
- list: "list";
393
- grep: "grep";
394
- glob: "glob";
395
390
  bash: "bash";
396
391
  edit: "edit";
392
+ glob: "glob";
393
+ grep: "grep";
394
+ list: "list";
395
+ read: "read";
396
+ task: "task";
397
397
  write: "write";
398
398
  }>>>;
399
399
  }, z.core.$strict>;
@@ -401,10 +401,10 @@ declare const configSchema: z.ZodObject<{
401
401
  host_models: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
402
402
  model: z.ZodOptional<z.ZodString>;
403
403
  reasoning_effort: z.ZodOptional<z.ZodEnum<{
404
- none: "none";
404
+ high: "high";
405
405
  low: "low";
406
406
  medium: "medium";
407
- high: "high";
407
+ none: "none";
408
408
  xhigh: "xhigh";
409
409
  }>>;
410
410
  type: z.ZodEnum<{
@@ -490,10 +490,10 @@ declare const configSchema: z.ZodObject<{
490
490
  models: z.ZodArray<z.ZodString>;
491
491
  profile: z.ZodString;
492
492
  reasoning_effort: z.ZodOptional<z.ZodEnum<{
493
- none: "none";
493
+ high: "high";
494
494
  low: "low";
495
495
  medium: "medium";
496
- high: "high";
496
+ none: "none";
497
497
  xhigh: "xhigh";
498
498
  }>>;
499
499
  }, z.core.$strict>>>;
@@ -503,8 +503,8 @@ declare const configSchema: z.ZodObject<{
503
503
  schedules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
504
504
  description: z.ZodOptional<z.ZodString>;
505
505
  baseline: z.ZodEnum<{
506
- quick: "quick";
507
506
  execute: "execute";
507
+ quick: "quick";
508
508
  }>;
509
509
  max_parallel_nodes: z.ZodOptional<z.ZodNumber>;
510
510
  node_catalog: z.ZodOptional<z.ZodString>;
@@ -516,8 +516,8 @@ declare const configSchema: z.ZodObject<{
516
516
  skills: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
517
517
  path: z.ZodString;
518
518
  source_root: z.ZodDefault<z.ZodEnum<{
519
- project: "project";
520
519
  package: "package";
520
+ project: "project";
521
521
  }>>;
522
522
  }, z.core.$strict>>>;
523
523
  task_context: z.ZodOptional<z.ZodObject<{
@@ -95,4 +95,4 @@ function commandIdForHost(host, entrypointId) {
95
95
  return entrypointId;
96
96
  }
97
97
  //#endregion
98
- export { AGENTS_MD_END, AGENTS_MD_START, CLAUDE_PROJECT_CONFIG_PATH, CLAUDE_USER_CONFIG_PATH, CODEX_CONFIG_PATH, COMMAND_HOSTS, ENTRYPOINT_PATH_PATTERNS, GENERATED_MARKER, GENERATED_TS_MARKER, GENERATED_YAML_MARKER, INSTALL_HOSTS, OPENCODE_PROJECT_CONFIG_PATH, OWNER_MARKER_PREFIX, OWNER_TS_MARKER_PREFIX, OWNER_YAML_MARKER_PREFIX, SINGLE_OPENCODE_PLUGIN_ARRAY_RE, commandIdForHost, compactLines, entrypointDescription, entrypointEntries, instructionsPointer, invocationForHost, profileEntries, resolveHarnessTarget };
98
+ export { AGENTS_MD_END, AGENTS_MD_START, CLAUDE_PROJECT_CONFIG_PATH, CLAUDE_USER_CONFIG_PATH, CODEX_CONFIG_PATH, COMMAND_HOSTS, ENTRYPOINT_PATH_PATTERNS, GENERATED_MARKER, GENERATED_TS_MARKER, GENERATED_YAML_MARKER, INSTALL_HOSTS, OPENCODE_PROJECT_CONFIG_PATH, OWNER_MARKER_PREFIX, OWNER_TS_MARKER_PREFIX, OWNER_YAML_MARKER_PREFIX, SINGLE_OPENCODE_PLUGIN_ARRAY_RE, claudeGlobalConfigDir, codexGlobalConfigDir, commandIdForHost, compactLines, entrypointDescription, entrypointEntries, instructionsPointer, invocationForHost, opencodeGlobalConfigDir, profileEntries, resolveHarnessTarget };
@@ -24,8 +24,12 @@ const NON_HOOK_OWNED_TARGETS = new Set([".opencode/opencode.json"]);
24
24
  function hashContent(content) {
25
25
  return createHash("sha256").update(content).digest("hex");
26
26
  }
27
- const MERGE_MANAGED = { ".claude/settings.json": ["hooks"] };
28
- function mergeKeyFor(path) {
27
+ const MERGE_MANAGED = { ".claude/settings.json": [
28
+ ["hooks"],
29
+ ["skillListingBudgetFraction"],
30
+ ["skillOverrides"]
31
+ ] };
32
+ function mergeKeysFor(path) {
29
33
  return MERGE_MANAGED[path];
30
34
  }
31
35
  function canonicalize(value) {
@@ -51,8 +55,12 @@ function managedSubtree(text, keyPath) {
51
55
  return cursor;
52
56
  }
53
57
  function targetIdentityHash(path, content) {
54
- const mergeKey = mergeKeyFor(path);
55
- return mergeKey ? hashJson(managedSubtree(content.toString("utf8"), mergeKey)) : hashContent(content);
58
+ const mergeKeys = mergeKeysFor(path);
59
+ if (!mergeKeys) return hashContent(content);
60
+ const text = content.toString("utf8");
61
+ const subtrees = {};
62
+ for (const keyPath of mergeKeys) subtrees[keyPath.join(".")] = managedSubtree(text, keyPath);
63
+ return hashJson(subtrees);
56
64
  }
57
65
  async function cloneHookRepository(targetDir) {
58
66
  await execa("gh", [
@@ -178,9 +186,15 @@ async function writePlannedFile(file) {
178
186
  if (file.action === "conflict" || file.action === "unchanged") return;
179
187
  const target = targetPath(file.path);
180
188
  await mkdir(dirname(target), { recursive: true });
181
- const mergeKey = mergeKeyFor(file.path);
182
- if (mergeKey && existsSync(target)) {
183
- await writeFile(target, ensureTrailingNewline(applyJsonEdit(readFileSync(target, "utf8"), mergeKey, managedSubtree(file.content.toString("utf8"), mergeKey))));
189
+ const mergeKeys = mergeKeysFor(file.path);
190
+ if (mergeKeys && existsSync(target)) {
191
+ const sourceText = file.content.toString("utf8");
192
+ let merged = readFileSync(target, "utf8");
193
+ for (const keyPath of mergeKeys) {
194
+ const desired = managedSubtree(sourceText, keyPath);
195
+ if (desired !== void 0) merged = applyJsonEdit(merged, keyPath, desired);
196
+ }
197
+ await writeFile(target, ensureTrailingNewline(merged));
184
198
  return;
185
199
  }
186
200
  await writeFile(target, file.content);
@@ -18,6 +18,10 @@ declare const mokaGlobalConfigSchema: z.ZodObject<{
18
18
  secretName: z.ZodString;
19
19
  url: z.ZodDefault<z.ZodString>;
20
20
  }, z.core.$strict>;
21
+ dbAuth: z.ZodOptional<z.ZodObject<{
22
+ secretKey: z.ZodDefault<z.ZodString>;
23
+ secretName: z.ZodString;
24
+ }, z.core.$strict>>;
21
25
  eventAuthSecretKey: z.ZodString;
22
26
  eventAuthSecretName: z.ZodString;
23
27
  eventUrl: z.ZodString;
@@ -1,3 +1,4 @@
1
+ import { dbAuthOptionSchema } from "./remote/argo/model.js";
1
2
  import { brokerAuthOptionSchema } from "./credentials/broker.js";
2
3
  import { PipelineConfigError, configIssuesFromZodError, validationError } from "./config/schemas.js";
3
4
  import { ConfigIoService, runConfigIoSync } from "./runtime/services/config-io-service.js";
@@ -17,6 +18,7 @@ const mokaDbGlobalConfigSchema = z.object({ url: z.string().url().refine((value)
17
18
  }, { message: "db.url must use postgresql or postgres protocol" }) }).strict();
18
19
  const mokaSubmitGlobalConfigSchema = z.object({
19
20
  brokerAuth: brokerAuthOptionSchema,
21
+ dbAuth: dbAuthOptionSchema.optional(),
20
22
  eventAuthSecretKey: z.string().min(1),
21
23
  eventAuthSecretName: z.string().min(1),
22
24
  eventUrl: z.string().url(),
@@ -40,15 +40,15 @@ declare const mokaSubmitDirectHookSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
40
40
  module: z.ZodString;
41
41
  }, z.core.$strict>], "kind">;
42
42
  declare const mokaSubmitDirectHooksSchema: z.ZodRecord<z.ZodEnum<{
43
- "workflow.start": "workflow.start";
44
- "workflow.success": "workflow.success";
45
- "workflow.failure": "workflow.failure";
46
- "workflow.complete": "workflow.complete";
47
- "node.start": "node.start";
48
- "node.success": "node.success";
43
+ "gate.failure": "gate.failure";
49
44
  "node.error": "node.error";
50
45
  "node.finish": "node.finish";
51
- "gate.failure": "gate.failure";
46
+ "node.start": "node.start";
47
+ "node.success": "node.success";
48
+ "workflow.complete": "workflow.complete";
49
+ "workflow.failure": "workflow.failure";
50
+ "workflow.start": "workflow.start";
51
+ "workflow.success": "workflow.success";
52
52
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
53
53
  failure: z.ZodDefault<z.ZodEnum<{
54
54
  fail: "fail";
@@ -142,15 +142,15 @@ declare const mokaSubmitBaseOptionsSchema: z.ZodObject<{
142
142
  timeoutMs: z.ZodOptional<z.ZodNumber>;
143
143
  }, z.core.$strict>>;
144
144
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
145
- "workflow.start": "workflow.start";
146
- "workflow.success": "workflow.success";
147
- "workflow.failure": "workflow.failure";
148
- "workflow.complete": "workflow.complete";
149
- "node.start": "node.start";
150
- "node.success": "node.success";
145
+ "gate.failure": "gate.failure";
151
146
  "node.error": "node.error";
152
147
  "node.finish": "node.finish";
153
- "gate.failure": "gate.failure";
148
+ "node.start": "node.start";
149
+ "node.success": "node.success";
150
+ "workflow.complete": "workflow.complete";
151
+ "workflow.failure": "workflow.failure";
152
+ "workflow.start": "workflow.start";
153
+ "workflow.success": "workflow.success";
154
154
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
155
155
  failure: z.ZodDefault<z.ZodEnum<{
156
156
  fail: "fail";
@@ -251,15 +251,15 @@ declare const mokaGraphSubmitOptionsSchema: z.ZodObject<{
251
251
  timeoutMs: z.ZodOptional<z.ZodNumber>;
252
252
  }, z.core.$strict>>;
253
253
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
254
- "workflow.start": "workflow.start";
255
- "workflow.success": "workflow.success";
256
- "workflow.failure": "workflow.failure";
257
- "workflow.complete": "workflow.complete";
258
- "node.start": "node.start";
259
- "node.success": "node.success";
254
+ "gate.failure": "gate.failure";
260
255
  "node.error": "node.error";
261
256
  "node.finish": "node.finish";
262
- "gate.failure": "gate.failure";
257
+ "node.start": "node.start";
258
+ "node.success": "node.success";
259
+ "workflow.complete": "workflow.complete";
260
+ "workflow.failure": "workflow.failure";
261
+ "workflow.start": "workflow.start";
262
+ "workflow.success": "workflow.success";
263
263
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
264
264
  failure: z.ZodDefault<z.ZodEnum<{
265
265
  fail: "fail";
@@ -377,15 +377,15 @@ declare const mokaCommandSubmitOptionsSchema: z.ZodObject<{
377
377
  timeoutMs: z.ZodOptional<z.ZodNumber>;
378
378
  }, z.core.$strict>>;
379
379
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
380
- "workflow.start": "workflow.start";
381
- "workflow.success": "workflow.success";
382
- "workflow.failure": "workflow.failure";
383
- "workflow.complete": "workflow.complete";
384
- "node.start": "node.start";
385
- "node.success": "node.success";
380
+ "gate.failure": "gate.failure";
386
381
  "node.error": "node.error";
387
382
  "node.finish": "node.finish";
388
- "gate.failure": "gate.failure";
383
+ "node.start": "node.start";
384
+ "node.success": "node.success";
385
+ "workflow.complete": "workflow.complete";
386
+ "workflow.failure": "workflow.failure";
387
+ "workflow.start": "workflow.start";
388
+ "workflow.success": "workflow.success";
389
389
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
390
390
  failure: z.ZodDefault<z.ZodEnum<{
391
391
  fail: "fail";
@@ -498,15 +498,15 @@ declare const mokaSubmitOptionsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
498
498
  timeoutMs: z.ZodOptional<z.ZodNumber>;
499
499
  }, z.core.$strict>>;
500
500
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
501
- "workflow.start": "workflow.start";
502
- "workflow.success": "workflow.success";
503
- "workflow.failure": "workflow.failure";
504
- "workflow.complete": "workflow.complete";
505
- "node.start": "node.start";
506
- "node.success": "node.success";
501
+ "gate.failure": "gate.failure";
507
502
  "node.error": "node.error";
508
503
  "node.finish": "node.finish";
509
- "gate.failure": "gate.failure";
504
+ "node.start": "node.start";
505
+ "node.success": "node.success";
506
+ "workflow.complete": "workflow.complete";
507
+ "workflow.failure": "workflow.failure";
508
+ "workflow.start": "workflow.start";
509
+ "workflow.success": "workflow.success";
510
510
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
511
511
  failure: z.ZodDefault<z.ZodEnum<{
512
512
  fail: "fail";
@@ -623,15 +623,15 @@ declare const mokaSubmitOptionsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
623
623
  timeoutMs: z.ZodOptional<z.ZodNumber>;
624
624
  }, z.core.$strict>>;
625
625
  hooks: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
626
- "workflow.start": "workflow.start";
627
- "workflow.success": "workflow.success";
628
- "workflow.failure": "workflow.failure";
629
- "workflow.complete": "workflow.complete";
630
- "node.start": "node.start";
631
- "node.success": "node.success";
626
+ "gate.failure": "gate.failure";
632
627
  "node.error": "node.error";
633
628
  "node.finish": "node.finish";
634
- "gate.failure": "gate.failure";
629
+ "node.start": "node.start";
630
+ "node.success": "node.success";
631
+ "workflow.complete": "workflow.complete";
632
+ "workflow.failure": "workflow.failure";
633
+ "workflow.start": "workflow.start";
634
+ "workflow.success": "workflow.success";
635
635
  }> & z.core.$partial, z.ZodDiscriminatedUnion<[z.ZodObject<{
636
636
  failure: z.ZodDefault<z.ZodEnum<{
637
637
  fail: "fail";
@@ -1,8 +1,12 @@
1
+ import { claudeGlobalConfigDir, codexGlobalConfigDir, opencodeGlobalConfigDir } from "./install-commands/shared.js";
1
2
  import { AGENT_SKILL_SOURCE } from "./agent-assets.js";
2
3
  import { installCommands } from "./install-commands.js";
3
4
  import { installHooks } from "./install-hooks.js";
4
5
  import { installRules } from "./install-rules.js";
5
6
  import { execa } from "execa";
7
+ import { homedir } from "node:os";
8
+ import { join } from "node:path";
9
+ import { rm } from "node:fs/promises";
6
10
  //#region src/pipeline-init.ts
7
11
  const DEFAULT_SKILL_INSTALL_SOURCE = AGENT_SKILL_SOURCE;
8
12
  const SKILL_INSTALL_AGENT_ARGS = [
@@ -17,8 +21,47 @@ const SKILL_INSTALL_AGENT_ARGS = [
17
21
  "--yes",
18
22
  "--global"
19
23
  ];
24
+ /**
25
+ * Every global location the `skills` CLI writes into for the three agents we
26
+ * manage. The CLI copies each skill's real folder once into the shared master
27
+ * store `~/.agents/skills` and points each agent's global skills dir at it via
28
+ * symlinks, recording install state in `~/.agents/.skill-lock.json` (or
29
+ * `$XDG_STATE_HOME/skills/.skill-lock.json`). Each entry below mirrors that
30
+ * resolution from the skills CLI source (skills `dist/cli.mjs`): per-agent
31
+ * config dirs honor `CLAUDE_CONFIG_DIR` / `CODEX_HOME` /
32
+ * `OPENCODE_CONFIG_DIR`+`XDG_CONFIG_HOME` (reused from install-commands so the
33
+ * test suite's env redirect isolates them), the master store and lock honor
34
+ * the home dir and `XDG_STATE_HOME`.
35
+ */
36
+ function globalSkillCleanTargets() {
37
+ const agentsHome = homedir();
38
+ const skillLockPath = process.env.XDG_STATE_HOME ? join(process.env.XDG_STATE_HOME, "skills", ".skill-lock.json") : join(agentsHome, ".agents", ".skill-lock.json");
39
+ return [
40
+ join(claudeGlobalConfigDir(), "skills"),
41
+ join(codexGlobalConfigDir(), "skills"),
42
+ join(opencodeGlobalConfigDir(), "skills"),
43
+ join(agentsHome, ".agents", "skills"),
44
+ skillLockPath
45
+ ];
46
+ }
47
+ /**
48
+ * Clean-replace step run before the additive `skills add`. `npx skills add`
49
+ * only ever adds, so without this a renamed, removed, or foreign global skill
50
+ * accumulates forever across `moka init` runs. Removing the per-agent symlink
51
+ * farms + shared master store + lock resets global skill state so the post-add
52
+ * set equals exactly the canonical `oisin-ee/agent` source. Safe when absent
53
+ * (rm force); only `skills` subdirs, the master store, and the lock are
54
+ * touched — never a whole host config dir.
55
+ */
56
+ async function cleanGlobalSkills() {
57
+ await Promise.all(globalSkillCleanTargets().map((target) => rm(target, {
58
+ force: true,
59
+ recursive: true
60
+ })));
61
+ }
20
62
  async function installDefaultSkills(cwd) {
21
63
  try {
64
+ await cleanGlobalSkills();
22
65
  await execa("npx", [
23
66
  "--yes",
24
67
  "skills",