catenext 0.1.2 → 0.2.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/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { createInterface } from "node:readline";
7
7
  import { fileURLToPath } from "node:url";
8
8
 
9
9
  // shared/src/api.ts
10
- import { z as z4 } from "zod";
10
+ import { z as z5 } from "zod";
11
11
 
12
12
  // shared/src/common.ts
13
13
  import { z } from "zod";
@@ -25,11 +25,78 @@ function countWords(text2) {
25
25
  return trimmed === "" ? 0 : trimmed.split(/\s+/).length;
26
26
  }
27
27
 
28
+ // shared/src/review.ts
29
+ import { z as z2 } from "zod";
30
+ var CommitShaSchema = z2.string().regex(/^[0-9a-f]{40}$/);
31
+ var PullRequestUrlSchema = z2.string().max(240).regex(
32
+ /^https:\/\/github\.com\/[a-z\d][a-z\d-]*\/[a-z\d_.-]+\/pull\/[1-9]\d*$/i,
33
+ "Gunakan URL pull request GitHub."
34
+ );
35
+ var PullRequestRefSchema = z2.object({
36
+ url: PullRequestUrlSchema,
37
+ base_branch: z2.string().min(1).max(255),
38
+ head_sha: CommitShaSchema
39
+ });
40
+ var REVIEW_STAGES = [
41
+ "draft",
42
+ "awaiting_review",
43
+ "in_review",
44
+ "changes_requested",
45
+ "revising",
46
+ "awaiting_human_approval",
47
+ "approved_awaiting_merge",
48
+ "closed_without_merge",
49
+ "merged"
50
+ ];
51
+ var ReviewStageSchema = z2.enum(REVIEW_STAGES);
52
+ var PullRequestStateSchema = PullRequestRefSchema.extend({
53
+ stage: ReviewStageSchema,
54
+ checked_at: z2.iso.datetime(),
55
+ reviewer: z2.string().nullable(),
56
+ merge_sha: CommitShaSchema.nullable()
57
+ });
58
+ var ReviewInput = z2.discriminatedUnion("action", [
59
+ z2.object({ action: z2.literal("list"), limit: z2.number().int().min(1).max(30).default(10) }),
60
+ z2.object({
61
+ action: z2.literal("claim"),
62
+ task_id: IdSchema,
63
+ agent_alias: z2.string().min(1).max(80).optional()
64
+ }),
65
+ z2.object({ action: z2.literal("refresh"), task_id: IdSchema }),
66
+ z2.object({
67
+ action: z2.literal("submit"),
68
+ task_id: IdSchema,
69
+ lease_id: IdSchema,
70
+ head_sha: CommitShaSchema,
71
+ decision: z2.enum(["approve", "request_changes"]),
72
+ feedback: z2.string().trim().min(1).max(1e3)
73
+ })
74
+ ]);
75
+ var ReviewEntrySchema = z2.object({
76
+ task_id: IdSchema,
77
+ title: z2.string(),
78
+ status: z2.enum(["NEEDS_REVIEW", "REVISION_REQUESTED", "DONE"]),
79
+ review: PullRequestStateSchema
80
+ });
81
+ var ReviewOutput = z2.union([
82
+ z2.object({ reviews: z2.array(ReviewEntrySchema) }),
83
+ ReviewEntrySchema.extend({
84
+ lease_id: IdSchema.optional(),
85
+ lease_expires_at: z2.iso.datetime().optional(),
86
+ notes_for_next_agent: z2.string().optional(),
87
+ warning: z2.string().optional()
88
+ })
89
+ ]);
90
+ var HumanReviewInput = z2.discriminatedUnion("action", [
91
+ z2.object({ action: z2.literal("refresh") }),
92
+ z2.object({ action: z2.literal("approve"), head_sha: CommitShaSchema })
93
+ ]);
94
+
28
95
  // shared/src/task.ts
29
- import { z as z3 } from "zod";
96
+ import { z as z4 } from "zod";
30
97
 
31
98
  // shared/src/handoff.ts
