catenext 0.1.2 → 0.3.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/CHANGELOG.md +62 -0
- package/README.md +115 -33
- package/dist/index.js +1170 -351
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
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
|
|
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
|
|
96
|
+
import { z as z4 } from "zod";
|
|
30
97
|
|
|
31
98
|
// shared/src/handoff.ts
|
|
32
|
-
import { z as
|
|
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 =
|
|
44
|
-
var NoCodeText = (max) =>
|
|
45
|
-
var HandoffSummarySchema =
|
|
46
|
-
files_modified:
|
|
47
|
-
key_decisions:
|
|
48
|
-
verification_command:
|
|
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
|
-
|
|
51
|
-
|
|
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 =
|
|
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 =
|
|
165
|
+
var TaskEventSchema = z4.enum(TASK_EVENTS);
|
|
96
166
|
var LOCK_LEASE_MS = 30 * 60 * 1e3;
|
|
97
|
-
var TaskSchema =
|
|
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:
|
|
104
|
-
prompt_instruction:
|
|
173
|
+
title: z4.string().min(1).max(200),
|
|
174
|
+
prompt_instruction: z4.string().min(1).max(8e3),
|
|
105
175
|
status: TaskStatusSchema,
|
|
106
|
-
requires_approval:
|
|
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:
|
|
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:
|
|
115
|
-
revision_count:
|
|
116
|
-
blocker_reason:
|
|
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:
|
|
119
|
-
depends_on:
|
|
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 =
|
|
195
|
+
var TaskSummarySchema = z4.object({
|
|
124
196
|
id: IdSchema,
|
|
125
|
-
title:
|
|
126
|
-
depends_on:
|
|
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:
|
|
203
|
+
revision: z4.boolean().optional()
|
|
130
204
|
});
|
|
131
205
|
var BLOCKER_CATEGORIES = [
|
|
132
206
|
"missing_env",
|
|
@@ -135,144 +209,160 @@ var BLOCKER_CATEGORIES = [
|
|
|
135
209
|
"dependency_issue",
|
|
136
210
|
"other"
|
|
137
211
|
];
|
|
138
|
-
var BlockerCategorySchema =
|
|
212
|
+
var BlockerCategorySchema = z4.enum(BLOCKER_CATEGORIES);
|
|
139
213
|
|
|
140
214
|
// shared/src/api.ts
|
|
141
|
-
var WorkspaceSchema =
|
|
215
|
+
var WorkspaceSchema = z5.object({
|
|
142
216
|
id: IdSchema,
|
|
143
|
-
name:
|
|
144
|
-
slug:
|
|
145
|
-
role:
|
|
217
|
+
name: z5.string(),
|
|
218
|
+
slug: z5.string(),
|
|
219
|
+
role: z5.string()
|
|
146
220
|
});
|
|
147
|
-
var ProjectSchema =
|
|
221
|
+
var ProjectSchema = z5.object({
|
|
148
222
|
id: IdSchema,
|
|
149
223
|
workspace_id: IdSchema,
|
|
150
|
-
name:
|
|
151
|
-
detected_stack:
|
|
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 =
|
|
230
|
+
var EpicSchema = z5.object({
|
|
157
231
|
id: IdSchema,
|
|
158
232
|
workspace_id: IdSchema,
|
|
159
233
|
project_id: IdSchema,
|
|
160
|
-
title:
|
|
161
|
-
description:
|
|
162
|
-
template_used:
|
|
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
|
-
|
|
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:
|
|
247
|
+
blocked_by: z5.array(IdSchema),
|
|
172
248
|
/** TODO/REVISION_REQUESTED dan semua dependensinya DONE: bisa diklaim agen sekarang. */
|
|
173
|
-
is_ready:
|
|
249
|
+
is_ready: z5.boolean()
|
|
174
250
|
});
|
|
175
|
-
var AgentPersonaSchema =
|
|
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:
|
|
257
|
+
rules: z5.array(z5.string()),
|
|
258
|
+
repos: z5.array(z5.string()),
|
|
182
259
|
created_at: IsoDateTimeSchema,
|
|
183
260
|
updated_at: IsoDateTimeSchema
|
|
184
261
|
});
|
|
185
|
-
var ApiKeySchema =
|
|
262
|
+
var ApiKeySchema = z5.object({
|
|
186
263
|
id: IdSchema,
|
|
187
264
|
workspace_id: IdSchema,
|
|
188
265
|
project_id: IdSchema.nullable(),
|
|
189
|
-
name:
|
|
190
|
-
prefix:
|
|
266
|
+
name: z5.string(),
|
|
267
|
+
prefix: z5.string(),
|
|
191
268
|
last_used_at: IsoDateTimeSchema.nullable(),
|
|
192
269
|
revoked_at: IsoDateTimeSchema.nullable(),
|
|
193
270
|
created_at: IsoDateTimeSchema
|
|
194
271
|
});
|
|
195
272
|
var ACTIVITY_ACTORS = ["human", "agent", "system"];
|
|
196
|
-
var ActivityLogSchema =
|
|
273
|
+
var ActivityLogSchema = z5.object({
|
|
197
274
|
id: IdSchema,
|
|
198
275
|
workspace_id: IdSchema,
|
|
199
276
|
project_id: IdSchema.nullable(),
|
|
200
277
|
task_id: IdSchema.nullable(),
|
|
201
|
-
event_type:
|
|
202
|
-
actor:
|
|
203
|
-
persona_alias:
|
|
278
|
+
event_type: z5.string(),
|
|
279
|
+
actor: z5.enum(ACTIVITY_ACTORS),
|
|
280
|
+
persona_alias: z5.string().nullable(),
|
|
204
281
|
/** Nama agen + repo untuk event agen (mis. `claude-code@web`), null untuk manusia/sistem. */
|
|
205
|
-
agent_name:
|
|
206
|
-
duration_ms:
|
|
207
|
-
metadata:
|
|
282
|
+
agent_name: z5.string().nullable(),
|
|
283
|
+
duration_ms: z5.number().int().nullable(),
|
|
284
|
+
metadata: z5.record(z5.string(), z5.unknown()).nullable(),
|
|
208
285
|
created_at: IsoDateTimeSchema
|
|
209
286
|
});
|
|
210
|
-
var ProjectMetricsSchema =
|
|
211
|
-
handoffs_7d:
|
|
212
|
-
revisions_7d:
|
|
213
|
-
blockers_7d:
|
|
214
|
-
avg_task_duration_ms:
|
|
287
|
+
var ProjectMetricsSchema = z5.object({
|
|
288
|
+
handoffs_7d: z5.number().int(),
|
|
289
|
+
revisions_7d: z5.number().int(),
|
|
290
|
+
blockers_7d: z5.number().int(),
|
|
291
|
+
avg_task_duration_ms: z5.number().int().nullable()
|
|
215
292
|
});
|
|
216
|
-
var CreateProjectInput =
|
|
217
|
-
name:
|
|
218
|
-
detected_stack:
|
|
293
|
+
var CreateProjectInput = z5.object({
|
|
294
|
+
name: z5.string().trim().min(1).max(120),
|
|
295
|
+
detected_stack: z5.array(z5.string().min(1).max(40)).max(20).default([])
|
|
219
296
|
});
|
|
220
|
-
var UpdateProjectInput =
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
297
|
+
var UpdateProjectInput = z5.object({
|
|
298
|
+
name: z5.string().trim().min(1).max(120).optional(),
|
|
299
|
+
detected_stack: z5.array(z5.string().min(1).max(40)).max(20).optional()
|
|
300
|
+
});
|
|
301
|
+
var CreateEpicInput = z5.object({
|
|
302
|
+
title: z5.string().trim().min(1).max(200),
|
|
303
|
+
description: z5.string().max(4e3).nullish(),
|
|
304
|
+
template_used: z5.string().max(80).nullish()
|
|
225
305
|
});
|
|
226
306
|
var UpdateEpicInput = CreateEpicInput.partial();
|
|
227
|
-
var CreateTaskInput =
|
|
228
|
-
title:
|
|
229
|
-
prompt_instruction:
|
|
307
|
+
var CreateTaskInput = z5.object({
|
|
308
|
+
title: z5.string().trim().min(1).max(200),
|
|
309
|
+
prompt_instruction: z5.string().min(1).max(8e3),
|
|
230
310
|
target_repo: RepoNameSchema.nullish(),
|
|
231
311
|
role: RoleSchema.nullish(),
|
|
232
|
-
|
|
233
|
-
|
|
312
|
+
/** Persona penanggung jawab; role task otomatis mengikuti role persona. */
|
|
313
|
+
persona_id: IdSchema.nullish(),
|
|
314
|
+
requires_approval: z5.boolean().default(false),
|
|
315
|
+
depends_on: z5.array(IdSchema).max(10).default([]),
|
|
234
316
|
/** Task buatan manusia langsung TODO; DRAFT bila ingin ditinjau bersama rencana agen. */
|
|
235
|
-
status:
|
|
317
|
+
status: z5.enum(["DRAFT", "TODO"]).default("TODO")
|
|
236
318
|
});
|
|
237
|
-
var UpdateTaskInput =
|
|
238
|
-
title:
|
|
239
|
-
prompt_instruction:
|
|
319
|
+
var UpdateTaskInput = z5.object({
|
|
320
|
+
title: z5.string().trim().min(1).max(200).optional(),
|
|
321
|
+
prompt_instruction: z5.string().min(1).max(8e3).optional(),
|
|
240
322
|
target_repo: RepoNameSchema.nullable().optional(),
|
|
241
323
|
role: RoleSchema.nullable().optional(),
|
|
242
|
-
|
|
324
|
+
persona_id: IdSchema.nullable().optional(),
|
|
325
|
+
requires_approval: z5.boolean().optional(),
|
|
243
326
|
assignee_id: IdSchema.nullable().optional(),
|
|
244
|
-
position:
|
|
327
|
+
position: z5.number().finite().optional(),
|
|
245
328
|
/** Hanya boleh false: manusia menandai task stale sudah diperiksa ulang. */
|
|
246
|
-
is_stale:
|
|
247
|
-
});
|
|
248
|
-
var SetDependenciesInput =
|
|
249
|
-
depends_on:
|
|
250
|
-
});
|
|
251
|
-
var TaskActionInput =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
event:
|
|
257
|
-
feedback:
|
|
329
|
+
is_stale: z5.literal(false).optional()
|
|
330
|
+
});
|
|
331
|
+
var SetDependenciesInput = z5.object({
|
|
332
|
+
depends_on: z5.array(IdSchema).max(10)
|
|
333
|
+
});
|
|
334
|
+
var TaskActionInput = z5.discriminatedUnion("event", [
|
|
335
|
+
z5.object({ event: z5.literal("approve_plan") }),
|
|
336
|
+
z5.object({ event: z5.literal("return_to_draft") }),
|
|
337
|
+
z5.object({ event: z5.literal("approve") }),
|
|
338
|
+
z5.object({
|
|
339
|
+
event: z5.literal("request_revision"),
|
|
340
|
+
feedback: z5.string().trim().min(5).max(2e3)
|
|
258
341
|
}),
|
|
259
|
-
|
|
342
|
+
z5.object({ event: z5.literal("unblock") })
|
|
260
343
|
]);
|
|
261
|
-
var PersonaInput =
|
|
344
|
+
var PersonaInput = z5.object({
|
|
262
345
|
alias: AgentAliasSchema,
|
|
263
346
|
role: RoleSchema,
|
|
264
|
-
rules:
|
|
347
|
+
rules: z5.array(z5.string().trim().min(1).max(300)).max(30).default([]),
|
|
348
|
+
repos: z5.array(RepoNameSchema).max(10).default([]),
|
|
265
349
|
project_id: IdSchema.nullish()
|
|
266
350
|
});
|
|
267
|
-
var UpdatePersonaInput =
|
|
268
|
-
|
|
269
|
-
|
|
351
|
+
var UpdatePersonaInput = z5.object({
|
|
352
|
+
alias: AgentAliasSchema.optional(),
|
|
353
|
+
role: RoleSchema.optional(),
|
|
354
|
+
rules: z5.array(z5.string().trim().min(1).max(300)).max(30).optional(),
|
|
355
|
+
repos: z5.array(RepoNameSchema).max(10).optional(),
|
|
270
356
|
project_id: IdSchema.nullish()
|
|
271
357
|
});
|
|
272
|
-
var
|
|
358
|
+
var CreateApiKeyInput = z5.object({
|
|
359
|
+
name: z5.string().trim().min(1).max(80),
|
|
360
|
+
project_id: IdSchema.nullish()
|
|
361
|
+
});
|
|
362
|
+
var CreateApiKeyOutput = z5.object({
|
|
273
363
|
api_key: ApiKeySchema,
|
|
274
364
|
/** Kunci mentah. Hanya dikirim sekali, saat dibuat. */
|
|
275
|
-
secret:
|
|
365
|
+
secret: z5.string()
|
|
276
366
|
});
|
|
277
367
|
var AGENT_HEADERS = {
|
|
278
368
|
project: "x-catenext-project",
|
|
@@ -280,43 +370,45 @@ var AGENT_HEADERS = {
|
|
|
280
370
|
agent: "x-catenext-agent"
|
|
281
371
|
};
|
|
282
372
|
var API_KEY_PREFIX = "ctnx_";
|
|
283
|
-
var ReleaseTaskInput =
|
|
284
|
-
var SyncSkillsInput =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
373
|
+
var ReleaseTaskInput = z5.object({ task_id: IdSchema, lease_id: IdSchema.optional() });
|
|
374
|
+
var SyncSkillsInput = z5.object({
|
|
375
|
+
revision: CommitShaSchema.optional(),
|
|
376
|
+
previous_revision: CommitShaSchema.nullable().optional(),
|
|
377
|
+
skills: z5.array(
|
|
378
|
+
z5.object({
|
|
379
|
+
name: z5.string().min(1).max(48),
|
|
380
|
+
when_to_use: z5.string().min(1).max(160)
|
|
289
381
|
})
|
|
290
382
|
).max(100)
|
|
291
383
|
});
|
|
292
|
-
var VerifyOutput =
|
|
293
|
-
token_valid:
|
|
384
|
+
var VerifyOutput = z5.object({
|
|
385
|
+
token_valid: z5.literal(true),
|
|
294
386
|
workspace_id: IdSchema,
|
|
295
|
-
project:
|
|
387
|
+
project: z5.object({ id: IdSchema, name: z5.string() }),
|
|
296
388
|
repo_name: RepoNameSchema
|
|
297
389
|
});
|
|
298
|
-
var ApiErrorSchema =
|
|
299
|
-
error:
|
|
300
|
-
code:
|
|
301
|
-
message:
|
|
302
|
-
details:
|
|
390
|
+
var ApiErrorSchema = z5.object({
|
|
391
|
+
error: z5.object({
|
|
392
|
+
code: z5.string(),
|
|
393
|
+
message: z5.string(),
|
|
394
|
+
details: z5.unknown().optional()
|
|
303
395
|
})
|
|
304
396
|
});
|
|
305
397
|
|
|
306
398
|
// shared/src/config.ts
|
|
307
|
-
import { z as
|
|
399
|
+
import { z as z6 } from "zod";
|
|
308
400
|
var CONFIG_SCHEMA_VERSION = 1;
|
|
309
|
-
var CatenextConfigSchema =
|
|
310
|
-
schema_version:
|
|
401
|
+
var CatenextConfigSchema = z6.object({
|
|
402
|
+
schema_version: z6.number().int().positive(),
|
|
311
403
|
project_id: IdSchema,
|
|
312
404
|
repo_name: RepoNameSchema,
|
|
313
|
-
stack:
|
|
405
|
+
stack: z6.array(z6.string().min(1).max(40)).max(20).default([]),
|
|
314
406
|
/** URL Catenext Cloud API; kosong = default bawaan CLI. */
|
|
315
|
-
api_url:
|
|
316
|
-
overrides:
|
|
407
|
+
api_url: z6.url().optional(),
|
|
408
|
+
overrides: z6.object({
|
|
317
409
|
default_agent_alias: AgentAliasSchema.optional(),
|
|
318
410
|
default_role: RoleSchema.optional(),
|
|
319
|
-
extra_rules:
|
|
411
|
+
extra_rules: z6.array(z6.string().min(1).max(300)).max(20).optional()
|
|
320
412
|
}).optional()
|
|
321
413
|
});
|
|
322
414
|
function checkConfigCompatibility(schemaVersion, supported = CONFIG_SCHEMA_VERSION) {
|
|
@@ -378,50 +470,99 @@ function findCycle(edges) {
|
|
|
378
470
|
}
|
|
379
471
|
|
|
380
472
|
// shared/src/device.ts
|
|
381
|
-
import { z as
|
|
382
|
-
var UserCodeSchema =
|
|
383
|
-
var DeviceCodeInput =
|
|
473
|
+
import { z as z7 } from "zod";
|
|
474
|
+
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)}`);
|
|
475
|
+
var DeviceCodeInput = z7.object({
|
|
384
476
|
/** Nama mesin/klien yang ditampilkan saat menyetujui, mis. "catenext CLI @ macbook". */
|
|
385
|
-
client_name:
|
|
477
|
+
client_name: z7.string().trim().min(1).max(80),
|
|
386
478
|
/**
|
|
387
479
|
* Public key X25519 sementara milik CLI (SPKI DER, base64url). API key hasil persetujuan
|
|
388
480
|
* dienkripsi ke kunci ini, jadi baris database saja tidak cukup untuk membacanya.
|
|
389
481
|
*/
|
|
390
|
-
public_key:
|
|
391
|
-
});
|
|
392
|
-
var DeviceCodeOutput =
|
|
393
|
-
device_code:
|
|
394
|
-
user_code:
|
|
395
|
-
verification_uri:
|
|
396
|
-
verification_uri_complete:
|
|
397
|
-
expires_in:
|
|
398
|
-
interval:
|
|
399
|
-
});
|
|
400
|
-
var DeviceTokenInput =
|
|
401
|
-
var DeviceTokenOutput =
|
|
482
|
+
public_key: z7.string().min(40).max(200)
|
|
483
|
+
});
|
|
484
|
+
var DeviceCodeOutput = z7.object({
|
|
485
|
+
device_code: z7.string(),
|
|
486
|
+
user_code: z7.string(),
|
|
487
|
+
verification_uri: z7.string(),
|
|
488
|
+
verification_uri_complete: z7.string(),
|
|
489
|
+
expires_in: z7.number().int(),
|
|
490
|
+
interval: z7.number().int()
|
|
491
|
+
});
|
|
492
|
+
var DeviceTokenInput = z7.object({ device_code: z7.string().min(20).max(200) });
|
|
493
|
+
var DeviceTokenOutput = z7.object({
|
|
402
494
|
/** API key terenkripsi ke public_key CLI: <pub efemeral>.<iv>.<tag>.<ciphertext> (base64url). */
|
|
403
|
-
encrypted_key:
|
|
495
|
+
encrypted_key: z7.string(),
|
|
404
496
|
workspace_id: IdSchema,
|
|
405
497
|
project_id: IdSchema.nullable()
|
|
406
498
|
});
|
|
407
|
-
var DeviceLookupOutput =
|
|
408
|
-
user_code:
|
|
409
|
-
client_name:
|
|
410
|
-
status:
|
|
411
|
-
expires_at:
|
|
499
|
+
var DeviceLookupOutput = z7.object({
|
|
500
|
+
user_code: z7.string(),
|
|
501
|
+
client_name: z7.string(),
|
|
502
|
+
status: z7.enum(["pending", "approved", "denied"]),
|
|
503
|
+
expires_at: z7.string()
|
|
412
504
|
});
|
|
413
|
-
var DeviceApproveInput =
|
|
505
|
+
var DeviceApproveInput = z7.object({
|
|
414
506
|
user_code: UserCodeSchema,
|
|
415
|
-
approve:
|
|
507
|
+
approve: z7.boolean(),
|
|
416
508
|
/** Batasi API key ke satu proyek (disarankan). null = semua proyek di workspace. */
|
|
417
509
|
project_id: IdSchema.nullish()
|
|
418
510
|
});
|
|
419
511
|
|
|
420
|
-
// shared/src/
|
|
512
|
+
// shared/src/documents.ts
|
|
421
513
|
import { z as z8 } from "zod";
|
|
514
|
+
var DOCUMENT_KINDS = [
|
|
515
|
+
"blueprint",
|
|
516
|
+
"erd",
|
|
517
|
+
"architecture",
|
|
518
|
+
"api_contract",
|
|
519
|
+
"decision",
|
|
520
|
+
"runbook",
|
|
521
|
+
"other"
|
|
522
|
+
];
|
|
523
|
+
var DocumentKindSchema = z8.enum(DOCUMENT_KINDS);
|
|
524
|
+
var DOCUMENT_LIMITS = {
|
|
525
|
+
/** Karakter per dokumen (~15k token). Lebih dari itu: pecah per bagian. */
|
|
526
|
+
content: 6e4,
|
|
527
|
+
perProject: 50
|
|
528
|
+
};
|
|
529
|
+
var DocumentSlugSchema = SlugSchema.max(64);
|
|
530
|
+
var DocumentIndexEntrySchema = z8.object({
|
|
531
|
+
slug: DocumentSlugSchema,
|
|
532
|
+
title: z8.string(),
|
|
533
|
+
kind: DocumentKindSchema,
|
|
534
|
+
version: z8.number().int().min(1),
|
|
535
|
+
/** "human:<nama>" atau nama agen (mis. claude-code@be). */
|
|
536
|
+
updated_by: z8.string(),
|
|
537
|
+
updated_at: IsoDateTimeSchema,
|
|
538
|
+
/** Panjang isi dalam karakter, agar agen bisa menimbang biaya membaca. */
|
|
539
|
+
size: z8.number().int().min(0)
|
|
540
|
+
});
|
|
541
|
+
var ProjectDocumentSchema = DocumentIndexEntrySchema.extend({
|
|
542
|
+
content: z8.string()
|
|
543
|
+
});
|
|
544
|
+
var SaveDocumentInput = z8.object({
|
|
545
|
+
slug: DocumentSlugSchema,
|
|
546
|
+
title: z8.string().trim().min(1).max(120),
|
|
547
|
+
kind: DocumentKindSchema,
|
|
548
|
+
content: z8.string().trim().min(1).max(DOCUMENT_LIMITS.content),
|
|
549
|
+
/**
|
|
550
|
+
* Versi yang dibaca penulis. 0 = dokumen baru. Bila versi di server sudah berubah, simpan
|
|
551
|
+
* ditolak (document_version_conflict) agar sesi lain tidak tertimpa diam-diam.
|
|
552
|
+
*/
|
|
553
|
+
expected_version: z8.number().int().min(0).optional()
|
|
554
|
+
});
|
|
555
|
+
var GetDocumentInput = z8.object({ slug: DocumentSlugSchema });
|
|
556
|
+
var SaveDocumentOutput = z8.object({
|
|
557
|
+
document: DocumentIndexEntrySchema,
|
|
558
|
+
created: z8.boolean()
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// shared/src/mcp-tools.ts
|
|
562
|
+
import { z as z10 } from "zod";
|
|
422
563
|
|
|
423
564
|
// shared/src/skill.ts
|
|
424
|
-
import { z as
|
|
565
|
+
import { z as z9 } from "zod";
|
|
425
566
|
var SKILL_LIMITS = {
|
|
426
567
|
maxWords: 500,
|
|
427
568
|
maxWhenToUseLength: 160,
|
|
@@ -429,9 +570,9 @@ var SKILL_LIMITS = {
|
|
|
429
570
|
maxCodeBlockLines: 15
|
|
430
571
|
};
|
|
431
572
|
var SkillNameSchema = SlugSchema.max(48);
|
|
432
|
-
var SkillFrontmatterSchema =
|
|
573
|
+
var SkillFrontmatterSchema = z9.object({
|
|
433
574
|
name: SkillNameSchema,
|
|
434
|
-
when_to_use:
|
|
575
|
+
when_to_use: z9.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
|
|
435
576
|
updated_at: IsoDateTimeSchema
|
|
436
577
|
});
|
|
437
578
|
function longestCodeBlockLines(markdown) {
|
|
@@ -443,117 +584,213 @@ function longestCodeBlockLines(markdown) {
|
|
|
443
584
|
}
|
|
444
585
|
return longest;
|
|
445
586
|
}
|
|
446
|
-
var SkillContentSchema =
|
|
587
|
+
var SkillContentSchema = z9.string().min(1).refine((s) => countWords(s) <= SKILL_LIMITS.maxWords, {
|
|
447
588
|
message: `Skill maksimal ${SKILL_LIMITS.maxWords} kata`
|
|
448
589
|
}).refine((s) => longestCodeBlockLines(s) <= SKILL_LIMITS.maxCodeBlockLines, {
|
|
449
590
|
message: `Blok kode maksimal ${SKILL_LIMITS.maxCodeBlockLines} baris; rujuk path file, jangan menyalin kode`
|
|
450
591
|
});
|
|
451
|
-
var SkillIndexEntrySchema =
|
|
592
|
+
var SkillIndexEntrySchema = z9.object({
|
|
452
593
|
name: SkillNameSchema,
|
|
453
|
-
when_to_use:
|
|
594
|
+
when_to_use: z9.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
|
|
454
595
|
repo_name: RepoNameSchema
|
|
455
596
|
});
|
|
597
|
+
function skillPath(name) {
|
|
598
|
+
return `.catenext/skills/${SkillNameSchema.parse(name)}.md`;
|
|
599
|
+
}
|
|
456
600
|
|
|
457
601
|
// shared/src/mcp-tools.ts
|
|
458
602
|
var PersonaFilter = {
|
|
459
603
|
agent_alias: AgentAliasSchema.optional(),
|
|
460
604
|
role: RoleSchema.optional()
|
|
461
605
|
};
|
|
462
|
-
var
|
|
606
|
+
var PersonaReposSchema = z10.array(RepoNameSchema).max(10);
|
|
607
|
+
var PersonaSchema = z10.object({
|
|
463
608
|
alias: AgentAliasSchema,
|
|
464
609
|
role: RoleSchema,
|
|
465
|
-
rules:
|
|
610
|
+
rules: z10.array(z10.string().min(1).max(300)).max(30),
|
|
611
|
+
repos: PersonaReposSchema.default([])
|
|
466
612
|
});
|
|
467
|
-
var DependencyHandoffSchema =
|
|
613
|
+
var DependencyHandoffSchema = z10.object({
|
|
468
614
|
task_id: IdSchema,
|
|
469
|
-
title:
|
|
470
|
-
handoff_summary: HandoffSummarySchema
|
|
615
|
+
title: z10.string(),
|
|
616
|
+
handoff_summary: HandoffSummarySchema,
|
|
617
|
+
integrated_commit: z10.object({ branch: z10.string(), sha: CommitShaSchema }).optional()
|
|
471
618
|
});
|
|
472
|
-
var GetProjectContextInput =
|
|
473
|
-
var GetProjectContextOutput =
|
|
474
|
-
project:
|
|
619
|
+
var GetProjectContextInput = z10.object({ ...PersonaFilter, lease_id: IdSchema.optional() });
|
|
620
|
+
var GetProjectContextOutput = z10.object({
|
|
621
|
+
project: z10.object({
|
|
475
622
|
id: IdSchema,
|
|
476
|
-
name:
|
|
623
|
+
name: z10.string(),
|
|
477
624
|
repo_name: RepoNameSchema,
|
|
478
|
-
stack:
|
|
625
|
+
stack: z10.array(z10.string())
|
|
479
626
|
}),
|
|
480
627
|
/** Aturan keras untuk agen (mis. jangan mengedit config MCP). Statis di atas agar ramah cache. */
|
|
481
|
-
directives:
|
|
628
|
+
directives: z10.array(z10.string()),
|
|
482
629
|
persona: PersonaSchema.optional(),
|
|
483
|
-
epic_summary:
|
|
630
|
+
epic_summary: z10.string().max(1e3).optional(),
|
|
484
631
|
/** Tier 1: indeks skill saja, isi lengkap lewat load_skill. */
|
|
485
|
-
skills:
|
|
632
|
+
skills: z10.array(SkillIndexEntrySchema),
|
|
633
|
+
skill_revision: CommitShaSchema.optional(),
|
|
486
634
|
/**
|
|
487
635
|
* Handoff dari dependensi langsung task aktif (dependency-scoped context). Jika belum ada
|
|
488
636
|
* task aktif: handoff dependensi task yang siap diklaim (maks. 5).
|
|
489
637
|
*/
|
|
490
|
-
recent_handoffs:
|
|
638
|
+
recent_handoffs: z10.array(DependencyHandoffSchema),
|
|
639
|
+
/** Repo yang dikenal proyek, agar orchestrator tahu ke mana task bisa diarahkan. */
|
|
640
|
+
project_repos: z10.array(RepoNameSchema).default([]),
|
|
641
|
+
/** Indeks dokumen proyek di Cloud (blueprint, ERD, ...); isi lewat get_document. */
|
|
642
|
+
documents: z10.array(DocumentIndexEntrySchema).default([])
|
|
643
|
+
});
|
|
644
|
+
var GetProjectBoardInput = z10.object({
|
|
645
|
+
epic_id: IdSchema.optional(),
|
|
646
|
+
/** Tanpa filter: semua status. */
|
|
647
|
+
status: z10.array(TaskStatusSchema).max(7).optional(),
|
|
648
|
+
limit: z10.number().int().min(1).max(200).default(100)
|
|
649
|
+
});
|
|
650
|
+
var BoardTaskSchema = z10.object({
|
|
651
|
+
id: IdSchema,
|
|
652
|
+
title: z10.string(),
|
|
653
|
+
epic_id: IdSchema,
|
|
654
|
+
status: TaskStatusSchema,
|
|
655
|
+
target_repo: RepoNameSchema.nullable(),
|
|
656
|
+
role: RoleSchema.nullable(),
|
|
657
|
+
persona: AgentAliasSchema.nullable(),
|
|
658
|
+
depends_on: z10.array(IdSchema),
|
|
659
|
+
/** TODO/REVISION_REQUESTED dengan semua dependensi DONE. */
|
|
660
|
+
is_ready: z10.boolean(),
|
|
661
|
+
is_stale: z10.boolean(),
|
|
662
|
+
revision_count: z10.number().int().min(0),
|
|
663
|
+
/** Repo yang sedang memegang lease (IN_PROGRESS). */
|
|
664
|
+
locked_by_repo: RepoNameSchema.nullable(),
|
|
665
|
+
blocker_reason: z10.string().nullable()
|
|
491
666
|
});
|
|
492
|
-
var
|
|
667
|
+
var GetProjectBoardOutput = z10.object({
|
|
668
|
+
epics: z10.array(
|
|
669
|
+
z10.object({
|
|
670
|
+
id: IdSchema,
|
|
671
|
+
title: z10.string(),
|
|
672
|
+
counts: z10.record(z10.string(), z10.number().int())
|
|
673
|
+
})
|
|
674
|
+
),
|
|
675
|
+
/** Repo yang dikenal proyek (dari task, skill, dan persona) beserta persona pemegangnya. */
|
|
676
|
+
repos: z10.array(z10.object({ repo: RepoNameSchema, personas: z10.array(AgentAliasSchema) })),
|
|
677
|
+
personas: z10.array(PersonaSchema),
|
|
678
|
+
tasks: z10.array(BoardTaskSchema),
|
|
679
|
+
truncated: z10.boolean()
|
|
680
|
+
});
|
|
681
|
+
var GetReadyTasksInput = z10.object({
|
|
493
682
|
...PersonaFilter,
|
|
494
|
-
|
|
683
|
+
lease_id: IdSchema.optional(),
|
|
684
|
+
limit: z10.number().int().min(1).max(50).default(10)
|
|
495
685
|
});
|
|
496
|
-
var GetReadyTasksOutput =
|
|
497
|
-
tasks:
|
|
686
|
+
var GetReadyTasksOutput = z10.object({
|
|
687
|
+
tasks: z10.array(TaskSummarySchema)
|
|
498
688
|
});
|
|
499
|
-
var ClaimTaskInput =
|
|
500
|
-
|
|
689
|
+
var ClaimTaskInput = z10.object({
|
|
690
|
+
worktree: z10.object({
|
|
691
|
+
session_id: IdSchema,
|
|
692
|
+
branch: z10.string().min(1).max(255).regex(/^[a-zA-Z0-9_./-]+$/).refine((s) => s !== "HEAD" && !s.startsWith("-") && !s.includes(".."))
|
|
693
|
+
}).optional(),
|
|
694
|
+
task_id: IdSchema,
|
|
695
|
+
/** Alias persona yang sedang dipakai agen. Task milik persona lain ditolak. */
|
|
696
|
+
agent_alias: AgentAliasSchema.optional()
|
|
501
697
|
});
|
|
502
|
-
var ClaimTaskOutput =
|
|
503
|
-
task:
|
|
698
|
+
var ClaimTaskOutput = z10.object({
|
|
699
|
+
task: z10.object({
|
|
504
700
|
id: IdSchema,
|
|
505
|
-
title:
|
|
506
|
-
prompt_instruction:
|
|
507
|
-
status:
|
|
701
|
+
title: z10.string(),
|
|
702
|
+
prompt_instruction: z10.string(),
|
|
703
|
+
status: z10.literal("IN_PROGRESS"),
|
|
508
704
|
role: RoleSchema.optional(),
|
|
509
705
|
target_repo: RepoNameSchema.optional(),
|
|
510
|
-
revision_count:
|
|
706
|
+
revision_count: z10.number().int().min(0)
|
|
511
707
|
}),
|
|
708
|
+
/** Persona penanggung jawab task (atau persona agen): ikuti aturan dan batas wilayahnya. */
|
|
709
|
+
persona: PersonaSchema.optional(),
|
|
512
710
|
lease_expires_at: IsoDateTimeSchema,
|
|
513
|
-
|
|
711
|
+
lease_id: IdSchema.optional(),
|
|
712
|
+
dependencies: z10.array(DependencyHandoffSchema),
|
|
514
713
|
/** Diisi bila task diambil dari REVISION_REQUESTED. */
|
|
515
|
-
revision:
|
|
516
|
-
review_feedback:
|
|
714
|
+
revision: z10.object({
|
|
715
|
+
review_feedback: z10.string(),
|
|
517
716
|
previous_handoff: HandoffSummarySchema.nullable()
|
|
518
717
|
}).optional(),
|
|
519
718
|
/** Peringatan bila branch lokal berbeda dari git_branch handoff dependensi. */
|
|
520
|
-
warnings:
|
|
719
|
+
warnings: z10.array(z10.string()).default([])
|
|
521
720
|
});
|
|
522
|
-
var CompleteHandoffInput =
|
|
721
|
+
var CompleteHandoffInput = z10.object({
|
|
722
|
+
lease_id: IdSchema.optional(),
|
|
523
723
|
task_id: IdSchema,
|
|
524
724
|
handoff_summary: HandoffSummarySchema
|
|
525
725
|
});
|
|
526
|
-
var CompleteHandoffOutput =
|
|
726
|
+
var CompleteHandoffOutput = z10.object({
|
|
527
727
|
task_id: IdSchema,
|
|
528
|
-
status:
|
|
529
|
-
unlocked_task_ids:
|
|
728
|
+
status: z10.enum(["DONE", "NEEDS_REVIEW"]),
|
|
729
|
+
unlocked_task_ids: z10.array(IdSchema),
|
|
530
730
|
/** Mis. saran mereset sesi chat (1 Task = 1 Fresh Session). */
|
|
531
|
-
next_step_hint:
|
|
731
|
+
next_step_hint: z10.string()
|
|
532
732
|
});
|
|
533
|
-
var ReportBlockerInput =
|
|
733
|
+
var ReportBlockerInput = z10.object({
|
|
734
|
+
lease_id: IdSchema.optional(),
|
|
534
735
|
task_id: IdSchema,
|
|
535
736
|
category: BlockerCategorySchema,
|
|
536
|
-
reason:
|
|
737
|
+
reason: z10.string().min(10).max(1e3)
|
|
738
|
+
});
|
|
739
|
+
var ReportBlockerOutput = z10.object({
|
|
740
|
+
task_id: IdSchema,
|
|
741
|
+
status: z10.literal("BLOCKED")
|
|
742
|
+
});
|
|
743
|
+
var MANAGE_TASK_ACTIONS = ["request_revision", "assign"];
|
|
744
|
+
var ManageTaskInput = z10.object({
|
|
745
|
+
action: z10.enum(MANAGE_TASK_ACTIONS),
|
|
746
|
+
task_id: IdSchema,
|
|
747
|
+
/** Wajib untuk request_revision: apa yang harus diperbaiki (feedback manusia/orchestrator). */
|
|
748
|
+
feedback: z10.string().trim().min(5).max(2e3).optional(),
|
|
749
|
+
/** Persona penanggung jawab baru. null = lepas persona (task diambil berdasarkan role). */
|
|
750
|
+
agent_alias: AgentAliasSchema.nullable().optional(),
|
|
751
|
+
/** Role task tanpa persona tertentu. Diabaikan bila agent_alias diisi (role ikut persona). */
|
|
752
|
+
role: RoleSchema.nullable().optional()
|
|
753
|
+
}).superRefine((v, ctx) => {
|
|
754
|
+
if (v.action === "request_revision" && !v.feedback) {
|
|
755
|
+
ctx.addIssue({
|
|
756
|
+
code: "custom",
|
|
757
|
+
path: ["feedback"],
|
|
758
|
+
message: "request_revision butuh feedback: apa yang harus diperbaiki."
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
if (v.action === "assign" && v.agent_alias === void 0 && v.role === void 0) {
|
|
762
|
+
ctx.addIssue({
|
|
763
|
+
code: "custom",
|
|
764
|
+
path: ["agent_alias"],
|
|
765
|
+
message: "assign butuh agent_alias atau role."
|
|
766
|
+
});
|
|
767
|
+
}
|
|
537
768
|
});
|
|
538
|
-
var
|
|
769
|
+
var ManageTaskOutput = z10.object({
|
|
539
770
|
task_id: IdSchema,
|
|
540
|
-
status:
|
|
771
|
+
status: TaskStatusSchema,
|
|
772
|
+
persona: AgentAliasSchema.nullable(),
|
|
773
|
+
role: RoleSchema.nullable(),
|
|
774
|
+
revision_count: z10.number().int().min(0),
|
|
775
|
+
stale_task_ids: z10.array(IdSchema)
|
|
541
776
|
});
|
|
542
777
|
var MAX_TASKS_PER_PLAN = 30;
|
|
543
|
-
var PlanRefSchema =
|
|
544
|
-
var PlannedTaskSchema =
|
|
778
|
+
var PlanRefSchema = z10.string().min(1).max(40).regex(/^[a-z0-9][a-z0-9_-]*$/, "ref harus huruf kecil, angka, '-' atau '_'");
|
|
779
|
+
var PlannedTaskSchema = z10.object({
|
|
545
780
|
ref: PlanRefSchema,
|
|
546
|
-
title:
|
|
547
|
-
prompt_instruction:
|
|
781
|
+
title: z10.string().min(1).max(200),
|
|
782
|
+
prompt_instruction: z10.string().min(1).max(8e3),
|
|
548
783
|
/** Berisi ref task lain dalam rencana ini, atau UUID task yang sudah ada. */
|
|
549
|
-
depends_on:
|
|
784
|
+
depends_on: z10.array(z10.union([PlanRefSchema, IdSchema])).max(10).default([]),
|
|
550
785
|
target_repo: RepoNameSchema.optional(),
|
|
551
786
|
role: RoleSchema.optional(),
|
|
552
|
-
|
|
787
|
+
/** Alias persona penanggung jawab (lihat list_personas). Role task mengikuti persona ini. */
|
|
788
|
+
persona: AgentAliasSchema.optional(),
|
|
789
|
+
requires_approval: z10.boolean().default(false)
|
|
553
790
|
});
|
|
554
|
-
var CreateTasksInput =
|
|
791
|
+
var CreateTasksInput = z10.object({
|
|
555
792
|
epic_id: IdSchema,
|
|
556
|
-
tasks:
|
|
793
|
+
tasks: z10.array(PlannedTaskSchema).min(1).max(MAX_TASKS_PER_PLAN)
|
|
557
794
|
}).superRefine((plan, ctx) => {
|
|
558
795
|
const refs = /* @__PURE__ */ new Set();
|
|
559
796
|
plan.tasks.forEach((t, i) => {
|
|
@@ -596,82 +833,120 @@ var CreateTasksInput = z8.object({
|
|
|
596
833
|
});
|
|
597
834
|
}
|
|
598
835
|
});
|
|
599
|
-
var CreateTasksOutput =
|
|
600
|
-
created:
|
|
601
|
-
|
|
602
|
-
ref:
|
|
836
|
+
var CreateTasksOutput = z10.object({
|
|
837
|
+
created: z10.array(
|
|
838
|
+
z10.object({
|
|
839
|
+
ref: z10.string(),
|
|
603
840
|
task_id: IdSchema,
|
|
604
841
|
status: TaskStatusSchema
|
|
605
842
|
})
|
|
606
843
|
)
|
|
607
844
|
});
|
|
608
|
-
var LoadSkillInput =
|
|
609
|
-
name: SkillNameSchema
|
|
845
|
+
var LoadSkillInput = z10.object({
|
|
846
|
+
name: SkillNameSchema,
|
|
847
|
+
revision: CommitShaSchema.optional()
|
|
610
848
|
});
|
|
611
|
-
var LoadSkillOutput =
|
|
849
|
+
var LoadSkillOutput = z10.object({
|
|
612
850
|
name: SkillNameSchema,
|
|
613
|
-
|
|
614
|
-
|
|
851
|
+
revision: CommitShaSchema.optional(),
|
|
852
|
+
when_to_use: z10.string(),
|
|
853
|
+
content: z10.string()
|
|
615
854
|
});
|
|
616
|
-
var SaveRepoSkillInput =
|
|
855
|
+
var SaveRepoSkillInput = z10.object({
|
|
617
856
|
name: SkillNameSchema,
|
|
618
|
-
when_to_use:
|
|
857
|
+
when_to_use: z10.string().min(1).max(SKILL_LIMITS.maxWhenToUseLength),
|
|
619
858
|
content: SkillContentSchema
|
|
620
859
|
});
|
|
621
|
-
var SaveRepoSkillOutput =
|
|
622
|
-
path:
|
|
623
|
-
created:
|
|
860
|
+
var SaveRepoSkillOutput = z10.object({
|
|
861
|
+
path: z10.string(),
|
|
862
|
+
created: z10.boolean()
|
|
624
863
|
});
|
|
625
|
-
var EpicSummarySchema =
|
|
864
|
+
var EpicSummarySchema = z10.object({
|
|
626
865
|
id: IdSchema,
|
|
627
|
-
title:
|
|
628
|
-
description:
|
|
866
|
+
title: z10.string(),
|
|
867
|
+
description: z10.string().nullable(),
|
|
629
868
|
/** Jumlah task per status, mis. { DRAFT: 3, TODO: 1 }. */
|
|
630
|
-
task_counts:
|
|
869
|
+
task_counts: z10.record(z10.string(), z10.number().int().min(0))
|
|
631
870
|
});
|
|
632
|
-
var ListEpicsInput =
|
|
633
|
-
var ListEpicsOutput =
|
|
634
|
-
epics:
|
|
871
|
+
var ListEpicsInput = z10.object({});
|
|
872
|
+
var ListEpicsOutput = z10.object({
|
|
873
|
+
epics: z10.array(EpicSummarySchema)
|
|
635
874
|
});
|
|
636
|
-
var CreateEpicToolInput =
|
|
637
|
-
title:
|
|
638
|
-
description:
|
|
875
|
+
var CreateEpicToolInput = z10.object({
|
|
876
|
+
title: z10.string().trim().min(1).max(200),
|
|
877
|
+
description: z10.string().max(4e3).optional()
|
|
639
878
|
});
|
|
640
|
-
var CreateEpicToolOutput =
|
|
879
|
+
var CreateEpicToolOutput = z10.object({
|
|
641
880
|
epic: EpicSummarySchema
|
|
642
881
|
});
|
|
643
|
-
var ListPersonasInput =
|
|
644
|
-
var ListPersonasOutput =
|
|
645
|
-
personas:
|
|
882
|
+
var ListPersonasInput = z10.object({});
|
|
883
|
+
var ListPersonasOutput = z10.object({
|
|
884
|
+
personas: z10.array(
|
|
646
885
|
PersonaSchema.extend({
|
|
647
886
|
/** "project" = khusus proyek ini (bisa diubah agen); "workspace" = global, hanya dari Web. */
|
|
648
|
-
scope:
|
|
887
|
+
scope: z10.enum(["project", "workspace"])
|
|
649
888
|
})
|
|
650
889
|
)
|
|
651
890
|
});
|
|
652
891
|
var UpsertPersonaInput = PersonaSchema.extend({
|
|
653
|
-
|
|
892
|
+
/**
|
|
893
|
+
* Tidak dikirim = aturan dipertahankan; persona proyek baru mewarisi aturan persona master
|
|
894
|
+
* (workspace) dengan alias yang sama.
|
|
895
|
+
*/
|
|
896
|
+
rules: z10.array(z10.string().trim().min(1).max(300)).max(30).optional(),
|
|
897
|
+
/** Tidak dikirim = repo persona yang ada dipertahankan. */
|
|
898
|
+
repos: PersonaReposSchema.optional()
|
|
654
899
|
});
|
|
655
|
-
var UpsertPersonaOutput =
|
|
900
|
+
var UpsertPersonaOutput = z10.object({
|
|
656
901
|
persona: PersonaSchema,
|
|
657
|
-
created:
|
|
902
|
+
created: z10.boolean()
|
|
658
903
|
});
|
|
659
904
|
function tool(description, input, output) {
|
|
660
905
|
return { description, input, output };
|
|
661
906
|
}
|
|
662
907
|
var MCP_TOOLS = {
|
|
908
|
+
release_task: tool(
|
|
909
|
+
"Lepas lease task supaya sesi lain bisa mengambilnya.",
|
|
910
|
+
ReleaseTaskInput,
|
|
911
|
+
z10.object({ task_id: IdSchema, status: z10.enum(["TODO", "REVISION_REQUESTED"]) })
|
|
912
|
+
),
|
|
913
|
+
get_project_board: tool(
|
|
914
|
+
"Khusus orchestrator: papan seluruh proyek lintas repo (epic, task, status, persona, repo, dependensi) untuk membagi, melanjutkan, dan menyerahkan task.",
|
|
915
|
+
GetProjectBoardInput,
|
|
916
|
+
GetProjectBoardOutput
|
|
917
|
+
),
|
|
918
|
+
get_document: tool(
|
|
919
|
+
"Baca isi dokumen proyek di Cloud (blueprint, ERD, arsitektur, kontrak API, keputusan) berdasarkan slug dari get_project_context.",
|
|
920
|
+
GetDocumentInput,
|
|
921
|
+
ProjectDocumentSchema
|
|
922
|
+
),
|
|
923
|
+
save_document: tool(
|
|
924
|
+
"Buat/perbarui dokumen proyek di Cloud agar sesi/IDE/CLI lain tidak kehilangan konteks. Markdown ringkas, tanpa code dump atau secret. Kirim expected_version dari versi yang Anda baca (0 = baru).",
|
|
925
|
+
SaveDocumentInput,
|
|
926
|
+
SaveDocumentOutput
|
|
927
|
+
),
|
|
928
|
+
manage_task: tool(
|
|
929
|
+
"Khusus orchestrator (agen utama, bukan subagent persona): request_revision memindahkan task NEEDS_REVIEW/DONE ke kolom Revisi dengan feedback (bukan membuat task baru) dan opsional mengganti persona; assign mengatur persona/role task yang belum dikerjakan.",
|
|
930
|
+
ManageTaskInput,
|
|
931
|
+
ManageTaskOutput
|
|
932
|
+
),
|
|
933
|
+
review_pull_request: tool(
|
|
934
|
+
"Antrean, claim, hasil review, atau cek merge pull request.",
|
|
935
|
+
z10.object({ request: ReviewInput }),
|
|
936
|
+
ReviewOutput
|
|
937
|
+
),
|
|
663
938
|
get_project_context: tool(
|
|
664
939
|
"Baca konteks proyek: identitas repo, aturan persona, indeks skill, dan handoff dependensi langsung.",
|
|
665
940
|
GetProjectContextInput,
|
|
666
941
|
GetProjectContextOutput
|
|
667
942
|
),
|
|
668
943
|
get_ready_tasks: tool(
|
|
669
|
-
"Daftar ringkas task siap dikerjakan untuk repo ini (semua dependensi DONE).",
|
|
944
|
+
"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
945
|
GetReadyTasksInput,
|
|
671
946
|
GetReadyTasksOutput
|
|
672
947
|
),
|
|
673
948
|
claim_task: tool(
|
|
674
|
-
"Kunci task (lease 30 menit) dan ambil instruksi lengkap
|
|
949
|
+
"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
950
|
ClaimTaskInput,
|
|
676
951
|
ClaimTaskOutput
|
|
677
952
|
),
|
|
@@ -723,10 +998,61 @@ var MCP_TOOLS = {
|
|
|
723
998
|
};
|
|
724
999
|
var MCP_TOOL_NAMES = Object.keys(MCP_TOOLS);
|
|
725
1000
|
|
|
1001
|
+
// shared/src/orchestrator.ts
|
|
1002
|
+
var ORCHESTRATOR_RULES = [
|
|
1003
|
+
"Anda, agen utama sesi ini, adalah **orchestrator**. Persona Catenext (mis. `bambang` backend di repo `be`, `mira` frontend di repo `fe`, `qori` QA) adalah **subagent** Anda. Orchestrator tidak memakai `agent_alias`.",
|
|
1004
|
+
"",
|
|
1005
|
+
"### Konteks di awal setiap sesi",
|
|
1006
|
+
"",
|
|
1007
|
+
"1. `get_project_context`: repo proyek (`project_repos`), indeks dokumen Cloud (`documents`), skill, dan handoff terbaru.",
|
|
1008
|
+
"2. Baca dokumen yang relevan dengan `get_document` (mis. `blueprint`, `erd`, `architecture`). Dokumen ini sumber kebenaran lintas sesi, IDE, dan CLI; jangan mengandalkan ingatan sesi sebelumnya.",
|
|
1009
|
+
"3. `get_project_board` (CLI: `catenext board`): semua epic dan task lintas repo, status, persona, repo tujuan, dan dependensi. Lanjutkan dari sini, bukan dari awal.",
|
|
1010
|
+
"",
|
|
1011
|
+
"### Tugas orchestrator",
|
|
1012
|
+
"",
|
|
1013
|
+
"1. Rencanakan: `list_epics`/`create_epic` lalu `create_tasks`. Setiap task wajib punya `target_repo` (repo tempat kode berubah) dan `persona` atau `role`. Pecah pekerjaan lintas repo per repo (mis. kontrak API di `be`, layar di `fe`, uji di `qa`) dan hubungkan dengan `depends_on`. Rencana masuk DRAFT sampai manusia menyetujuinya di Web.",
|
|
1014
|
+
'2. Bagi tugas: tetapkan pemegang repo dengan `upsert_persona` (`repos: ["be"]`; CLI: `catenext persona set bambang --role backend --repo be`). Task tanpa `target_repo` milik persona yang memegang satu repo otomatis diarahkan ke repo itu.',
|
|
1015
|
+
'3. Delegasikan: untuk task yang `is_ready` di board, panggil subagent persona penanggung jawab (mis. "bambang, kerjakan task <task_id> di repo be"). Jangan mengerjakan sendiri task milik persona kecuali manusia memintanya.',
|
|
1016
|
+
"4. Tinjau handoff subagent: ringkasan, perintah verifikasi, dan PR. Jalankan verifikasinya, lalu lanjutkan task hilir yang terbuka.",
|
|
1017
|
+
'5. Revisi: bila hasil perlu diperbaiki (temuan review Anda atau permintaan manusia), pakai `manage_task` dengan `action: request_revision` dan `feedback` yang spesifik (CLI: `catenext revise <task_id> --feedback "..." [--to <alias>]`). Task pindah ke kolom **Revisi**; **jangan membuat task baru untuk revisi**. Lalu delegasikan lagi ke subagent penanggung jawabnya.',
|
|
1018
|
+
"6. Assign: `manage_task` dengan `action: assign` (CLI: `catenext assign <task_id> --to <alias>` atau `--role <role>`) untuk menetapkan atau mengganti penanggung jawab task yang belum dikerjakan.",
|
|
1019
|
+
"7. Catat konteks: keputusan arsitektur, skema data (ERD), dan kontrak antar-repo disimpan dengan `save_document` (kirim `expected_version` dari versi yang Anda baca; 0 = dokumen baru). Ringkas, Markdown, tanpa code dump atau secret.",
|
|
1020
|
+
"",
|
|
1021
|
+
"### Subagent per persona dan repo terpisah",
|
|
1022
|
+
"",
|
|
1023
|
+
"Setiap persona dari `list_personas` menjadi satu subagent: nama = alias, isi = role, repo yang dipegang, aturan persona, dan alur subagent di bawah.",
|
|
1024
|
+
"",
|
|
1025
|
+
"- Claude Code: `catenext sync` membuat `.claude/agents/<alias>.md` secara otomatis.",
|
|
1026
|
+
"- IDE/CLI lain: buat subagent, mode, atau rule dengan format bawaan IDE Anda. Bila IDE tidak punya subagent, buka satu sesi baru per persona.",
|
|
1027
|
+
"- Repo di folder terpisah: jalankan `catenext init --project <project_id> --repo <nama>` sekali di setiap folder repo (`--repo be` di folder backend, `--repo fe` di folder frontend). Subagent bekerja dari folder repo yang ia pegang; dari folder lain ia memakai CLI di folder itu (`cd <folder-be> && npx catenext next --as bambang`), karena MCP di folder ini terikat ke repo folder ini.",
|
|
1028
|
+
"- Persona master (tingkat workspace) berlaku lintas proyek. Untuk memegang repo di proyek ini, buat persona proyek dengan alias yang sama: aturan master diwarisi bila `rules` tidak dikirim.",
|
|
1029
|
+
"- Persona belum ada: usulkan alias, role, repo, dan aturannya ke manusia, lalu `upsert_persona` setelah disetujui.",
|
|
1030
|
+
"",
|
|
1031
|
+
"### Alur subagent (persona)",
|
|
1032
|
+
"",
|
|
1033
|
+
"1. Pastikan berada di folder repo yang dipegang. `get_ready_tasks` dan `claim_task` dengan `agent_alias: <alias>`; patuhi aturan persona di hasil claim. Task di kolom Revisi didahulukan dan membawa feedback revisinya.",
|
|
1034
|
+
"2. Baca dokumen proyek yang dirujuk task (`get_document`) bila perlu konteks desain.",
|
|
1035
|
+
"3. Kerjakan, jalankan tes, commit di branch kerja.",
|
|
1036
|
+
"4. `complete_handoff` dengan ringkasan terstruktur, atau `report_blocker` bila buntu.",
|
|
1037
|
+
"5. Laporkan ke orchestrator: task, status, dan perintah verifikasi.",
|
|
1038
|
+
"",
|
|
1039
|
+
"Subagent hanya mengerjakan satu task per pemanggilan dan tidak memanggil `create_tasks`, `manage_task`, `upsert_persona`, atau `save_document`."
|
|
1040
|
+
];
|
|
1041
|
+
var CLI_FALLBACK_RULES = [
|
|
1042
|
+
"### Tanpa tool MCP",
|
|
1043
|
+
"",
|
|
1044
|
+
"- Orchestrator: `catenext board`, `catenext doc list|get|save`, `catenext persona list|set`, `catenext revise`, `catenext assign`.",
|
|
1045
|
+
'- Subagent: `catenext next --as <alias>`, `catenext claim <task_id> --as <alias>`, kerjakan & commit, lalu `catenext done <task_id> --notes "<ringkasan>" --verify "<perintah tes>"`.',
|
|
1046
|
+
'- Bila buntu: `catenext block <task_id> --category <missing_env|ambiguous_requirement|failing_tests|dependency_issue|other> --reason "..."`.'
|
|
1047
|
+
];
|
|
1048
|
+
var GENERAL_RULES = [
|
|
1049
|
+
"Aturan: jangan menyalin kode atau secret ke handoff atau dokumen (rujuk path file); jangan mengedit `.catenext/config.yaml` atau file konfigurasi MCP IDE. Skill repo ada di `.catenext/skills/`."
|
|
1050
|
+
];
|
|
1051
|
+
|
|
726
1052
|
// shared/src/quota.ts
|
|
727
|
-
import { z as
|
|
1053
|
+
import { z as z11 } from "zod";
|
|
728
1054
|
var PLANS = ["free", "pro", "team"];
|
|
729
|
-
var PlanSchema =
|
|
1055
|
+
var PlanSchema = z11.enum(PLANS);
|
|
730
1056
|
var QUOTA_DIMENSIONS = [
|
|
731
1057
|
/** Jumlah proyek di workspace. */
|
|
732
1058
|
"projects",
|
|
@@ -741,38 +1067,48 @@ var QUOTA_DIMENSIONS = [
|
|
|
741
1067
|
/** Persona di workspace (semua proyek). */
|
|
742
1068
|
"personas",
|
|
743
1069
|
/** Indeks skill per repo yang disinkronkan ke Cloud. */
|
|
744
|
-
"skills"
|
|
1070
|
+
"skills",
|
|
1071
|
+
/** Dokumen proyek di Cloud (blueprint, ERD, ...) di workspace. */
|
|
1072
|
+
"documents",
|
|
1073
|
+
/** Panjang maksimum satu dokumen (karakter). Pemakaian = dokumen terpanjang. */
|
|
1074
|
+
"document_chars",
|
|
1075
|
+
/** Repo yang dikenal satu proyek (mis. be, fe, qa). Pemakaian = proyek dengan repo terbanyak. */
|
|
1076
|
+
"repos_per_project",
|
|
1077
|
+
/** Task yang dipindah ke kolom Revisi per bulan oleh manusia (Web) atau orchestrator. */
|
|
1078
|
+
"revisions_per_month",
|
|
1079
|
+
/** Task yang sedang dikerjakan bersamaan (IN_PROGRESS) di workspace. */
|
|
1080
|
+
"active_tasks"
|
|
745
1081
|
];
|
|
746
|
-
var QuotaDimensionSchema =
|
|
1082
|
+
var QuotaDimensionSchema = z11.enum(QUOTA_DIMENSIONS);
|
|
747
1083
|
var QUOTA_WARNING_HEADER = "x-catenext-quota-warning";
|
|
748
|
-
var QuotaExceededDetailsSchema =
|
|
1084
|
+
var QuotaExceededDetailsSchema = z11.object({
|
|
749
1085
|
dimension: QuotaDimensionSchema,
|
|
750
1086
|
plan: PlanSchema,
|
|
751
|
-
limit:
|
|
752
|
-
used:
|
|
1087
|
+
limit: z11.number().int(),
|
|
1088
|
+
used: z11.number().int(),
|
|
753
1089
|
/** Kapan kuota bulanan direset; null untuk kuota jumlah (proyek, persona, ...). */
|
|
754
1090
|
reset_at: IsoDateTimeSchema.nullable(),
|
|
755
|
-
upgrade_url:
|
|
1091
|
+
upgrade_url: z11.string()
|
|
756
1092
|
});
|
|
757
|
-
var UsageItemSchema =
|
|
1093
|
+
var UsageItemSchema = z11.object({
|
|
758
1094
|
dimension: QuotaDimensionSchema,
|
|
759
|
-
label:
|
|
760
|
-
used:
|
|
761
|
-
limit:
|
|
1095
|
+
label: z11.string(),
|
|
1096
|
+
used: z11.number().int().min(0),
|
|
1097
|
+
limit: z11.number().int().nullable()
|
|
762
1098
|
});
|
|
763
|
-
var UsageOutput =
|
|
1099
|
+
var UsageOutput = z11.object({
|
|
764
1100
|
plan: PlanSchema,
|
|
765
|
-
plans:
|
|
766
|
-
|
|
1101
|
+
plans: z11.array(
|
|
1102
|
+
z11.object({
|
|
767
1103
|
plan: PlanSchema,
|
|
768
|
-
available:
|
|
769
|
-
limits:
|
|
1104
|
+
available: z11.boolean(),
|
|
1105
|
+
limits: z11.record(z11.string(), z11.number().nullable())
|
|
770
1106
|
})
|
|
771
1107
|
),
|
|
772
1108
|
period_start: IsoDateTimeSchema,
|
|
773
1109
|
reset_at: IsoDateTimeSchema,
|
|
774
|
-
retention_days:
|
|
775
|
-
usage:
|
|
1110
|
+
retention_days: z11.number().int().nullable(),
|
|
1111
|
+
usage: z11.array(UsageItemSchema)
|
|
776
1112
|
});
|
|
777
1113
|
|
|
778
1114
|
// src/index.ts
|
|
@@ -935,7 +1271,7 @@ async function findProjectRoot(start = process.cwd()) {
|
|
|
935
1271
|
import { chmod, mkdir, readFile as readFile2, rename, writeFile } from "node:fs/promises";
|
|
936
1272
|
import { homedir } from "node:os";
|
|
937
1273
|
import { join as join2 } from "node:path";
|
|
938
|
-
import { z as
|
|
1274
|
+
import { z as z12 } from "zod";
|
|
939
1275
|
function catenextHome() {
|
|
940
1276
|
return process.env.CATENEXT_HOME ?? join2(homedir(), ".catenext");
|
|
941
1277
|
}
|
|
@@ -944,10 +1280,10 @@ function credentialsPath() {
|
|
|
944
1280
|
}
|
|
945
1281
|
var PRODUCTION_API_URL = "https://catenext.mapan.digital";
|
|
946
1282
|
var DEFAULT_API_URL = PRODUCTION_API_URL;
|
|
947
|
-
var CredentialsSchema =
|
|
948
|
-
api_key:
|
|
949
|
-
api_url:
|
|
950
|
-
saved_at:
|
|
1283
|
+
var CredentialsSchema = z12.object({
|
|
1284
|
+
api_key: z12.string().startsWith(API_KEY_PREFIX),
|
|
1285
|
+
api_url: z12.url().optional(),
|
|
1286
|
+
saved_at: z12.string().optional()
|
|
951
1287
|
});
|
|
952
1288
|
var CredentialsError = class extends Error {
|
|
953
1289
|
constructor(message) {
|
|
@@ -1125,6 +1461,7 @@ async function deviceLogin(opts) {
|
|
|
1125
1461
|
|
|
1126
1462
|
// src/fallback.ts
|
|
1127
1463
|
import { execFile } from "node:child_process";
|
|
1464
|
+
import { randomUUID } from "node:crypto";
|
|
1128
1465
|
import { promisify } from "node:util";
|
|
1129
1466
|
|
|
1130
1467
|
// src/planning.ts
|
|
@@ -1304,16 +1641,94 @@ async function personaList(api, asJson) {
|
|
|
1304
1641
|
);
|
|
1305
1642
|
}
|
|
1306
1643
|
for (const p of res.personas) {
|
|
1307
|
-
|
|
1644
|
+
const repos = p.repos.length > 0 ? `, repo ${p.repos.join("/")}` : "";
|
|
1645
|
+
console.log(
|
|
1646
|
+
`${p.alias} (${p.role}${repos}, ${p.scope === "project" ? "proyek" : "workspace"})`
|
|
1647
|
+
);
|
|
1308
1648
|
for (const r of p.rules) console.log(` - ${r}`);
|
|
1309
1649
|
}
|
|
1310
1650
|
}
|
|
1311
|
-
async function personaSet(api, alias, role, rules, asJson) {
|
|
1312
|
-
const body = prepare(
|
|
1651
|
+
async function personaSet(api, alias, role, rules, asJson, repos) {
|
|
1652
|
+
const body = prepare(
|
|
1653
|
+
UpsertPersonaInput,
|
|
1654
|
+
{
|
|
1655
|
+
alias,
|
|
1656
|
+
role,
|
|
1657
|
+
// Tanpa --rule: aturan lama dipertahankan (persona baru mewarisi persona master).
|
|
1658
|
+
...rules.length > 0 ? { rules } : {},
|
|
1659
|
+
...repos ? { repos } : {}
|
|
1660
|
+
},
|
|
1661
|
+
["alias", "role", "repos"]
|
|
1662
|
+
);
|
|
1313
1663
|
const res = await api.put("personas", body);
|
|
1314
1664
|
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
1315
1665
|
console.log(
|
|
1316
|
-
`\u2713 Persona "${res.persona.alias}" (${res.persona.role}) ${res.created ? "dibuat" : "diperbarui"} untuk proyek ini, ${res.persona.rules.length} aturan.`
|
|
1666
|
+
`\u2713 Persona "${res.persona.alias}" (${res.persona.role}) ${res.created ? "dibuat" : "diperbarui"} untuk proyek ini, ${res.persona.rules.length} aturan${res.persona.repos.length > 0 ? `, memegang repo ${res.persona.repos.join(", ")}` : ""}.`
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
async function boardShow(api, opts) {
|
|
1670
|
+
const body = prepare(
|
|
1671
|
+
GetProjectBoardInput,
|
|
1672
|
+
{
|
|
1673
|
+
...opts.epic ? { epic_id: opts.epic } : {},
|
|
1674
|
+
...opts.status?.length ? { status: opts.status } : {}
|
|
1675
|
+
},
|
|
1676
|
+
["epic_id", "status"]
|
|
1677
|
+
);
|
|
1678
|
+
const res = await api.post("board", body);
|
|
1679
|
+
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1680
|
+
console.log("Repo:");
|
|
1681
|
+
for (const r of res.repos)
|
|
1682
|
+
console.log(
|
|
1683
|
+
` ${r.repo}: ${r.personas.length ? r.personas.join(", ") : "(belum ada persona)"}`
|
|
1684
|
+
);
|
|
1685
|
+
for (const e of res.epics) {
|
|
1686
|
+
console.log(`
|
|
1687
|
+
# ${e.title} ${JSON.stringify(e.counts)}`);
|
|
1688
|
+
for (const t of res.tasks.filter((x) => x.epic_id === e.id)) {
|
|
1689
|
+
const who = t.persona ? `@${t.persona}` : t.role ? `role ${t.role}` : "-";
|
|
1690
|
+
const flags = [t.is_ready ? "siap" : null, t.is_stale ? "stale" : null].filter(Boolean).join(",");
|
|
1691
|
+
console.log(
|
|
1692
|
+
` ${t.status.padEnd(18)} ${t.id} ${t.title} [${t.target_repo ?? "repo bebas"} \xB7 ${who}]${flags ? ` (${flags})` : ""}`
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
if (res.truncated) console.log("\n(daftar dipotong; pakai --epic untuk mempersempit)");
|
|
1697
|
+
}
|
|
1698
|
+
async function docList(api, asJson) {
|
|
1699
|
+
const res = await api.post("documents/list");
|
|
1700
|
+
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
1701
|
+
if (res.documents.length === 0)
|
|
1702
|
+
return console.log(
|
|
1703
|
+
"Belum ada dokumen proyek. Buat dengan: catenext doc save <slug> --file <path.md>"
|
|
1704
|
+
);
|
|
1705
|
+
for (const d of res.documents)
|
|
1706
|
+
console.log(`${d.slug} v${d.version} ${d.kind} ${d.title} (${d.size} karakter)`);
|
|
1707
|
+
}
|
|
1708
|
+
async function docGet(api, slug, asJson) {
|
|
1709
|
+
const body = prepare(GetDocumentInput, { slug }, ["slug"]);
|
|
1710
|
+
const res = await api.post("documents/get", body);
|
|
1711
|
+
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
1712
|
+
console.log(`<!-- ${res.slug} v${res.version} (${res.kind}) -->`);
|
|
1713
|
+
console.log(res.content);
|
|
1714
|
+
}
|
|
1715
|
+
async function docSave(api, slug, opts) {
|
|
1716
|
+
const content = await readFile3(opts.file, "utf8");
|
|
1717
|
+
const body = prepare(
|
|
1718
|
+
SaveDocumentInput,
|
|
1719
|
+
{
|
|
1720
|
+
slug,
|
|
1721
|
+
title: opts.title ?? slug,
|
|
1722
|
+
kind: opts.kind,
|
|
1723
|
+
content,
|
|
1724
|
+
...opts.version !== void 0 ? { expected_version: Number(opts.version) } : {}
|
|
1725
|
+
},
|
|
1726
|
+
["slug", "kind", "expected_version"]
|
|
1727
|
+
);
|
|
1728
|
+
const res = await api.put("documents", body);
|
|
1729
|
+
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1730
|
+
console.log(
|
|
1731
|
+
`\u2713 Dokumen "${res.document.slug}" ${res.created ? "dibuat" : "diperbarui"} (v${res.document.version}).`
|
|
1317
1732
|
);
|
|
1318
1733
|
}
|
|
1319
1734
|
|
|
@@ -1339,7 +1754,9 @@ async function readGitState(cwd = process.cwd()) {
|
|
|
1339
1754
|
}
|
|
1340
1755
|
async function taskNext(api, opts) {
|
|
1341
1756
|
const res = await api.post("ready-tasks", {
|
|
1342
|
-
limit: opts.limit ?? 10
|
|
1757
|
+
limit: opts.limit ?? 10,
|
|
1758
|
+
...opts.lease ? { lease_id: opts.lease } : {},
|
|
1759
|
+
...opts.as ? { agent_alias: opts.as } : {}
|
|
1343
1760
|
});
|
|
1344
1761
|
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1345
1762
|
if (res.tasks.length === 0) {
|
|
@@ -1348,20 +1765,30 @@ async function taskNext(api, opts) {
|
|
|
1348
1765
|
);
|
|
1349
1766
|
}
|
|
1350
1767
|
for (const t of res.tasks) {
|
|
1351
|
-
const tags = [t.role, t.revision ? "revisi" : null].filter(Boolean).join(", ");
|
|
1768
|
+
const tags = [t.persona ? `@${t.persona}` : null, t.role, t.revision ? "revisi" : null].filter(Boolean).join(", ");
|
|
1352
1769
|
console.log(`${t.id} ${t.title}${tags ? ` [${tags}]` : ""}`);
|
|
1353
1770
|
}
|
|
1354
|
-
console.log(
|
|
1355
|
-
|
|
1771
|
+
console.log(
|
|
1772
|
+
`
|
|
1773
|
+
Ambil satu: catenext claim ${res.tasks[0]?.id}${opts.as ? ` --as ${opts.as}` : ""}`
|
|
1774
|
+
);
|
|
1356
1775
|
}
|
|
1357
1776
|
function renderClaim(res) {
|
|
1358
1777
|
const out = [];
|
|
1359
1778
|
out.push(`# Task: ${res.task.title}`, "");
|
|
1360
1779
|
out.push(`- ID: ${res.task.id}`);
|
|
1361
1780
|
out.push(`- Lease sampai: ${res.lease_expires_at} (diperpanjang setiap perintah catenext)`);
|
|
1781
|
+
if (res.lease_id)
|
|
1782
|
+
out.push(`- Gunakan --lease ${res.lease_id} saat memperbarui atau menyerahkan task.`);
|
|
1362
1783
|
if (res.task.role) out.push(`- Role: ${res.task.role}`);
|
|
1363
1784
|
if (res.task.revision_count > 0) out.push(`- Revisi ke-${res.task.revision_count}`);
|
|
1364
1785
|
out.push("", "## Instruksi", "", res.task.prompt_instruction.trim(), "");
|
|
1786
|
+
if (res.persona) {
|
|
1787
|
+
out.push(`## Persona: ${res.persona.alias} (${res.persona.role})`, "");
|
|
1788
|
+
out.push("Patuhi aturan dan batas wilayah berikut:", "");
|
|
1789
|
+
for (const r of res.persona.rules) out.push(`- ${r}`);
|
|
1790
|
+
out.push("");
|
|
1791
|
+
}
|
|
1365
1792
|
if (res.revision) {
|
|
1366
1793
|
out.push("## Feedback revisi dari reviewer", "", res.revision.review_feedback.trim(), "");
|
|
1367
1794
|
}
|
|
@@ -1371,6 +1798,9 @@ function renderClaim(res) {
|
|
|
1371
1798
|
const h = d.handoff_summary;
|
|
1372
1799
|
out.push(`### ${d.title}`, "");
|
|
1373
1800
|
out.push(`- Branch/commit: ${h.git_branch} @ ${h.last_commit_hash}`);
|
|
1801
|
+
if (d.integrated_commit) {
|
|
1802
|
+
out.push(`- Terintegrasi: ${d.integrated_commit.branch} @ ${d.integrated_commit.sha}`);
|
|
1803
|
+
}
|
|
1374
1804
|
if (h.files_modified.length) out.push(`- File: ${h.files_modified.join(", ")}`);
|
|
1375
1805
|
for (const k of h.key_decisions) out.push(`- Keputusan: ${k}`);
|
|
1376
1806
|
if (h.verification_command) out.push(`- Verifikasi: \`${h.verification_command}\``);
|
|
@@ -1387,7 +1817,19 @@ function renderClaim(res) {
|
|
|
1387
1817
|
return out.join("\n");
|
|
1388
1818
|
}
|
|
1389
1819
|
async function taskClaim(api, taskId, opts) {
|
|
1390
|
-
const
|
|
1820
|
+
const branch = opts.worktree ? await git(["symbolic-ref", "--short", "HEAD"], process.cwd()) : null;
|
|
1821
|
+
if (opts.worktree && !branch)
|
|
1822
|
+
throw new PlanningInputError("Checkout branch kerja sebelum memakai --worktree.");
|
|
1823
|
+
const payload = prepare(
|
|
1824
|
+
ClaimTaskInput,
|
|
1825
|
+
{
|
|
1826
|
+
task_id: taskId,
|
|
1827
|
+
...opts.as ? { agent_alias: opts.as } : {},
|
|
1828
|
+
...branch ? { worktree: { branch, session_id: randomUUID() } } : {}
|
|
1829
|
+
},
|
|
1830
|
+
["task_id", "session_id"]
|
|
1831
|
+
);
|
|
1832
|
+
const res = await api.post("claim", payload);
|
|
1391
1833
|
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1392
1834
|
console.log(renderClaim(res));
|
|
1393
1835
|
}
|
|
@@ -1402,6 +1844,8 @@ function buildHandoff(opts, gitState) {
|
|
|
1402
1844
|
"Tidak bisa membaca branch/commit git. Jalankan di dalam repo git dan commit pekerjaan Anda dulu."
|
|
1403
1845
|
);
|
|
1404
1846
|
}
|
|
1847
|
+
if (Boolean(opts.pr) !== Boolean(opts.base))
|
|
1848
|
+
throw new PlanningInputError("Gunakan --pr dan --base bersama.");
|
|
1405
1849
|
const files = opts.file.length ? opts.file : gitState.changedFiles;
|
|
1406
1850
|
return {
|
|
1407
1851
|
files_modified: files.slice(0, HANDOFF_LIMITS.maxFilesModified),
|
|
@@ -1409,32 +1853,73 @@ function buildHandoff(opts, gitState) {
|
|
|
1409
1853
|
verification_command: opts.verify ?? null,
|
|
1410
1854
|
notes_for_next_agent: opts.notes,
|
|
1411
1855
|
git_branch: gitState.branch,
|
|
1412
|
-
last_commit_hash: gitState.commit
|
|
1856
|
+
last_commit_hash: gitState.commit,
|
|
1857
|
+
...opts.pr && opts.base ? { pull_request: { url: opts.pr, base_branch: opts.base, head_sha: gitState.commit } } : {}
|
|
1413
1858
|
};
|
|
1414
1859
|
}
|
|
1415
1860
|
async function taskDone(api, taskId, opts) {
|
|
1416
1861
|
const summary = opts.handoff ? await readJsonInput(opts.handoff) : buildHandoff(opts, await readGitState());
|
|
1417
|
-
const body = prepare(
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1862
|
+
const body = prepare(
|
|
1863
|
+
CompleteHandoffInput,
|
|
1864
|
+
{ task_id: taskId, handoff_summary: summary, lease_id: opts.lease },
|
|
1865
|
+
["task_id", "last_commit_hash", "head_sha", "lease_id"]
|
|
1866
|
+
);
|
|
1421
1867
|
const res = await api.post("complete", body);
|
|
1422
1868
|
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1423
1869
|
console.log(
|
|
1424
|
-
res.status === "DONE" ? `\u2713 Task selesai (DONE). ${res.unlocked_task_ids.length} task hilir terbuka.` : "\u2713 Handoff terkirim, menunggu review
|
|
1870
|
+
res.status === "DONE" ? `\u2713 Task selesai (DONE). ${res.unlocked_task_ids.length} task hilir terbuka.` : "\u2713 Handoff terkirim, menunggu review (NEEDS_REVIEW)."
|
|
1425
1871
|
);
|
|
1426
1872
|
console.log(` ${res.next_step_hint}`);
|
|
1427
1873
|
}
|
|
1428
1874
|
async function taskBlock(api, taskId, opts) {
|
|
1429
1875
|
const body = prepare(
|
|
1430
1876
|
ReportBlockerInput,
|
|
1431
|
-
{ task_id: taskId, category: opts.category, reason: opts.reason },
|
|
1432
|
-
["task_id", "category"]
|
|
1877
|
+
{ task_id: taskId, category: opts.category, reason: opts.reason, lease_id: opts.lease },
|
|
1878
|
+
["task_id", "category", "lease_id"]
|
|
1433
1879
|
);
|
|
1434
1880
|
const res = await api.post("blocker", body);
|
|
1435
1881
|
if (opts.json) return console.log(JSON.stringify(res, null, 2));
|
|
1436
1882
|
console.log("\u2713 Task ditandai BLOCKED dan lock dilepas. Manusia akan meninjau di Dashboard.");
|
|
1437
1883
|
}
|
|
1884
|
+
async function taskReview(api, input, json2) {
|
|
1885
|
+
const body = prepare(ReviewInput, input, ["task_id", "lease_id", "head_sha"]);
|
|
1886
|
+
const result = await api.post(
|
|
1887
|
+
body.action === "list" ? "review/list" : "review",
|
|
1888
|
+
body
|
|
1889
|
+
);
|
|
1890
|
+
if (json2) console.log(JSON.stringify(result, null, 2));
|
|
1891
|
+
else if ("reviews" in result) {
|
|
1892
|
+
if (!result.reviews.length) console.log("Belum ada PR yang bisa Anda review di repo ini.");
|
|
1893
|
+
for (const item of result.reviews)
|
|
1894
|
+
console.log(`${item.task_id} ${item.title} ${item.review.url}`);
|
|
1895
|
+
} else {
|
|
1896
|
+
console.log(`${result.title} ${result.status} \xB7 ${result.review.stage}`);
|
|
1897
|
+
console.log(`${result.review.url} @ ${result.review.head_sha}`);
|
|
1898
|
+
if (result.lease_id)
|
|
1899
|
+
console.log(`Lease review: ${result.lease_id} (sampai ${result.lease_expires_at})`);
|
|
1900
|
+
if (result.notes_for_next_agent) console.log(result.notes_for_next_agent);
|
|
1901
|
+
if (result.warning) console.error(result.warning);
|
|
1902
|
+
}
|
|
1903
|
+
if ("warning" in result && result.warning) process.exitCode = 1;
|
|
1904
|
+
}
|
|
1905
|
+
async function taskManage(api, input, json2) {
|
|
1906
|
+
const body = prepare(ManageTaskInput, input, ["action", "task_id", "agent_alias", "role"]);
|
|
1907
|
+
const res = await api.post("tasks/manage", body);
|
|
1908
|
+
if (json2) return console.log(JSON.stringify(res, null, 2));
|
|
1909
|
+
const owner = res.persona ? `@${res.persona}` : res.role ? `role ${res.role}` : "tanpa persona";
|
|
1910
|
+
if (body.action === "request_revision") {
|
|
1911
|
+
console.log(
|
|
1912
|
+
`\u2713 Task dipindah ke kolom Revisi (revisi ke-${res.revision_count}) untuk ${owner}.`
|
|
1913
|
+
);
|
|
1914
|
+
console.log(
|
|
1915
|
+
res.persona ? ` Delegasikan ke subagent ${res.persona}; ia akan mengambilnya lewat claim_task.` : " Subagent dengan role yang cocok dapat mengambilnya lewat claim_task."
|
|
1916
|
+
);
|
|
1917
|
+
if (res.stale_task_ids.length > 0)
|
|
1918
|
+
console.log(` ${res.stale_task_ids.length} task hilir ditandai stale.`);
|
|
1919
|
+
} else {
|
|
1920
|
+
console.log(`\u2713 Penanggung jawab task: ${owner} (status ${res.status}).`);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1438
1923
|
|
|
1439
1924
|
// src/init/index.ts
|
|
1440
1925
|
import { mkdir as mkdir2, readFile as readFile5, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -1448,20 +1933,15 @@ var BLOCK_END = "<!-- catenext:end -->";
|
|
|
1448
1933
|
function renderAgentsBlock() {
|
|
1449
1934
|
return [
|
|
1450
1935
|
BLOCK_START,
|
|
1451
|
-
"## Catenext:
|
|
1936
|
+
"## Catenext: orchestrator & subagent",
|
|
1452
1937
|
"",
|
|
1453
|
-
"Repo ini memakai Catenext
|
|
1454
|
-
"(`get_project_context` -> `get_ready_tasks` -> `claim_task` -> `complete_handoff`).",
|
|
1455
|
-
"Bila tidak, pakai CLI berikut:",
|
|
1938
|
+
"Repo ini memakai Catenext lewat tool MCP `catenext` (atau CLI `catenext` bila MCP tidak ada).",
|
|
1456
1939
|
"",
|
|
1457
|
-
|
|
1458
|
-
"2. `catenext claim <task_id>`: kunci task dan baca instruksi + handoff dependensinya.",
|
|
1459
|
-
"3. Kerjakan, jalankan tes, lalu commit.",
|
|
1460
|
-
'4. `catenext done <task_id> --notes "<ringkasan>" --verify "<perintah tes>" [--decision "..."]`',
|
|
1461
|
-
'5. Bila buntu: `catenext block <task_id> --category <missing_env|ambiguous_requirement|failing_tests|dependency_issue|other> --reason "..."`',
|
|
1940
|
+
...ORCHESTRATOR_RULES,
|
|
1462
1941
|
"",
|
|
1463
|
-
|
|
1464
|
-
"
|
|
1942
|
+
...CLI_FALLBACK_RULES,
|
|
1943
|
+
"",
|
|
1944
|
+
...GENERAL_RULES,
|
|
1465
1945
|
BLOCK_END
|
|
1466
1946
|
].join("\n");
|
|
1467
1947
|
}
|
|
@@ -1511,13 +1991,13 @@ function renderNewConfig(f) {
|
|
|
1511
1991
|
return out;
|
|
1512
1992
|
}
|
|
1513
1993
|
function updateConfig(source, changes) {
|
|
1514
|
-
const
|
|
1994
|
+
const doc2 = parseDocument(source);
|
|
1515
1995
|
for (const [key, value] of Object.entries(changes)) {
|
|
1516
1996
|
if (value === void 0) continue;
|
|
1517
|
-
if (JSON.stringify(
|
|
1518
|
-
|
|
1997
|
+
if (JSON.stringify(doc2.get(key)) === JSON.stringify(value)) continue;
|
|
1998
|
+
doc2.set(key, value);
|
|
1519
1999
|
}
|
|
1520
|
-
const out =
|
|
2000
|
+
const out = doc2.toString();
|
|
1521
2001
|
if (out === parseDocument(source).toString()) return source;
|
|
1522
2002
|
parseConfig(out);
|
|
1523
2003
|
return out;
|
|
@@ -1615,13 +2095,13 @@ function detectFormatting(source) {
|
|
|
1615
2095
|
function upsertMcpEntry(source, entry, file) {
|
|
1616
2096
|
const base = source && source.trim() !== "" ? source : "{}\n";
|
|
1617
2097
|
const errors = [];
|
|
1618
|
-
const
|
|
1619
|
-
if (errors.length > 0 ||
|
|
2098
|
+
const doc2 = parse2(base, errors, { allowTrailingComma: true, disallowComments: false });
|
|
2099
|
+
if (errors.length > 0 || doc2 === null || typeof doc2 !== "object" || Array.isArray(doc2)) {
|
|
1620
2100
|
throw new McpConfigError(
|
|
1621
2101
|
`${file} bukan JSON/JSONC objek yang valid, jadi tidak disentuh. Perbaiki manual lalu jalankan ulang \`catenext init\`.`
|
|
1622
2102
|
);
|
|
1623
2103
|
}
|
|
1624
|
-
const servers =
|
|
2104
|
+
const servers = doc2.mcpServers;
|
|
1625
2105
|
if (servers !== void 0 && (servers === null || typeof servers !== "object" || Array.isArray(servers))) {
|
|
1626
2106
|
throw new McpConfigError(`${file}: "mcpServers" harus berupa objek. Perbaiki manual dulu.`);
|
|
1627
2107
|
}
|
|
@@ -1636,9 +2116,9 @@ function upsertMcpEntry(source, entry, file) {
|
|
|
1636
2116
|
}
|
|
1637
2117
|
function readMcpEntry(source) {
|
|
1638
2118
|
const errors = [];
|
|
1639
|
-
const
|
|
2119
|
+
const doc2 = parse2(source, errors, { allowTrailingComma: true });
|
|
1640
2120
|
if (errors.length > 0) return null;
|
|
1641
|
-
const entry =
|
|
2121
|
+
const entry = doc2?.mcpServers?.[MCP_SERVER_KEY];
|
|
1642
2122
|
return entry && typeof entry.command === "string" && Array.isArray(entry.args) ? entry : null;
|
|
1643
2123
|
}
|
|
1644
2124
|
|
|
@@ -1733,8 +2213,8 @@ async function applyInit(root, changes) {
|
|
|
1733
2213
|
|
|
1734
2214
|
// src/maintenance.ts
|
|
1735
2215
|
import { existsSync } from "node:fs";
|
|
1736
|
-
import { copyFile, mkdir as mkdir4, readFile as
|
|
1737
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
2216
|
+
import { copyFile, mkdir as mkdir4, readFile as readFile8, rename as rename4, rm, rmdir, writeFile as writeFile4 } from "node:fs/promises";
|
|
2217
|
+
import { dirname as dirname3, isAbsolute, join as join8, resolve as resolve3 } from "node:path";
|
|
1738
2218
|
import { applyEdits as applyEdits2, modify as modify2, parse as parse4, visit } from "jsonc-parser";
|
|
1739
2219
|
|
|
1740
2220
|
// src/node-command.ts
|
|
@@ -1775,8 +2255,10 @@ function npxLaunch(entry) {
|
|
|
1775
2255
|
}
|
|
1776
2256
|
|
|
1777
2257
|
// src/skills.ts
|
|
2258
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
1778
2259
|
import { mkdir as mkdir3, readdir, readFile as readFile6, rename as rename3, writeFile as writeFile3 } from "node:fs/promises";
|
|
1779
2260
|
import { join as join6 } from "node:path";
|
|
2261
|
+
import { promisify as promisify2 } from "node:util";
|
|
1780
2262
|
import { parse as parse3, stringify } from "yaml";
|
|
1781
2263
|
var SKILLS_DIR = join6(".catenext", "skills");
|
|
1782
2264
|
var SkillError = class extends Error {
|
|
@@ -1785,6 +2267,7 @@ var SkillError = class extends Error {
|
|
|
1785
2267
|
this.name = "SkillError";
|
|
1786
2268
|
}
|
|
1787
2269
|
};
|
|
2270
|
+
var exec2 = promisify2(execFile2);
|
|
1788
2271
|
var FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
1789
2272
|
function parseSkill(source, fileName) {
|
|
1790
2273
|
const m = FRONTMATTER.exec(source);
|
|
@@ -1840,10 +2323,25 @@ async function listSkills(root) {
|
|
|
1840
2323
|
function skillIndex(skills) {
|
|
1841
2324
|
return skills.map((s) => ({ name: s.name, when_to_use: s.when_to_use }));
|
|
1842
2325
|
}
|
|
1843
|
-
async function loadSkill(root, name) {
|
|
2326
|
+
async function loadSkill(root, name, revision) {
|
|
1844
2327
|
const parsedName = SkillNameSchema.safeParse(name);
|
|
1845
2328
|
if (!parsedName.success) throw new SkillError(`Nama skill "${name}" tidak valid.`);
|
|
1846
2329
|
const file = `${parsedName.data}.md`;
|
|
2330
|
+
if (revision) {
|
|
2331
|
+
const sha = CommitShaSchema.safeParse(revision);
|
|
2332
|
+
if (!sha.success) throw new SkillError("Gunakan SHA commit Git lengkap untuk revisi skill.");
|
|
2333
|
+
let source2;
|
|
2334
|
+
try {
|
|
2335
|
+
source2 = (await exec2("git", ["show", `${sha.data}:${skillPath(parsedName.data)}`], { cwd: root })).stdout;
|
|
2336
|
+
} catch {
|
|
2337
|
+
throw new SkillError(
|
|
2338
|
+
`Skill "${name}" tidak tersedia pada ${sha.data}. Fetch commit itu lalu coba kembali.`
|
|
2339
|
+
);
|
|
2340
|
+
}
|
|
2341
|
+
const skill = parseSkill(source2, file);
|
|
2342
|
+
if (skill.name !== name) throw new SkillError(`${file}: name harus sama dengan nama file.`);
|
|
2343
|
+
return skill;
|
|
2344
|
+
}
|
|
1847
2345
|
let source;
|
|
1848
2346
|
try {
|
|
1849
2347
|
source = await readFile6(join6(root, SKILLS_DIR, file), "utf8");
|
|
@@ -1876,12 +2374,126 @@ async function saveSkill(root, input, now = /* @__PURE__ */ new Date()) {
|
|
|
1876
2374
|
await rename3(tmp, target);
|
|
1877
2375
|
return { path: join6(SKILLS_DIR, `${name}.md`), created, skill };
|
|
1878
2376
|
}
|
|
2377
|
+
async function committedSkillIndex(root, previous) {
|
|
2378
|
+
const config = { cwd: root };
|
|
2379
|
+
const branchRef = (await exec2("git", ["symbolic-ref", "-q", "refs/remotes/origin/HEAD"], config).catch(() => null))?.stdout.trim();
|
|
2380
|
+
const branch = (await exec2("git", ["symbolic-ref", "-q", "HEAD"], config).catch(() => null))?.stdout.trim();
|
|
2381
|
+
if (!branchRef?.startsWith("refs/remotes/origin/") || branch !== `refs/heads/${branchRef.slice("refs/remotes/origin/".length)}`)
|
|
2382
|
+
return null;
|
|
2383
|
+
const revision = CommitShaSchema.parse(
|
|
2384
|
+
(await exec2("git", ["rev-parse", branchRef], config)).stdout.trim()
|
|
2385
|
+
);
|
|
2386
|
+
const head = (await exec2("git", ["rev-parse", "HEAD"], config)).stdout.trim();
|
|
2387
|
+
if (head !== revision) return null;
|
|
2388
|
+
if (previous && previous !== revision && !await exec2("git", ["merge-base", "--is-ancestor", previous, revision], config).catch(
|
|
2389
|
+
() => null
|
|
2390
|
+
)) {
|
|
2391
|
+
throw new SkillError(
|
|
2392
|
+
"Revisi Git lokal tertinggal dari indeks Cloud. Fetch branch utama lalu coba lagi."
|
|
2393
|
+
);
|
|
2394
|
+
}
|
|
2395
|
+
const names = (await exec2("git", ["ls-tree", "-rz", "--name-only", revision, "--", SKILLS_DIR], config)).stdout.split("\0").flatMap((path) => {
|
|
2396
|
+
const file = /^\.catenext\/skills\/([^/]+)\.md$/.exec(path);
|
|
2397
|
+
return file?.[1] ? [file[1]] : [];
|
|
2398
|
+
});
|
|
2399
|
+
const skills = [];
|
|
2400
|
+
const invalid = [];
|
|
2401
|
+
for (const name of names) {
|
|
2402
|
+
try {
|
|
2403
|
+
skills.push(await loadSkill(root, name, revision));
|
|
2404
|
+
} catch (err) {
|
|
2405
|
+
invalid.push({ file: `${name}.md`, error: err.message });
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
return { revision, skills: skillIndex(skills), invalid };
|
|
2409
|
+
}
|
|
1879
2410
|
|
|
1880
|
-
// src/
|
|
2411
|
+
// src/subagents.ts
|
|
2412
|
+
import { readdir as readdir2, readFile as readFile7 } from "node:fs/promises";
|
|
2413
|
+
import { join as join7 } from "node:path";
|
|
2414
|
+
var SUBAGENTS_DIR = join7(".claude", "agents");
|
|
2415
|
+
var SUBAGENT_MARKER = "<!-- catenext:persona -->";
|
|
2416
|
+
function renderSubagent(p) {
|
|
2417
|
+
const rules = p.rules.length > 0 ? p.rules.map((r) => `- ${r}`) : ["- (belum ada aturan)"];
|
|
2418
|
+
const alias = JSON.stringify(p.alias);
|
|
2419
|
+
return [
|
|
2420
|
+
"---",
|
|
2421
|
+
`name: ${p.alias}`,
|
|
2422
|
+
`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.`,
|
|
2423
|
+
"---",
|
|
2424
|
+
SUBAGENT_MARKER,
|
|
2425
|
+
`<!-- Dibuat oleh \`catenext sync\` dari persona di Cloud; ubah persona di Dashboard, bukan file ini. -->`,
|
|
2426
|
+
"",
|
|
2427
|
+
`Anda adalah persona Catenext **${p.alias}** (role: ${p.role}).`,
|
|
2428
|
+
"",
|
|
2429
|
+
...p.repos.length > 0 ? [
|
|
2430
|
+
`Repo yang dipegang: ${p.repos.map((r) => `\`${r}\``).join(", ")}. Kerjakan dari folder checkout repo itu (yang berisi \`.catenext/config.yaml\` dengan \`repo_name\` tersebut). Bila dipanggil dari folder repo lain, pindah ke folder repo Anda dan pakai CLI di sana: \`cd <folder-${p.repos[0]}> && npx catenext next --as ${p.alias}\`.`,
|
|
2431
|
+
""
|
|
2432
|
+
] : [],
|
|
2433
|
+
"## Alur kerja (satu task per pemanggilan)",
|
|
2434
|
+
"",
|
|
2435
|
+
`1. \`get_project_context\` dengan \`agent_alias: ${alias}\`.`,
|
|
2436
|
+
`2. \`get_ready_tasks\` dengan \`agent_alias: ${alias}\`; pilih task teratas. Bila kosong, laporkan "tidak ada task untuk ${p.alias}" lalu berhenti.`,
|
|
2437
|
+
`3. \`claim_task\` dengan \`task_id\` dan \`agent_alias: ${alias}\`. Patuhi field \`persona\` di hasilnya.`,
|
|
2438
|
+
"4. Kerjakan, jalankan tes, commit di branch kerja.",
|
|
2439
|
+
"5. `complete_handoff` dengan ringkasan terstruktur, atau `report_blocker` bila buntu.",
|
|
2440
|
+
"6. Laporkan ke orchestrator (pemanggil): task apa yang selesai, status, dan perintah verifikasinya.",
|
|
2441
|
+
"",
|
|
2442
|
+
`Tanpa tool MCP: \`catenext next --as ${p.alias}\`, \`catenext claim <id> --as ${p.alias}\`, \`catenext done <id> ...\`.`,
|
|
2443
|
+
"",
|
|
2444
|
+
"## Batas subagent",
|
|
2445
|
+
"",
|
|
2446
|
+
`- Anda subagent dari orchestrator (agen utama). Hanya kerjakan task milik ${p.alias} yang didelegasikan.`,
|
|
2447
|
+
"- Task di kolom Revisi didahulukan; baca feedback revisi di hasil claim dan perbaiki di branch/PR yang sama.",
|
|
2448
|
+
"- Jangan memanggil `create_tasks`, `manage_task`, atau `upsert_persona`; perencanaan, revisi, dan assign adalah tugas orchestrator.",
|
|
2449
|
+
"",
|
|
2450
|
+
"## Aturan & batas wilayah",
|
|
2451
|
+
"",
|
|
2452
|
+
...rules,
|
|
2453
|
+
""
|
|
2454
|
+
].join("\n");
|
|
2455
|
+
}
|
|
1881
2456
|
var readOrNull2 = (p) => readFile7(p, "utf8").then(
|
|
1882
2457
|
(s) => s,
|
|
1883
2458
|
() => null
|
|
1884
2459
|
);
|
|
2460
|
+
async function planSubagents(root, personas) {
|
|
2461
|
+
const edits = [];
|
|
2462
|
+
const skipped = [];
|
|
2463
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
2464
|
+
for (const p of personas) {
|
|
2465
|
+
const path = join7(SUBAGENTS_DIR, `${p.alias}.md`);
|
|
2466
|
+
wanted.add(path);
|
|
2467
|
+
const before = await readOrNull2(join7(root, path));
|
|
2468
|
+
if (before !== null && !before.includes(SUBAGENT_MARKER)) {
|
|
2469
|
+
skipped.push(path);
|
|
2470
|
+
continue;
|
|
2471
|
+
}
|
|
2472
|
+
const after = renderSubagent(p);
|
|
2473
|
+
if (after !== before) edits.push({ path, before, after });
|
|
2474
|
+
}
|
|
2475
|
+
for (const path of await catenextSubagentFiles(root)) {
|
|
2476
|
+
if (!wanted.has(path)) {
|
|
2477
|
+
edits.push({ path, before: await readOrNull2(join7(root, path)), after: null });
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
return { edits, skipped };
|
|
2481
|
+
}
|
|
2482
|
+
async function catenextSubagentFiles(root) {
|
|
2483
|
+
const names = await readdir2(join7(root, SUBAGENTS_DIR)).catch(() => []);
|
|
2484
|
+
const out = [];
|
|
2485
|
+
for (const n of names.filter((n2) => n2.endsWith(".md")).sort()) {
|
|
2486
|
+
const path = join7(SUBAGENTS_DIR, n);
|
|
2487
|
+
if ((await readOrNull2(join7(root, path)))?.includes(SUBAGENT_MARKER)) out.push(path);
|
|
2488
|
+
}
|
|
2489
|
+
return out;
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
// src/maintenance.ts
|
|
2493
|
+
var readOrNull3 = (p) => readFile8(p, "utf8").then(
|
|
2494
|
+
(s) => s,
|
|
2495
|
+
() => null
|
|
2496
|
+
);
|
|
1885
2497
|
function countEntries(source) {
|
|
1886
2498
|
let count = 0;
|
|
1887
2499
|
let depth = 0;
|
|
@@ -1919,8 +2531,8 @@ function removeMcpEntries(source) {
|
|
|
1919
2531
|
}
|
|
1920
2532
|
function isValidJsonObject(source) {
|
|
1921
2533
|
const errors = [];
|
|
1922
|
-
const
|
|
1923
|
-
return errors.length === 0 &&
|
|
2534
|
+
const doc2 = parse4(source, errors, { allowTrailingComma: true, disallowComments: false });
|
|
2535
|
+
return errors.length === 0 && doc2 !== null && typeof doc2 === "object" && !Array.isArray(doc2);
|
|
1924
2536
|
}
|
|
1925
2537
|
function entryIsStale(entry) {
|
|
1926
2538
|
if (isAbsolute(entry.command) && !existsSync(entry.command)) return true;
|
|
@@ -1939,7 +2551,7 @@ async function planSync(opts) {
|
|
|
1939
2551
|
const edits = [];
|
|
1940
2552
|
const findings = [];
|
|
1941
2553
|
for (const adapter of ADAPTERS) {
|
|
1942
|
-
const before = await
|
|
2554
|
+
const before = await readOrNull3(join8(root, adapter.path));
|
|
1943
2555
|
if (before !== null && before.trim() !== "" && !isValidJsonObject(before)) {
|
|
1944
2556
|
if (!opts.fix) {
|
|
1945
2557
|
findings.push({
|
|
@@ -2002,12 +2614,12 @@ async function planSync(opts) {
|
|
|
2002
2614
|
);
|
|
2003
2615
|
if (after !== before) edits.push({ path: adapter.path, before, after });
|
|
2004
2616
|
}
|
|
2005
|
-
const gitignore = await
|
|
2617
|
+
const gitignore = await readOrNull3(join8(root, ".gitignore"));
|
|
2006
2618
|
const gitignoreAfter = ensureGitignore(gitignore);
|
|
2007
2619
|
if (gitignoreAfter !== gitignore) {
|
|
2008
2620
|
edits.push({ path: ".gitignore", before: gitignore, after: gitignoreAfter });
|
|
2009
2621
|
}
|
|
2010
|
-
const agents = await
|
|
2622
|
+
const agents = await readOrNull3(join8(root, AGENTS_MD));
|
|
2011
2623
|
if (agents?.includes(BLOCK_START)) {
|
|
2012
2624
|
const after = upsertAgentsBlock(agents);
|
|
2013
2625
|
if (after !== agents) edits.push({ path: AGENTS_MD, before: agents, after });
|
|
@@ -2015,23 +2627,31 @@ async function planSync(opts) {
|
|
|
2015
2627
|
return { edits, findings };
|
|
2016
2628
|
}
|
|
2017
2629
|
async function syncSkills(root, api) {
|
|
2018
|
-
const {
|
|
2019
|
-
|
|
2020
|
-
return { count:
|
|
2630
|
+
const { revision: previous } = api ? await api.post("skills/ref") : { revision: null };
|
|
2631
|
+
const index = await committedSkillIndex(root, previous);
|
|
2632
|
+
if (!index) return { count: 0, invalid: [], skipped: true };
|
|
2633
|
+
if (api && previous !== index.revision) {
|
|
2634
|
+
await api.put("skills", {
|
|
2635
|
+
revision: index.revision,
|
|
2636
|
+
previous_revision: previous,
|
|
2637
|
+
skills: index.skills
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
return { count: index.skills.length, invalid: index.invalid, skipped: false };
|
|
2021
2641
|
}
|
|
2022
2642
|
async function planRemove(opts) {
|
|
2023
2643
|
const root = resolve3(opts.root);
|
|
2024
2644
|
const edits = [];
|
|
2025
2645
|
for (const adapter of ADAPTERS) {
|
|
2026
|
-
const before = await
|
|
2646
|
+
const before = await readOrNull3(join8(root, adapter.path));
|
|
2027
2647
|
if (before === null || countEntries(before) === 0) continue;
|
|
2028
2648
|
const stripped = removeMcpEntries(before);
|
|
2029
|
-
const
|
|
2030
|
-
const servers =
|
|
2031
|
-
const emptyDoc = Object.keys(
|
|
2649
|
+
const doc2 = parse4(stripped, [], { allowTrailingComma: true });
|
|
2650
|
+
const servers = doc2?.mcpServers;
|
|
2651
|
+
const emptyDoc = Object.keys(doc2 ?? {}).every((k) => k === "mcpServers") && Object.keys(servers ?? {}).length === 0 && !/\/\/|\/\*/.test(stripped);
|
|
2032
2652
|
edits.push({ path: adapter.path, before, after: emptyDoc ? null : stripped });
|
|
2033
2653
|
}
|
|
2034
|
-
const gitignore = await
|
|
2654
|
+
const gitignore = await readOrNull3(join8(root, ".gitignore"));
|
|
2035
2655
|
if (gitignore !== null) {
|
|
2036
2656
|
const eol = gitignore.includes("\r\n") ? "\r\n" : "\n";
|
|
2037
2657
|
const lines = gitignore.split(/\r?\n/);
|
|
@@ -2043,19 +2663,22 @@ async function planRemove(opts) {
|
|
|
2043
2663
|
edits.push({ path: ".gitignore", before: gitignore, after: text2 ? `${text2}${eol}` : null });
|
|
2044
2664
|
}
|
|
2045
2665
|
}
|
|
2046
|
-
const agents = await
|
|
2666
|
+
const agents = await readOrNull3(join8(root, AGENTS_MD));
|
|
2047
2667
|
if (agents?.includes(BLOCK_START)) {
|
|
2048
2668
|
edits.push({ path: AGENTS_MD, before: agents, after: removeAgentsBlock(agents) });
|
|
2049
2669
|
}
|
|
2050
|
-
for (const p of
|
|
2051
|
-
|
|
2670
|
+
for (const p of await catenextSubagentFiles(root)) {
|
|
2671
|
+
edits.push({ path: p, before: await readOrNull3(join8(root, p)), after: null });
|
|
2672
|
+
}
|
|
2673
|
+
for (const p of [CONFIG_PATH, join8(".catenext", "cache.json")]) {
|
|
2674
|
+
const before = await readOrNull3(join8(root, p));
|
|
2052
2675
|
if (before !== null) edits.push({ path: p, before, after: null });
|
|
2053
2676
|
}
|
|
2054
2677
|
if (opts.all) {
|
|
2055
2678
|
const { skills, invalid } = await listSkills(root);
|
|
2056
2679
|
for (const f of [...skills.map((s) => `${s.name}.md`), ...invalid.map((i) => i.file)]) {
|
|
2057
|
-
const p =
|
|
2058
|
-
edits.push({ path: p, before: await
|
|
2680
|
+
const p = join8(SKILLS_DIR, f);
|
|
2681
|
+
edits.push({ path: p, before: await readOrNull3(join8(root, p)), after: null });
|
|
2059
2682
|
}
|
|
2060
2683
|
}
|
|
2061
2684
|
return edits;
|
|
@@ -2063,7 +2686,7 @@ async function planRemove(opts) {
|
|
|
2063
2686
|
async function applyFileEdits(root, edits) {
|
|
2064
2687
|
const base = resolve3(root);
|
|
2065
2688
|
for (const e of edits) {
|
|
2066
|
-
const target =
|
|
2689
|
+
const target = join8(base, e.path);
|
|
2067
2690
|
if (e.after === null) {
|
|
2068
2691
|
await rm(target, { force: true });
|
|
2069
2692
|
continue;
|
|
@@ -2074,8 +2697,8 @@ async function applyFileEdits(root, edits) {
|
|
|
2074
2697
|
await writeFile4(tmp, e.after);
|
|
2075
2698
|
await rename4(tmp, target);
|
|
2076
2699
|
}
|
|
2077
|
-
for (const dir of [SKILLS_DIR, ".catenext", ".cursor"]) {
|
|
2078
|
-
await rmdir(
|
|
2700
|
+
for (const dir of [SKILLS_DIR, ".catenext", ".cursor", SUBAGENTS_DIR, ".claude"]) {
|
|
2701
|
+
await rmdir(join8(base, dir)).catch(() => {
|
|
2079
2702
|
});
|
|
2080
2703
|
}
|
|
2081
2704
|
}
|
|
@@ -2094,7 +2717,10 @@ var SERVER_INSTRUCTIONS = [
|
|
|
2094
2717
|
"Catenext mengatur estafet task antar-agen AI untuk repo ini.",
|
|
2095
2718
|
"Alur: get_project_context -> get_ready_tasks -> claim_task -> kerjakan & tes -> complete_handoff.",
|
|
2096
2719
|
"Merencanakan: list_epics/create_epic -> create_tasks (masuk DRAFT, disetujui manusia di Web sebelum bisa dikerjakan).",
|
|
2097
|
-
"
|
|
2720
|
+
"Orchestrator = agen utama sesi (bukan subagent persona): ia merencanakan, mendelegasikan task ke subagent per persona, dan meninjau hasilnya. Revisi atas task yang sudah diserahkan memakai manage_task action request_revision (task pindah ke kolom Revisi dan diambil lagi oleh persona penanggung jawabnya); jangan membuat task baru untuk revisi. manage_task action assign menetapkan persona/role task. Subagent persona tidak memakai manage_task maupun create_tasks.",
|
|
2721
|
+
'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.',
|
|
2722
|
+
"Multi-repo: satu proyek bisa membawahi banyak repo (mis. be dan fe di folder terpisah). Orchestrator memakai get_project_board untuk melihat semua task lintas repo dan persona pemegang tiap repo, lalu mendelegasikan ke subagent yang bekerja dari folder repo tujuan.",
|
|
2723
|
+
"Dokumen proyek (blueprint, ERD, arsitektur, keputusan) tersimpan di Cloud: indeksnya di get_project_context, isi lewat get_document, perbarui lewat save_document dengan expected_version. Baca dokumen relevan di awal sesi agar konteks tidak hilang antar sesi/IDE/CLI.",
|
|
2098
2724
|
"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
2725
|
"Bila buntu, panggil report_blocker. Jangan menyalin kode atau secret ke handoff; rujuk path file.",
|
|
2100
2726
|
"Jangan mengedit .catenext/config.yaml atau file konfigurasi MCP IDE."
|
|
@@ -2156,7 +2782,8 @@ function createCatenextMcpServer(opts) {
|
|
|
2156
2782
|
async ({ api, config }) => json(
|
|
2157
2783
|
await api.post("context", {
|
|
2158
2784
|
agent_alias: input.agent_alias ?? config.overrides?.default_agent_alias,
|
|
2159
|
-
role: input.role ?? config.overrides?.default_role
|
|
2785
|
+
role: input.role ?? config.overrides?.default_role,
|
|
2786
|
+
lease_id: input.lease_id
|
|
2160
2787
|
})
|
|
2161
2788
|
)
|
|
2162
2789
|
)
|
|
@@ -2172,7 +2799,8 @@ function createCatenextMcpServer(opts) {
|
|
|
2172
2799
|
await api.post("ready-tasks", {
|
|
2173
2800
|
agent_alias: input.agent_alias ?? config.overrides?.default_agent_alias,
|
|
2174
2801
|
role: input.role ?? config.overrides?.default_role,
|
|
2175
|
-
limit: input.limit
|
|
2802
|
+
limit: input.limit,
|
|
2803
|
+
lease_id: input.lease_id
|
|
2176
2804
|
})
|
|
2177
2805
|
)
|
|
2178
2806
|
)
|
|
@@ -2180,7 +2808,15 @@ function createCatenextMcpServer(opts) {
|
|
|
2180
2808
|
server.registerTool(
|
|
2181
2809
|
"claim_task",
|
|
2182
2810
|
{ description: MCP_TOOLS.claim_task.description, inputSchema: MCP_TOOLS.claim_task.input },
|
|
2183
|
-
(input) => call(
|
|
2811
|
+
(input) => call(
|
|
2812
|
+
async ({ api, config }) => json(
|
|
2813
|
+
await api.post("claim", {
|
|
2814
|
+
task_id: input.task_id,
|
|
2815
|
+
worktree: input.worktree,
|
|
2816
|
+
agent_alias: input.agent_alias ?? config.overrides?.default_agent_alias
|
|
2817
|
+
})
|
|
2818
|
+
)
|
|
2819
|
+
)
|
|
2184
2820
|
);
|
|
2185
2821
|
server.registerTool(
|
|
2186
2822
|
"complete_handoff",
|
|
@@ -2189,7 +2825,10 @@ function createCatenextMcpServer(opts) {
|
|
|
2189
2825
|
inputSchema: MCP_TOOLS.complete_handoff.input
|
|
2190
2826
|
},
|
|
2191
2827
|
(input) => call(async ({ api }) => {
|
|
2192
|
-
const scrubbed = scrubDeep(
|
|
2828
|
+
const scrubbed = scrubDeep(
|
|
2829
|
+
input,
|
|
2830
|
+
/* @__PURE__ */ new Set(["task_id", "last_commit_hash", "head_sha", "lease_id"])
|
|
2831
|
+
);
|
|
2193
2832
|
const parsed = CompleteHandoffInput.safeParse(scrubbed.value);
|
|
2194
2833
|
if (!parsed.success) {
|
|
2195
2834
|
return text(
|
|
@@ -2215,7 +2854,7 @@ Ringkas lalu panggil complete_handoff lagi.`,
|
|
|
2215
2854
|
inputSchema: MCP_TOOLS.report_blocker.input
|
|
2216
2855
|
},
|
|
2217
2856
|
(input) => call(async ({ api }) => {
|
|
2218
|
-
const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["task_id", "category"]));
|
|
2857
|
+
const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["task_id", "category", "lease_id"]));
|
|
2219
2858
|
const parsed = ReportBlockerInput.safeParse(scrubbed.value);
|
|
2220
2859
|
if (!parsed.success) {
|
|
2221
2860
|
return text(`Laporan blocker tidak valid:
|
|
@@ -2230,6 +2869,26 @@ ${zodIssues(parsed.error)}`, true);
|
|
|
2230
2869
|
return json(await api.post("blocker", parsed.data), notes);
|
|
2231
2870
|
})
|
|
2232
2871
|
);
|
|
2872
|
+
server.registerTool(
|
|
2873
|
+
"release_task",
|
|
2874
|
+
{ description: MCP_TOOLS.release_task.description, inputSchema: MCP_TOOLS.release_task.input },
|
|
2875
|
+
(input) => call(async ({ api }) => json(await api.post("release", input)))
|
|
2876
|
+
);
|
|
2877
|
+
server.registerTool(
|
|
2878
|
+
"review_pull_request",
|
|
2879
|
+
{
|
|
2880
|
+
description: MCP_TOOLS.review_pull_request.description,
|
|
2881
|
+
inputSchema: MCP_TOOLS.review_pull_request.input
|
|
2882
|
+
},
|
|
2883
|
+
({ request }) => call(async ({ api, config }) => {
|
|
2884
|
+
const scrubbed = scrubDeep(request, /* @__PURE__ */ new Set(["task_id", "head_sha", "lease_id"]));
|
|
2885
|
+
const input = ReviewInput.parse(scrubbed.value);
|
|
2886
|
+
if (input.action === "claim" && !input.agent_alias && config.overrides?.default_role === "reviewer") {
|
|
2887
|
+
input.agent_alias = config.overrides.default_agent_alias;
|
|
2888
|
+
}
|
|
2889
|
+
return json(await api.post(input.action === "list" ? "review/list" : "review", input));
|
|
2890
|
+
})
|
|
2891
|
+
);
|
|
2233
2892
|
const scrubbedWrite = (schema, keep, send) => (input) => call(async ({ api }) => {
|
|
2234
2893
|
const scrubbed = scrubDeep(input, new Set(keep));
|
|
2235
2894
|
const parsed = schema.safeParse(scrubbed.value);
|
|
@@ -2245,6 +2904,40 @@ ${zodIssues(parsed.error)}`, true);
|
|
|
2245
2904
|
}
|
|
2246
2905
|
return json(await send(api, parsed.data), notes);
|
|
2247
2906
|
});
|
|
2907
|
+
server.registerTool(
|
|
2908
|
+
"manage_task",
|
|
2909
|
+
{ description: MCP_TOOLS.manage_task.description, inputSchema: MCP_TOOLS.manage_task.input },
|
|
2910
|
+
scrubbedWrite(
|
|
2911
|
+
ManageTaskInput,
|
|
2912
|
+
["action", "task_id", "agent_alias", "role"],
|
|
2913
|
+
(api, payload) => api.post("tasks/manage", payload)
|
|
2914
|
+
)
|
|
2915
|
+
);
|
|
2916
|
+
server.registerTool(
|
|
2917
|
+
"get_project_board",
|
|
2918
|
+
{
|
|
2919
|
+
description: MCP_TOOLS.get_project_board.description,
|
|
2920
|
+
inputSchema: MCP_TOOLS.get_project_board.input
|
|
2921
|
+
},
|
|
2922
|
+
(input) => call(async ({ api }) => json(await api.post("board", GetProjectBoardInput.parse(input))))
|
|
2923
|
+
);
|
|
2924
|
+
server.registerTool(
|
|
2925
|
+
"get_document",
|
|
2926
|
+
{ description: MCP_TOOLS.get_document.description, inputSchema: MCP_TOOLS.get_document.input },
|
|
2927
|
+
(input) => call(async ({ api }) => json(await api.post("documents/get", GetDocumentInput.parse(input))))
|
|
2928
|
+
);
|
|
2929
|
+
server.registerTool(
|
|
2930
|
+
"save_document",
|
|
2931
|
+
{
|
|
2932
|
+
description: MCP_TOOLS.save_document.description,
|
|
2933
|
+
inputSchema: MCP_TOOLS.save_document.input
|
|
2934
|
+
},
|
|
2935
|
+
scrubbedWrite(
|
|
2936
|
+
SaveDocumentInput,
|
|
2937
|
+
["slug", "kind", "expected_version"],
|
|
2938
|
+
(api, payload) => api.put("documents", payload)
|
|
2939
|
+
)
|
|
2940
|
+
);
|
|
2248
2941
|
server.registerTool(
|
|
2249
2942
|
"list_epics",
|
|
2250
2943
|
{ description: MCP_TOOLS.list_epics.description, inputSchema: MCP_TOOLS.list_epics.input },
|
|
@@ -2263,7 +2956,7 @@ ${zodIssues(parsed.error)}`, true);
|
|
|
2263
2956
|
},
|
|
2264
2957
|
scrubbedWrite(
|
|
2265
2958
|
CreateTasksInput,
|
|
2266
|
-
["epic_id", "ref", "depends_on", "target_repo", "role"],
|
|
2959
|
+
["epic_id", "ref", "depends_on", "target_repo", "role", "persona"],
|
|
2267
2960
|
(api, body) => api.post("tasks", body)
|
|
2268
2961
|
)
|
|
2269
2962
|
);
|
|
@@ -2287,17 +2980,22 @@ ${zodIssues(parsed.error)}`, true);
|
|
|
2287
2980
|
"load_skill",
|
|
2288
2981
|
{ description: MCP_TOOLS.load_skill.description, inputSchema: MCP_TOOLS.load_skill.input },
|
|
2289
2982
|
(input) => call(async ({ root }) => {
|
|
2290
|
-
const skill = await loadSkill(root, input.name);
|
|
2291
|
-
return json({
|
|
2983
|
+
const skill = await loadSkill(root, input.name, input.revision);
|
|
2984
|
+
return json({
|
|
2985
|
+
name: skill.name,
|
|
2986
|
+
when_to_use: skill.when_to_use,
|
|
2987
|
+
content: skill.content,
|
|
2988
|
+
...input.revision ? { revision: input.revision } : {}
|
|
2989
|
+
});
|
|
2292
2990
|
})
|
|
2293
2991
|
);
|
|
2294
2992
|
server.registerTool(
|
|
2295
2993
|
"save_repo_skill",
|
|
2296
2994
|
{
|
|
2297
|
-
description: `${MCP_TOOLS.save_repo_skill.description}
|
|
2995
|
+
description: `${MCP_TOOLS.save_repo_skill.description} File disimpan di checkout. Indeks Cloud diperbarui lewat sync dari branch utama.`,
|
|
2298
2996
|
inputSchema: MCP_TOOLS.save_repo_skill.input
|
|
2299
2997
|
},
|
|
2300
|
-
(input) => call(async ({
|
|
2998
|
+
(input) => call(async ({ root }) => {
|
|
2301
2999
|
const scrubbed = scrubDeep(input, /* @__PURE__ */ new Set(["name"]));
|
|
2302
3000
|
const parsed = SaveRepoSkillInput.safeParse(scrubbed.value);
|
|
2303
3001
|
if (!parsed.success) {
|
|
@@ -2315,14 +3013,7 @@ Ringkas (rujuk path file, jangan menyalin kode) lalu coba lagi.`,
|
|
|
2315
3013
|
notes.push(note);
|
|
2316
3014
|
}
|
|
2317
3015
|
const saved = await saveSkill(root, parsed.data);
|
|
2318
|
-
|
|
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
|
-
}
|
|
3016
|
+
notes.push("Commit dan merge file skill, lalu jalankan catenext sync di branch utama.");
|
|
2326
3017
|
return json({ path: saved.path, created: saved.created }, notes);
|
|
2327
3018
|
})
|
|
2328
3019
|
);
|
|
@@ -2381,8 +3072,8 @@ async function runMcpServer(opts) {
|
|
|
2381
3072
|
}
|
|
2382
3073
|
|
|
2383
3074
|
// src/verify.ts
|
|
2384
|
-
import { readFile as
|
|
2385
|
-
import { join as
|
|
3075
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
3076
|
+
import { join as join9 } from "node:path";
|
|
2386
3077
|
async function verifySetup(root, config) {
|
|
2387
3078
|
const lines = [];
|
|
2388
3079
|
let tokenLine;
|
|
@@ -2422,7 +3113,7 @@ async function verifySetup(root, config) {
|
|
|
2422
3113
|
const missing = [];
|
|
2423
3114
|
const stale = [];
|
|
2424
3115
|
for (const adapter of ADAPTERS) {
|
|
2425
|
-
const src = await
|
|
3116
|
+
const src = await readFile9(join9(root, adapter.path), "utf8").catch(() => null);
|
|
2426
3117
|
const entry = src ? readMcpEntry(src) : null;
|
|
2427
3118
|
if (!entry) missing.push(adapter.label);
|
|
2428
3119
|
else if (entryIsStale(entry)) stale.push(adapter.label);
|
|
@@ -2446,14 +3137,14 @@ function formatChecks(lines) {
|
|
|
2446
3137
|
}
|
|
2447
3138
|
|
|
2448
3139
|
// src/index.ts
|
|
2449
|
-
var VERSION = "0.
|
|
3140
|
+
var VERSION = "0.3.0";
|
|
2450
3141
|
var program = new Command();
|
|
2451
3142
|
program.name("catenext").description("Estafet tugas & konteks antar-agen AI coding").version(VERSION);
|
|
2452
3143
|
async function friendly(fn) {
|
|
2453
3144
|
try {
|
|
2454
3145
|
await fn();
|
|
2455
3146
|
} catch (err) {
|
|
2456
|
-
if (err instanceof ConfigError || err instanceof CredentialsError || err instanceof McpConfigError || err instanceof PlanningInputError) {
|
|
3147
|
+
if (err instanceof ConfigError || err instanceof CredentialsError || err instanceof McpConfigError || err instanceof SkillError || err instanceof PlanningInputError) {
|
|
2457
3148
|
console.error(`\u2717 ${err.message}`);
|
|
2458
3149
|
process.exitCode = 1;
|
|
2459
3150
|
return;
|
|
@@ -2592,21 +3283,43 @@ persona.command("set").description("Buat atau perbarui persona khusus proyek ini
|
|
|
2592
3283
|
"Aturan kerja (boleh diulang)",
|
|
2593
3284
|
(v, prev) => [...prev, v],
|
|
2594
3285
|
[]
|
|
3286
|
+
).option(
|
|
3287
|
+
"--repo <name>",
|
|
3288
|
+
"Repo yang dipegang persona di proyek ini, mis. be (boleh diulang)",
|
|
3289
|
+
(v, prev) => [...prev ?? [], v]
|
|
2595
3290
|
).option("--json", "Keluaran JSON").action(
|
|
2596
3291
|
(alias, opts) => friendly(
|
|
2597
|
-
async () => personaSet(await cliApi(), alias, opts.role, opts.rule, Boolean(opts.json))
|
|
3292
|
+
async () => personaSet(await cliApi(), alias, opts.role, opts.rule, Boolean(opts.json), opts.repo)
|
|
2598
3293
|
)
|
|
2599
3294
|
);
|
|
3295
|
+
program.command("board").description("Orchestrator: papan proyek lintas repo (task, status, persona, repo)").option("--epic <id>", "Batasi ke satu epic").option(
|
|
3296
|
+
"--status <status>",
|
|
3297
|
+
"Filter status (boleh diulang)",
|
|
3298
|
+
(v, p) => [...p, v],
|
|
3299
|
+
[]
|
|
3300
|
+
).option("--json", "Keluaran JSON").action(
|
|
3301
|
+
(opts) => friendly(async () => boardShow(await cliApi(), opts))
|
|
3302
|
+
);
|
|
3303
|
+
var doc = program.command("doc").description("Dokumen proyek di Cloud (blueprint, ERD, arsitektur, keputusan)");
|
|
3304
|
+
doc.command("list").option("--json", "Keluaran JSON").action(
|
|
3305
|
+
(opts) => friendly(async () => docList(await cliApi(), Boolean(opts.json)))
|
|
3306
|
+
);
|
|
3307
|
+
doc.command("get").argument("<slug>").option("--json", "Keluaran JSON").action(
|
|
3308
|
+
(slug, opts) => friendly(async () => docGet(await cliApi(), slug, Boolean(opts.json)))
|
|
3309
|
+
);
|
|
3310
|
+
doc.command("save").argument("<slug>", "Slug dokumen, mis. blueprint atau erd").requiredOption("--file <path>", "File Markdown berisi dokumen").option("--title <text>", "Judul dokumen (default: slug)").option("--kind <kind>", `Salah satu: ${DOCUMENT_KINDS.join(", ")}`, "other").option("--version <n>", "Versi yang Anda baca (0 = dokumen baru); mencegah menimpa sesi lain").option("--json", "Keluaran JSON").action(
|
|
3311
|
+
(slug, opts) => friendly(async () => docSave(await cliApi(), slug, opts))
|
|
3312
|
+
);
|
|
2600
3313
|
var collect = (v, prev) => [...prev, v];
|
|
2601
3314
|
var AGENT_OPT = [
|
|
2602
3315
|
"--agent <name>",
|
|
2603
3316
|
"Nama agen untuk log aktivitas, mis. codex",
|
|
2604
3317
|
"catenext-cli"
|
|
2605
3318
|
];
|
|
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(
|
|
3319
|
+
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
3320
|
(opts) => friendly(async () => taskNext(await cliApi(opts.agent), opts))
|
|
2608
3321
|
);
|
|
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(
|
|
3322
|
+
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
3323
|
(taskId, opts) => friendly(async () => taskClaim(await cliApi(opts.agent), taskId, opts))
|
|
2611
3324
|
);
|
|
2612
3325
|
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 +3332,106 @@ program.command("done").description("Selesaikan task dengan handoff terstruktur
|
|
|
2619
3332
|
"File yang diubah (boleh diulang; default dari git)",
|
|
2620
3333
|
collect,
|
|
2621
3334
|
[]
|
|
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(
|
|
3335
|
+
).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
3336
|
(taskId, opts) => friendly(async () => taskDone(await cliApi(opts.agent), taskId, opts))
|
|
2624
3337
|
);
|
|
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(
|
|
3338
|
+
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
3339
|
(taskId, opts) => friendly(async () => taskBlock(await cliApi(opts.agent), taskId, opts))
|
|
2627
3340
|
);
|
|
3341
|
+
program.command("release").description("Lepas task untuk sesi lain").argument("<task_id>").option("--lease <id>", "Lease worktree dari claim").option(...AGENT_OPT).action(
|
|
3342
|
+
(taskId, opts) => friendly(async () => {
|
|
3343
|
+
const input = prepare(ReleaseTaskInput, { task_id: taskId, lease_id: opts.lease }, [
|
|
3344
|
+
"task_id",
|
|
3345
|
+
"lease_id"
|
|
3346
|
+
]);
|
|
3347
|
+
const api = await cliApi(opts.agent);
|
|
3348
|
+
console.log(JSON.stringify(await api.post("release", input), null, 2));
|
|
3349
|
+
})
|
|
3350
|
+
);
|
|
3351
|
+
program.command("revise").description(
|
|
3352
|
+
"Orchestrator: kembalikan task NEEDS_REVIEW/DONE ke kolom Revisi (bukan task baru; setara manage_task)"
|
|
3353
|
+
).argument("<task_id>").requiredOption("--feedback <text>", "Apa yang harus diperbaiki (min. 5 karakter)").option("--to <alias>", "Ganti persona penanggung jawab revisi").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
|
|
3354
|
+
(taskId, opts) => friendly(
|
|
3355
|
+
async () => taskManage(
|
|
3356
|
+
await cliApi(opts.agent),
|
|
3357
|
+
{
|
|
3358
|
+
action: "request_revision",
|
|
3359
|
+
task_id: taskId,
|
|
3360
|
+
feedback: opts.feedback,
|
|
3361
|
+
...opts.to ? { agent_alias: opts.to } : {}
|
|
3362
|
+
},
|
|
3363
|
+
Boolean(opts.json)
|
|
3364
|
+
)
|
|
3365
|
+
)
|
|
3366
|
+
);
|
|
3367
|
+
program.command("assign").description(
|
|
3368
|
+
"Orchestrator: tetapkan persona atau role penanggung jawab task (setara manage_task)"
|
|
3369
|
+
).argument("<task_id>").option("--to <alias>", "Persona penanggung jawab").option("--role <role>", "Role task tanpa persona tertentu").option("--unassign", "Lepas persona (task diambil berdasarkan role)").option(...AGENT_OPT).option("--json", "Keluaran JSON").action(
|
|
3370
|
+
(taskId, opts) => friendly(
|
|
3371
|
+
async () => taskManage(
|
|
3372
|
+
await cliApi(opts.agent),
|
|
3373
|
+
{
|
|
3374
|
+
action: "assign",
|
|
3375
|
+
task_id: taskId,
|
|
3376
|
+
...opts.unassign ? { agent_alias: null } : opts.to ? { agent_alias: opts.to } : {},
|
|
3377
|
+
...opts.role ? { role: opts.role } : {}
|
|
3378
|
+
},
|
|
3379
|
+
Boolean(opts.json)
|
|
3380
|
+
)
|
|
3381
|
+
)
|
|
3382
|
+
);
|
|
3383
|
+
var review = program.command("review").description("Antrean dan keputusan review pull request");
|
|
3384
|
+
review.command("list").option("-n, --limit <n>", "Jumlah maksimal", Number, 10).option(...AGENT_OPT).option("--json").action(
|
|
3385
|
+
(opts) => friendly(
|
|
3386
|
+
async () => taskReview(
|
|
3387
|
+
await cliApi(opts.agent),
|
|
3388
|
+
{ action: "list", limit: opts.limit },
|
|
3389
|
+
Boolean(opts.json)
|
|
3390
|
+
)
|
|
3391
|
+
)
|
|
3392
|
+
);
|
|
3393
|
+
review.command("claim").argument("<task_id>").option("--as <alias>", "Persona reviewer").option(...AGENT_OPT).option("--json").action(
|
|
3394
|
+
(taskId, opts) => friendly(
|
|
3395
|
+
async () => taskReview(
|
|
3396
|
+
await cliApi(opts.agent),
|
|
3397
|
+
{ action: "claim", task_id: taskId, agent_alias: opts.as },
|
|
3398
|
+
Boolean(opts.json)
|
|
3399
|
+
)
|
|
3400
|
+
)
|
|
3401
|
+
);
|
|
3402
|
+
review.command("refresh").argument("<task_id>").option(...AGENT_OPT).option("--json").action(
|
|
3403
|
+
(taskId, opts) => friendly(
|
|
3404
|
+
async () => taskReview(
|
|
3405
|
+
await cliApi(opts.agent),
|
|
3406
|
+
{ action: "refresh", task_id: taskId },
|
|
3407
|
+
Boolean(opts.json)
|
|
3408
|
+
)
|
|
3409
|
+
)
|
|
3410
|
+
);
|
|
3411
|
+
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(
|
|
3412
|
+
(taskId, opts) => friendly(
|
|
3413
|
+
async () => taskReview(
|
|
3414
|
+
await cliApi(opts.agent),
|
|
3415
|
+
{
|
|
3416
|
+
action: "submit",
|
|
3417
|
+
task_id: taskId,
|
|
3418
|
+
lease_id: opts.lease,
|
|
3419
|
+
head_sha: opts.sha,
|
|
3420
|
+
decision: opts.decision,
|
|
3421
|
+
feedback: opts.feedback
|
|
3422
|
+
},
|
|
3423
|
+
Boolean(opts.json)
|
|
3424
|
+
)
|
|
3425
|
+
)
|
|
3426
|
+
);
|
|
3427
|
+
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(
|
|
3428
|
+
(name, opts) => friendly(async () => {
|
|
3429
|
+
const skill = await loadSkill(await requireRoot(), name, opts.revision);
|
|
3430
|
+
console.log(
|
|
3431
|
+
opts.json ? JSON.stringify({ ...skill, revision: opts.revision }, null, 2) : skill.content
|
|
3432
|
+
);
|
|
3433
|
+
})
|
|
3434
|
+
);
|
|
2628
3435
|
async function requireRoot() {
|
|
2629
3436
|
const root = await findProjectRoot();
|
|
2630
3437
|
if (!root) {
|
|
@@ -2656,9 +3463,9 @@ program.command("sync").description("Selaraskan entri MCP, .gitignore, blok AGEN
|
|
|
2656
3463
|
for (const f of plan.findings) console.log(`${f.level === "ok" ? "\u2022" : "!"} ${f.message}`);
|
|
2657
3464
|
if (opts.dryRun) {
|
|
2658
3465
|
for (const l of summarize(plan.edits)) console.log(l);
|
|
2659
|
-
const { count, invalid } = await syncSkills(root, null);
|
|
3466
|
+
const { count, invalid, skipped } = await syncSkills(root, null);
|
|
2660
3467
|
console.log(
|
|
2661
|
-
`(dry-run) ${plan.edits.length} file akan berubah; indeks ${count} skill akan dikirim.`
|
|
3468
|
+
`(dry-run) ${plan.edits.length} file akan berubah; ${skipped ? "indeks skill tidak akan diubah." : `indeks ${count} skill akan dikirim.`}`
|
|
2662
3469
|
);
|
|
2663
3470
|
for (const i of invalid) console.log(`! Skill dilewati: ${i.error}`);
|
|
2664
3471
|
return;
|
|
@@ -2668,12 +3475,24 @@ program.command("sync").description("Selaraskan entri MCP, .gitignore, blok AGEN
|
|
|
2668
3475
|
const fixable = plan.findings.some((f) => f.level === "fixable");
|
|
2669
3476
|
if (plan.edits.length === 0 && !fixable) console.log("\u2713 File lokal sudah selaras.");
|
|
2670
3477
|
try {
|
|
2671
|
-
const
|
|
2672
|
-
|
|
3478
|
+
const api = await cliApi();
|
|
3479
|
+
const { count, invalid, skipped } = await syncSkills(root, api);
|
|
3480
|
+
console.log(
|
|
3481
|
+
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).`
|
|
3482
|
+
);
|
|
2673
3483
|
for (const i of invalid) console.log(`! Skill dilewati: ${i.error}`);
|
|
3484
|
+
const { personas } = await api.post("personas/list");
|
|
3485
|
+
const sub = await planSubagents(root, personas);
|
|
3486
|
+
await applyFileEdits(root, sub.edits);
|
|
3487
|
+
for (const l of summarize(sub.edits)) console.log(l);
|
|
3488
|
+
for (const s of sub.skipped)
|
|
3489
|
+
console.log(`! ${s} sudah ada dan bukan buatan Catenext; tidak ditimpa.`);
|
|
3490
|
+
console.log(
|
|
3491
|
+
`\u2713 ${personas.length} persona tersedia sebagai subagent Claude Code di ${SUBAGENTS_DIR}/.`
|
|
3492
|
+
);
|
|
2674
3493
|
} catch (err) {
|
|
2675
3494
|
if (!(err instanceof CredentialsError || err instanceof ApiRequestError)) throw err;
|
|
2676
|
-
console.log(`!
|
|
3495
|
+
console.log(`! Skill/persona belum tersinkron: ${err.message}`);
|
|
2677
3496
|
}
|
|
2678
3497
|
console.log("");
|
|
2679
3498
|
console.log(formatChecks(await verifySetup(root, config)));
|