32
- import { z as z2 } from "zod";
99
+ import { z as z3 } from "zod";
33
100
  var HANDOFF_LIMITS = {
34
101
  maxFilesModified: 15,
35
102
  maxPathLength: 200,
@@ -40,15 +107,18 @@ var HANDOFF_LIMITS = {
40
107
  maxTokens: 600
41
108
  };
42
109
  var CODE_FENCE = /```/;
43
- var FilePathSchema = z2.string().min(1).max(HANDOFF_LIMITS.maxPathLength).regex(/^[^\s]+$/, "Path file tidak boleh berisi spasi atau baris baru (tanpa potongan kode)");
44
- var NoCodeText = (max) => z2.string().min(1).max(max).refine((s) => !CODE_FENCE.test(s), "Jangan menempelkan blok kode; cukup rujuk path file");
45
- var HandoffSummarySchema = z2.object({
46
- files_modified: z2.array(FilePathSchema).max(HANDOFF_LIMITS.maxFilesModified),
47
- key_decisions: z2.array(NoCodeText(HANDOFF_LIMITS.maxKeyDecisionLength)).max(HANDOFF_LIMITS.maxKeyDecisions),
48
- verification_command: z2.string().min(1).max(HANDOFF_LIMITS.maxVerificationCommandLength).nullable(),
110
+ var FilePathSchema = z3.string().min(1).max(HANDOFF_LIMITS.maxPathLength).regex(/^[^\s]+$/, "Path file tidak boleh berisi spasi atau baris baru (tanpa potongan kode)");
111
+ var NoCodeText = (max) => z3.string().min(1).max(max).refine((s) => !CODE_FENCE.test(s), "Jangan menempelkan blok kode; cukup rujuk path file");
112
+ var HandoffSummarySchema = z3.object({
113
+ files_modified: z3.array(FilePathSchema).max(HANDOFF_LIMITS.maxFilesModified),
114
+ key_decisions: z3.array(NoCodeText(HANDOFF_LIMITS.maxKeyDecisionLength)).max(HANDOFF_LIMITS.maxKeyDecisions),
115
+ verification_command: z3.string().min(1).max(HANDOFF_LIMITS.maxVerificationCommandLength).nullable(),
49
116
  notes_for_next_agent: NoCodeText(HANDOFF_LIMITS.maxNotesLength),
50
- git_branch: z2.string().min(1).max(255),
51
- last_commit_hash: z2.string().regex(/^[0-9a-f]{7,64}$/, "Hash commit git (hex, 7\u201364 karakter)")
117
+ pull_request: PullRequestRefSchema.optional(),
118
+ git_branch: z3.string().min(1).max(255),
119
+ last_commit_hash: z3.string().regex(/^[0-9a-f]{7,64}$/, "Hash commit git (hex, 7\u201364 karakter)")
120
+ }).refine((h) => !h.pull_request || h.last_commit_hash === h.pull_request.head_sha, {
121
+ message: "SHA handoff harus sama dengan head SHA PR."
52
122
  }).refine((h) => estimateHandoffTokens(h) <= HANDOFF_LIMITS.maxTokens, {
53
123
  message: `Ringkasan handoff melebihi ~${HANDOFF_LIMITS.maxTokens} token; ringkas lagi`
54
124
  });
@@ -66,7 +136,7 @@ var TASK_STATUSES = [
66
136
  "BLOCKED",
67
137
  "DONE"
68
138
  ];
69
- var TaskStatusSchema = z3.enum(TASK_STATUSES);
139
+ var TaskStatusSchema = z4.enum(TASK_STATUSES);
70
140
  var KANBAN_STATUSES = TASK_STATUSES.filter(
71
141
  (s) => s !== "DRAFT"
72
142
  );
@@ -92,41 +162,45 @@ var TASK_EVENTS = [
92
162
  "unblock"
93
163
  // human: BLOCKED -> TODO
94
164
  ];
95
- var TaskEventSchema = z3.enum(TASK_EVENTS);
165
+ var TaskEventSchema = z4.enum(TASK_EVENTS);
96
166
  var LOCK_LEASE_MS = 30 * 60 * 1e3;
97
- var TaskSchema = z3.object({
167
+ var TaskSchema = z4.object({
98
168
  id: IdSchema,
99
169
  /** Diduplikasi dari project agar kebijakan RLS cukup `workspace_id = current_setting(...)`. */
100
170
  workspace_id: IdSchema,
101
171
  project_id: IdSchema,
102
172
  epic_id: IdSchema,
103
- title: z3.string().min(1).max(200),
104
- prompt_instruction: z3.string().min(1).max(8e3),
173
+ title: z4.string().min(1).max(200),
174
+ prompt_instruction: z4.string().min(1).max(8e3),
105
175
  status: TaskStatusSchema,
106
- requires_approval: z3.boolean().default(false),
176
+ requires_approval: z4.boolean().default(false),
107
177
  target_repo: RepoNameSchema.nullable(),
108
178
  role: RoleSchema.nullable(),
179
+ /** Persona penanggung jawab. Bila diisi, hanya agen dengan alias persona ini yang boleh mengambilnya. */
180
+ persona_id: IdSchema.nullable(),
109
181
  assignee_id: IdSchema.nullable(),
110
- locked_by: z3.string().max(200).nullable(),
182
+ locked_by: z4.string().max(200).nullable(),
111
183
  locked_at: IsoDateTimeSchema.nullable(),
112
184
  lease_expires_at: IsoDateTimeSchema.nullable(),
113
185
  handoff_summary: HandoffSummarySchema.nullable(),
114
- review_feedback: z3.string().max(2e3).nullable(),
115
- revision_count: z3.number().int().min(0).default(0),
116
- blocker_reason: z3.string().max(1e3).nullable(),
186
+ review_feedback: z4.string().max(2e3).nullable(),
187
+ revision_count: z4.number().int().min(0).default(0),
188
+ blocker_reason: z4.string().max(1e3).nullable(),
117
189
  /** Ditandai bila dependensi hulu dibuka ulang setelah task ini berjalan. */
118
- is_stale: z3.boolean().default(false),
119
- depends_on: z3.array(IdSchema).default([]),
190
+ is_stale: z4.boolean().default(false),
191
+ depends_on: z4.array(IdSchema).default([]),
120
192
  created_at: IsoDateTimeSchema,
121
193
  updated_at: IsoDateTimeSchema
122
194
  });
123
- var TaskSummarySchema = z3.object({
195
+ var TaskSummarySchema = z4.object({
124
196
  id: IdSchema,
125
- title: z3.string().min(1).max(200),
126
- depends_on: z3.array(IdSchema),
197
+ title: z4.string().min(1).max(200),
198
+ depends_on: z4.array(IdSchema),
127
199
  role: RoleSchema.optional(),
200
+ /** Alias persona penanggung jawab. */
201
+ persona: AgentAliasSchema.optional(),
128
202
  target_repo: RepoNameSchema.optional(),
129
- revision: z3.boolean().optional()
203
+ revision: z4.boolean().optional()
130
204
  });
131
205
  var BLOCKER_CATEGORIES = [
132
206
  "missing_env",
@@ -135,144 +209,157 @@ var BLOCKER_CATEGORIES = [
135
209
  "dependency_issue",
136
210
  "other"
137
211
  ];
138
- var BlockerCategorySchema = z3.enum(BLOCKER_CATEGORIES);
212
+ var BlockerCategorySchema = z4.enum(BLOCKER_CATEGORIES);
139
213
 
140
214
  // shared/src/api.ts
141
- var WorkspaceSchema = z4.object({
215
+ var WorkspaceSchema = z5.object({
142
216
  id: IdSchema,
143
- name: z4.string(),
144
- slug: z4.string(),
145
- role: z4.string()
217
+ name: z5.string(),
218
+ slug: z5.string(),
219
+ role: z5.string()
146
220
  });
147
- var ProjectSchema = z4.object({
221
+ var ProjectSchema = z5.object({
148
222
  id: IdSchema,
149
223
  workspace_id: IdSchema,
150
- name: z4.string().min(1).max(120),
151
- detected_stack: z4.array(z4.string()),
224
+ name: z5.string().min(1).max(120),
225
+ detected_stack: z5.array(z5.string()),
152
226
  agent_connected_at: IsoDateTimeSchema.nullable(),
153
227
  created_at: IsoDateTimeSchema,
154
228
  updated_at: IsoDateTimeSchema
155
229
  });
156
- var EpicSchema = z4.object({
230
+ var EpicSchema = z5.object({
157
231
  id: IdSchema,
158
232
  workspace_id: IdSchema,
159
233
  project_id: IdSchema,
160
- title: z4.string().min(1).max(200),
161
- description: z4.string().max(4e3).nullable(),
162
- template_used: z4.string().max(80).nullable(),
234
+ title: z5.string().min(1).max(200),
235
+ description: z5.string().max(4e3).nullable(),
236
+ template_used: z5.string().max(80).nullable(),
163
237
  created_at: IsoDateTimeSchema,
164
238
  updated_at: IsoDateTimeSchema
165
239
  });
166
240
  var TaskDtoSchema = TaskSchema.extend({
167
- position: z4.number(),
241
+ pull_request: PullRequestStateSchema.nullable().optional(),
242
+ worktree_branch: z5.string().nullable().optional(),
243
+ position: z5.number(),
168
244
  lock_repo: RepoNameSchema.nullable(),
169
245
  blocker_category: BlockerCategorySchema.nullable(),
170
246
  /** Dependensi yang belum DONE. Kosong = tidak tertahan dependensi. */
171
- blocked_by: z4.array(IdSchema),
247
+ blocked_by: z5.array(IdSchema),
172
248
  /** TODO/REVISION_REQUESTED dan semua dependensinya DONE: bisa diklaim agen sekarang. */
173
- is_ready: z4.boolean()
249
+ is_ready: z5.boolean()
174
250
  });
175
- var AgentPersonaSchema = z4.object({
251
+ var AgentPersonaSchema = z5.object({
176
252
  id: IdSchema,
177
253
  workspace_id: IdSchema,
178
254
  project_id: IdSchema.nullable(),
179
255
  alias: AgentAliasSchema,
180
256
  role: RoleSchema,
181
- rules: z4.array(z4.string()),
257
+ rules: z5.array(z5.string()),
182
258
  created_at: IsoDateTimeSchema,
183
259
  updated_at: IsoDateTimeSchema
184
260
  });
185
- var ApiKeySchema = z4.object({
261
+ var ApiKeySchema = z5.object({
186
262
  id: IdSchema,
187
263
  workspace_id: IdSchema,
188
264
  project_id: IdSchema.nullable(),
189
- name: z4.string(),
190
- prefix: z4.string(),
265
+ name: z5.string(),
266
+ prefix: z5.string(),
191
267
  last_used_at: IsoDateTimeSchema.nullable(),
192
268
  revoked_at: IsoDateTimeSchema.nullable(),
193
269
  created_at: IsoDateTimeSchema
194
270
  });
195
271
  var ACTIVITY_ACTORS = ["human", "agent", "system"];
196
- var ActivityLogSchema = z4.object({
272
+ var ActivityLogSchema = z5.object({
197
273
  id: IdSchema,
198
274
  workspace_id: IdSchema,
199
275
  project_id: IdSchema.nullable(),
200
276
  task_id: IdSchema.nullable(),
201
- event_type: z4.string(),
202
- actor: z4.enum(ACTIVITY_ACTORS),
203
- persona_alias: z4.string().nullable(),
277
+ event_type: z5.string(),
278
+ actor: z5.enum(ACTIVITY_ACTORS),
279
+ persona_alias: z5.string().nullable(),
204
280
  /** Nama agen + repo untuk event agen (mis. `claude-code@web`), null untuk manusia/sistem. */
205
- agent_name: z4.string().nullable(),
206
- duration_ms: z4.number().int().nullable(),
207
- metadata: z4.record(z4.string(), z4.unknown()).nullable(),
281
+ agent_name: z5.string().nullable(),
282
+ duration_ms: z5.number().int().nullable(),
283
+ metadata: z5.record(z5.string(), z5.unknown()).nullable(),
208
284
  created_at: IsoDateTimeSchema
209
285
  });
210
- var ProjectMetricsSchema = z4.object({
211
- handoffs_7d: z4.number().int(),
212
- revisions_7d: z4.number().int(),
213
- blockers_7d: z4.number().int(),
214
- avg_task_duration_ms: z4.number().int().nullable()
286
+ var ProjectMetricsSchema = z5.object({
287
+ handoffs_7d: z5.number().int(),
288
+ revisions_7d: z5.number().int(),
289
+ blockers_7d: z5.number().int(),
290
+ avg_task_duration_ms: z5.number().int().nullable()
291
+ });
292
+ var CreateProjectInput = z5.object({
293
+ name: z5.string().trim().min(1).max(120),
294
+ detected_stack: z5.array(z5.string().min(1).max(40)).max(20).default([])
215
295
  });
216
- var CreateProjectInput = z4.object({
217
- name: z4.string().trim().min(1).max(120),
218
- detected_stack: z4.array(z4.string().min(1).max(40)).max(20).default([])
296
+ var UpdateProjectInput = z5.object({
297
+ name: z5.string().trim().min(1).max(120).optional(),
298
+ detected_stack: z5.array(z5.string().min(1).max(40)).max(20).optional()
219
299
  });
220
- var UpdateProjectInput = CreateProjectInput.partial();
221
- var CreateEpicInput = z4.object({
222
- title: z4.string().trim().min(1).max(200),
223
- description: z4.string().max(4e3).nullish(),
224
- template_used: z4.string().max(80).nullish()
300
+ var CreateEpicInput = z5.object({
301
+ title: z5.string().trim().min(1).max(200),
302
+ description: z5.string().max(4e3).nullish(),
303
+ template_used: z5.string().max(80).nullish()
225
304
  });
226
305
  var UpdateEpicInput = CreateEpicInput.partial();
227
- var CreateTaskInput = z4.object({
228
- title: z4.string().trim().min(1).max(200),
229
- prompt_instruction: z4.string().min(1).max(8e3),
306
+ var CreateTaskInput = z5.object({
307
+ title: z5.string().trim().min(1).max(200),
308
+ prompt_instruction: z5.string().min(1).max(8e3),
230
309
  target_repo: RepoNameSchema.nullish(),
231
310
  role: RoleSchema.nullish(),
232
- requires_approval: z4.boolean().default(false),
233
- depends_on: z4.array(IdSchema).max(10).default([]),
311
+ /** Persona penanggung jawab; role task otomatis mengikuti role persona. */
312
+ persona_id: IdSchema.nullish(),
313
+ requires_approval: z5.boolean().default(false),
314
+ depends_on: z5.array(IdSchema).max(10).default([]),
234
315
  /** Task buatan manusia langsung TODO; DRAFT bila ingin ditinjau bersama rencana agen. */
235
- status: z4.enum(["DRAFT", "TODO"]).default("TODO")
316
+ status: z5.enum(["DRAFT", "TODO"]).default("TODO")
236
317
  });
237
- var UpdateTaskInput = z4.object({
238
- title: z4.string().trim().min(1).max(200).optional(),
239
- prompt_instruction: z4.string().min(1).max(8e3).optional(),
318
+ var UpdateTaskInput = z5.object({
319
+ title: z5.string().trim().min(1).max(200).optional(),
320
+ prompt_instruction: z5.string().min(1).max(8e3).optional(),
240
321
  target_repo: RepoNameSchema.nullable().optional(),
241
322
  role: RoleSchema.nullable().optional(),
242
- requires_approval: z4.boolean().optional(),
323
+ persona_id: IdSchema.nullable().optional(),
324
+ requires_approval: z5.boolean().optional(),
243
325
  assignee_id: IdSchema.nullable().optional(),
244
- position: z4.number().finite().optional(),
326
+ position: z5.number().finite().optional(),
245
327
  /** Hanya boleh false: manusia menandai task stale sudah diperiksa ulang. */
246
- is_stale: z4.literal(false).optional()
247
- });
248
- var SetDependenciesInput = z4.object({
249
- depends_on: z4.array(IdSchema).max(10)
250
- });
251
- var TaskActionInput = z4.discriminatedUnion("event", [
252
- z4.object({ event: z4.literal("approve_plan") }),
253
- z4.object({ event: z4.literal("return_to_draft") }),
254
- z4.object({ event: z4.literal("approve") }),
255
- z4.object({
256
- event: z4.literal("request_revision"),
257
- feedback: z4.string().trim().min(5).max(2e3)
328
+ is_stale: z5.literal(false).optional()
329
+ });
330
+ var SetDependenciesInput = z5.object({
331
+ depends_on: z5.array(IdSchema).max(10)
332
+ });
333
+ var TaskActionInput = z5.discriminatedUnion("event", [
334
+ z5.object({ event: z5.literal("approve_plan") }),
335
+ z5.object({ event: z5.literal("return_to_draft") }),
336
+ z5.object({ event: z5.literal("approve") }),
337
+ z5.object({
338
+ event: z5.literal("request_revision"),
339
+ feedback: z5.string().trim().min(5).max(2e3)
258
340
  }),
259
- z4.object({ event: z4.literal("unblock") })
341
+ z5.object({ event: z5.literal("unblock") })
260
342
  ]);
261
- var PersonaInput = z4.object({
343
+ var PersonaInput = z5.object({
262
344
  alias: AgentAliasSchema,
263
345
  role: RoleSchema,
264
- rules: z4.array(z4.string().trim().min(1).max(300)).max(30).default([]),
346
+ rules: z5.array(z5.string().trim().min(1).max(300)).max(30).default([]),
265
347
  project_id: IdSchema.nullish()
266
348
  });
267
- var UpdatePersonaInput = PersonaInput.partial();
268
- var CreateApiKeyInput = z4.object({
269
- name: z4.string().trim().min(1).max(80),
349
+ var UpdatePersonaInput = z5.object({
350
+ alias: AgentAliasSchema.optional(),
351
+ role: RoleSchema.optional(),
352
+ rules: z5.array(z5.string().trim().min(1).max(300)).max(30).optional(),
270
353
  project_id: IdSchema.nullish()
271
354
  });
272
- var CreateApiKeyOutput = z4.object({
355
+ var CreateApiKeyInput = z5.object({
356
+ name: z5.string().trim().min(1).max(80),
357
+ project_id: IdSchema.nullish()
358
+ });
359
+ var CreateApiKeyOutput = z5.object({
273
360
  api_key: ApiKeySchema,
274
361
  /** Kunci mentah. Hanya dikirim sekali, saat dibuat. */
275
- secret: z4.string()
362
+ secret: z5.string()
276
363
  });
277
364
  var AGENT_HEADERS = {
278
365
  project: "x-catenext-project",
@@ -280,43 +367,45 @@ var AGENT_HEADERS = {
280
367
  agent: "x-catenext-agent"
281
368
  };
282
369
  var API_KEY_PREFIX = "ctnx_";
283
- var ReleaseTaskInput = z4.object({ task_id: IdSchema });
284
- var SyncSkillsInput = z4.object({
285
- skills: z4.array(
286
- z4.object({
287
- name: z4.string().min(1).max(48),
288
- when_to_use: z4.string().min(1).max(160)
370
+ var ReleaseTaskInput = z5.object({ task_id: IdSchema, lease_id: IdSchema.optional() });
371
+ var SyncSkillsInput = z5.object({
372
+ revision: CommitShaSchema.optional(),
373
+ previous_revision: CommitShaSchema.nullable().optional(),
374
+ skills: z5.array(
375
+ z5.object({
376
+ name: z5.string().min(1).max(48),
377
+ when_to_use: z5.string().min(1).max(160)
289
378
  })
290
379
  ).max(100)
291
380
  });
292
- var VerifyOutput = z4.object({
293
- token_valid: z4.literal(true),
381
+ var VerifyOutput = z5.object({
382
+ token_valid: z5.literal(true),
294
383
  workspace_id: IdSchema,
295
- project: z4.object({ id: IdSchema, name: z4.string() }),
384
+ project: z5.object({ id: IdSchema, name: z5.string() }),
296
385
  repo_name: RepoNameSchema
297
386
  });
298
- var ApiErrorSchema = z4.object({
299
- error: z4.object({
300
- code: z4.string(),
301
- message: z4.string(),
302
- details: z4.unknown().optional()
387
+ var ApiErrorSchema = z5.object({
388
+ error: z5.object({
389
+ code: z5.string(),
390
+ message: z5.string(),
391
+ details: z5.unknown().optional()
303
392
  })
304
393
  });
305
394
 
306
395
  // shared/src/config.ts
307
- import { z as z5 } from "zod";
396
+ import { z as z6 } from "zod";
308
397
  var CONFIG_SCHEMA_VERSION = 1;
309
- var CatenextConfigSchema = z5.object({
310
- schema_version: z5.number().int().positive(),
398
+ var CatenextConfigSchema = z6.object({
399
+ schema_version: z6.number().int().positive(),
311
400
  project_id: IdSchema,
312
401
  repo_name: RepoNameSchema,
313
- stack: z5.array(z5.string().min(1).max(40)).max(20).default([]),
402
+ stack: z6.array(z6.string().min(1).max(40)).max(20).default([]),
314
403
  /** URL Catenext Cloud API; kosong = default bawaan CLI. */
315
- api_url: z5.url().optional(),
316
- overrides: z5.object({
404
+ api_url: z6.url().optional(),
405
+ overrides: z6.object({
317
406
  default_agent_alias: AgentAliasSchema.optional(),
318
407
  default_role: RoleSchema.optional(),
319
- extra_rules: z5.array(z5.string().min(1).max(300)).max(20).optional()
408
+ extra_rules: z6.array(z6.string().min(1).max(300)).max(20).optional()
320
409
  }).optional()
321
410
  });
322
411
  function checkConfigCompatibility(schemaVersion, supported = CONFIG_SCHEMA_VERSION) {
@@ -378,50 +467,50 @@ function findCycle(edges) {
378
467
  }
379
468
 
380
469
  // shared/src/device.ts
381
- import { z as z6 } from "zod";
382
- var UserCodeSchema = z6.string().trim().toUpperCase().regex(/^[A-Z2-9]{4}-?[A-Z2-9]{4}$/, "Kode harus 8 karakter, mis. ABCD-EFGH").transform((s) => s.includes("-") ? s : `${s.slice(0, 4)}-${s.slice(4)}`);
383
- var DeviceCodeInput = z6.object({
470
+ import { z as z7 } from "zod";
471
+ var UserCodeSchema = z7.string().trim().toUpperCase().regex(/^[A-Z2-9]{4}-?[A-Z2-9]{4}$/, "Kode harus 8 karakter, mis. ABCD-EFGH").transform((s) => s.includes("-") ? s : `${s.slice(0, 4)}-${s.slice(4)}`);
472
+ var DeviceCodeInput = z7.object({
384
473
  /** Nama mesin/klien yang ditampilkan saat menyetujui, mis. "catenext CLI @ macbook". */
385
- client_name: z6.string().trim().min(1).max(80),
474
+ client_name: z7.string().trim().min(1).max(80),
386
475
  /**
387
476
  * Public key X25519 sementara milik CLI (SPKI DER, base64url). API key hasil persetujuan
388
477
  * dienkripsi ke kunci ini, jadi baris database saja tidak cukup untuk membacanya.
389
478
  */
390
- public_key: z6.string().min(40).max(200)
391
- });
392
- var DeviceCodeOutput = z6.object({
393
- device_code: z6.string(),
394
- user_code: z6.string(),
395
- verification_uri: z6.string(),
396
- verification_uri_complete: z6.string(),
397
- expires_in: z6.number().int(),
398
- interval: z6.number().int()
399
- });
400
- var DeviceTokenInput = z6.object({ device_code: z6.string().min(20).max(200) });
401
- var DeviceTokenOutput = z6.object({
479
+ public_key: z7.string().min(40).max(200)
480
+ });
481
+ var DeviceCodeOutput = z7.object({
482
+ device_code: z7.string(),
483
+ user_code: z7.string(),
484
+ verification_uri: z7.string(),
485
+ verification_uri_complete: z7.string(),
486
+ expires_in: z7.number().int(),
487
+ interval: z7.number().int()
488
+ });
489
+ var DeviceTokenInput = z7.object({ device_code: z7.string().min(20).max(200) });
490
+ var DeviceTokenOutput = z7.object({
402
491
  /** API key terenkripsi ke public_key CLI: <pub efemeral>.<iv>.<tag>.<ciphertext> (base64url). */
403
- encrypted_key: z6.string(),
492
+ encrypted_key: z7.string(),
404
493
  workspace_id: IdSchema,
405
494
  project_id: IdSchema.nullable()
406
495
  });
407
- var DeviceLookupOutput = z6.object({
408
- user_code: z6.string(),
409
- client_name: z6.string(),
410
- status: z6.enum(["pending", "approved", "denied"]),
411
- expires_at: z6.string()
496
+ var DeviceLookupOutput = z7.object({
497
+ user_code: z7.string(),
498
+ client_name: z7.string(),
499
+ status: z7.enum(["pending", "approved", "denied"]),
500
+ expires_at: z7.string()
412
501
  });
413
- var DeviceApproveInput = z6.object({
502
+ var DeviceApproveInput = z7.object({
414
503
  user_code: UserCodeSchema,
415
- approve: z6.boolean(),
504
+ approve: z7.boolean(),
416
505
  /** Batasi API key ke satu proyek (disarankan). null = semua proyek di workspace. */
417
506
  project_id: IdSchema.nullish()
418
507
  });
419
508
 
420
509
  // shared/src/mcp-tools.ts
421
- import { z as z8 } from "zod";
510
+ import { z as z9 } from "zod";
422
511
 
423
512
  // shared/src/skill.ts
424
- import { z as z7 } from "zod";
513
+ import { z as z8 } from "zod";
425
514
  var SKILL_LIMITS = {
426
515
  maxWords: 500,
427
516
  maxWhenToUseLength: 160,
@@ -429,9 +518,9 @@ var SKILL_LIMITS = {
429
518
  maxCodeBlockLines: 15
430
519
  };
431
520
  var SkillNameSchema = SlugSchema.max(48);
432
- var SkillFrontmatterSchema = z7.object({
521
+ var SkillFrontmatterSchema = z8.object({
433
522
  name: SkillNameSchema,
434
- when_to_use: z7.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
523
+ when_to_use: z8.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
435
524
  updated_at: IsoDateTimeSchema
436
525
  });
437
526
  function longestCodeBlockLines(markdown) {
@@ -443,117 +532,136 @@ function longestCodeBlockLines(markdown) {
443
532
  }
444
533
  return longest;
445
534
  }
446
- var SkillContentSchema = z7.string().min(1).refine((s) => countWords(s) <= SKILL_LIMITS.maxWords, {
535
+ var SkillContentSchema = z8.string().min(1).refine((s) => countWords(s) <= SKILL_LIMITS.maxWords, {
447
536
  message: `Skill maksimal ${SKILL_LIMITS.maxWords} kata`
448
537
  }).refine((s) => longestCodeBlockLines(s) <= SKILL_LIMITS.maxCodeBlockLines, {
449
538
  message: `Blok kode maksimal ${SKILL_LIMITS.maxCodeBlockLines} baris; rujuk path file, jangan menyalin kode`
450
539
  });
451
- var SkillIndexEntrySchema = z7.object({
540
+ var SkillIndexEntrySchema = z8.object({
452
541
  name: SkillNameSchema,
453
- when_to_use: z7.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
542
+ when_to_use: z8.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
454
543
  repo_name: RepoNameSchema
455
544
  });
545
+ function skillPath(name) {
546
+ return `.catenext/skills/${SkillNameSchema.parse(name)}.md`;
547
+ }
456
548
 
457
549
  // shared/src/mcp-tools.ts
458
550
  var PersonaFilter = {
459
551
  agent_alias: AgentAliasSchema.optional(),
460
552
  role: RoleSchema.optional()
461
553
  };
462
- var PersonaSchema = z8.object({
554
+ var PersonaSchema = z9.object({
463
555
  alias: AgentAliasSchema,
464
556
  role: RoleSchema,
465
- rules: z8.array(z8.string().min(1).max(300)).max(30)
557
+ rules: z9.array(z9.string().min(1).max(300)).max(30)
466
558
  });
467
- var DependencyHandoffSchema = z8.object({
559
+ var DependencyHandoffSchema = z9.object({
468
560
  task_id: IdSchema,
469
- title: z8.string(),
470
- handoff_summary: HandoffSummarySchema
561
+ title: z9.string(),
562
+ handoff_summary: HandoffSummarySchema,
563
+ integrated_commit: z9.object({ branch: z9.string(), sha: CommitShaSchema }).optional()
471
564
  });
472
- var GetProjectContextInput = z8.object(PersonaFilter);
473
- var GetProjectContextOutput = z8.object({
474
- project: z8.object({
565
+ var GetProjectContextInput = z9.object({ ...PersonaFilter, lease_id: IdSchema.optional() });
566
+ var GetProjectContextOutput = z9.object({
567
+ project: z9.object({
475
568
  id: IdSchema,
476
- name: z8.string(),
569
+ name: z9.string(),
477
570
  repo_name: RepoNameSchema,
478
- stack: z8.array(z8.string())
571
+ stack: z9.array(z9.string())
479
572
  }),
480
573
  /** Aturan keras untuk agen (mis. jangan mengedit config MCP). Statis di atas agar ramah cache. */
481
- directives: z8.array(z8.string()),
574
+ directives: z9.array(z9.string()),
482
575
  persona: PersonaSchema.optional(),
483
- epic_summary: z8.string().max(1e3).optional(),
576
+ epic_summary: z9.string().max(1e3).optional(),
484
577
  /** Tier 1: indeks skill saja, isi lengkap lewat load_skill. */
485
- skills: z8.array(SkillIndexEntrySchema),
578
+ skills: z9.array(SkillIndexEntrySchema),
579
+ skill_revision: CommitShaSchema.optional(),
486
580
  /**
487
581
  * Handoff dari dependensi langsung task aktif (dependency-scoped context). Jika belum ada
488
582
  * task aktif: handoff dependensi task yang siap diklaim (maks. 5).
489
583
  */
490
- recent_handoffs: z8.array(DependencyHandoffSchema)
584
+ recent_handoffs: z9.array(DependencyHandoffSchema)
491
585
  });
492
- var GetReadyTasksInput = z8.object({
586
+ var GetReadyTasksInput = z9.object({
493
587
  ...PersonaFilter,
494
- limit: z8.number().int().min(1).max(50).default(10)
588
+ lease_id: IdSchema.optional(),
589
+ limit: z9.number().int().min(1).max(50).default(10)
495
590
  });
496
- var GetReadyTasksOutput = z8.object({
497
- tasks: z8.array(TaskSummarySchema)
591
+ var GetReadyTasksOutput = z9.object({
592
+ tasks: z9.array(TaskSummarySchema)
498
593
  });
499
- var ClaimTaskInput = z8.object({
500
- task_id: IdSchema
594
+ var ClaimTaskInput = z9.object({
595
+ worktree: z9.object({
596
+ session_id: IdSchema,
597
+ branch: z9.string().min(1).max(255).regex(/^[a-zA-Z0-9_./-]+$/).refine((s) => s !== "HEAD" && !s.startsWith("-") && !s.includes(".."))
598
+ }).optional(),
599
+ task_id: IdSchema,
600
+ /** Alias persona yang sedang dipakai agen. Task milik persona lain ditolak. */
601
+ agent_alias: AgentAliasSchema.optional()
501
602
  });
502
- var ClaimTaskOutput = z8.object({
503
- task: z8.object({
603
+ var ClaimTaskOutput = z9.object({
604
+ task: z9.object({
504
605
  id: IdSchema,
505
- title: z8.string(),
506
- prompt_instruction: z8.string(),
507
- status: z8.literal("IN_PROGRESS"),
606
+ title: z9.string(),
607
+ prompt_instruction: z9.string(),
608
+ status: z9.literal("IN_PROGRESS"),
508
609
  role: RoleSchema.optional(),
509
610
  target_repo: RepoNameSchema.optional(),
510
- revision_count: z8.number().int().min(0)
611
+ revision_count: z9.number().int().min(0)
511
612
  }),
613
+ /** Persona penanggung jawab task (atau persona agen): ikuti aturan dan batas wilayahnya. */
614
+ persona: PersonaSchema.optional(),
512
615
  lease_expires_at: IsoDateTimeSchema,
513
- dependencies: z8.array(DependencyHandoffSchema),
616
+ lease_id: IdSchema.optional(),
617
+ dependencies: z9.array(DependencyHandoffSchema),
514
618
  /** Diisi bila task diambil dari REVISION_REQUESTED. */
515
- revision: z8.object({
516
- review_feedback: z8.string(),
619
+ revision: z9.object({
620
+ review_feedback: z9.string(),
517
621
  previous_handoff: HandoffSummarySchema.nullable()
518
622
  }).optional(),
519
623
  /** Peringatan bila branch lokal berbeda dari git_branch handoff dependensi. */
520
- warnings: z8.array(z8.string()).default([])
624
+ warnings: z9.array(z9.string()).default([])
521
625
  });
522
- var CompleteHandoffInput = z8.object({
626
+ var CompleteHandoffInput = z9.object({
627
+ lease_id: IdSchema.optional(),
523
628
  task_id: IdSchema,
524
629
  handoff_summary: HandoffSummarySchema
525
630
  });
526
- var CompleteHandoffOutput = z8.object({
631
+ var CompleteHandoffOutput = z9.object({
527
632
  task_id: IdSchema,
528
- status: z8.enum(["DONE", "NEEDS_REVIEW"]),
529
- unlocked_task_ids: z8.array(IdSchema),
633
+ status: z9.enum(["DONE", "NEEDS_REVIEW"]),
634
+ unlocked_task_ids: z9.array(IdSchema),
530
635
  /** Mis. saran mereset sesi chat (1 Task = 1 Fresh Session). */
531
- next_step_hint: z8.string()
636
+ next_step_hint: z9.string()
532
637
  });
533
- var ReportBlockerInput = z8.object({
638
+ var ReportBlockerInput = z9.object({
639
+ lease_id: IdSchema.optional(),
534
640
  task_id: IdSchema,
535
641
  category: BlockerCategorySchema,
536
- reason: z8.string().min(10).max(1e3)
642
+ reason: z9.string().min(10).max(1e3)
537
643
  });
538
- var ReportBlockerOutput = z8.object({
644
+ var ReportBlockerOutput = z9.object({
539
645
  task_id: IdSchema,
540
- status: z8.literal("BLOCKED")
646
+ status: z9.literal("BLOCKED")
541
647
  });
542
648
  var MAX_TASKS_PER_PLAN = 30;
543
- var PlanRefSchema = z8.string().min(1).max(40).regex(/^[a-z0-9][a-z0-9_-]*$/, "ref harus huruf kecil, angka, '-' atau '_'");
544
- var PlannedTaskSchema = z8.object({
649
+ var PlanRefSchema = z9.string().min(1).max(40).regex(/^[a-z0-9][a-z0-9_-]*$/, "ref harus huruf kecil, angka, '-' atau '_'");
650
+ var PlannedTaskSchema = z9.object({
545
651
  ref: PlanRefSchema,
546
- title: z8.string().min(1).max(200),
547
- prompt_instruction: z8.string().min(1).max(8e3),
652
+ title: z9.string().min(1).max(200),
653
+ prompt_instruction: z9.string().min(1).max(8e3),
548
654
  /** Berisi ref task lain dalam rencana ini, atau UUID task yang sudah ada. */
549
- depends_on: z8.array(z8.union([PlanRefSchema, IdSchema])).max(10).default([]),
655
+ depends_on: z9.array(z9.union([PlanRefSchema, IdSchema])).max(10).default([]),
550
656
  target_repo: RepoNameSchema.optional(),
551
657
  role: RoleSchema.optional(),
552
- requires_approval: z8.boolean().default(false)
658
+ /** Alias persona penanggung jawab (lihat list_personas). Role task mengikuti persona ini. */
659
+ persona: AgentAliasSchema.optional(),
660
+ requires_approval: z9.boolean().default(false)
553
661
  });
554
- var CreateTasksInput = z8.object({
662
+ var CreateTasksInput = z9.object({
555
663
  epic_id: IdSchema,
556
- tasks: z8.array(PlannedTaskSchema).min(1).max(MAX_TASKS_PER_PLAN)
664
+ tasks: z9.array(PlannedTaskSchema).min(1).max(MAX_TASKS_PER_PLAN)
557
665
  }).superRefine((plan, ctx) => {
558
666
  const refs = /* @__PURE__ */ new Set();
559
667
  plan.tasks.forEach((t, i) => {
@@ -596,82 +704,94 @@ var CreateTasksInput = z8.object({
596
704
  });
597
705
  }
598
706
  });
599
- var CreateTasksOutput = z8.object({
600
- created: z8.array(
601
- z8.object({
602
- ref: z8.string(),
707
+ var CreateTasksOutput = z9.object({
708
+ created: z9.array(
709
+ z9.object({
710
+ ref: z9.string(),
603
711
  task_id: IdSchema,
604
712
  status: TaskStatusSchema
605
713
  })
606
714
  )
607
715
  });
608
- var LoadSkillInput = z8.object({
609
- name: SkillNameSchema
716
+ var LoadSkillInput = z9.object({
717
+ name: SkillNameSchema,
718
+ revision: CommitShaSchema.optional()
610
719
  });
611
- var LoadSkillOutput = z8.object({
720
+ var LoadSkillOutput = z9.object({
612
721
  name: SkillNameSchema,
613
- when_to_use: z8.string(),
614
- content: z8.string()
722
+ revision: CommitShaSchema.optional(),
723
+ when_to_use: z9.string(),
724
+ content: z9.string()
615
725
  });
616
- var SaveRepoSkillInput = z8.object({
726
+ var SaveRepoSkillInput = z9.object({
617
727
  name: SkillNameSchema,
618
- when_to_use: z8.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
728
+ when_to_use: z9.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
619
729
  content: SkillContentSchema
620
730
  });
621
- var SaveRepoSkillOutput = z8.object({
622
- path: z8.string(),
623
- created: z8.boolean()
731
+ var SaveRepoSkillOutput = z9.object({
732
+ path: z9.string(),
733
+ created: z9.boolean()
624
734
  });
625
- var EpicSummarySchema = z8.object({
735
+ var EpicSummarySchema = z9.object({
626
736
  id: IdSchema,
627
- title: z8.string(),
628
- description: z8.string().nullable(),
737
+ title: z9.string(),
738
+ description: z9.string().nullable(),
629
739
  /** Jumlah task per status, mis. { DRAFT: 3, TODO: 1 }. */
630
- task_counts: z8.record(z8.string(), z8.number().int().min(0))
740
+ task_counts: z9.record(z9.string(), z9.number().int().min(0))
631
741
  });
632
- var ListEpicsInput = z8.object({});
633
- var ListEpicsOutput = z8.object({
634
- epics: z8.array(EpicSummarySchema)
742
+ var ListEpicsInput = z9.object({});
743
+ var ListEpicsOutput = z9.object({
744
+ epics: z9.array(EpicSummarySchema)
635
745
  });
636
- var CreateEpicToolInput = z8.object({
637
- title: z8.string().trim().min(1).max(200),
638
- description: z8.string().max(4e3).optional()
746
+ var CreateEpicToolInput = z9.object({
747
+ title: z9.string().trim().min(1).max(200),
748
+ description: z9.string().max(4e3).optional()
639
749
  });
640
- var CreateEpicToolOutput = z8.object({
750
+ var CreateEpicToolOutput = z9.object({
641
751
  epic: EpicSummarySchema
642
752
  });
643
- var ListPersonasInput = z8.object({});
644
- var ListPersonasOutput = z8.object({
645
- personas: z8.array(
753
+ var ListPersonasInput = z9.object({});
754
+ var ListPersonasOutput = z9.object({
755
+ personas: z9.array(
646
756
  PersonaSchema.extend({
647
757
  /** "project" = khusus proyek ini (bisa diubah agen); "workspace" = global, hanya dari Web. */
648
- scope: z8.enum(["project", "workspace"])
758
+ scope: z9.enum(["project", "workspace"])
649
759
  })
650
760
  )
651
761
  });
652
762
  var UpsertPersonaInput = PersonaSchema.extend({
653
- rules: z8.array(z8.string().trim().min(1).max(300)).max(30).default([])
763
+ rules: z9.array(z9.string().trim().min(1).max(300)).max(30).default([])
654
764
  });
655
- var UpsertPersonaOutput = z8.object({
765
+ var UpsertPersonaOutput = z9.object({
656
766
  persona: PersonaSchema,
657
- created: z8.boolean()
767
+ created: z9.boolean()
658
768
  });
659
769
  function tool(description, input, output) {
660
770
  return { description, input, output };
661
771
  }
662
772
  var MCP_TOOLS = {
773
+ release_task: tool(
774
+ "Lepas lease task supaya sesi lain bisa mengambilnya.",
775
+ ReleaseTaskInput,
776
+ z9.object({ task_id: IdSchema, status: z9.enum(["TODO", "REVISION_REQUESTED"]) })
777
+ ),
778
+ review_pull_request: tool(
779
+ "Antrean, claim, hasil review, atau cek merge pull request.",
780
+ z9.object({ request: ReviewInput }),
781
+ ReviewOutput
782
+ ),
663
783
  get_project_context: tool(
664
784
  "Baca konteks proyek: identitas repo, aturan persona, indeks skill, dan handoff dependensi langsung.",
665
785
  GetProjectContextInput,
666
786
  GetProjectContextOutput
667
787
  ),
668
788
  get_ready_tasks: tool(
669
- "Daftar ringkas task siap dikerjakan untuk repo ini (semua dependensi DONE).",
789
+ "Daftar ringkas task siap dikerjakan untuk repo ini (semua dependensi DONE). Dengan agent_alias, hanya task milik persona itu (dan task tanpa penanggung jawab yang role-nya cocok).",
670
790
  GetReadyTasksInput,
671
791
  GetReadyTasksOutput
672
792
  ),
673
793
  claim_task: tool(
674
- "Kunci task (lease 30 menit) dan ambil instruksi lengkap beserta handoff dependensinya.",
794
+ "Kunci task (lease 30 menit) dan ambil instruksi lengkap, handoff dependensi, serta aturan persona penanggung jawabnya. Kirim agent_alias bila bekerja sebagai persona tertentu.",
675
795
  ClaimTaskInput,
676
796
  ClaimTaskOutput
677
797
  ),
@@ -724,9 +844,9 @@ var MCP_TOOLS = {
724
844
  var MCP_TOOL_NAMES = Object.keys(MCP_TOOLS);
725
845
 
726
846
  // shared/src/quota.ts
727
- import { z as z9 } from "zod";
847
+ import { z as z10 } from "zod";
728
848
  var PLANS = ["free", "pro", "team"];
729
- var PlanSchema = z9.enum(PLANS);
849
+ var PlanSchema = z10.enum(PLANS);
730
850
  var QUOTA_DIMENSIONS = [
731
851
  /** Jumlah proyek di workspace. */
732
852
  "projects",
@@ -743,36 +863,36 @@ var QUOTA_DIMENSIONS = [
743
863
  /** Indeks skill per repo yang disinkronkan ke Cloud. */
744
864
  "skills"
745
865
  ];
746
- var QuotaDimensionSchema = z9.enum(QUOTA_DIMENSIONS);
866
+ var QuotaDimensionSchema = z10.enum(QUOTA_DIMENSIONS);
747
867
  var QUOTA_WARNING_HEADER = "x-catenext-quota-warning";
748
- var QuotaExceededDetailsSchema = z9.object({
868
+ var QuotaExceededDetailsSchema = z10.object({
749
869
  dimension: QuotaDimensionSchema,
750
870
  plan: PlanSchema,
751
- limit: z9.number().int(),
752
- used: z9.number().int(),
871
+ limit: z10.number().int(),
872
+ used: z10.number().int(),
753
873
  /** Kapan kuota bulanan direset; null untuk kuota jumlah (proyek, persona, ...). */
754
874
  reset_at: IsoDateTimeSchema.nullable(),
755
- upgrade_url: z9.string()
875
+ upgrade_url: z10.string()
756
876
  });
757
- var UsageItemSchema = z9.object({
877
+ var UsageItemSchema = z10.object({
758
878
  dimension: QuotaDimensionSchema,
759
- label: z9.string(),
760
- used: z9.number().int().min(0),
761
- limit: z9.number().int().nullable()
879
+ label: z10.string(),
880
+ used: z10.number().int().min(0),
881
+ limit: z10.number().int().nullable()
762
882
  });
763
- var UsageOutput = z9.object({
883
+ var UsageOutput = z10.object({
764
884
  plan: PlanSchema,
765
- plans: z9.array(
766
- z9.object({
885
+ plans: z10.array(
886
+ z10.object({
767
887
  plan: PlanSchema,
768
- available: z9.boolean(),
769
- limits: z9.record(z9.string(), z9.number().nullable())
888
+ available: z10.boolean(),
889
+ limits: z10.record(z10.string(), z10.number().nullable())
770
890
  })
771
891
  ),
772
892
  period_start: IsoDateTimeSchema,
773
893
  reset_at: IsoDateTimeSchema,
774
- retention_days: z9.number().int().nullable(),
775
- usage: z9.array(UsageItemSchema)
894
+ retention_days: z10.number().int().nullable(),
895
+ usage: z10.array(UsageItemSchema)
776
896
  });
777
897
 
778
898
  // src/index.ts
@@ -935,7 +1055,7 @@ async function findProjectRoot(start = process.cwd()) {
935
1055
  import { chmod, mkdir, readFile as readFile2, rename, writeFile } from "node:fs/promises";
936
1056
  import { homedir } from "node:os";
937
1057
  import { join as join2 } from "node:path";
938
- import { z as z10 } from "zod";
1058
+ import { z as z11 } from "zod";
939
1059
  function catenextHome() {
940
1060
  return process.env.CATENEXT_HOME ?? join2(homedir(), ".catenext");
941
1061
  }
@@ -944,10 +1064,10 @@ function credentialsPath() {
944
1064
  }
945
1065
  var PRODUCTION_API_URL = "https://catenext.mapan.digital";
946
1066
  var DEFAULT_API_URL = PRODUCTION_API_URL;
947
- var CredentialsSchema = z10.object({
948
- api_key: z10.string().startsWith(API_KEY_PREFIX),
949
- api_url: z10.url().optional(),
950
- saved_at: z10.string().optional()
1067
+ var CredentialsSchema = z11.object({
1068
+ api_key: z11.string().startsWith(API_KEY_PREFIX),
1069
+ api_url: z11.url().optional(),
1070
+ saved_at: z11.string().optional()
951
1071
  });
952
1072
  var CredentialsError = class extends Error {
953
1073
  constructor(message) {
@@ -1125,6 +1245,7 @@ async function deviceLogin(opts) {
1125
1245
 
1126
1246
  // src/fallback.ts
1127
1247
  import { execFile } from "node:child_process";
1248
+ import { randomUUID } from "node:crypto";
1128
1249
  import { promisify } from "node:util";
1129
1250
 
1130
1251
  // src/planning.ts
@@ -1339,7 +1460,9 @@ async function readGitState(cwd = process.cwd()) {
1339
1460
  }
1340
1461
  async function taskNext(api, opts) {
1341
1462
  const res = await api.post("ready-tasks", {
1342
- limit: opts.limit ?? 10
1463
+ limit: opts.limit ?? 10,
1464
+ ...opts.lease ? { lease_id: opts.lease } : {},
1465
+ ...opts.as ? { agent_alias: opts.as } : {}
1343
1466
  });
1344
1467
  if (opts.json) return console.log(JSON.stringify(res, null, 2));
1345
1468
  if (res.tasks.length === 0) {
@@ -1348,20 +1471,30 @@ async function taskNext(api, opts) {
1348
1471
  );
1349
1472
  }
1350
1473
  for (const t of res.tasks) {
1351
- const tags = [t.role, t.revision ? "revisi" : null].filter(Boolean).join(", ");
1474
+ const tags = [t.persona ? `@${t.persona}` : null, t.role, t.revision ? "revisi" : null].filter(Boolean).join(", ");
1352
1475
  console.log(`${t.id} ${t.title}${tags ? ` [${tags}]` : ""}`);
1353
1476
  }
1354
- console.log(`
1355
- Ambil satu: catenext claim ${res.tasks[0]?.id}`);
1477
+ console.log(
1478
+ `
1479
+ Ambil satu: catenext claim ${res.tasks[0]?.id}${opts.as ? ` --as ${opts.as}` : ""}`
1480
+ );
1356
1481
  }
1357
1482
  function renderClaim(res) {
1358
1483
  const out = [];
1359
1484
  out.push(`# Task: ${res.task.title}`, "");
1360
1485
  out.push(`- ID: ${res.task.id}`);
1361
1486
  out.push(`- Lease sampai: ${res.lease_expires_at} (diperpanjang setiap perintah catenext)`);
1487
+ if (res.lease_id)
1488
+ out.push(`- Gunakan --lease ${res.lease_id} saat memperbarui atau menyerahkan task.`);
1362
1489
  if (res.task.role) out.push(`- Role: ${res.task.role}`);
1363
1490
  if (res.task.revision_count > 0) out.push(`- Revisi ke-${res.task.revision_count}`);
1364
1491
  out.push("", "## Instruksi", "", res.task.prompt_instruction.trim(), "");
1492
+ if (res.persona) {
1493
+ out.push(`## Persona: ${res.persona.alias} (${res.persona.role})`, "");
1494
+ out.push("Patuhi aturan dan batas wilayah berikut:", "");
1495
+ for (const r of res.persona.rules) out.push(`- ${r}`);
1496
+ out.push("");
1497
+ }
1365
1498
  if (res.revision) {
1366
1499
  out.push("## Feedback revisi dari reviewer", "", res.revision.review_feedback.trim(), "");
1367
1500
  }
@@ -1371,6 +1504,9 @@ function renderClaim(res) {
1371
1504
  const h = d.handoff_summary;
1372
1505
  out.push(`### ${d.title}`, "");
1373
1506
  out.push(`- Branch/commit: ${h.git_branch} @ ${h.last_commit_hash}`);
1507
+ if (d.integrated_commit) {
1508
+ out.push(`- Terintegrasi: ${d.integrated_commit.branch} @ ${d.integrated_commit.sha}`);
1509
+ }
1374
1510
  if (h.files_modified.length) out.push(`- File: ${h.files_modified.join(", ")}`);
1375
1511
  for (const k of h.key_decisions) out.push(`- Keputusan: ${k}`);
1376
1512
  if (h.verification_command) out.push(`- Verifikasi: \`${h.verification_command}\``);
@@ -1387,7 +1523,19 @@ function renderClaim(res) {
1387
1523
  return out.join("\n");
1388
1524
  }
1389
1525
  async function taskClaim(api, taskId, opts) {
1390
- const res = await api.post("claim", { task_id: taskId });
1526
+ const branch = opts.worktree ? await git(["symbolic-ref", "--short", "HEAD"], process.cwd()) : null;
1527
+ if (opts.worktree && !branch)
1528
+ throw new PlanningInputError("Checkout branch kerja sebelum memakai --worktree.");
1529
+ const payload = prepare(
1530
+ ClaimTaskInput,
1531
+ {
1532
+ task_id: taskId,
1533
+ ...opts.as ? { agent_alias: opts.as } : {},
1534
+ ...branch ? { worktree: { branch, session_id: randomUUID() } } : {}
1535
+ },
1536
+ ["task_id", "session_id"]
1537
+ );
1538
+ const res = await api.post("claim", payload);
1391
1539
  if (opts.json) return console.log(JSON.stringify(res, null, 2));
1392
1540
  console.log(renderClaim(res));
1393
1541
  }
@@ -1402,6 +1550,8 @@ function buildHandoff(opts, gitState) {
1402
1550
  "Tidak bisa membaca branch/commit git. Jalankan di dalam repo git dan commit pekerjaan Anda dulu."
1403
1551
  );
1404
1552
  }
1553
+ if (Boolean(opts.pr) !== Boolean(opts.base))
1554
+ throw new PlanningInputError("Gunakan --pr dan --base bersama.");
1405
1555
  const files = opts.file.length ? opts.file : gitState.changedFiles;
1406
1556
  return {
1407
1557
  files_modified: files.slice(0, HANDOFF_LIMITS.maxFilesModified),
@@ -1409,32 +1559,55 @@ function buildHandoff(opts, gitState) {
1409
1559
  verification_command: opts.verify ?? null,
1410
1560
  notes_for_next_agent: opts.notes,
1411
1561
  git_branch: gitState.branch,
1412
- last_commit_hash: gitState.commit
1562
+ last_commit_hash: gitState.commit,
1563
+ ...opts.pr && opts.base ? { pull_request: { url: opts.pr, base_branch: opts.base, head_sha: gitState.commit } } : {}
1413
1564
  };
1414
1565
  }
1415
1566
  async function taskDone(api, taskId, opts) {
1416
1567
  const summary = opts.handoff ? await readJsonInput(opts.handoff) : buildHandoff(opts, await readGitState());
1417
- const body = prepare(CompleteHandoffInput, { task_id: taskId, handoff_summary: summary }, [
1418
- "task_id",
1419
- "last_commit_hash"
1420
- ]);
1568
+ const body = prepare(
1569
+ CompleteHandoffInput,
1570
+ { task_id: taskId, handoff_summary: summary, lease_id: opts.lease },
1571
+ ["task_id", "last_commit_hash", "head_sha", "lease_id"]
1572
+ );
1421
1573
  const res = await api.post("complete", body);
1422
1574
  if (opts.json) return console.log(JSON.stringify(res, null, 2));
1423
1575
  console.log(
1424
- res.status === "DONE" ? `\u2713 Task selesai (DONE). ${res.unlocked_task_ids.length} task hilir terbuka.` : "\u2713 Handoff terkirim, menunggu review manusia (NEEDS_REVIEW)."
1576
+ res.status === "DONE" ? `\u2713 Task selesai (DONE). ${res.unlocked_task_ids.length} task hilir terbuka.` : "\u2713 Handoff terkirim, menunggu review (NEEDS_REVIEW)."
1425
1577
  );
1426
1578
  console.log(` ${res.next_step_hint}`);
1427
1579
  }
1428
1580
  async function taskBlock(api, taskId, opts) {
1429
1581
  const body = prepare(
1430
1582
  ReportBlockerInput,
1431
- { task_id: taskId, category: opts.category, reason: opts.reason },
1432
- ["task_id", "category"]
1583
+ { task_id: taskId, category: opts.category, reason: opts.reason, lease_id: opts.lease },
1584
+ ["task_id", "category", "lease_id"]
1433
1585
  );
1434
1586
  const res = await api.post("blocker", body);
1435
1587
  if (opts.json) return console.log(JSON.stringify(res, null, 2));
1436
1588
  console.log("\u2713 Task ditandai BLOCKED dan lock dilepas. Manusia akan meninjau di Dashboard.");
1437
1589
  }
1590
+ async function taskReview(api, input, json2) {
1591
+ const body = prepare(ReviewInput, input, ["task_id", "lease_id", "head_sha"]);
1592
+ const result = await api.post(
1593
+ body.action === "list" ? "review/list" : "review",
1594
+ body
1595
+ );
1596
+ if (json2) console.log(JSON.stringify(result, null, 2));
1597
+ else if ("reviews" in result) {
1598
+ if (!result.reviews.length) console.log("Belum ada PR yang bisa Anda review di repo ini.");
1599
+ for (const item of result.reviews)
1600
+ console.log(`${item.task_id} ${item.title} ${item.review.url}`);
1601
+ } else {
1602
+ console.log(`${result.title} ${result.status} \xB7 ${result.review.stage}`);
1603
+ console.log(`${result.review.url} @ ${result.review.head_sha}`);
1604
+ if (result.lease_id)
1605
+ console.log(`Lease review: ${result.lease_id} (sampai ${result.lease_expires_at})`);
1606
+ if (result.notes_for_next_agent) console.log(result.notes_for_next_agent);
1607
+ if (result.warning) console.error(result.warning);
1608
+ }
1609
+ if ("warning" in result && result.warning) process.exitCode = 1;
1610
+ }
1438
1611
 
1439
1612
  // src/init/index.ts
1440
1613
  import { mkdir as mkdir2, readFile as readFile5, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
@@ -1460,6 +1633,11 @@ function renderAgentsBlock() {
1460
1633
  '4. `catenext done <task_id> --notes "<ringkasan>" --verify "<perintah tes>" [--decision "..."]`',
1461
1634
  '5. Bila buntu: `catenext block <task_id> --category <missing_env|ambiguous_requirement|failing_tests|dependency_issue|other> --reason "..."`',
1462
1635
  "",
1636
+ "Persona: tiap task bisa punya persona penanggung jawab (mis. `adel`). Bila diminta",
1637
+ '"adel, kerjakan", pakai `catenext next --as adel` lalu `catenext claim <task_id> --as adel`',
1638
+ "(dengan MCP: kirim `agent_alias` ke get_ready_tasks dan claim_task), dan patuhi aturannya.",
1639
+ "Di Claude Code, `catenext sync` membuat subagent per persona di `.claude/agents/`.",
1640
+ "",
1463
1641
  "Aturan: satu task per sesi; jangan menyalin kode atau secret ke handoff (rujuk path file);",
1464
1642
  "jangan mengedit `.catenext/config.yaml`. Skill repo ada di `.catenext/skills/`.",
1465
1643
  BLOCK_END
@@ -1733,8 +1911,8 @@ async function applyInit(root, changes) {
1733
1911
 
1734
1912
  // src/maintenance.ts
1735
1913
  import { existsSync } from "node:fs";
1736
- import { copyFile, mkdir as mkdir4, readFile as readFile7, rename as rename4, rm, rmdir, writeFile as writeFile4 } from "node:fs/promises";
1737
- import { dirname as dirname3, isAbsolute, join as join7, resolve as resolve3 } from "node:path";
1914
+ import { copyFile, mkdir as mkdir4, readFile as readFile8, rename as rename4, rm, rmdir, writeFile as writeFile4 } from "node:fs/promises";
1915
+ import { dirname as dirname3, isAbsolute, join as join8, resolve as resolve3 } from "node:path";
1738
1916
  import { applyEdits as applyEdits2, modify as modify2, parse as parse4, visit } from "jsonc-parser";
1739
1917
 
1740
1918
  // src/node-command.ts
@@ -1775,8 +1953,10 @@ function npxLaunch(entry) {
1775
1953
  }
1776
1954
 
1777
1955
  // src/skills.ts
1956
+ import { execFile as execFile2 } from "node:child_process";
1778
1957
  import { mkdir as mkdir3, readdir, readFile as readFile6, rename as rename3, writeFile as writeFile3 } from "node:fs/promises";
1779
1958
  import { join as join6 } from "node:path";
1959
+ import { promisify as promisify2 } from "node:util";
1780
1960
  import { parse as parse3, stringify } from "yaml";
1781
1961
  var SKILLS_DIR = join6(".catenext", "skills");
1782
1962
  var SkillError = class extends Error {
@@ -1785,6 +1965,7 @@ var SkillError = class extends Error {
1785
1965
  this.name = "SkillError";
1786
1966
  }
1787
1967
  };
1968
+ var exec2 = promisify2(execFile2);
1788
1969
  var FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
1789
1970
  function parseSkill(source, fileName) {
1790
1971
  const m = FRONTMATTER.exec(source);
@@ -1840,10 +2021,25 @@ async function listSkills(root) {
1840
2021
  function skillIndex(skills) {
1841
2022
  return skills.map((s) => ({ name: s.name, when_to_use: s.when_to_use }));
1842
2023
  }
1843
- async function loadSkill(root, name) {
2024
+ async function loadSkill(root, name, revision) {
1844
2025
  const parsedName = SkillNameSchema.safeParse(name);
1845
2026
  if (!parsedName.success) throw new SkillError(`Nama skill "${name}" tidak valid.`);
1846
2027
  const file = `${parsedName.data}.md`;
2028
+ if (revision) {
2029
+ const sha = CommitShaSchema.safeParse(revision);
2030
+ if (!sha.success) throw new SkillError("Gunakan SHA commit Git lengkap untuk revisi skill.");
2031
+ let source2;
2032
+ try {
2033
+ source2 = (await exec2("git", ["show", `${sha.data}:${skillPath(parsedName.data)}`], { cwd: root })).stdout;
2034
+ } catch {
2035
+ throw new SkillError(
2036
+ `Skill "${name}" tidak tersedia pada ${sha.data}. Fetch commit itu lalu coba kembali.`
2037
+ );
2038
+ }
2039
+ const skill = parseSkill(source2, file);
2040
+ if (skill.name !== name) throw new SkillError(`${file}: name harus sama dengan nama file.`);
2041
+ return skill;
2042
+ }
1847
2043
  let source;
1848
2044
  try {
1849
2045
  source = await readFile6(join6(root, SKILLS_DIR, file), "utf8");
@@ -1876,12 +2072,116 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
1876
2072
  await rename3(tmp, target);
1877
2073
  return { path: join6(SKILLS_DIR, `${name}.md`), created, skill };
1878
2074
  }
2075
+ async function committedSkillIndex(root, previous) {
2076
+ const config = { cwd: root };
2077
+ const branchRef = (await exec2("git", ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], config).catch(() => null))?.stdout.trim();
2078
+ const branch = (await exec2("git", ["symbolic-ref", "-q", "HEAD"], config).catch(() => null))?.stdout.trim();
2079
+ if (!branchRef?.startsWith("refs/remotes/origin/") || branch !== `refs/heads/${branchRef.slice("refs/remotes/origin/".length)}`)
2080
+ return null;
2081
+ const revision = CommitShaSchema.parse(
2082
+ (await exec2("git", ["rev-parse", branchRef], config)).stdout.trim()
2083
+ );
2084
+ const head = (await exec2("git", ["rev-parse", "HEAD"], config)).stdout.trim();
2085
+ if (head !== revision) return null;
2086
+ if (previous && previous !== revision && !await exec2("git", ["merge-base", "--is-ancestor", previous, revision], config).catch(
2087
+ () => null
2088
+ )) {
2089
+ throw new SkillError(
2090
+ "Revisi Git lokal tertinggal dari indeks Cloud. Fetch branch utama lalu coba lagi."
2091
+ );
2092
+ }
2093
+ const names = (await exec2("git", ["ls-tree", "-rz", "--name-only", revision, "--", SKILLS_DIR], config)).stdout.split("\0").flatMap((path) => {
2094
+ const file = /^\.catenext\/skills\/([^/]+)\.md$/.exec(path);
2095
+ return file?.[1] ? [file[1]] : [];
2096
+ });
2097
+ const skills = [];
2098
+ const invalid = [];
2099
+ for (const name of names) {
2100
+ try {
2101
+ skills.push(await loadSkill(root, name, revision));
2102
+ } catch (err) {
2103
+ invalid.push({ file: `${name}.md`, error: err.message });
2104
+ }
2105
+ }
2106
+ return { revision, skills: skillIndex(skills), invalid };
2107
+ }
1879
2108
 
1880
- // src/maintenance.ts
2109
+ // src/subagents.ts
2110
+ import { readdir as readdir2, readFile as readFile7 } from "node:fs/promises";
2111
+ import { join as join7 } from "node:path";
2112
+ var SUBAGENTS_DIR = join7(".claude", "agents");
2113
+ var SUBAGENT_MARKER = "<!-- catenext:persona -->";
2114
+ function renderSubagent(p) {
2115
+ const rules = p.rules.length > 0 ? p.rules.map((r) => `- ${r}`) : ["- (belum ada aturan)"];
2116
+ const alias = JSON.stringify(p.alias);
2117
+ return [
2118
+ "---",
2119
+ `name: ${p.alias}`,
2120
+ `description: Persona Catenext "${p.alias}" (role ${p.role}). Pakai saat diminta "${p.alias}, kerjakan" atau untuk task Catenext milik ${p.alias}. Mengerjakan satu task lalu melapor.`,
2121
+ "---",
2122
+ SUBAGENT_MARKER,
2123
+ `<!-- Dibuat oleh \`catenext sync\` dari persona di Cloud; ubah persona di Dashboard, bukan file ini. -->`,
2124
+ "",
2125
+ `Anda adalah persona Catenext **${p.alias}** (role: ${p.role}).`,
2126
+ "",
2127
+ "## Alur kerja (satu task per pemanggilan)",
2128
+ "",
2129
+ `1. \`get_project_context\` dengan \`agent_alias: ${alias}\`.`,
2130
+ `2. \`get_ready_tasks\` dengan \`agent_alias: ${alias}\`; pilih task teratas. Bila kosong, laporkan "tidak ada task untuk ${p.alias}" lalu berhenti.`,
2131
+ `3. \`claim_task\` dengan \`task_id\` dan \`agent_alias: ${alias}\`. Patuhi field \`persona\` di hasilnya.`,
2132
+ "4. Kerjakan, jalankan tes, commit di branch kerja.",
2133
+ "5. `complete_handoff` dengan ringkasan terstruktur, atau `report_blocker` bila buntu.",
2134
+ "6. Laporkan ke pemanggil: task apa yang selesai, status, dan perintah verifikasinya.",
2135
+ "",
2136
+ `Tanpa tool MCP: \`catenext next --as ${p.alias}\`, \`catenext claim <id> --as ${p.alias}\`, \`catenext done <id> ...\`.`,
2137
+ "",
2138
+ "## Aturan & batas wilayah",
2139
+ "",
2140
+ ...rules,
2141
+ ""
2142
+ ].join("\n");
2143
+ }
1881
2144
  var readOrNull2 = (p) => readFile7(p, "utf8").then(
1882
2145
  (s) => s,
1883
2146
  () => null
1884
2147
  );
2148
+ async function planSubagents(root, personas) {
2149
+ const edits = [];
2150
+ const skipped = [];
2151
+ const wanted = /* @__PURE__ */ new Set();
2152
+ for (const p of personas) {
2153
+ const path = join7(SUBAGENTS_DIR, `${p.alias}.md`);
2154
+ wanted.add(path);
2155
+ const before = await readOrNull2(join7(root, path));
2156
+ if (before !== null && !before.includes(SUBAGENT_MARKER)) {
2157
+ skipped.push(path);
2158
+ continue;
2159
+ }
2160
+ const after = renderSubagent(p);
2161
+ if (after !== before) edits.push({ path, before, after });
2162
+ }
2163
+ for (const path of await catenextSubagentFiles(root)) {
2164
+ if (!wanted.has(path)) {
2165
+ edits.push({ path, before: await readOrNull2(join7(root, path)), after: null });
2166
+ }
2167
+ }
2168
+ return { edits, skipped };
2169
+ }
2170
+ async function catenextSubagentFiles(root) {
2171
+ const names = await readdir2(join7(root, SUBAGENTS_DIR)).catch(() => []);
2172
+ const out = [];
2173
+ for (const n of names.filter((n2) => n2.endsWith(".md")).sort()) {
2174
+ const path = join7(SUBAGENTS_DIR, n);
2175
+ if ((await readOrNull2(join7(root, path)))?.includes(SUBAGENT_MARKER)) out.push(path);
2176
+ }
2177
+ return out;
2178
+ }
2179
+
2180
+ // src/maintenance.ts
2181
+ var readOrNull3 = (p) => readFile8(p, "utf8").then(
2182
+ (s) => s,
2183
+ () => null
2184
+ );
1885
2185
  function countEntries(source) {
1886
2186
  let count = 0;
1887
2187
  let depth = 0;
@@ -1939,7 +2239,7 @@ async function planSync(opts) {
1939
2239
  const edits = [];
1940
2240
  const findings = [];
1941
2241
  for (const adapter of ADAPTERS) {
1942
- const before = await readOrNull2(join7(root, adapter.path));
2242
+ const before = await readOrNull3(join8(root, adapter.path));
1943
2243
  if (before !== null && before.trim() !== "" && !isValidJsonObject(before)) {
1944
2244
  if (!opts.fix) {
1945
2245
  findings.push({
@@ -2002,12 +2302,12 @@ async function planSync(opts) {
2002
2302
  );
2003
2303
  if (after !== before) edits.push({ path: adapter.path, before, after });
2004
2304
  }
2005
- const gitignore = await readOrNull2(join7(root, ".gitignore"));
2305
+ const gitignore = await readOrNull3(join8(root, ".gitignore"));
2006
2306
  const gitignoreAfter = ensureGitignore(gitignore);
2007
2307
  if (gitignoreAfter !== gitignore) {
2008
2308
  edits.push({ path: ".gitignore", before: gitignore, after: gitignoreAfter });
2009
2309
  }
2010
- const agents = await readOrNull2(join7(root, AGENTS_MD));
2310
+ const agents = await readOrNull3(join8(root, AGENTS_MD));
2011
2311
  if (agents?.includes(BLOCK_START)) {
2012
2312
  const after = upsertAgentsBlock(agents);
2013
2313
  if (after !== agents) edits.push({ path: AGENTS_MD, before: agents, after });
@@ -2015,15 +2315,23 @@ async function planSync(opts) {
2015
2315
  return { edits, findings };
2016
2316
  }
2017
2317
  async function syncSkills(root, api) {
2018
- const { skills, invalid } = await listSkills(root);
2019
- if (api) await api.put("skills", { skills: skillIndex(skills) });
2020
- return { count: skills.length, invalid };
2318
+ const { revision: previous } = api ? await api.post("skills/ref") : { revision: null };
2319
+ const index = await committedSkillIndex(root, previous);
2320
+ if (!index) return { count: 0, invalid: [], skipped: true };
2321
+ if (api && previous !== index.revision) {
2322
+ await api.put("skills", {
2323
+ revision: index.revision,
2324
+ previous_revision: previous,
2325
+ skills: index.skills
2326
+ });
2327
+ }
2328
+ return { count: index.skills.length, invalid: index.invalid, skipped: false };
2021
2329
  }
2022
2330
  async function planRemove(opts) {
2023
2331
  const root = resolve3(opts.root);
2024
2332
  const edits = [];
2025
2333
  for (const adapter of ADAPTERS) {
2026
- const before = await readOrNull2(join7(root, adapter.path));
2334
+ const before = await readOrNull3(join8(root, adapter.path));
2027
2335
  if (before === null || countEntries(before) === 0) continue;
2028
2336
  const stripped = removeMcpEntries(before);
2029
2337
  const doc = parse4(stripped, [], { allowTrailingComma: true });
@@ -2031,7 +2339,7 @@ async function planRemove(opts) {
2031
2339
  const emptyDoc = Object.keys(doc ?? {}).every((k) => k === "mcpServers") && Object.keys(servers ?? {}).length === 0 && !/\/\/|\/\*/.test(stripped);
2032
2340
  edits.push({ path: adapter.path, before, after: emptyDoc ? null : stripped });
2033
2341
  }
2034
- const gitignore = await readOrNull2(join7(root, ".gitignore"));
2342
+ const gitignore = await readOrNull3(join8(root, ".gitignore"));
2035
2343
  if (gitignore !== null) {
2036
2344
  const eol = gitignore.includes("\r\n") ? "\r\n" : "\n";
2037
2345
  const lines = gitignore.split(/\r?\n/);
@@ -2043,19 +2351,22 @@ async function planRemove(opts) {
2043
2351
  edits.push({ path: ".gitignore", before: gitignore, after: text2 ? `${text2}${eol}` : null });
2044
2352
  }
2045
2353
  }
2046
- const agents = await readOrNull2(join7(root, AGENTS_MD));
2354
+ const agents = await readOrNull3(join8(root, AGENTS_MD));
2047
2355
  if (agents?.includes(BLOCK_START)) {
2048
2356
  edits.push({ path: AGENTS_MD, before: agents, after: removeAgentsBlock(agents) });
2049
2357
  }
2050
- for (const p of [CONFIG_PATH, join7(".catenext", "cache.json")]) {
2051
- const before = await readOrNull2(join7(root, p));
2358
+ for (const p of await catenextSubagentFiles(root)) {
2359
+ edits.push({ path: p, before: await readOrNull3(join8(root, p)), after: null });
2360
+ }
2361
+ for (const p of [CONFIG_PATH, join8(".catenext", "cache.json")]) {
2362
+ const before = await readOrNull3(join8(root, p));
2052
2363
  if (before !== null) edits.push({ path: p, before, after: null });
2053
2364
  }
2054
2365
  if (opts.all) {
2055
2366
  const { skills, invalid } = await listSkills(root);
2056
2367
  for (const f of [...skills.map((s) => `${s.name}.md`), ...invalid.map((i) => i.file)]) {
2057
- const p = join7(SKILLS_DIR, f);
2058
- edits.push({ path: p, before: await readOrNull2(join7(root, p)), after: null });
2368
+ const p = join8(SKILLS_DIR, f);
2369
+ edits.push({ path: p, before: await readOrNull3(join8(root, p)), after: null });
2059
2370
  }
2060
2371
  }
2061
2372
  return edits;
@@ -2063,7 +2374,7 @@ async function planRemove(opts) {
2063
2374
  async function applyFileEdits(root, edits) {
2064
2375
  const base = resolve3(root);
2065
2376
  for (const e of edits) {
2066
- const target = join7(base, e.path);
2377
+ const target = join8(base, e.path);
2067
2378
  if (e.after === null) {
2068
2379
  await rm(target, { force: true });
2069
2380
  continue;
@@ -2074,8 +2385,8 @@ async function applyFileEdits(root, edits) {
2074
2385
  await writeFile4(tmp, e.after);
2075
2386
  await rename4(tmp, target);
2076
2387
  }
2077
- for (const dir of [SKILLS_DIR, ".catenext", ".cursor"]) {
2078
- await rmdir(join7(base, dir)).catch(() => {
2388
+ for (const dir of [SKILLS_DIR, ".catenext", ".cursor", SUBAGENTS_DIR, ".claude"]) {
2389
+ await rmdir(join8(base, dir)).catch(() => {
2079
2390
  });
2080
2391
  }
2081
2392
  }
@@ -2094,7 +2405,7 @@ var SERVER_INSTRUCTIONS = [
2094
2405
  "Catenext mengatur estafet task antar-agen AI untuk repo ini.",
2095
2406
  "Alur: get_project_context -> get_ready_tasks -> claim_task -> kerjakan & tes -> complete_handoff.",
2096
2407
  "Merencanakan: list_epics/create_epic -> create_tasks (masuk DRAFT, disetujui manusia di Web sebelum bisa dikerjakan).",
2097
- "Persona: list_personas/upsert_persona untuk alias, role, dan aturan agen di proyek ini.",
2408
+ 'Persona: list_personas/upsert_persona untuk alias, role, dan aturan agen di proyek ini. Setiap task bisa punya persona penanggung jawab; bila diminta bekerja sebagai persona (mis. "adel, kerjakan"), kirim agent_alias-nya ke get_project_context, get_ready_tasks, dan claim_task, lalu patuhi aturan persona dari hasil claim_task.',
2098
2409
  "Skill repo: indeksnya ada di get_project_context; panggil load_skill hanya bila relevan, dan save_repo_skill untuk mencatat konvensi/pitfall yang ditemukan (maks. 500 kata, tanpa code dump).",
2099
2410
  "Bila buntu, panggil report_blocker. Jangan menyalin kode atau secret ke handoff; rujuk path file.",
2100
2411
  "Jangan mengedit .catenext/config.yaml atau file konfigurasi MCP IDE."
@@ -2156,7 +2467,8 @@ function createCatenextMcpServer(opts) {
2156
2467
  async ({ api, config }) => json(
2157
2468
  await api.post("context", {
2158
2469
  agent_alias: input.agent_alias ?? config.overrides?.default_agent_alias,
2159
- role: input.role ?? config.overrides?.default_role
2470
+ role: input.role ?? config.overrides?.default_role,
2471
+ lease_id: input.lease_id
2160
2472
  })
2161
2473
  )
2162
2474
  )
@@ -2172,7 +2484,8 @@ function createCatenextMcpServer(opts) {
2172
2484
  await api.post("ready-tasks", {
2173
2485
  agent_alias: input.agent_alias ?? config.overrides?.default_agent_alias,
2174
2486
  role: input.role ?? config.overrides?.default_role,
2175
- limit: input.limit
2487
+ limit: input.limit,
2488
+ lease_id: input.lease_id
2176
2489
  })
2177
2490
  )
2178
2491
  )
@@ -2180,7 +2493,15 @@ function createCatenextMcpServer(opts) {
2180
2493
  server.registerTool(
2181
2494
  "claim_task",
2182
2495
  { description: MCP_TOOLS.claim_task.description, inputSchema: MCP_TOOLS.claim_task.input },
2183
- (input) => call(async ({ api }) => json(await api.post("claim", { task_id: input.task_id })))
2496
+ (input) => call(
2497
+ async ({ api, config }) => json(
2498
+ await api.post("claim", {
2499
+ task_id: input.task_id,
2500
+ worktree: input.worktree,
2501
+ agent_alias: input.agent_alias ?? config.overrides?.default_agent_alias
2502
+ })
2503
+ )
2504
+ )
2184
2505
  );
2185
2506
  server.registerTool(
2186
2507
  "complete_handoff",
@@ -2189,7 +2510,10 @@ function createCatenextMcpServer(opts) {
2189
2510
  inputSchema: MCP_TOOLS.complete_handoff.input
2190
2511
  },
2191
2512
  (input) => call(async ({ api }) => {
2192
- const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["task_id", "last_commit_hash"]));
2513
+ const scrubbed = scrubDeep(
2514
+ input,
2515
+ /* @__PURE__ */ new Set(["task_id", "last_commit_hash", "head_sha", "lease_id"])
2516
+ );
2193
2517
  const parsed = CompleteHandoffInput.safeParse(scrubbed.value);
2194
2518
  if (!parsed.success) {
2195
2519
  return text(
@@ -2215,7 +2539,7 @@ Ringkas lalu panggil complete_handoff lagi.`,
2215
2539
  inputSchema: MCP_TOOLS.report_blocker.input
2216
2540
  },
2217
2541
  (input) => call(async ({ api }) => {
2218
- const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["task_id", "category"]));
2542
+ const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["task_id", "category", "lease_id"]));
2219
2543
  const parsed = ReportBlockerInput.safeParse(scrubbed.value);
2220
2544
  if (!parsed.success) {
2221
2545
  return text(`Laporan blocker tidak valid:
@@ -2230,6 +2554,26 @@ ${zodIssues(parsed.error)}`, true);
2230
2554
  return json(await api.post("blocker", parsed.data), notes);
2231
2555
  })
2232
2556
  );
2557
+ server.registerTool(
2558
+ "release_task",
2559
+ { description: MCP_TOOLS.release_task.description, inputSchema: MCP_TOOLS.release_task.input },
2560
+ (input) => call(async ({ api }) => json(await api.post("release", input)))
2561
+ );
2562
+ server.registerTool(
2563
+ "review_pull_request",
2564
+ {
2565
+ description: MCP_TOOLS.review_pull_request.description,
2566
+ inputSchema: MCP_TOOLS.review_pull_request.input
2567
+ },
2568
+ ({ request }) => call(async ({ api, config }) => {
2569
+ const scrubbed = scrubDeep(request, /* @__PURE__ */ new Set(["task_id", "head_sha", "lease_id"]));
2570
+ const input = ReviewInput.parse(scrubbed.value);
2571
+ if (input.action === "claim" && !input.agent_alias && config.overrides?.default_role === "reviewer") {
2572
+ input.agent_alias = config.overrides.default_agent_alias;
2573
+ }
2574
+ return json(await api.post(input.action === "list" ? "review/list" : "review", input));
2575
+ })
2576
+ );
2233
2577
  const scrubbedWrite = (schema, keep, send) => (input) => call(async ({ api }) => {
2234
2578
  const scrubbed = scrubDeep(input, new Set(keep));
2235
2579
  const parsed = schema.safeParse(scrubbed.value);
@@ -2263,7 +2607,7 @@ ${zodIssues(parsed.error)}`, true);
2263
2607
  },
2264
2608
  scrubbedWrite(
2265
2609
  CreateTasksInput,
2266
- ["epic_id", "ref", "depends_on", "target_repo", "role"],
2610
+ ["epic_id", "ref", "depends_on", "target_repo", "role", "persona"],
2267
2611
  (api, body) => api.post("tasks", body)
2268
2612
  )
2269
2613
  );
@@ -2287,17 +2631,22 @@ ${zodIssues(parsed.error)}`, true);
2287
2631
  "load_skill",
2288
2632
  { description: MCP_TOOLS.load_skill.description, inputSchema: MCP_TOOLS.load_skill.input },
2289
2633
  (input) => call(async ({ root }) => {
2290
- const skill = await loadSkill(root, input.name);
2291
- return json({ name: skill.name, when_to_use: skill.when_to_use, content: skill.content });
2634
+ const skill = await loadSkill(root, input.name, input.revision);
2635
+ return json({
2636
+ name: skill.name,
2637
+ when_to_use: skill.when_to_use,
2638
+ content: skill.content,
2639
+ ...input.revision ? { revision: input.revision } : {}
2640
+ });
2292
2641
  })
2293
2642
  );
2294
2643
  server.registerTool(
2295
2644
  "save_repo_skill",
2296
2645
  {
2297
- description: `${MCP_TOOLS.save_repo_skill.description} Isi tetap di repo; hanya indeks (nama + when_to_use) yang dikirim ke Cloud.`,
2646
+ description: `${MCP_TOOLS.save_repo_skill.description} File disimpan di checkout. Indeks Cloud diperbarui lewat sync dari branch utama.`,
2298
2647
  inputSchema: MCP_TOOLS.save_repo_skill.input
2299
2648
  },
2300
- (input) => call(async ({ api, root }) => {
2649
+ (input) => call(async ({ root }) => {
2301
2650
  const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["name"]));
2302
2651
  const parsed = SaveRepoSkillInput.safeParse(scrubbed.value);
2303
2652
  if (!parsed.success) {
@@ -2315,14 +2664,7 @@ Ringkas (rujuk path file, jangan menyalin kode) lalu coba lagi.`,
2315
2664
  notes.push(note);
2316
2665
  }
2317
2666
  const saved = await saveSkill(root, parsed.data);
2318
- try {
2319
- const { skills } = await listSkills(root);
2320
- await api.put("skills", { skills: skillIndex(skills) });
2321
- } catch (err) {
2322
- notes.push(
2323
- `Skill tersimpan lokal, tetapi indeks belum tersinkron ke Cloud (${err.message}). Jalankan \`catenext sync\` nanti.`
2324
- );
2325
- }
2667
+ notes.push("Commit dan merge file skill, lalu jalankan catenext sync di branch utama.");
2326
2668
  return json({ path: saved.path, created: saved.created }, notes);
2327
2669
  })
2328
2670
  );
@@ -2381,8 +2723,8 @@ async function runMcpServer(opts) {
2381
2723
  }
2382
2724
 
2383
2725
  // src/verify.ts
2384
- import { readFile as readFile8 } from "node:fs/promises";
2385
- import { join as join8 } from "node:path";
2726
+ import { readFile as readFile9 } from "node:fs/promises";
2727
+ import { join as join9 } from "node:path";
2386
2728
  async function verifySetup(root, config) {
2387
2729
  const lines = [];
2388
2730
  let tokenLine;
@@ -2422,7 +2764,7 @@ async function verifySetup(root, config) {
2422
2764
  const missing = [];
2423
2765
  const stale = [];
2424
2766
  for (const adapter of ADAPTERS) {
2425
- const src = await readFile8(join8(root, adapter.path), "utf8").catch(() => null);
2767
+ const src = await readFile9(join9(root, adapter.path), "utf8").catch(() => null);
2426
2768
  const entry = src ? readMcpEntry(src) : null;
2427
2769
  if (!entry) missing.push(adapter.label);
2428
2770
  else if (entryIsStale(entry)) stale.push(adapter.label);
@@ -2446,14 +2788,14 @@ function formatChecks(lines) {
2446
2788
  }
2447
2789
 
2448
2790
  // src/index.ts
2449
- var VERSION = "0.1.2";
2791
+ var VERSION = "0.2.0";
2450
2792
  var program = new Command();
2451
2793
  program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
2452
2794
  async function friendly(fn) {
2453
2795
  try {
2454
2796
  await fn();
2455
2797
  } catch (err) {
2456
- if (err instanceof ConfigError || err instanceof CredentialsError || err instanceof McpConfigError || err instanceof PlanningInputError) {
2798
+ if (err instanceof ConfigError || err instanceof CredentialsError || err instanceof McpConfigError || err instanceof SkillError || err instanceof PlanningInputError) {
2457
2799
  console.error(`\u2717 ${err.message}`);
2458
2800
  process.exitCode = 1;
2459
2801
  return;
@@ -2603,10 +2945,10 @@ var AGENT_OPT = [
2603
2945
  "Nama agen untuk log aktivitas, mis. codex",
2604
2946
  "catenext-cli"
2605
2947
  ];
2606
- program.command("next").description("Daftar task siap untuk repo ini (setara get_ready_tasks)").option("-n, --limit <n>", "Jumlah maksimal", (v) => Number.parseInt(v, 10), 10).option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2948
+ program.command("next").description("Daftar task siap untuk repo ini (setara get_ready_tasks)").option("-n, --limit <n>", "Jumlah maksimal", (v) => Number.parseInt(v, 10), 10).option("--as <alias>", "Bekerja sebagai persona ini: hanya task miliknya (mis. adel)").option("--lease <id>", "Perpanjang lease worktree yang aktif").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2607
2949
  (opts) => friendly(async () => taskNext(await cliApi(opts.agent), opts))
2608
2950
  );
2609
- program.command("claim").description("Kunci task dan cetak instruksi + handoff dependensinya (setara claim_task)").argument("<task_id>").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2951
+ program.command("claim").description("Kunci task dan cetak instruksi + handoff dependensinya (setara claim_task)").argument("<task_id>").option("--as <alias>", "Bekerja sebagai persona ini; task milik persona lain ditolak").option("--worktree", "Reservasi branch checkout dan ambil lease sesi terpisah").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2610
2952
  (taskId, opts) => friendly(async () => taskClaim(await cliApi(opts.agent), taskId, opts))
2611
2953
  );
2612
2954
  program.command("done").description("Selesaikan task dengan handoff terstruktur (setara complete_handoff)").argument("<task_id>").option("--notes <text>", "Ringkasan untuk agen berikutnya (maks. 500 karakter)").option(
@@ -2619,12 +2961,74 @@ program.command("done").description("Selesaikan task dengan handoff terstruktur
2619
2961
  "File yang diubah (boleh diulang; default dari git)",
2620
2962
  collect,
2621
2963
  []
2622
- ).option("--verify <cmd>", "Perintah verifikasi, mis. pnpm test").option("--handoff <file>", "File JSON handoff_summary lengkap, atau '-' untuk stdin").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2964
+ ).option("--verify <cmd>", "Perintah verifikasi, mis. pnpm test").option("--pr <url>", "URL pull request GitHub").option("--base <branch>", "Branch tujuan PR").option("--lease <id>", "Lease worktree dari claim").option("--handoff <file>", "File JSON handoff_summary lengkap, atau '-' untuk stdin").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2623
2965
  (taskId, opts) => friendly(async () => taskDone(await cliApi(opts.agent), taskId, opts))
2624
2966
  );
2625
- program.command("block").description("Lepas lock dan tandai task BLOCKED (setara report_blocker)").argument("<task_id>").requiredOption("--category <category>", `Salah satu: ${BLOCKER_CATEGORIES.join(", ")}`).requiredOption("--reason <text>", "Alasan spesifik (min. 10 karakter)").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2967
+ program.command("block").description("Lepas lock dan tandai task BLOCKED (setara report_blocker)").argument("<task_id>").requiredOption("--category <category>", `Salah satu: ${BLOCKER_CATEGORIES.join(", ")}`).requiredOption("--reason <text>", "Alasan spesifik (min. 10 karakter)").option("--lease <id>", "Lease worktree dari claim").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
2626
2968
  (taskId, opts) => friendly(async () => taskBlock(await cliApi(opts.agent), taskId, opts))
2627
2969
  );
2970
+ program.command("release").description("Lepas task untuk sesi lain").argument("<task_id>").option("--lease <id>", "Lease worktree dari claim").option(...AGENT_OPT).action(
2971
+ (taskId, opts) => friendly(async () => {
2972
+ const input = prepare(ReleaseTaskInput, { task_id: taskId, lease_id: opts.lease }, [
2973
+ "task_id",
2974
+ "lease_id"
2975
+ ]);
2976
+ const api = await cliApi(opts.agent);
2977
+ console.log(JSON.stringify(await api.post("release", input), null, 2));
2978
+ })
2979
+ );
2980
+ var review = program.command("review").description("Antrean dan keputusan review pull request");
2981
+ review.command("list").option("-n, --limit <n>", "Jumlah maksimal", Number, 10).option(...AGENT_OPT).option("--json").action(
2982
+ (opts) => friendly(
2983
+ async () => taskReview(
2984
+ await cliApi(opts.agent),
2985
+ { action: "list", limit: opts.limit },
2986
+ Boolean(opts.json)
2987
+ )
2988
+ )
2989
+ );
2990
+ review.command("claim").argument("<task_id>").option("--as <alias>", "Persona reviewer").option(...AGENT_OPT).option("--json").action(
2991
+ (taskId, opts) => friendly(
2992
+ async () => taskReview(
2993
+ await cliApi(opts.agent),
2994
+ { action: "claim", task_id: taskId, agent_alias: opts.as },
2995
+ Boolean(opts.json)
2996
+ )
2997
+ )
2998
+ );
2999
+ review.command("refresh").argument("<task_id>").option(...AGENT_OPT).option("--json").action(
3000
+ (taskId, opts) => friendly(
3001
+ async () => taskReview(
3002
+ await cliApi(opts.agent),
3003
+ { action: "refresh", task_id: taskId },
3004
+ Boolean(opts.json)
3005
+ )
3006
+ )
3007
+ );
3008
+ review.command("submit").argument("<task_id>").requiredOption("--lease <id>").requiredOption("--sha <sha>").requiredOption("--decision <approve|request_changes>").requiredOption("--feedback <text>").option(...AGENT_OPT).option("--json").action(
3009
+ (taskId, opts) => friendly(
3010
+ async () => taskReview(
3011
+ await cliApi(opts.agent),
3012
+ {
3013
+ action: "submit",
3014
+ task_id: taskId,
3015
+ lease_id: opts.lease,
3016
+ head_sha: opts.sha,
3017
+ decision: opts.decision,
3018
+ feedback: opts.feedback
3019
+ },
3020
+ Boolean(opts.json)
3021
+ )
3022
+ )
3023
+ );
3024
+ program.command("skill").description("Baca skill repo dari checkout atau revisi Git").command("load").argument("<name>").option("--revision <sha>", "SHA commit Git untuk paritas lintas perangkat").option("--json").action(
3025
+ (name, opts) => friendly(async () => {
3026
+ const skill = await loadSkill(await requireRoot(), name, opts.revision);
3027
+ console.log(
3028
+ opts.json ? JSON.stringify({ ...skill, revision: opts.revision }, null, 2) : skill.content
3029
+ );
3030
+ })
3031
+ );
2628
3032
  async function requireRoot() {
2629
3033
  const root = await findProjectRoot();
2630
3034
  if (!root) {
@@ -2656,9 +3060,9 @@ program.command("sync").description("Selaraskan entri MCP, .gitignore, blok AGEN
2656
3060
  for (const f of plan.findings) console.log(`${f.level === "ok" ? "\u2022" : "!"} ${f.message}`);
2657
3061
  if (opts.dryRun) {
2658
3062
  for (const l of summarize(plan.edits)) console.log(l);
2659
- const { count, invalid } = await syncSkills(root, null);
3063
+ const { count, invalid, skipped } = await syncSkills(root, null);
2660
3064
  console.log(
2661
- `(dry-run) ${plan.edits.length} file akan berubah; indeks ${count} skill akan dikirim.`
3065
+ `(dry-run) ${plan.edits.length} file akan berubah; ${skipped ? "indeks skill tidak akan diubah." : `indeks ${count} skill akan dikirim.`}`
2662
3066
  );
2663
3067
  for (const i of invalid) console.log(`! Skill dilewati: ${i.error}`);
2664
3068
  return;
@@ -2668,12 +3072,24 @@ program.command("sync").description("Selaraskan entri MCP, .gitignore, blok AGEN
2668
3072
  const fixable = plan.findings.some((f) => f.level === "fixable");
2669
3073
  if (plan.edits.length === 0 && !fixable) console.log("\u2713 File lokal sudah selaras.");
2670
3074
  try {
2671
- const { count, invalid } = await syncSkills(root, await cliApi());
2672
- console.log(`\u2713 Indeks ${count} skill tersinkron ke Cloud (isi skill tetap lokal).`);
3075
+ const api = await cliApi();
3076
+ const { count, invalid, skipped } = await syncSkills(root, api);
3077
+ console.log(
3078
+ skipped ? "\u2022 Indeks Cloud mengikuti branch utama origin. Sinkronkan dari checkout branch itu setelah fetch." : `\u2713 Indeks ${count} skill tersinkron ke Cloud (isi skill tetap di Git).`
3079
+ );
2673
3080
  for (const i of invalid) console.log(`! Skill dilewati: ${i.error}`);
3081
+ const { personas } = await api.post("personas/list");
3082
+ const sub = await planSubagents(root, personas);
3083
+ await applyFileEdits(root, sub.edits);
3084
+ for (const l of summarize(sub.edits)) console.log(l);
3085
+ for (const s of sub.skipped)
3086
+ console.log(`! ${s} sudah ada dan bukan buatan Catenext; tidak ditimpa.`);
3087
+ console.log(
3088
+ `\u2713 ${personas.length} persona tersedia sebagai subagent Claude Code di ${SUBAGENTS_DIR}/.`
3089
+ );
2674
3090
  } catch (err) {
2675
3091
  if (!(err instanceof CredentialsError || err instanceof ApiRequestError)) throw err;
2676
- console.log(`! Indeks skill belum tersinkron: ${err.message}`);
3092
+ console.log(`! Skill/persona belum tersinkron: ${err.message}`);
2677
3093
  }
2678
3094
  console.log("");
2679
3095
  console.log(formatChecks(await verifySetup(root, config)));